cleaned up category code
This commit is contained in:
parent
8e5d2881a3
commit
a53195bedf
5 changed files with 46 additions and 52 deletions
|
@ -2,8 +2,8 @@ package com.github.stachelbeere1248.zombiesutils;
|
||||||
|
|
||||||
import com.github.stachelbeere1248.zombiesutils.commands.CategoryCommand;
|
import com.github.stachelbeere1248.zombiesutils.commands.CategoryCommand;
|
||||||
import com.github.stachelbeere1248.zombiesutils.commands.SlaCommand;
|
import com.github.stachelbeere1248.zombiesutils.commands.SlaCommand;
|
||||||
import com.github.stachelbeere1248.zombiesutils.config.ZombiesUtilsConfig;
|
|
||||||
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.handlers.ChatHandler;
|
import com.github.stachelbeere1248.zombiesutils.handlers.ChatHandler;
|
||||||
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;
|
||||||
|
|
|
@ -10,6 +10,7 @@ public class ZombiesUtilsConfig {
|
||||||
public static Configuration config;
|
public static Configuration config;
|
||||||
private static boolean slaToggle;
|
private static boolean slaToggle;
|
||||||
private static String chatMacro;
|
private static String chatMacro;
|
||||||
|
private static String defaultCategory;
|
||||||
public static void load() {
|
public static void load() {
|
||||||
ZombiesUtils.getInstance().getLogger().debug("Loading config...");
|
ZombiesUtils.getInstance().getLogger().debug("Loading config...");
|
||||||
config.load();
|
config.load();
|
||||||
|
@ -26,7 +27,13 @@ public class ZombiesUtilsConfig {
|
||||||
Configuration.CATEGORY_GENERAL,
|
Configuration.CATEGORY_GENERAL,
|
||||||
"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.getString(
|
||||||
|
"Default Category",
|
||||||
|
Configuration.CATEGORY_GENERAL,
|
||||||
|
"general",
|
||||||
|
"name of the category to be selected unless specified using /runCategory"
|
||||||
|
);
|
||||||
|
|
||||||
ZombiesUtils.getInstance().getLogger().debug("Saving Config...");
|
ZombiesUtils.getInstance().getLogger().debug("Saving Config...");
|
||||||
config.save();
|
config.save();
|
||||||
|
@ -45,4 +52,7 @@ public class ZombiesUtilsConfig {
|
||||||
public static String getChatMacro() {
|
public static String getChatMacro() {
|
||||||
return chatMacro;
|
return chatMacro;
|
||||||
}
|
}
|
||||||
|
public static String getDefaultCategory() {
|
||||||
|
return defaultCategory;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,27 +4,17 @@ import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@SuppressWarnings("DuplicatedCode")
|
@SuppressWarnings("DuplicatedCode")
|
||||||
public class GameMode {
|
public class GameMode {
|
||||||
private static GameMode currentGameMode = null;
|
public 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);
|
|
||||||
public static final GameMode BAD_BLOOD_NORMAL = new GameMode(Map.BAD_BLOOD), BAD_BLOOD_HARD = new GameMode(Map.BAD_BLOOD, Difficulty.HARD), BAD_BLOOD_RIP = new GameMode(Map.BAD_BLOOD, Difficulty.RIP);
|
|
||||||
public static final GameMode ALIEN_ARCADIUM = new GameMode(Map.ALIEN_ARCADIUM);
|
|
||||||
private final Map map;
|
private final Map map;
|
||||||
private final Difficulty difficulty;
|
private Difficulty difficulty;
|
||||||
|
|
||||||
private GameMode (@NotNull Map map, @NotNull Difficulty difficulty) {
|
public GameMode(@NotNull Map map) {
|
||||||
this.map = map;
|
|
||||||
this.difficulty = difficulty;
|
|
||||||
}
|
|
||||||
private GameMode(@NotNull Map map) {
|
|
||||||
this.map = map;
|
this.map = map;
|
||||||
this.difficulty = Difficulty.NORMAL;
|
this.difficulty = Difficulty.NORMAL;
|
||||||
}
|
}
|
||||||
public static void create(@NotNull Map map) {
|
public GameMode(@NotNull Map map, @NotNull Difficulty difficulty) {
|
||||||
switch (map) {
|
this.map = map;
|
||||||
case DEAD_END: currentGameMode = DEAD_END_NORMAL; break;
|
this.difficulty = difficulty;
|
||||||
case BAD_BLOOD: currentGameMode = BAD_BLOOD_NORMAL; break;
|
|
||||||
case ALIEN_ARCADIUM: currentGameMode = ALIEN_ARCADIUM; break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
public Map getMap() {
|
public Map getMap() {
|
||||||
return map;
|
return map;
|
||||||
|
@ -34,21 +24,11 @@ public class GameMode {
|
||||||
}
|
}
|
||||||
public void changeDifficulty(@NotNull Difficulty difficulty) {
|
public void changeDifficulty(@NotNull Difficulty difficulty) {
|
||||||
switch (map) {
|
switch (map) {
|
||||||
|
case DEAD_END: case BAD_BLOOD:
|
||||||
|
this.difficulty = difficulty;
|
||||||
|
break;
|
||||||
case ALIEN_ARCADIUM:
|
case ALIEN_ARCADIUM:
|
||||||
throw new RuntimeException("Achievement Get: Alien Arcadium Hard/RIP" + Map.ALIEN_ARCADIUM);
|
throw new RuntimeException("Achievement Get: Alien Arcadium Hard/RIP" + Map.ALIEN_ARCADIUM);
|
||||||
case DEAD_END:
|
|
||||||
switch (difficulty) {
|
|
||||||
case NORMAL: currentGameMode = DEAD_END_NORMAL; break;
|
|
||||||
case HARD: currentGameMode = DEAD_END_HARD; break;
|
|
||||||
case RIP: currentGameMode = DEAD_END_RIP; break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case BAD_BLOOD:
|
|
||||||
switch (difficulty) {
|
|
||||||
case NORMAL: currentGameMode = BAD_BLOOD_NORMAL; break;
|
|
||||||
case HARD: currentGameMode = BAD_BLOOD_HARD; break;
|
|
||||||
case RIP: currentGameMode = BAD_BLOOD_RIP; break;
|
|
||||||
} break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static GameMode getCurrentGameMode() {
|
public static GameMode getCurrentGameMode() {
|
||||||
|
@ -62,7 +42,7 @@ public class GameMode {
|
||||||
currentGameMode = null;
|
currentGameMode = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean equals(@NotNull GameMode gameMode) {
|
public boolean is(Map map, Difficulty difficulty) {
|
||||||
return (this.getDifficulty() == gameMode.getDifficulty() && this.getMap() == gameMode.getMap());
|
return this.getDifficulty() == difficulty && this.getMap() == map;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class Timer {
|
||||||
else throw new RuntimeException("invalid servernumber");
|
else throw new RuntimeException("invalid servernumber");
|
||||||
|
|
||||||
this.category = new Category();
|
this.category = new Category();
|
||||||
GameMode.create(map);
|
GameMode.currentGameMode = new GameMode(map);
|
||||||
if (ZombiesUtilsConfig.isSlaToggled()) SLA.instance = new SLA(map);
|
if (ZombiesUtilsConfig.isSlaToggled()) SLA.instance = new SLA(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,45 +1,49 @@
|
||||||
package com.github.stachelbeere1248.zombiesutils.timer.recorder;
|
package com.github.stachelbeere1248.zombiesutils.timer.recorder;
|
||||||
|
|
||||||
|
import com.github.stachelbeere1248.zombiesutils.config.ZombiesUtilsConfig;
|
||||||
|
import com.github.stachelbeere1248.zombiesutils.game.Difficulty;
|
||||||
import com.github.stachelbeere1248.zombiesutils.game.GameMode;
|
import com.github.stachelbeere1248.zombiesutils.game.GameMode;
|
||||||
|
import com.github.stachelbeere1248.zombiesutils.game.Map;
|
||||||
import com.github.stachelbeere1248.zombiesutils.timer.Timer;
|
import com.github.stachelbeere1248.zombiesutils.timer.Timer;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
public class Category {
|
public class Category {
|
||||||
private static String selectedCategory = "general"; // read from config ?
|
private static String selectedCategory = ZombiesUtilsConfig.getDefaultCategory();
|
||||||
public final TimesFile[] timesFiles = new TimesFile[7];
|
public final TimesFile[] timesFiles = new TimesFile[7];
|
||||||
private final String name;
|
private final String name;
|
||||||
public Category() {
|
public Category() {
|
||||||
timesFiles[0] = new TimesFile(selectedCategory, GameMode.DEAD_END_NORMAL);
|
timesFiles[0] = new TimesFile(selectedCategory, new GameMode(Map.DEAD_END));
|
||||||
timesFiles[1] = new TimesFile(selectedCategory, GameMode.DEAD_END_HARD);
|
timesFiles[1] = new TimesFile(selectedCategory, new GameMode(Map.DEAD_END, Difficulty.HARD));
|
||||||
timesFiles[2] = new TimesFile(selectedCategory, GameMode.DEAD_END_RIP);
|
timesFiles[2] = new TimesFile(selectedCategory, new GameMode(Map.DEAD_END, Difficulty.RIP));
|
||||||
|
|
||||||
timesFiles[3] = new TimesFile(selectedCategory, GameMode.BAD_BLOOD_NORMAL);
|
timesFiles[3] = new TimesFile(selectedCategory, new GameMode(Map.BAD_BLOOD));
|
||||||
timesFiles[4] = new TimesFile(selectedCategory, GameMode.BAD_BLOOD_HARD);
|
timesFiles[4] = new TimesFile(selectedCategory, new GameMode(Map.BAD_BLOOD, Difficulty.HARD));
|
||||||
timesFiles[5] = new TimesFile(selectedCategory, GameMode.BAD_BLOOD_RIP);
|
timesFiles[5] = new TimesFile(selectedCategory, new GameMode(Map.BAD_BLOOD, Difficulty.RIP));
|
||||||
|
|
||||||
timesFiles[6] = new TimesFile(selectedCategory, GameMode.ALIEN_ARCADIUM);
|
timesFiles[6] = new TimesFile(selectedCategory, new GameMode(Map.ALIEN_ARCADIUM));
|
||||||
name = selectedCategory;
|
name = selectedCategory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public TimesFile getByGameMode(@NotNull GameMode gameMode) {
|
public TimesFile getByGameMode(@NotNull GameMode gameMode) {
|
||||||
if (gameMode.equals(GameMode.DEAD_END_NORMAL)) return timesFiles[0];
|
if (gameMode.is(Map.DEAD_END, Difficulty.NORMAL)) return timesFiles[0];
|
||||||
if (gameMode.equals(GameMode.DEAD_END_HARD)) return timesFiles[1];
|
else if (gameMode.is(Map.BAD_BLOOD, Difficulty.NORMAL)) return timesFiles[3];
|
||||||
if (gameMode.equals(GameMode.DEAD_END_RIP)) return timesFiles[2];
|
else if (gameMode.is(Map.ALIEN_ARCADIUM, Difficulty.NORMAL)) return timesFiles[6];
|
||||||
if (gameMode.equals(GameMode.BAD_BLOOD_NORMAL)) return timesFiles[3];
|
|
||||||
if (gameMode.equals(GameMode.BAD_BLOOD_HARD)) return timesFiles[4];
|
else if (gameMode.is(Map.DEAD_END, Difficulty.HARD)) return timesFiles[1];
|
||||||
if (gameMode.equals(GameMode.BAD_BLOOD_RIP)) return timesFiles[5];
|
else if (gameMode.is(Map.DEAD_END, Difficulty.RIP)) return timesFiles[2];
|
||||||
if (gameMode.equals(GameMode.ALIEN_ARCADIUM)) return timesFiles[6];
|
|
||||||
throw new IllegalStateException("Unexpected value: " + gameMode);
|
else if (gameMode.is(Map.BAD_BLOOD, Difficulty.HARD)) return timesFiles[4];
|
||||||
|
else if (gameMode.is(Map.BAD_BLOOD, Difficulty.RIP)) return timesFiles[5];
|
||||||
|
else throw new IllegalStateException("Unexpected value: " + gameMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setSelectedCategory(String selectedCategory) {
|
public static void setSelectedCategory(String selectedCategory) {
|
||||||
Category.selectedCategory = selectedCategory;
|
Category.selectedCategory = selectedCategory;
|
||||||
if (!Timer.getInstance().isPresent()) return;
|
Timer.getInstance().ifPresent(timer -> timer.setCategory(new Category()));
|
||||||
Timer.getInstance().get().category = new Category();
|
|
||||||
}
|
}
|
||||||
public static String[] getCategories() {
|
public static String[] getCategories() {
|
||||||
File dir = new File("zombies");
|
File dir = new File("zombies");
|
||||||
|
|
Loading…
Add table
Reference in a new issue