Archived
0

UPDATE 0.1.1 ~ new classes and methods etc.

This commit is contained in:
Prot-CN
2019-03-17 08:15:14 +06:00
committed by DmitriyMX
parent 74aec1d470
commit 87b651a4f1
42 changed files with 1018 additions and 2147 deletions

View File

@@ -18,7 +18,7 @@ public class Manager {
private FileConfiguration fileConfiguration;
public Manager(String id) {
file = new File(PrisonAPI.PLUGIN_PATH + "/", "PRISON_" + id + ".yml");
file = new File(PrisonAPI.PLUGIN_MANAGER_PATH + "/", "PRISON_" + id + ".yml");
fileConfiguration = YamlConfiguration.loadConfiguration(file);
}
@@ -26,6 +26,10 @@ public class Manager {
return file.exists();
}
public String getName() {
return file.getName().replace("PRISON_", "").replace(".yml", "");
}
public String getWorld() {
return fileConfiguration.getString("WORLD");
}
@@ -55,7 +59,7 @@ public class Manager {
}
public List<Integer> getSpawnCords(int faction) {
return fileConfiguration.getIntegerList("FACTIONS." + selectFactType(faction) + ".CORDS");
return fileConfiguration.getIntegerList("FACTIONS." + PrisonAPI.Factions.valueOf(faction) + ".CORDS");
}
public void setSpawnCords(int faction, List<Integer> data) {
@@ -139,26 +143,39 @@ public class Manager {
}
public List<String> getAllTerrs() {
List<String> terrs = new ArrayList<>();
for(String t : fileConfiguration.getConfigurationSection("TERRITORIES").getKeys(false))
terrs.add(t);
return terrs;
try {
List<String> terrs = new ArrayList<>();
for (String t : fileConfiguration.getConfigurationSection("TERRITORIES").getKeys(false))
terrs.add(t);
return terrs;
} catch(NullPointerException z) {
return null;
}
}
public List<String> getCages() {
List<String> cages = new ArrayList<>();
for(String c : fileConfiguration.getConfigurationSection("CAGES").getKeys(false))
cages.add(c);
return cages;
try {
List<String> cages = new ArrayList<>();
for (String c : fileConfiguration.getConfigurationSection("CAGES").getKeys(false))
cages.add(c);
return cages;
} catch(NullPointerException z) {
return null;
}
}
public List<Integer> getPointCage(String cage) {
return new ArrayList<>(fileConfiguration.getIntegerList("CAGES." + cage));
}
public Location getLocationCage(String cage) {
List<Integer> point = getPointCage(cage);
return new Location(Bukkit.getWorld(getWorld()), point.get(0) + 0.5, point.get(1), point.get(2) + 0.5);
}
public void teleportInToCage(Prisoner prs, String cage) {
List<Integer> data =fileConfiguration.getIntegerList("CAGES." + cage);
Location loc = new Location(Bukkit.getWorld(fileConfiguration.getString("WORLD")),
List<Integer> data = fileConfiguration.getIntegerList("CAGES." + cage);
Location loc = new Location(Bukkit.getWorld(getWorld()),
data.get(0) + 0.5, data.get(1), data.get(2) + 0.5);
prs.getPlayer().teleport(loc);
}