sla improved, minor bug fixes
This commit is contained in:
parent
00c9ecf03f
commit
ba64f4bd1b
21 changed files with 236 additions and 80 deletions
|
@ -15,5 +15,6 @@ The Timer automatically splits every round. The Personal-Best-recorder automatic
|
|||
- default state: disabled
|
||||
- /sla set \<de|bb|aa> - forcefully set the map
|
||||
- /sla offset \<x> \<y> \<z> - set an offset, allowing you to use sla on map-recreations, such as housings
|
||||
- Mogi_a: 41 -35 22
|
||||
### Extra
|
||||
- Migration of split-category names: In your minecraft folder is a folder called "zombies". You can simply rename the sub-folders.
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.github.stachelbeere1248.zombiesutils;
|
|||
|
||||
import com.github.stachelbeere1248.zombiesutils.commands.CategoryCommand;
|
||||
import com.github.stachelbeere1248.zombiesutils.commands.SlaCommand;
|
||||
import com.github.stachelbeere1248.zombiesutils.config.Config;
|
||||
import com.github.stachelbeere1248.zombiesutils.handlers.ChatHandler;
|
||||
import com.github.stachelbeere1248.zombiesutils.handlers.TickHandler;
|
||||
import com.github.stachelbeere1248.zombiesutils.render.RenderGameOverlayHandler;
|
||||
|
@ -12,11 +13,11 @@ import net.minecraftforge.fml.common.Mod;
|
|||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@Mod(modid = "zombiesutils", useMetadata = true, clientSideOnly = true)
|
||||
@Mod(modid = "zombiesutils", useMetadata = true, clientSideOnly = true, guiFactory = "com.github.stachelbeere1248.zombiesutils.config.GuiFactory")
|
||||
public class ZombiesUtils {
|
||||
private static ZombiesUtils instance;
|
||||
private Configuration config;
|
||||
private Logger logger;
|
||||
public ZombiesUtils() {
|
||||
instance = this;
|
||||
|
@ -26,22 +27,20 @@ public class ZombiesUtils {
|
|||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
public void preInit(@NotNull FMLPreInitializationEvent event) {
|
||||
logger = event.getModLog();
|
||||
config = new Configuration(event.getSuggestedConfigurationFile());
|
||||
config.load();
|
||||
Config.config = new Configuration(event.getSuggestedConfigurationFile());
|
||||
Config.load();
|
||||
}
|
||||
@Mod.EventHandler
|
||||
public void init(FMLInitializationEvent event) {
|
||||
MinecraftForge.EVENT_BUS.register(new RenderGameOverlayHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new TickHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new ChatHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new Config());
|
||||
ClientCommandHandler.instance.registerCommand(new CategoryCommand());
|
||||
ClientCommandHandler.instance.registerCommand(new SlaCommand());
|
||||
}
|
||||
public Configuration getConfig() {
|
||||
return config;
|
||||
}
|
||||
public Logger getLogger() {
|
||||
return logger;
|
||||
}
|
||||
|
|
|
@ -3,10 +3,13 @@ package com.github.stachelbeere1248.zombiesutils.commands;
|
|||
import com.github.stachelbeere1248.zombiesutils.timer.Timer;
|
||||
import com.github.stachelbeere1248.zombiesutils.timer.recorder.Category;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -25,10 +28,12 @@ public class CategoryCommand extends CommandBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender sender, String[] args) {
|
||||
if (args.length == 0) sender.addChatMessage(new ChatComponentText(getCommandUsage(sender)));
|
||||
public void processCommand(ICommandSender sender, String @NotNull [] args) throws CommandException {
|
||||
if (args.length == 0) throw new WrongUsageException("Please enter a name for the category");
|
||||
else {
|
||||
Category.setSelectedCategory(args[0]);
|
||||
String cat = args[0];
|
||||
if (cat.contains(File.separator)) throw new WrongUsageException("Your name must not contain '" + File.separator + "' as this is the systems separator character for folder" + File.separator + "subfolder");
|
||||
Category.setSelectedCategory(cat);
|
||||
Timer.getInstance().ifPresent(timer -> timer.setCategory(new Category()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +2,8 @@ package com.github.stachelbeere1248.zombiesutils.commands;
|
|||
|
||||
import com.github.stachelbeere1248.zombiesutils.game.Map;
|
||||
import com.github.stachelbeere1248.zombiesutils.game.windows.Sla;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.command.*;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -22,7 +21,7 @@ public class SlaCommand extends CommandBase {
|
|||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender sender) {
|
||||
return "/sla toggle\n/sla offset [x] [x] [x]\n/sla set <de|bb|aa>";
|
||||
return "/sla off\n/sla offset [x] [x] [x]\n/sla rotate\n/sla mirror\n/sla map <de|bb|aa>";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -30,13 +29,13 @@ public class SlaCommand extends CommandBase {
|
|||
if (args.length == 0) sender.addChatMessage(new ChatComponentText(getCommandUsage(sender)));
|
||||
else {
|
||||
switch (args[0]) {
|
||||
case "toggle":
|
||||
Sla.toggle();
|
||||
sender.addChatMessage(new ChatComponentText("SLA active: " + Sla.isEnabled()));
|
||||
case "off":
|
||||
Sla.drop();
|
||||
sender.addChatMessage(new ChatComponentText("SLA data deleted"));
|
||||
break;
|
||||
case "offset":
|
||||
if (args.length == 1) Sla.getInstance().ifPresent(Sla::resetOffset);
|
||||
else if (args.length != 4) sender.addChatMessage(new ChatComponentText("/sla offset [x] [x] [x]"));
|
||||
else if (args.length != 4) throw new WrongUsageException("An offset should have three coordinates!");
|
||||
else {
|
||||
try {
|
||||
double x = Double.parseDouble(args[1]);
|
||||
|
@ -45,38 +44,57 @@ public class SlaCommand extends CommandBase {
|
|||
Sla.getInstance().ifPresent(sla -> sla.setOffset(new double[]{x, y, z}));
|
||||
sender.addChatMessage(new ChatComponentText(String.format("Offset set to %s %s %s", x, y, z)));
|
||||
} catch (NumberFormatException ignored) {
|
||||
sender.addChatMessage(new ChatComponentText("Please input valid numbers"));
|
||||
throw new NumberInvalidException();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "set":
|
||||
case "rotate":
|
||||
sender.addChatMessage(new ChatComponentText("Rotating map..."));
|
||||
Sla.getInstance().ifPresent(Sla::rotate);
|
||||
break;
|
||||
case "mirror":
|
||||
switch (args[1]) {
|
||||
case "x":
|
||||
Sla.getInstance().ifPresent(Sla::mirrorX);
|
||||
break;
|
||||
case "z":
|
||||
Sla.getInstance().ifPresent(Sla::mirrorZ);
|
||||
break;
|
||||
default: throw new WrongUsageException("Invalid option: available: x, z");
|
||||
}
|
||||
break;
|
||||
case "map":
|
||||
switch (args[1]) {
|
||||
case "de":
|
||||
new Sla(Map.DEAD_END);
|
||||
Sla.instance = new Sla(Map.DEAD_END);
|
||||
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("SLA forced to map DE"));
|
||||
break;
|
||||
case "bb":
|
||||
new Sla(Map.BAD_BLOOD);
|
||||
Sla.instance = new Sla(Map.BAD_BLOOD);
|
||||
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("SLA forced to map BB"));
|
||||
break;
|
||||
case "aa":
|
||||
new Sla(Map.ALIEN_ARCADIUM);
|
||||
Sla.instance = new Sla(Map.ALIEN_ARCADIUM);
|
||||
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("SLA forced to map AA"));
|
||||
break;
|
||||
default:
|
||||
sender.addChatMessage(new ChatComponentText("/sla set <de|bb|aa>"));
|
||||
default: throw new WrongUsageException("Invalid option: available: de, bb, aa");
|
||||
|
||||
}
|
||||
break;
|
||||
default:
|
||||
sender.addChatMessage(new ChatComponentText(getCommandUsage(sender)));
|
||||
break;
|
||||
default: throw new WrongUsageException("Invalid option: available: off, offset, rotate, mirror, map");
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public List<String> addTabCompletionOptions(ICommandSender sender, String @NotNull [] args, BlockPos blockPos) {
|
||||
List<String> options = new ArrayList<String>();
|
||||
if (args.length == 1) options.addAll(Arrays.asList("toggle","offset","set"));
|
||||
List<String> options = new ArrayList<>();
|
||||
if (args.length == 1) options.addAll(Arrays.asList("off","offset","rotate","mirror","map"));
|
||||
else if ("offset".equals(args[0]) && (args.length == 2 || args.length == 3 || args.length == 4))
|
||||
options.add("0");
|
||||
else if ("set".equals(args[0])) options.addAll(Arrays.asList("de", "bb", "aa"));
|
||||
else if ("map".equals(args[0])) options.addAll(Arrays.asList("de", "bb", "aa"));
|
||||
else if ("mirror".equals(args[0])) {
|
||||
options.addAll(Arrays.asList("x","z"));
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
package com.github.stachelbeere1248.zombiesutils.config;
|
||||
|
||||
import com.github.stachelbeere1248.zombiesutils.ZombiesUtils;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class Config {
|
||||
public static Configuration config;
|
||||
|
||||
private static boolean slaToggle;
|
||||
public static void load() {
|
||||
ZombiesUtils.getInstance().getLogger().debug("Loading config...");
|
||||
config.load();
|
||||
ZombiesUtils.getInstance().getLogger().debug("Config loaded.");
|
||||
|
||||
slaToggle = config.getBoolean(
|
||||
"SLA Launcher",
|
||||
Configuration.CATEGORY_GENERAL,
|
||||
slaToggle,
|
||||
"Should SLA be started when a game starts?"
|
||||
);
|
||||
|
||||
ZombiesUtils.getInstance().getLogger().debug("Saving Config...");
|
||||
config.save();
|
||||
ZombiesUtils.getInstance().getLogger().debug("Config saved.");
|
||||
}
|
||||
@SubscribeEvent
|
||||
public void onConfigChange(ConfigChangedEvent.@NotNull OnConfigChangedEvent event) {
|
||||
if (event.modID.equals("zombiesutils") && event.configID == null) {
|
||||
config.save();
|
||||
Config.load();
|
||||
}
|
||||
}
|
||||
public static boolean isSlaToggled() {
|
||||
return slaToggle;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.github.stachelbeere1248.zombiesutils.config;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraftforge.common.config.ConfigElement;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
|
||||
public class GuiConfig extends net.minecraftforge.fml.client.config.GuiConfig {
|
||||
public GuiConfig(GuiScreen parentScreen) {
|
||||
super(
|
||||
parentScreen,
|
||||
new ConfigElement(Config.config.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(),
|
||||
"zombiesutils",
|
||||
false,
|
||||
false,
|
||||
"Zombies Utils"
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.github.stachelbeere1248.zombiesutils.config;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraftforge.fml.client.IModGuiFactory;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class GuiFactory implements IModGuiFactory {
|
||||
|
||||
public boolean hasConfigGui() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(Minecraft minecraft) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends GuiScreen> mainConfigGuiClass() {
|
||||
return GuiConfig.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@ package com.github.stachelbeere1248.zombiesutils.game;
|
|||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@SuppressWarnings("DuplicatedCode")
|
||||
public class GameMode {
|
||||
private static GameMode currentGameMode = null;
|
||||
public static final GameMode DEAD_END_NORMAL = new GameMode(Map.DEAD_END), DEAD_END_HARD = new GameMode(Map.DEAD_END, Difficulty.HARD), DEAD_END_RIP = new GameMode(Map.DEAD_END, Difficulty.RIP);
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.github.stachelbeere1248.zombiesutils.game;
|
|||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@SuppressWarnings("DuplicatedCode")
|
||||
public class Waves {
|
||||
private static final byte[][] 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}},
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.github.stachelbeere1248.zombiesutils.game.windows;
|
||||
|
||||
import net.minecraft.util.Vec3;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
@ -21,6 +22,8 @@ public class Room {
|
|||
|
||||
@Contract(" -> new")
|
||||
public static Room @NotNull [] getDE() {
|
||||
Vec3 t = new Vec3(3,3,3);
|
||||
t.rotatePitch(3);
|
||||
return new Room[]{
|
||||
new Room("Alley", new Window[]{
|
||||
new Window(1,13,138,63),
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
package com.github.stachelbeere1248.zombiesutils.game.windows;
|
||||
|
||||
import com.github.stachelbeere1248.zombiesutils.ZombiesUtils;
|
||||
import com.github.stachelbeere1248.zombiesutils.game.Map;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
|
||||
public class Sla {
|
||||
private static Sla instance = null;
|
||||
private static boolean enabled = false;
|
||||
public static Sla instance = null;
|
||||
private final double[] offset = new double[3];
|
||||
private final Room[] rooms;
|
||||
|
||||
|
@ -22,15 +23,39 @@ public class Sla {
|
|||
case ALIEN_ARCADIUM: this.rooms = Room.getAA(); break;
|
||||
default: throw new IllegalStateException("Unexpected value: " + map);
|
||||
}
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public void rotate() {
|
||||
for (Room room : rooms) {
|
||||
for (Window window: room.getWindows()) {
|
||||
window.rotate();
|
||||
}
|
||||
}
|
||||
System.out.println("Co3 now at " + Arrays.toString(rooms[0].getWindows()[0].getXYZ()));
|
||||
}
|
||||
public void mirrorX() {
|
||||
for (Room room : rooms) {
|
||||
for (Window window: room.getWindows()) {
|
||||
window.mirrorX();
|
||||
}
|
||||
}
|
||||
System.out.println("Co3 now at " + Arrays.toString(rooms[0].getWindows()[0].getXYZ()));
|
||||
}
|
||||
public void mirrorZ() {
|
||||
for (Room room : rooms) {
|
||||
for (Window window: room.getWindows()) {
|
||||
window.mirrorZ();
|
||||
}
|
||||
}
|
||||
short[] win0 = rooms[0].getWindows()[0].getXYZ();
|
||||
ZombiesUtils.getInstance().getLogger().info("Window \"0\" is now at %s %s %s" + (double) win0[0]/2 + (double) win0[1]/2 + (double) win0[2]/2);
|
||||
}
|
||||
public void refreshActives() {
|
||||
final EntityPlayerSP player = Minecraft.getMinecraft().thePlayer;
|
||||
final double[] playerCoords = {
|
||||
player.posX + offset[0],
|
||||
player.posY + offset[1],
|
||||
player.posZ + offset[2]
|
||||
(player.posX - offset[0]),
|
||||
player.posY - offset[1],
|
||||
player.posZ - offset[2]
|
||||
};
|
||||
for (Room room: rooms
|
||||
) {
|
||||
|
@ -61,12 +86,6 @@ public class Sla {
|
|||
public Room[] getRooms() {
|
||||
return rooms;
|
||||
}
|
||||
public static boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
public static void toggle() {
|
||||
Sla.enabled = !Sla.enabled;
|
||||
}
|
||||
public void resetOffset() {
|
||||
Arrays.fill(this.offset, 0);
|
||||
}
|
||||
|
|
|
@ -17,10 +17,21 @@ public class Window {
|
|||
return xyz;
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return isActive;
|
||||
}
|
||||
public void setActive(boolean active) {
|
||||
isActive = active;
|
||||
}
|
||||
public boolean isActive() {
|
||||
return isActive;
|
||||
}
|
||||
public void rotate() {
|
||||
final short x = xyz[0], z = xyz[2];
|
||||
xyz[0] = (short) -z;
|
||||
xyz[2] = x;
|
||||
}
|
||||
public void mirrorX() {
|
||||
xyz[0] = (short) -xyz[0];
|
||||
}
|
||||
public void mirrorZ() {
|
||||
xyz[2] = (short) -xyz[2];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.github.stachelbeere1248.zombiesutils.game.Difficulty;
|
|||
import com.github.stachelbeere1248.zombiesutils.game.GameMode;
|
||||
import net.minecraftforge.client.event.ClientChatReceivedEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
@ -15,7 +16,7 @@ public class ChatHandler {
|
|||
private static final Pattern STRIP_COLOR_PATTERN = Pattern.compile("§[0-9A-FK-ORZ]", Pattern.CASE_INSENSITIVE);
|
||||
|
||||
@SubscribeEvent
|
||||
public void difficultyChange(ClientChatReceivedEvent event) {
|
||||
public void difficultyChange(@NotNull ClientChatReceivedEvent event) {
|
||||
String message = STRIP_COLOR_PATTERN.matcher(event.message.getUnformattedText()).replaceAll("").trim();
|
||||
GameMode gameMode = GameMode.getCurrentGameMode();
|
||||
|
||||
|
|
|
@ -3,10 +3,11 @@ package com.github.stachelbeere1248.zombiesutils.handlers;
|
|||
import com.github.stachelbeere1248.zombiesutils.utils.Scoreboard;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class TickHandler {
|
||||
@SubscribeEvent
|
||||
public void onTick(TickEvent.ClientTickEvent event) {
|
||||
public void onTick(TickEvent.@NotNull ClientTickEvent event) {
|
||||
if (event.phase == TickEvent.Phase.START) return;
|
||||
Scoreboard.refresh();
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||
|
||||
@Mixin(NetHandlerPlayClient.class)
|
||||
public class MixinNetHandlerPlayClient {
|
||||
public MixinNetHandlerPlayClient() {}
|
||||
@Unique
|
||||
private boolean zombies_utils$alienUfoOpened;
|
||||
@Inject(method = "handleSoundEffect", at = @At(value = "HEAD"))
|
||||
|
@ -29,7 +28,7 @@ public class MixinNetHandlerPlayClient {
|
|||
}
|
||||
@Unique
|
||||
private void zombies_utils$handleSound(@NotNull S29PacketSoundEffect packet) {
|
||||
if (!Scoreboard.isZombies()) return;
|
||||
if (Scoreboard.isZombies()) return;
|
||||
String soundEffect = packet.getSoundName();
|
||||
if (!(
|
||||
soundEffect.equals("mob.wither.spawn")
|
||||
|
@ -58,11 +57,11 @@ public class MixinNetHandlerPlayClient {
|
|||
}
|
||||
}
|
||||
@Unique
|
||||
private void zombies_utils$handleTitle(S45PacketTitle packet) {
|
||||
private void zombies_utils$handleTitle(@NotNull S45PacketTitle packet) {
|
||||
if (packet.getType() != S45PacketTitle.Type.TITLE) return;
|
||||
if (!Scoreboard.isZombies()) return;
|
||||
if (Scoreboard.isZombies()) return;
|
||||
final String message = packet.getMessage().getUnformattedText().trim();
|
||||
if (message.equals("\u00a7aYou Win!")) {
|
||||
if (message.equals("§aYou Win!")) {
|
||||
switch (GameMode.getCurrentGameMode().getMap()) {
|
||||
case DEAD_END: case BAD_BLOOD:
|
||||
Timer.getInstance().ifPresent(timer -> {
|
||||
|
@ -77,7 +76,7 @@ public class MixinNetHandlerPlayClient {
|
|||
});
|
||||
break;
|
||||
}
|
||||
} else if (message.equals("\u00a7cGame Over!")) {
|
||||
} else if (message.equals("§cGame Over!")) {
|
||||
Timer.dropInstances();
|
||||
} else {
|
||||
ZombiesUtils.getInstance().getLogger().debug(message);
|
||||
|
|
|
@ -21,10 +21,10 @@ public class RenderGameOverlayHandler {
|
|||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onRenderGameOverlay(RenderGameOverlayEvent.Post event) {
|
||||
public void onRenderGameOverlay(RenderGameOverlayEvent.@NotNull Post event) {
|
||||
if (event.type != RenderGameOverlayEvent.ElementType.TEXT) return;
|
||||
Timer.getInstance().ifPresent(timer -> renderTime(timer.roundTime()));
|
||||
if (Sla.isEnabled()) Sla.getInstance().ifPresent(sla -> {
|
||||
Sla.getInstance().ifPresent(sla -> {
|
||||
sla.refreshActives();
|
||||
renderSla(sla.getRooms());
|
||||
});
|
||||
|
@ -32,7 +32,7 @@ public class RenderGameOverlayHandler {
|
|||
}
|
||||
|
||||
private void renderTime(long timerTicks) {
|
||||
if (!Scoreboard.isZombies()) return;
|
||||
if (Scoreboard.isZombies()) return;
|
||||
long minutesPart = (timerTicks*50) / 60000;
|
||||
long secondsPart = ((timerTicks*50) % 60000) / 1000;
|
||||
long tenthSecondsPart = ((timerTicks*50) % 1000) / 100;
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.github.stachelbeere1248.zombiesutils.timer.recorder.Category;
|
|||
import com.github.stachelbeere1248.zombiesutils.timer.recorder.TimesFile;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class RecordManager {
|
||||
|
@ -16,21 +17,21 @@ public class RecordManager {
|
|||
timesFile.setBestSegment(round, roundTime);
|
||||
|
||||
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
|
||||
"\u00a7l\u00a7e Category: " + category.getName() + " - ***" + "\u00a7l\u00a76 NEW BEST SEGMENT! " + "\u00a7l\u00a7e***"
|
||||
"§l§e Category: " + category.getName() + " - ***" + "§l§6 NEW BEST SEGMENT! " + "§l§e***"
|
||||
));
|
||||
final String timeString = formattedTime(roundTime);
|
||||
final String message = "\u00a7cRound " + round + "\u00a7e took \u00a7a" + timeString + "\u00a7e!";
|
||||
final String message = "§cRound " + round + "§e took §a" + timeString + "§e!";
|
||||
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(message));
|
||||
|
||||
} else {
|
||||
if (roundTime<bestSegment) {
|
||||
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
|
||||
"\u00a7l\u00a7e Category: " + category.getName() + " - ***" + "\u00a7l\u00a76 NEW BEST SEGMENT! " + "\u00a7l\u00a7e***"
|
||||
"§l§e Category: " + category.getName() + " - ***" + "§l§6 NEW BEST SEGMENT! " + "§l§e***"
|
||||
));
|
||||
timesFile.setBestSegment(round, roundTime);
|
||||
}
|
||||
final String timeString = formattedTime(roundTime);
|
||||
final String message = "\u00a7cRound " + round + "\u00a7e took \u00a7a" + timeString + " \u00a79" + formattedDelta(roundTime,bestSegment);
|
||||
final String message = "§cRound " + round + "§e took §a" + timeString + " §9" + formattedDelta(roundTime,bestSegment);
|
||||
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(message));
|
||||
}
|
||||
sendBar();
|
||||
|
@ -43,23 +44,23 @@ public class RecordManager {
|
|||
timesFile.setPersonalBest(round, gameTime);
|
||||
|
||||
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
|
||||
"\u00a7l\u00a7e Category: " + category.getName() + " - ***" + "\u00a7l\u00a76 NEW PERSONAL BEST! " + "\u00a7l\u00a7e***"
|
||||
"§l§e Category: " + category.getName() + " - ***" + "§l§6 NEW PERSONAL BEST! " + "§l§e***"
|
||||
));
|
||||
|
||||
final String timeString = formattedTime(gameTime);
|
||||
final String message = "\u00a7cRound " + round + "\u00a7e finished at \u00a7a" + timeString + "\u00a7e!";
|
||||
final String message = "§cRound " + round + "§e finished at §a" + timeString + "§e!";
|
||||
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(message));
|
||||
|
||||
} else {
|
||||
if (gameTime<personalBest) {
|
||||
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
|
||||
"\u00a7l\u00a7e Category: " + category.getName() + " - ***" + "\u00a7l\u00a76 NEW PERSONAL BEST! " + "\u00a7l\u00a7e***"
|
||||
"§l§e Category: " + category.getName() + " - ***" + "§l§6 NEW PERSONAL BEST! " + "§l§e***"
|
||||
));
|
||||
timesFile.setPersonalBest(round, gameTime);
|
||||
}
|
||||
|
||||
final String timeString = formattedTime(gameTime);
|
||||
final String message = "\u00a7cRound " + round + "\u00a7e finished at \u00a7a" + timeString + " \u00a79" + formattedDelta(gameTime, personalBest);
|
||||
final String message = "§cRound " + round + "§e finished at §a" + timeString + " §9" + formattedDelta(gameTime, personalBest);
|
||||
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(message));
|
||||
|
||||
}
|
||||
|
@ -72,7 +73,8 @@ public class RecordManager {
|
|||
((gameTime *50) % 1000) / 100
|
||||
);
|
||||
}
|
||||
private static String formattedDelta(int newTime, int prevTime) {
|
||||
@Contract(pure = true)
|
||||
private static @NotNull String formattedDelta(int newTime, int prevTime) {
|
||||
double delta = (double) (newTime - prevTime) / 20;
|
||||
if (delta<0) {
|
||||
return String.valueOf(delta);
|
||||
|
@ -80,7 +82,7 @@ public class RecordManager {
|
|||
}
|
||||
private static void sendBar() {
|
||||
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
|
||||
"\u00a7l\u00a7a▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬"
|
||||
"§l§a▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬"
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.github.stachelbeere1248.zombiesutils.timer;
|
||||
|
||||
import com.github.stachelbeere1248.zombiesutils.ZombiesUtils;
|
||||
import com.github.stachelbeere1248.zombiesutils.config.Config;
|
||||
import com.github.stachelbeere1248.zombiesutils.game.GameMode;
|
||||
import com.github.stachelbeere1248.zombiesutils.game.Map;
|
||||
import com.github.stachelbeere1248.zombiesutils.game.windows.Sla;
|
||||
|
@ -34,7 +35,7 @@ public class Timer {
|
|||
|
||||
this.category = new Category();
|
||||
GameMode.create(map);
|
||||
new Sla(map);
|
||||
if (Config.isSlaToggled()) Sla.instance = new Sla(map);
|
||||
}
|
||||
|
||||
|
||||
|
@ -44,7 +45,7 @@ public class Timer {
|
|||
* @param passedRound The round that has been passed.
|
||||
*/
|
||||
public void split(byte passedRound) {
|
||||
if (dontDupeSplitPlease == passedRound) {
|
||||
if (dontDupeSplitPlease == passedRound || passedRound == 0) {
|
||||
ZombiesUtils.getInstance().getLogger().debug("SPLIT CANCELLED");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.github.stachelbeere1248.zombiesutils.timer.recorder;
|
|||
|
||||
import com.google.gson.Gson;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
|
@ -9,7 +10,7 @@ import java.io.IOException;
|
|||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class FileManager {
|
||||
private static FileData readDataFromFile(File file) throws FileNotFoundException {
|
||||
private static FileData readDataFromFile(@NotNull File file) throws FileNotFoundException {
|
||||
if (!file.exists()) throw new FileNotFoundException();
|
||||
|
||||
String dataJson;
|
||||
|
@ -23,7 +24,7 @@ public class FileManager {
|
|||
|
||||
return gson.fromJson(dataJson, FileData.class);
|
||||
}
|
||||
private static void createDataFile(FileData fileData, File file) {
|
||||
private static void createDataFile(FileData fileData, @NotNull File file) {
|
||||
try {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
file.getParentFile().mkdirs();
|
||||
|
@ -34,7 +35,7 @@ public class FileManager {
|
|||
}
|
||||
writeDataToFile(fileData, file);
|
||||
}
|
||||
public static void writeDataToFile(FileData fileData, File file) {
|
||||
public static void writeDataToFile(@NotNull FileData fileData, File file) {
|
||||
try {
|
||||
FileUtils.writeStringToFile(file, fileData.getAsJsonString(), StandardCharsets.UTF_16);
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
package com.github.stachelbeere1248.zombiesutils.timer.recorder;
|
||||
|
||||
import com.github.stachelbeere1248.zombiesutils.game.GameMode;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class TimesFile extends File {
|
||||
private final FileData fileData;
|
||||
private final GameMode gameMode;
|
||||
public TimesFile(String category, GameMode gameMode) {
|
||||
public TimesFile(String category, @NotNull GameMode gameMode) {
|
||||
// Game-directory -> custom category -> file named "MAP_DIFFICULTY.times"
|
||||
// Content encoded in StandardCharsets.UTF_16
|
||||
super("zombies" + File.separator + category,gameMode.getMap() + "_" + gameMode.getDifficulty() + ".times");
|
||||
|
|
|
@ -17,6 +17,7 @@ import java.util.regex.Pattern;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
public class Scoreboard {
|
||||
@SuppressWarnings("UnnecessaryUnicodeEscape")
|
||||
private static final Pattern SIDEBAR_EMOJI_PATTERN = Pattern.compile("[\uD83D\uDD2B\uD83C\uDF6B\uD83D\uDCA3\uD83D\uDC7D\uD83D\uDD2E\uD83D\uDC0D\uD83D\uDC7E\uD83C\uDF20\uD83C\uDF6D\u26BD\uD83C\uDFC0\uD83D\uDC79\uD83C\uDF81\uD83C\uDF89\uD83C\uDF82]+");
|
||||
private static final Pattern STRIP_COLOR_PATTERN = Pattern.compile("§[0-9A-FK-ORZ]", Pattern.CASE_INSENSITIVE);
|
||||
private static final Pattern ROUND_LINE_PATTERN = Pattern.compile("(Round )([0-9]{1,3})");
|
||||
|
@ -50,7 +51,7 @@ public class Scoreboard {
|
|||
else scores = filteredScores;
|
||||
scores = Lists.reverse(scores);
|
||||
|
||||
lines = new ArrayList<String>();
|
||||
lines = new ArrayList<>();
|
||||
for (Score score: scores
|
||||
) {
|
||||
ScorePlayerTeam team = scoreboard.getPlayersTeam(score.getPlayerName());
|
||||
|
@ -110,6 +111,6 @@ public class Scoreboard {
|
|||
}
|
||||
}
|
||||
public static boolean isZombies() {
|
||||
return ("ZOMBIES".equals(title));
|
||||
return (!"ZOMBIES".equals(title));
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue