diff --git a/README.md b/README.md index 289089d..b25b7fc 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,6 @@ The timer automatically splits every round. The PB/Segment recorder automaticall - Language: The selected Hypixel language. Currently supports EN,FR,DE. - Timer: - Default Category: The record-category to be selected when starting the game. - - Paste Delta: Whether to include +- relative to PB when clicking the round summaries to paste it in chat. - PB Announcements: Whether to show **\*\*\*NEW PERSONAL BEST\*\*\*** on PB in summaries. - SST: - Enabled: Enables / disables this feature. diff --git a/gradle.properties b/gradle.properties index 2d838c4..2c80e9d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,4 +3,4 @@ org.gradle.jvmargs=-Xmx2g baseGroup = com.github.stachelbeere1248.zombiesutils mcVersion = 1.8.9 modid = zombiesutils -version = 1.3.1-PREVIEW_4 \ No newline at end of file +version = 1.3.2 \ No newline at end of file diff --git a/src/main/java/com/github/stachelbeere1248/zombiesutils/ZombiesUtils.java b/src/main/java/com/github/stachelbeere1248/zombiesutils/ZombiesUtils.java index 1505c88..f7a20d6 100644 --- a/src/main/java/com/github/stachelbeere1248/zombiesutils/ZombiesUtils.java +++ b/src/main/java/com/github/stachelbeere1248/zombiesutils/ZombiesUtils.java @@ -40,10 +40,9 @@ public class ZombiesUtils { @Mod.EventHandler public void preInit(@NotNull FMLPreInitializationEvent event) { - logger = event.getModLog(); + this.logger = event.getModLog(); this.config = new ZombiesUtilsConfig(new Configuration( - event.getSuggestedConfigurationFile(), - "1.2.4") + event.getSuggestedConfigurationFile()) ); } diff --git a/src/main/java/com/github/stachelbeere1248/zombiesutils/config/ZombiesUtilsConfig.java b/src/main/java/com/github/stachelbeere1248/zombiesutils/config/ZombiesUtilsConfig.java index 8fe8c1a..6af7def 100644 --- a/src/main/java/com/github/stachelbeere1248/zombiesutils/config/ZombiesUtilsConfig.java +++ b/src/main/java/com/github/stachelbeere1248/zombiesutils/config/ZombiesUtilsConfig.java @@ -24,7 +24,6 @@ public class ZombiesUtilsConfig { private Property defaultCategory; private Property language; private Property auditory; - private Property copyDelta; private Property cpsCounter; private Property announcePB; private Property playerVis; @@ -93,12 +92,6 @@ public class ZombiesUtilsConfig { "general", "name of the category to be selected unless specified using /runCategory" ); - copyDelta = config.get( - "timer", - "copy delta", - false, - "Also copy the delta-time when clicking the round-end message?" - ); announcePB = config.get( "timer", "announce", @@ -154,7 +147,6 @@ public class ZombiesUtilsConfig { private List getTimerElements() { return Arrays.asList( new CustomConfigElement("Default category", defaultCategory), - new CustomConfigElement("Paste delta", copyDelta), new CustomConfigElement("PB announcements", announcePB) ); } @@ -209,10 +201,6 @@ public class ZombiesUtilsConfig { return sstHud.getBoolean(); } - public boolean getCopyDelta() { - return copyDelta.getBoolean(); - } - public boolean getCpsToggle() { return cpsCounter.getBoolean(); } diff --git a/src/main/java/com/github/stachelbeere1248/zombiesutils/game/GameMode.java b/src/main/java/com/github/stachelbeere1248/zombiesutils/game/GameMode.java index 284b56c..2c2e666 100644 --- a/src/main/java/com/github/stachelbeere1248/zombiesutils/game/GameMode.java +++ b/src/main/java/com/github/stachelbeere1248/zombiesutils/game/GameMode.java @@ -4,6 +4,8 @@ import com.github.stachelbeere1248.zombiesutils.game.enums.Difficulty; import com.github.stachelbeere1248.zombiesutils.game.enums.Map; import org.jetbrains.annotations.NotNull; +import java.util.Objects; + public class GameMode { private final Map map; private Difficulty difficulty; @@ -41,4 +43,7 @@ public class GameMode { public boolean is(Map map, Difficulty difficulty) { return this.getDifficulty() == difficulty && this.getMap() == map; } + public boolean is(Map map) { + return this.getMap() == map; + } } diff --git a/src/main/java/com/github/stachelbeere1248/zombiesutils/game/SLA.java b/src/main/java/com/github/stachelbeere1248/zombiesutils/game/SLA.java index 8541dc1..e0493a4 100644 --- a/src/main/java/com/github/stachelbeere1248/zombiesutils/game/SLA.java +++ b/src/main/java/com/github/stachelbeere1248/zombiesutils/game/SLA.java @@ -80,8 +80,7 @@ public class SLA { player.posY - offset[1], player.posZ - offset[2] }; - for (Room room : rooms - ) { + for (Room room : rooms) { room.resetActiveWindowCount(); for (Window window : room.getWindows() ) { @@ -91,7 +90,8 @@ public class SLA { } // (2x)²+(2y)²+(2z)² = 4(x²+y²+z²) = 4d² - if (distanceDoubledThenSquared < 6400) { + final int slaRange = 40; + if (distanceDoubledThenSquared < 4 * slaRange * slaRange) { window.setActive(true); room.increaseActiveWindowCount(); } else window.setActive(false); diff --git a/src/main/java/com/github/stachelbeere1248/zombiesutils/game/waves/Waves.java b/src/main/java/com/github/stachelbeere1248/zombiesutils/game/waves/Waves.java index 8a433fa..ba18030 100644 --- a/src/main/java/com/github/stachelbeere1248/zombiesutils/game/waves/Waves.java +++ b/src/main/java/com/github/stachelbeere1248/zombiesutils/game/waves/Waves.java @@ -12,7 +12,7 @@ public class Waves { deadEndWaveTimes = {{10, 20}, {10, 20}, {10, 20, 35}, {10, 20, 35}, {10, 22, 37}, {10, 22, 44}, {10, 25, 47}, {10, 25, 50}, {10, 22, 38}, {10, 24, 45}, {10, 25, 48}, {10, 25, 50}, {10, 25, 50}, {10, 25, 45}, {10, 25, 46}, {10, 24, 47}, {10, 24, 47}, {10, 24, 47}, {10, 24, 47}, {10, 24, 49}, {10, 23, 44}, {10, 23, 45}, {10, 23, 42}, {10, 23, 43}, {10, 23, 43}, {10, 23, 36}, {10, 24, 44}, {10, 24, 42}, {10, 24, 42}, {10, 24, 45}}, badBloodWaveTimes = {{10, 22}, {10, 22}, {10, 22}, {10, 22, 34}, {10, 22, 34}, {10, 22, 34}, {10, 22, 34}, {10, 22, 34}, {10, 22, 34}, {10, 22, 34}, {10, 22, 34}, {10, 22, 34}, {10, 22, 34}, {10, 22, 34}, {10, 22, 34}, {10, 22, 34}, {10, 22, 34}, {10, 22, 34}, {10, 22, 34}, {10, 22, 34}, {10, 22, 34}, {10, 22, 34}, {10, 22, 34}, {10, 22, 34}, {10, 22, 34}, {10, 24, 38}, {10, 24, 38}, {10, 22, 34}, {10, 24, 38}, {10, 22, 34}}, alienArcadiumWaveTimes = {{10, 13, 16, 19}, {10, 14, 18, 22}, {10, 13, 16, 19}, {10, 14, 17, 21, 25, 28}, {10, 14, 18, 22, 26, 30}, {10, 14, 19, 23, 28, 32}, {10, 15, 19, 23, 27, 31}, {10, 15, 20, 25, 30, 35}, {10, 14, 19, 23, 28, 32}, {10, 16, 22, 27, 33, 38}, {10, 16, 21, 27, 32, 38}, {10, 16, 22, 28, 34, 40}, {10, 16, 22, 28, 34, 40}, {10, 16, 21, 26, 31, 36}, {10, 17, 24, 31, 38, 46}, {10, 16, 22, 27, 33, 38}, {10, 14, 19, 23, 28, 32}, {10, 14, 19, 23, 28, 32}, {10, 14, 18, 22, 26, 30}, {10, 15, 21, 26, 31, 36}, {10, 14, 19, 23, 28, 32}, {10, 14, 19, 23, 28, 34}, {10, 14, 18, 22, 26, 30}, {10, 14, 19, 23, 28, 32}, {10}, {10, 23, 36}, {10, 22, 34}, {10, 20, 30}, {10, 24, 38}, {10, 22, 34}, {10, 22, 34}, {10, 21, 32}, {10, 22, 34}, {10, 22, 34}, {10}, {10, 22, 34}, {10, 20, 31}, {10, 22, 34}, {10, 22, 34}, {10, 22, 34, 37, 45}, {10, 21, 32}, {10, 22, 34}, {10, 13, 22, 25, 34, 37}, {10, 22, 34}, {10, 22, 34, 35}, {10, 21, 32, 35}, {10, 20, 30}, {10, 20, 30, 33}, {10, 21, 32}, {10, 22, 34, 37}, {10, 20, 30, 33}, {10, 22, 34, 37}, {10, 22, 34, 37}, {10, 20, 32, 35, 39}, {10, 16, 22, 28, 34, 40}, {10, 14, 18}, {10, 14, 18}, {10, 22, 34, 37, 38}, {10, 14, 18, 22, 26, 30}, {10, 20, 30, 33}, {10, 14, 18, 22, 26, 30}, {10, 14, 18, 22, 26, 30}, {10, 14, 18, 22, 26, 30}, {10, 14, 18, 22, 26, 30}, {10, 14, 18, 22, 26, 30}, {10, 14, 18, 22, 26, 30}, {10, 14, 18, 22, 26, 30}, {10, 14, 18, 22, 26, 30}, {10, 14, 18, 22, 26, 30}, {10, 14, 18, 22, 26, 30}, {10, 14, 18, 22, 26, 30}, {10, 14, 18, 22, 26, 30}, {10, 14, 18, 22, 26, 30}, {10, 14, 18, 22, 26, 30}, {10, 14, 18, 22, 27, 32}, {10, 14, 18, 22, 27, 32}, {10, 14, 18, 22, 26, 30}, {10, 14, 18, 22, 26, 30}, {10, 14, 18, 22, 26, 30}, {10, 14, 18, 22, 26, 30}, {10, 14, 18, 22, 26, 30}, {10, 14, 18, 22, 26, 30}, {10, 14, 18, 22, 26, 30}, {10, 14, 18, 22, 26, 30}, {10, 14, 18, 22, 26, 30}, {10, 14, 18, 22, 26, 30}, {10, 14, 18, 22, 26, 30}, {10, 14, 18, 22, 26, 30}, {10, 14, 18, 22, 26, 30}, {10, 14, 18, 22, 26, 30}, {10, 14, 18, 22, 26, 30}, {10, 14, 18, 22, 26, 30}, {10, 14, 18, 22, 26, 30}, {10, 14, 18, 22, 26, 30}, {10, 14, 18, 22, 26, 30}, {10, 14, 18, 22, 26, 30}, {10, 14, 18, 22, 26, 30}, {10, 14, 18, 22, 26, 30}, {10, 14, 18, 22, 26, 30}, {10, 14, 18, 22, 26, 30}, {5}, {5}, {5}, {5}, {5}}, - prisonWaveTimes = {{10, 20}, {10, 20, 30}, {10, 17, 24, 31}, {10, 17, 24, 31}, {10, 20, 30}, {10, 20, 30}, {10, 20, 30}, {10, 25, 40}, {10, 25, 35}, {10, 25, 45}, {10, 25, 40}, {10, 25, 37}, {10, 22, 34}, {10, 25, 37}, {10, 25, 40}, {10, 22, 37}, {10, 22, 42}, {10, 25, 45}, {10, 25, 45}, {10, 25, 40}, {10, 20, 35, 55, 75}, {10, 25, 40}, {10, 30, 50}, {10, 30, 50}, {10, 25, 45}, {10, 30, 50}, {10, 25, 45}, {10, 30, 50}, {10, 30, 55}, {10}}; + prisonWaveTimes = {{10, 20}, {10, 20, 30}, {10, 17, 24, 31}, {10, 17, 24, 31}, {10, 20, 30}, {10, 20, 30}, {10, 20, 30}, {10, 25, 40}, {10, 25, 35}, {10, 25, 45}, {10, 25, 40}, {10, 25, 37}, {10, 22, 34}, {10, 25, 37}, {10, 25, 40}, {10, 22, 37}, {10, 22, 42}, {10, 25, 45}, {10, 25, 45}, {10, 25, 40}, {10, 20, 35, 55, 75}, {10, 25, 40}, {10, 30, 50}, {10, 30, 50}, {10, 25, 45}, {10, 30, 50}, {10, 25, 45}, {10, 30, 50}, {10, 30, 55}, {10}, {0, 15, 30, 45, 60, 75, 90, 105}}; @Contract(pure = true) public static byte[] get(@NotNull Map map, int round) { diff --git a/src/main/java/com/github/stachelbeere1248/zombiesutils/handlers/ChatHandler.java b/src/main/java/com/github/stachelbeere1248/zombiesutils/handlers/ChatHandler.java index be1d2d4..5f66b18 100644 --- a/src/main/java/com/github/stachelbeere1248/zombiesutils/handlers/ChatHandler.java +++ b/src/main/java/com/github/stachelbeere1248/zombiesutils/handlers/ChatHandler.java @@ -25,6 +25,8 @@ public class ChatHandler { game.getGameMode().changeDifficulty(Difficulty.HARD); } else if (LanguageSupport.containsRIP(message)) { game.getGameMode().changeDifficulty(Difficulty.RIP); + } else if (LanguageSupport.isHelicopterIncoming(message)) { + game.helicopter(); } } ); diff --git a/src/main/java/com/github/stachelbeere1248/zombiesutils/handlers/Handlers.java b/src/main/java/com/github/stachelbeere1248/zombiesutils/handlers/Handlers.java index 7738912..38a7c92 100644 --- a/src/main/java/com/github/stachelbeere1248/zombiesutils/handlers/Handlers.java +++ b/src/main/java/com/github/stachelbeere1248/zombiesutils/handlers/Handlers.java @@ -15,10 +15,10 @@ public class Handlers { public void registerAll() { MinecraftForge.EVENT_BUS.register(ZombiesUtils.getInstance().getConfig()); MinecraftForge.EVENT_BUS.register(renderer); + MinecraftForge.EVENT_BUS.register(renderPlayerHandler); MinecraftForge.EVENT_BUS.register(new TickHandler()); MinecraftForge.EVENT_BUS.register(new ChatHandler()); MinecraftForge.EVENT_BUS.register(new KeyInputHandler()); - MinecraftForge.EVENT_BUS.register(new RenderPlayerHandler()); } public RenderGameOverlayHandler getRenderer() { diff --git a/src/main/java/com/github/stachelbeere1248/zombiesutils/handlers/KeyInputHandler.java b/src/main/java/com/github/stachelbeere1248/zombiesutils/handlers/KeyInputHandler.java index d1c37ac..f0c314c 100644 --- a/src/main/java/com/github/stachelbeere1248/zombiesutils/handlers/KeyInputHandler.java +++ b/src/main/java/com/github/stachelbeere1248/zombiesutils/handlers/KeyInputHandler.java @@ -17,7 +17,7 @@ public class KeyInputHandler { if (event instanceof InputEvent.KeyInputEvent) { if (Keyboard.getEventKey() == '\0') return; if (Keyboard.getEventKeyState()) { - Hotkeys hotkeys = ZombiesUtils.getInstance().getHotkeys(); + final Hotkeys hotkeys = ZombiesUtils.getInstance().getHotkeys(); if (Keyboard.getEventKey() == hotkeys.getChatMacro().getKeyCode()) Minecraft.getMinecraft().thePlayer .sendChatMessage(ZombiesUtils.getInstance().getConfig().getChatMacro()); else if (Keyboard.getEventKey() == hotkeys.getRlSpawn().getKeyCode()) { diff --git a/src/main/java/com/github/stachelbeere1248/zombiesutils/handlers/RenderGameOverlayHandler.java b/src/main/java/com/github/stachelbeere1248/zombiesutils/handlers/RenderGameOverlayHandler.java index 296c4a2..36d30d4 100644 --- a/src/main/java/com/github/stachelbeere1248/zombiesutils/handlers/RenderGameOverlayHandler.java +++ b/src/main/java/com/github/stachelbeere1248/zombiesutils/handlers/RenderGameOverlayHandler.java @@ -47,7 +47,6 @@ public class RenderGameOverlayHandler { public void onRenderGameOverlay(RenderGameOverlayEvent.@NotNull Post event) { if (event.type != RenderGameOverlayEvent.ElementType.TEXT) return; - ZombiesUtils.getInstance().getGameManager().getGame().ifPresent( game -> { renderTime(game.getTimer().getRoundTime()); @@ -61,7 +60,7 @@ public class RenderGameOverlayHandler { } ); - SLA.getInstance().ifPresent(sla -> renderSla(sla.getRooms())); + if (!Minecraft.getMinecraft().gameSettings.showDebugInfo) SLA.getInstance().ifPresent(sla -> renderSla(sla.getRooms())); if (ZombiesUtils.getInstance().getConfig().getCpsToggle()) renderCPS(); } diff --git a/src/main/java/com/github/stachelbeere1248/zombiesutils/handlers/RenderPlayerHandler.java b/src/main/java/com/github/stachelbeere1248/zombiesutils/handlers/RenderPlayerHandler.java index 208b3a2..94aaf9e 100644 --- a/src/main/java/com/github/stachelbeere1248/zombiesutils/handlers/RenderPlayerHandler.java +++ b/src/main/java/com/github/stachelbeere1248/zombiesutils/handlers/RenderPlayerHandler.java @@ -1,7 +1,6 @@ package com.github.stachelbeere1248.zombiesutils.handlers; import com.github.stachelbeere1248.zombiesutils.ZombiesUtils; -import com.github.stachelbeere1248.zombiesutils.config.ZombiesUtilsConfig; import net.minecraft.client.Minecraft; import net.minecraft.util.Vec3; import net.minecraftforge.client.event.RenderPlayerEvent; @@ -9,7 +8,12 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import org.jetbrains.annotations.NotNull; public class RenderPlayerHandler { - private boolean visible = ZombiesUtils.getInstance().getConfig().getPlayerVis(); + private boolean visible; + + public RenderPlayerHandler() { + this.visible = ZombiesUtils.getInstance().getConfig().getPlayerVis(); + } + @SubscribeEvent public void onRender(RenderPlayerEvent.@NotNull Pre event) { if (event.entityPlayer.isPlayerSleeping() || event.entityPlayer.isUser()) return; diff --git a/src/main/java/com/github/stachelbeere1248/zombiesutils/handlers/Round1Correction.java b/src/main/java/com/github/stachelbeere1248/zombiesutils/handlers/Round1Correction.java index 1d84a50..3803f21 100644 --- a/src/main/java/com/github/stachelbeere1248/zombiesutils/handlers/Round1Correction.java +++ b/src/main/java/com/github/stachelbeere1248/zombiesutils/handlers/Round1Correction.java @@ -1,27 +1,36 @@ package com.github.stachelbeere1248.zombiesutils.handlers; import com.github.stachelbeere1248.zombiesutils.timer.Timer; -import net.minecraft.entity.Entity; +import com.github.stachelbeere1248.zombiesutils.utils.Scoreboard; import net.minecraft.entity.monster.EntityZombie; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import org.jetbrains.annotations.NotNull; +import java.util.Optional; + public class Round1Correction { - private final Timer TIMER; + private final Timer timer; + private final String serverNumber; - public Round1Correction(Timer timer) { - TIMER = timer; + public Round1Correction(Timer timer, String serverNumber) { + this.timer = timer; + this.serverNumber = serverNumber; } @SubscribeEvent public void onWaveSpawn(@NotNull EntityJoinWorldEvent event) { - final Entity entity = event.entity; - if (entity instanceof EntityZombie) { - TIMER.correctStartTick(); + if (!(event.entity instanceof EntityZombie)) return; + if (Scoreboard.isNotZombies()) return; + final Optional s = Scoreboard.getServerNumber(); + if (!s.isPresent()) return; + if (!s.get().equals(serverNumber)) { MinecraftForge.EVENT_BUS.unregister(this); + return; } + this.timer.correctStartTick(); + MinecraftForge.EVENT_BUS.unregister(this); } } diff --git a/src/main/java/com/github/stachelbeere1248/zombiesutils/timer/Game.java b/src/main/java/com/github/stachelbeere1248/zombiesutils/timer/Game.java index a92b028..863a2a8 100644 --- a/src/main/java/com/github/stachelbeere1248/zombiesutils/timer/Game.java +++ b/src/main/java/com/github/stachelbeere1248/zombiesutils/timer/Game.java @@ -9,49 +9,47 @@ import com.github.stachelbeere1248.zombiesutils.timer.recorder.Category; import com.github.stachelbeere1248.zombiesutils.timer.recorder.files.CategoryFile; import com.github.stachelbeere1248.zombiesutils.timer.recorder.files.GameFile; import net.minecraft.client.Minecraft; -import net.minecraft.event.ClickEvent; import net.minecraft.util.ChatComponentText; -import net.minecraft.util.ChatStyle; import net.minecraftforge.common.MinecraftForge; import org.apache.commons.lang3.exception.ExceptionUtils; -import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; public class Game { - private final Timer TIMER; - private final GameMode GAME_MODE; - private final GameFile GAME_FILE; + private final Timer timer; + private final GameMode gameMode; + private final GameFile gameFile; private final boolean roundOneRecorded; private int round; private Category category; + private boolean escaping; public Game(@NotNull final Map map, final String serverNumber) { - this.GAME_MODE = new GameMode(map); - this.TIMER = new Timer(); - this.GAME_FILE = new GameFile(serverNumber, map); + this.gameMode = new GameMode(map); + this.timer = new Timer(); + this.gameFile = new GameFile(serverNumber, map); this.category = new Category(); this.round = 1; this.roundOneRecorded = true; - MinecraftForge.EVENT_BUS.register(new Round1Correction(TIMER)); + MinecraftForge.EVENT_BUS.register(new Round1Correction(this.timer, serverNumber)); if (ZombiesUtils.getInstance().getConfig().isSlaToggled()) SLA.instance = new SLA(map); } public Game(@NotNull final Map map, final String serverNumber, final int round) { - this.GAME_MODE = new GameMode(map); - this.TIMER = new Timer(); - this.GAME_FILE = new GameFile(serverNumber, map); + this.gameMode = new GameMode(map); + this.timer = new Timer(); + this.gameFile = new GameFile(serverNumber, map); this.category = new Category(); this.round = round; this.roundOneRecorded = (round == 1); - MinecraftForge.EVENT_BUS.register(new Round1Correction(TIMER)); + MinecraftForge.EVENT_BUS.register(new Round1Correction(this.timer, serverNumber)); if (ZombiesUtils.getInstance().getConfig().isSlaToggled()) SLA.instance = new SLA(map); } public Timer getTimer() { - return this.TIMER; - }; + return this.timer; + } public void setCategory(Category category) { this.category = category; @@ -60,11 +58,11 @@ public class Game { return round; } public GameMode getGameMode() { - return GAME_MODE; + return gameMode; } public void pass(int round) { - if ((round == 0) || (this.round == round + 1) || (this.TIMER.getRoundTime() < 100)) { + if ((round == 0) || (this.round == round + 1) || (this.timer.getRoundTime() < 100)) { ZombiesUtils.getInstance().getLogger().debug("SPLIT CANCELLED"); return; } @@ -72,105 +70,51 @@ public class Game { record(); } catch (Exception e) { ZombiesUtils.getInstance().getLogger().error(ExceptionUtils.getStackTrace(e)); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Error recording splits")); + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("§cError recording splits")); } - this.TIMER.split(); + this.timer.split(); this.round = round + 1; } + public void helicopter() { + if (!gameMode.is(Map.PRISON)) { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("§cEscaping without playing prison???")); + ZombiesUtils.getInstance().getLogger().error(Thread.currentThread().getStackTrace()); + return; + } + this.escaping = true; + this.pass(30); + } private void record() { this.compareSegment(); if (this.roundOneRecorded) this.compareBest(); - this.GAME_FILE.setSegment(this.round, this.TIMER.getRoundTime()); + this.gameFile.setSegment(this.round, this.timer.getRoundTime()); } - private static final String bar = "§l§a▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬"; - public void compareSegment() throws IndexOutOfBoundsException { - final CategoryFile categoryFile = this.category.getByGameMode(this.GAME_MODE); + if (this.escaping) return; + final CategoryFile categoryFile = this.category.getByGameMode(this.gameMode); final short bestSegment = categoryFile.getBestSegment(round); final int roundTime = this.getTimer().getRoundTime(); - final String timeString = formattedTime(roundTime); - String segmentMessage = Game.bar + "\n§e Category: §d" + category.getName(); - String deltaString = ""; - - - if (bestSegment == (short) 0) { - categoryFile.setBestSegment(round, roundTime); - - if (ZombiesUtils.getInstance().getConfig().getAnnouncePB()) - segmentMessage += "\n§e§l***§6§l NEW BEST SEGMENT! §e§l***"; - segmentMessage += "\n§cRound " + round + "§e took §a" + timeString + "§e!"; - } else { - if (roundTime < bestSegment) { - if (ZombiesUtils.getInstance().getConfig().getAnnouncePB()) - segmentMessage += "\n§e§l***§6§l NEW BEST SEGMENT! §e§l***"; - categoryFile.setBestSegment(round, roundTime); - } - deltaString = formattedDelta(roundTime, bestSegment); - segmentMessage += "\n§cRound " + round + "§e took §a" + timeString + " §9" + deltaString; - if (ZombiesUtils.getInstance().getConfig().getCopyDelta()) deltaString = " (" + deltaString + ")"; - } - - - segmentMessage += "\n" + Game.bar; - final ChatComponentText message = new ChatComponentText(segmentMessage); - - String copyString = String.format("Round %s took %s%s!", round, timeString, deltaString); - message.setChatStyle(new ChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, copyString))); - - Minecraft.getMinecraft().thePlayer.addChatMessage(message); + if (bestSegment == (short) 0) categoryFile.setBestSegment(round, roundTime); + else if (roundTime < bestSegment) categoryFile.setBestSegment(round, roundTime); + final RecordMessageSender recordMessageSender = new RecordMessageSender(this.category.getName(), round, false, roundTime, bestSegment); + recordMessageSender.roundSplit(); + recordMessageSender.sendRecordMessage(); } public void compareBest() throws IndexOutOfBoundsException { - final CategoryFile categoryFile = this.category.getByGameMode(this.GAME_MODE); + final CategoryFile categoryFile = this.category.getByGameMode(this.gameMode); + final int round = this.escaping ? 31 : this.round; final int personalBest = categoryFile.getPersonalBest(round); - final int gameTime = this.TIMER.getGameTime(); - String deltaString = ""; + final int gameTime = this.timer.getGameTime(); - String bestMessage = Game.bar + "\n§e Category: §d" + category.getName(); - final String timeString = formattedTime(gameTime); - - if (personalBest == 0) { - categoryFile.setPersonalBest(round, gameTime); - - if (ZombiesUtils.getInstance().getConfig().getAnnouncePB()) - bestMessage += "\n§e§l***§6§l NEW PERSONAL BEST! §e§l***"; - bestMessage += "\n§cRound " + round + "§e finished at §a" + timeString + "§e!"; - } else { - if (gameTime < personalBest) { - if (ZombiesUtils.getInstance().getConfig().getAnnouncePB()) - bestMessage += "\n§e§l***§6§l NEW PERSONAL BEST! §e§l***"; - categoryFile.setPersonalBest(round, gameTime); - } - deltaString = formattedDelta(gameTime, personalBest); - bestMessage += "\n§cRound " + round + "§e finished at §a" + timeString + " §9" + deltaString; - if (ZombiesUtils.getInstance().getConfig().getCopyDelta()) deltaString = " (" + deltaString + ")"; - } - bestMessage += "\n" + Game.bar; - final ChatComponentText message = new ChatComponentText(bestMessage); - - String copyString = String.format("Round %s finished at %s%s!", round, timeString, deltaString); - message.setChatStyle(new ChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, copyString))); - - Minecraft.getMinecraft().thePlayer.addChatMessage(message); - } - - @Contract(pure = true) - private String formattedTime(int gameTime) { - gameTime *= 50; - return String.format("%d:%02d.%d%d", - gameTime / 60000, - (gameTime % 60000) / 1000, - (gameTime % 1000) / 100, - (gameTime % 100) / 10 - ); - } - - @Contract(pure = true) - private static @NotNull String formattedDelta(int newTime, int prevTime) { - final double delta = (double) (newTime - prevTime) / 20; - return String.format("%+.2f", delta); + if (personalBest == 0) categoryFile.setPersonalBest(round, gameTime); + else if (gameTime < personalBest) categoryFile.setPersonalBest(round, gameTime); + final RecordMessageSender recordMessageSender = new RecordMessageSender(category.getName(), round, true, gameTime, personalBest); + if (!escaping) recordMessageSender.gameSplit(); + else recordMessageSender.helicopterSplit(); + recordMessageSender.sendRecordMessage(); } } diff --git a/src/main/java/com/github/stachelbeere1248/zombiesutils/timer/GameManager.java b/src/main/java/com/github/stachelbeere1248/zombiesutils/timer/GameManager.java index 6e8c4f6..1d13a4f 100644 --- a/src/main/java/com/github/stachelbeere1248/zombiesutils/timer/GameManager.java +++ b/src/main/java/com/github/stachelbeere1248/zombiesutils/timer/GameManager.java @@ -28,11 +28,11 @@ public class GameManager { switch (game.getGameMode().getMap()) { case DEAD_END: case BAD_BLOOD: - case PRISON: //TODO: Escape - game.pass((byte) 30); + case PRISON: + game.pass(30); break; case ALIEN_ARCADIUM: - game.pass((byte) 105); + game.pass(105); break; } } diff --git a/src/main/java/com/github/stachelbeere1248/zombiesutils/timer/RecordMessageSender.java b/src/main/java/com/github/stachelbeere1248/zombiesutils/timer/RecordMessageSender.java new file mode 100644 index 0000000..5ddf7de --- /dev/null +++ b/src/main/java/com/github/stachelbeere1248/zombiesutils/timer/RecordMessageSender.java @@ -0,0 +1,112 @@ +package com.github.stachelbeere1248.zombiesutils.timer; + +import com.github.stachelbeere1248.zombiesutils.ZombiesUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.event.ClickEvent; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ChatStyle; +import org.jetbrains.annotations.Contract; + +public class RecordMessageSender { + private final StringBuilder recordMessage; + private final int roundTime; + private final int gameTime; + private final int oldPB; + private final int oldBS; + private final int round; + private final String deltaString; + private final String timeString; + private final boolean cumulative; + private String copyString; + public RecordMessageSender(final String categoryName, final int round, final boolean cumulative, final int newTime, final int oldTime) { + this.recordMessage = new StringBuilder( + "§l§a▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\n§e Category: §d" + categoryName + ); + if (cumulative) { + this.gameTime = newTime; + this.oldPB = oldTime; + this.roundTime = 0; + this.oldBS = 0; + } else { + this.gameTime = 0; + this.oldPB = 0; + this.roundTime = newTime; + this.oldBS = oldTime; + } + this.deltaString = oldTime != 0 ? formattedDelta(newTime, oldTime) : ""; + this.timeString = formattedTime(newTime); + this.cumulative = cumulative; + this.round = round; + } + + public void sendRecordMessage() { + final ChatComponentText message = new ChatComponentText( + this.recordMessage + .append("\n§l§a▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬") + .toString() + ); + message.setChatStyle(new ChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, this.copyString))); + Minecraft.getMinecraft().thePlayer.addChatMessage(message); + } + + public void gameSplit() { + final String announcement = gameTime < oldPB && ZombiesUtils.getInstance().getConfig().getAnnouncePB() ? + "\n§e§l***§6§l NEW PERSONAL BEST! §e§l***" : ""; + this.recordMessage.append(announcement) + .append("\n§cRound ") + .append(round) + .append("§e finished at §a") + .append(timeString) + .append(deltaString) + .append("§e!"); + this.copyString = deltaString.isEmpty() ? + String.format("Round %d finished at %s!", round, timeString) : + String.format("Round %d finished at %s (%s)!", round, timeString, deltaString); + } + + public void roundSplit() { + final String announcement = roundTime < oldBS && ZombiesUtils.getInstance().getConfig().getAnnouncePB() ? + "\n§e§l***§6§l NEW BEST SEGMENT! §e§l***" : ""; + final String timeString = formattedTime(roundTime); + final String deltaString = oldBS != 0 ? formattedDelta(roundTime, oldBS) : ""; + this.recordMessage.append(announcement) + .append("\n§cRound ") + .append(round) + .append("§e took §a") + .append(timeString) + .append(" §9") + .append(deltaString) + .append("§e!"); + this.copyString = deltaString.isEmpty() ? + String.format("Round %d took %s!", round, timeString) : + String.format("Round %d took %s (%s)!", round, timeString, deltaString); + } + public void helicopterSplit() { + final String announcement = gameTime < oldPB && ZombiesUtils.getInstance().getConfig().getAnnouncePB() ? + "\n§e§l***§6§l NEW PERSONAL BEST! §e§l***" : ""; + this.recordMessage.append(announcement) + .append("§8§lHelicopter §r§ecalled at §a") + .append(timeString) + .append(" §9") + .append(deltaString) + .append("§e!"); + this.copyString = deltaString.isEmpty() ? + String.format("Helicopter called at %s!", timeString) : + String.format("Helicopter called at %s (%s)!", timeString, deltaString); + } + @Contract(pure = true) + private String formattedTime(int time) { + time *= 50; + return String.format("%d:%02d.%d%d", + time / 60000, + (time % 60000) / 1000, + (time % 1000) / 100, + (time % 100) / 10 + ); + } + @Contract(pure = true) + private String formattedDelta(int newTime, int oldTime) { + final double delta = (double) (newTime - oldTime) / 20; + return String.format("%+.2f", delta); + } +} diff --git a/src/main/java/com/github/stachelbeere1248/zombiesutils/timer/recorder/data/CategoryData.java b/src/main/java/com/github/stachelbeere1248/zombiesutils/timer/recorder/data/CategoryData.java index c6cf4db..15c5b1f 100644 --- a/src/main/java/com/github/stachelbeere1248/zombiesutils/timer/recorder/data/CategoryData.java +++ b/src/main/java/com/github/stachelbeere1248/zombiesutils/timer/recorder/data/CategoryData.java @@ -23,7 +23,7 @@ public class CategoryData implements ISplitsData { personalBests = new int[30]; break; case PRISON: - bestSegments = new short[31]; + bestSegments = new short[30]; personalBests = new int[31]; break; default: diff --git a/src/main/java/com/github/stachelbeere1248/zombiesutils/utils/LanguageSupport.java b/src/main/java/com/github/stachelbeere1248/zombiesutils/utils/LanguageSupport.java index 8e618d7..f8ca89c 100644 --- a/src/main/java/com/github/stachelbeere1248/zombiesutils/utils/LanguageSupport.java +++ b/src/main/java/com/github/stachelbeere1248/zombiesutils/utils/LanguageSupport.java @@ -7,7 +7,7 @@ import java.util.regex.Pattern; @SuppressWarnings("SpellCheckingInspection") public class LanguageSupport { - private static final String[] LANGUAGEs = { + private static final String[] LANGUAGES = { "EN", "FR", "DE" @@ -51,6 +51,12 @@ public class LanguageSupport { }; return Arrays.stream(words).anyMatch(input::contains); } + public static boolean isHelicopterIncoming(@NotNull String input) { + final String[] words = { + "The Helicopter is on its way! Hold out for 120 more seconds!" + }; + return Arrays.stream(words).anyMatch(input::contains); + } public static @NotNull Pattern roundPattern(@NotNull String language) { switch (language) { @@ -64,21 +70,7 @@ public class LanguageSupport { throw new IllegalStateException("Unexpected value: " + language); } } - - public static @NotNull Pattern mapPattern(@NotNull String language) { - switch (language) { - case "EN": - return Pattern.compile("Map:.*(Dead End|Bad Blood|Alien Arcadium|Prison)"); - case "FR": - return Pattern.compile("Carte:.*(Dead End|Bad Blood|Alien Arcadium|Prison)"); - case "DE": - return Pattern.compile("Karte:.*(Dead End|Bad Blood|Alien Arcadium|Prison)"); - default: - throw new IllegalStateException("Unexpected value: " + language); - } - } - public static String[] getLanguages() { - return LANGUAGEs; + return LANGUAGES; } }