diff --git a/src/main/java/com/snowleopard1863/APTurrets/TracerManager.java b/src/main/java/com/snowleopard1863/APTurrets/TracerManager.java deleted file mode 100644 index 987d9c7..0000000 --- a/src/main/java/com/snowleopard1863/APTurrets/TracerManager.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.snowleopard1863.APTurrets; - -import org.bukkit.entity.Arrow; -import org.bukkit.entity.Player; -import org.bukkit.metadata.FixedMetadataValue; - -import java.util.HashSet; - -public class TracerManager { - private final HashSet tracedArrows = new HashSet<>(); - - public void disable() { - tracedArrows.clear(); - } - - public boolean isTraced(Arrow a) { - return tracedArrows.contains(a); - } - - public HashSet getTracedArrows() { - return tracedArrows; - } - - public void removeTracedArrow(Arrow a) { - tracedArrows.remove(a); - } - - public void startTracing(Arrow arrow) { - arrow.setMetadata("tracer", new FixedMetadataValue(TurretsMain.getInstance(), true)); - tracedArrows.add(arrow); - arrow.setCritical(false); - - try { - Object packet = TurretsMain.getInstance().getNMUtils().getNMClass("PacketPlayOutEntityDestroy").getConstructor(int[].class).newInstance(new int[]{arrow.getEntityId()}); - for(Player p : TurretsMain.getInstance().getServer().getOnlinePlayers()) { - Object nmsPlayer = p.getClass().getMethod("getHandle").invoke(p); - Object pConn = nmsPlayer.getClass().getField("playerConnection").get(nmsPlayer); - pConn.getClass().getMethod("sendPacket", TurretsMain.getInstance().getNMUtils().getNMClass("Packet")).invoke(pConn, packet); - } - } catch (Exception e) { - e.printStackTrace(); - } - } -} diff --git a/src/main/java/com/snowleopard1863/APTurrets/TurretManager.java b/src/main/java/com/snowleopard1863/APTurrets/TurretManager.java index 5b89e4c..ae28b75 100644 --- a/src/main/java/com/snowleopard1863/APTurrets/TurretManager.java +++ b/src/main/java/com/snowleopard1863/APTurrets/TurretManager.java @@ -116,12 +116,7 @@ public void fire(Player player) { return; Arrow arrow = launchArrow(player); - - if (Config.UseParticleTracers) { - TurretsMain.getInstance().getTracerManager().startTracing(arrow); - } else { - arrow.setCritical(true); - } + arrow.setCritical(true); World world = player.getWorld(); world.playSound(player.getLocation(), Sound.ENTITY_FIREWORK_ROCKET_BLAST, 1.0F, 2.0F); diff --git a/src/main/java/com/snowleopard1863/APTurrets/TurretsMain.java b/src/main/java/com/snowleopard1863/APTurrets/TurretsMain.java index 79f2b81..369d011 100644 --- a/src/main/java/com/snowleopard1863/APTurrets/TurretsMain.java +++ b/src/main/java/com/snowleopard1863/APTurrets/TurretsMain.java @@ -2,7 +2,6 @@ import com.snowleopard1863.APTurrets.config.Config; import com.snowleopard1863.APTurrets.listener.*; -import com.snowleopard1863.APTurrets.task.ArrowTracerTask; import com.snowleopard1863.APTurrets.utils.NMUtils; import net.milkbowl.vault.economy.Economy; import org.bukkit.ChatColor; @@ -22,7 +21,6 @@ public static TurretsMain getInstance() { private NMUtils nmsUtils; private TurretManager turretManager; - private TracerManager tracerManager; public void onEnable() { saveDefaultConfig(); @@ -36,7 +34,6 @@ public void onEnable() { Config.IncindiaryChance = getConfig().getDouble("IncindiaryChance", 0.1D); Config.Damage = getConfig().getDouble("Damage", 2.5D); Config.ArrowVelocity = getConfig().getDouble("ArrowVelocity", 4.0D); - Config.UseParticleTracers = getConfig().getBoolean("UseParticleTracers", true); Config.DelayBetweenShots = getConfig().getDouble("DelayBetweenShots", 0.2D); Config.DoRaycast = getConfig().getBoolean("DoRaycast", false); Config.RaycastRadians = getConfig().getDouble("RaycastAngle", 5.0D) / 180.0 * Math.PI; @@ -71,10 +68,6 @@ public void onEnable() { return; } - if (Config.UseParticleTracers) { - getServer().getScheduler().scheduleSyncRepeatingTask(this, new ArrowTracerTask(), 0L, 0L); - } - getServer().getPluginManager().registerEvents(this, this); getServer().getPluginManager().registerEvents(new EntityDamageEntityListener(), this); getServer().getPluginManager().registerEvents(new PlayerDeathListener(), this); @@ -88,14 +81,12 @@ public void onEnable() { nmsUtils = new NMUtils(); turretManager = new TurretManager(); - tracerManager = new TracerManager(); getLogger().info(getDescription().getName() + " v" + getDescription().getVersion() + " has been enabled."); instance = this; } public void onDisable() { turretManager.disable(); - tracerManager.disable(); getLogger().info(getDescription().getName() + " v" + getDescription().getVersion() + " has been disabled."); } @@ -110,8 +101,4 @@ public NMUtils getNMUtils() { public TurretManager getTurretManager() { return turretManager; } - - public TracerManager getTracerManager() { - return tracerManager; - } } diff --git a/src/main/java/com/snowleopard1863/APTurrets/config/Config.java b/src/main/java/com/snowleopard1863/APTurrets/config/Config.java index ee12154..b946c7b 100644 --- a/src/main/java/com/snowleopard1863/APTurrets/config/Config.java +++ b/src/main/java/com/snowleopard1863/APTurrets/config/Config.java @@ -13,7 +13,6 @@ public class Config { public static double IncindiaryChance = 0.1D; public static double ArrowVelocity = 4.0D; public static int KnockbackStrength = 2; - public static boolean UseParticleTracers = true; public static double DelayBetweenShots = 0.2D; public static boolean DoRaycast = false; public static double RaycastRadians = 2.0 / 180.0 * Math.PI; diff --git a/src/main/java/com/snowleopard1863/APTurrets/task/ArrowTracerTask.java b/src/main/java/com/snowleopard1863/APTurrets/task/ArrowTracerTask.java deleted file mode 100644 index e572283..0000000 --- a/src/main/java/com/snowleopard1863/APTurrets/task/ArrowTracerTask.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.snowleopard1863.APTurrets.task; - -import com.snowleopard1863.APTurrets.TurretsMain; -import org.bukkit.Particle; -import org.bukkit.entity.Arrow; - -import java.util.HashSet; - -public class ArrowTracerTask implements Runnable { - @Override - public void run() { - HashSet removeSet = new HashSet<>(); - for(Arrow a : TurretsMain.getInstance().getTracerManager().getTracedArrows()) { - a.getWorld().spawnParticle(Particle.CRIT, a.getLocation(), 1, 0.0D, 0.0D, 0.0D, 0.0D); - - if (a.isOnGround() || a.isDead() || a.getTicksLived() > 100) - removeSet.add(a); - } - for(Arrow a : removeSet) { - TurretsMain.getInstance().getTracerManager().removeTracedArrow(a); - a.remove(); - } - } -} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 13ed229..e595dd8 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -7,7 +7,6 @@ Damage: 2.5 # How much damage this should deal IncindiaryChance: 0.1 # Chance to incinerate your enemies ArrowVelocity: 4.0 # Velocity for arrows to go KnockbackStrength: 2 # Knockback strength of the arrows -UseParticleTracers: true # Whether to use tracers DelayBetweenShots: 0.2 # Delay between each shot DoRaycast: false # Do raycast instant shots for elytra fliers RaycastAngle: 5.0 # Angle for the raycast cone of aiming