summaryrefslogtreewikicommitdiff
path: root/src/main/java/net/tylermurphy/hideAndSeek/Store.java
blob: afbb79cb2d83e719feb7efb91c0924badbf16d78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
package net.tylermurphy.hideAndSeek;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import org.bukkit.configuration.ConfigurationSection;
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 {

	public static Map<String,Player> playerList = new HashMap<String,Player>();
	
	public static Scoreboard board;	
	public static Team Hider,Seeker,Spectator;
	
	public static String status = "Setup";
	
	public static String messagePrefix,errorPrefix,tauntPrefix,worldborderPrefix,abortPrefix,gameoverPrefix;
	
	public static Vector spawnPosition;
	public static String spawnWorld;
	
	public static Vector worldborderPosition;
	public static int worldborderSize,worldborderDelay,currentWorldborderSize;
	public static boolean worldborderEnabled = false, decreaseBorder = false;
	
	public static List<String> blockedCommands;
	
	public static boolean nametagsVisible;
	
	public static String tauntPlayer = "";
	
	public static int glowTime = 0;
	
	public static int gameId = 0;
	
	public static FileConfiguration getConfig() {
		return Main.plugin.getConfig();
	}
	
	public static void saveConfig() {
		Main.plugin.saveConfig();
	}
	
	public static void loadConfig() {
		
		Main.plugin.reloadConfig();
		
		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);
		getConfig().addDefault("blockedCommands", Arrays.asList("tp","kill","gamemode","effect","clear"));
		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");
		getConfig().addDefault("nametagsVisible", false);
		
		spawnPosition = new Vector(
				getConfig().getDouble("spawn.x"), 
				getConfig().getDouble("spawn.y"),
				getConfig().getDouble("spawn.z")
			);
		spawnWorld = getConfig().getString("spawn.world");
		
		worldborderPosition = new Vector(
				getConfig().getInt("worldBorder.x"), 
				0, 
				getConfig().getInt("worldBorder.z")
			);
		worldborderSize = getConfig().getInt("worldBorder.size");
		worldborderDelay = getConfig().getInt("worldBorder.delay");
		worldborderEnabled = getConfig().getBoolean("worldBorder.enabled");
		
		blockedCommands = getConfig().getStringList("blockedCommands");
		
		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);
		
		nametagsVisible = getConfig().getBoolean("nametagsVisible");
		
		getConfig().options().copyDefaults(true);
		saveConfig();
		
		if(spawnPosition.getBlockX() != 0 || spawnPosition.getBlockY() != 0 || spawnPosition.getBlockZ() != 0) {
			status = "Standby";
		}
		
	}
	
	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();
	}
	
}