diff --git a/pom.xml b/pom.xml index 949e7b1..1f08947 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ me.paradoxpixel themepark - 1.3 + 1.3.1 diff --git a/src/main/java/me/paradoxpixel/themepark/api/LocationUtils.java b/src/main/java/me/paradoxpixel/themepark/api/LocationUtils.java index a62f8b5..ab0a920 100644 --- a/src/main/java/me/paradoxpixel/themepark/api/LocationUtils.java +++ b/src/main/java/me/paradoxpixel/themepark/api/LocationUtils.java @@ -26,16 +26,22 @@ public class LocationUtils { } public static Location toLocation(String string) { - if(string == null) + if(string == null || string.isEmpty()) { + System.out.println("LocationUtils: Incorrect String passed"); return null; + } String[] args = string.split(":"); - if(args.length < 4) + if(args.length < 4) { + System.out.println("LocationUtils: Not enough arguments"); return null; + } World world = Bukkit.getWorld(args[0]); - if(world == null) + if(world == null) { + System.out.println("LocationUtils: No world with name: "+args[0]); return null; + } double x = Double.parseDouble(args[1]); double y = Double.parseDouble(args[2]); diff --git a/src/main/java/me/paradoxpixel/themepark/api/attraction/component/Status.java b/src/main/java/me/paradoxpixel/themepark/api/attraction/component/Status.java index 62683fb..ea82f85 100644 --- a/src/main/java/me/paradoxpixel/themepark/api/attraction/component/Status.java +++ b/src/main/java/me/paradoxpixel/themepark/api/attraction/component/Status.java @@ -21,6 +21,8 @@ public enum Status { return CLOSED; case "MAINTENANCE": return MAINTENANCE; + case "MALFUNCTION": + return MALFUNCTION; case "ACTIVE": return ACTIVE; case "INACTIVE": diff --git a/src/main/java/me/paradoxpixel/themepark/attraction/sign/SignManager.java b/src/main/java/me/paradoxpixel/themepark/attraction/sign/SignManager.java index 1632f28..3c9c56c 100644 --- a/src/main/java/me/paradoxpixel/themepark/attraction/sign/SignManager.java +++ b/src/main/java/me/paradoxpixel/themepark/attraction/sign/SignManager.java @@ -18,13 +18,18 @@ public class SignManager { private static HashMap> signs = new HashMap<>(); public static void loadSigns(Attraction attraction) { - if(attraction == null) + if(attraction == null) { + System.out.println("SignManager: No attraction passed"); return; + } - if(!config.getConfig().contains("signs." + attraction.getId())) + if(!config.getConfig().contains("signs." + attraction.getId())) { + System.out.println("SignManager: No signs for attraction with ID: "+attraction.getId()); return; + } if(!config.getConfig().isList("signs." + attraction.getId())) { + System.out.println("SignManager: No signs for attraction with ID: "+attraction.getId()); config.getConfig().set("signs." + attraction.getId(), null); config.save(); return; @@ -34,11 +39,15 @@ public class SignManager { List locations = config.getConfig().getStringList("signs." + attraction.getId()); for(String string : locations) { Location location = LocationUtils.toLocation(string); - if(location == null) + if(location == null) { + System.out.println("SignManager: Incorrect sign Location"); continue; + } - if(!(location.getBlock().getState() instanceof Sign)) - return; + if(!(location.getBlock().getState() instanceof Sign)) { + System.out.println("SignManager: Block is not a sign at: "+string); + continue; + } array.add(new StatusSign(attraction, location)); } diff --git a/src/main/java/me/paradoxpixel/themepark/database/Database.java b/src/main/java/me/paradoxpixel/themepark/database/Database.java index c73653f..ac544f8 100644 --- a/src/main/java/me/paradoxpixel/themepark/database/Database.java +++ b/src/main/java/me/paradoxpixel/themepark/database/Database.java @@ -18,20 +18,21 @@ public class Database { return; } - enabled = config.getConfig().getBoolean("mysql.enabled"); - host = config.getConfig().getString("mysql.host"); - port = config.getConfig().getInt("mysql.port"); - database = config.getConfig().getString("mysql.database"); - user = config.getConfig().getString("mysql.user"); - password = config.getConfig().getString("mysql.password"); + enabled = config.getConfig().getBoolean("mysql.enabled"); + String host = config.getConfig().getString("mysql.host"); + int port = config.getConfig().getInt("mysql.port"); + String database = config.getConfig().getString("mysql.database"); + user = config.getConfig().getString("mysql.user"); + password = config.getConfig().getString("mysql.password"); + url = config.getConfig().getString("mysql.url"); + + url = url.replace("%host%", host); + url = url.replace("%port%", Integer.toString(port)); + url = url.replace("%database%", database); } private boolean enabled; - private String host; - private int port; - private String database; - private String user; - private String password; + private String user, password, url; private Connection connection; private int TaskID; @@ -43,7 +44,7 @@ public class Database { public void connect() { try { Class.forName("com.mysql.jdbc.Driver").newInstance(); - connection = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database + "?useSSL=false", user, password); + connection = DriverManager.getConnection(url, user, password); startPool(); } catch(Exception e) { diff --git a/src/main/java/me/paradoxpixel/themepark/listener/ChangeListener.java b/src/main/java/me/paradoxpixel/themepark/listener/ChangeListener.java index fb717e7..45a2e15 100644 --- a/src/main/java/me/paradoxpixel/themepark/listener/ChangeListener.java +++ b/src/main/java/me/paradoxpixel/themepark/listener/ChangeListener.java @@ -36,12 +36,7 @@ public class ChangeListener implements Listener { message = message.replace("{status}", StatusManager.getName(status)); Bukkit.broadcastMessage(Utils.color(message)); - Bukkit.getScheduler().runTaskAsynchronously(ThemeParkPlugin.getInstance(), new Runnable() { - @Override - public void run() { - ThemeParkPlugin.getInstance().getDatabaseHandler().updateAttraction(e.getAttraction()); - } - }); + Bukkit.getScheduler().runTaskAsynchronously(ThemeParkPlugin.getInstance(), () -> ThemeParkPlugin.getInstance().getDatabaseHandler().updateAttraction(e.getAttraction())); } @EventHandler @@ -51,13 +46,7 @@ public class ChangeListener implements Listener { AttractionMenu.reload(); SignManager.loadSigns(e.getAttraction()); - - Bukkit.getScheduler().runTaskAsynchronously(ThemeParkPlugin.getInstance(), new Runnable() { - @Override - public void run() { - ThemeParkPlugin.getInstance().getDatabaseHandler().addAttraction(e.getAttraction()); - } - }); + Bukkit.getScheduler().runTaskAsynchronously(ThemeParkPlugin.getInstance(), () -> ThemeParkPlugin.getInstance().getDatabaseHandler().addAttraction(e.getAttraction())); } @EventHandler @@ -67,17 +56,11 @@ public class ChangeListener implements Listener { AttractionMenu.reload(); SignManager.remove(e.getAttraction()); - YamlConfig config = ThemeParkPlugin.getInstance().getAttraction(); config.getConfig().set("attraction." + e.getAttraction().getId(), null); config.save(); - Bukkit.getScheduler().runTaskAsynchronously(ThemeParkPlugin.getInstance(), new Runnable() { - @Override - public void run() { - ThemeParkPlugin.getInstance().getDatabaseHandler().removeAttraction(e.getAttraction()); - } - }); + Bukkit.getScheduler().runTaskAsynchronously(ThemeParkPlugin.getInstance(), () -> ThemeParkPlugin.getInstance().getDatabaseHandler().removeAttraction(e.getAttraction())); } @EventHandler @@ -86,13 +69,7 @@ public class ChangeListener implements Listener { return; AttractionMenu.reload(); - - Bukkit.getScheduler().runTaskAsynchronously(ThemeParkPlugin.getInstance(), new Runnable() { - @Override - public void run() { - ThemeParkPlugin.getInstance().getDatabaseHandler().addRegion(e.getRegion()); - } - }); + Bukkit.getScheduler().runTaskAsynchronously(ThemeParkPlugin.getInstance(), () -> ThemeParkPlugin.getInstance().getDatabaseHandler().addRegion(e.getRegion())); } @EventHandler @@ -101,13 +78,7 @@ public class ChangeListener implements Listener { return; AttractionMenu.reload(); - - Bukkit.getScheduler().runTaskAsynchronously(ThemeParkPlugin.getInstance(), new Runnable() { - @Override - public void run() { - ThemeParkPlugin.getInstance().getDatabaseHandler().updateRegion(e.getRegion()); - } - }); + Bukkit.getScheduler().runTaskAsynchronously(ThemeParkPlugin.getInstance(), () -> ThemeParkPlugin.getInstance().getDatabaseHandler().updateRegion(e.getRegion())); } @EventHandler @@ -116,17 +87,11 @@ public class ChangeListener implements Listener { return; AttractionMenu.reload(); - YamlConfig config = ThemeParkPlugin.getInstance().getAttraction(); config.getConfig().set("region." + e.getRegion().getId(), null); config.save(); - Bukkit.getScheduler().runTaskAsynchronously(ThemeParkPlugin.getInstance(), new Runnable() { - @Override - public void run() { - ThemeParkPlugin.getInstance().getDatabaseHandler().removeRegion(e.getRegion()); - } - }); + Bukkit.getScheduler().runTaskAsynchronously(ThemeParkPlugin.getInstance(), () -> ThemeParkPlugin.getInstance().getDatabaseHandler().removeRegion(e.getRegion())); } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index f5cef00..374ba73 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ name: ThemePark -version: 1.3 +version: 1.3.1 main: me.paradoxpixel.themepark.ThemeParkPlugin author: ParadoxPixel softdepend: [PlaceholderAPI] diff --git a/src/main/resources/settings.yml b/src/main/resources/settings.yml index ac29cbc..4137d02 100644 --- a/src/main/resources/settings.yml +++ b/src/main/resources/settings.yml @@ -22,6 +22,7 @@ mysql: database: 'database' user: 'username' password: 'password' + url: 'jdbc:mysql://%host%:%port%/%database%?useSSL=false' CONSTRUCTION: name: "&7Under Construction"