Bug fix
This commit is contained in:
parent
35984bc18c
commit
a4425949e6
4 changed files with 12 additions and 13 deletions
|
@ -68,6 +68,11 @@ public class API {
|
||||||
regions.remove(id.toLowerCase());
|
regions.remove(id.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void clearRegions() {
|
||||||
|
regions.clear();
|
||||||
|
attractions.clear();
|
||||||
|
}
|
||||||
|
|
||||||
public static void addAttraction(Attraction attraction) {
|
public static void addAttraction(Attraction attraction) {
|
||||||
if(!isRegion(attraction.getRegion_id()))
|
if(!isRegion(attraction.getRegion_id()))
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -26,10 +26,11 @@ public class AttractionMenu {
|
||||||
private static YamlConfig settings = ThemeParkPlugin.getInstance().getSettings();
|
private static YamlConfig settings = ThemeParkPlugin.getInstance().getSettings();
|
||||||
private static GUI gui;
|
private static GUI gui;
|
||||||
|
|
||||||
private static HashMap<String, Integer> index = new HashMap<>();
|
private static HashMap<String, Integer> index;
|
||||||
|
|
||||||
public static void load() {
|
public static void load() {
|
||||||
gui = new GUI(settings.getConfig().getString("menu.title"), 9);
|
gui = new GUI(settings.getConfig().getString("menu.title"), 9);
|
||||||
|
index = new HashMap<>();
|
||||||
loadData();
|
loadData();
|
||||||
loadItems();
|
loadItems();
|
||||||
}
|
}
|
||||||
|
@ -106,10 +107,6 @@ public class AttractionMenu {
|
||||||
Attraction attraction = new Attraction(id, name, region_id, location, type, status);
|
Attraction attraction = new Attraction(id, name, region_id, location, type, status);
|
||||||
API.addAttraction(attraction);
|
API.addAttraction(attraction);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(Region region : API.getRegions().values())
|
|
||||||
if(region.getAttractions().isEmpty())
|
|
||||||
API.removeRegion(region.getId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void loadItems() {
|
private static void loadItems() {
|
||||||
|
|
|
@ -180,16 +180,13 @@ public class ThemeParkCommand extends BukkitCommand {
|
||||||
ThemeParkPlugin.getInstance().getSigns().reload();
|
ThemeParkPlugin.getInstance().getSigns().reload();
|
||||||
ThemeParkPlugin.getInstance().getSettings().reload();
|
ThemeParkPlugin.getInstance().getSettings().reload();
|
||||||
ThemeParkPlugin.getInstance().getMessage().reload();
|
ThemeParkPlugin.getInstance().getMessage().reload();
|
||||||
|
API.clearRegions();
|
||||||
API.getRegions().clear();
|
|
||||||
API.getAttractions().clear();
|
|
||||||
|
|
||||||
StatusManager.load();
|
StatusManager.load();
|
||||||
AttractionMenu.load();
|
AttractionMenu.load();
|
||||||
for(Region region : API.getRegions().values())
|
Bukkit.getScheduler().runTaskAsynchronously(ThemeParkPlugin.getInstance(),() -> {
|
||||||
if(region.getAttractions().isEmpty())
|
ThemeParkPlugin.getInstance().getDatabaseHandler().load();
|
||||||
API.removeRegion(region.getId());
|
});
|
||||||
|
|
||||||
sender.sendMessage(Utils.color(Message.getMessage("reloaded")));
|
sender.sendMessage(Utils.color(Message.getMessage("reloaded")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ public class DatabaseHandler {
|
||||||
load();
|
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 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 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);
|
database.execute("CREATE TABLE IF NOT EXISTS status (statusId VARCHAR(256) NOT NULL, statusName VARCHAR(256) NOT NULL)", null);
|
||||||
|
|
Reference in a new issue