forked from Miyazono2003/AutoIslandPurge
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Settings.java
77 lines (63 loc) · 2.15 KB
/
Settings.java
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
package me.hsgamer.autoislandpurge;
import org.bukkit.Location;
import java.util.ArrayList;
import java.util.List;
public class Settings {
private final AutoIslandPurge addon;
private final List<String> enabledGameModes = new ArrayList<>();
private int offlineDays = 7;
private int maxMemberSize = 1;
private long checkTicks = 300;
private long deleteTicks = 10;
private Location spawnLocation;
private boolean forcedSpawnLocation;
public Settings(AutoIslandPurge addon) {
this.addon = addon;
}
public void setup() {
var config = addon.getConfig();
enabledGameModes.clear();
config.getStringList("enabled-modes").forEach(s -> enabledGameModes.add(s.toLowerCase()));
offlineDays = config.getInt("offline-days-until-purge", offlineDays);
maxMemberSize = config.getInt("purge-island-member-size", maxMemberSize);
checkTicks = config.getLong("check-purge-ticks", checkTicks);
deleteTicks = config.getLong("ticks-per-island-deleted", deleteTicks);
try {
var section = config.getConfigurationSection("spawn-location");
if (section != null) {
var map = section.getValues(false);
spawnLocation = Location.deserialize(map);
}
} catch (Exception e) {
// IGNORED
}
forcedSpawnLocation = config.getBoolean("forced-spawn-location", forcedSpawnLocation);
}
public List<String> getEnabledGameModes() {
return enabledGameModes;
}
public boolean isGameModeEnabled(String gameMode) {
if (gameMode == null) {
return false;
}
return enabledGameModes.contains(gameMode.toLowerCase());
}
public int getOfflineDays() {
return offlineDays;
}
public int getMaxMemberSize() {
return maxMemberSize;
}
public long getCheckTicks() {
return checkTicks;
}
public long getDeleteTicks() {
return deleteTicks;
}
public Location getSpawnLocation() {
return spawnLocation;
}
public boolean isForcedSpawnLocation() {
return forcedSpawnLocation;
}
}