mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-04 22:16:22 +00:00
Optimise vanish checker and fix some migration bugs
This commit is contained in:
1 parent
f550bd69f0
commit
fe5c7b910a
2 files changed
+14
-4
No files matched your search
@@ -11,10 +11,8 @@ public class vanishChecker {
|
|||||||
for (MetadataValue meta : player.getMetadata("vanished")) {
|
for (MetadataValue meta : player.getMetadata("vanished")) {
|
||||||
if (meta.asBoolean()) return true;
|
if (meta.asBoolean()) return true;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -61,6 +61,9 @@ public class huskHomes1Migrator {
|
|||||||
FileConfiguration sourceConfig = loadConfiguration(new File(plugin.getDataFolder() + File.separator + "MigratedData" + File.separator + "OLD_config.yml"));
|
FileConfiguration sourceConfig = loadConfiguration(new File(plugin.getDataFolder() + File.separator + "MigratedData" + File.separator + "OLD_config.yml"));
|
||||||
Bukkit.getLogger().info("- Migrating config data -");
|
Bukkit.getLogger().info("- Migrating config data -");
|
||||||
try {
|
try {
|
||||||
|
plugin.getConfig().options().copyDefaults(true);
|
||||||
|
plugin.saveDefaultConfig();
|
||||||
|
|
||||||
// Transfer mySQL credentials
|
// Transfer mySQL credentials
|
||||||
plugin.getConfig().set("data_storage_options.storage_type", "mySQL");
|
plugin.getConfig().set("data_storage_options.storage_type", "mySQL");
|
||||||
plugin.getConfig().set("data_storage_options.mysql_credentials.host", sourceConfig.getString("host"));
|
plugin.getConfig().set("data_storage_options.mysql_credentials.host", sourceConfig.getString("host"));
|
||||||
@@ -69,6 +72,7 @@ public class huskHomes1Migrator {
|
|||||||
plugin.getConfig().set("data_storage_options.mysql_credentials.username", sourceConfig.getString("username"));
|
plugin.getConfig().set("data_storage_options.mysql_credentials.username", sourceConfig.getString("username"));
|
||||||
plugin.getConfig().set("data_storage_options.mysql_credentials.password", sourceConfig.getString("password"));
|
plugin.getConfig().set("data_storage_options.mysql_credentials.password", sourceConfig.getString("password"));
|
||||||
|
|
||||||
|
// Get tables to copy from
|
||||||
sourcePlayerTable = sourceConfig.getString("player_data_table");
|
sourcePlayerTable = sourceConfig.getString("player_data_table");
|
||||||
sourceHomeTable = sourceConfig.getString("home_data_table");
|
sourceHomeTable = sourceConfig.getString("home_data_table");
|
||||||
|
|
||||||
@@ -97,7 +101,7 @@ public class huskHomes1Migrator {
|
|||||||
// Transfer spawn command settings (and location if set)
|
// Transfer spawn command settings (and location if set)
|
||||||
plugin.getConfig().set("spawn_command.enabled", sourceConfig.getBoolean("do_spawn_command"));
|
plugin.getConfig().set("spawn_command.enabled", sourceConfig.getBoolean("do_spawn_command"));
|
||||||
if (sourceConfig.contains("spawn_world")) {
|
if (sourceConfig.contains("spawn_world")) {
|
||||||
plugin.getConfig().set("spawn_command.position.world", sourceConfig.getBoolean("spawn_world"));
|
plugin.getConfig().set("spawn_command.position.world", sourceConfig.getString("spawn_world"));
|
||||||
plugin.getConfig().set("spawn_command.position.x", sourceConfig.getDouble("spawn_x"));
|
plugin.getConfig().set("spawn_command.position.x", sourceConfig.getDouble("spawn_x"));
|
||||||
plugin.getConfig().set("spawn_command.position.y", sourceConfig.getDouble("spawn_y"));
|
plugin.getConfig().set("spawn_command.position.y", sourceConfig.getDouble("spawn_y"));
|
||||||
plugin.getConfig().set("spawn_command.position.z", sourceConfig.getDouble("spawn_z"));
|
plugin.getConfig().set("spawn_command.position.z", sourceConfig.getDouble("spawn_z"));
|
||||||
@@ -135,6 +139,7 @@ public class huskHomes1Migrator {
|
|||||||
|
|
||||||
public void migratePlayerData() {
|
public void migratePlayerData() {
|
||||||
// Migrate player data
|
// Migrate player data
|
||||||
|
Bukkit.getLogger().info("- Migrating Player Data -");
|
||||||
try {
|
try {
|
||||||
Connection connection = getConnection();
|
Connection connection = getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM " + sourcePlayerTable + ";");
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM " + sourcePlayerTable + ";");
|
||||||
@@ -144,6 +149,7 @@ public class huskHomes1Migrator {
|
|||||||
String username = resultSet.getString("USERNAME");
|
String username = resultSet.getString("USERNAME");
|
||||||
int homeSlots = resultSet.getInt("HOME_SLOTS");
|
int homeSlots = resultSet.getInt("HOME_SLOTS");
|
||||||
if (!dataManager.playerExists(uuid)) {
|
if (!dataManager.playerExists(uuid)) {
|
||||||
|
Bukkit.getLogger().info("> Migrating player data for \"" + username + "\"");
|
||||||
dataManager.createPlayer(uuid, username, homeSlots);
|
dataManager.createPlayer(uuid, username, homeSlots);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -151,11 +157,14 @@ public class huskHomes1Migrator {
|
|||||||
} catch (SQLException playerSQLException) {
|
} catch (SQLException playerSQLException) {
|
||||||
Bukkit.getLogger().info("A SQL exception occurred transferring player data! " + playerSQLException.getCause());
|
Bukkit.getLogger().info("A SQL exception occurred transferring player data! " + playerSQLException.getCause());
|
||||||
playerSQLException.printStackTrace();
|
playerSQLException.printStackTrace();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
Bukkit.getLogger().info("- Finished Migrating Player Data -");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void migrateHomeData() {
|
public void migrateHomeData() {
|
||||||
// Migrate player data
|
// Migrate player data
|
||||||
|
Bukkit.getLogger().info("- Migrating Set Home Data -");
|
||||||
try {
|
try {
|
||||||
Connection connection = getConnection();
|
Connection connection = getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM " + sourceHomeTable + ";");
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM " + sourceHomeTable + ";");
|
||||||
@@ -180,6 +189,7 @@ public class huskHomes1Migrator {
|
|||||||
|
|
||||||
// Add the home to the database
|
// Add the home to the database
|
||||||
if (!dataManager.homeExists(ownerUsername, name)) {
|
if (!dataManager.homeExists(ownerUsername, name)) {
|
||||||
|
Bukkit.getLogger().info("> Migrating home \"" + ownerUsername + "." + name + "\"");
|
||||||
Home home = new Home(teleportationPoint, ownerUsername, ownerUUID, name, description, isPublic);
|
Home home = new Home(teleportationPoint, ownerUsername, ownerUUID, name, description, isPublic);
|
||||||
dataManager.addHome(home, UUID.fromString(ownerUUID));
|
dataManager.addHome(home, UUID.fromString(ownerUUID));
|
||||||
}
|
}
|
||||||
@@ -189,6 +199,8 @@ public class huskHomes1Migrator {
|
|||||||
Bukkit.getLogger().info("A SQL exception occurred transferring home data! " + homeSQLException.getCause());
|
Bukkit.getLogger().info("A SQL exception occurred transferring home data! " + homeSQLException.getCause());
|
||||||
homeSQLException.printStackTrace();
|
homeSQLException.printStackTrace();
|
||||||
}
|
}
|
||||||
|
Bukkit.getLogger().info("- Finished Migrating Set Home Data -");
|
||||||
|
Bukkit.getLogger().info("-- Migration complete! --");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user