refactor config
This commit is contained in:
parent
93df8513bc
commit
328f07d6f6
22 changed files with 492 additions and 150 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.5
|
version = 1.3
|
||||||
|
|
|
@ -16,6 +16,7 @@ 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 ZombiesUtilsConfig config;
|
||||||
private Handlers handlers;
|
private Handlers handlers;
|
||||||
private Logger logger;
|
private Logger logger;
|
||||||
|
|
||||||
|
@ -28,14 +29,18 @@ public class ZombiesUtils {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isHypixel() {
|
||||||
|
String ip = Minecraft.getMinecraft().getCurrentServerData().serverIP;
|
||||||
|
return (ip.equals("localhost") || ip.matches("(.+\\.)?(hypixel\\.net)(:25565)?"));
|
||||||
|
}
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
public void preInit(@NotNull FMLPreInitializationEvent event) {
|
public void preInit(@NotNull FMLPreInitializationEvent event) {
|
||||||
logger = event.getModLog();
|
logger = event.getModLog();
|
||||||
ZombiesUtilsConfig.config = new Configuration(
|
this.config = new ZombiesUtilsConfig(new Configuration(
|
||||||
event.getSuggestedConfigurationFile(),
|
event.getSuggestedConfigurationFile(),
|
||||||
"1.2.4"
|
"1.2.4")
|
||||||
);
|
);
|
||||||
ZombiesUtilsConfig.load();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
|
@ -58,7 +63,7 @@ public class ZombiesUtils {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isHypixel() {
|
public ZombiesUtilsConfig getConfig() {
|
||||||
return Minecraft.getMinecraft().getCurrentServerData().serverIP.matches("(.+\\.)?(hypixel\\.net)(:25565)?");
|
return config;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@ package com.github.stachelbeere1248.zombiesutils.commands;
|
||||||
|
|
||||||
import com.github.stachelbeere1248.zombiesutils.timer.Timer;
|
import com.github.stachelbeere1248.zombiesutils.timer.Timer;
|
||||||
import com.github.stachelbeere1248.zombiesutils.timer.recorder.Category;
|
import com.github.stachelbeere1248.zombiesutils.timer.recorder.Category;
|
||||||
import net.minecraft.command.CommandBase;
|
|
||||||
import net.minecraft.command.CommandException;
|
import net.minecraft.command.CommandException;
|
||||||
|
import net.minecraft.command.ICommand;
|
||||||
import net.minecraft.command.ICommandSender;
|
import net.minecraft.command.ICommandSender;
|
||||||
import net.minecraft.command.WrongUsageException;
|
import net.minecraft.command.WrongUsageException;
|
||||||
import net.minecraft.util.BlockPos;
|
import net.minecraft.util.BlockPos;
|
||||||
|
@ -13,7 +13,7 @@ import java.io.File;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class CategoryCommand extends CommandBase {
|
public class CategoryCommand implements ICommand {
|
||||||
public CategoryCommand() {
|
public CategoryCommand() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,13 +28,18 @@ public class CategoryCommand extends CommandBase {
|
||||||
return "/category <category-name>";
|
return "/category <category-name>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getCommandAliases() {
|
||||||
|
return Arrays.asList("runCategory", "cat");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
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("Please enter a name for the category");
|
if (args.length == 0) throw new WrongUsageException("Please enter a name for the category");
|
||||||
else {
|
else {
|
||||||
String cat = args[0];
|
String cat = args[0];
|
||||||
if (cat.contains(File.separator))
|
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");
|
throw new WrongUsageException("Your name must not contain '" + File.separator + "' as this is the systems separator character for folder" + File.separator + "sub-folder");
|
||||||
Category.setSelectedCategory(cat);
|
Category.setSelectedCategory(cat);
|
||||||
Timer.getInstance().ifPresent(timer -> timer.setCategory(new Category()));
|
Timer.getInstance().ifPresent(timer -> timer.setCategory(new Category()));
|
||||||
}
|
}
|
||||||
|
@ -45,8 +50,18 @@ public class CategoryCommand extends CommandBase {
|
||||||
return Arrays.asList(Category.getCategories());
|
return Arrays.asList(Category.getCategories());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isUsernameIndex(String[] args, int index) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canCommandSenderUseCommand(ICommandSender sender) {
|
public boolean canCommandSenderUseCommand(ICommandSender sender) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(@NotNull ICommand command) {
|
||||||
|
return this.getCommandName().compareTo(command.getCommandName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package com.github.stachelbeere1248.zombiesutils.commands;
|
package com.github.stachelbeere1248.zombiesutils.commands;
|
||||||
|
|
||||||
|
import com.github.stachelbeere1248.zombiesutils.game.SLA;
|
||||||
import com.github.stachelbeere1248.zombiesutils.game.enums.Map;
|
import com.github.stachelbeere1248.zombiesutils.game.enums.Map;
|
||||||
import com.github.stachelbeere1248.zombiesutils.game.sla.QuickSLA;
|
import com.github.stachelbeere1248.zombiesutils.game.sla.QuickSLA;
|
||||||
import com.github.stachelbeere1248.zombiesutils.game.SLA;
|
|
||||||
import net.minecraft.command.*;
|
import net.minecraft.command.*;
|
||||||
import net.minecraft.util.BlockPos;
|
import net.minecraft.util.BlockPos;
|
||||||
import net.minecraft.util.ChatComponentText;
|
import net.minecraft.util.ChatComponentText;
|
||||||
|
|
|
@ -0,0 +1,244 @@
|
||||||
|
package com.github.stachelbeere1248.zombiesutils.config;
|
||||||
|
|
||||||
|
import net.minecraftforge.common.config.ConfigCategory;
|
||||||
|
import net.minecraftforge.common.config.ConfigElement;
|
||||||
|
import net.minecraftforge.common.config.Property;
|
||||||
|
import net.minecraftforge.fml.client.config.ConfigGuiType;
|
||||||
|
import net.minecraftforge.fml.client.config.GuiConfigEntries;
|
||||||
|
import net.minecraftforge.fml.client.config.GuiEditArrayEntries;
|
||||||
|
import net.minecraftforge.fml.client.config.IConfigElement;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
public class CustomConfigElement implements IConfigElement {
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
private final boolean isProperty;
|
||||||
|
private Property prop;
|
||||||
|
private ConfigCategory category;
|
||||||
|
|
||||||
|
public CustomConfigElement(String name, Property prop) {
|
||||||
|
this.prop = prop;
|
||||||
|
this.isProperty = true;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CustomConfigElement(String name, ConfigCategory category) {
|
||||||
|
this.category = category;
|
||||||
|
this.isProperty = false;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ConfigGuiType getType(Property prop) {
|
||||||
|
return prop.getType() == Property.Type.BOOLEAN ? ConfigGuiType.BOOLEAN : prop.getType() == Property.Type.DOUBLE ? ConfigGuiType.DOUBLE :
|
||||||
|
prop.getType() == Property.Type.INTEGER ? ConfigGuiType.INTEGER : prop.getType() == Property.Type.COLOR ? ConfigGuiType.COLOR :
|
||||||
|
prop.getType() == Property.Type.MOD_ID ? ConfigGuiType.MOD_ID : ConfigGuiType.STRING;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<IConfigElement> getChildElements() {
|
||||||
|
if (!isProperty) {
|
||||||
|
List<IConfigElement> elements = new ArrayList<>();
|
||||||
|
|
||||||
|
for (Property property : category.getOrderedValues()) {
|
||||||
|
ConfigElement temp = new ConfigElement(property);
|
||||||
|
if (temp.showInGui())
|
||||||
|
elements.add(temp);
|
||||||
|
}
|
||||||
|
return elements;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isProperty() {
|
||||||
|
return isProperty;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<? extends GuiConfigEntries.IConfigEntry> getConfigEntryClass() {
|
||||||
|
return isProperty ? prop.getConfigEntryClass() : category.getConfigEntryClass();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<? extends GuiEditArrayEntries.IArrayEntry> getArrayEntryClass() {
|
||||||
|
return isProperty ? prop.getArrayEntryClass() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getQualifiedName() {
|
||||||
|
return isProperty ? prop.getName() : category.getQualifiedName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ConfigGuiType getType() {
|
||||||
|
return isProperty ? getType(this.prop) : ConfigGuiType.CONFIG_CATEGORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isList() {
|
||||||
|
return isProperty && prop.isList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isListLengthFixed() {
|
||||||
|
return isProperty && prop.isListLengthFixed();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxListLength() {
|
||||||
|
return isProperty ? prop.getMaxListLength() : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getComment() {
|
||||||
|
return isProperty ? prop.comment : category.getComment();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDefault() {
|
||||||
|
return !isProperty || prop.isDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setToDefault() {
|
||||||
|
if (isProperty)
|
||||||
|
prop.setToDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean requiresWorldRestart() {
|
||||||
|
return isProperty ? prop.requiresWorldRestart() : category.requiresWorldRestart();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean showInGui() {
|
||||||
|
return isProperty ? prop.showInGui() : category.showInGui();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean requiresMcRestart() {
|
||||||
|
return isProperty ? prop.requiresMcRestart() : category.requiresMcRestart();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] getValidValues() {
|
||||||
|
return isProperty ? prop.getValidValues() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getLanguageKey() {
|
||||||
|
return isProperty ? prop.getLanguageKey() : category.getLanguagekey();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getDefault() {
|
||||||
|
return isProperty ? prop.getDefault() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object[] getDefaults() {
|
||||||
|
if (isProperty) {
|
||||||
|
String[] aVal = prop.getDefaults();
|
||||||
|
return getObjects(aVal);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object[] getObjects(String[] aVal) {
|
||||||
|
if (prop.getType() == Property.Type.BOOLEAN) {
|
||||||
|
Boolean[] ba = new Boolean[aVal.length];
|
||||||
|
for (int i = 0; i < aVal.length; i++)
|
||||||
|
ba[i] = Boolean.valueOf(aVal[i]);
|
||||||
|
return ba;
|
||||||
|
} else if (prop.getType() == Property.Type.DOUBLE) {
|
||||||
|
Double[] da = new Double[aVal.length];
|
||||||
|
for (int i = 0; i < aVal.length; i++)
|
||||||
|
da[i] = Double.valueOf(aVal[i]);
|
||||||
|
return da;
|
||||||
|
} else if (prop.getType() == Property.Type.INTEGER) {
|
||||||
|
Integer[] ia = new Integer[aVal.length];
|
||||||
|
for (int i = 0; i < aVal.length; i++)
|
||||||
|
ia[i] = Integer.valueOf(aVal[i]);
|
||||||
|
return ia;
|
||||||
|
} else
|
||||||
|
return aVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Pattern getValidationPattern() {
|
||||||
|
return isProperty ? prop.getValidationPattern() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object get() {
|
||||||
|
return isProperty ? prop.getString() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object[] getList() {
|
||||||
|
if (isProperty) {
|
||||||
|
String[] aVal = prop.getStringList();
|
||||||
|
return getObjects(aVal);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void set(Object value) {
|
||||||
|
if (isProperty) {
|
||||||
|
if (prop.getType() == Property.Type.BOOLEAN)
|
||||||
|
prop.set(Boolean.parseBoolean(value.toString()));
|
||||||
|
else if (prop.getType() == Property.Type.DOUBLE)
|
||||||
|
prop.set(Double.parseDouble(value.toString()));
|
||||||
|
else if (prop.getType() == Property.Type.INTEGER)
|
||||||
|
prop.set(Integer.parseInt(value.toString()));
|
||||||
|
else
|
||||||
|
prop.set(value.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void set(Object[] aVal) {
|
||||||
|
if (isProperty) {
|
||||||
|
if (prop.getType() == Property.Type.BOOLEAN) {
|
||||||
|
boolean[] ba = new boolean[aVal.length];
|
||||||
|
for (int i = 0; i < aVal.length; i++)
|
||||||
|
ba[i] = Boolean.parseBoolean(aVal[i].toString());
|
||||||
|
prop.set(ba);
|
||||||
|
} else if (prop.getType() == Property.Type.DOUBLE) {
|
||||||
|
double[] da = new double[aVal.length];
|
||||||
|
for (int i = 0; i < aVal.length; i++)
|
||||||
|
da[i] = Double.parseDouble(aVal[i].toString());
|
||||||
|
prop.set(da);
|
||||||
|
} else if (prop.getType() == Property.Type.INTEGER) {
|
||||||
|
int[] ia = new int[aVal.length];
|
||||||
|
for (int i = 0; i < aVal.length; i++)
|
||||||
|
ia[i] = Integer.parseInt(aVal[i].toString());
|
||||||
|
prop.set(ia);
|
||||||
|
} else {
|
||||||
|
String[] is = new String[aVal.length];
|
||||||
|
for (int i = 0; i < aVal.length; i++)
|
||||||
|
is[i] = aVal[i].toString();
|
||||||
|
prop.set(is);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getMinValue() {
|
||||||
|
return isProperty ? prop.getMinValue() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getMaxValue() {
|
||||||
|
return isProperty ? prop.getMaxValue() : null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,14 +1,13 @@
|
||||||
package com.github.stachelbeere1248.zombiesutils.config;
|
package com.github.stachelbeere1248.zombiesutils.config;
|
||||||
|
|
||||||
|
import com.github.stachelbeere1248.zombiesutils.ZombiesUtils;
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
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 class GuiConfig extends net.minecraftforge.fml.client.config.GuiConfig {
|
||||||
public GuiConfig(GuiScreen parentScreen) {
|
public GuiConfig(GuiScreen parentScreen) {
|
||||||
super(
|
super(
|
||||||
parentScreen,
|
parentScreen,
|
||||||
new ConfigElement(ZombiesUtilsConfig.config.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(),
|
ZombiesUtils.getInstance().getConfig().getRootElements(),
|
||||||
"zombiesutils",
|
"zombiesutils",
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
|
|
|
@ -4,29 +4,109 @@ import com.github.stachelbeere1248.zombiesutils.ZombiesUtils;
|
||||||
import com.github.stachelbeere1248.zombiesutils.utils.LanguageSupport;
|
import com.github.stachelbeere1248.zombiesutils.utils.LanguageSupport;
|
||||||
import net.minecraftforge.common.config.Configuration;
|
import net.minecraftforge.common.config.Configuration;
|
||||||
import net.minecraftforge.common.config.Property;
|
import net.minecraftforge.common.config.Property;
|
||||||
|
import net.minecraftforge.fml.client.config.DummyConfigElement;
|
||||||
|
import net.minecraftforge.fml.client.config.IConfigElement;
|
||||||
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
|
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class ZombiesUtilsConfig {
|
import java.util.Arrays;
|
||||||
public static Configuration config;
|
import java.util.List;
|
||||||
private static Property slaToggle;
|
|
||||||
private static Property slaShortener;
|
|
||||||
private static Property shortSpawntime;
|
|
||||||
private static Property sst;
|
|
||||||
private static Property chatMacro;
|
|
||||||
private static Property defaultCategory;
|
|
||||||
private static Property waveOffset;
|
|
||||||
private static Property language;
|
|
||||||
private static Property auditory;
|
|
||||||
private static Property copyDelta;
|
|
||||||
private static Property cpsCounter;
|
|
||||||
|
|
||||||
public static void load() {
|
public class ZombiesUtilsConfig {
|
||||||
|
public final Configuration config;
|
||||||
|
private Property sstHud;
|
||||||
|
private Property offset;
|
||||||
|
private Property slaToggle;
|
||||||
|
private Property slaShortener;
|
||||||
|
private Property shortSpawntime;
|
||||||
|
private Property chatMacro;
|
||||||
|
private Property defaultCategory;
|
||||||
|
private Property language;
|
||||||
|
private Property auditory;
|
||||||
|
private Property copyDelta;
|
||||||
|
private Property cpsCounter;
|
||||||
|
private Property announcePB;
|
||||||
|
|
||||||
|
public ZombiesUtilsConfig(Configuration config) {
|
||||||
|
this.config = config;
|
||||||
|
this.read();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void read() {
|
||||||
ZombiesUtils.getInstance().getLogger().debug("Loading config...");
|
ZombiesUtils.getInstance().getLogger().debug("Loading config...");
|
||||||
config.load();
|
config.load();
|
||||||
ZombiesUtils.getInstance().getLogger().debug("Config loaded.");
|
ZombiesUtils.getInstance().getLogger().debug("Config loaded.");
|
||||||
|
|
||||||
|
//SST
|
||||||
|
sstHud = config.get(
|
||||||
|
"SST",
|
||||||
|
"enabled",
|
||||||
|
true,
|
||||||
|
"Show the spawn-time HUD?"
|
||||||
|
);
|
||||||
|
auditory = config.get(
|
||||||
|
"SST",
|
||||||
|
"auditory",
|
||||||
|
new int[]{-40, -20, 0},
|
||||||
|
"For every entry a sound will be played x ticks before the wave spawn.",
|
||||||
|
-200,
|
||||||
|
200,
|
||||||
|
false,
|
||||||
|
5
|
||||||
|
);
|
||||||
|
//noinspection SpellCheckingInspection
|
||||||
|
shortSpawntime = config.get(
|
||||||
|
"SST",
|
||||||
|
"autohide",
|
||||||
|
false,
|
||||||
|
"Hide passed rounds?"
|
||||||
|
);
|
||||||
|
offset = config.get(
|
||||||
|
"SST",
|
||||||
|
"offset",
|
||||||
|
-28,
|
||||||
|
"Offset is added while in RL-mode",
|
||||||
|
-200,
|
||||||
|
200
|
||||||
|
);
|
||||||
|
|
||||||
|
//SLA
|
||||||
|
slaToggle = config.get(
|
||||||
|
"SLA",
|
||||||
|
"autostart",
|
||||||
|
false,
|
||||||
|
"Should SLA be started when a game starts?"
|
||||||
|
);
|
||||||
|
slaShortener = config.get(
|
||||||
|
"SLA",
|
||||||
|
"shortened SLA",
|
||||||
|
true,
|
||||||
|
"If on, inactive windows / rooms will not show"
|
||||||
|
);
|
||||||
|
|
||||||
|
//Timer
|
||||||
|
defaultCategory = config.get(
|
||||||
|
"timer",
|
||||||
|
"Default Category",
|
||||||
|
"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",
|
||||||
|
true,
|
||||||
|
"Whether to announce PBs."
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//ROOT
|
||||||
language = config.get(
|
language = config.get(
|
||||||
Configuration.CATEGORY_GENERAL,
|
Configuration.CATEGORY_GENERAL,
|
||||||
"Language",
|
"Language",
|
||||||
|
@ -34,66 +114,12 @@ public class ZombiesUtilsConfig {
|
||||||
"Your Hypixel language",
|
"Your Hypixel language",
|
||||||
LanguageSupport.getLanguages()
|
LanguageSupport.getLanguages()
|
||||||
);
|
);
|
||||||
slaToggle = config.get(
|
|
||||||
Configuration.CATEGORY_GENERAL,
|
|
||||||
"SLA Launcher",
|
|
||||||
false,
|
|
||||||
"Should SLA be started when a game starts?"
|
|
||||||
);
|
|
||||||
slaShortener = config.get(
|
|
||||||
Configuration.CATEGORY_GENERAL,
|
|
||||||
"shortened SLA",
|
|
||||||
true,
|
|
||||||
"If on, inactive windows / rooms will not show"
|
|
||||||
);
|
|
||||||
chatMacro = config.get(
|
chatMacro = config.get(
|
||||||
Configuration.CATEGORY_GENERAL,
|
Configuration.CATEGORY_GENERAL,
|
||||||
"Chat Macro",
|
"Chat Macro",
|
||||||
"T",
|
"T",
|
||||||
"The Text to be sent when pressing the chat-macro hotkey"
|
"The Text to be sent when pressing the chat-macro hotkey"
|
||||||
);
|
);
|
||||||
defaultCategory = config.get(
|
|
||||||
Configuration.CATEGORY_GENERAL,
|
|
||||||
"Default Category",
|
|
||||||
"general",
|
|
||||||
"name of the category to be selected unless specified using /runCategory"
|
|
||||||
);
|
|
||||||
waveOffset = config.get(
|
|
||||||
Configuration.CATEGORY_GENERAL,
|
|
||||||
"RL-mode offset",
|
|
||||||
-28,
|
|
||||||
"ticks to be added to the wave spawn time",
|
|
||||||
-200,
|
|
||||||
200
|
|
||||||
);
|
|
||||||
shortSpawntime = config.get(
|
|
||||||
Configuration.CATEGORY_GENERAL,
|
|
||||||
"passed wave spawns",
|
|
||||||
true,
|
|
||||||
"Display spawn-time for passed waves"
|
|
||||||
);
|
|
||||||
auditory = config.get(Configuration.CATEGORY_GENERAL,
|
|
||||||
"auditory sst",
|
|
||||||
new int[]{-40, -20, 0},
|
|
||||||
"Tick-offset to play sound",
|
|
||||||
-200,
|
|
||||||
200,
|
|
||||||
false,
|
|
||||||
5
|
|
||||||
);
|
|
||||||
sst = config.get(
|
|
||||||
Configuration.CATEGORY_GENERAL,
|
|
||||||
"SST HUD",
|
|
||||||
false,
|
|
||||||
"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(
|
cpsCounter = config.get(
|
||||||
Configuration.CATEGORY_GENERAL,
|
Configuration.CATEGORY_GENERAL,
|
||||||
"cps",
|
"cps",
|
||||||
|
@ -102,52 +128,95 @@ public class ZombiesUtilsConfig {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static short getWaveOffset() {
|
private List<IConfigElement> getSpawntimeElements() {
|
||||||
return (short) waveOffset.getInt();
|
return Arrays.asList(
|
||||||
|
new CustomConfigElement("Enabled", sstHud),
|
||||||
|
new CustomConfigElement("Auditory", auditory),
|
||||||
|
new CustomConfigElement("RL pre-timing", offset),
|
||||||
|
new CustomConfigElement("Truncate", shortSpawntime)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSlaToggled() {
|
private List<IConfigElement> getSlaElements() {
|
||||||
|
return Arrays.asList(
|
||||||
|
new CustomConfigElement("Enabled", slaToggle),
|
||||||
|
new CustomConfigElement("Truncate", slaShortener),
|
||||||
|
new CustomConfigElement("PB announcements", announcePB)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<IConfigElement> getTimerElements() {
|
||||||
|
return Arrays.asList(
|
||||||
|
new CustomConfigElement("Default category", defaultCategory),
|
||||||
|
new CustomConfigElement("Paste delta", copyDelta)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<IConfigElement> getRootElements() {
|
||||||
|
return Arrays.asList(
|
||||||
|
new DummyConfigElement.DummyCategoryElement("Timer", "", getSpawntimeElements()),
|
||||||
|
new DummyConfigElement.DummyCategoryElement("SST", "", getSpawntimeElements()),
|
||||||
|
new DummyConfigElement.DummyCategoryElement("SLA", "", getSpawntimeElements()),
|
||||||
|
new CustomConfigElement("Language", language),
|
||||||
|
new CustomConfigElement("Macro message", chatMacro),
|
||||||
|
new CustomConfigElement("CPS counter", cpsCounter)
|
||||||
|
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public short getOffset() {
|
||||||
|
return (short) offset.getInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSlaToggled() {
|
||||||
return slaToggle.getBoolean();
|
return slaToggle.getBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSlaShortened() {
|
public boolean isSlaShortened() {
|
||||||
return slaShortener.getBoolean();
|
return slaShortener.getBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSpawntimeNotShortened() {
|
public boolean isSpawntimeShortened() {
|
||||||
return shortSpawntime.getBoolean();
|
return shortSpawntime.getBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getChatMacro() {
|
public String getChatMacro() {
|
||||||
return chatMacro.getString();
|
return chatMacro.getString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getDefaultCategory() {
|
public String getDefaultCategory() {
|
||||||
return defaultCategory.getString();
|
return defaultCategory.getString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getLanguage() {
|
public String getLanguage() {
|
||||||
return language.getString();
|
return language.getString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int[] getAuditory() {
|
public int[] getAuditory() {
|
||||||
return auditory.getIntList();
|
return auditory.getIntList();
|
||||||
}
|
}
|
||||||
public static boolean getSST() {
|
|
||||||
return sst.getBoolean();
|
public boolean getSST() {
|
||||||
|
return sstHud.getBoolean();
|
||||||
}
|
}
|
||||||
public static boolean getCopyDelta() {
|
|
||||||
|
public boolean getCopyDelta() {
|
||||||
return copyDelta.getBoolean();
|
return copyDelta.getBoolean();
|
||||||
}
|
}
|
||||||
public static boolean getCpsToggle() {
|
|
||||||
|
public boolean getCpsToggle() {
|
||||||
return cpsCounter.getBoolean();
|
return cpsCounter.getBoolean();
|
||||||
}
|
}
|
||||||
|
public boolean getAnnouncePB() {
|
||||||
|
return announcePB.getBoolean();
|
||||||
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onConfigChange(ConfigChangedEvent.@NotNull OnConfigChangedEvent event) {
|
public void onConfigChange(ConfigChangedEvent.@NotNull OnConfigChangedEvent event) {
|
||||||
if (event.modID.equals("zombiesutils") && event.configID == null) {
|
if (event.modID.equals("zombiesutils") && event.configID == null) {
|
||||||
config.save();
|
config.save();
|
||||||
ZombiesUtilsConfig.load();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
package com.github.stachelbeere1248.zombiesutils.game.enums;
|
package com.github.stachelbeere1248.zombiesutils.game.enums;
|
||||||
|
|
||||||
public enum Map {
|
public enum Map {
|
||||||
DEAD_END, BAD_BLOOD, ALIEN_ARCADIUM, PRISON;
|
DEAD_END, BAD_BLOOD, ALIEN_ARCADIUM, PRISON
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
package com.github.stachelbeere1248.zombiesutils.game.waves;
|
package com.github.stachelbeere1248.zombiesutils.game.waves;
|
||||||
|
|
||||||
import com.github.stachelbeere1248.zombiesutils.config.ZombiesUtilsConfig;
|
import com.github.stachelbeere1248.zombiesutils.ZombiesUtils;
|
||||||
import com.github.stachelbeere1248.zombiesutils.timer.Timer;
|
import com.github.stachelbeere1248.zombiesutils.timer.Timer;
|
||||||
|
import com.github.stachelbeere1248.zombiesutils.utils.Scoreboard;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
@ -16,6 +17,7 @@ public class WaveTiming {
|
||||||
timer.getRound()
|
timer.getRound()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte getLastWave(@NotNull Timer timer) {
|
public static byte getLastWave(@NotNull Timer timer) {
|
||||||
return Waves.getLastWave(
|
return Waves.getLastWave(
|
||||||
timer.getGameMode().getMap(),
|
timer.getGameMode().getMap(),
|
||||||
|
@ -24,19 +26,23 @@ public class WaveTiming {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onTick() {
|
public static void onTick() {
|
||||||
|
if (Scoreboard.isNotZombies()) return;
|
||||||
Timer.getInstance().ifPresent(timer -> {
|
Timer.getInstance().ifPresent(timer -> {
|
||||||
int wave = (getLastWave(timer)*20)+rl;
|
byte[] waves = getWaves(timer);
|
||||||
final int roundTime = timer.roundTime();
|
final int roundTime = timer.roundTime();
|
||||||
final int[] auditory = ZombiesUtilsConfig.getAuditory();
|
final int[] auditory = ZombiesUtils.getInstance().getConfig().getAuditory();
|
||||||
|
for (int wave : waves) {
|
||||||
|
wave = wave * 20 + rl;
|
||||||
final Integer pre = roundTime - wave;
|
final Integer pre = roundTime - wave;
|
||||||
if (Arrays.stream(auditory).anyMatch(pre::equals)) {
|
if (Arrays.stream(auditory).anyMatch(pre::equals)) {
|
||||||
Minecraft.getMinecraft().thePlayer.playSound("note.pling", 1, 2);
|
Minecraft.getMinecraft().thePlayer.playSound("note.pling", 1, 2);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void toggleRL() {
|
public static void toggleRL() {
|
||||||
if (rl == 0) rl = ZombiesUtilsConfig.getWaveOffset();
|
if (rl == 0) rl = ZombiesUtils.getInstance().getConfig().getOffset();
|
||||||
else rl = 0;
|
else rl = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.github.stachelbeere1248.zombiesutils.game.windows;
|
package com.github.stachelbeere1248.zombiesutils.game.windows;
|
||||||
|
|
||||||
import com.github.stachelbeere1248.zombiesutils.config.ZombiesUtilsConfig;
|
import com.github.stachelbeere1248.zombiesutils.ZombiesUtils;
|
||||||
import net.minecraft.util.Vec3;
|
import net.minecraft.util.Vec3;
|
||||||
import org.jetbrains.annotations.Contract;
|
import org.jetbrains.annotations.Contract;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
@ -179,7 +179,8 @@ public class Room {
|
||||||
StringBuilder slaString = new StringBuilder(String.format("§6%s§r§d %x§e:", this.getName(), activeWindowCount));
|
StringBuilder slaString = new StringBuilder(String.format("§6%s§r§d %x§e:", this.getName(), activeWindowCount));
|
||||||
for (Window window : this.windows) {
|
for (Window window : this.windows) {
|
||||||
if (window.isActive()) slaString.append("§2 ").append(alias).append(window.getID());
|
if (window.isActive()) slaString.append("§2 ").append(alias).append(window.getID());
|
||||||
else if (!ZombiesUtilsConfig.isSlaShortened()) slaString.append("§c ").append(alias).append(window.getID());
|
else if (!ZombiesUtils.getInstance().getConfig().isSlaShortened())
|
||||||
|
slaString.append("§c ").append(alias).append(window.getID());
|
||||||
}
|
}
|
||||||
return slaString.toString();
|
return slaString.toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.github.stachelbeere1248.zombiesutils.handlers;
|
package com.github.stachelbeere1248.zombiesutils.handlers;
|
||||||
|
|
||||||
import com.github.stachelbeere1248.zombiesutils.game.enums.Difficulty;
|
|
||||||
import com.github.stachelbeere1248.zombiesutils.game.GameMode;
|
import com.github.stachelbeere1248.zombiesutils.game.GameMode;
|
||||||
|
import com.github.stachelbeere1248.zombiesutils.game.enums.Difficulty;
|
||||||
import com.github.stachelbeere1248.zombiesutils.timer.Timer;
|
import com.github.stachelbeere1248.zombiesutils.timer.Timer;
|
||||||
import com.github.stachelbeere1248.zombiesutils.utils.LanguageSupport;
|
import com.github.stachelbeere1248.zombiesutils.utils.LanguageSupport;
|
||||||
import net.minecraftforge.client.event.ClientChatReceivedEvent;
|
import net.minecraftforge.client.event.ClientChatReceivedEvent;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.github.stachelbeere1248.zombiesutils.handlers;
|
package com.github.stachelbeere1248.zombiesutils.handlers;
|
||||||
|
|
||||||
import com.github.stachelbeere1248.zombiesutils.config.ZombiesUtilsConfig;
|
import com.github.stachelbeere1248.zombiesutils.ZombiesUtils;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
|
||||||
public class Handlers {
|
public class Handlers {
|
||||||
|
@ -11,7 +11,7 @@ public class Handlers {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerAll() {
|
public void registerAll() {
|
||||||
MinecraftForge.EVENT_BUS.register(new ZombiesUtilsConfig());
|
MinecraftForge.EVENT_BUS.register(ZombiesUtils.getInstance().getConfig());
|
||||||
MinecraftForge.EVENT_BUS.register(renderer);
|
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());
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.github.stachelbeere1248.zombiesutils.handlers;
|
||||||
|
|
||||||
import com.github.stachelbeere1248.zombiesutils.ZombiesUtils;
|
import com.github.stachelbeere1248.zombiesutils.ZombiesUtils;
|
||||||
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.game.waves.WaveTiming;
|
import com.github.stachelbeere1248.zombiesutils.game.waves.WaveTiming;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
@ -20,7 +19,7 @@ public class KeyInputHandler {
|
||||||
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()
|
ZombiesUtils.getInstance().getConfig().getChatMacro()
|
||||||
);
|
);
|
||||||
} else if (Keyboard.getEventKey() == hotkeys.getRlSpawn().getKeyCode()) {
|
} else if (Keyboard.getEventKey() == hotkeys.getRlSpawn().getKeyCode()) {
|
||||||
ZombiesUtils.getInstance().getHandlers().getRenderer().toggleRL();
|
ZombiesUtils.getInstance().getHandlers().getRenderer().toggleRL();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.github.stachelbeere1248.zombiesutils.handlers;
|
package com.github.stachelbeere1248.zombiesutils.handlers;
|
||||||
|
|
||||||
import com.github.stachelbeere1248.zombiesutils.config.ZombiesUtilsConfig;
|
import com.github.stachelbeere1248.zombiesutils.ZombiesUtils;
|
||||||
import com.github.stachelbeere1248.zombiesutils.game.SLA;
|
import com.github.stachelbeere1248.zombiesutils.game.SLA;
|
||||||
import com.github.stachelbeere1248.zombiesutils.game.waves.Waves;
|
import com.github.stachelbeere1248.zombiesutils.game.waves.Waves;
|
||||||
import com.github.stachelbeere1248.zombiesutils.game.windows.Room;
|
import com.github.stachelbeere1248.zombiesutils.game.windows.Room;
|
||||||
|
@ -16,10 +16,10 @@ import org.jetbrains.annotations.NotNull;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class RenderGameOverlayHandler {
|
public class RenderGameOverlayHandler {
|
||||||
private int rl = 0;
|
private final byte[] clicks = new byte[20];
|
||||||
private final boolean[] clicks = new boolean[20];
|
|
||||||
private int clickPointer = 0;
|
|
||||||
private final FontRenderer fontRenderer;
|
private final FontRenderer fontRenderer;
|
||||||
|
private int rl = 0;
|
||||||
|
private int clickPointer = 0;
|
||||||
|
|
||||||
public RenderGameOverlayHandler() {
|
public RenderGameOverlayHandler() {
|
||||||
this.fontRenderer = Objects.requireNonNull(Minecraft.getMinecraft().fontRendererObj, "FontRenderer must not be null!");
|
this.fontRenderer = Objects.requireNonNull(Minecraft.getMinecraft().fontRendererObj, "FontRenderer must not be null!");
|
||||||
|
@ -40,7 +40,7 @@ public class RenderGameOverlayHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
void toggleRL() {
|
void toggleRL() {
|
||||||
if (rl == 0) rl = ZombiesUtilsConfig.getWaveOffset();
|
if (rl == 0) rl = ZombiesUtils.getInstance().getConfig().getOffset();
|
||||||
else rl = 0;
|
else rl = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ public class RenderGameOverlayHandler {
|
||||||
renderSla(sla.getRooms());
|
renderSla(sla.getRooms());
|
||||||
});
|
});
|
||||||
|
|
||||||
if (ZombiesUtilsConfig.getCpsToggle()) renderCPS();
|
if (ZombiesUtils.getInstance().getConfig().getCpsToggle()) renderCPS();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderTime(long timerTicks) {
|
private void renderTime(long timerTicks) {
|
||||||
|
@ -88,7 +88,7 @@ public class RenderGameOverlayHandler {
|
||||||
private void renderSla(Room @NotNull [] rooms) {
|
private void renderSla(Room @NotNull [] rooms) {
|
||||||
int y = 0;
|
int y = 0;
|
||||||
for (Room room : rooms) {
|
for (Room room : rooms) {
|
||||||
if (ZombiesUtilsConfig.isSlaShortened() && room.getActiveWindowCount() == 0) continue;
|
if (ZombiesUtils.getInstance().getConfig().isSlaShortened() && room.getActiveWindowCount() == 0) continue;
|
||||||
fontRenderer.drawStringWithShadow(
|
fontRenderer.drawStringWithShadow(
|
||||||
room.getSlaString(),
|
room.getSlaString(),
|
||||||
1,
|
1,
|
||||||
|
@ -100,7 +100,7 @@ public class RenderGameOverlayHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderSpawnTime(byte @NotNull [] waveTimes, short roundTicks) {
|
private void renderSpawnTime(byte @NotNull [] waveTimes, short roundTicks) {
|
||||||
if (Scoreboard.isNotZombies() || !ZombiesUtilsConfig.getSST()) return;
|
if (Scoreboard.isNotZombies() || !ZombiesUtils.getInstance().getConfig().getSST()) return;
|
||||||
|
|
||||||
final int length = waveTimes.length + 1;
|
final int length = waveTimes.length + 1;
|
||||||
int heightIndex = 0;
|
int heightIndex = 0;
|
||||||
|
@ -111,7 +111,7 @@ public class RenderGameOverlayHandler {
|
||||||
final short waveTicks = (short) ((waveTime * 20) + rl);
|
final short waveTicks = (short) ((waveTime * 20) + rl);
|
||||||
|
|
||||||
if (roundTicks > waveTicks) {
|
if (roundTicks > waveTicks) {
|
||||||
if (ZombiesUtilsConfig.isSpawntimeNotShortened()) clonedColor = 0x555555;
|
if (!ZombiesUtils.getInstance().getConfig().isSpawntimeShortened()) clonedColor = 0x555555;
|
||||||
else {
|
else {
|
||||||
heightIndex++;
|
heightIndex++;
|
||||||
continue;
|
continue;
|
||||||
|
@ -134,6 +134,7 @@ public class RenderGameOverlayHandler {
|
||||||
heightIndex++;
|
heightIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renderCPS() {
|
public void renderCPS() {
|
||||||
final String cps = String.format("%2d", getClicks());
|
final String cps = String.format("%2d", getClicks());
|
||||||
final ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
|
final ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
|
||||||
|
@ -150,18 +151,18 @@ public class RenderGameOverlayHandler {
|
||||||
|
|
||||||
public int getClicks() {
|
public int getClicks() {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (boolean tick : clicks) {
|
for (byte tick : clicks) {
|
||||||
if (tick) i++;
|
i += tick;
|
||||||
}
|
}
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addClick() {
|
public void addClick() {
|
||||||
clicks[clickPointer] = true;
|
clicks[clickPointer]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void tick() {
|
public void tick() {
|
||||||
clickPointer = (clickPointer + 1) % 20;
|
clickPointer = (clickPointer + 1) % 20;
|
||||||
clicks[clickPointer] = false;
|
clicks[clickPointer] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.github.stachelbeere1248.zombiesutils.timer;
|
package com.github.stachelbeere1248.zombiesutils.timer;
|
||||||
|
|
||||||
import com.github.stachelbeere1248.zombiesutils.config.ZombiesUtilsConfig;
|
import com.github.stachelbeere1248.zombiesutils.ZombiesUtils;
|
||||||
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;
|
||||||
|
@ -14,8 +14,7 @@ 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 {
|
||||||
@SuppressWarnings("OptionalGetWithoutIsPresent")
|
@SuppressWarnings("OptionalGetWithoutIsPresent") final CategoryFile categoryFile = category.getByGameMode(Timer.getInstance().get().getGameMode());
|
||||||
final CategoryFile categoryFile = category.getByGameMode(Timer.getInstance().get().getGameMode());
|
|
||||||
final short bestSegment = categoryFile.getBestSegment(round);
|
final short bestSegment = categoryFile.getBestSegment(round);
|
||||||
|
|
||||||
final String timeString = formattedTime(roundTime);
|
final String timeString = formattedTime(roundTime);
|
||||||
|
@ -26,16 +25,18 @@ public class RecordManager {
|
||||||
if (bestSegment == (short) 0) {
|
if (bestSegment == (short) 0) {
|
||||||
categoryFile.setBestSegment(round, roundTime);
|
categoryFile.setBestSegment(round, roundTime);
|
||||||
|
|
||||||
|
if (ZombiesUtils.getInstance().getConfig().getAnnouncePB())
|
||||||
segmentMessage += "\n§e§l***§6§l NEW BEST SEGMENT! §e§l***";
|
segmentMessage += "\n§e§l***§6§l NEW BEST SEGMENT! §e§l***";
|
||||||
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) {
|
||||||
|
if (ZombiesUtils.getInstance().getConfig().getAnnouncePB())
|
||||||
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);
|
||||||
}
|
}
|
||||||
deltaString = formattedDelta(roundTime, bestSegment);
|
deltaString = formattedDelta(roundTime, bestSegment);
|
||||||
segmentMessage += "\n§cRound " + round + "§e took §a" + timeString + " §9" + deltaString;
|
segmentMessage += "\n§cRound " + round + "§e took §a" + timeString + " §9" + deltaString;
|
||||||
if (ZombiesUtilsConfig.getCopyDelta()) deltaString = " (" + deltaString + ")";
|
if (ZombiesUtils.getInstance().getConfig().getCopyDelta()) deltaString = " (" + deltaString + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,8 +50,7 @@ public class RecordManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
||||||
@SuppressWarnings("OptionalGetWithoutIsPresent")
|
@SuppressWarnings("OptionalGetWithoutIsPresent") final CategoryFile categoryFile = category.getByGameMode(Timer.getInstance().get().getGameMode());
|
||||||
final CategoryFile categoryFile = category.getByGameMode(Timer.getInstance().get().getGameMode());
|
|
||||||
final int personalBest = categoryFile.getPersonalBest(round);
|
final int personalBest = categoryFile.getPersonalBest(round);
|
||||||
String deltaString = "";
|
String deltaString = "";
|
||||||
|
|
||||||
|
@ -60,16 +60,18 @@ public class RecordManager {
|
||||||
if (personalBest == 0) {
|
if (personalBest == 0) {
|
||||||
categoryFile.setPersonalBest(round, gameTime);
|
categoryFile.setPersonalBest(round, gameTime);
|
||||||
|
|
||||||
|
if (ZombiesUtils.getInstance().getConfig().getAnnouncePB())
|
||||||
bestMessage += "\n§e§l***§6§l NEW PERSONAL BEST! §e§l***";
|
bestMessage += "\n§e§l***§6§l NEW PERSONAL BEST! §e§l***";
|
||||||
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) {
|
||||||
|
if (ZombiesUtils.getInstance().getConfig().getAnnouncePB())
|
||||||
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);
|
deltaString = formattedDelta(gameTime, personalBest);
|
||||||
bestMessage += "\n§cRound " + round + "§e finished at §a" + timeString + " §9" + deltaString;
|
bestMessage += "\n§cRound " + round + "§e finished at §a" + timeString + " §9" + deltaString;
|
||||||
if (ZombiesUtilsConfig.getCopyDelta()) deltaString = " (" + deltaString + ")";
|
if (ZombiesUtils.getInstance().getConfig().getCopyDelta()) deltaString = " (" + deltaString + ")";
|
||||||
}
|
}
|
||||||
bestMessage += "\n" + bar;
|
bestMessage += "\n" + bar;
|
||||||
final ChatComponentText message = new ChatComponentText(bestMessage);
|
final ChatComponentText message = new ChatComponentText(bestMessage);
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
package com.github.stachelbeere1248.zombiesutils.timer;
|
package com.github.stachelbeere1248.zombiesutils.timer;
|
||||||
|
|
||||||
import com.github.stachelbeere1248.zombiesutils.ZombiesUtils;
|
import com.github.stachelbeere1248.zombiesutils.ZombiesUtils;
|
||||||
import com.github.stachelbeere1248.zombiesutils.config.ZombiesUtilsConfig;
|
|
||||||
import com.github.stachelbeere1248.zombiesutils.game.GameMode;
|
import com.github.stachelbeere1248.zombiesutils.game.GameMode;
|
||||||
import com.github.stachelbeere1248.zombiesutils.game.enums.Map;
|
|
||||||
import com.github.stachelbeere1248.zombiesutils.game.SLA;
|
import com.github.stachelbeere1248.zombiesutils.game.SLA;
|
||||||
|
import com.github.stachelbeere1248.zombiesutils.game.enums.Map;
|
||||||
import com.github.stachelbeere1248.zombiesutils.handlers.Round1Correction;
|
import com.github.stachelbeere1248.zombiesutils.handlers.Round1Correction;
|
||||||
import com.github.stachelbeere1248.zombiesutils.timer.recorder.Category;
|
import com.github.stachelbeere1248.zombiesutils.timer.recorder.Category;
|
||||||
import com.github.stachelbeere1248.zombiesutils.timer.recorder.files.GameFile;
|
import com.github.stachelbeere1248.zombiesutils.timer.recorder.files.GameFile;
|
||||||
|
@ -44,7 +43,7 @@ public class Timer {
|
||||||
|
|
||||||
this.gameMode = new GameMode(map);
|
this.gameMode = new GameMode(map);
|
||||||
this.round = round;
|
this.round = round;
|
||||||
if (ZombiesUtilsConfig.isSlaToggled()) SLA.instance = new SLA(map);
|
if (ZombiesUtils.getInstance().getConfig().isSlaToggled()) SLA.instance = new SLA(map);
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.register(new Round1Correction());
|
MinecraftForge.EVENT_BUS.register(new Round1Correction());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
package com.github.stachelbeere1248.zombiesutils.timer.recorder;
|
package com.github.stachelbeere1248.zombiesutils.timer.recorder;
|
||||||
|
|
||||||
import com.github.stachelbeere1248.zombiesutils.ZombiesUtils;
|
import com.github.stachelbeere1248.zombiesutils.ZombiesUtils;
|
||||||
import com.github.stachelbeere1248.zombiesutils.config.ZombiesUtilsConfig;
|
|
||||||
import com.github.stachelbeere1248.zombiesutils.game.enums.Difficulty;
|
|
||||||
import com.github.stachelbeere1248.zombiesutils.game.GameMode;
|
import com.github.stachelbeere1248.zombiesutils.game.GameMode;
|
||||||
|
import com.github.stachelbeere1248.zombiesutils.game.enums.Difficulty;
|
||||||
import com.github.stachelbeere1248.zombiesutils.game.enums.Map;
|
import com.github.stachelbeere1248.zombiesutils.game.enums.Map;
|
||||||
import com.github.stachelbeere1248.zombiesutils.timer.Timer;
|
import com.github.stachelbeere1248.zombiesutils.timer.Timer;
|
||||||
import com.github.stachelbeere1248.zombiesutils.timer.recorder.files.CategoryFile;
|
import com.github.stachelbeere1248.zombiesutils.timer.recorder.files.CategoryFile;
|
||||||
|
@ -12,7 +11,7 @@ import org.jetbrains.annotations.NotNull;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
public class Category {
|
public class Category {
|
||||||
private static String selectedCategory = ZombiesUtilsConfig.getDefaultCategory();
|
private static String selectedCategory = ZombiesUtils.getInstance().getConfig().getDefaultCategory();
|
||||||
public final CategoryFile[] categoryFiles = new CategoryFile[7];
|
public final CategoryFile[] categoryFiles = new CategoryFile[7];
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,8 @@ public class CategoryData implements ISplitsData {
|
||||||
Arrays.fill(personalBests, 0);
|
Arrays.fill(personalBests, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override @NotNull
|
@Override
|
||||||
|
@NotNull
|
||||||
public String toJSON() {
|
public String toJSON() {
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
return gson.toJson(this, CategoryData.class);
|
return gson.toJson(this, CategoryData.class);
|
||||||
|
|
|
@ -25,7 +25,8 @@ public class GameData implements ISplitsData {
|
||||||
Arrays.fill(segments, (short) 0);
|
Arrays.fill(segments, (short) 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override @NotNull
|
@Override
|
||||||
|
@NotNull
|
||||||
public String toJSON() {
|
public String toJSON() {
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
return gson.toJson(this.segments);
|
return gson.toJson(this.segments);
|
||||||
|
|
|
@ -24,6 +24,7 @@ public class GameFile extends SplitsFile {
|
||||||
this.data = new GameData(map);
|
this.data = new GameData(map);
|
||||||
FileManager.createDataFile(this, this.data);
|
FileManager.createDataFile(this, this.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static String formattedTime() {
|
private static String formattedTime() {
|
||||||
final LocalDateTime dateTime = LocalDateTime.now().truncatedTo(ChronoUnit.MINUTES);
|
final LocalDateTime dateTime = LocalDateTime.now().truncatedTo(ChronoUnit.MINUTES);
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.github.stachelbeere1248.zombiesutils.utils;
|
package com.github.stachelbeere1248.zombiesutils.utils;
|
||||||
|
|
||||||
import com.github.stachelbeere1248.zombiesutils.ZombiesUtils;
|
import com.github.stachelbeere1248.zombiesutils.ZombiesUtils;
|
||||||
import com.github.stachelbeere1248.zombiesutils.config.ZombiesUtilsConfig;
|
|
||||||
import com.github.stachelbeere1248.zombiesutils.game.enums.Map;
|
import com.github.stachelbeere1248.zombiesutils.game.enums.Map;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
@ -67,7 +66,7 @@ public class Scoreboard {
|
||||||
} catch (IndexOutOfBoundsException | NullPointerException ignored) {
|
} catch (IndexOutOfBoundsException | NullPointerException ignored) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
final Pattern ROUND_LINE_PATTERN = LanguageSupport.roundPattern(ZombiesUtilsConfig.getLanguage());
|
final Pattern ROUND_LINE_PATTERN = LanguageSupport.roundPattern(ZombiesUtils.getInstance().getConfig().getLanguage());
|
||||||
|
|
||||||
String string = ROUND_LINE_PATTERN.matcher(line).replaceAll("$1");
|
String string = ROUND_LINE_PATTERN.matcher(line).replaceAll("$1");
|
||||||
|
|
||||||
|
@ -105,7 +104,7 @@ public class Scoreboard {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final Pattern MAP_PATTERN = LanguageSupport.mapPattern(ZombiesUtilsConfig.getLanguage());
|
final Pattern MAP_PATTERN = LanguageSupport.mapPattern(ZombiesUtils.getInstance().getConfig().getLanguage());
|
||||||
String mapString = MAP_PATTERN.matcher(line).replaceAll("$1");
|
String mapString = MAP_PATTERN.matcher(line).replaceAll("$1");
|
||||||
switch (mapString) {
|
switch (mapString) {
|
||||||
case "Dead End":
|
case "Dead End":
|
||||||
|
|
Loading…
Add table
Reference in a new issue