cps counter, refactor, practise server patch?
This commit is contained in:
parent
1704e3c80c
commit
1af6d3efc3
10 changed files with 175 additions and 51 deletions
|
@ -3,4 +3,4 @@ org.gradle.jvmargs=-Xmx2g
|
||||||
baseGroup = com.github.stachelbeere1248.zombiesutils
|
baseGroup = com.github.stachelbeere1248.zombiesutils
|
||||||
mcVersion = 1.8.9
|
mcVersion = 1.8.9
|
||||||
modid = zombiesutils
|
modid = zombiesutils
|
||||||
version = 1.2.4-PREVIEW_6
|
version = 1.2.5
|
|
@ -3,9 +3,8 @@ package com.github.stachelbeere1248.zombiesutils;
|
||||||
import com.github.stachelbeere1248.zombiesutils.commands.CommandRegistry;
|
import com.github.stachelbeere1248.zombiesutils.commands.CommandRegistry;
|
||||||
import com.github.stachelbeere1248.zombiesutils.config.Hotkeys;
|
import com.github.stachelbeere1248.zombiesutils.config.Hotkeys;
|
||||||
import com.github.stachelbeere1248.zombiesutils.config.ZombiesUtilsConfig;
|
import com.github.stachelbeere1248.zombiesutils.config.ZombiesUtilsConfig;
|
||||||
import com.github.stachelbeere1248.zombiesutils.handlers.HandlerRegistry;
|
import com.github.stachelbeere1248.zombiesutils.handlers.Handlers;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.common.config.Configuration;
|
import net.minecraftforge.common.config.Configuration;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||||
|
@ -17,10 +16,12 @@ import org.jetbrains.annotations.NotNull;
|
||||||
public class ZombiesUtils {
|
public class ZombiesUtils {
|
||||||
private static ZombiesUtils instance;
|
private static ZombiesUtils instance;
|
||||||
private final Hotkeys hotkeys;
|
private final Hotkeys hotkeys;
|
||||||
|
private final Handlers handlers;
|
||||||
private Logger logger;
|
private Logger logger;
|
||||||
|
|
||||||
public ZombiesUtils() {
|
public ZombiesUtils() {
|
||||||
hotkeys = new Hotkeys();
|
hotkeys = new Hotkeys();
|
||||||
|
handlers = new Handlers();
|
||||||
instance = this;
|
instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +41,7 @@ public class ZombiesUtils {
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
public void init(FMLInitializationEvent event) {
|
public void init(FMLInitializationEvent event) {
|
||||||
HandlerRegistry.registerAll();
|
handlers.registerAll();
|
||||||
CommandRegistry.registerAll();
|
CommandRegistry.registerAll();
|
||||||
hotkeys.registerAll();
|
hotkeys.registerAll();
|
||||||
}
|
}
|
||||||
|
@ -52,6 +53,11 @@ public class ZombiesUtils {
|
||||||
public Hotkeys getHotkeys() {
|
public Hotkeys getHotkeys() {
|
||||||
return hotkeys;
|
return hotkeys;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Handlers getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isHypixel() {
|
public static boolean isHypixel() {
|
||||||
return Minecraft.getMinecraft().getCurrentServerData().serverIP.matches("(.+\\.)?(hypixel\\.net)(:25565)?");
|
return Minecraft.getMinecraft().getCurrentServerData().serverIP.matches("(.+\\.)?(hypixel\\.net)(:25565)?");
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,8 @@ public class ZombiesUtilsConfig {
|
||||||
private static Property waveOffset;
|
private static Property waveOffset;
|
||||||
private static Property language;
|
private static Property language;
|
||||||
private static Property auditory;
|
private static Property auditory;
|
||||||
|
private static Property copyDelta;
|
||||||
|
private static Property cpsCounter;
|
||||||
|
|
||||||
public static void load() {
|
public static void load() {
|
||||||
ZombiesUtils.getInstance().getLogger().debug("Loading config...");
|
ZombiesUtils.getInstance().getLogger().debug("Loading config...");
|
||||||
|
@ -86,6 +88,18 @@ public class ZombiesUtilsConfig {
|
||||||
"Enable if not using SST by Sosean"
|
"Enable if not using SST by Sosean"
|
||||||
|
|
||||||
);
|
);
|
||||||
|
copyDelta = config.get(
|
||||||
|
Configuration.CATEGORY_GENERAL,
|
||||||
|
"copy delta",
|
||||||
|
false,
|
||||||
|
"Also copy the delta-time when clicking the round-end message?"
|
||||||
|
);
|
||||||
|
cpsCounter = config.get(
|
||||||
|
Configuration.CATEGORY_GENERAL,
|
||||||
|
"cps",
|
||||||
|
false,
|
||||||
|
"whether to show cps"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static short getWaveOffset() {
|
public static short getWaveOffset() {
|
||||||
|
@ -122,6 +136,12 @@ public class ZombiesUtilsConfig {
|
||||||
public static boolean getSST() {
|
public static boolean getSST() {
|
||||||
return sst.getBoolean();
|
return sst.getBoolean();
|
||||||
}
|
}
|
||||||
|
public static boolean getCopyDelta() {
|
||||||
|
return copyDelta.getBoolean();
|
||||||
|
}
|
||||||
|
public static boolean getCpsToggle() {
|
||||||
|
return cpsCounter.getBoolean();
|
||||||
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onConfigChange(ConfigChangedEvent.@NotNull OnConfigChangedEvent event) {
|
public void onConfigChange(ConfigChangedEvent.@NotNull OnConfigChangedEvent event) {
|
||||||
|
|
|
@ -1,5 +1,18 @@
|
||||||
package com.github.stachelbeere1248.zombiesutils.game.enums;
|
package com.github.stachelbeere1248.zombiesutils.game.enums;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public enum Map {
|
public enum Map {
|
||||||
DEAD_END, BAD_BLOOD, ALIEN_ARCADIUM, PRISON
|
DEAD_END, BAD_BLOOD, ALIEN_ARCADIUM, PRISON;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull String toString() {
|
||||||
|
switch (this) {
|
||||||
|
case DEAD_END: return "Dead End";
|
||||||
|
case BAD_BLOOD: return "Bad Blood";
|
||||||
|
case ALIEN_ARCADIUM: return "Alien Arcadium";
|
||||||
|
case PRISON: return "Prison";
|
||||||
|
default: throw new IllegalStateException("Unexpected Map value:" + this);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package com.github.stachelbeere1248.zombiesutils.game.waves;
|
package com.github.stachelbeere1248.zombiesutils.game.waves;
|
||||||
|
|
||||||
import com.github.stachelbeere1248.zombiesutils.game.enums.Map;
|
import com.github.stachelbeere1248.zombiesutils.game.enums.Map;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.util.ChatComponentText;
|
||||||
import org.jetbrains.annotations.Contract;
|
import org.jetbrains.annotations.Contract;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
@ -16,16 +18,24 @@ public class Waves {
|
||||||
|
|
||||||
@Contract(pure = true)
|
@Contract(pure = true)
|
||||||
public static byte[] get(@NotNull Map map, byte round) {
|
public static byte[] get(@NotNull Map map, byte round) {
|
||||||
|
byte[] ret = new byte[0];
|
||||||
|
try {
|
||||||
switch (map) {
|
switch (map) {
|
||||||
case DEAD_END:
|
case DEAD_END:
|
||||||
return deadEndWaveTimes[round - 1];
|
ret = deadEndWaveTimes[round - 1];
|
||||||
case BAD_BLOOD:
|
case BAD_BLOOD:
|
||||||
return badBloodWaveTimes[round - 1];
|
ret = badBloodWaveTimes[round - 1];
|
||||||
case ALIEN_ARCADIUM:
|
case ALIEN_ARCADIUM:
|
||||||
return alienArcadiumWaveTimes[round - 1];
|
ret = alienArcadiumWaveTimes[round - 1];
|
||||||
default:
|
default:
|
||||||
throw new IllegalStateException("Unexpected value: " + map);
|
throw new IllegalStateException("Unexpected value: " + map);
|
||||||
}
|
}
|
||||||
|
} catch (ArrayIndexOutOfBoundsException e) {
|
||||||
|
Minecraft.getMinecraft().thePlayer.addChatMessage(
|
||||||
|
new ChatComponentText("Achievement get: Round " + round + map)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static short getSum(@NotNull Map map, byte round) {
|
public static short getSum(@NotNull Map map, byte round) {
|
||||||
|
|
|
@ -3,12 +3,22 @@ package com.github.stachelbeere1248.zombiesutils.handlers;
|
||||||
import com.github.stachelbeere1248.zombiesutils.config.ZombiesUtilsConfig;
|
import com.github.stachelbeere1248.zombiesutils.config.ZombiesUtilsConfig;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
|
||||||
public class HandlerRegistry {
|
public class Handlers {
|
||||||
public static void registerAll() {
|
private final RenderGameOverlayHandler renderer;
|
||||||
|
|
||||||
|
public Handlers() {
|
||||||
|
renderer = new RenderGameOverlayHandler();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerAll() {
|
||||||
MinecraftForge.EVENT_BUS.register(new ZombiesUtilsConfig());
|
MinecraftForge.EVENT_BUS.register(new ZombiesUtilsConfig());
|
||||||
MinecraftForge.EVENT_BUS.register(new RenderGameOverlayHandler());
|
MinecraftForge.EVENT_BUS.register(renderer);
|
||||||
MinecraftForge.EVENT_BUS.register(new TickHandler());
|
MinecraftForge.EVENT_BUS.register(new TickHandler());
|
||||||
MinecraftForge.EVENT_BUS.register(new ChatHandler());
|
MinecraftForge.EVENT_BUS.register(new ChatHandler());
|
||||||
MinecraftForge.EVENT_BUS.register(new KeyInputHandler());
|
MinecraftForge.EVENT_BUS.register(new KeyInputHandler());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RenderGameOverlayHandler getRenderer() {
|
||||||
|
return renderer;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -5,25 +5,33 @@ import com.github.stachelbeere1248.zombiesutils.config.Hotkeys;
|
||||||
import com.github.stachelbeere1248.zombiesutils.config.ZombiesUtilsConfig;
|
import com.github.stachelbeere1248.zombiesutils.config.ZombiesUtilsConfig;
|
||||||
import com.github.stachelbeere1248.zombiesutils.game.waves.WaveTiming;
|
import com.github.stachelbeere1248.zombiesutils.game.waves.WaveTiming;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraftforge.event.entity.player.PlayerUseItemEvent;
|
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.gameevent.InputEvent;
|
import net.minecraftforge.fml.common.gameevent.InputEvent;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
|
import org.lwjgl.input.Mouse;
|
||||||
|
|
||||||
|
|
||||||
public class KeyInputHandler {
|
public class KeyInputHandler {
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onKeyInput(InputEvent.KeyInputEvent event) {
|
public void onKeyInput(InputEvent event) {
|
||||||
if (Keyboard.getEventKeyState() && Minecraft.getMinecraft().currentScreen == null) {
|
if (Minecraft.getMinecraft().currentScreen != null) return;
|
||||||
|
if (event instanceof InputEvent.KeyInputEvent) {
|
||||||
|
if (Keyboard.getEventKeyState()) {
|
||||||
Hotkeys hotkeys = ZombiesUtils.getInstance().getHotkeys();
|
Hotkeys hotkeys = ZombiesUtils.getInstance().getHotkeys();
|
||||||
if (Keyboard.getEventKey() == hotkeys.getChatMacro().getKeyCode()) {
|
if (Keyboard.getEventKey() == hotkeys.getChatMacro().getKeyCode()) {
|
||||||
Minecraft.getMinecraft().thePlayer.sendChatMessage(
|
Minecraft.getMinecraft().thePlayer.sendChatMessage(
|
||||||
ZombiesUtilsConfig.getChatMacro()
|
ZombiesUtilsConfig.getChatMacro()
|
||||||
);
|
);
|
||||||
} else if (Keyboard.getEventKey() == hotkeys.getRlSpawn().getKeyCode()) {
|
} else if (Keyboard.getEventKey() == hotkeys.getRlSpawn().getKeyCode()) {
|
||||||
RenderGameOverlayHandler.toggleRL();
|
ZombiesUtils.getInstance().getHandlers().getRenderer().toggleRL();
|
||||||
WaveTiming.toggleRL();
|
WaveTiming.toggleRL();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (event instanceof InputEvent.MouseInputEvent) {
|
||||||
|
if (Mouse.getEventButtonState()) {
|
||||||
|
if (Mouse.getEventButton() == 1) ZombiesUtils.getInstance().getHandlers().getRenderer().addClick();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -16,7 +16,9 @@ import org.jetbrains.annotations.NotNull;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class RenderGameOverlayHandler {
|
public class RenderGameOverlayHandler {
|
||||||
private static int rl = 0;
|
private int rl = 0;
|
||||||
|
private final boolean[] clicks = new boolean[20];
|
||||||
|
private int clickPointer = 0;
|
||||||
private final FontRenderer fontRenderer;
|
private final FontRenderer fontRenderer;
|
||||||
|
|
||||||
public RenderGameOverlayHandler() {
|
public RenderGameOverlayHandler() {
|
||||||
|
@ -37,7 +39,7 @@ public class RenderGameOverlayHandler {
|
||||||
return String.format("W%d %d:%02d.%d", wave, minutesPart, secondsPart, tenthSecondsPart);
|
return String.format("W%d %d:%02d.%d", wave, minutesPart, secondsPart, tenthSecondsPart);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void toggleRL() {
|
void toggleRL() {
|
||||||
if (rl == 0) rl = ZombiesUtilsConfig.getWaveOffset();
|
if (rl == 0) rl = ZombiesUtilsConfig.getWaveOffset();
|
||||||
else rl = 0;
|
else rl = 0;
|
||||||
}
|
}
|
||||||
|
@ -45,6 +47,7 @@ public class RenderGameOverlayHandler {
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onRenderGameOverlay(RenderGameOverlayEvent.@NotNull Post event) {
|
public void onRenderGameOverlay(RenderGameOverlayEvent.@NotNull Post event) {
|
||||||
if (event.type != RenderGameOverlayEvent.ElementType.TEXT) return;
|
if (event.type != RenderGameOverlayEvent.ElementType.TEXT) return;
|
||||||
|
|
||||||
Timer.getInstance().ifPresent(timer -> {
|
Timer.getInstance().ifPresent(timer -> {
|
||||||
renderTime(timer.roundTime());
|
renderTime(timer.roundTime());
|
||||||
renderSpawnTime(
|
renderSpawnTime(
|
||||||
|
@ -55,10 +58,13 @@ public class RenderGameOverlayHandler {
|
||||||
timer.roundTime()
|
timer.roundTime()
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
SLA.getInstance().ifPresent(sla -> {
|
SLA.getInstance().ifPresent(sla -> {
|
||||||
sla.refreshActives();
|
sla.refreshActives();
|
||||||
renderSla(sla.getRooms());
|
renderSla(sla.getRooms());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (ZombiesUtilsConfig.getCpsToggle()) renderCPS();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderTime(long timerTicks) {
|
private void renderTime(long timerTicks) {
|
||||||
|
@ -128,4 +134,34 @@ public class RenderGameOverlayHandler {
|
||||||
heightIndex++;
|
heightIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void renderCPS() {
|
||||||
|
final String cps = String.format("%2.1f", getClicks());
|
||||||
|
final ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
|
||||||
|
final int screenWidth = scaledResolution.getScaledWidth();
|
||||||
|
final int width = fontRenderer.getStringWidth(cps);
|
||||||
|
|
||||||
|
fontRenderer.drawStringWithShadow(
|
||||||
|
cps,
|
||||||
|
screenWidth - width,
|
||||||
|
0,
|
||||||
|
0xAAAAAA
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getClicks() {
|
||||||
|
int i = 0;
|
||||||
|
for (boolean tick : clicks) {
|
||||||
|
if (tick) i++;
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addClick() {
|
||||||
|
clicks[clickPointer] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void tick() {
|
||||||
|
clickPointer = (clickPointer + 1) % 20;
|
||||||
|
clicks[clickPointer] = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.github.stachelbeere1248.zombiesutils.handlers;
|
package com.github.stachelbeere1248.zombiesutils.handlers;
|
||||||
|
|
||||||
|
import com.github.stachelbeere1248.zombiesutils.ZombiesUtils;
|
||||||
import com.github.stachelbeere1248.zombiesutils.game.waves.WaveTiming;
|
import com.github.stachelbeere1248.zombiesutils.game.waves.WaveTiming;
|
||||||
import com.github.stachelbeere1248.zombiesutils.utils.Scoreboard;
|
import com.github.stachelbeere1248.zombiesutils.utils.Scoreboard;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
@ -12,5 +13,6 @@ public class TickHandler {
|
||||||
if (event.phase == TickEvent.Phase.START) return;
|
if (event.phase == TickEvent.Phase.START) return;
|
||||||
Scoreboard.refresh();
|
Scoreboard.refresh();
|
||||||
WaveTiming.onTick();
|
WaveTiming.onTick();
|
||||||
|
ZombiesUtils.getInstance().getHandlers().getRenderer().tick();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
package com.github.stachelbeere1248.zombiesutils.timer;
|
package com.github.stachelbeere1248.zombiesutils.timer;
|
||||||
|
|
||||||
|
import com.github.stachelbeere1248.zombiesutils.config.ZombiesUtilsConfig;
|
||||||
import com.github.stachelbeere1248.zombiesutils.timer.recorder.Category;
|
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.CategoryFile;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.event.ClickEvent;
|
||||||
import net.minecraft.util.ChatComponentText;
|
import net.minecraft.util.ChatComponentText;
|
||||||
|
import net.minecraft.util.ChatStyle;
|
||||||
import org.jetbrains.annotations.Contract;
|
import org.jetbrains.annotations.Contract;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
@ -11,55 +14,73 @@ public class RecordManager {
|
||||||
private static final String bar = "§l§a▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬";
|
private static final String bar = "§l§a▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬";
|
||||||
|
|
||||||
public static void compareSegment(byte round, short roundTime, @NotNull Category category) throws IndexOutOfBoundsException {
|
public static void compareSegment(byte round, short roundTime, @NotNull Category category) throws IndexOutOfBoundsException {
|
||||||
String segmentMessage = bar +
|
@SuppressWarnings("OptionalGetWithoutIsPresent")
|
||||||
"\n§e Category: §d" + category.getName();
|
final CategoryFile categoryFile = category.getByGameMode(Timer.getInstance().get().getGameMode());
|
||||||
|
final short bestSegment = categoryFile.getBestSegment(round);
|
||||||
|
|
||||||
|
final String timeString = formattedTime(roundTime);
|
||||||
|
String segmentMessage = bar + "\n§e Category: §d" + category.getName();
|
||||||
|
String deltaString = "";
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("OptionalGetWithoutIsPresent") final CategoryFile categoryFile = category.getByGameMode(Timer.getInstance().get().getGameMode());
|
|
||||||
short bestSegment = categoryFile.getBestSegment(round);
|
|
||||||
if (bestSegment == (short) 0) {
|
if (bestSegment == (short) 0) {
|
||||||
categoryFile.setBestSegment(round, roundTime);
|
categoryFile.setBestSegment(round, roundTime);
|
||||||
|
|
||||||
segmentMessage += "\n§e§l***§6§l NEW BEST SEGMENT! §e§l***";
|
segmentMessage += "\n§e§l***§6§l NEW BEST SEGMENT! §e§l***";
|
||||||
final String timeString = formattedTime(roundTime);
|
|
||||||
segmentMessage += "\n§cRound " + round + "§e took §a" + timeString + "§e!";
|
segmentMessage += "\n§cRound " + round + "§e took §a" + timeString + "§e!";
|
||||||
} else {
|
} else {
|
||||||
if (roundTime < bestSegment) {
|
if (roundTime < bestSegment) {
|
||||||
segmentMessage += "\n§e§l***§6§l NEW BEST SEGMENT! §e§l***";
|
segmentMessage += "\n§e§l***§6§l NEW BEST SEGMENT! §e§l***";
|
||||||
categoryFile.setBestSegment(round, roundTime);
|
categoryFile.setBestSegment(round, roundTime);
|
||||||
}
|
}
|
||||||
final String timeString = formattedTime(roundTime);
|
deltaString = formattedDelta(roundTime, bestSegment);
|
||||||
segmentMessage += "\n§cRound " + round + "§e took §a" + timeString + " §9" + formattedDelta(roundTime, bestSegment);
|
segmentMessage += "\n§cRound " + round + "§e took §a" + timeString + " §9" + deltaString;
|
||||||
|
if (ZombiesUtilsConfig.getCopyDelta()) deltaString = " (" + deltaString + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
segmentMessage += "\n" + bar;
|
segmentMessage += "\n" + bar;
|
||||||
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(segmentMessage));
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void compareBest(byte round, int gameTime, @NotNull Category category) throws IndexOutOfBoundsException {
|
public static void compareBest(byte round, int gameTime, @NotNull Category category) throws IndexOutOfBoundsException {
|
||||||
String bestMessage = bar +
|
@SuppressWarnings("OptionalGetWithoutIsPresent")
|
||||||
"\n§e Category: §d" + category.getName();
|
final CategoryFile categoryFile = category.getByGameMode(Timer.getInstance().get().getGameMode());
|
||||||
|
final int personalBest = categoryFile.getPersonalBest(round);
|
||||||
|
String deltaString = "";
|
||||||
|
|
||||||
|
String bestMessage = bar + "\n§e Category: §d" + category.getName();
|
||||||
|
final String timeString = formattedTime(gameTime);
|
||||||
|
|
||||||
@SuppressWarnings("OptionalGetWithoutIsPresent") final CategoryFile categoryFile = category.getByGameMode(Timer.getInstance().get().getGameMode());
|
|
||||||
int personalBest = categoryFile.getPersonalBest(round);
|
|
||||||
if (personalBest == 0) {
|
if (personalBest == 0) {
|
||||||
categoryFile.setPersonalBest(round, gameTime);
|
categoryFile.setPersonalBest(round, gameTime);
|
||||||
|
|
||||||
bestMessage += "\n§e§l***§6§l NEW PERSONAL BEST! §e§l***";
|
bestMessage += "\n§e§l***§6§l NEW PERSONAL BEST! §e§l***";
|
||||||
final String timeString = formattedTime(gameTime);
|
|
||||||
bestMessage += "\n§cRound " + round + "§e finished at §a" + timeString + "§e!";
|
bestMessage += "\n§cRound " + round + "§e finished at §a" + timeString + "§e!";
|
||||||
} else {
|
} else {
|
||||||
if (gameTime < personalBest) {
|
if (gameTime < personalBest) {
|
||||||
bestMessage += "\n§e§l***§6§l NEW PERSONAL BEST! §e§l***";
|
bestMessage += "\n§e§l***§6§l NEW PERSONAL BEST! §e§l***";
|
||||||
categoryFile.setPersonalBest(round, gameTime);
|
categoryFile.setPersonalBest(round, gameTime);
|
||||||
}
|
}
|
||||||
|
deltaString = formattedDelta(gameTime, personalBest);
|
||||||
final String timeString = formattedTime(gameTime);
|
bestMessage += "\n§cRound " + round + "§e finished at §a" + timeString + " §9" + deltaString;
|
||||||
bestMessage += "\n§cRound " + round + "§e finished at §a" + timeString + " §9" + formattedDelta(gameTime, personalBest);
|
if (ZombiesUtilsConfig.getCopyDelta()) deltaString = " (" + deltaString + ")";
|
||||||
}
|
}
|
||||||
bestMessage += "\n" + bar;
|
bestMessage += "\n" + bar;
|
||||||
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(bestMessage));
|
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 static String formattedTime(int gameTime) {
|
private static String formattedTime(int gameTime) {
|
||||||
gameTime *= 50;
|
gameTime *= 50;
|
||||||
return String.format("%d:%02d.%d%d",
|
return String.format("%d:%02d.%d%d",
|
||||||
|
@ -72,9 +93,7 @@ public class RecordManager {
|
||||||
|
|
||||||
@Contract(pure = true)
|
@Contract(pure = true)
|
||||||
private static @NotNull String formattedDelta(int newTime, int prevTime) {
|
private static @NotNull String formattedDelta(int newTime, int prevTime) {
|
||||||
double delta = (double) (newTime - prevTime) / 20;
|
final double delta = (double) (newTime - prevTime) / 20;
|
||||||
if (delta < 0) {
|
return String.format("%+.2f", delta);
|
||||||
return String.valueOf(delta);
|
|
||||||
} else return ("+" + delta);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue