1.1.3
This commit is contained in:
parent
a7a206d273
commit
acb51e6a3a
15 changed files with 267 additions and 112 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.1.2
|
version = 1.1.3
|
|
@ -5,6 +5,7 @@ import com.github.stachelbeere1248.zombiesutils.commands.SlaCommand;
|
||||||
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.ChatHandler;
|
import com.github.stachelbeere1248.zombiesutils.handlers.ChatHandler;
|
||||||
|
import com.github.stachelbeere1248.zombiesutils.handlers.KeyInputHandler;
|
||||||
import com.github.stachelbeere1248.zombiesutils.handlers.TickHandler;
|
import com.github.stachelbeere1248.zombiesutils.handlers.TickHandler;
|
||||||
import com.github.stachelbeere1248.zombiesutils.render.RenderGameOverlayHandler;
|
import com.github.stachelbeere1248.zombiesutils.render.RenderGameOverlayHandler;
|
||||||
import net.minecraftforge.client.ClientCommandHandler;
|
import net.minecraftforge.client.ClientCommandHandler;
|
||||||
|
@ -44,7 +45,7 @@ public class ZombiesUtils {
|
||||||
MinecraftForge.EVENT_BUS.register(new RenderGameOverlayHandler());
|
MinecraftForge.EVENT_BUS.register(new RenderGameOverlayHandler());
|
||||||
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(hotkeys);
|
MinecraftForge.EVENT_BUS.register(new KeyInputHandler());
|
||||||
|
|
||||||
ClientCommandHandler.instance.registerCommand(new CategoryCommand());
|
ClientCommandHandler.instance.registerCommand(new CategoryCommand());
|
||||||
ClientCommandHandler.instance.registerCommand(new SlaCommand());
|
ClientCommandHandler.instance.registerCommand(new SlaCommand());
|
||||||
|
|
|
@ -19,12 +19,12 @@ public class CategoryCommand extends CommandBase {
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public String getCommandName() {
|
public String getCommandName() {
|
||||||
return "runCategory";
|
return "category";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getCommandUsage(ICommandSender sender) {
|
public String getCommandUsage(ICommandSender sender) {
|
||||||
return "runCategory <category-name>";
|
return "/category <category-name>";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -28,8 +28,7 @@ public class SlaCommand extends CommandBase {
|
||||||
public void processCommand(ICommandSender sender, String @NotNull [] args) throws CommandException {
|
public void processCommand(ICommandSender sender, String @NotNull [] args) throws CommandException {
|
||||||
if (args.length == 0) throw new WrongUsageException(
|
if (args.length == 0) throw new WrongUsageException(
|
||||||
"[Missing option] options: off, offset, rotate, mirror, map, quick");
|
"[Missing option] options: off, offset, rotate, mirror, map, quick");
|
||||||
else {
|
else switch (args[0]) {
|
||||||
switch (args[0]) {
|
|
||||||
case "off":
|
case "off":
|
||||||
SLA.drop();
|
SLA.drop();
|
||||||
sender.addChatMessage(new ChatComponentText("SLA data deleted"));
|
sender.addChatMessage(new ChatComponentText("SLA data deleted"));
|
||||||
|
@ -106,14 +105,14 @@ public class SlaCommand extends CommandBase {
|
||||||
default:
|
default:
|
||||||
//noinspection SpellCheckingInspection
|
//noinspection SpellCheckingInspection
|
||||||
throw new WrongUsageException(
|
throw new WrongUsageException(
|
||||||
"[Invalid option] options: mogi_a, ghxula, ghxula-garden", args[1]); }
|
"[Invalid option] options: mogi_a, ghxula, ghxula-garden", args[1]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new WrongUsageException(
|
throw new WrongUsageException(
|
||||||
"[Invalid option] options: off, offset, rotate, mirror, map", args[0]);
|
"[Invalid option] options: off, offset, rotate, mirror, map", args[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> addTabCompletionOptions(ICommandSender sender, String @NotNull [] args, BlockPos blockPos) {
|
public List<String> addTabCompletionOptions(ICommandSender sender, String @NotNull [] args, BlockPos blockPos) {
|
||||||
|
@ -136,7 +135,7 @@ public class SlaCommand extends CommandBase {
|
||||||
case "quick":
|
case "quick":
|
||||||
//noinspection SpellCheckingInspection
|
//noinspection SpellCheckingInspection
|
||||||
options.addAll(Arrays.asList("mogi_a", "ghxula", "ghxula-garden"));
|
options.addAll(Arrays.asList("mogi_a", "ghxula", "ghxula-garden"));
|
||||||
default:
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return options;
|
return options;
|
||||||
|
|
|
@ -0,0 +1,68 @@
|
||||||
|
package com.github.stachelbeere1248.zombiesutils.commands;
|
||||||
|
|
||||||
|
import com.github.stachelbeere1248.zombiesutils.timer.Timer;
|
||||||
|
import com.github.stachelbeere1248.zombiesutils.timer.recorder.Category;
|
||||||
|
import com.github.stachelbeere1248.zombiesutils.utils.Scoreboard;
|
||||||
|
import net.minecraft.command.*;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ZombiesUtilsCommand extends CommandBase {
|
||||||
|
@Override
|
||||||
|
public String getCommandName() {
|
||||||
|
return "zombiesutils";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCommandUsage(ICommandSender sender) {
|
||||||
|
return "/zombiesutils";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processCommand(ICommandSender sender, String @NotNull [] args) throws CommandException {
|
||||||
|
if (args.length == 0) throw new WrongUsageException(
|
||||||
|
"[Missing option] options: timer");
|
||||||
|
else switch (args[0]) {
|
||||||
|
case "timer":
|
||||||
|
switch (args[1]) {
|
||||||
|
case "kill": Timer.dropInstances(); break;
|
||||||
|
case "split":
|
||||||
|
try {
|
||||||
|
Timer.getInstance().ifPresent(timer -> timer.split(Byte.parseByte(args[2])));
|
||||||
|
} catch (NumberFormatException | NullPointerException ignored) {
|
||||||
|
throw new NumberInvalidException("t",args[2]);
|
||||||
|
} break;
|
||||||
|
case "start": new Timer(
|
||||||
|
Scoreboard.getServerNumber().orElseThrow(() -> new RuntimeException("cannot figure out servernumber")),
|
||||||
|
Scoreboard.getMap().orElseThrow(() -> new RuntimeException("cannot figure out map")).map
|
||||||
|
); break;
|
||||||
|
default:
|
||||||
|
throw new WrongUsageException(
|
||||||
|
"[Invalid option] options: kill, split, start", args[0]);
|
||||||
|
} break;
|
||||||
|
default:
|
||||||
|
throw new WrongUsageException(
|
||||||
|
"[Invalid option] options: timer", args[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public List<String> addTabCompletionOptions(ICommandSender sender, String @NotNull [] args, BlockPos blockPos) {
|
||||||
|
if (args.length == 1) return new ArrayList<>(Collections.singleton("timer"));
|
||||||
|
switch (args[0]) {
|
||||||
|
case "timer":
|
||||||
|
return new ArrayList<>(Arrays.asList("kill","split","start"));
|
||||||
|
default: return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canCommandSenderUseCommand(ICommandSender sender) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,6 +9,7 @@ import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
public class Hotkeys {
|
public class Hotkeys {
|
||||||
private final KeyBinding chatMacro;
|
private final KeyBinding chatMacro;
|
||||||
|
private final KeyBinding debug;
|
||||||
|
|
||||||
public Hotkeys() {
|
public Hotkeys() {
|
||||||
chatMacro = new KeyBinding(
|
chatMacro = new KeyBinding(
|
||||||
|
@ -16,14 +17,20 @@ public class Hotkeys {
|
||||||
Keyboard.KEY_Q,
|
Keyboard.KEY_Q,
|
||||||
"Zombies Utils"
|
"Zombies Utils"
|
||||||
);
|
);
|
||||||
|
debug = new KeyBinding(
|
||||||
|
"Debug",
|
||||||
|
Keyboard.KEY_K,
|
||||||
|
"Zombies Utils"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
public void registerAll() {
|
public void registerAll() {
|
||||||
ClientRegistry.registerKeyBinding(this.chatMacro);
|
ClientRegistry.registerKeyBinding(this.chatMacro);
|
||||||
|
ClientRegistry.registerKeyBinding(this.debug);
|
||||||
}
|
}
|
||||||
@SubscribeEvent
|
public KeyBinding getChatMacro() {
|
||||||
public void onKeyInput(InputEvent.KeyInputEvent event) {
|
return chatMacro;
|
||||||
if (Keyboard.getEventKey() == chatMacro.getKeyCode() && Keyboard.getEventKeyState() && Minecraft.getMinecraft().currentScreen == null) {
|
|
||||||
Minecraft.getMinecraft().thePlayer.sendChatMessage(ZombiesUtilsConfig.getChatMacro());
|
|
||||||
}
|
}
|
||||||
|
public KeyBinding getDebugger() {
|
||||||
|
return debug;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
package com.github.stachelbeere1248.zombiesutils.handlers;
|
||||||
|
|
||||||
|
import com.github.stachelbeere1248.zombiesutils.ZombiesUtils;
|
||||||
|
import com.github.stachelbeere1248.zombiesutils.config.Hotkeys;
|
||||||
|
import com.github.stachelbeere1248.zombiesutils.config.ZombiesUtilsConfig;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
import net.minecraftforge.fml.common.gameevent.InputEvent;
|
||||||
|
import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
|
|
||||||
|
public class KeyInputHandler {
|
||||||
|
/*
|
||||||
|
@SuppressWarnings("SpellCheckingInspection")
|
||||||
|
private final String[] secret = new String[]{
|
||||||
|
"Rule #1: Use Zombies Utils.",
|
||||||
|
"Rule #2: Use the god damn maarkro.",
|
||||||
|
"Rule #3: Be as toxic as possible (not).",
|
||||||
|
"Rule #4: /friend remove 9c3584fe963d4d579081e7e9e225763d",
|
||||||
|
"Rule #5: Play legit.",
|
||||||
|
"Rule #6: Don't type wave 3.",
|
||||||
|
"Rule #7: Don't trust shotgun.",
|
||||||
|
"Rule #8: Hit your wallshots.",
|
||||||
|
"Rule #9: Start the recording right now.",
|
||||||
|
"Rule #10: Don't s1 on wr pace.",
|
||||||
|
"Rule #11: There can be only one GOAT.",
|
||||||
|
"Rule #12: Fast T please.",
|
||||||
|
"Rule #13: Step back if insta.",
|
||||||
|
"Rule #14: No killing Teammates.",
|
||||||
|
"rule #15: No arguing because prplx is always left."
|
||||||
|
};
|
||||||
|
private int secretIndex = 0;*/
|
||||||
|
@SubscribeEvent
|
||||||
|
public void onKeyInput(InputEvent.KeyInputEvent event) {
|
||||||
|
if (Keyboard.getEventKeyState() && Minecraft.getMinecraft().currentScreen == null) {
|
||||||
|
Hotkeys hotkeys = ZombiesUtils.getInstance().getHotkeys();
|
||||||
|
if (Keyboard.getEventKey() == hotkeys.getChatMacro().getKeyCode()) {
|
||||||
|
Minecraft.getMinecraft().thePlayer.sendChatMessage(
|
||||||
|
ZombiesUtilsConfig.getChatMacro()
|
||||||
|
);
|
||||||
|
} else if (Keyboard.getEventKey() == hotkeys.getDebugger().getKeyCode()) {
|
||||||
|
for (Entity entity:Minecraft.getMinecraft().theWorld.loadedEntityList) {
|
||||||
|
System.out.println(entity.getNBTTagCompound());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package com.github.stachelbeere1248.zombiesutils.handlers;
|
package com.github.stachelbeere1248.zombiesutils.handlers;
|
||||||
|
|
||||||
import com.github.stachelbeere1248.zombiesutils.utils.Scoreboard;
|
import com.github.stachelbeere1248.zombiesutils.utils.Scoreboard;
|
||||||
|
import net.minecraftforge.client.event.sound.PlaySoundEvent;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.github.stachelbeere1248.zombiesutils.ZombiesUtils;
|
||||||
import com.github.stachelbeere1248.zombiesutils.game.GameMode;
|
import com.github.stachelbeere1248.zombiesutils.game.GameMode;
|
||||||
import com.github.stachelbeere1248.zombiesutils.timer.Timer;
|
import com.github.stachelbeere1248.zombiesutils.timer.Timer;
|
||||||
import com.github.stachelbeere1248.zombiesutils.utils.Scoreboard;
|
import com.github.stachelbeere1248.zombiesutils.utils.Scoreboard;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||||
import net.minecraft.network.play.server.S29PacketSoundEffect;
|
import net.minecraft.network.play.server.S29PacketSoundEffect;
|
||||||
import net.minecraft.network.play.server.S45PacketTitle;
|
import net.minecraft.network.play.server.S45PacketTitle;
|
||||||
|
@ -40,18 +41,24 @@ public class MixinNetHandlerPlayClient {
|
||||||
ZombiesUtils.getInstance().getLogger().info("Attempting creation of new timer");
|
ZombiesUtils.getInstance().getLogger().info("Attempting creation of new timer");
|
||||||
new Timer(
|
new Timer(
|
||||||
Scoreboard.getServerNumber().orElseThrow(() -> new RuntimeException("cannot figure out servernumber")),
|
Scoreboard.getServerNumber().orElseThrow(() -> new RuntimeException("cannot figure out servernumber")),
|
||||||
Scoreboard.getMap().orElseThrow(() -> new RuntimeException("cannot figure out map"))
|
Scoreboard.getMap().orElseThrow(() -> new RuntimeException("cannot figure out map")).map
|
||||||
);
|
);
|
||||||
} else {
|
} else { Timer timer = Timer.getInstance().get();
|
||||||
Timer timer = Timer.getInstance().get();
|
|
||||||
if (timer.equalsServerOrNull(Scoreboard.getServerNumber().orElse(null))) timer.split(Scoreboard.getRound());
|
|
||||||
|
|
||||||
|
Scoreboard.MapContainer map = Scoreboard.getMap().orElseThrow(() -> new RuntimeException("Scoreboard Error"));
|
||||||
|
if (map.pregame) {
|
||||||
|
ZombiesUtils.getInstance().getLogger().info("Attempting creation of new timer");
|
||||||
|
new Timer(
|
||||||
|
Scoreboard.getServerNumber().orElseThrow(() -> new RuntimeException("cannot figure out servernumber")),
|
||||||
|
map.map
|
||||||
|
);
|
||||||
|
} else if (timer.equalsServerOrNull(Scoreboard.getServerNumber().orElse(null))) timer.split(Scoreboard.getRound());
|
||||||
else {
|
else {
|
||||||
ZombiesUtils.getInstance().getLogger().info("Attempting creation of new timer");
|
ZombiesUtils.getInstance().getLogger().info("Attempting creation of new timer");
|
||||||
//also kills the previous timer using the garbage collector
|
//also kills the previous timer using the garbage collector
|
||||||
new Timer(
|
new Timer(
|
||||||
Scoreboard.getServerNumber().orElseThrow(() -> new RuntimeException("cannot figure out servernumber")),
|
Scoreboard.getServerNumber().orElseThrow(() -> new RuntimeException("cannot figure out servernumber")),
|
||||||
Scoreboard.getMap().orElseThrow(() -> new RuntimeException("cannot figure out map"))
|
map.map
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ public class Timer {
|
||||||
private final String serverNumber;
|
private final String serverNumber;
|
||||||
public Category category;
|
public Category category;
|
||||||
private boolean pbTracking = false;
|
private boolean pbTracking = false;
|
||||||
private byte dontDupeSplitPlease = 0;
|
private int round = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a timer and saves it to {@link #instance}.
|
* Constructs a timer and saves it to {@link #instance}.
|
||||||
|
@ -49,12 +49,19 @@ public class Timer {
|
||||||
final int gameTime = gameTime();
|
final int gameTime = gameTime();
|
||||||
final short roundTime = (short) (gameTime - passedRoundsTickSum);
|
final short roundTime = (short) (gameTime - passedRoundsTickSum);
|
||||||
|
|
||||||
if (dontDupeSplitPlease == passedRound || passedRound == 0 || roundTime == 0) {
|
if ((round == passedRound) || (passedRound == 0) || (roundTime == 0)) {
|
||||||
ZombiesUtils.getInstance().getLogger().debug("SPLIT CANCELLED");
|
ZombiesUtils.getInstance().getLogger().debug("SPLIT CANCELLED");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (passedRound == (byte) 1) pbTracking = true;
|
|
||||||
|
|
||||||
|
record(passedRound, roundTime, gameTime);
|
||||||
|
|
||||||
|
passedRoundsTickSum = gameTime;
|
||||||
|
round = passedRound;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void record(byte passedRound, short roundTime, int gameTime) {
|
||||||
|
if (passedRound == (byte) 1) pbTracking = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
RecordManager.compareSegment(passedRound, roundTime, category);
|
RecordManager.compareSegment(passedRound, roundTime, category);
|
||||||
|
@ -64,12 +71,9 @@ public class Timer {
|
||||||
String.format("Split not recorded. (invalid round parsed from scoreboard: %s)", passedRound)
|
String.format("Split not recorded. (invalid round parsed from scoreboard: %s)", passedRound)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
passedRoundsTickSum = gameTime;
|
|
||||||
dontDupeSplitPlease = passedRound;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private long getCurrentTotalWorldTime() {
|
private long getCurrentTotalWorldTime() {
|
||||||
if (Minecraft.getMinecraft() == null) return 0;
|
if (Minecraft.getMinecraft() == null) return 0;
|
||||||
if (Minecraft.getMinecraft().theWorld == null) return 0;
|
if (Minecraft.getMinecraft().theWorld == null) return 0;
|
||||||
|
@ -97,6 +101,8 @@ public class Timer {
|
||||||
public static void dropInstances() {
|
public static void dropInstances() {
|
||||||
instance = null;
|
instance = null;
|
||||||
GameMode.drop();
|
GameMode.drop();
|
||||||
SLA.drop();
|
}
|
||||||
|
public int getRound() {
|
||||||
|
return round+1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class Category {
|
||||||
Timer.getInstance().ifPresent(timer -> timer.setCategory(new Category()));
|
Timer.getInstance().ifPresent(timer -> timer.setCategory(new Category()));
|
||||||
}
|
}
|
||||||
public static String[] getCategories() {
|
public static String[] getCategories() {
|
||||||
File dir = new File("zombies");
|
File dir = new File("zombies"+File.separator+"splits");
|
||||||
if (dir.isDirectory()) return dir.list();
|
if (dir.isDirectory()) return dir.list();
|
||||||
else return new String[0];
|
else return new String[0];
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ public class FileData{
|
||||||
Arrays.fill(bestSegments, (short) 0);
|
Arrays.fill(bestSegments, (short) 0);
|
||||||
Arrays.fill(personalBests, 0);
|
Arrays.fill(personalBests, 0);
|
||||||
}
|
}
|
||||||
String getAsJsonString() {
|
public String getAsJsonString() {
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
return gson.toJson(this, FileData.class);
|
return gson.toJson(this, FileData.class);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.github.stachelbeere1248.zombiesutils.timer.recorder;
|
package com.github.stachelbeere1248.zombiesutils.timer.recorder;
|
||||||
|
|
||||||
import com.github.stachelbeere1248.zombiesutils.game.GameMode;
|
import com.github.stachelbeere1248.zombiesutils.game.GameMode;
|
||||||
|
import com.github.stachelbeere1248.zombiesutils.utils.FileManager;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -11,7 +12,7 @@ public class TimesFile extends File {
|
||||||
public TimesFile(String category, @NotNull GameMode gameMode) {
|
public TimesFile(String category, @NotNull GameMode gameMode) {
|
||||||
// Game-directory -> custom category -> file named "MAP_DIFFICULTY.times"
|
// Game-directory -> custom category -> file named "MAP_DIFFICULTY.times"
|
||||||
// Content encoded in StandardCharsets.UTF_16
|
// Content encoded in StandardCharsets.UTF_16
|
||||||
super("zombies" + File.separator + category,gameMode.getMap() + "_" + gameMode.getDifficulty() + ".times");
|
super("zombies" + File.separator + "splits" + File.separator + category,gameMode.getMap() + "_" + gameMode.getDifficulty() + ".times");
|
||||||
this.gameMode = gameMode;
|
this.gameMode = gameMode;
|
||||||
fileData = FileManager.readOrCreate(this);
|
fileData = FileManager.readOrCreate(this);
|
||||||
}
|
}
|
||||||
|
@ -31,7 +32,7 @@ public class TimesFile extends File {
|
||||||
FileManager.writeDataToFile(fileData,this);
|
FileManager.writeDataToFile(fileData,this);
|
||||||
}
|
}
|
||||||
|
|
||||||
GameMode getGameMode() {
|
public GameMode getGameMode() {
|
||||||
return gameMode;
|
return gameMode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.github.stachelbeere1248.zombiesutils.timer.recorder;
|
package com.github.stachelbeere1248.zombiesutils.utils;
|
||||||
|
|
||||||
|
import com.github.stachelbeere1248.zombiesutils.timer.recorder.FileData;
|
||||||
|
import com.github.stachelbeere1248.zombiesutils.timer.recorder.TimesFile;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
|
@ -91,26 +91,40 @@ public class Scoreboard {
|
||||||
ZombiesUtils.getInstance().getLogger().debug("Servernumber: " + string);
|
ZombiesUtils.getInstance().getLogger().debug("Servernumber: " + string);
|
||||||
return Optional.ofNullable(string);
|
return Optional.ofNullable(string);
|
||||||
}
|
}
|
||||||
public static Optional<Map> getMap() {
|
public static Optional<MapContainer> getMap() {
|
||||||
String line;
|
String line;
|
||||||
|
boolean pregame;
|
||||||
try {
|
try {
|
||||||
line = lines.get(12);
|
line = lines.get(12);
|
||||||
|
pregame = false;
|
||||||
} catch (Exception couldBePregame) {
|
} catch (Exception couldBePregame) {
|
||||||
try {
|
try {
|
||||||
line = lines.get(2);
|
line = lines.get(2);
|
||||||
|
pregame = true;
|
||||||
} catch (IndexOutOfBoundsException | NullPointerException ignored) {
|
} catch (IndexOutOfBoundsException | NullPointerException ignored) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String mapString = MAP_PATTERN.matcher(line).replaceAll("$1");
|
String mapString = MAP_PATTERN.matcher(line).replaceAll("$1");
|
||||||
switch (mapString) {
|
switch (mapString) {
|
||||||
case "Dead End": return Optional.of(Map.DEAD_END);
|
case "Dead End": return Optional.of(new MapContainer(Map.DEAD_END,pregame));
|
||||||
case "Bad Blood": return Optional.of(Map.BAD_BLOOD);
|
case "Bad Blood": return Optional.of(new MapContainer(Map.BAD_BLOOD,pregame));
|
||||||
case "Alien Arcadium": return Optional.of(Map.ALIEN_ARCADIUM);
|
case "Alien Arcadium": return Optional.of(new MapContainer(Map.ALIEN_ARCADIUM,pregame));
|
||||||
default: return Optional.empty();
|
default: return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public static boolean isZombies() {
|
public static boolean isZombies() {
|
||||||
return (!"ZOMBIES".equals(title));
|
return (!"ZOMBIES".equals(title));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class MapContainer {
|
||||||
|
public final Map map;
|
||||||
|
public final boolean pregame;
|
||||||
|
|
||||||
|
public MapContainer(Map map, boolean pregame) {
|
||||||
|
this.map = map;
|
||||||
|
this.pregame = pregame;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue