Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

import net.countercraft.movecraft.combat.features.*;
import net.countercraft.movecraft.combat.features.combat.CombatRelease;
import net.countercraft.movecraft.combat.features.directors.AADirectors;
import net.countercraft.movecraft.combat.features.directors.ArrowDirectors;
import net.countercraft.movecraft.combat.features.directors.CannonDirectors;
import net.countercraft.movecraft.combat.features.directors.Directors;
import net.countercraft.movecraft.combat.features.directors.*;
import net.countercraft.movecraft.combat.features.tracers.MovementTracers;
import net.countercraft.movecraft.combat.features.tracers.TNTTracers;
import net.countercraft.movecraft.combat.features.tracers.commands.MovementTracerSettingCommand;
Expand Down Expand Up @@ -85,6 +82,7 @@ public void onEnable() {
FireballPenetration.load(getConfig());
ReImplementTNTTranslocation.load(getConfig());
BlockBehaviorOverride.load(getConfig());
DirectorElytraListener.load(getConfig());

// Register event translation listeners
getServer().getPluginManager().registerEvents(new CraftCollisionExplosionListener(), this);
Expand All @@ -104,6 +102,8 @@ public void onEnable() {
var cannonDirectors = new CannonDirectors();
getServer().getPluginManager().registerEvents(cannonDirectors, this);
cannonDirectors.runTaskTimer(this, 0, 1); // Every tick
var DirectorElytra = new DirectorElytraListener();
getServer().getPluginManager().registerEvents(DirectorElytra, this);

var playerManager = new PlayerManager();
getServer().getPluginManager().registerEvents(playerManager, this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import java.util.HashMap;
import java.util.HashSet;

import static net.countercraft.movecraft.util.ChatUtils.ERROR_PREFIX;
import static net.countercraft.movecraft.util.ChatUtils.errorPrefix;

public class CombatRelease extends BukkitRunnable implements Listener {
public static boolean EnableCombatReleaseTracking = false;
Expand Down Expand Up @@ -181,7 +181,7 @@ public void onCraftScuttle(@NotNull CraftScuttleEvent e) {
return;

e.setCancelled(true);
cause.sendMessage(ERROR_PREFIX + " You may not scuttle while in combat!");
cause.sendMessage(errorPrefix() + " You may not scuttle while in combat!");
}

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
import net.countercraft.movecraft.craft.type.CraftType;
import net.countercraft.movecraft.craft.type.property.BooleanProperty;
import net.countercraft.movecraft.util.MathUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.NamespacedKey;
import org.bukkit.World;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
import org.bukkit.configuration.file.FileConfiguration;
Expand All @@ -28,11 +25,12 @@
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;

import static net.countercraft.movecraft.util.ChatUtils.ERROR_PREFIX;
import static net.countercraft.movecraft.util.ChatUtils.errorPrefix;

public class AADirectors extends Directors implements Listener {
public static final NamespacedKey ALLOW_AA_DIRECTOR_SIGN = new NamespacedKey("movecraft-combat", "allow_aa_director_sign");
private static final String HEADER = "AA Director";
private static boolean DisableDirectorElytra = false;
public static int AADirectorDistance = 50;
public static int AADirectorRange = 120;
private long lastCheck = 0;
Expand All @@ -48,6 +46,7 @@ public static void register() {
public static void load(@NotNull FileConfiguration config) {
AADirectorDistance = config.getInt("AADirectorDistance", 50);
AADirectorRange = config.getInt("AADirectorRange", 120);
DisableDirectorElytra = config.getBoolean("DisableDirectorElytra", false);
}

@Override
Expand Down Expand Up @@ -174,12 +173,12 @@ public void onSignClick(@NotNull PlayerInteractEvent e) {

Player p = e.getPlayer();
if (foundCraft == null) {
p.sendMessage(ERROR_PREFIX + " " + I18nSupport.getInternationalisedString("Sign - Must Be Part Of Craft"));
p.sendMessage(errorPrefix() + " " + I18nSupport.getInternationalisedString("Sign - Must Be Part Of Craft"));
return;
}

if (!foundCraft.getType().getBoolProperty(ALLOW_AA_DIRECTOR_SIGN)) {
p.sendMessage(ERROR_PREFIX + " " + I18nSupport.getInternationalisedString("AADirector - Not Allowed On Craft"));
p.sendMessage(errorPrefix() + " " + I18nSupport.getInternationalisedString("AADirector - Not Allowed On Craft"));
return;
}

Expand All @@ -192,6 +191,17 @@ public void onSignClick(@NotNull PlayerInteractEvent e) {
return;
}

// check if the player has an elytra on
if (DisableDirectorElytra) {
if (p.getInventory().getChestplate() != null) {
if (p.getInventory().getChestplate().getType().equals(Material.ELYTRA)) {
p.sendMessage(I18nSupport.getInternationalisedString("AADirector - No Elytra While Directing"));
clearDirector(p);
return;
}
}
}

clearDirector(p);
addDirector(foundCraft, p);
p.sendMessage(I18nSupport.getInternationalisedString("AADirector - Directing"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;

import static net.countercraft.movecraft.util.ChatUtils.ERROR_PREFIX;
import static net.countercraft.movecraft.util.ChatUtils.errorPrefix;

public class ArrowDirectors extends Directors implements Listener {
public static final NamespacedKey ALLOW_ARROW_DIRECTOR_SIGN = new NamespacedKey("movecraft-combat", "allow_arrow_director_sign");
private static final String HEADER = "Arrow Director";
private static boolean DisableDirectorElytra = false;
public static int ArrowDirectorDistance = 50;
public static int ArrowDirectorRange = 120;
private long lastCheck = 0;
Expand All @@ -46,6 +47,7 @@ public static void register() {
public static void load(@NotNull FileConfiguration config) {
ArrowDirectorDistance = config.getInt("ArrowDirectorDistance", 50);
ArrowDirectorRange = config.getInt("ArrowDirectorRange", 120);
DisableDirectorElytra = config.getBoolean("DisableDirectorElytra", false);
}

@Override
Expand Down Expand Up @@ -171,12 +173,12 @@ public void onSignClick(@NotNull PlayerInteractEvent e) {

Player p = e.getPlayer();
if (foundCraft == null) {
p.sendMessage(ERROR_PREFIX + " " + I18nSupport.getInternationalisedString("Sign - Must Be Part Of Craft"));
p.sendMessage(errorPrefix() + " " + I18nSupport.getInternationalisedString("Sign - Must Be Part Of Craft"));
return;
}

if (!foundCraft.getType().getBoolProperty(ALLOW_ARROW_DIRECTOR_SIGN)) {
p.sendMessage(ERROR_PREFIX + " " + I18nSupport.getInternationalisedString("ArrowDirector - Not Allowed On Craft"));
p.sendMessage(errorPrefix() + " " + I18nSupport.getInternationalisedString("ArrowDirector - Not Allowed On Craft"));
return;
}

Expand All @@ -189,6 +191,17 @@ public void onSignClick(@NotNull PlayerInteractEvent e) {
return;
}

// check if the player has an elytra on
if (DisableDirectorElytra) {
if (p.getInventory().getChestplate() != null) {
if (p.getInventory().getChestplate().getType().equals(Material.ELYTRA)) {
p.sendMessage(I18nSupport.getInternationalisedString("ArrowDirector - No Elytra While Directing"));
clearDirector(p);
return;
}
}
}

clearDirector(p);
addDirector(foundCraft, p);
p.sendMessage(I18nSupport.getInternationalisedString("ArrowDirector - Directing"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@
import java.util.List;
import java.util.UUID;

import static net.countercraft.movecraft.util.ChatUtils.ERROR_PREFIX;
import static net.countercraft.movecraft.util.ChatUtils.errorPrefix;

public class CannonDirectors extends Directors implements Listener {
public static final NamespacedKey ALLOW_CANNON_DIRECTOR_SIGN = new NamespacedKey("movecraft-combat", "allow_cannon_director_sign");
private static final String HEADER = "Cannon Director";
private static boolean DisableDirectorElytra = false;
public static int CannonDirectorDistance = 100;
public static int CannonDirectorRange = 120;
private final Object2DoubleOpenHashMap<TNTPrimed> tracking = new Object2DoubleOpenHashMap<>();
Expand All @@ -61,6 +62,7 @@ public static void register() {
public static void load(@NotNull FileConfiguration config) {
CannonDirectorDistance = config.getInt("CannonDirectorDistance", 100);
CannonDirectorRange = config.getInt("CannonDirectorRange", 120);
DisableDirectorElytra = config.getBoolean("DisableDirectorElytra", false);
}

@Override
Expand Down Expand Up @@ -208,12 +210,12 @@ public final void onSignClick(@NotNull PlayerInteractEvent e) {

Player p = e.getPlayer();
if (foundCraft == null) {
p.sendMessage(ERROR_PREFIX + " " + I18nSupport.getInternationalisedString("Sign - Must Be Part Of Craft"));
p.sendMessage(errorPrefix() + " " + I18nSupport.getInternationalisedString("Sign - Must Be Part Of Craft"));
return;
}

if (!foundCraft.getType().getBoolProperty(ALLOW_CANNON_DIRECTOR_SIGN)) {
p.sendMessage(ERROR_PREFIX + " " + I18nSupport.getInternationalisedString("CannonDirector - Not Allowed On Craft"));
p.sendMessage(errorPrefix() + " " + I18nSupport.getInternationalisedString("CannonDirector - Not Allowed On Craft"));
return;
}

Expand All @@ -226,6 +228,17 @@ public final void onSignClick(@NotNull PlayerInteractEvent e) {
return;
}

// check if the player has an elytra on
if (DisableDirectorElytra) {
if (p.getInventory().getChestplate() != null) {
if (p.getInventory().getChestplate().getType().equals(Material.ELYTRA)) {
p.sendMessage(I18nSupport.getInternationalisedString("CannonDirector - No Elytra While Directing"));
clearDirector(p);
return;
}
}
}

clearDirector(p);
addDirector(foundCraft, p);
p.sendMessage(I18nSupport.getInternationalisedString("CannonDirector - Directing"));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package net.countercraft.movecraft.combat.features.directors;

import com.destroystokyo.paper.event.player.PlayerArmorChangeEvent;
import net.countercraft.movecraft.combat.localisation.I18nSupport;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.jetbrains.annotations.NotNull;

/**
* Determines when a player swaps an elytra on themselves
*/
public class DirectorElytraListener extends Directors implements Listener {
private static boolean DisableDirectorElytra = false;

public static void load(@NotNull FileConfiguration config) {
DisableDirectorElytra = config.getBoolean("DisableDirectorElytra", false);
}

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void ElytraEquipEvent(@NotNull PlayerArmorChangeEvent e) {
Player p = e.getPlayer();

if (!DisableDirectorElytra)
return;

// If the player equips an elytra, remove their directors
if (e.getNewItem().getType().equals(Material.ELYTRA)) {
clearDirector(p);
p.sendMessage(I18nSupport.getInternationalisedString("Director - No Elytra While Directing"));
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import java.util.ArrayList;
import java.util.List;

import static net.countercraft.movecraft.util.ChatUtils.MOVECRAFT_COMMAND_PREFIX;
import static net.countercraft.movecraft.util.ChatUtils.commandPrefix;

public class MovementTracerSettingCommand implements TabExecutor {
@NotNull
Expand All @@ -29,28 +29,28 @@ public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command
return false;

if(!(commandSender instanceof Player)) {
commandSender.sendMessage(MOVECRAFT_COMMAND_PREFIX + I18nSupport.getInternationalisedString("Command - Must Be Player"));
commandSender.sendMessage(commandPrefix() + I18nSupport.getInternationalisedString("Command - Must Be Player"));
return true;
}
Player player = (Player) commandSender;

if(args.length == 0) {
commandSender.sendMessage(MOVECRAFT_COMMAND_PREFIX + I18nSupport.getInternationalisedString("Command - Current Setting") + ": " + manager.getMovementSetting(player));
commandSender.sendMessage(commandPrefix() + I18nSupport.getInternationalisedString("Command - Current Setting") + ": " + manager.getMovementSetting(player));
return true;
}
if (args.length != 1) {
commandSender.sendMessage(MOVECRAFT_COMMAND_PREFIX + I18nSupport.getInternationalisedString("Command - Specify Setting"));
commandSender.sendMessage(commandPrefix() + I18nSupport.getInternationalisedString("Command - Specify Setting"));
return true;
}

String setting = args[0].toUpperCase();
try {
manager.setMovementSetting(player, setting);
commandSender.sendMessage(MOVECRAFT_COMMAND_PREFIX + I18nSupport.getInternationalisedString("Command - Movement Tracer Set") + ": " + setting);
commandSender.sendMessage(commandPrefix() + I18nSupport.getInternationalisedString("Command - Movement Tracer Set") + ": " + setting);
return true;
}
catch (IllegalArgumentException e) {
commandSender.sendMessage(MOVECRAFT_COMMAND_PREFIX + I18nSupport.getInternationalisedString("Command - Specify Valid Setting"));
commandSender.sendMessage(commandPrefix() + I18nSupport.getInternationalisedString("Command - Specify Valid Setting"));
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import java.util.ArrayList;
import java.util.List;

import static net.countercraft.movecraft.util.ChatUtils.MOVECRAFT_COMMAND_PREFIX;
import static net.countercraft.movecraft.util.ChatUtils.commandPrefix;

public class TNTTracerModeCommand implements TabExecutor {
@NotNull
Expand All @@ -29,28 +29,28 @@ public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command
return false;

if (!(commandSender instanceof Player)) {
commandSender.sendMessage(MOVECRAFT_COMMAND_PREFIX + I18nSupport.getInternationalisedString("Command - Must Be Player"));
commandSender.sendMessage(commandPrefix() + I18nSupport.getInternationalisedString("Command - Must Be Player"));
return true;
}
Player player = (Player) commandSender;

if (args.length == 0) {
commandSender.sendMessage(MOVECRAFT_COMMAND_PREFIX + I18nSupport.getInternationalisedString("Command - Current Mode") + ": " + manager.getTNTMode(player));
commandSender.sendMessage(commandPrefix() + I18nSupport.getInternationalisedString("Command - Current Mode") + ": " + manager.getTNTMode(player));
return true;
}
if (args.length != 1) {
commandSender.sendMessage(MOVECRAFT_COMMAND_PREFIX + I18nSupport.getInternationalisedString("Command - Specify Mode"));
commandSender.sendMessage(commandPrefix() + I18nSupport.getInternationalisedString("Command - Specify Mode"));
return true;
}

String mode = args[0].toUpperCase();
try {
manager.setTNTMode(player, mode);
commandSender.sendMessage(MOVECRAFT_COMMAND_PREFIX + I18nSupport.getInternationalisedString("Command - Tracer Set") + ": " + mode);
commandSender.sendMessage(commandPrefix() + I18nSupport.getInternationalisedString("Command - Tracer Set") + ": " + mode);
return true;
}
catch (IllegalArgumentException e) {
commandSender.sendMessage(MOVECRAFT_COMMAND_PREFIX + I18nSupport.getInternationalisedString("Command - Specify Valid Mode"));
commandSender.sendMessage(commandPrefix() + I18nSupport.getInternationalisedString("Command - Specify Valid Mode"));
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import java.util.ArrayList;
import java.util.List;

import static net.countercraft.movecraft.util.ChatUtils.MOVECRAFT_COMMAND_PREFIX;
import static net.countercraft.movecraft.util.ChatUtils.commandPrefix;

public class TNTTracerSettingCommand implements TabExecutor {
@NotNull
Expand All @@ -29,28 +29,28 @@ public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command
return false;

if (!(commandSender instanceof Player)) {
commandSender.sendMessage(MOVECRAFT_COMMAND_PREFIX + I18nSupport.getInternationalisedString("Command - Must Be Player"));
commandSender.sendMessage(commandPrefix() + I18nSupport.getInternationalisedString("Command - Must Be Player"));
return true;
}
Player player = (Player) commandSender;

if (args.length == 0) {
commandSender.sendMessage(MOVECRAFT_COMMAND_PREFIX + I18nSupport.getInternationalisedString("Command - Current Setting") + ": " + manager.getTNTSetting(player));
commandSender.sendMessage(commandPrefix() + I18nSupport.getInternationalisedString("Command - Current Setting") + ": " + manager.getTNTSetting(player));
return true;
}
if (args.length != 1) {
commandSender.sendMessage(MOVECRAFT_COMMAND_PREFIX + I18nSupport.getInternationalisedString("Command - Specify Setting"));
commandSender.sendMessage(commandPrefix() + I18nSupport.getInternationalisedString("Command - Specify Setting"));
return true;
}

String setting = args[0].toUpperCase();
try {
manager.setTNTSetting(player, setting);
commandSender.sendMessage(MOVECRAFT_COMMAND_PREFIX + I18nSupport.getInternationalisedString("Command - Tracer Set") + ": " + setting);
commandSender.sendMessage(commandPrefix() + I18nSupport.getInternationalisedString("Command - Tracer Set") + ": " + setting);
return true;
}
catch (IllegalArgumentException e) {
commandSender.sendMessage(MOVECRAFT_COMMAND_PREFIX + I18nSupport.getInternationalisedString("Command - Specify Valid Setting"));
commandSender.sendMessage(commandPrefix() + I18nSupport.getInternationalisedString("Command - Specify Valid Setting"));
return true;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ CannonDirectorRange: 120 # Max range at which it will direct to a block vs in th

# Directors
DirectorTool: STICK # Material name for director control.
DisableDirectorElytra: false # Disables the ability for players with elytras equipped to use directors
TransparentBlocks: # List of MATERIAL_NAMES which are ignored for directing. See https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html for a full list.
- "#glass"
- IRON_BARS
Expand Down
Loading
Loading