Let's use some more of CommandBase

This commit is contained in:
Daniil Z committed 2021-03-01 01:55:08 +03:00
1 parent fd4b886631
commit 1dbf932230
29 files changed
+541 -643

No files matched your search

@@ -1,7 +1,6 @@
package me.william278.huskhomes2.data;
import me.william278.huskhomes2.HuskHomes;
import me.william278.huskhomes2.data.logging.Errors;
import me.william278.huskhomes2.teleport.points.Home;
import me.william278.huskhomes2.teleport.points.TeleportationPoint;
import me.william278.huskhomes2.teleport.points.Warp;
@@ -27,7 +26,7 @@ public class DataManager {
public static String createLocationsTable = "";
public static String createHomesTable = "CREATE TABLE IF NOT EXISTS " + HuskHomes.settings.getHomesDataTable() + " (" +
public static final String createHomesTable = "CREATE TABLE IF NOT EXISTS " + HuskHomes.settings.getHomesDataTable() + " (" +
"`player_id` integer NOT NULL," +
"`location_id` integer NOT NULL," +
"`name` varchar(16) NOT NULL," +
@@ -38,7 +37,7 @@ public class DataManager {
"FOREIGN KEY (`location_id`) REFERENCES " + HuskHomes.settings.getLocationsDataTable() + " (`location_id`) ON DELETE CASCADE ON UPDATE NO ACTION" +
");";
public static String createWarpsTable = "CREATE TABLE IF NOT EXISTS " + HuskHomes.settings.getWarpsDataTable() + " (" +
public static final String createWarpsTable = "CREATE TABLE IF NOT EXISTS " + HuskHomes.settings.getWarpsDataTable() + " (" +
"`location_id` integer NOT NULL," +
"`name` varchar(16) NOT NULL UNIQUE," +
"`description` varchar(255) NOT NULL," +
@@ -80,7 +79,7 @@ public class DataManager {
return null; // If the player doesn't exist, playerID will be null
}
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
}
return null;
}
@@ -106,7 +105,7 @@ public class DataManager {
return null; // If the player doesn't exist, playerID will be null
}
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
}
return null;
}
@@ -133,7 +132,7 @@ public class DataManager {
return null;
}
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
}
return null;
}
@@ -170,7 +169,7 @@ public class DataManager {
return null;
}
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
}
return null;
}
@@ -198,7 +197,7 @@ public class DataManager {
return null;
}
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
}
return null;
}
@@ -274,7 +273,7 @@ public class DataManager {
return null;
}
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
}
return null;
}
@@ -305,7 +304,7 @@ public class DataManager {
return null;
}
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
}
return null;
}
@@ -336,7 +335,7 @@ public class DataManager {
}
return warps;
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
}
return null;
}
@@ -370,7 +369,7 @@ public class DataManager {
return null;
}
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
}
return null;
}
@@ -395,7 +394,7 @@ public class DataManager {
Bukkit.getLogger().severe("Failed to obtain home teleportation location ID");
}
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
}
return null;
}
@@ -433,7 +432,7 @@ public class DataManager {
Bukkit.getLogger().severe("Failed to obtain warp teleportation location ID");
}
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
}
return null;
}
@@ -518,7 +517,7 @@ public class DataManager {
return null;
}
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
}
return null;
}
@@ -540,7 +539,7 @@ public class DataManager {
return false;
}
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
}
return null;
}
@@ -573,7 +572,7 @@ public class DataManager {
return false;
}
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
}
return null;
}
@@ -600,7 +599,7 @@ public class DataManager {
return false;
}
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
}
return null;
}
@@ -627,7 +626,7 @@ public class DataManager {
return null;
}
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
}
return null;
}
@@ -1,8 +1,6 @@
package me.william278.huskhomes2.data;
import me.william278.huskhomes2.HuskHomes;
import me.william278.huskhomes2.data.logging.Error;
import me.william278.huskhomes2.data.logging.Errors;
import me.william278.huskhomes2.teleport.points.Home;
import me.william278.huskhomes2.teleport.points.TeleportationPoint;
import me.william278.huskhomes2.teleport.points.Warp;
@@ -60,7 +58,7 @@ public abstract class Database {
}
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
}
return null;
}
@@ -82,7 +80,7 @@ public abstract class Database {
ps.setBoolean(5, home.isPublic());
ps.executeUpdate();
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
}
}
@@ -104,7 +102,7 @@ public abstract class Database {
ps.setString(3, warp.getDescription());
ps.executeUpdate();
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
}
}
@@ -122,7 +120,7 @@ public abstract class Database {
ps.executeUpdate();
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
}
}
@@ -141,7 +139,7 @@ public abstract class Database {
ps.executeUpdate();
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
}
}
@@ -162,7 +160,7 @@ public abstract class Database {
ps.executeUpdate();
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
}
}
@@ -183,7 +181,7 @@ public abstract class Database {
ps.executeUpdate();
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
}
}
@@ -204,7 +202,7 @@ public abstract class Database {
ps.executeUpdate();
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
}
}
@@ -219,7 +217,7 @@ public abstract class Database {
ps.setInt(2, playerID);
ps.executeUpdate();
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
}
}
@@ -234,7 +232,7 @@ public abstract class Database {
ps.setInt(2, playerID);
ps.executeUpdate();
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
}
}
@@ -249,7 +247,7 @@ public abstract class Database {
ps.setInt(2, playerID);
ps.executeUpdate();
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
}
}
@@ -264,7 +262,7 @@ public abstract class Database {
ps.setInt(2, playerID);
ps.executeUpdate();
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
}
}
@@ -281,7 +279,7 @@ public abstract class Database {
ps.executeUpdate();
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
}
}
@@ -300,7 +298,7 @@ public abstract class Database {
ps.setInt(3, ownerID);
ps.executeUpdate();
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
}
}
@@ -322,7 +320,7 @@ public abstract class Database {
ps.setInt(3, ownerID);
ps.executeUpdate();
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
}
}
@@ -343,7 +341,7 @@ public abstract class Database {
ps.setString(2, warpName);
ps.executeUpdate();
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
}
}
// Update the description of a home
@@ -361,7 +359,7 @@ public abstract class Database {
ps.setInt(3, ownerID);
ps.executeUpdate();
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
}
}
@@ -379,7 +377,7 @@ public abstract class Database {
ps.setString(2, warpName);
ps.executeUpdate();
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
}
}
@@ -399,7 +397,7 @@ public abstract class Database {
ps.executeUpdate();
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
}
}
@@ -418,7 +416,7 @@ public abstract class Database {
ps.executeUpdate();
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
}
}
@@ -439,7 +437,7 @@ public abstract class Database {
ps.setInt(2, playerID);
ps.executeUpdate();
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
}
}
@@ -461,7 +459,7 @@ public abstract class Database {
ps.executeUpdate();
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
}
}
@@ -476,7 +474,7 @@ public abstract class Database {
ps.setInt(1, playerID);
ps.executeUpdate();
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
}
}
@@ -491,7 +489,7 @@ public abstract class Database {
ps.setInt(1, playerID);
ps.executeUpdate();
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
}
}
@@ -1,14 +1,19 @@
package me.william278.huskhomes2.data.logging;
package me.william278.huskhomes2.data;
import me.william278.huskhomes2.HuskHomes;
import java.util.logging.Level;
public class Error {
public static final String SQL_CONNECTION_EXECUTE = "Couldn't execute MySQL statement: ";
public static final String SQL_CONNECTION_CLOSE = "Failed to close MySQL connection: ";
public static final String SQL_NO_CONNECTION = "Unable to retrieve MYSQL connection: ";
public static final String SQL_NO_TABLE_FOUND = "Database Error: No Table Found";
public static void execute(HuskHomes plugin, Exception ex){
plugin.getLogger().log(Level.SEVERE, "Couldn't execute MySQL statement: ", ex);
}
public static void close(HuskHomes plugin, Exception ex){
plugin.getLogger().log(Level.SEVERE, "Failed to close MySQL connection: ", ex);
}
@@ -12,7 +12,7 @@ import java.util.logging.Level;
public class SQL extends Database {
final String SQLiteDatabaseName = "HuskHomesData";
private final String SQLiteDatabaseName = "HuskHomesData";
private Connection connection;
@@ -1,16 +0,0 @@
package me.william278.huskhomes2.data.logging;
public class Errors {
public static String sqlConnectionExecute(){
return "Couldn't execute MySQL statement: ";
}
public static String sqlConnectionClose(){
return "Failed to close MySQL connection: ";
}
public static String noSQLConnection(){
return "Unable to retrieve MYSQL connection: ";
}
public static String noTableFound(){
return "Database Error: No Table Found";
}
}