summaryrefslogtreewikicommitdiff
path: root/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java')
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java178
1 files changed, 22 insertions, 156 deletions
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java
index a71369f..5881d19 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java
@@ -1,22 +1,3 @@
-/*
- * This file is part of Kenshins Hide and Seek
- *
- * Copyright (c) 2021 Tyler Murphy.
- *
- * Kenshins Hide and Seek free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * he Free Software Foundation version 3.
- *
- * Kenshins Hide and Seek is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
package net.tylermurphy.hideAndSeek.configuration;
import com.cryptomorin.xseries.XItemStack;
@@ -24,16 +5,15 @@ import com.cryptomorin.xseries.XMaterial;
import com.cryptomorin.xseries.XSound;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.game.util.CountdownDisplay;
+import net.tylermurphy.hideAndSeek.util.Location;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.inventory.ItemStack;
-import org.bukkit.util.Vector;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.Optional;
@@ -49,10 +29,6 @@ public class Config {
abortPrefix,
gameOverPrefix,
warningPrefix,
- spawnWorld,
- seekerLobbyWorld,
- exitWorld,
- lobbyWorld,
locale,
leaveServer,
placeholderError,
@@ -64,18 +40,10 @@ public class Config {
databasePass,
databaseName;
- public static Vector
- spawnPosition,
- lobbyPosition,
- exitPosition,
- seekerLobbyPosition,
- worldBorderPosition;
-
public static boolean
nameTagsVisible,
permissionsRequired,
announceMessagesToNonPlayers,
- worldBorderEnabled,
tauntEnabled,
tauntCountdown,
tauntLast,
@@ -93,20 +61,11 @@ public class Config {
mapSaveEnabled,
allowNaturalCauses,
saveInventory,
- blockhuntEnabled,
delayedRespawn;
public static int
minPlayers,
- worldBorderSize,
- worldBorderDelay,
- currentWorldborderSize,
- worldBorderChange,
gameLength,
- saveMinX,
- saveMinZ,
- saveMaxX,
- saveMaxZ,
tauntDelay,
glowLength,
countdown,
@@ -120,7 +79,6 @@ public class Config {
lobbyItemStartPosition,
flightToggleItemPosition,
teleportItemPosition,
- solidifyTime,
delayedRespawnDelay;
public static float
@@ -132,27 +90,6 @@ public class Config {
blockedCommands,
blockedInteracts;
- public static List<Material>
- blockhuntBlocks;
-
- public static String
- LOBBY_TITLE,
- GAME_TITLE,
- COUNTDOWN_WAITING,
- COUNTDOWN_COUNTING,
- COUNTDOWN_ADMINSTART,
- TAUNT_COUNTING,
- TAUNT_ACTIVE,
- TAUNT_EXPIRED,
- GLOW_ACTIVE,
- GLOW_INACTIVE,
- BORDER_COUNTING,
- BORDER_DECREASING;
-
- public static List<String>
- LOBBY_CONTENTS,
- GAME_CONTENTS;
-
public static ItemStack
lobbyLeaveItem,
lobbyStartItem,
@@ -166,74 +103,36 @@ public class Config {
public static CountdownDisplay
countdownDisplay;
+
+ public static Location
+ exitPosition;
public static void loadConfig() {
config = ConfigManager.create("config.yml");
config.saveConfig();
- ConfigManager leaderboard = ConfigManager.create("leaderboard.yml");
-
- //Spawn
- spawnPosition = new Vector(
- config.getDouble("spawns.game.x"),
- Math.max(Main.getInstance().supports(18) ? -64 : 0, Math.min(255, config.getDouble("spawns.game.y"))),
- config.getDouble("spawns.game.z")
- );
- spawnWorld = config.getString("spawns.game.world");
-
- ///Lobby
- lobbyPosition = new Vector(
- config.getDouble("spawns.lobby.x"),
- Math.max(Main.getInstance().supports(18) ? -64 : 0, Math.min(255, config.getDouble("spawns.lobby.y"))),
- config.getDouble("spawns.lobby.z")
- );
- lobbyWorld = config.getString("spawns.lobby.world");
-
- ///Seeker Lobby
- seekerLobbyPosition = new Vector(
- config.getDouble("spawns.seeker.x"),
- Math.max(Main.getInstance().supports(18) ? -64 : 0, Math.min(255, config.getDouble("spawns.seeker.y"))),
- config.getDouble("spawns.seeker.z")
- );
- seekerLobbyWorld = config.getString("spawns.seeker.world");
announceMessagesToNonPlayers = config.getBoolean("announceMessagesToNonPlayers");
- exitPosition = new Vector(
- config.getDouble("spawns.exit.x"),
- Math.max(Main.getInstance().supports(18) ? -64 : 0, Math.min(255, config.getDouble("spawns.exit.y"))),
- config.getDouble("spawns.exit.z")
- );
- exitWorld = config.getString("spawns.exit.world");
-
- //World border
- worldBorderPosition = new Vector(
- config.getInt("worldBorder.x"),
- 0,
- config.getInt("worldBorder.z")
- );
- worldBorderSize = Math.max(100, config.getInt("worldBorder.size"));
- worldBorderDelay = Math.max(1, config.getInt("worldBorder.delay"));
- worldBorderEnabled = config.getBoolean("worldBorder.enabled");
- worldBorderChange = config.getInt("worldBorder.moveAmount");
-
//Prefix
- char SYMBOLE = '\u00A7';
- String SYMBOLE_STRING = String.valueOf(SYMBOLE);
+ char SYMBOL = '\u00A7';
+ String SYMBOL_STRING = String.valueOf(SYMBOL);
- messagePrefix = config.getString("prefix.default").replace("&", SYMBOLE_STRING);
- errorPrefix = config.getString("prefix.error").replace("&", SYMBOLE_STRING);
- tauntPrefix = config.getString("prefix.taunt").replace("&", SYMBOLE_STRING);
- worldBorderPrefix = config.getString("prefix.border").replace("&", SYMBOLE_STRING);
- abortPrefix = config.getString("prefix.abort").replace("&", SYMBOLE_STRING);
- gameOverPrefix = config.getString("prefix.gameover").replace("&", SYMBOLE_STRING);
- warningPrefix = config.getString("prefix.warning").replace("&", SYMBOLE_STRING);
+ messagePrefix = config.getString("prefix.default").replace("&", SYMBOL_STRING);
+ errorPrefix = config.getString("prefix.error").replace("&", SYMBOL_STRING);
+ tauntPrefix = config.getString("prefix.taunt").replace("&", SYMBOL_STRING);
+ worldBorderPrefix = config.getString("prefix.border").replace("&", SYMBOL_STRING);
+ abortPrefix = config.getString("prefix.abort").replace("&", SYMBOL_STRING);
+ gameOverPrefix = config.getString("prefix.gameover").replace("&", SYMBOL_STRING);
+ warningPrefix = config.getString("prefix.warning").replace("&", SYMBOL_STRING);
- //Map Bounds
- saveMinX = config.getInt("bounds.min.x");
- saveMinZ = config.getInt("bounds.min.z");
- saveMaxX = config.getInt("bounds.max.x");
- saveMaxZ = config.getInt("bounds.max.z");
+ // Locations
+ exitPosition = new Location(
+ config.getString("exit.world"),
+ config.getInt("exit.x"),
+ config.getInt("exit.y"),
+ config.getInt("exit.z")
+ );
mapSaveEnabled = config.getBoolean("mapSaveEnabled");
//Taunt
@@ -289,8 +188,7 @@ public class Config {
try {
countdownDisplay = CountdownDisplay.valueOf(config.getString("hideCountdownDisplay"));
} catch (IllegalArgumentException e) {
- countdownDisplay = CountdownDisplay.CHAT;
- Main.getInstance().getLogger().warning("hideCountdownDisplay: "+config.getString("hideCountdownDisplay")+" is not a valid configuration option!");
+ throw new RuntimeException("hideCountdownDisplay: "+config.getString("hideCountdownDisplay")+", is not a valid configuration option!");
}
blockedInteracts = new ArrayList<>();
List<String> tempInteracts = config.getStringList("blockedInteracts");
@@ -305,37 +203,6 @@ public class Config {
}
bungeeLeave = config.getString("leaveType") == null || config.getString("leaveType").equalsIgnoreCase("proxy");
leaveServer = config.getString("leaveServer");
- blockhuntEnabled = config.getBoolean("blockhunt.enabled") && Main.getInstance().supports(9);
- blockhuntBlocks = new ArrayList<>();
- tempInteracts = config.getStringList("blockhunt.blocks");
- for(String id : tempInteracts) {
- Optional<XMaterial> optional_mat = XMaterial.matchXMaterial(id);
- if (optional_mat.isPresent()) {
- Material mat = optional_mat.get().parseMaterial();
- if (mat != null) {
- blockhuntBlocks.add(mat);
- }
- }
- }
- solidifyTime = Math.max(20,config.getInt("blockhunt.solidifyTime"));
-
- //Leaderboard
- LOBBY_TITLE = leaderboard.getString("lobby.title");
- GAME_TITLE = leaderboard.getString("game.title");
- LOBBY_CONTENTS = leaderboard.getStringList("lobby.content");
- Collections.reverse(LOBBY_CONTENTS);
- GAME_CONTENTS = leaderboard.getStringList("game.content");
- Collections.reverse(GAME_CONTENTS);
- COUNTDOWN_WAITING = leaderboard.getString("countdown.waiting");
- COUNTDOWN_COUNTING = leaderboard.getString("countdown.counting");
- COUNTDOWN_ADMINSTART = leaderboard.getString("countdown.adminStart");
- TAUNT_COUNTING = leaderboard.getString("taunt.counting");
- TAUNT_ACTIVE = leaderboard.getString("taunt.active");
- TAUNT_EXPIRED = leaderboard.getString("taunt.expired");
- GLOW_ACTIVE = leaderboard.getString("glow.active");
- GLOW_INACTIVE = leaderboard.getString("glow.inactive");
- BORDER_COUNTING = leaderboard.getString("border.counting");
- BORDER_DECREASING = leaderboard.getString("border.decreasing");
//Lobby Items
if (config.getBoolean("lobbyItems.leave.enabled")) {
@@ -364,8 +231,7 @@ public class Config {
databaseType = config.getString("databaseType").toUpperCase();
if(!databaseType.equals("SQLITE") && !databaseType.equals("MYSQL")){
- Main.getInstance().getLogger().warning("databaseType: "+databaseType+" is not a valid configuration option!");
- databaseType = "SQLITE";
+ throw new RuntimeException("databaseType: "+databaseType+" is not a valid configuration option!");
}
delayedRespawn = config.getBoolean("delayedRespawn.enabled");