From 9b9da7ff6c28193ef75ccc97a94af4d9ff7802d6 Mon Sep 17 00:00:00 2001 From: lixfel Date: Tue, 26 Mar 2019 12:00:56 +0100 Subject: [PATCH 1/2] Fixes, Fixes, Fixes --- .gitignore | 1 - pom.xml | 78 +++++++++++++++++++ config.yml => src/config.yml | 8 +- src/me/yaruma/fightsystem/FightSystem.java | 25 +++--- .../listener/PlayerChatListener.java | 4 +- .../listener/PlayerDeathListener.java | 5 +- .../listener/PlayerQuitListener.java | 4 +- .../utils/countdown/Countdown.java | 40 +++++----- .../countdown/FinishNoPlayersOnline.java | 1 - .../utils/countdown/FinishNoneEntern.java | 2 +- .../utils/countdown/FinishSetupOver.java | 3 +- .../utils/countdown/FinishSpectateOver.java | 1 - .../utils/countdown/FinishTimeOver.java | 2 +- .../utils/scoreboard/Scoreboard.java | 14 +++- .../winconditions/WinconditionAllDead.java | 12 +-- .../WinconditionCaptainDead.java | 13 +--- .../winconditions/WinconditionEntern.java | 4 +- plugin.yml => src/plugin.yml | 0 18 files changed, 137 insertions(+), 80 deletions(-) create mode 100644 pom.xml rename config.yml => src/config.yml (96%) rename plugin.yml => src/plugin.yml (100%) diff --git a/.gitignore b/.gitignore index e220b6c..29b636a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ .idea -pom.xml *.iml \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..fa29f24 --- /dev/null +++ b/pom.xml @@ -0,0 +1,78 @@ + + + 4.0.0 + + me.yaruma + FightSystem + 1.0 + jar + https://maven.apache.org + + + UTF-8 + + + + + maven + https://warking.de:81/maven/ + + + spigotmc-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + + + src + + + src + + **/*.java + **/*.kt + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.6.1 + + 1.8 + 1.8 + + + + + + + + org.spigotmc + spigot-api + 1.12.2-R0.1-SNAPSHOT + provided + + + warking + SpigotCore + 1.0 + provided + + + warking + WorldEdit + 1.0 + provided + + + warking + FAWE + 1.0 + provided + + + \ No newline at end of file diff --git a/config.yml b/src/config.yml similarity index 96% rename from config.yml rename to src/config.yml index 1dbc12b..3cc3f9a 100644 --- a/config.yml +++ b/src/config.yml @@ -3,7 +3,6 @@ Times: SetupDuration: 0 PreFightDuration: 0 SpectatorDuration: 0 - Arena: Schemsize: x: 0 @@ -22,30 +21,25 @@ Arena: z: 0 underArenaBorder: 0 BorderFromSchematic: 0 - Output: TeamRedColor: &c TeamBlueColor: &3 TeamRedName: Team1 TeamBlueName: Team2 - GameName: AirWargear + GameName: AirShip TeamChatDetection: + - WinConditions: Timeout: boolean AllDead: boolean CaptainDead: boolean PercentSystem: boolean Entern: boolean - WinConditionParams: TimeoutTime: 0 EnterPhaseBegin: 0 PercentWin: 0 - Fight: OnlyPublicSchematics: boolean - Money: Win: 0 Lose: 0 diff --git a/src/me/yaruma/fightsystem/FightSystem.java b/src/me/yaruma/fightsystem/FightSystem.java index 11de7bb..b53e25a 100644 --- a/src/me/yaruma/fightsystem/FightSystem.java +++ b/src/me/yaruma/fightsystem/FightSystem.java @@ -24,8 +24,8 @@ import java.io.File; public class FightSystem extends JavaPlugin { - public static String PREFIX = "[FightSystem] "; - public static String NOPERM = PREFIX + "§4Du darfst das nicht!"; + public static final String PREFIX = "§6Arena§8» "; + public static final String NOPERM = PREFIX + "§cDu darfst das nicht!"; private static FightSystem plugin; private FileManager fileManager; @@ -171,14 +171,10 @@ public class FightSystem extends JavaPlugin { int setupDuration = fileManager.getIntegerFromConfig("Times.NoPlayersOnlineDuration"); Countdown countdown = new Countdown(setupDuration, new FinishNoPlayersOnline()); countdown.startTimer(getPlugin()); - - System.out.println(PREFIX + "§aPlugin gestartet!"); } public void onDisable() { - System.out.println(PREFIX + "§cPlugin deaktiviert!"); - } private void init() { @@ -276,9 +272,7 @@ public class FightSystem extends JavaPlugin { WorldEdit.replace(Fight.getBlueTeam().getLeader().getPlayer(), team1cornerX, team1cornerY, team1cornerZ, team1cornerX + schemsizeX, team1cornerY + schemsizeY, team1cornerZ + schemsizeZ); WorldEdit.replace(Fight.getRedTeam().getLeader().getPlayer(), team2cornerX, team2cornerY, team2cornerZ, team2cornerX + schemsizeX, team2cornerY + schemsizeY, team2cornerZ + schemsizeZ); - Bukkit.broadcastMessage(" "); - Bukkit.broadcastMessage("§aDer Fight beginnt!"); - Bukkit.broadcastMessage(" "); + Bukkit.broadcastMessage(PREFIX + "§aDer Kampf beginnt!"); } private void setAllPlayersGM(GameMode gm) { @@ -303,7 +297,7 @@ public class FightSystem extends JavaPlugin { WinconditionTimeout.timeout(); WinconditionEntern.entern(); - Bukkit.broadcastMessage("§aArena freigegeben!"); + Bukkit.broadcastMessage(PREFIX + "§aArena freigegeben!"); } public void setSpectateState(FightTeam winFightTeam) { @@ -316,8 +310,7 @@ public class FightSystem extends JavaPlugin { Bukkit.broadcastMessage(" "); if(winFightTeam != null) { - - Bukkit.broadcastMessage(PREFIX + "§aDas Team von §6" + winFightTeam.getLeader().getPlayer().getName() + " §ahat gewonnen!"); + Bukkit.broadcastMessage(PREFIX + "§aDas Team " + winFightTeam.getPrefix() + winFightTeam.getName() + " §ahat gewonnen!"); plugin.getFightManager().teleportAllToFightSpawn(); for(FightPlayer fightPlayer : winFightTeam.getPlayers()) { @@ -328,17 +321,17 @@ public class FightSystem extends JavaPlugin { CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(getMoneyToPay("Money.Lose")); } } else { - //Keine Message! Wird in FinishTimeOver gesendet! - for(FightPlayer fightPlayer : winFightTeam.getPlayers()) { + Bukkit.broadcastMessage(PREFIX + "§aKein Team hat gewonnen!"); + for(FightPlayer fightPlayer : Fight.getBlueTeam().getPlayers()) { CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(getMoneyToPay("Money.Undecided")); } - for(FightPlayer fightPlayer : Fight.getOpposite(winFightTeam).getPlayers()) { + for(FightPlayer fightPlayer : Fight.getRedTeam().getPlayers()) { CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(getMoneyToPay("Money.Undecided")); } } - Countdown countdown = new Countdown(20*60, new FinishSpectateOver()); + Countdown countdown = new Countdown(fileManager.getIntegerFromConfig("Times.SpectatorDuration"), new FinishSpectateOver()); countdown.startTimer(FightSystem.getPlugin()); } diff --git a/src/me/yaruma/fightsystem/listener/PlayerChatListener.java b/src/me/yaruma/fightsystem/listener/PlayerChatListener.java index 2488f4d..6257841 100644 --- a/src/me/yaruma/fightsystem/listener/PlayerChatListener.java +++ b/src/me/yaruma/fightsystem/listener/PlayerChatListener.java @@ -29,10 +29,10 @@ public class PlayerChatListener implements Listener { if(message.startsWith(teamChatDetection)) { fightTeam.broadcast(prefixColorCode + player.getName() + "» " + prefixColorCode + message.substring(1)); } else { - Bukkit.broadcastMessage(prefixColorCode + teamName + " " + player.getName() + " §8» §7" + message); + Bukkit.broadcastMessage(prefixColorCode + teamName + " " + player.getName() + "§8» §7" + message); } }else{ - Bukkit.broadcastMessage("§7" + player.getName() + " §8» §7" + message); + Bukkit.broadcastMessage("§7" + player.getName() + "§8» §7" + message); } event.setCancelled(true); diff --git a/src/me/yaruma/fightsystem/listener/PlayerDeathListener.java b/src/me/yaruma/fightsystem/listener/PlayerDeathListener.java index 9d5e502..70efc8d 100644 --- a/src/me/yaruma/fightsystem/listener/PlayerDeathListener.java +++ b/src/me/yaruma/fightsystem/listener/PlayerDeathListener.java @@ -6,6 +6,7 @@ import me.yaruma.fightsystem.fight.FightTeam; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.entity.PlayerDeathEvent; @@ -13,13 +14,13 @@ public class PlayerDeathListener implements Listener { FightSystem instance = FightSystem.getPlugin(); - @EventHandler + @EventHandler(priority = EventPriority.HIGH) public void handlePlayerDeath(PlayerDeathEvent event) { Player player = event.getEntity().getPlayer(); if(Fight.getPlayerTeam(player) == null) return; FightTeam fightTeam = Fight.getPlayerTeam(player); - fightTeam.getFightPlayer(player).setOut(true); event.setDeathMessage(FightSystem.PREFIX + "§cDer Spieler §6" + player.getName() + " §cist gestorben!"); + fightTeam.getFightPlayer(player).setOut(true); } diff --git a/src/me/yaruma/fightsystem/listener/PlayerQuitListener.java b/src/me/yaruma/fightsystem/listener/PlayerQuitListener.java index 0591688..c0d9613 100644 --- a/src/me/yaruma/fightsystem/listener/PlayerQuitListener.java +++ b/src/me/yaruma/fightsystem/listener/PlayerQuitListener.java @@ -26,8 +26,8 @@ public class PlayerQuitListener implements Listener { Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler §6" + player.getName() + " §chat den Kampf verlassen!"); if(fightTeam.allPlayersOut() && FightSystem.getPlugin().getFightState() == FightState.SETUP) { - 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()); + Bukkit.broadcastMessage(FightSystem.PREFIX + "§cAlle Spieler aus dem Team " + fightTeam.getPrefix() + fightTeam.getName() + " §chaben den Kampf verlassen!"); + Countdown countdown = new Countdown(30, new FinishNoPlayersOnline()); countdown.startTimer(FightSystem.getPlugin()); } } diff --git a/src/me/yaruma/fightsystem/utils/countdown/Countdown.java b/src/me/yaruma/fightsystem/utils/countdown/Countdown.java index a1eb667..4cfb118 100644 --- a/src/me/yaruma/fightsystem/utils/countdown/Countdown.java +++ b/src/me/yaruma/fightsystem/utils/countdown/Countdown.java @@ -18,34 +18,30 @@ public class Countdown { this.time = time; this.countdownCallback = countdownCallback; countdowns.add(this); - - if(countdownCallback instanceof FinishTimeOver) FightSystem.getPlugin().fightTime = time; } public void startTimer(FightSystem plugin) { BukkitScheduler bukkitScheduler = Bukkit.getServer().getScheduler(); - this.taskID = bukkitScheduler.scheduleSyncRepeatingTask(plugin, new Runnable() { - @Override - public void run() { + this.taskID = bukkitScheduler.scheduleSyncRepeatingTask(plugin, () -> { - switch (time) { - case 600: case 300: - Bukkit.broadcastMessage("§6Noch §a" + time / 60 + " §6Minuten " + countdownCallback.countdownCounting()); - break; - case 60: case 30: case 20: case 15: case 10: case 5: case 4: case 3: case 2: - Bukkit.broadcastMessage("§6Noch §a" + time + " §6Sekunden " + countdownCallback.countdownCounting()); - break; - case 1: - Bukkit.broadcastMessage("§6Noch §aeine §6Sekunde " + countdownCallback.countdownCounting()); - break; - case 0: - cancelTimer(); - countdownCallback.countdownFinished(); - break; - } - time--; + switch (time) { + case 900: case 600: case 300: case 180: case 120: + Bukkit.broadcastMessage(FightSystem.PREFIX + "§7Noch §a" + time / 60 + " §7Minuten " + countdownCallback.countdownCounting()); + break; + case 60: case 30: case 20: case 15: case 10: case 5: case 4: case 3: case 2: + Bukkit.broadcastMessage(FightSystem.PREFIX + "§7Noch §a" + time + " §7Sekunden " + countdownCallback.countdownCounting()); + break; + case 1: + Bukkit.broadcastMessage(FightSystem.PREFIX + "§7Noch §aeine §7Sekunde " + countdownCallback.countdownCounting()); + break; + case 0: + cancelTimer(); + countdownCallback.countdownFinished(); + break; } + time--; + if(countdownCallback instanceof FinishTimeOver) FightSystem.getPlugin().fightTime = time; }, 0, 20); } @@ -53,10 +49,10 @@ public class Countdown { try { Bukkit.getScheduler().cancelTask(this.taskID); - countdowns.remove(this); } catch (AssertionError ex) { ex.printStackTrace(); } + countdowns.remove(this); } public static void cancelAllTimers() { diff --git a/src/me/yaruma/fightsystem/utils/countdown/FinishNoPlayersOnline.java b/src/me/yaruma/fightsystem/utils/countdown/FinishNoPlayersOnline.java index 78defbf..f83d81c 100644 --- a/src/me/yaruma/fightsystem/utils/countdown/FinishNoPlayersOnline.java +++ b/src/me/yaruma/fightsystem/utils/countdown/FinishNoPlayersOnline.java @@ -11,7 +11,6 @@ public class FinishNoPlayersOnline implements CountdownCallback { @Override public void countdownFinished() { - Bukkit.broadcastMessage("§aStoppe Server..."); Bukkit.getServer().shutdown(); } diff --git a/src/me/yaruma/fightsystem/utils/countdown/FinishNoneEntern.java b/src/me/yaruma/fightsystem/utils/countdown/FinishNoneEntern.java index 75c982d..a267e6b 100644 --- a/src/me/yaruma/fightsystem/utils/countdown/FinishNoneEntern.java +++ b/src/me/yaruma/fightsystem/utils/countdown/FinishNoneEntern.java @@ -13,7 +13,7 @@ public class FinishNoneEntern implements CountdownCallback { @Override public void countdownFinished() { FightSystem.getPlugin().entern = true; - Bukkit.broadcastMessage("§aEntern ist nun erlaubt!"); + Bukkit.broadcastMessage(FightSystem.PREFIX + "§aEntern ist nun erlaubt!"); } @Override diff --git a/src/me/yaruma/fightsystem/utils/countdown/FinishSetupOver.java b/src/me/yaruma/fightsystem/utils/countdown/FinishSetupOver.java index 411c9e6..701d6e2 100644 --- a/src/me/yaruma/fightsystem/utils/countdown/FinishSetupOver.java +++ b/src/me/yaruma/fightsystem/utils/countdown/FinishSetupOver.java @@ -1,5 +1,6 @@ package me.yaruma.fightsystem.utils.countdown; +import me.yaruma.fightsystem.FightSystem; import org.bukkit.Bukkit; public class FinishSetupOver implements CountdownCallback { @@ -11,7 +12,7 @@ public class FinishSetupOver implements CountdownCallback { @Override public void countdownFinished() { - Bukkit.broadcastMessage("Fight wird abgebrochen! \n Stoppe Server..."); + Bukkit.broadcastMessage(FightSystem.PREFIX + "§cKampf wird abgebrochen!"); Bukkit.getServer().shutdown(); } diff --git a/src/me/yaruma/fightsystem/utils/countdown/FinishSpectateOver.java b/src/me/yaruma/fightsystem/utils/countdown/FinishSpectateOver.java index ed77a48..65b6327 100644 --- a/src/me/yaruma/fightsystem/utils/countdown/FinishSpectateOver.java +++ b/src/me/yaruma/fightsystem/utils/countdown/FinishSpectateOver.java @@ -11,7 +11,6 @@ public class FinishSpectateOver implements CountdownCallback { @Override public void countdownFinished() { - Bukkit.broadcastMessage("§aStoppe Server..."); Bukkit.getServer().shutdown(); } diff --git a/src/me/yaruma/fightsystem/utils/countdown/FinishTimeOver.java b/src/me/yaruma/fightsystem/utils/countdown/FinishTimeOver.java index 4d32f58..4d046e3 100644 --- a/src/me/yaruma/fightsystem/utils/countdown/FinishTimeOver.java +++ b/src/me/yaruma/fightsystem/utils/countdown/FinishTimeOver.java @@ -12,7 +12,7 @@ public class FinishTimeOver implements CountdownCallback { @Override public void countdownFinished() { - Bukkit.broadcastMessage("§aZeit abgelaufen! Der Kampf ist vorbei..."); + Bukkit.broadcastMessage(FightSystem.PREFIX +"§aZeit abgelaufen!"); FightSystem.getPlugin().setSpectateState(null); } diff --git a/src/me/yaruma/fightsystem/utils/scoreboard/Scoreboard.java b/src/me/yaruma/fightsystem/utils/scoreboard/Scoreboard.java index 54a01d5..69f0997 100644 --- a/src/me/yaruma/fightsystem/utils/scoreboard/Scoreboard.java +++ b/src/me/yaruma/fightsystem/utils/scoreboard/Scoreboard.java @@ -37,7 +37,7 @@ public class Scoreboard { scoreboard.registerNewObjective("AAA", "BBB"); objective.setDisplaySlot(DisplaySlot.SIDEBAR); - objective.setDisplayName("§6Info " + fightTeam.getPrefix() + fightTeam.getName()); + objective.setDisplayName(fightTeam.getPrefix() + fightTeam.getName()); for(FightPlayer fp : fightTeam.getPlayers()) { objective.getScore(fightTeam.getPrefix() + fp.getPlayer().getName()).setScore((int) fp.getPlayer().getHealth()); @@ -51,9 +51,15 @@ public class Scoreboard { scoreboard.registerNewObjective("AAA", "BBB"); objective.setDisplaySlot(DisplaySlot.SIDEBAR); - objective.setDisplayName("§6Fight Info"); - objective.getScore("§7Zeit: §a" + FightSystem.getPlugin().getFightTime()).setScore(3); - if(Methods.isEnabled("Fight.Entern")) objective.getScore("§7Entern: " + (FightSystem.getPlugin().isEntern() ? "§aja" : "§cnein")).setScore(2); + objective.setDisplayName("§6Kampf"); + if(Methods.isEnabled("WinConditions.Timeout")){ + int fightTime = FightSystem.getPlugin().getFightTime(); + if(fightTime >= 60) + objective.getScore("§7Zeit: §a" + fightTime/60 + "m " + fightTime%60 + "s" ).setScore(3); + else + objective.getScore("§7Zeit: §a" + fightTime + "s").setScore(3); + } + if(Methods.isEnabled("WinConditions.Entern")) objective.getScore("§7Entern: " + (FightSystem.getPlugin().isEntern() ? "§aja" : "§cnein")).setScore(2); if(Methods.isEnabled("WinConditions.PercentSystem")) objective.getScore("§eSchaden ROT: §c" + FightSystem.getPlugin().getDamageRed() + "%").setScore(1); if(Methods.isEnabled("WinConditions.PercentSystem")) objective.getScore("§eSchaden BLAU: §c" + FightSystem.getPlugin().getGetDamageBlue() + "%").setScore(0); index = 0; diff --git a/src/me/yaruma/fightsystem/winconditions/WinconditionAllDead.java b/src/me/yaruma/fightsystem/winconditions/WinconditionAllDead.java index 00a9c2d..3596f31 100644 --- a/src/me/yaruma/fightsystem/winconditions/WinconditionAllDead.java +++ b/src/me/yaruma/fightsystem/winconditions/WinconditionAllDead.java @@ -20,12 +20,10 @@ public class WinconditionAllDead implements Listener { Player player = event.getEntity().getPlayer(); if(Fight.getPlayerTeam(player) == null) return; FightTeam fightTeam = Fight.getPlayerTeam(player); - FightTeam oppositeFightTeam = Fight.getOpposite(fightTeam); if(fightTeam.allPlayersOut()) { - Bukkit.broadcastMessage(FightSystem.PREFIX + "§cAlle Spieler aus dem Team von " + fightTeam.getLeader().getPlayer().getName() + " §csind gestorben oder haben den Kampf verlassen!"); - instance.setSpectateState(oppositeFightTeam); - return; + Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer letzte Spieler aus " + fightTeam.getPrefix() + fightTeam.getName() + " §cist gestorben!"); + instance.setSpectateState(Fight.getOpposite(fightTeam)); } } @@ -35,12 +33,10 @@ public class WinconditionAllDead implements Listener { Player player = event.getPlayer(); if(Fight.getPlayerTeam(player) == null) return; FightTeam fightTeam = Fight.getPlayerTeam(player); - FightTeam oppositeFightTeam = Fight.getOpposite(fightTeam); if(fightTeam.allPlayersOut()) { - Bukkit.broadcastMessage(FightSystem.PREFIX + "§cAlle Spieler aus dem Team von §6" + fightTeam.getLeader().getPlayer().getName() + " §csind gestorben oder haben den Kampf verlassen!"); - instance.setSpectateState(oppositeFightTeam); - return; + Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer letzte Spieler aus §6" + fightTeam.getPrefix() + fightTeam.getName() + " §chat den Kampf verlassen!"); + instance.setSpectateState(Fight.getOpposite(fightTeam)); } } diff --git a/src/me/yaruma/fightsystem/winconditions/WinconditionCaptainDead.java b/src/me/yaruma/fightsystem/winconditions/WinconditionCaptainDead.java index 4b29022..d7261a8 100644 --- a/src/me/yaruma/fightsystem/winconditions/WinconditionCaptainDead.java +++ b/src/me/yaruma/fightsystem/winconditions/WinconditionCaptainDead.java @@ -22,13 +22,10 @@ public class WinconditionCaptainDead implements Listener { Player player = event.getEntity().getPlayer(); if(Fight.getPlayerTeam(player) == null) return; FightTeam fightTeam = Fight.getPlayerTeam(player); - FightTeam oppositeFightTeam = Fight.getOpposite(fightTeam); - - String team = Fight.getRedTeam().isPlayerLeader(player) ? "Red" : "Blue"; if(fightTeam.isPlayerLeader(player)) { - Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Leader von Team " + fileManager.getStringFromConfig("Output.Team" + team + "Color") + fileManager.getStringFromConfig("Output.Team" + team + "Name") + " §cist gestorben!"); - instance.setSpectateState(oppositeFightTeam); + Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Leader von " + fightTeam.getPrefix() + fightTeam.getName() + " §cist gestorben!"); + instance.setSpectateState(Fight.getOpposite(fightTeam)); return; } } @@ -39,12 +36,10 @@ public class WinconditionCaptainDead implements Listener { Player player = event.getPlayer(); if(Fight.getPlayerTeam(player) == null) return; FightTeam fightTeam = Fight.getPlayerTeam(player); - FightTeam oppositeFightTeam = Fight.getOpposite(fightTeam); - - String team = Fight.getRedTeam().isPlayerLeader(player) ? "Red" : "Blue"; if(fightTeam.isPlayerLeader(player)) { - instance.setSpectateState(oppositeFightTeam); + 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/WinconditionEntern.java b/src/me/yaruma/fightsystem/winconditions/WinconditionEntern.java index 35930d2..89f3946 100644 --- a/src/me/yaruma/fightsystem/winconditions/WinconditionEntern.java +++ b/src/me/yaruma/fightsystem/winconditions/WinconditionEntern.java @@ -3,7 +3,7 @@ package me.yaruma.fightsystem.winconditions; import me.yaruma.fightsystem.FightSystem; import me.yaruma.fightsystem.manager.FileManager; import me.yaruma.fightsystem.utils.countdown.Countdown; -import me.yaruma.fightsystem.utils.countdown.FinishTimeOver; +import me.yaruma.fightsystem.utils.countdown.FinishNoneEntern; public class WinconditionEntern { @@ -14,7 +14,7 @@ public class WinconditionEntern { if(!Methods.isEnabled("WinConditions.Entern")) return; int timeTimeOver = fileManager.getIntegerFromConfig("WinConditionParams.EnterPhaseBegin"); - Countdown countdownTimeOver = new Countdown(timeTimeOver, new FinishTimeOver()); + Countdown countdownTimeOver = new Countdown(timeTimeOver, new FinishNoneEntern()); countdownTimeOver.startTimer(instance); } diff --git a/plugin.yml b/src/plugin.yml similarity index 100% rename from plugin.yml rename to src/plugin.yml From 140959cdbd57f00d8e8a82572054998f6b94c926 Mon Sep 17 00:00:00 2001 From: lixfel Date: Tue, 26 Mar 2019 12:33:33 +0100 Subject: [PATCH 2/2] Fixes + Automatic Inspection Cleanup run (potentially something broken) --- .gitignore | 3 +- fightsystem.iml | 25 +++++++++++ src/me/yaruma/fightsystem/FightSystem.java | 42 +++++++++--------- .../fightsystem/commands/AkCommand.java | 6 +-- src/me/yaruma/fightsystem/fight/Fight.java | 4 +- .../fightsystem/fight/FightCreator.java | 3 +- .../yaruma/fightsystem/fight/FightState.java | 2 +- .../yaruma/fightsystem/fight/FightTeam.java | 6 +-- .../fightsystem/fight/WaterRemover.java | 44 ++++++++----------- .../listener/BlockBreakListener.java | 2 +- .../EntityDamageByEntityListener.java | 44 ++++++++----------- .../listener/EntityExplodeListener.java | 2 + .../listener/PlayerChatListener.java | 2 +- .../listener/PlayerDeathListener.java | 1 - .../listener/PlayerInteractListener.java | 2 +- .../listener/PlayerJoinListener.java | 4 +- .../listener/PlayerMoveListener.java | 9 ++-- .../listener/PlayerQuitListener.java | 1 - .../listener/PlayerRespawnListener.java | 2 +- .../fightsystem/manager/FileManager.java | 10 ++--- .../yaruma/fightsystem/utils/ItemBuilder.java | 4 +- src/me/yaruma/fightsystem/utils/Region.java | 7 ++- .../utils/countdown/Countdown.java | 8 ++-- .../utils/countdown/CountdownCallback.java | 2 +- .../utils/countdown/CountdownType.java | 2 +- .../utils/countdown/FinishPreRunning.java | 1 - .../utils/scoreboard/Scoreboard.java | 31 ++++++------- .../winconditions/WinconditionAllDead.java | 2 +- .../WinconditionCaptainDead.java | 2 +- .../winconditions/WinconditionEntern.java | 4 +- .../WinconditionPercentSystem.java | 10 ++--- .../winconditions/WinconditionTimeout.java | 4 +- 32 files changed, 148 insertions(+), 143 deletions(-) create mode 100644 fightsystem.iml diff --git a/.gitignore b/.gitignore index 29b636a..723ef36 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ -.idea -*.iml \ No newline at end of file +.idea \ No newline at end of file diff --git a/fightsystem.iml b/fightsystem.iml new file mode 100644 index 0000000..73f0348 --- /dev/null +++ b/fightsystem.iml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/me/yaruma/fightsystem/FightSystem.java b/src/me/yaruma/fightsystem/FightSystem.java index b53e25a..99727ba 100644 --- a/src/me/yaruma/fightsystem/FightSystem.java +++ b/src/me/yaruma/fightsystem/FightSystem.java @@ -37,44 +37,42 @@ public class FightSystem extends JavaPlugin { private FightState fightState; - public Location Team1SpawnLoc = null; - public Location Team2SpawnLoc = null; - public Location SpecSpawnLoc = null; - public Location Team1PasteLoc = null; - public Location Team2PasteLoc = null; + private Location Team1SpawnLoc = null; + private Location Team2SpawnLoc = null; + private Location SpecSpawnLoc = null; + private Location Team1PasteLoc = null; + private Location Team2PasteLoc = null; public int ArenaMinX; public int ArenaMaxX; public int ArenaMinZ; public int ArenaMaxZ; - public int schemsizeX; - public int schemsizeY; - public int schemsizeZ; + private int schemsizeX; + private int schemsizeY; + private int schemsizeZ; - public int team1cornerX; - public int team1cornerY; - public int team1cornerZ; + private int team1cornerX; + private int team1cornerY; + private int team1cornerZ; - public int team2cornerX; - public int team2cornerY; - public int team2cornerZ; + private int team2cornerX; + private int team2cornerY; + private int team2cornerZ; public int underArenaBorder; public int fightTime = 0; - public double damageRed = 0D; - public double getDamageBlue = 0D; public boolean entern = false; - public File kits = new File("plugins/" + this.getName(), "kits.data"); - public FileConfiguration getKitData = YamlConfiguration.loadConfiguration(kits); + private final File kits = new File("plugins/" + this.getName(), "kits.data"); + private final FileConfiguration getKitData = YamlConfiguration.loadConfiguration(kits); - public void saveKitData() { - try { getKitData.save(kits); } catch (Exception ex) { } + private void saveKitData() { + try { getKitData.save(kits); } catch (Exception ignored) { } } @@ -335,7 +333,7 @@ public class FightSystem extends JavaPlugin { countdown.startTimer(FightSystem.getPlugin()); } - public int getMoneyToPay(String moneyPath) { + private int getMoneyToPay(String moneyPath) { return fileManager.getIntegerFromConfig(moneyPath); } @@ -425,10 +423,12 @@ public class FightSystem extends JavaPlugin { } public double getDamageRed() { + double damageRed = 0D; return damageRed; } public double getGetDamageBlue() { + double getDamageBlue = 0D; return getDamageBlue; } diff --git a/src/me/yaruma/fightsystem/commands/AkCommand.java b/src/me/yaruma/fightsystem/commands/AkCommand.java index 203bbd0..e87221b 100644 --- a/src/me/yaruma/fightsystem/commands/AkCommand.java +++ b/src/me/yaruma/fightsystem/commands/AkCommand.java @@ -64,12 +64,12 @@ public class AkCommand implements CommandExecutor { if(!Fight.getBlueTeam().hasTeamLeader()){ FightPlayer fightPlayer = new FightPlayer(player, false); Fight.getBlueTeam().setLeader(fightPlayer); - player.sendMessage(FightSystem.PREFIX + "§aDu bist nun Leader von " + fileManager.getStringFromConfig("Output.TeamBlueColor") + fileManager.getStringFromConfig("Output.TeamBlueName")); + player.sendMessage(FightSystem.PREFIX + "§aDu bist nun Leader von " + Fight.getBlueTeam().getPrefix() + Fight.getBlueTeam().getName()); } else if(!Fight.getRedTeam().hasTeamLeader()){ FightPlayer fightPlayer = new FightPlayer(player, false); Fight.getBlueTeam().setLeader(fightPlayer); - player.sendMessage(FightSystem.PREFIX + "§aDu bist nun Leader von " + fileManager.getStringFromConfig("Output.TeamRedColor") + fileManager.getStringFromConfig("Output.TeamRedName")); + player.sendMessage(FightSystem.PREFIX + "§aDu bist nun Leader von " + Fight.getRedTeam().getPrefix() + Fight.getRedTeam().getName()); } else player.sendMessage(FightSystem.PREFIX + "§cEs sind bereits zwei Leader vorhanden!"); @@ -107,7 +107,7 @@ public class AkCommand implements CommandExecutor { if(fightPlayer.isLeader() && fightTeam.isPlayerInTeam(target)){ fightTeam.removePlayer(target); player.sendMessage(FightSystem.PREFIX + "§aDu hast den Spieler §6" + target.getName() + " §aaus dem Team entfernt!"); - target.sendMessage(FightSystem.PREFIX + "§4Du wurdest auf deinem Team entfernt!"); + target.sendMessage(FightSystem.PREFIX + "§cDu wurdest auf deinem Team entfernt!"); } } } diff --git a/src/me/yaruma/fightsystem/fight/Fight.java b/src/me/yaruma/fightsystem/fight/Fight.java index 6a0ff5c..c294e48 100644 --- a/src/me/yaruma/fightsystem/fight/Fight.java +++ b/src/me/yaruma/fightsystem/fight/Fight.java @@ -5,8 +5,8 @@ import org.bukkit.entity.Player; public class Fight { - public static FightTeam redTeam = new FightTeam(null, FightSystem.getPlugin()); - public static FightTeam blueTeam = new FightTeam(null, FightSystem.getPlugin()); + public static final FightTeam redTeam = new FightTeam(null, FightSystem.getPlugin()); + public static final FightTeam blueTeam = new FightTeam(null, FightSystem.getPlugin()); public static FightTeam getPlayerTeam(Player player) { diff --git a/src/me/yaruma/fightsystem/fight/FightCreator.java b/src/me/yaruma/fightsystem/fight/FightCreator.java index 69c38fb..7ee7619 100644 --- a/src/me/yaruma/fightsystem/fight/FightCreator.java +++ b/src/me/yaruma/fightsystem/fight/FightCreator.java @@ -2,8 +2,9 @@ package me.yaruma.fightsystem.fight; import org.bukkit.entity.Player; -public class FightCreator { +class FightCreator { + @SuppressWarnings("EmptyMethod") public static void invitePlayerToTeam(Player player) { } diff --git a/src/me/yaruma/fightsystem/fight/FightState.java b/src/me/yaruma/fightsystem/fight/FightState.java index 3df2b81..6e30788 100644 --- a/src/me/yaruma/fightsystem/fight/FightState.java +++ b/src/me/yaruma/fightsystem/fight/FightState.java @@ -5,5 +5,5 @@ public enum FightState { SETUP, PRE_RUNNING, RUNNING, - SPECTATE; + SPECTATE } diff --git a/src/me/yaruma/fightsystem/fight/FightTeam.java b/src/me/yaruma/fightsystem/fight/FightTeam.java index 1f67fe2..2b73ecc 100644 --- a/src/me/yaruma/fightsystem/fight/FightTeam.java +++ b/src/me/yaruma/fightsystem/fight/FightTeam.java @@ -11,10 +11,10 @@ import java.util.ArrayList; public class FightTeam { private FightPlayer leader; - private ArrayList players; + private final ArrayList players; private FightSystem plugin; private boolean ready; - private ArrayList invited; + private final ArrayList invited; private String name; private String prefix; @@ -115,7 +115,7 @@ public class FightTeam { FightSystem instance = FightSystem.getPlugin(); - if(this.ready == true) { + if(this.ready) { fightTeam.getLeader().getPlayer().getInventory().setItem(3, new ItemBuilder(Material.INK_SACK, (short) 8).removeAllAtributs().addEnchantment(Enchantment.DURABILITY,1 ).setDisplayName("§aBereit").build()); broadcast(FightSystem.PREFIX + "§aEuer Team ist nun bereit!"); diff --git a/src/me/yaruma/fightsystem/fight/WaterRemover.java b/src/me/yaruma/fightsystem/fight/WaterRemover.java index 2c91df3..06aef9d 100644 --- a/src/me/yaruma/fightsystem/fight/WaterRemover.java +++ b/src/me/yaruma/fightsystem/fight/WaterRemover.java @@ -15,41 +15,37 @@ import java.util.List; public class WaterRemover { - private List> explodedBlocks = new ArrayList>(); - private List waterList = new ArrayList(); + private List> explodedBlocks = new ArrayList<>(); + private List waterList = new ArrayList<>(); private BukkitTask task; public void start() { this.stop(); - this.explodedBlocks = new ArrayList>(); - this.waterList = new ArrayList(); - this.task = Bukkit.getScheduler().runTaskTimerAsynchronously((Plugin)FightSystem.getPlugin(), new Runnable(){ - - @Override - public void run() { - try { - WaterRemover.this.wateredCheck(); - WaterRemover.this.removeWater(); - } - catch (Exception e) { - e.printStackTrace(); - } + this.explodedBlocks = new ArrayList<>(); + this.waterList = new ArrayList<>(); + this.task = Bukkit.getScheduler().runTaskTimerAsynchronously((Plugin)FightSystem.getPlugin(), () -> { + try { + WaterRemover.this.wateredCheck(); + WaterRemover.this.removeWater(); + } + catch (Exception e) { + e.printStackTrace(); } }, 0L, 20L); } - public void stop() { + private void stop() { if (this.task != null) { this.task.cancel(); } } public void add(Location loc) { - this.explodedBlocks.add(new AbstractMap.SimpleEntry(loc, 0)); + this.explodedBlocks.add(new AbstractMap.SimpleEntry<>(loc, 0)); } private void wateredCheck() { - for (int i = 0; i < this.explodedBlocks.size(); ++i) { + for (int i = this.explodedBlocks.size() - 1; i >= 0; i--) { if (this.explodedBlocks.get(i).getValue() >= 15) { Block b = this.explodedBlocks.get(i).getKey().getBlock(); if (b.getType() == Material.WATER || b.getType() == Material.STATIONARY_WATER) { @@ -63,12 +59,10 @@ public class WaterRemover { } private void removeWater() { - ArrayList blocksToRemove = new ArrayList(); + ArrayList blocksToRemove = new ArrayList<>(); for (int i = this.waterList.size() - 1; i > -1; --i) { Block current = this.waterList.get(i); - for (Block removeBlock : this.getSourceBlocksOfWater(current)) { - blocksToRemove.add(removeBlock); - } + blocksToRemove.addAll(this.getSourceBlocksOfWater(current)); if (current.getType() != Material.AIR) continue; this.waterList.remove(i); } @@ -80,12 +74,12 @@ public class WaterRemover { } private List getSourceBlocksOfWater(Block startBlock) { - ArrayList water = new ArrayList(); - this.collectBlocks(startBlock, water, new ArrayList()); + ArrayList water = new ArrayList<>(); + this.collectBlocks(startBlock, water, new ArrayList<>()); return water; } - public void collectBlocks(Block anchor, List collected, List visitedBlocks) { + private void collectBlocks(Block anchor, List collected, List visitedBlocks) { if (anchor.getType() != Material.WATER && anchor.getType() != Material.STATIONARY_WATER) { return; } diff --git a/src/me/yaruma/fightsystem/listener/BlockBreakListener.java b/src/me/yaruma/fightsystem/listener/BlockBreakListener.java index ee8e82d..41a9ee8 100644 --- a/src/me/yaruma/fightsystem/listener/BlockBreakListener.java +++ b/src/me/yaruma/fightsystem/listener/BlockBreakListener.java @@ -10,7 +10,7 @@ import org.bukkit.event.block.BlockBreakEvent; public class BlockBreakListener implements Listener { - FightSystem instance = FightSystem.getPlugin(); + private final FightSystem instance = FightSystem.getPlugin(); @EventHandler public void handleBlockBreak(BlockBreakEvent event) { diff --git a/src/me/yaruma/fightsystem/listener/EntityDamageByEntityListener.java b/src/me/yaruma/fightsystem/listener/EntityDamageByEntityListener.java index ffd49f3..ef35167 100644 --- a/src/me/yaruma/fightsystem/listener/EntityDamageByEntityListener.java +++ b/src/me/yaruma/fightsystem/listener/EntityDamageByEntityListener.java @@ -11,43 +11,37 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; public class EntityDamageByEntityListener implements Listener { - FightSystem instance = FightSystem.getPlugin(); + private final FightSystem instance = FightSystem.getPlugin(); @EventHandler public void handleEntityDamageByEntity(EntityDamageByEntityEvent event) { if(instance.getFightState() != FightState.RUNNING) { event.setCancelled(true); - } else { - if(event.getEntity() instanceof Player) { - Player player = ((Player) event.getEntity()).getPlayer(); + } else if(event.getEntity() instanceof Player) { + Player player = ((Player) event.getEntity()).getPlayer(); - if(event.getDamager() instanceof Player) { - Player damager = ((Player) event.getDamager()).getPlayer(); + if(event.getDamager() instanceof Player) { + Player damager = ((Player) event.getDamager()).getPlayer(); - if(Fight.getPlayerTeam(player) != null) { - if(Fight.getPlayerTeam(player) == Fight.getPlayerTeam(damager)) { - event.setCancelled(true); - damager.sendMessage(FightSystem.PREFIX + "§cDu darfst deinen Teamkollegen keinen Schaden machen!"); - } - } else - event.setCancelled(true); - return; - } - - if(event.getDamager() instanceof Arrow) { - Arrow damagerArrow = (Arrow) event.getDamager(); - if(!(damagerArrow.getShooter() instanceof Player)) { - return; - } - Player damager = (Player) damagerArrow.getShooter(); + if(Fight.getPlayerTeam(player) != null) { if(Fight.getPlayerTeam(player) == Fight.getPlayerTeam(damager)) { event.setCancelled(true); - damager.sendMessage(FightSystem.PREFIX + "§cDu darfst deinen Teamkollegen keinen Schaden machen!"); - damagerArrow.setFireTicks(0); - player.setFireTicks(0); + damager.sendMessage(FightSystem.PREFIX + "§cDu darfst deinen Teamkollegen keinen Schaden zufügen!"); } + } else + event.setCancelled(true); + }else if(event.getDamager() instanceof Arrow) { + Arrow damagerArrow = (Arrow) event.getDamager(); + if(!(damagerArrow.getShooter() instanceof Player)) { return; } + Player damager = (Player) damagerArrow.getShooter(); + if(Fight.getPlayerTeam(player) == Fight.getPlayerTeam(damager)) { + event.setCancelled(true); + damager.sendMessage(FightSystem.PREFIX + "§cDu darfst deinen Teamkollegen keinen Schaden zufügen!"); + damagerArrow.setFireTicks(0); + player.setFireTicks(0); + } } } } diff --git a/src/me/yaruma/fightsystem/listener/EntityExplodeListener.java b/src/me/yaruma/fightsystem/listener/EntityExplodeListener.java index 0efc40d..620acbc 100644 --- a/src/me/yaruma/fightsystem/listener/EntityExplodeListener.java +++ b/src/me/yaruma/fightsystem/listener/EntityExplodeListener.java @@ -1,6 +1,7 @@ package me.yaruma.fightsystem.listener; import me.yaruma.fightsystem.FightSystem; +import me.yaruma.fightsystem.fight.FightState; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.event.EventHandler; @@ -11,6 +12,7 @@ public class EntityExplodeListener implements Listener { @EventHandler public void handleEntityExplode(EntityExplodeEvent event) { + if(FightSystem.getPlugin().getFightState() != FightState.RUNNING) return; for(Block block : event.blockList()) { if(block.getType() != Material.WATER || block.getType() != Material.STATIONARY_WATER) FightSystem.getPlugin().getWaterRemover().add(block.getLocation()); diff --git a/src/me/yaruma/fightsystem/listener/PlayerChatListener.java b/src/me/yaruma/fightsystem/listener/PlayerChatListener.java index 6257841..2f26c5c 100644 --- a/src/me/yaruma/fightsystem/listener/PlayerChatListener.java +++ b/src/me/yaruma/fightsystem/listener/PlayerChatListener.java @@ -12,7 +12,7 @@ import org.bukkit.event.player.PlayerChatEvent; public class PlayerChatListener implements Listener { - FileManager fileManager = FightSystem.getPlugin().getFileManager(); + private final FileManager fileManager = FightSystem.getPlugin().getFileManager(); @EventHandler public void handlePlayerChat(PlayerChatEvent event) { diff --git a/src/me/yaruma/fightsystem/listener/PlayerDeathListener.java b/src/me/yaruma/fightsystem/listener/PlayerDeathListener.java index 70efc8d..25394ad 100644 --- a/src/me/yaruma/fightsystem/listener/PlayerDeathListener.java +++ b/src/me/yaruma/fightsystem/listener/PlayerDeathListener.java @@ -3,7 +3,6 @@ package me.yaruma.fightsystem.listener; import me.yaruma.fightsystem.FightSystem; import me.yaruma.fightsystem.fight.Fight; import me.yaruma.fightsystem.fight.FightTeam; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; diff --git a/src/me/yaruma/fightsystem/listener/PlayerInteractListener.java b/src/me/yaruma/fightsystem/listener/PlayerInteractListener.java index 5ca39c6..a071cd2 100644 --- a/src/me/yaruma/fightsystem/listener/PlayerInteractListener.java +++ b/src/me/yaruma/fightsystem/listener/PlayerInteractListener.java @@ -17,7 +17,7 @@ import org.bukkit.inventory.meta.ItemMeta; public class PlayerInteractListener implements Listener { FileManager fileManager = FightSystem.getPlugin().getFileManager(); - FightSystem instance = FightSystem.getPlugin(); + private final FightSystem instance = FightSystem.getPlugin(); @EventHandler public void handlePlayerInteract(PlayerInteractEvent event) { diff --git a/src/me/yaruma/fightsystem/listener/PlayerJoinListener.java b/src/me/yaruma/fightsystem/listener/PlayerJoinListener.java index 1c3f314..30632bd 100644 --- a/src/me/yaruma/fightsystem/listener/PlayerJoinListener.java +++ b/src/me/yaruma/fightsystem/listener/PlayerJoinListener.java @@ -19,8 +19,8 @@ import org.bukkit.event.player.PlayerJoinEvent; public class PlayerJoinListener implements Listener { - FightSystem instance = FightSystem.getPlugin(); - FileManager fileManager = instance.getFileManager(); + private final FightSystem instance = FightSystem.getPlugin(); + private final FileManager fileManager = instance.getFileManager(); @EventHandler public void handlePlayerJoin(PlayerJoinEvent event) { diff --git a/src/me/yaruma/fightsystem/listener/PlayerMoveListener.java b/src/me/yaruma/fightsystem/listener/PlayerMoveListener.java index f9d7e9f..b931d56 100644 --- a/src/me/yaruma/fightsystem/listener/PlayerMoveListener.java +++ b/src/me/yaruma/fightsystem/listener/PlayerMoveListener.java @@ -14,8 +14,8 @@ import org.bukkit.event.player.PlayerMoveEvent; public class PlayerMoveListener implements Listener { - FightSystem instance = FightSystem.getPlugin(); - FileManager fileManager = FightSystem.getPlugin().getFileManager(); + private final FightSystem instance = FightSystem.getPlugin(); + private final FileManager fileManager = FightSystem.getPlugin().getFileManager(); @EventHandler public void handlePlayerMove(PlayerMoveEvent event) { @@ -56,10 +56,7 @@ public class PlayerMoveListener implements Listener { } }else if(fightTeam != null && !instance.isEntern()){ player.teleport(from); - if (fightTeam == Fight.blueTeam) - player.sendMessage(FightSystem.PREFIX + "§cDu darfst nicht zu Team " + fileManager.getStringFromConfig("Output.TeamRedColor") + fileManager.getStringFromConfig("Output.TeamRedName") + " §c!"); - else - player.sendMessage(FightSystem.PREFIX + "§cDu darfst nicht zu Team " + fileManager.getStringFromConfig("Output.TeamBlueColor") + fileManager.getStringFromConfig("Output.TeamBlueName") + " §c!"); + player.sendMessage(FightSystem.PREFIX + "§cDu darfst nicht zu " + Fight.getOpposite(fightTeam).getPrefix() + Fight.getOpposite(fightTeam).getName() + "§c!"); } } } diff --git a/src/me/yaruma/fightsystem/listener/PlayerQuitListener.java b/src/me/yaruma/fightsystem/listener/PlayerQuitListener.java index c0d9613..afbb184 100644 --- a/src/me/yaruma/fightsystem/listener/PlayerQuitListener.java +++ b/src/me/yaruma/fightsystem/listener/PlayerQuitListener.java @@ -6,7 +6,6 @@ import me.yaruma.fightsystem.fight.FightState; import me.yaruma.fightsystem.fight.FightTeam; import me.yaruma.fightsystem.utils.countdown.Countdown; import me.yaruma.fightsystem.utils.countdown.FinishNoPlayersOnline; -import me.yaruma.fightsystem.utils.countdown.FinishSpectateOver; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; diff --git a/src/me/yaruma/fightsystem/listener/PlayerRespawnListener.java b/src/me/yaruma/fightsystem/listener/PlayerRespawnListener.java index 6b088e7..f310a95 100644 --- a/src/me/yaruma/fightsystem/listener/PlayerRespawnListener.java +++ b/src/me/yaruma/fightsystem/listener/PlayerRespawnListener.java @@ -9,7 +9,7 @@ import org.bukkit.event.player.PlayerRespawnEvent; public class PlayerRespawnListener implements Listener { - FightSystem instance = FightSystem.getPlugin(); + private final FightSystem instance = FightSystem.getPlugin(); @EventHandler public void handlePlayerRespawn(PlayerRespawnEvent event) { diff --git a/src/me/yaruma/fightsystem/manager/FileManager.java b/src/me/yaruma/fightsystem/manager/FileManager.java index 5dd0cef..f36d047 100644 --- a/src/me/yaruma/fightsystem/manager/FileManager.java +++ b/src/me/yaruma/fightsystem/manager/FileManager.java @@ -4,16 +4,12 @@ import me.yaruma.fightsystem.FightSystem; import java.io.File; import java.io.IOException; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.World; import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.configuration.file.FileConfigurationOptions; public class FileManager { - public File file; - public FileConfiguration config; + private final File file; + private final FileConfiguration config; public FileManager(FightSystem instance) { this.config = instance.getConfig(); @@ -55,7 +51,7 @@ public class FileManager return this.config; } - public void save() { + private void save() { try { this.config.save(this.file); } diff --git a/src/me/yaruma/fightsystem/utils/ItemBuilder.java b/src/me/yaruma/fightsystem/utils/ItemBuilder.java index 5fbe357..4673dd5 100644 --- a/src/me/yaruma/fightsystem/utils/ItemBuilder.java +++ b/src/me/yaruma/fightsystem/utils/ItemBuilder.java @@ -10,8 +10,8 @@ import org.bukkit.inventory.meta.ItemMeta; public class ItemBuilder { - private ItemStack item; - private ItemMeta meta; + private final ItemStack item; + private final ItemMeta meta; public ItemBuilder(Material matrial) { item = new ItemStack(matrial); diff --git a/src/me/yaruma/fightsystem/utils/Region.java b/src/me/yaruma/fightsystem/utils/Region.java index 2725bc6..0312fc9 100644 --- a/src/me/yaruma/fightsystem/utils/Region.java +++ b/src/me/yaruma/fightsystem/utils/Region.java @@ -1,7 +1,6 @@ package me.yaruma.fightsystem.utils; import org.bukkit.Location; -import org.bukkit.entity.Player; public class Region { @@ -17,7 +16,7 @@ public class Region { return isIn2DRegion(location, minX, minZ, minX + xRange, minZ + zRange, margin); } - public static boolean isIn2DRegion(Location location, int minX, int minZ, int maxX, int maxZ, int margin){ + private static boolean isIn2DRegion(Location location, int minX, int minZ, int maxX, int maxZ, int margin){ return inRange(location.getBlockX(), minX, maxX, margin) && inRange(location.getBlockZ(), minZ, maxZ, margin); } @@ -25,11 +24,11 @@ public class Region { return inRange(location.getBlockX(), minX, maxX) && inRange(location.getBlockZ(), minZ, maxZ); } - public static boolean inRange(double value, int min, int max, int margin){ + private static boolean inRange(double value, int min, int max, int margin){ return inRange(value, min-margin, max+margin); } - public static boolean inRange(double value, int min, int max){ + private static boolean inRange(double value, int min, int max){ return min <= value && value <= max; } } diff --git a/src/me/yaruma/fightsystem/utils/countdown/Countdown.java b/src/me/yaruma/fightsystem/utils/countdown/Countdown.java index 4cfb118..c146139 100644 --- a/src/me/yaruma/fightsystem/utils/countdown/Countdown.java +++ b/src/me/yaruma/fightsystem/utils/countdown/Countdown.java @@ -8,10 +8,10 @@ import java.util.ArrayList; public class Countdown { - private static ArrayList countdowns = new ArrayList<>(); + private static final ArrayList countdowns = new ArrayList<>(); private int time; - private CountdownCallback countdownCallback; + private final CountdownCallback countdownCallback; private int taskID; public Countdown(int time, CountdownCallback countdownCallback) { @@ -45,7 +45,7 @@ public class Countdown { }, 0, 20); } - public void cancelTimer() { + private void cancelTimer() { try { Bukkit.getScheduler().cancelTask(this.taskID); @@ -68,7 +68,7 @@ public class Countdown { } } - public CountdownType getType() { + private CountdownType getType() { return countdownCallback.getType(); } } diff --git a/src/me/yaruma/fightsystem/utils/countdown/CountdownCallback.java b/src/me/yaruma/fightsystem/utils/countdown/CountdownCallback.java index 766756f..471f6cf 100644 --- a/src/me/yaruma/fightsystem/utils/countdown/CountdownCallback.java +++ b/src/me/yaruma/fightsystem/utils/countdown/CountdownCallback.java @@ -1,6 +1,6 @@ package me.yaruma.fightsystem.utils.countdown; -public interface CountdownCallback { +interface CountdownCallback { String countdownCounting(); void countdownFinished(); diff --git a/src/me/yaruma/fightsystem/utils/countdown/CountdownType.java b/src/me/yaruma/fightsystem/utils/countdown/CountdownType.java index 66489c5..f148d78 100644 --- a/src/me/yaruma/fightsystem/utils/countdown/CountdownType.java +++ b/src/me/yaruma/fightsystem/utils/countdown/CountdownType.java @@ -7,7 +7,7 @@ public enum CountdownType { PRE_RUNNING, SETUP_OVER, SPECTATE_OVER, - TIME_OVER; + TIME_OVER } diff --git a/src/me/yaruma/fightsystem/utils/countdown/FinishPreRunning.java b/src/me/yaruma/fightsystem/utils/countdown/FinishPreRunning.java index 3831c29..3d3be55 100644 --- a/src/me/yaruma/fightsystem/utils/countdown/FinishPreRunning.java +++ b/src/me/yaruma/fightsystem/utils/countdown/FinishPreRunning.java @@ -2,7 +2,6 @@ package me.yaruma.fightsystem.utils.countdown; import me.yaruma.fightsystem.FightSystem; import me.yaruma.fightsystem.manager.FileManager; -import org.bukkit.Bukkit; public class FinishPreRunning implements CountdownCallback { diff --git a/src/me/yaruma/fightsystem/utils/scoreboard/Scoreboard.java b/src/me/yaruma/fightsystem/utils/scoreboard/Scoreboard.java index 69f0997..cf67d48 100644 --- a/src/me/yaruma/fightsystem/utils/scoreboard/Scoreboard.java +++ b/src/me/yaruma/fightsystem/utils/scoreboard/Scoreboard.java @@ -13,33 +13,31 @@ import org.bukkit.scoreboard.ScoreboardManager; public class Scoreboard { - private ScoreboardManager scoreboardManager; - private org.bukkit.scoreboard.Scoreboard scoreboard; - private Objective objective; - private int taskID; + private final org.bukkit.scoreboard.Scoreboard scoreboard; + private final Objective objective; public Scoreboard(FightSystem instance) { - this.scoreboardManager = Bukkit.getScoreboardManager(); - this.scoreboard = this.scoreboardManager.getNewScoreboard(); + ScoreboardManager scoreboardManager = Bukkit.getScoreboardManager(); + this.scoreboard = scoreboardManager.getNewScoreboard(); this.objective = scoreboard.registerNewObjective("AAA", "BBB"); } public void setAutoScoreboard(int delay, Player player) { - taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(FightSystem.getPlugin(), new Runnable() { + int taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(FightSystem.getPlugin(), new Runnable() { private int index = 0; @Override public void run() { FightTeam fightTeam = getIndexDisplay(index); - if(fightTeam != null) { + if (fightTeam != null) { objective.unregister(); scoreboard.registerNewObjective("AAA", "BBB"); objective.setDisplaySlot(DisplaySlot.SIDEBAR); objective.setDisplayName(fightTeam.getPrefix() + fightTeam.getName()); - for(FightPlayer fp : fightTeam.getPlayers()) { + for (FightPlayer fp : fightTeam.getPlayers()) { objective.getScore(fightTeam.getPrefix() + fp.getPlayer().getName()).setScore((int) fp.getPlayer().getHealth()); } @@ -52,16 +50,19 @@ public class Scoreboard { objective.setDisplaySlot(DisplaySlot.SIDEBAR); objective.setDisplayName("§6Kampf"); - if(Methods.isEnabled("WinConditions.Timeout")){ + if (Methods.isEnabled("WinConditions.Timeout")) { int fightTime = FightSystem.getPlugin().getFightTime(); - if(fightTime >= 60) - objective.getScore("§7Zeit: §a" + fightTime/60 + "m " + fightTime%60 + "s" ).setScore(3); + if (fightTime >= 60) + objective.getScore("§7Zeit: §a" + fightTime / 60 + "m " + fightTime % 60 + "s").setScore(3); else objective.getScore("§7Zeit: §a" + fightTime + "s").setScore(3); } - if(Methods.isEnabled("WinConditions.Entern")) objective.getScore("§7Entern: " + (FightSystem.getPlugin().isEntern() ? "§aja" : "§cnein")).setScore(2); - if(Methods.isEnabled("WinConditions.PercentSystem")) objective.getScore("§eSchaden ROT: §c" + FightSystem.getPlugin().getDamageRed() + "%").setScore(1); - if(Methods.isEnabled("WinConditions.PercentSystem")) objective.getScore("§eSchaden BLAU: §c" + FightSystem.getPlugin().getGetDamageBlue() + "%").setScore(0); + if (Methods.isEnabled("WinConditions.Entern")) + objective.getScore("§7Entern: " + (FightSystem.getPlugin().isEntern() ? "§aja" : "§cnein")).setScore(2); + if (Methods.isEnabled("WinConditions.PercentSystem")) + objective.getScore("§eSchaden ROT: §c" + FightSystem.getPlugin().getDamageRed() + "%").setScore(1); + if (Methods.isEnabled("WinConditions.PercentSystem")) + objective.getScore("§eSchaden BLAU: §c" + FightSystem.getPlugin().getGetDamageBlue() + "%").setScore(0); index = 0; } player.setScoreboard(scoreboard); diff --git a/src/me/yaruma/fightsystem/winconditions/WinconditionAllDead.java b/src/me/yaruma/fightsystem/winconditions/WinconditionAllDead.java index 3596f31..c488c56 100644 --- a/src/me/yaruma/fightsystem/winconditions/WinconditionAllDead.java +++ b/src/me/yaruma/fightsystem/winconditions/WinconditionAllDead.java @@ -12,7 +12,7 @@ import org.bukkit.event.player.PlayerQuitEvent; public class WinconditionAllDead implements Listener { - FightSystem instance = FightSystem.getPlugin(); + private final FightSystem instance = FightSystem.getPlugin(); @EventHandler public void handlePlayerDeath(PlayerDeathEvent event) { diff --git a/src/me/yaruma/fightsystem/winconditions/WinconditionCaptainDead.java b/src/me/yaruma/fightsystem/winconditions/WinconditionCaptainDead.java index d7261a8..7dc8cfd 100644 --- a/src/me/yaruma/fightsystem/winconditions/WinconditionCaptainDead.java +++ b/src/me/yaruma/fightsystem/winconditions/WinconditionCaptainDead.java @@ -13,7 +13,7 @@ import org.bukkit.event.player.PlayerQuitEvent; public class WinconditionCaptainDead implements Listener { - FightSystem instance = FightSystem.getPlugin(); + private final FightSystem instance = FightSystem.getPlugin(); FileManager fileManager = instance.getFileManager(); @EventHandler diff --git a/src/me/yaruma/fightsystem/winconditions/WinconditionEntern.java b/src/me/yaruma/fightsystem/winconditions/WinconditionEntern.java index 89f3946..8d51db1 100644 --- a/src/me/yaruma/fightsystem/winconditions/WinconditionEntern.java +++ b/src/me/yaruma/fightsystem/winconditions/WinconditionEntern.java @@ -7,8 +7,8 @@ import me.yaruma.fightsystem.utils.countdown.FinishNoneEntern; public class WinconditionEntern { - private static FightSystem instance = FightSystem.getPlugin(); - private static FileManager fileManager = instance.getFileManager(); + private static final FightSystem instance = FightSystem.getPlugin(); + private static final FileManager fileManager = instance.getFileManager(); public static void entern() { if(!Methods.isEnabled("WinConditions.Entern")) return; diff --git a/src/me/yaruma/fightsystem/winconditions/WinconditionPercentSystem.java b/src/me/yaruma/fightsystem/winconditions/WinconditionPercentSystem.java index 9800511..ee95898 100644 --- a/src/me/yaruma/fightsystem/winconditions/WinconditionPercentSystem.java +++ b/src/me/yaruma/fightsystem/winconditions/WinconditionPercentSystem.java @@ -12,13 +12,13 @@ import org.bukkit.event.entity.EntityExplodeEvent; public class WinconditionPercentSystem implements Listener { - public static int team1DestroyedBlocks; - public static int team2DestroyedBlocks; + private static int team1DestroyedBlocks; + private static int team2DestroyedBlocks; - FightSystem instance = FightSystem.getPlugin(); - FileManager fileManager = instance.getFileManager(); + private final FightSystem instance = FightSystem.getPlugin(); + private final FileManager fileManager = instance.getFileManager(); - private static int schematicSize = + private static final int schematicSize = Math.abs( FightSystem.getPlugin().getFileManager().getIntegerFromConfig("Arena.Schemsize.x") * FightSystem.getPlugin().getFileManager().getIntegerFromConfig("Arena.Schemsize.y") * diff --git a/src/me/yaruma/fightsystem/winconditions/WinconditionTimeout.java b/src/me/yaruma/fightsystem/winconditions/WinconditionTimeout.java index 10a0da4..51c2b59 100644 --- a/src/me/yaruma/fightsystem/winconditions/WinconditionTimeout.java +++ b/src/me/yaruma/fightsystem/winconditions/WinconditionTimeout.java @@ -7,8 +7,8 @@ import me.yaruma.fightsystem.utils.countdown.FinishTimeOver; public class WinconditionTimeout { - private static FightSystem instance = FightSystem.getPlugin(); - private static FileManager fileManager = instance.getFileManager(); + private static final FightSystem instance = FightSystem.getPlugin(); + private static final FileManager fileManager = instance.getFileManager(); public static void timeout() { if(!Methods.isEnabled("WinConditions.Timeout")) return;