3
0
Fork 0
This commit is contained in:
BuildTools 2019-01-19 21:50:39 +01:00
parent 35984bc18c
commit a4425949e6
4 changed files with 12 additions and 13 deletions

View file

@ -68,6 +68,11 @@ public class API {
regions.remove(id.toLowerCase());
}
public static void clearRegions() {
regions.clear();
attractions.clear();
}
public static void addAttraction(Attraction attraction) {
if(!isRegion(attraction.getRegion_id()))
return;

View file

@ -26,10 +26,11 @@ public class AttractionMenu {
private static YamlConfig settings = ThemeParkPlugin.getInstance().getSettings();
private static GUI gui;
private static HashMap<String, Integer> index = new HashMap<>();
private static HashMap<String, Integer> index;
public static void load() {
gui = new GUI(settings.getConfig().getString("menu.title"), 9);
index = new HashMap<>();
loadData();
loadItems();
}
@ -106,10 +107,6 @@ public class AttractionMenu {
Attraction attraction = new Attraction(id, name, region_id, location, type, status);
API.addAttraction(attraction);
}
for(Region region : API.getRegions().values())
if(region.getAttractions().isEmpty())
API.removeRegion(region.getId());
}
private static void loadItems() {

View file

@ -180,16 +180,13 @@ public class ThemeParkCommand extends BukkitCommand {
ThemeParkPlugin.getInstance().getSigns().reload();
ThemeParkPlugin.getInstance().getSettings().reload();
ThemeParkPlugin.getInstance().getMessage().reload();
API.getRegions().clear();
API.getAttractions().clear();
API.clearRegions();
StatusManager.load();
AttractionMenu.load();
for(Region region : API.getRegions().values())
if(region.getAttractions().isEmpty())
API.removeRegion(region.getId());
Bukkit.getScheduler().runTaskAsynchronously(ThemeParkPlugin.getInstance(),() -> {
ThemeParkPlugin.getInstance().getDatabaseHandler().load();
});
sender.sendMessage(Utils.color(Message.getMessage("reloaded")));
}

View file

@ -21,7 +21,7 @@ public class DatabaseHandler {
load();
}
private void load() {
public void load() {
database.execute("CREATE TABLE IF NOT EXISTS attraction (id VARCHAR(256) NOT NULL, name VARCHAR(256) NOT NULL, region_id VARCHAR(256) NOT NULL, type VARCHAR(256) NOT NULL, status VARCHAR(256) NOT NULL, PRIMARY KEY(id))", null);
database.execute("CREATE TABLE IF NOT EXISTS region (id VARCHAR(256) NOT NULL, name VARCHAR(256) NOT NULL, PRIMARY KEY(id))", null);
database.execute("CREATE TABLE IF NOT EXISTS status (statusId VARCHAR(256) NOT NULL, statusName VARCHAR(256) NOT NULL)", null);