diff --git a/FightSystem_API/src/de/steamwar/fightsystem/Config.java b/FightSystem_API/src/de/steamwar/fightsystem/Config.java index 6bc2361..6ecaabe 100644 --- a/FightSystem_API/src/de/steamwar/fightsystem/Config.java +++ b/FightSystem_API/src/de/steamwar/fightsystem/Config.java @@ -24,9 +24,10 @@ public class Config { public static final int PreSchemPasteDuration; public static final int SetupDuration; public static final int PreFightDuration; - public static final int EnterPhaseBegin; public static final int SpectatorDuration; - public static final boolean Entern; + + // entern parameter + public static final List EnterStages; //arena parameter public static final int SchemsizeX; @@ -183,16 +184,16 @@ public class Config { PercentSystem = config.getBoolean("WinConditions.PercentSystem"); RelativePercent = config.getBoolean("WinConditions.RelativePercent"); Points = config.getBoolean("WinConditions.Points"); - Entern = config.getBoolean("WinConditions.Entern"); TechKO = config.getBoolean("WinConditions.TechKO"); WaterTechKO = config.getBoolean("WinConditions.WaterTechKO"); PumpkinTechKO = config.getBoolean("WinConditions.PumpkinTechKO"); TimeoutTime = config.getInt("WinConditionParams.TimeoutTime"); - EnterPhaseBegin = config.getInt("WinConditionParams.EnterPhaseBegin"); PercentWin = config.getDouble("WinConditionParams.PercentWin"); IgnoredBlocks = Collections.unmodifiableList(config.getStringList("WinConditionParams.IgnoredBlocks")); + EnterStages = Collections.unmodifiableList(config.getIntegerList("EnterStages")); + MemberDefault = config.getString("Kits.MemberDefault"); LeaderDefault = config.getString("Kits.LeaderDefault"); PersonalKits = config.getBoolean("Kits.PersonalKits"); diff --git a/FightSystem_API/src/de/steamwar/fightsystem/IFightSystem.java b/FightSystem_API/src/de/steamwar/fightsystem/IFightSystem.java index 87856b8..6a0a0eb 100644 --- a/FightSystem_API/src/de/steamwar/fightsystem/IFightSystem.java +++ b/FightSystem_API/src/de/steamwar/fightsystem/IFightSystem.java @@ -11,7 +11,6 @@ public class IFightSystem { private static Plugin plugin; private static String prefix; private static EventFight eventFight; - private static boolean entern = false; private static Player eventLeiter; public static void init(Plugin plugin, String prefix){ @@ -21,9 +20,6 @@ public class IFightSystem { static void setEventFight(EventFight ef){ eventFight = ef; } - static void setEntern(boolean entern){ - IFightSystem.entern = entern; - } static void setEventLeiter(Player el){ eventLeiter = el; } @@ -37,9 +33,6 @@ public class IFightSystem { public static EventFight getEventFight(){ return eventFight; } - public static boolean isEntern(){ - return entern; - } public static Player getEventLeiter(){ return eventLeiter; } diff --git a/FightSystem_API/src/de/steamwar/fightsystem/fight/IFightTeam.java b/FightSystem_API/src/de/steamwar/fightsystem/fight/IFightTeam.java index 6491970..c18a8a7 100644 --- a/FightSystem_API/src/de/steamwar/fightsystem/fight/IFightTeam.java +++ b/FightSystem_API/src/de/steamwar/fightsystem/fight/IFightTeam.java @@ -6,4 +6,5 @@ public interface IFightTeam { boolean isBlue(); boolean isPlayerInTeam(Player player); + boolean canPlayerEntern(Player player); } diff --git a/FightSystem_API/src/de/steamwar/fightsystem/utils/ITechHider.java b/FightSystem_API/src/de/steamwar/fightsystem/utils/ITechHider.java index d8540b4..144075f 100644 --- a/FightSystem_API/src/de/steamwar/fightsystem/utils/ITechHider.java +++ b/FightSystem_API/src/de/steamwar/fightsystem/utils/ITechHider.java @@ -70,13 +70,13 @@ public class ITechHider { arenaMinZ > chunkZ || chunkZ > arenaMaxZ; }else if(ft.isBlue()){ - return IFightSystem.isEntern() || + return ft.canPlayerEntern(p) || redMinX > chunkX || chunkX > redMaxX || redMinZ > chunkZ || chunkZ > redMaxZ; }else{ - return IFightSystem.isEntern() || + return ft.canPlayerEntern(p) || blueMinX > chunkX || chunkX > blueMaxX || blueMinZ > chunkZ || diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java b/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java index feb9395..70fced4 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java @@ -21,7 +21,6 @@ import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.Objects; import java.util.logging.Level; @@ -77,6 +76,8 @@ public class FightSystem extends JavaPlugin { if(Core.getVersion() > 8) new ExtendedInventoryListener(); + new EnterHandler(); + new WinconditionAllDead(); new WinconditionCaptainDead(); new WinconditionPumpkinTechKO(); @@ -172,30 +173,11 @@ public class FightSystem extends JavaPlugin { setFightState(FightState.RUNNING); setAllPlayersGM(GameMode.SURVIVAL); - if(Config.Entern) - mainCountdown = new EnternCountdown(); - FightStatistics.start(); WaterRemover.init(); Bukkit.broadcastMessage(PREFIX + "§aArena freigegeben!"); } - public static void setEntern() { - if(fightState != FightState.RUNNING) - throw new SecurityException(fightState.name()); - setFightState(FightState.ENTERN); - - final List chunksBlue = TechHider.prepareChunkReload(Fight.getBlueTeam().getPlayers().iterator().next().getPlayer()); - final List chunksRed = TechHider.prepareChunkReload(Fight.getRedTeam().getPlayers().iterator().next().getPlayer()); - IFightSystem.setEntern(true); - for(FightPlayer player : Fight.getBlueTeam().getPlayers()){ - TechHider.reloadChunks(player.getPlayer(), chunksBlue); - } - for(FightPlayer player : Fight.getRedTeam().getPlayers()){ - TechHider.reloadChunks(player.getPlayer(), chunksRed); - } - } - public static void setSpectateState(FightTeam winFightTeam, String windescription) { if(!fightState.ingame()) throw new SecurityException(fightState.name()); diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/Countdown.java b/FightSystem_Main/src/de/steamwar/fightsystem/countdown/Countdown.java index c26acc1..d330b6c 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/Countdown.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/countdown/Countdown.java @@ -59,7 +59,7 @@ public abstract class Countdown { BasicListener.toActionbar(p, msg); } - private void count(){ + void count(){ switch (time) { case 900: case 600: case 300: case 180: case 120: broadcast("§rNoch §a" + time / 60 + " §rMinuten " + countdownCounting()); diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/EnternCountdown.java b/FightSystem_Main/src/de/steamwar/fightsystem/countdown/EnternCountdown.java index 0029c7b..c18b4bc 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/EnternCountdown.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/countdown/EnternCountdown.java @@ -1,13 +1,24 @@ package de.steamwar.fightsystem.countdown; -import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.Config; -import org.bukkit.Bukkit; +import de.steamwar.fightsystem.FightSystem; +import de.steamwar.fightsystem.fight.FightPlayer; +import de.steamwar.fightsystem.listener.BasicListener; +import de.steamwar.fightsystem.utils.ITechHider; +import de.steamwar.fightsystem.utils.TechHider; +import net.md_5.bungee.api.chat.TextComponent; +import org.bukkit.entity.Player; + +import java.util.List; public class EnternCountdown extends Countdown { - public EnternCountdown() { - super(Config.EnterPhaseBegin, SWSound.BLOCK_NOTE_PLING, false); + private final FightPlayer fightPlayer; + private List chunkPos; + + public EnternCountdown(FightPlayer fp) { + super(fp.getKit().getEnterStage(), SWSound.BLOCK_NOTE_PLING, false); + fightPlayer = fp; } @Override @@ -17,7 +28,42 @@ public class EnternCountdown extends Countdown { @Override public void countdownFinished() { - FightSystem.setEntern(); - Bukkit.broadcastMessage(FightSystem.PREFIX + "§aEntern ist nun erlaubt!"); + fightPlayer.getPlayer().sendMessage(FightSystem.PREFIX + "§aEntern ist nun erlaubt!"); + TechHider.reloadChunks(fightPlayer.getPlayer(), chunkPos); + } + + @Override + void count(){ + if(!fightPlayer.isLiving()){ + disable(); + return; + } + + Player player = fightPlayer.getPlayer(); + int time = Config.EnterStages.get(fightPlayer.getKit().getEnterStage()) - FightSystem.getFightTime(); + switch (time) { + case 900: case 600: case 300: case 180: case 120: + BasicListener.toActionbar(player, TextComponent.fromLegacyText("§rNoch §a" + time / 60 + " §rMinuten " + countdownCounting())); + break; + case 60: case 30: case 20: case 15: case 10: case 5: case 4: case 3: case 2: + player.playSound(player.getLocation(), Countdown.getSound(SWSound.BLOCK_NOTE_PLING), 100.0F, 1.0F); + + BasicListener.toActionbar(player, TextComponent.fromLegacyText("§rNoch §a" + time + " §rSekunden " + countdownCounting())); + break; + case 1: + player.playSound(player.getLocation(), Countdown.getSound(SWSound.BLOCK_NOTE_PLING), 100.0F, 1.0F); + + BasicListener.toActionbar(player, TextComponent.fromLegacyText("§rNoch §a1 §rSekunde " + countdownCounting())); + + chunkPos = TechHider.prepareChunkReload(player); + break; + case 0: + player.playSound(player.getLocation(), Countdown.getSound(SWSound.BLOCK_NOTE_PLING), 100.0F, 2.0F); + + disable(); + countdownFinished(); + break; + default: + } } } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightPlayer.java b/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightPlayer.java index 43bfbce..57f0c28 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightPlayer.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightPlayer.java @@ -1,5 +1,6 @@ package de.steamwar.fightsystem.fight; +import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.kit.KitManager; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.kit.Kit; @@ -62,4 +63,10 @@ public class FightPlayer { public void addKill(){ kills++; } + + public boolean canEntern(){ + if(Config.EnterStages.size() <= kit.getEnterStage() || kit.getEnterStage() < 0) + return false; + return Config.EnterStages.get(kit.getEnterStage()) >= FightSystem.getFightTime(); + } } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java b/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java index 22e7a21..0063501 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java @@ -127,6 +127,11 @@ public class FightTeam implements IFightTeam{ return false; } + @Override + public boolean canPlayerEntern(Player player) { + return getFightPlayer(player).canEntern(); + } + public boolean isPlayerLeader(Player player) { if(leader != null) return leader.getPlayer().equals(player); diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/kit/Kit.java b/FightSystem_Main/src/de/steamwar/fightsystem/kit/Kit.java index f7a413d..fda2c5d 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/kit/Kit.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/kit/Kit.java @@ -21,6 +21,8 @@ public class Kit { private final ItemStack[] inventory; private final ItemStack[] armor; private final Collection effects; + private final int enterStage; + private final boolean tnt; Kit(String name, Player player) { this.name = name; @@ -29,13 +31,15 @@ public class Kit { this.inventory = player.getInventory().getContents(); this.armor = player.getInventory().getArmorContents(); this.effects = player.getActivePotionEffects(); + this.enterStage = 0; + this.tnt = true; } Kit(ConfigurationSection kit){ name = kit.getName(); - inventory = Objects.requireNonNull(kit.getList("Items")).toArray(new ItemStack[1]); + inventory = Objects.requireNonNull(kit.getList("Items")).toArray(new ItemStack[0]); if(kit.isList("Armor")) - armor = Objects.requireNonNull(kit.getList("Armor")).toArray(new ItemStack[1]); + armor = Objects.requireNonNull(kit.getList("Armor")).toArray(new ItemStack[0]); else armor = null; leaderAllowed = kit.getBoolean("LeaderAllowed"); @@ -44,6 +48,8 @@ public class Kit { effects = (Collection) kit.getList("Effects"); else effects = null; + enterStage = kit.getInt("EnterStage", 0); + tnt = kit.getBoolean("TNT", true); } public String getName() { @@ -58,6 +64,16 @@ public class Kit { return memberAllowed; } + /* Is this kit allowed to set/handle tnt? */ + public boolean isTnt(){ + return tnt; + } + + /* In which stage is entern allowed? */ + public int getEnterStage() { + return enterStage; + } + public boolean isStackInKit(ItemStack stack){ for(ItemStack is : inventory){ if(stack.equals(is)) @@ -88,6 +104,8 @@ public class Kit { section.set("LeaderAllowed", leaderAllowed); section.set("MemberAllowed", memberAllowed); section.set("Effects", effects); + section.set("EnterStage", enterStage); + section.set("TNT", tnt); } /** diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/kit/KitManager.java b/FightSystem_Main/src/de/steamwar/fightsystem/kit/KitManager.java index e6a05e5..88cfd3e 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/kit/KitManager.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/kit/KitManager.java @@ -15,8 +15,7 @@ import java.util.logging.Level; public class KitManager { private KitManager(){} - private static final String KITS_PATH = "plugins/" + FightSystem.getPlugin().getName() + "/kits.data"; - private static final File kits = new File(KITS_PATH); + private static final File kits = new File(FightSystem.getPlugin().getDataFolder(), "kits.data"); private static final FileConfiguration kitData = YamlConfiguration.loadConfiguration(kits); private static final ArrayList loadedKits = new ArrayList<>(); @@ -49,7 +48,7 @@ public class KitManager { } public static void loadAllKits() { - if(!new File(KITS_PATH).exists()) { + if(!kits.exists()) { saveAllKits(); Bukkit.getLogger().log(Level.INFO, "kits.data erstellt!"); FightSystem.shutdown(null); diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/EntityExplodeListener.java b/FightSystem_Main/src/de/steamwar/fightsystem/listener/EntityExplodeListener.java index 390ddfb..facbef6 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/EntityExplodeListener.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/listener/EntityExplodeListener.java @@ -10,7 +10,7 @@ import java.util.EnumSet; public class EntityExplodeListener extends BasicListener { public EntityExplodeListener() { - super(EnumSet.of(FightState.RUNNING, FightState.ENTERN)); + super(EnumSet.of(FightState.RUNNING)); } @EventHandler diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/InFightDamageListener.java b/FightSystem_Main/src/de/steamwar/fightsystem/listener/InFightDamageListener.java index fda06cb..9bf5239 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/InFightDamageListener.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/listener/InFightDamageListener.java @@ -15,7 +15,7 @@ import java.util.Objects; public class InFightDamageListener extends BasicListener { public InFightDamageListener() { - super(EnumSet.of(FightState.RUNNING, FightState.ENTERN)); + super(EnumSet.of(FightState.RUNNING)); } @EventHandler diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/InFightInventoryListener.java b/FightSystem_Main/src/de/steamwar/fightsystem/listener/InFightInventoryListener.java index 65c1bb0..531b2e5 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/InFightInventoryListener.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/listener/InFightInventoryListener.java @@ -1,9 +1,13 @@ package de.steamwar.fightsystem.listener; +import de.steamwar.fightsystem.fight.Fight; +import de.steamwar.fightsystem.fight.FightPlayer; import de.steamwar.fightsystem.states.FightState; +import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Material; import org.bukkit.event.EventHandler; import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryDragEvent; import org.bukkit.event.inventory.InventoryPickupItemEvent; @@ -17,7 +21,7 @@ import java.util.EnumSet; public class InFightInventoryListener extends BasicListener { public InFightInventoryListener() { - super(EnumSet.of(FightState.RUNNING, FightState.ENTERN)); + super(EnumSet.of(FightState.RUNNING)); } @EventHandler @@ -93,4 +97,12 @@ public class InFightInventoryListener extends BasicListener { } } + @EventHandler + public void onBlockPlace(BlockPlaceEvent e) { + FightPlayer fp = Fight.getFightPlayer(e.getPlayer()); + if(fp != null && !fp.getKit().isTnt() && e.getBlockPlaced().getType() == Material.TNT){ + BasicListener.toActionbar(e.getPlayer(), TextComponent.fromLegacyText("§cDu darfst kein TNT setzen!")); + e.setCancelled(true); + } + } } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/PistonListener.java b/FightSystem_Main/src/de/steamwar/fightsystem/listener/PistonListener.java index 472e4b8..bbaf4d7 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/PistonListener.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/listener/PistonListener.java @@ -15,7 +15,7 @@ public class PistonListener extends BasicListener { public PistonListener() { //Wenn Entern aktiv ist, sollen Raketen etc. entern können - super(Config.Entern + super(Config.EnterStages.isEmpty() ? EnumSet.of(FightState.PRE_LEADER_SETUP, FightState.PRE_SCHEM_SETUP, FightState.POST_SCHEM_SETUP) : EnumSet.allOf(FightState.class)); } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/PlayerMoveListener.java b/FightSystem_Main/src/de/steamwar/fightsystem/listener/PlayerMoveListener.java index 2584a99..5b7561c 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/PlayerMoveListener.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/listener/PlayerMoveListener.java @@ -50,7 +50,7 @@ public class PlayerMoveListener extends BasicListener { reset(event, DENY_TEAM); else if(fightTeam == Fight.getBlueTeam() && player.getGameMode() == GameMode.SPECTATOR) reset(event, DENY_ENTERN); - }else if(fightTeam != null && FightSystem.getFightState() != FightState.ENTERN && player.getGameMode() != GameMode.SPECTATOR) + }else if(fightTeam != null && player.getGameMode() != GameMode.SPECTATOR && !fightTeam.canPlayerEntern(player)) reset(event, DENY_ENTERN); } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/states/FightState.java b/FightSystem_Main/src/de/steamwar/fightsystem/states/FightState.java index 36af1ae..34cc543 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/states/FightState.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/states/FightState.java @@ -6,13 +6,12 @@ public enum FightState { POST_SCHEM_SETUP(true, true, false, false), PRE_RUNNING(false, false, true, false), RUNNING(false, false, true, true), - ENTERN(false, false, true, true), //Can be skipped SPECTATE(false, true, false, false); private final boolean setup; //PRE_LEADER_SETUP, PRE_SCHEM_SETUP, POST_SCHEM_SETUP private final boolean outgame; //PRE_LEADER_SETUP, PRE_SCHEM_SETUP, POST_SCHEM_SETUP, SPECTATE - private final boolean ingame; //PRE_RUNNING, RUNNING, ENTERN - private final boolean infight; //RUNNING, ENTERN + private final boolean ingame; //PRE_RUNNING, RUNNING + private final boolean infight; //RUNNING FightState(boolean setup, boolean outgame, boolean ingame, boolean infight){ this.setup = setup; diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/utils/EnterHandler.java b/FightSystem_Main/src/de/steamwar/fightsystem/utils/EnterHandler.java new file mode 100644 index 0000000..3eb6d4a --- /dev/null +++ b/FightSystem_Main/src/de/steamwar/fightsystem/utils/EnterHandler.java @@ -0,0 +1,44 @@ +package de.steamwar.fightsystem.utils; + +import de.steamwar.fightsystem.Config; +import de.steamwar.fightsystem.countdown.EnternCountdown; +import de.steamwar.fightsystem.fight.Fight; +import de.steamwar.fightsystem.fight.FightPlayer; +import de.steamwar.fightsystem.fight.FightTeam; +import de.steamwar.fightsystem.states.FightState; +import de.steamwar.fightsystem.states.StateDependent; + +import java.util.EnumSet; +import java.util.HashSet; +import java.util.Set; + +public class EnterHandler implements StateDependent { + private static final Set enabled = EnumSet.of(FightState.RUNNING); + private static final Set countdowns = new HashSet<>(); + + @Override + public Set enabled() { + return enabled; + } + + private void registerTeam(FightTeam team){ + for(FightPlayer fp : team.getPlayers()){ + if(Config.EnterStages.size() > fp.getKit().getEnterStage() && fp.getKit().getEnterStage() >= 0) + countdowns.add(new EnternCountdown(fp)); + } + } + + @Override + public void enable() { + registerTeam(Fight.getBlueTeam()); + registerTeam(Fight.getRedTeam()); + } + + @Override + public void disable() { + for(EnternCountdown countdown : countdowns){ + countdown.disable(); + } + countdowns.clear(); + } +} diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/utils/FightScoreboard.java b/FightSystem_Main/src/de/steamwar/fightsystem/utils/FightScoreboard.java index f11db48..4e1b7a0 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/utils/FightScoreboard.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/utils/FightScoreboard.java @@ -19,7 +19,7 @@ public class FightScoreboard { private FightScoreboard(){} - private static final Set fullScoreboard = EnumSet.of(FightState.RUNNING, FightState.ENTERN, FightState.SPECTATE); + private static final Set fullScoreboard = EnumSet.of(FightState.RUNNING, FightState.SPECTATE); private static final Scoreboard scoreboard = Objects.requireNonNull(Bukkit.getScoreboardManager()).getMainScoreboard(); private static final Objective objective; private static int index = 0; @@ -70,8 +70,6 @@ public class FightScoreboard { else objective.getScore("§7Zeit: §a" + fightTime + "s").setScore(3); } - if (Config.Entern) - objective.getScore("§7Entern: " + (FightSystem.getFightState() == FightState.ENTERN ? "§aja" : "§cnein")).setScore(2); if(fullScoreboard.contains(FightSystem.getFightState())){ if (Config.PercentSystem){ diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/utils/WaterRemover.java b/FightSystem_Main/src/de/steamwar/fightsystem/utils/WaterRemover.java index 64ef49e..b4cb48b 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/utils/WaterRemover.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/utils/WaterRemover.java @@ -16,11 +16,19 @@ public class WaterRemover { private static final Map explodedBlocks = Collections.synchronizedMap(new HashMap<>()); private static Set waterList = new HashSet<>(); + private static boolean isRunning = false; + private static int steps = 1; public static void init() { Bukkit.getScheduler().runTaskTimerAsynchronously(FightSystem.getPlugin(), () -> { + if(isRunning){ + steps++; + return; + } + isRunning = true; wateredCheck(); removeWater(); + isRunning = false; }, 0, 20); } @@ -41,13 +49,14 @@ public class WaterRemover { it.remove(); continue; } - e.setValue(e.getValue() + 1); + e.setValue(e.getValue() + steps); if(e.getValue() > 15) it.remove(); } + steps = 1; }catch(ConcurrentModificationException e){ - wateredCheck(); + steps++; } } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/PlayerWincondition.java b/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/PlayerWincondition.java index 9cac8f5..06f21af 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/PlayerWincondition.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/PlayerWincondition.java @@ -10,7 +10,7 @@ import java.util.EnumSet; abstract class PlayerWincondition extends ListenerWincondition { PlayerWincondition(boolean condition) { - super(condition, EnumSet.of(FightState.PRE_RUNNING, FightState.RUNNING, FightState.ENTERN)); + super(condition, EnumSet.of(FightState.PRE_RUNNING, FightState.RUNNING)); } boolean isTarget(Player player){ diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionHeartRatioTimeout.java b/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionHeartRatioTimeout.java index 32d8b7c..f4721a9 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionHeartRatioTimeout.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionHeartRatioTimeout.java @@ -13,7 +13,7 @@ public class WinconditionHeartRatioTimeout extends Wincondition { private TimeOverCountdown countdown; public WinconditionHeartRatioTimeout() { - super(Config.HeartRatioTimeout, EnumSet.of(FightState.RUNNING, FightState.ENTERN)); + super(Config.HeartRatioTimeout, EnumSet.of(FightState.RUNNING)); } @Override diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPercentSystem.java b/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPercentSystem.java index b9c566a..b2146e6 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPercentSystem.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPercentSystem.java @@ -22,7 +22,7 @@ public class WinconditionPercentSystem extends ListenerWincondition { private static final int schematicSize = Math.abs(Config.SchemsizeX * Config.SchemsizeY * Config.SchemsizeZ); public WinconditionPercentSystem() { - super(Config.PercentSystem, EnumSet.of(FightState.RUNNING, FightState.ENTERN)); + super(Config.PercentSystem, EnumSet.of(FightState.RUNNING)); } @EventHandler diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPumpkinTechKO.java b/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPumpkinTechKO.java index c59d1ae..313cbff 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPumpkinTechKO.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPumpkinTechKO.java @@ -22,7 +22,7 @@ public class WinconditionPumpkinTechKO extends Wincondition { private BukkitTask task; public WinconditionPumpkinTechKO(){ - super(Config.PumpkinTechKO, EnumSet.of(FightState.PRE_RUNNING, FightState.RUNNING, FightState.ENTERN)); + super(Config.PumpkinTechKO, EnumSet.of(FightState.PRE_RUNNING, FightState.RUNNING)); } public static int getTeamBluePumpkins() { diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionRelativePercent.java b/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionRelativePercent.java index fe4efc3..0dc010b 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionRelativePercent.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionRelativePercent.java @@ -89,7 +89,8 @@ public class WinconditionRelativePercent extends Wincondition{ } private int currentBlocks(){ - if(FightSystem.getFightState() == FightState.ENTERN || FightSystem.getFightState() == FightState.SPECTATE) + // Entern active + if(!Config.EnterStages.isEmpty() && Config.EnterStages.get(0) <= FightSystem.getFightTime()) return currentBlocks; int blocks = 0; diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionTimeout.java b/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionTimeout.java index 6b95af1..8a9ea6d 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionTimeout.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionTimeout.java @@ -12,7 +12,7 @@ public class WinconditionTimeout extends Wincondition { private TimeOverCountdown countdown; public WinconditionTimeout() { - super(Config.Timeout, EnumSet.of(FightState.RUNNING, FightState.ENTERN)); + super(Config.Timeout, EnumSet.of(FightState.RUNNING)); } @Override