From 78f78fb6da96a84d1ba394b29709fdd6f3edc30e Mon Sep 17 00:00:00 2001 From: lixfel Date: Sat, 23 Feb 2019 17:14:00 +0100 Subject: [PATCH] Rework of remaining Listeners --- .../fightsystem/listener/BlockBreakListener.java | 14 +++++--------- .../fightsystem/listener/BlockPlaceListener.java | 9 ++------- .../fightsystem/listener/PlayerDeathListener.java | 12 ++++-------- .../fightsystem/listener/PlayerQuitListener.java | 1 - 4 files changed, 11 insertions(+), 25 deletions(-) diff --git a/src/me/yaruma/fightsystem/listener/BlockBreakListener.java b/src/me/yaruma/fightsystem/listener/BlockBreakListener.java index c6280dc..22a5449 100644 --- a/src/me/yaruma/fightsystem/listener/BlockBreakListener.java +++ b/src/me/yaruma/fightsystem/listener/BlockBreakListener.java @@ -14,19 +14,15 @@ public class BlockBreakListener implements Listener { public void handleBlockBreak(BlockBreakEvent event) { Player player = event.getPlayer(); - if(Fight.getPlayerTeam(player) == null) { + if(Fight.getPlayerTeam(player) == null) event.setCancelled(true); - return; - } - if(FightSystem.getPlugin().getFightState() != FightState.RUNNING) { + else if(FightSystem.getPlugin().getFightState() != FightState.RUNNING) { event.setCancelled(true); - if(FightSystem.getPlugin().getFightState() == FightState.RUNNING || FightSystem.getPlugin().getFightState() == FightState.PRE_RUNNING) { - player.sendMessage(FightSystem.PREFIX + "§cDu darfst erst nach Fightbeginn Blöcke setzen!"); + if(FightSystem.getPlugin().getFightState() == FightState.PRE_RUNNING) { + player.sendMessage(FightSystem.PREFIX + "§cDu darfst erst nach Fightbeginn Blöcke abbauen!"); } else - player.sendMessage(FightSystem.PREFIX + "§cDu darfst keine Blöcke mehr setzen!"); - return; + player.sendMessage(FightSystem.PREFIX + "§cDu darfst keine Blöcke mehr abbauen!"); } } - } diff --git a/src/me/yaruma/fightsystem/listener/BlockPlaceListener.java b/src/me/yaruma/fightsystem/listener/BlockPlaceListener.java index 2185505..d746cb7 100644 --- a/src/me/yaruma/fightsystem/listener/BlockPlaceListener.java +++ b/src/me/yaruma/fightsystem/listener/BlockPlaceListener.java @@ -14,19 +14,14 @@ public class BlockPlaceListener implements Listener { public void handleBlockPlace(BlockPlaceEvent event) { Player player = event.getPlayer(); - if(Fight.getPlayerTeam(player) == null) { + if(Fight.getPlayerTeam(player) == null) event.setCancelled(true); - return; - } - if(FightSystem.getPlugin().getFightState() != FightState.RUNNING) { + else if(FightSystem.getPlugin().getFightState() != FightState.RUNNING) { event.setCancelled(true); if(FightSystem.getPlugin().getFightState() == FightState.PRE_RUNNING) { player.sendMessage(FightSystem.PREFIX + "§cDu darfst erst nach Fightbeginn Blöcke setzen!"); } else player.sendMessage(FightSystem.PREFIX + "§cDu darfst keine Blöcke mehr setzen!"); - return; } } - - } diff --git a/src/me/yaruma/fightsystem/listener/PlayerDeathListener.java b/src/me/yaruma/fightsystem/listener/PlayerDeathListener.java index 9a2a754..e13e51b 100644 --- a/src/me/yaruma/fightsystem/listener/PlayerDeathListener.java +++ b/src/me/yaruma/fightsystem/listener/PlayerDeathListener.java @@ -22,17 +22,13 @@ public class PlayerDeathListener implements Listener { fightTeam.getFightPlayer(player).setOut(true); Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler §6" + player.getName() + " §cist gestorben!"); if(fightTeam.allPlayersOut()) { - Bukkit.broadcastMessage(FightSystem.PREFIX + "§cAlle Spieler aus dem Team von " + fightTeam.getLeader().getPlayer().getName() + " §csind gestorben!"); + Bukkit.broadcastMessage(FightSystem.PREFIX + "§cAlle Spieler aus dem Team " + fightTeam.getLeader().getPlayer().getName() + " §csind gestorben!"); instance.setSpectateState(oppositeFightTeam); - return; } else { - if(Fight.getPlayerTeam(player) == Fight.redTeam) { + if(Fight.getPlayerTeam(player) == Fight.redTeam){ player.teleport(instance.getFightManager().getRedTeleportLocation()); - return; - } - if(Fight.getPlayerTeam(player) == Fight.blueTeam) { - player.teleport(instance.getFightManager().getRedTeleportLocation()); - return; + }else{ + player.teleport(instance.getFightManager().getBlueTeleportLocation()); } } } diff --git a/src/me/yaruma/fightsystem/listener/PlayerQuitListener.java b/src/me/yaruma/fightsystem/listener/PlayerQuitListener.java index 9b297e1..0401ad7 100644 --- a/src/me/yaruma/fightsystem/listener/PlayerQuitListener.java +++ b/src/me/yaruma/fightsystem/listener/PlayerQuitListener.java @@ -28,7 +28,6 @@ public class PlayerQuitListener implements Listener { Bukkit.broadcastMessage(FightSystem.PREFIX + "§cAlle Spieler aus dem Team von §6" + fightTeam.getLeader().getPlayer() + " §chaben den Kampf verlassen! \n §4Stoppe Server in 30 Sekunden..."); Countdown countdown = new Countdown(30*20, new FinishNoPlayersOnline()); countdown.startTimer(FightSystem.getPlugin()); - return; } else { Bukkit.broadcastMessage(FightSystem.PREFIX + "§cAlle Spieler aus dem Team von §6" + fightTeam.getLeader().getPlayer() + " §csind tot oder haben den Kampf verlassen! \n §60 Sekunden Zeit zum Begutachten!"); FightSystem.getPlugin().setSpectateState(Fight.getOpposite(fightTeam));