From d3adc79f0f164f43da64970be1ea4ee3e1cd17f0 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 23 Apr 2019 18:33:18 +0200 Subject: [PATCH] Bugfixes --- fightsystem.iml | 1 + pom.xml | 6 ++++ src/me/yaruma/fightsystem/FightSystem.java | 36 +++++++++---------- .../listener/PlayerMoveListener.java | 2 +- .../listener/ProjectileLaunchListener.java | 6 ++-- .../WinconditionCaptainDead.java | 5 ++- .../WinconditionPercentSystem.java | 3 +- .../winconditions/WinconditionTechKO.java | 13 ++++--- src/plugin.yml | 2 +- 9 files changed, 41 insertions(+), 33 deletions(-) diff --git a/fightsystem.iml b/fightsystem.iml index 73f0348..832cd58 100644 --- a/fightsystem.iml +++ b/fightsystem.iml @@ -21,5 +21,6 @@ + \ No newline at end of file diff --git a/pom.xml b/pom.xml index fa29f24..598b1c6 100644 --- a/pom.xml +++ b/pom.xml @@ -74,5 +74,11 @@ 1.0 provided + + warking + ProtocolLib + 1.0 + provided + \ No newline at end of file diff --git a/src/me/yaruma/fightsystem/FightSystem.java b/src/me/yaruma/fightsystem/FightSystem.java index c23f476..1a015d3 100644 --- a/src/me/yaruma/fightsystem/FightSystem.java +++ b/src/me/yaruma/fightsystem/FightSystem.java @@ -31,7 +31,7 @@ public class FightSystem extends JavaPlugin { private Scoreboard scoreboard; private WaterRemover waterRemover; - private FightState fightState; + private static FightState fightState; public int fightTime = 0; @@ -40,7 +40,7 @@ public class FightSystem extends JavaPlugin { private final File kits = new File("plugins/" + this.getName(), "kits.data"); private final FileConfiguration getKitData = YamlConfiguration.loadConfiguration(kits); - public void saveKitData() { + private void saveKitData() { try { getKitData.save(kits); } catch (Exception ignored) { } } @@ -65,6 +65,13 @@ public class FightSystem extends JavaPlugin { fightState = FightState.SETUP; Countdown countdown = new Countdown(Config.NoPlayerOnlineDuration, new FinishNoPlayersOnline()); countdown.startTimer(getPlugin()); + + /*ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(this, ListenerPriority.NORMAL, PacketType.Play.Server.MAP_CHUNK) { + @Override + public void onPacketSending(PacketEvent e) { + e.getPacket(); + } + });*/ } public void onDisable() { @@ -109,11 +116,7 @@ public class FightSystem extends JavaPlugin { return plugin; } - public FightState getCurrentFightState() { - return fightState; - } - - public FightState getFightState() { + public static FightState getFightState() { return fightState; } @@ -126,9 +129,9 @@ public class FightSystem extends JavaPlugin { } public void setPreRunningState() { - if(this.fightState != FightState.SETUP) + if(fightState != FightState.SETUP) return; - this.fightState = FightState.PRE_RUNNING; + fightState = FightState.PRE_RUNNING; Countdown.cancelAllTimers(); Countdown countdown = new Countdown(Config.PreFightDuration, new FinishPreRunning()); @@ -169,9 +172,9 @@ public class FightSystem extends JavaPlugin { } public void setRunningState() { - if(this.fightState != FightState.PRE_RUNNING) + if(fightState != FightState.PRE_RUNNING) return; - this.fightState = FightState.RUNNING; + fightState = FightState.RUNNING; Countdown.cancelAllTimers(); getWaterRemover().start(); @@ -185,18 +188,15 @@ public class FightSystem extends JavaPlugin { } public void setSpectateState(FightTeam winFightTeam) { - if(this.fightState != FightState.RUNNING) + if(fightState != FightState.RUNNING) return; - this.fightState = FightState.SPECTATE; + fightState = FightState.SPECTATE; Countdown.cancelAllTimers(); Bukkit.getScheduler().cancelTask(WinconditionTechKO.taskID); setAllPlayersGM(GameMode.SPECTATOR); - for(FightPlayer team1 : winFightTeam.getPlayers()) { - team1.getPlayer().getInventory().clear(); - } - for(FightPlayer team2 : Fight.getOpposite(winFightTeam).getPlayers()) { - team2.getPlayer().getInventory().clear(); + for(Player p : Bukkit.getOnlinePlayers()){ + p.getInventory().clear(); } Bukkit.broadcastMessage(" "); diff --git a/src/me/yaruma/fightsystem/listener/PlayerMoveListener.java b/src/me/yaruma/fightsystem/listener/PlayerMoveListener.java index c61864d..d022574 100644 --- a/src/me/yaruma/fightsystem/listener/PlayerMoveListener.java +++ b/src/me/yaruma/fightsystem/listener/PlayerMoveListener.java @@ -35,7 +35,7 @@ public class PlayerMoveListener implements Listener { if(fightTeam == null){ player.teleport(from); player.sendMessage(FightSystem.PREFIX + "§cDu darfst die Arena nicht verlassen!"); - }else if(instance.getCurrentFightState() == FightState.RUNNING) + }else if(FightSystem.getFightState() == FightState.RUNNING) player.damage(2); else if(fightTeam == Fight.redTeam) player.teleport(Config.TeamRedSpawn); diff --git a/src/me/yaruma/fightsystem/listener/ProjectileLaunchListener.java b/src/me/yaruma/fightsystem/listener/ProjectileLaunchListener.java index b1ef744..7b8478c 100644 --- a/src/me/yaruma/fightsystem/listener/ProjectileLaunchListener.java +++ b/src/me/yaruma/fightsystem/listener/ProjectileLaunchListener.java @@ -13,10 +13,12 @@ public class ProjectileLaunchListener implements Listener { @EventHandler public void handleProjectileLaunch(ProjectileLaunchEvent event) { - Player player = (Player) event.getEntity().getShooter(); if(instance.getFightState() != FightState.RUNNING) { event.setCancelled(true); - player.sendMessage(FightSystem.PREFIX + "§cDu kannst den Bogen erst nach Fightbeginn nutzen!"); + if(event.getEntity().getShooter() instanceof Player){ + Player player = (Player) event.getEntity().getShooter(); + player.sendMessage(FightSystem.PREFIX + "§cDu kannst den Bogen erst nach Fightbeginn nutzen!"); + } } } diff --git a/src/me/yaruma/fightsystem/winconditions/WinconditionCaptainDead.java b/src/me/yaruma/fightsystem/winconditions/WinconditionCaptainDead.java index b216d37..ff6ab9c 100644 --- a/src/me/yaruma/fightsystem/winconditions/WinconditionCaptainDead.java +++ b/src/me/yaruma/fightsystem/winconditions/WinconditionCaptainDead.java @@ -19,7 +19,7 @@ public class WinconditionCaptainDead implements Listener { @EventHandler public void handlePlayerDeath(PlayerDeathEvent event) { if(!Config.CaptainDead) return; - if(instance.getFightState() != FightState.PRE_RUNNING && instance.getFightState() != FightState.RUNNING) return; + if(FightSystem.getFightState() != FightState.PRE_RUNNING && FightSystem.getFightState() != FightState.RUNNING) return; Player player = event.getEntity().getPlayer(); if(Fight.getPlayerTeam(player) == null) return; FightTeam fightTeam = Fight.getPlayerTeam(player); @@ -35,7 +35,7 @@ public class WinconditionCaptainDead implements Listener { @EventHandler public void handlePlayerQuit(PlayerQuitEvent event) { if(!Config.CaptainDead) return; - if(instance.getFightState() != FightState.PRE_RUNNING && instance.getFightState() != FightState.RUNNING) return; + if(FightSystem.getFightState() != FightState.PRE_RUNNING && FightSystem.getFightState() != FightState.RUNNING) return; Player player = event.getPlayer(); if(Fight.getPlayerTeam(player) == null) return; FightTeam fightTeam = Fight.getPlayerTeam(player); @@ -44,7 +44,6 @@ public class WinconditionCaptainDead implements Listener { if(fightTeam.isPlayerLeader(player)) { Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Leader von " + fightTeam.getPrefix() + fightTeam.getName() + " §chat den Kampf verlassen!"); instance.setSpectateState(Fight.getOpposite(fightTeam)); - return; } } diff --git a/src/me/yaruma/fightsystem/winconditions/WinconditionPercentSystem.java b/src/me/yaruma/fightsystem/winconditions/WinconditionPercentSystem.java index 45b37f0..4f35426 100644 --- a/src/me/yaruma/fightsystem/winconditions/WinconditionPercentSystem.java +++ b/src/me/yaruma/fightsystem/winconditions/WinconditionPercentSystem.java @@ -2,9 +2,9 @@ package me.yaruma.fightsystem.winconditions; import me.yaruma.fightsystem.FightSystem; import me.yaruma.fightsystem.fight.Fight; +import me.yaruma.fightsystem.fight.FightState; import me.yaruma.fightsystem.utils.Config; import me.yaruma.fightsystem.utils.Region; -import org.bukkit.Bukkit; import org.bukkit.entity.Entity; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -27,6 +27,7 @@ public class WinconditionPercentSystem implements Listener { @EventHandler public void handleEntityExplode(EntityExplodeEvent event) { if(!Config.PercentSystem) return; + if(FightSystem.getFightState() != FightState.PRE_RUNNING && FightSystem.getFightState() != FightState.RUNNING) return; Entity entity = event.getEntity(); //Team Blue diff --git a/src/me/yaruma/fightsystem/winconditions/WinconditionTechKO.java b/src/me/yaruma/fightsystem/winconditions/WinconditionTechKO.java index cb8fdd5..09bf1a7 100644 --- a/src/me/yaruma/fightsystem/winconditions/WinconditionTechKO.java +++ b/src/me/yaruma/fightsystem/winconditions/WinconditionTechKO.java @@ -2,6 +2,7 @@ package me.yaruma.fightsystem.winconditions; import me.yaruma.fightsystem.FightSystem; import me.yaruma.fightsystem.fight.Fight; +import me.yaruma.fightsystem.fight.FightState; import me.yaruma.fightsystem.utils.Config; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -12,12 +13,13 @@ import java.util.Iterator; public class WinconditionTechKO { - public static HashSet teamRedWater = new HashSet<>(); - public static HashSet teamBlueWater = new HashSet<>(); + private static HashSet teamRedWater = new HashSet<>(); + private static HashSet teamBlueWater = new HashSet<>(); public static int taskID; public static void addWater() { if(!Config.TechKO) return; + if(FightSystem.getFightState() != FightState.PRE_RUNNING && FightSystem.getFightState() != FightState.RUNNING) return; teamRedWater.clear(); teamBlueWater.clear(); @@ -71,12 +73,11 @@ public class WinconditionTechKO { FightSystem.getPlugin().setSpectateState(Fight.getRedTeam()); FightSystem.getPlugin().getWaterRemover().stop(); } - System.out.println("RedList: " + teamRedWater.size()); - System.out.println("BlueList: " + teamBlueWater.size()); } public static void removeWater() { if(!Config.TechKO) return; + if(FightSystem.getFightState() != FightState.PRE_RUNNING && FightSystem.getFightState() != FightState.RUNNING) return; //Team Red Iterator itrRed = teamRedWater.iterator(); @@ -84,7 +85,6 @@ public class WinconditionTechKO { Location location = (Location) itrRed.next(); if(location.getBlock().getType() != Material.WATER && location.getBlock().getType() != Material.STATIONARY_WATER) { itrRed.remove(); - System.out.println("red remove" + teamRedWater.size()); } } if(teamRedWater.isEmpty()) { @@ -100,7 +100,6 @@ public class WinconditionTechKO { Location location = (Location) itrBlue.next(); if(location.getBlock().getType() != Material.WATER && location.getBlock().getType() != Material.STATIONARY_WATER) { itrBlue.remove(); - System.out.println("blue remove" + teamBlueWater.size()); } } if(teamBlueWater.isEmpty()) { @@ -113,7 +112,7 @@ public class WinconditionTechKO { public static void startAutoChecker() { if(!Config.TechKO) return; - taskID = Bukkit.getScheduler().scheduleAsyncRepeatingTask(FightSystem.getPlugin(), () -> addWater(), 0, 20*20); + taskID = Bukkit.getScheduler().scheduleAsyncRepeatingTask(FightSystem.getPlugin(), WinconditionTechKO::addWater, 0, 20*20); } } diff --git a/src/plugin.yml b/src/plugin.yml index 06aa185..aab0365 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -2,7 +2,7 @@ name: FightSystem version: 1.0 author: [Yaruma3341, Lixfel] main: me.yaruma.fightsystem.FightSystem -depend: [CoreSystem, WorldEdit, FastAsyncWorldEdit] +depend: [CoreSystem, WorldEdit, FastAsyncWorldEdit, ProtocolLib] commands: ak: \ No newline at end of file