From 600ab0eea778b6ab559b212266314981131782ac Mon Sep 17 00:00:00 2001 From: nossr50 Date: Tue, 9 Jul 2024 12:13:50 -0700 Subject: [PATCH] SQL fixed player cooldowns being loaded incorrectly Fixes #5042 Fixes #5032 --- Changelog.txt | 3 ++ pom.xml | 2 +- .../nossr50/database/SQLDatabaseManager.java | 33 +++++++++++-------- .../nossr50/datatypes/player/McMMOPlayer.java | 9 +++-- .../datatypes/player/PlayerProfile.java | 5 ++- 5 files changed, 34 insertions(+), 18 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 1eba74a63..9ed224e00 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,3 +1,6 @@ +Version 2.2.016 + (SQL) Fixed a bug where skill cooldowns were being loaded for players incorrectly + Version 2.2.015 Added Maces skill Added Mace to repair.vanilla.yml (see notes) diff --git a/pom.xml b/pom.xml index 4d74477b7..55570efef 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.2.015 + 2.2.016-SNAPSHOT mcMMO https://github.com/mcMMO-Dev/mcMMO diff --git a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java index aef90e48c..a219b364b 100644 --- a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java @@ -1219,18 +1219,18 @@ public final class SQLDatabaseManager implements DatabaseManager { } private PlayerProfile loadFromResult(String playerName, ResultSet result) throws SQLException { - Map skills = new EnumMap<>(PrimarySkillType.class); // Skill & Level - Map skillsXp = new EnumMap<>(PrimarySkillType.class); // Skill & XP - Map skillsDATS = new EnumMap<>(SuperAbilityType.class); // Ability & Cooldown - Map uniqueData = new EnumMap<>(UniqueDataType.class); //Chimaera wing cooldown and other misc info + final Map skills = new EnumMap<>(PrimarySkillType.class); // Skill & Level + final Map skillsXp = new EnumMap<>(PrimarySkillType.class); // Skill & XP + final Map skillsDATS = new EnumMap<>(SuperAbilityType.class); // Ability & Cooldown + final Map uniqueData = new EnumMap<>(UniqueDataType.class); //Chimaera wing cooldown and other misc info UUID uuid; int scoreboardTipsShown; - final int OFFSET_SKILLS = 0; // TODO update these numbers when the query - // changes (a new skill is added) - final int OFFSET_XP = 16; - final int OFFSET_DATS = 29; - final int OFFSET_OTHER = 42; + final int SKILL_COLUMNS = 16; + final int OFFSET_SKILLS = 0; + final int OFFSET_XP = SKILL_COLUMNS; + final int OFFSET_DATS = OFFSET_XP + SKILL_COLUMNS; + final int OFFSET_OTHER = OFFSET_DATS + SKILL_COLUMNS; skills.put(PrimarySkillType.TAMING, result.getInt(OFFSET_SKILLS + 1)); skills.put(PrimarySkillType.MINING, result.getInt(OFFSET_SKILLS + 2)); @@ -1284,17 +1284,24 @@ public final class SQLDatabaseManager implements DatabaseManager { skillsDATS.put(SuperAbilityType.TRIDENTS_SUPER_ABILITY, result.getInt(OFFSET_DATS + 15)); skillsDATS.put(SuperAbilityType.MACES_SUPER_ABILITY, result.getInt(OFFSET_DATS + 16)); + // ORDER IS AS FOLLOWS + // MOB HEALTH BAR + // SCOREBOARD TIPS + // UUID + // USER + try { + // Mob Health bar is unused, so we add two + // TODO: Why even SELECT the mob health bar? + // Refactor later. scoreboardTipsShown = result.getInt(OFFSET_OTHER + 2); - } - catch (Exception e) { + } catch (Exception e) { scoreboardTipsShown = 0; } try { uuid = UUID.fromString(result.getString(OFFSET_OTHER + 3)); - } - catch (Exception e) { + } catch (Exception e) { uuid = null; } diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java index b8b20262c..c974930e0 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -1059,9 +1059,12 @@ public class McMMOPlayer implements Identified { } } - private void tooTiredMultiple(PrimarySkillType primarySkillType, SubSkillType aSubSkill, SuperAbilityType aSuperAbility, SubSkillType bSubSkill, SuperAbilityType bSuperAbility) { - String aSuperAbilityCD = LocaleLoader.getString("Skills.TooTired.Named", aSubSkill.getLocaleName(), String.valueOf(calculateTimeRemaining(aSuperAbility))); - String bSuperAbilityCD = LocaleLoader.getString("Skills.TooTired.Named", bSubSkill.getLocaleName(), String.valueOf(calculateTimeRemaining(bSuperAbility))); + private void tooTiredMultiple(PrimarySkillType primarySkillType, SubSkillType aSubSkill, + SuperAbilityType aSuperAbility, SubSkillType bSubSkill, SuperAbilityType bSuperAbility) { + String aSuperAbilityCD = LocaleLoader.getString("Skills.TooTired.Named", aSubSkill.getLocaleName(), + String.valueOf(calculateTimeRemaining(aSuperAbility))); + String bSuperAbilityCD = LocaleLoader.getString("Skills.TooTired.Named", bSubSkill.getLocaleName(), + String.valueOf(calculateTimeRemaining(bSuperAbility))); String allCDStr = aSuperAbilityCD + ", " + bSuperAbilityCD; NotificationManager.sendPlayerInformation(player, NotificationType.TOOL, "Skills.TooTired.Extra", diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java b/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java index 80f94427d..48578aae9 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java @@ -88,7 +88,10 @@ public class PlayerProfile { this.loaded = isLoaded; } - public PlayerProfile(@NotNull String playerName, @Nullable UUID uuid, Map levelData, Map xpData, Map cooldownData, int scoreboardTipsShown, Map uniqueProfileData, @Nullable Long lastLogin) { + public PlayerProfile(@NotNull String playerName, @Nullable UUID uuid, + Map levelData, Map xpData, + Map cooldownData, int scoreboardTipsShown, + Map uniqueProfileData, @Nullable Long lastLogin) { this.playerName = playerName; this.uuid = uuid; this.scoreboardTipsShown = scoreboardTipsShown;