2021-08-13 20:49:36 +00:00
|
|
|
package net.tylermurphy.hideAndSeek;
|
|
|
|
|
2021-10-11 21:18:37 +00:00
|
|
|
import java.util.ArrayList;
|
2021-08-25 03:43:01 +00:00
|
|
|
import java.util.Arrays;
|
2021-08-13 20:49:36 +00:00
|
|
|
import java.util.HashMap;
|
2021-08-25 03:43:01 +00:00
|
|
|
import java.util.List;
|
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-10-11 21:06:21 +00:00
|
|
|
import org.bukkit.Location;
|
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.entity.Player;
|
|
|
|
import org.bukkit.scoreboard.Scoreboard;
|
|
|
|
import org.bukkit.scoreboard.Team;
|
|
|
|
import org.bukkit.util.Vector;
|
|
|
|
|
|
|
|
public class Store {
|
|
|
|
|
2021-08-26 13:38:12 +00:00
|
|
|
public static Map<String,Player>
|
2021-10-11 21:06:21 +00:00
|
|
|
playerList = new HashMap<String,Player>();
|
|
|
|
|
|
|
|
public static Map<String,Location>
|
|
|
|
playerLastLocationList = new HashMap<String,Location>();
|
2021-08-18 23:21:59 +00:00
|
|
|
|
2021-09-01 01:55:27 +00:00
|
|
|
public static List<String>
|
2021-10-11 21:18:37 +00:00
|
|
|
Hider = new ArrayList<String>(),
|
|
|
|
Seeker = new ArrayList<String>(),
|
|
|
|
Spectator = new ArrayList<String>();
|
2021-09-01 01:55:27 +00:00
|
|
|
|
2021-08-26 13:38:12 +00:00
|
|
|
public static Scoreboard
|
|
|
|
board;
|
2021-08-18 23:21:59 +00:00
|
|
|
|
2021-08-26 13:38:12 +00:00
|
|
|
public static Team
|
2021-09-01 01:55:27 +00:00
|
|
|
HiderTeam,
|
|
|
|
SeekerTeam,
|
|
|
|
SpectatorTeam;
|
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-09-01 01:55:27 +00:00
|
|
|
status = "Standby";
|
2021-08-18 23:21:59 +00:00
|
|
|
|
2021-08-26 13:38:12 +00:00
|
|
|
public static Vector
|
|
|
|
spawnPosition,
|
2021-10-11 21:06:21 +00:00
|
|
|
lobbyPosition,
|
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 List<String>
|
|
|
|
blockedCommands;
|
2021-08-18 23:21:59 +00:00
|
|
|
|
2021-08-26 13:38:12 +00:00
|
|
|
public static boolean
|
|
|
|
nametagsVisible,
|
|
|
|
permissionsRequired,
|
2021-10-11 21:06:21 +00:00
|
|
|
lobbyManualJoin,
|
|
|
|
lobbyAnnounced,
|
2021-10-11 15:52:56 +00:00
|
|
|
lobbyStarted = false,
|
2021-08-26 13:38:12 +00:00
|
|
|
unbreakableArmorstands,
|
|
|
|
unbreakablePaintings,
|
|
|
|
unbreakableItemframes,
|
|
|
|
interactableArmorstands,
|
|
|
|
interactableItemframes,
|
|
|
|
interactableDoors,
|
|
|
|
interactableTrapdoors,
|
|
|
|
interactableFencegate,
|
|
|
|
worldborderEnabled = false,
|
2021-08-28 00:32:50 +00:00
|
|
|
runningBackup = false;
|
2021-08-25 03:43:01 +00:00
|
|
|
|
2021-08-26 13:38:12 +00:00
|
|
|
public static int
|
|
|
|
minPlayers,
|
|
|
|
gameId = 0,
|
|
|
|
worldborderSize,
|
|
|
|
worldborderDelay,
|
|
|
|
currentWorldborderSize;
|
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
|
|
|
//Default
|
2021-08-25 03:43:01 +00:00
|
|
|
getConfig().addDefault("spawn.x", 0);
|
|
|
|
getConfig().addDefault("spawn.y", 0);
|
|
|
|
getConfig().addDefault("spawn.z", 0);
|
|
|
|
getConfig().addDefault("spawn.world", "world");
|
|
|
|
getConfig().addDefault("worldBorder.x", 0);
|
|
|
|
getConfig().addDefault("worldBorder.z", 0);
|
|
|
|
getConfig().addDefault("worldBorder.delay", 10);
|
|
|
|
getConfig().addDefault("worldBorder.size", 500);
|
|
|
|
getConfig().addDefault("worldBorder.enabled", false);
|
2021-08-27 21:20:07 +00:00
|
|
|
getConfig().addDefault("blockedCommands", Arrays.asList("whisper","msg"));
|
2021-08-25 03:43:01 +00:00
|
|
|
getConfig().addDefault("prefix.default", "&9Hide and Seek > &f");
|
|
|
|
getConfig().addDefault("prefix.error", "&cError > &f");
|
|
|
|
getConfig().addDefault("prefix.taunt", "&eTaunt > &f");
|
|
|
|
getConfig().addDefault("prefix.border", "&cWorld Border > &f");
|
|
|
|
getConfig().addDefault("prefix.abort", "&cAbort > &f");
|
|
|
|
getConfig().addDefault("prefix.gameover", "&aGame Over > &f");
|
2021-08-27 21:20:07 +00:00
|
|
|
getConfig().addDefault("prefix.warning", "&cWarning > &f");
|
2021-08-25 03:43:01 +00:00
|
|
|
getConfig().addDefault("nametagsVisible", false);
|
2021-08-26 13:38:12 +00:00
|
|
|
getConfig().addDefault("permissionsRequired", true);
|
2021-10-11 21:06:21 +00:00
|
|
|
getConfig().addDefault("lobby.manualJoin", false);
|
|
|
|
getConfig().addDefault("lobby.announceJoinAndLeave", false);
|
|
|
|
getConfig().addDefault("lobby.spawn.x", 0);
|
|
|
|
getConfig().addDefault("lobby.spawn.y", 0);
|
|
|
|
getConfig().addDefault("lobby.spawn.z", 0);
|
2021-08-26 13:38:12 +00:00
|
|
|
getConfig().addDefault("blockSettings.unbreakable.painting", false);
|
|
|
|
getConfig().addDefault("blockSettings.unbreakable.armorstand", false);
|
|
|
|
getConfig().addDefault("blockSettings.unbreakable.itemframe", false);
|
|
|
|
getConfig().addDefault("blockSettings.interactable.armorstand", true);
|
|
|
|
getConfig().addDefault("blockSettings.interactable.itemframe", true);
|
|
|
|
getConfig().addDefault("blockSettings.interactable.door", true);
|
|
|
|
getConfig().addDefault("blockSettings.interactable.trapdoor", true);
|
|
|
|
getConfig().addDefault("blockSettings.interactable.fence", true);
|
|
|
|
getConfig().addDefault("minPlayers", 2);
|
2021-08-25 03:43:01 +00:00
|
|
|
|
2021-08-26 13:38:12 +00:00
|
|
|
//Spawn
|
2021-08-25 03:43:01 +00:00
|
|
|
spawnPosition = new Vector(
|
|
|
|
getConfig().getDouble("spawn.x"),
|
2021-08-26 13:38:12 +00:00
|
|
|
Math.max(0,Math.min(255,getConfig().getDouble("spawn.y"))),
|
2021-08-25 03:43:01 +00:00
|
|
|
getConfig().getDouble("spawn.z")
|
|
|
|
);
|
|
|
|
spawnWorld = getConfig().getString("spawn.world");
|
|
|
|
|
2021-10-11 21:06:21 +00:00
|
|
|
///Lobby
|
|
|
|
lobbyPosition = new Vector(
|
|
|
|
getConfig().getDouble("lobby.spawn.x"),
|
|
|
|
Math.max(0,Math.min(255,getConfig().getDouble("lobby.spawn.y"))),
|
|
|
|
getConfig().getDouble("lobby.spawn.z")
|
|
|
|
);
|
|
|
|
|
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");
|
|
|
|
blockedCommands = getConfig().getStringList("blockedCommands");
|
2021-09-01 01:55:27 +00:00
|
|
|
blockedCommands.add("team");
|
2021-08-25 03:43:01 +00:00
|
|
|
|
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-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");
|
2021-10-11 21:06:21 +00:00
|
|
|
lobbyManualJoin = getConfig().getBoolean("lobby.manualJoin");
|
2021-08-26 13:38:12 +00:00
|
|
|
unbreakablePaintings = getConfig().getBoolean("blockSettings.unbreakable.painting");
|
|
|
|
unbreakableArmorstands = getConfig().getBoolean("blockSettings.unbreakable.armorstand");
|
|
|
|
unbreakableItemframes = getConfig().getBoolean("blockSettings.unbreakable.itemframe");
|
|
|
|
interactableArmorstands = getConfig().getBoolean("blockSettings.interactable.armorstand");
|
|
|
|
interactableItemframes = getConfig().getBoolean("blockSettings.interactable.itemframe");
|
|
|
|
interactableDoors = getConfig().getBoolean("blockSettings.interactable.door");
|
|
|
|
interactableTrapdoors = getConfig().getBoolean("blockSettings.interactable.trapdoor");
|
|
|
|
interactableFencegate = getConfig().getBoolean("blockSettings.interactable.fence");
|
|
|
|
minPlayers = Math.max(2,getConfig().getInt("minPlayers"));
|
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-08-18 23:21:59 +00:00
|
|
|
}
|