Better format for profession exp placeholder

This commit is contained in:
Indyuce 2022-08-21 15:38:10 +02:00
parent fe12e07f37
commit 81a311f453
3 changed files with 47 additions and 68 deletions

View File

@ -13,6 +13,14 @@ public class MySQLDataProvider extends MMODataSource implements DataProvider {
private final MySQLPlayerDataManager playerManager = new MySQLPlayerDataManager(this);
private final YAMLGuildDataManager guildManager = new YAMLGuildDataManager();
private static final String[] NEW_COLUMNS = new String[]{
"times_claimed", "LONGTEXT",
"is_saved", "TINYINT",
"skill_reallocation_points", "INT(11)",
"skill_tree_reallocation_points", "INT(11)",
"skill_tree_points", "LONGTEXT",
"skill_tree_levels", "LONGTEXT"};
public MySQLDataProvider(FileConfiguration config) {
this.setup(config);
}
@ -21,72 +29,44 @@ public class MySQLDataProvider extends MMODataSource implements DataProvider {
public void load() {
// Fully create table
executeUpdateAsync(
"CREATE TABLE IF NOT EXISTS mmocore_playerdata(uuid VARCHAR(36),class_points "
+ "INT(11) DEFAULT 0,skill_points INT(11) DEFAULT 0,attribute_points INT(11) "
+ "DEFAULT 0,attribute_realloc_points INT(11) DEFAULT 0,skill_reallocation_points INT(11) DEFAULT 0,level INT(11) DEFAULT 1,"
+ "experience INT(11) DEFAULT 0,class VARCHAR(20),guild VARCHAR(20),last_login LONG,"
+ "attributes LONGTEXT,professions LONGTEXT,times_claimed LONGTEXT,quests LONGTEXT,"
+ "waypoints LONGTEXT,friends LONGTEXT,skills LONGTEXT,bound_skills LONGTEXT,"
+ "class_info LONGTEXT, is_saved TINYINT, PRIMARY KEY (uuid));");
executeUpdateAsync("CREATE TABLE IF NOT EXISTS mmocore_playerdata(uuid VARCHAR(36)," +
"class_points INT(11) DEFAULT 0," +
"skill_points INT(11) DEFAULT 0," +
"attribute_points INT(11) DEFAULT 0," +
"attribute_realloc_points INT(11) DEFAULT 0," +
"skill_reallocation_points INT(11) DEFAULT 0," +
"skill_tree_reallocation_points INT(11) DEFAULT 0," +
"skill_tree_points LONGTEXT," +
"skill_tree_levels LONGTEXT," +
"level INT(11) DEFAULT 1," +
"experience INT(11) DEFAULT 0," +
"class VARCHAR(20),guild VARCHAR(20)," +
"last_login LONG," +
"attributes LONGTEXT," +
"professions LONGTEXT," +
"times_claimed LONGTEXT," +
"quests LONGTEXT," +
"waypoints LONGTEXT," +
"friends LONGTEXT," +
"skills LONGTEXT," +
"bound_skills LONGTEXT," +
"class_info LONGTEXT," +
"is_saved TINYINT," +
"PRIMARY KEY (uuid));");
// Add 'times_claimed' if it doesn't exist
getResultAsync("SELECT * FROM information_schema.COLUMNS WHERE TABLE_NAME = 'mmocore_playerdata' AND COLUMN_NAME = 'times_claimed'", result -> {
try {
if (!result.next())
executeUpdateAsync("ALTER TABLE mmocore_playerdata ADD COLUMN times_claimed LONGTEXT");
} catch (SQLException exception) {
exception.printStackTrace();
}
});
// Add 'is_saved' if it doesn't exist
getResultAsync("SELECT * FROM information_schema.COLUMNS WHERE TABLE_NAME = 'mmocore_playerdata' AND COLUMN_NAME = 'is_saved'", result -> {
try {
if (!result.next())
executeUpdate("ALTER TABLE mmocore_playerdata ADD COLUMN is_saved TINYINT");
} catch (SQLException exception) {
exception.printStackTrace();
}
});
// Add 'skill_reallocation_points' if it doesn't exist
getResultAsync("SELECT * FROM information_schema.COLUMNS WHERE TABLE_NAME = 'mmocore_playerdata' AND COLUMN_NAME = 'skill_reallocation_points'", result -> {
try {
if (!result.next())
executeUpdate("ALTER TABLE mmocore_playerdata ADD COLUMN skill_reallocation_points INT(11)");
} catch (SQLException exception) {
exception.printStackTrace();
}
});
// Add 'skill_tree_reallocation_points' if it doesn't exist
getResultAsync("SELECT * FROM information_schema.COLUMNS WHERE TABLE_NAME = 'mmocore_playerdata' AND COLUMN_NAME = 'skill_tree_reallocation_points'", result -> {
try {
if (!result.next())
executeUpdate("ALTER TABLE mmocore_playerdata ADD COLUMN skill_tree_reallocation_points INT(11)");
} catch (SQLException exception) {
exception.printStackTrace();
}
});
// Add 'skill_tree_points' if it doesn't exist
getResultAsync("SELECT * FROM information_schema.COLUMNS WHERE TABLE_NAME = 'mmocore_playerdata' AND COLUMN_NAME = 'skill_tree_points'", result -> {
try {
if (!result.next())
executeUpdate("ALTER TABLE mmocore_playerdata ADD COLUMN skill_tree_points LONGTEXT");
} catch (SQLException exception) {
exception.printStackTrace();
}
});
// Add 'skill_tree_levels' if it doesn't exist
getResultAsync("SELECT * FROM information_schema.COLUMNS WHERE TABLE_NAME = 'mmocore_playerdata' AND COLUMN_NAME = 'skill_tree_levels'", result -> {
try {
if (!result.next())
executeUpdate("ALTER TABLE mmocore_playerdata ADD COLUMN skill_tree_levels LONGTEXT");
} catch (SQLException exception) {
exception.printStackTrace();
}
});
// Add columns that might not be here by default
for (int i = 0; i < NEW_COLUMNS.length; i += 2) {
final String columnName = NEW_COLUMNS[i];
final String dataType = NEW_COLUMNS[i + 1];
getResultAsync("SELECT * FROM information_schema.COLUMNS WHERE TABLE_NAME = 'mmocore_playerdata' AND COLUMN_NAME = '" + columnName + "'", result -> {
try {
if (!result.next())
executeUpdate("ALTER TABLE mmocore_playerdata ADD COLUMN " + columnName + " " + dataType);
} catch (SQLException exception) {
exception.printStackTrace();
}
});
}
}
@Override

View File

@ -35,7 +35,6 @@ default-playerdata:
attribute-points: 0
attribute-realloc-points: 0
# The list of all conditions which must be met for the
# BLOCK REGEN and BLOCK RESTRICTIONS to apply. Set to
# 'custom-mine-conditions: []' to disable custom mining entirely.
@ -91,7 +90,6 @@ skill-casting:
mode: SKILL_BAR
open: SWAP_HANDS
loot-chests:
# Time in seconds it takes for a loot chest to
@ -205,6 +203,7 @@ hotbar-swapping:
# in creative mode to enter casting mode
can-creative-cast: false
# Not implemented yet
ability-targeting-options:
# Prevent heals/buffs on players in a different guild

View File

@ -16,7 +16,7 @@
<description>Offer your players a brand new RPG experience!!</description>
<properties>
<revision>1.10.1-SNAPSHOT</revision>
<revision>1.10.3-SNAPSHOT</revision>
<downloadSources>false</downloadSources>
<downloadJavadocs>false</downloadJavadocs>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>