Some small fixes
This commit is contained in:
parent
41784cb4e8
commit
ceafeebede
8 changed files with 47 additions and 63 deletions
2
pom.xml
2
pom.xml
|
@ -11,7 +11,7 @@
|
|||
|
||||
<groupId>me.paradoxpixel</groupId>
|
||||
<artifactId>themepark</artifactId>
|
||||
<version>1.3</version>
|
||||
<version>1.3.1</version>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
|
|
|
@ -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]);
|
||||
|
|
|
@ -21,6 +21,8 @@ public enum Status {
|
|||
return CLOSED;
|
||||
case "MAINTENANCE":
|
||||
return MAINTENANCE;
|
||||
case "MALFUNCTION":
|
||||
return MALFUNCTION;
|
||||
case "ACTIVE":
|
||||
return ACTIVE;
|
||||
case "INACTIVE":
|
||||
|
|
|
@ -18,13 +18,18 @@ public class SignManager {
|
|||
private static HashMap<Attraction, ArrayList<StatusSign>> 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<String> 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));
|
||||
}
|
||||
|
|
|
@ -19,19 +19,20 @@ public class Database {
|
|||
}
|
||||
|
||||
enabled = config.getConfig().getBoolean("mysql.enabled");
|
||||
host = config.getConfig().getString("mysql.host");
|
||||
port = config.getConfig().getInt("mysql.port");
|
||||
database = config.getConfig().getString("mysql.database");
|
||||
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) {
|
||||
|
|
|
@ -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()));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
name: ThemePark
|
||||
version: 1.3
|
||||
version: 1.3.1
|
||||
main: me.paradoxpixel.themepark.ThemeParkPlugin
|
||||
author: ParadoxPixel
|
||||
softdepend: [PlaceholderAPI]
|
||||
|
|
|
@ -22,6 +22,7 @@ mysql:
|
|||
database: 'database'
|
||||
user: 'username'
|
||||
password: 'password'
|
||||
url: 'jdbc:mysql://%host%:%port%/%database%?useSSL=false'
|
||||
|
||||
CONSTRUCTION:
|
||||
name: "&7Under Construction"
|
||||
|
|
Reference in a new issue