From 5ce40e8149b540b8442f5f51e7f6bda78fed6869 Mon Sep 17 00:00:00 2001 From: Yaruma3341 Date: Sun, 14 Apr 2019 01:23:46 +0200 Subject: [PATCH] code cleanup; reworked percent system Signed-off-by: Yaruma3341 --- src/me/yaruma/fightsystem/FightSystem.java | 11 --------- .../utils/scoreboard/Scoreboard.java | 5 ++-- .../WinconditionPercentSystem.java | 23 ++++++++++++++----- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/me/yaruma/fightsystem/FightSystem.java b/src/me/yaruma/fightsystem/FightSystem.java index 574ec79..78fe143 100644 --- a/src/me/yaruma/fightsystem/FightSystem.java +++ b/src/me/yaruma/fightsystem/FightSystem.java @@ -26,7 +26,6 @@ import java.io.File; public class FightSystem extends JavaPlugin { public static final String PREFIX = "§6Arena§8» "; - public static final String NOPERM = PREFIX + "§cDu darfst das nicht!"; private static FightSystem plugin; private Scoreboard scoreboard; @@ -224,16 +223,6 @@ public class FightSystem extends JavaPlugin { return fightTime; } - public double getDamageRed() { - double damageRed = 0D; - return damageRed; - } - - public double getGetDamageBlue() { - double getDamageBlue = 0D; - return getDamageBlue; - } - public boolean isEntern() { return entern; } diff --git a/src/me/yaruma/fightsystem/utils/scoreboard/Scoreboard.java b/src/me/yaruma/fightsystem/utils/scoreboard/Scoreboard.java index 4e48d1b..bee543f 100644 --- a/src/me/yaruma/fightsystem/utils/scoreboard/Scoreboard.java +++ b/src/me/yaruma/fightsystem/utils/scoreboard/Scoreboard.java @@ -5,6 +5,7 @@ import me.yaruma.fightsystem.fight.Fight; import me.yaruma.fightsystem.fight.FightPlayer; import me.yaruma.fightsystem.fight.FightTeam; import me.yaruma.fightsystem.utils.Config; +import me.yaruma.fightsystem.winconditions.WinconditionPercentSystem; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.scoreboard.DisplaySlot; @@ -60,8 +61,8 @@ public class Scoreboard { if (Config.Entern) objective.getScore("§7Entern: " + (FightSystem.getPlugin().isEntern() ? "§aja" : "§cnein")).setScore(2); if (Config.PercentSystem){ - objective.getScore("§eSchaden ROT: §c" + FightSystem.getPlugin().getDamageRed() + "%").setScore(1); - objective.getScore("§eSchaden BLAU: §c" + FightSystem.getPlugin().getGetDamageBlue() + "%").setScore(0); + objective.getScore("§eSchaden ROT: §c" + (Math.round(100.0 * WinconditionPercentSystem.getRedPercent()) / 100) + "%").setScore(1); + objective.getScore("§eSchaden BLAU: §c" + (Math.round(100.0 * WinconditionPercentSystem.getBluePercent()) / 100) + "%").setScore(0); } index = 0; } diff --git a/src/me/yaruma/fightsystem/winconditions/WinconditionPercentSystem.java b/src/me/yaruma/fightsystem/winconditions/WinconditionPercentSystem.java index 77dbfa0..45b37f0 100644 --- a/src/me/yaruma/fightsystem/winconditions/WinconditionPercentSystem.java +++ b/src/me/yaruma/fightsystem/winconditions/WinconditionPercentSystem.java @@ -12,6 +12,9 @@ import org.bukkit.event.entity.EntityExplodeEvent; public class WinconditionPercentSystem implements Listener { + private static double bluePercent = 0D; + private static double redPercent = 0D; + private static int blueDestroyedBlocks; private static int redDestroyedBlocks; @@ -26,22 +29,24 @@ public class WinconditionPercentSystem implements Listener { if(!Config.PercentSystem) return; Entity entity = event.getEntity(); - //Team 1 / Rot + //Team Blue if(Region.isInRange(entity.getLocation(), Config.TeamBlueCornerX, Config.TeamBlueCornerY, Config.TeamBlueCornerZ, Config.SchemsizeX, Config.SchemsizeY, Config.SchemsizeZ, Config.BorderFromSchematic)){ blueDestroyedBlocks = blueDestroyedBlocks + event.blockList().size(); - Bukkit.broadcastMessage("red"); - double destroyPercent = blueDestroyedBlocks * 100 / schematicSize; - Bukkit.broadcastMessage(" " + destroyPercent); + double doubleBlueDestroyedBlocks = blueDestroyedBlocks; + double destroyPercent = doubleBlueDestroyedBlocks * 100 / schematicSize; + bluePercent = destroyPercent; if(destroyPercent >= Config.PercentWin) { FightSystem.getPlugin().setSpectateState(Fight.blueTeam); } return; } - //Team 2 / Blau + //Team Red if(Region.isInRange(entity.getLocation(), Config.TeamRedCornerX, Config.TeamRedCornerY, Config.TeamRedCornerZ, Config.SchemsizeX, Config.SchemsizeY, Config.SchemsizeZ, Config.BorderFromSchematic)) { redDestroyedBlocks = redDestroyedBlocks + event.blockList().size(); - double destroyPercent = redDestroyedBlocks * 100 / schematicSize; + double doubleRedDestroyedBlocks = redDestroyedBlocks; + double destroyPercent = doubleRedDestroyedBlocks * 100 / schematicSize; + redPercent = destroyPercent; if(destroyPercent >= Config.PercentWin) { FightSystem.getPlugin().setSpectateState(Fight.redTeam); } @@ -49,5 +54,11 @@ public class WinconditionPercentSystem implements Listener { } } + public static double getBluePercent() { + return bluePercent; + } + public static double getRedPercent() { + return redPercent; + } }