2021-10-23 00:03:15 +00:00
|
|
|
package net.tylermurphy.hideAndSeek.configuration;
|
2021-08-13 20:49:36 +00:00
|
|
|
|
|
|
|
import java.util.Map;
|
2021-08-25 03:43:01 +00:00
|
|
|
import java.util.Map.Entry;
|
2021-08-13 20:49:36 +00:00
|
|
|
|
2021-08-25 03:43:01 +00:00
|
|
|
import org.bukkit.configuration.ConfigurationSection;
|
2021-08-13 20:49:36 +00:00
|
|
|
import org.bukkit.configuration.file.FileConfiguration;
|
|
|
|
import org.bukkit.util.Vector;
|
|
|
|
|
2021-10-23 00:03:15 +00:00
|
|
|
import net.tylermurphy.hideAndSeek.Main;
|
|
|
|
|
2021-10-21 00:14:01 +00:00
|
|
|
public class Config {
|
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-10-21 00:14:01 +00:00
|
|
|
lobbyWorld;
|
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-21 00:14:01 +00:00
|
|
|
worldborderEnabled;
|
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,
|
|
|
|
saveMaxZ;
|
2021-08-13 20:49:36 +00:00
|
|
|
|
|
|
|
public static FileConfiguration getConfig() {
|
|
|
|
return Main.plugin.getConfig();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void saveConfig() {
|
|
|
|
Main.plugin.saveConfig();
|
|
|
|
}
|
|
|
|
|
2021-08-25 03:43:01 +00:00
|
|
|
public static void loadConfig() {
|
|
|
|
|
|
|
|
Main.plugin.reloadConfig();
|
|
|
|
|
2021-08-26 13:38:12 +00:00
|
|
|
//Spawn
|
2021-08-25 03:43:01 +00:00
|
|
|
spawnPosition = new Vector(
|
2021-10-18 02:52:57 +00:00
|
|
|
getConfig().getDouble("spawns.game.x"),
|
|
|
|
Math.max(0,Math.min(255,getConfig().getDouble("spawns.game.y"))),
|
|
|
|
getConfig().getDouble("spawns.game.z")
|
2021-08-25 03:43:01 +00:00
|
|
|
);
|
2021-10-18 02:52:57 +00:00
|
|
|
spawnWorld = getConfig().getString("spawns.game.world");
|
2021-08-25 03:43:01 +00:00
|
|
|
|
2021-10-11 21:06:21 +00:00
|
|
|
///Lobby
|
|
|
|
lobbyPosition = new Vector(
|
2021-10-18 02:52:57 +00:00
|
|
|
getConfig().getDouble("spawns.lobby.x"),
|
|
|
|
Math.max(0,Math.min(255,getConfig().getDouble("spawns.lobby.y"))),
|
|
|
|
getConfig().getDouble("spawns.lobby.z")
|
|
|
|
);
|
|
|
|
lobbyWorld = getConfig().getString("spawns.lobby.world");
|
|
|
|
|
|
|
|
announceMessagesToNonPlayers = getConfig().getBoolean("announceMessagesToNonPlayers");
|
|
|
|
|
|
|
|
exitPosition = new Vector(
|
|
|
|
getConfig().getDouble("spawns.exit.x"),
|
|
|
|
Math.max(0,Math.min(255,getConfig().getDouble("spawns.exit.y"))),
|
|
|
|
getConfig().getDouble("spawns.exit.z")
|
2021-10-11 21:06:21 +00:00
|
|
|
);
|
2021-10-18 02:52:57 +00:00
|
|
|
exitWorld = getConfig().getString("spawns.exit.world");
|
2021-10-11 21:06:21 +00:00
|
|
|
|
2021-08-26 13:38:12 +00:00
|
|
|
//World border
|
2021-08-25 03:43:01 +00:00
|
|
|
worldborderPosition = new Vector(
|
|
|
|
getConfig().getInt("worldBorder.x"),
|
|
|
|
0,
|
|
|
|
getConfig().getInt("worldBorder.z")
|
|
|
|
);
|
2021-08-26 13:38:12 +00:00
|
|
|
worldborderSize = Math.max(100,getConfig().getInt("worldBorder.size"));
|
|
|
|
worldborderDelay = Math.max(1,getConfig().getInt("worldBorder.delay"));
|
2021-08-25 03:43:01 +00:00
|
|
|
worldborderEnabled = getConfig().getBoolean("worldBorder.enabled");
|
|
|
|
|
2021-08-26 13:38:12 +00:00
|
|
|
//Prefix
|
2021-08-25 04:02:24 +00:00
|
|
|
char SYMBOLE = '\u00A7';
|
|
|
|
String SYMBOLE_STRING = new String(new char[] {SYMBOLE});
|
|
|
|
|
|
|
|
messagePrefix = getConfig().getString("prefix.default").replace("&", SYMBOLE_STRING);
|
|
|
|
errorPrefix = getConfig().getString("prefix.error").replace("&", SYMBOLE_STRING);
|
|
|
|
tauntPrefix = getConfig().getString("prefix.taunt").replace("&", SYMBOLE_STRING);
|
|
|
|
worldborderPrefix = getConfig().getString("prefix.border").replace("&", SYMBOLE_STRING);
|
|
|
|
abortPrefix = getConfig().getString("prefix.abort").replace("&", SYMBOLE_STRING);
|
|
|
|
gameoverPrefix = getConfig().getString("prefix.gameover").replace("&", SYMBOLE_STRING);
|
2021-08-27 21:20:07 +00:00
|
|
|
warningPrefix = getConfig().getString("prefix.warning").replace("&", SYMBOLE_STRING);
|
2021-08-25 03:43:01 +00:00
|
|
|
|
2021-10-27 23:57:44 +00:00
|
|
|
//Map Bounds
|
|
|
|
saveMinX = getConfig().getInt("bounds.min.x");
|
|
|
|
saveMinZ = getConfig().getInt("bounds.min.z");
|
|
|
|
saveMaxX = getConfig().getInt("bounds.max.x");
|
|
|
|
saveMaxZ = getConfig().getInt("bounds.max.z");
|
|
|
|
|
2021-08-26 13:38:12 +00:00
|
|
|
//Other
|
2021-08-25 03:43:01 +00:00
|
|
|
nametagsVisible = getConfig().getBoolean("nametagsVisible");
|
2021-08-26 13:38:12 +00:00
|
|
|
permissionsRequired = getConfig().getBoolean("permissionsRequired");
|
|
|
|
minPlayers = Math.max(2,getConfig().getInt("minPlayers"));
|
2021-10-18 02:52:57 +00:00
|
|
|
gameLength = getConfig().getInt("gameLength");
|
2021-08-25 03:43:01 +00:00
|
|
|
|
|
|
|
getConfig().options().copyDefaults(true);
|
|
|
|
saveConfig();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void addToSection(String sectionName, Map<String,Object> values) {
|
|
|
|
ConfigurationSection section = getConfig().getConfigurationSection(sectionName);
|
|
|
|
if(section == null) section = getConfig().createSection(sectionName);
|
|
|
|
Map<String,Object> sectionValues = section.getValues(true);
|
|
|
|
for(Entry<String, Object> entry : values.entrySet()) {
|
|
|
|
sectionValues.put(entry.getKey(), entry.getValue());
|
|
|
|
}
|
|
|
|
getConfig().createSection(sectionName, sectionValues);
|
|
|
|
saveConfig();
|
|
|
|
}
|
|
|
|
|
2021-10-27 23:57:44 +00:00
|
|
|
public static void addToConfig(String path, Object value) {
|
|
|
|
getConfig().set(path, value);
|
|
|
|
}
|
|
|
|
|
2021-08-18 23:21:59 +00:00
|
|
|
}
|