2021-12-27 19:01:39 +00:00
|
|
|
/*
|
|
|
|
* 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
|
2021-12-27 19:14:32 +00:00
|
|
|
* he Free Software Foundation version 3.
|
2021-12-27 19:01:39 +00:00
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2021-10-23 00:03:15 +00:00
|
|
|
package net.tylermurphy.hideAndSeek.configuration;
|
2021-08-13 20:49:36 +00:00
|
|
|
|
|
|
|
import org.bukkit.util.Vector;
|
|
|
|
|
2021-10-21 00:14:01 +00:00
|
|
|
public class Config {
|
2021-10-29 03:09:28 +00:00
|
|
|
|
2021-10-31 15:25:27 +00:00
|
|
|
private static ConfigManager manager;
|
2021-08-18 23:21:59 +00:00
|
|
|
|
2021-08-26 13:38:12 +00:00
|
|
|
public static String
|
|
|
|
messagePrefix,
|
|
|
|
errorPrefix,
|
|
|
|
tauntPrefix,
|
|
|
|
worldborderPrefix,
|
|
|
|
abortPrefix,
|
|
|
|
gameoverPrefix,
|
2021-08-27 21:20:07 +00:00
|
|
|
warningPrefix,
|
2021-08-26 13:38:12 +00:00
|
|
|
spawnWorld,
|
2021-10-18 02:52:57 +00:00
|
|
|
exitWorld,
|
2021-12-20 22:24:43 +00:00
|
|
|
lobbyWorld,
|
|
|
|
local;
|
2021-08-18 23:21:59 +00:00
|
|
|
|
2021-10-18 02:52:57 +00:00
|
|
|
public static Vector
|
2021-08-26 13:38:12 +00:00
|
|
|
spawnPosition,
|
2021-10-11 21:06:21 +00:00
|
|
|
lobbyPosition,
|
2021-10-18 02:52:57 +00:00
|
|
|
exitPosition,
|
2021-08-26 13:38:12 +00:00
|
|
|
worldborderPosition;
|
2021-08-18 23:21:59 +00:00
|
|
|
|
2021-08-26 13:38:12 +00:00
|
|
|
public static boolean
|
|
|
|
nametagsVisible,
|
|
|
|
permissionsRequired,
|
2021-10-18 02:52:57 +00:00
|
|
|
announceMessagesToNonPlayers,
|
2021-10-29 23:57:40 +00:00
|
|
|
worldborderEnabled,
|
|
|
|
tauntEnabled,
|
|
|
|
tauntCountdown,
|
|
|
|
tauntLast,
|
|
|
|
glowEnabled,
|
2021-10-31 15:25:27 +00:00
|
|
|
glowStackable,
|
|
|
|
pvpEnabled,
|
|
|
|
autoJoin,
|
2021-12-25 14:16:03 +00:00
|
|
|
teleportToExit,
|
|
|
|
lobbyCountdownEnabled;
|
2021-08-25 03:43:01 +00:00
|
|
|
|
2021-08-26 13:38:12 +00:00
|
|
|
public static int
|
|
|
|
minPlayers,
|
|
|
|
worldborderSize,
|
|
|
|
worldborderDelay,
|
2021-10-18 02:52:57 +00:00
|
|
|
currentWorldborderSize,
|
2021-10-27 23:57:44 +00:00
|
|
|
gameLength,
|
|
|
|
saveMinX,
|
|
|
|
saveMinZ,
|
|
|
|
saveMaxX,
|
2021-10-29 23:57:40 +00:00
|
|
|
saveMaxZ,
|
|
|
|
tauntDelay,
|
2021-12-25 14:16:03 +00:00
|
|
|
glowLength,
|
|
|
|
countdown,
|
|
|
|
changeCountdown,
|
|
|
|
lobbyMin,
|
|
|
|
lobbyMax;
|
2021-08-13 20:49:36 +00:00
|
|
|
|
2021-08-25 03:43:01 +00:00
|
|
|
public static void loadConfig() {
|
2021-10-29 03:09:28 +00:00
|
|
|
|
|
|
|
manager = new ConfigManager("config.yml");
|
2021-10-29 23:57:40 +00:00
|
|
|
manager.saveConfig();
|
2021-10-29 03:09:28 +00:00
|
|
|
|
2021-08-26 13:38:12 +00:00
|
|
|
//Spawn
|
2021-08-25 03:43:01 +00:00
|
|
|
spawnPosition = new Vector(
|
2021-10-29 03:09:28 +00:00
|
|
|
manager.getDouble("spawns.game.x"),
|
|
|
|
Math.max(0, Math.min(255, manager.getDouble("spawns.game.y"))),
|
|
|
|
manager.getDouble("spawns.game.z")
|
|
|
|
);
|
|
|
|
spawnWorld = manager.getString("spawns.game.world");
|
|
|
|
|
2021-10-11 21:06:21 +00:00
|
|
|
///Lobby
|
|
|
|
lobbyPosition = new Vector(
|
2021-10-29 03:09:28 +00:00
|
|
|
manager.getDouble("spawns.lobby.x"),
|
|
|
|
Math.max(0, Math.min(255, manager.getDouble("spawns.lobby.y"))),
|
|
|
|
manager.getDouble("spawns.lobby.z")
|
|
|
|
);
|
|
|
|
lobbyWorld = manager.getString("spawns.lobby.world");
|
|
|
|
|
|
|
|
announceMessagesToNonPlayers = manager.getBoolean("announceMessagesToNonPlayers");
|
|
|
|
|
2021-10-18 02:52:57 +00:00
|
|
|
exitPosition = new Vector(
|
2021-10-29 03:09:28 +00:00
|
|
|
manager.getDouble("spawns.exit.x"),
|
|
|
|
Math.max(0, Math.min(255, manager.getDouble("spawns.exit.y"))),
|
|
|
|
manager.getDouble("spawns.exit.z")
|
|
|
|
);
|
|
|
|
exitWorld = manager.getString("spawns.exit.world");
|
|
|
|
|
2021-08-26 13:38:12 +00:00
|
|
|
//World border
|
2021-08-25 03:43:01 +00:00
|
|
|
worldborderPosition = new Vector(
|
2021-10-29 03:09:28 +00:00
|
|
|
manager.getInt("worldBorder.x"),
|
|
|
|
0,
|
|
|
|
manager.getInt("worldBorder.z")
|
|
|
|
);
|
|
|
|
worldborderSize = Math.max(100, manager.getInt("worldBorder.size"));
|
|
|
|
worldborderDelay = Math.max(1, manager.getInt("worldBorder.delay"));
|
|
|
|
worldborderEnabled = manager.getBoolean("worldBorder.enabled");
|
|
|
|
|
2021-08-26 13:38:12 +00:00
|
|
|
//Prefix
|
2021-08-25 04:02:24 +00:00
|
|
|
char SYMBOLE = '\u00A7';
|
2021-10-29 23:57:40 +00:00
|
|
|
String SYMBOLE_STRING = String.valueOf(SYMBOLE);
|
2021-10-29 03:09:28 +00:00
|
|
|
|
|
|
|
messagePrefix = manager.getString("prefix.default").replace("&", SYMBOLE_STRING);
|
|
|
|
errorPrefix = manager.getString("prefix.error").replace("&", SYMBOLE_STRING);
|
|
|
|
tauntPrefix = manager.getString("prefix.taunt").replace("&", SYMBOLE_STRING);
|
|
|
|
worldborderPrefix = manager.getString("prefix.border").replace("&", SYMBOLE_STRING);
|
|
|
|
abortPrefix = manager.getString("prefix.abort").replace("&", SYMBOLE_STRING);
|
|
|
|
gameoverPrefix = manager.getString("prefix.gameover").replace("&", SYMBOLE_STRING);
|
|
|
|
warningPrefix = manager.getString("prefix.warning").replace("&", SYMBOLE_STRING);
|
|
|
|
|
2021-10-27 23:57:44 +00:00
|
|
|
//Map Bounds
|
2021-10-29 03:09:28 +00:00
|
|
|
saveMinX = manager.getInt("bounds.min.x");
|
|
|
|
saveMinZ = manager.getInt("bounds.min.z");
|
|
|
|
saveMaxX = manager.getInt("bounds.max.x");
|
|
|
|
saveMaxZ = manager.getInt("bounds.max.z");
|
|
|
|
|
2021-10-29 23:57:40 +00:00
|
|
|
//Taunt
|
|
|
|
tauntEnabled = manager.getBoolean("taunt.enabled");
|
|
|
|
tauntCountdown = manager.getBoolean("taunt.showCountdown");
|
|
|
|
tauntDelay = Math.max(60,manager.getInt("taunt.delay"));
|
|
|
|
tauntLast = manager.getBoolean("taunt.whenLastPerson");
|
|
|
|
|
|
|
|
//Glow
|
|
|
|
glowLength = Math.max(1,manager.getInt("glow.time"));
|
|
|
|
glowStackable = manager.getBoolean("glow.stackable");
|
|
|
|
glowEnabled = manager.getBoolean("glow.enabled");
|
|
|
|
|
2021-12-25 14:16:03 +00:00
|
|
|
//Lobby
|
|
|
|
minPlayers = Math.max(2, manager.getInt("minPlayers"));
|
|
|
|
countdown = Math.max(10,manager.getInt("lobby.countdown"));
|
|
|
|
changeCountdown = Math.max(minPlayers,manager.getInt("lobby.changeCountdown"));
|
|
|
|
lobbyMin = Math.max(minPlayers,manager.getInt("lobby.min"));
|
|
|
|
lobbyMax = manager.getInt("lobby.max");
|
|
|
|
lobbyCountdownEnabled = manager.getBoolean("lobby.enabled");
|
|
|
|
|
2021-08-26 13:38:12 +00:00
|
|
|
//Other
|
2021-10-29 03:09:28 +00:00
|
|
|
nametagsVisible = manager.getBoolean("nametagsVisible");
|
|
|
|
permissionsRequired = manager.getBoolean("permissionsRequired");
|
|
|
|
gameLength = manager.getInt("gameLength");
|
2021-10-31 15:25:27 +00:00
|
|
|
pvpEnabled = manager.getBoolean("pvp");
|
|
|
|
autoJoin = manager.getBoolean("autoJoin");
|
|
|
|
teleportToExit = manager.getBoolean("teleportToExit");
|
2021-12-20 22:24:43 +00:00
|
|
|
local = manager.getString("local");
|
2021-08-25 03:43:01 +00:00
|
|
|
}
|
|
|
|
|
2021-10-27 23:57:44 +00:00
|
|
|
public static void addToConfig(String path, Object value) {
|
2021-10-29 03:09:28 +00:00
|
|
|
manager.set(path, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void saveConfig() {
|
|
|
|
manager.saveConfig();
|
2021-10-27 23:57:44 +00:00
|
|
|
}
|
|
|
|
|
2021-08-18 23:21:59 +00:00
|
|
|
}
|