diff --git a/plugins/namelayer-paper/namelayer-spigot/pom.xml b/plugins/namelayer-paper/namelayer-spigot/pom.xml
index 797f2c632..2aab17135 100755
--- a/plugins/namelayer-paper/namelayer-spigot/pom.xml
+++ b/plugins/namelayer-paper/namelayer-spigot/pom.xml
@@ -26,7 +26,7 @@
provided
- vg.civcraft.mc.civmodcore
+ com.github.civclassic
CivModCore
1.9.0
provided
diff --git a/plugins/namelayer-paper/namelayer-spigot/src/main/java/vg/civcraft/mc/namelayer/NameLayerPlugin.java b/plugins/namelayer-paper/namelayer-spigot/src/main/java/vg/civcraft/mc/namelayer/NameLayerPlugin.java
index e6c318aa4..fe4d00811 100644
--- a/plugins/namelayer-paper/namelayer-spigot/src/main/java/vg/civcraft/mc/namelayer/NameLayerPlugin.java
+++ b/plugins/namelayer-paper/namelayer-spigot/src/main/java/vg/civcraft/mc/namelayer/NameLayerPlugin.java
@@ -8,6 +8,7 @@ import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import vg.civcraft.mc.civmodcore.ACivMod;
+import vg.civcraft.mc.civmodcore.dao.DatabaseCredentials;
import vg.civcraft.mc.civmodcore.dao.ManagedDatasource;
import vg.civcraft.mc.namelayer.command.CommandHandler;
import vg.civcraft.mc.namelayer.database.AssociationList;
@@ -35,7 +36,7 @@ public class NameLayerPlugin extends ACivMod {
private static int groupLimit = 10;
private static boolean createGroupOnFirstJoin;
private FileConfiguration config;
-
+
@Override
public void onEnable() {
super.onEnable(); // Need to call this to properly initialize this mod
@@ -47,12 +48,12 @@ public class NameLayerPlugin extends ACivMod {
createGroupOnFirstJoin = config.getBoolean("groups.creationOnFirstJoin", true);
instance = this;
loadDatabases();
- ClassHandler.Initialize(Bukkit.getServer());
+ ClassHandler.Initialize(Bukkit.getServer());
new NameAPI(new GroupManager(), associations);
NameCleanser.load(config.getConfigurationSection("name_cleanser"));
MojangNames.init(this);
registerListeners();
- if (loadGroups){
+ if (loadGroups) {
PermissionType.initialize();
blackList = new BlackList();
groupManagerDao.loadGroupsInvitations();
@@ -61,8 +62,8 @@ public class NameLayerPlugin extends ACivMod {
handle = new CommandHandler(this);
}
}
-
- public void registerListeners(){
+
+ public void registerListeners() {
registerListener(new AssociationListener());
registerListener(new PlayerListener());
}
@@ -72,12 +73,12 @@ public class NameLayerPlugin extends ACivMod {
MojangNames.reset(this);
super.onDisable();
}
-
- public static NameLayerPlugin getInstance(){
+
+ public static NameLayerPlugin getInstance() {
return instance;
}
-
- public void loadDatabases(){
+
+ public void loadDatabases() {
String host = config.getString("sql.hostname", "localhost");
int port = config.getInt("sql.port", 3306);
String dbname = config.getString("sql.dbname", "namelayer");
@@ -88,23 +89,24 @@ public class NameLayerPlugin extends ACivMod {
long idleTimeout = config.getLong("sql.idle_timeout", 600000l);
long maxLifetime = config.getLong("sql.max_lifetime", 7200000l);
try {
- db = new ManagedDatasource(this, username, password, host, port, dbname,
- poolsize, connectionTimeout, idleTimeout, maxLifetime);
+ db = ManagedDatasource.construct(this,
+ new DatabaseCredentials(username, password, host, port, "mysql", dbname, poolsize,
+ connectionTimeout, idleTimeout, maxLifetime));
db.getConnection().close();
} catch (Exception se) {
NameLayerPlugin.log(Level.WARNING, "Could not connect to DataBase, shutting down!");
Bukkit.shutdown();
return;
}
-
+
if (!db.isManaged()) {
// First "migration" is conversion from old system to new, and lives outside AssociationList and GroupManagerDao.
boolean isNew = true;
try (Connection connection = db.getConnection();
- PreparedStatement checkNewInstall = connection.prepareStatement("SELECT * FROM db_version LIMIT 1;");
- // See if this was a new install. If it was, db_version statement will fail. If it isn't, it'll succeed.
- // If the version statement fails, return true; this is new install, carryon.
- ResultSet rs = checkNewInstall.executeQuery();) {
+ PreparedStatement checkNewInstall = connection.prepareStatement("SELECT * FROM db_version LIMIT 1;");
+ // See if this was a new install. If it was, db_version statement will fail. If it isn't, it'll succeed.
+ // If the version statement fails, return true; this is new install, carryon.
+ ResultSet rs = checkNewInstall.executeQuery();) {
isNew = !rs.next();
} catch (SQLException se) {
NameLayerPlugin.log(Level.INFO, "New installation: Welcome to Namelayer!");
@@ -112,16 +114,18 @@ public class NameLayerPlugin extends ACivMod {
if (!isNew) {
try (Connection connection = db.getConnection();
- PreparedStatement migrateInstall = connection.prepareStatement(
- "INSERT INTO managed_plugin_data (plugin_name, current_migration_number, last_migration)"
- + " SELECT plugin_name, max(db_version), `timestamp` FROM db_version WHERE plugin_name = '"
- + this.getName() + "' LIMIT 1;");) {
+ PreparedStatement migrateInstall = connection.prepareStatement(
+ "INSERT INTO managed_plugin_data (plugin_name, current_migration_number, last_migration)"
+ +
+ " SELECT plugin_name, max(db_version), `timestamp` FROM db_version WHERE plugin_name = '"
+ + this.getName() + "' LIMIT 1;");) {
int rows = migrateInstall.executeUpdate();
if (rows == 1) {
NameLayerPlugin.log(Level.INFO, "Migration successful!");
} else {
Bukkit.shutdown();
- NameLayerPlugin.log(Level.SEVERE, "Migration failed; db_version exists but uncaptured. Could be version problem.");
+ NameLayerPlugin.log(Level.SEVERE,
+ "Migration failed; db_version exists but uncaptured. Could be version problem.");
return;
}
} catch (SQLException se) {
@@ -138,14 +142,14 @@ public class NameLayerPlugin extends ACivMod {
associations = new AssociationList(getLogger(), db);
associations.registerMigrations();
-
+
if (loadGroups) {
groupManagerDao = new GroupManagerDao(getLogger(), db);
groupManagerDao.registerMigrations();
NameLayerPlugin.log(Level.INFO, "Removing any cycles...");
groupManagerDao.removeCycles();
}
-
+
long begin_time = System.currentTimeMillis();
try {
@@ -159,56 +163,60 @@ public class NameLayerPlugin extends ACivMod {
Bukkit.shutdown();
}
- getLogger().log(Level.INFO, "Database update took {0} seconds", (System.currentTimeMillis() - begin_time) / 1000);
+ getLogger()
+ .log(Level.INFO, "Database update took {0} seconds", (System.currentTimeMillis() - begin_time) / 1000);
}
-
+
/**
* @return Returns the AssocationList.
*/
- public static AssociationList getAssociationList(){
+ public static AssociationList getAssociationList() {
return associations;
}
+
/**
* @return Returns the GroupManagerDatabase.
*/
- public static GroupManagerDao getGroupManagerDao(){
+ public static GroupManagerDao getGroupManagerDao() {
return groupManagerDao;
}
-
- public static void log(Level level, String message){
- if (level == Level.INFO)
+
+ public static void log(Level level, String message) {
+ if (level == Level.INFO) {
Bukkit.getLogger().log(level, "[NameLayer:] Info follows\n" +
- message);
- else if (level == Level.WARNING)
+ message);
+ } else if (level == Level.WARNING) {
Bukkit.getLogger().log(level, "[NameLayer:] Warning follows\n" +
message);
- else if (level == Level.SEVERE)
- Bukkit.getLogger().log(level, "[NameLayer:] Stack Trace follows\n --------------------------------------\n" +
- message +
- "\n --------------------------------------");
+ } else if (level == Level.SEVERE) {
+ Bukkit.getLogger()
+ .log(level, "[NameLayer:] Stack Trace follows\n --------------------------------------\n" +
+ message +
+ "\n --------------------------------------");
+ }
}
-
- public static String getSpecialAdminGroup(){
+
+ public static String getSpecialAdminGroup() {
return "Name_Layer_Special";
}
-
+
public static boolean createGroupOnFirstJoin() {
return createGroupOnFirstJoin;
}
- public int getGroupLimit(){
+ public int getGroupLimit() {
return groupLimit;
}
-
+
public static BlackList getBlackList() {
return blackList;
}
-
+
public static AutoAcceptHandler getAutoAcceptHandler() {
return autoAcceptHandler;
}
-
+
public static DefaultGroupHandler getDefaultGroupHandler() {
return defaultGroupHandler;
}