1
0
mirror of https://github.com/mcMMO-Dev/mcMMO.git synced 2025-04-02 09:46:24 +02:00

SQL fixed player cooldowns being loaded incorrectly Fixes Fixes

This commit is contained in:
nossr50 2024-07-09 12:13:50 -07:00
parent 940fb66652
commit 600ab0eea7
5 changed files with 34 additions and 18 deletions
Changelog.txtpom.xml
src/main/java/com/gmail/nossr50

@ -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 Version 2.2.015
Added Maces skill Added Maces skill
Added Mace to repair.vanilla.yml (see notes) Added Mace to repair.vanilla.yml (see notes)

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.nossr50.mcMMO</groupId> <groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId> <artifactId>mcMMO</artifactId>
<version>2.2.015</version> <version>2.2.016-SNAPSHOT</version>
<name>mcMMO</name> <name>mcMMO</name>
<url>https://github.com/mcMMO-Dev/mcMMO</url> <url>https://github.com/mcMMO-Dev/mcMMO</url>
<scm> <scm>

@ -1219,18 +1219,18 @@ public final class SQLDatabaseManager implements DatabaseManager {
} }
private PlayerProfile loadFromResult(String playerName, ResultSet result) throws SQLException { private PlayerProfile loadFromResult(String playerName, ResultSet result) throws SQLException {
Map<PrimarySkillType, Integer> skills = new EnumMap<>(PrimarySkillType.class); // Skill & Level final Map<PrimarySkillType, Integer> skills = new EnumMap<>(PrimarySkillType.class); // Skill & Level
Map<PrimarySkillType, Float> skillsXp = new EnumMap<>(PrimarySkillType.class); // Skill & XP final Map<PrimarySkillType, Float> skillsXp = new EnumMap<>(PrimarySkillType.class); // Skill & XP
Map<SuperAbilityType, Integer> skillsDATS = new EnumMap<>(SuperAbilityType.class); // Ability & Cooldown final Map<SuperAbilityType, Integer> skillsDATS = new EnumMap<>(SuperAbilityType.class); // Ability & Cooldown
Map<UniqueDataType, Integer> uniqueData = new EnumMap<>(UniqueDataType.class); //Chimaera wing cooldown and other misc info final Map<UniqueDataType, Integer> uniqueData = new EnumMap<>(UniqueDataType.class); //Chimaera wing cooldown and other misc info
UUID uuid; UUID uuid;
int scoreboardTipsShown; int scoreboardTipsShown;
final int OFFSET_SKILLS = 0; // TODO update these numbers when the query final int SKILL_COLUMNS = 16;
// changes (a new skill is added) final int OFFSET_SKILLS = 0;
final int OFFSET_XP = 16; final int OFFSET_XP = SKILL_COLUMNS;
final int OFFSET_DATS = 29; final int OFFSET_DATS = OFFSET_XP + SKILL_COLUMNS;
final int OFFSET_OTHER = 42; final int OFFSET_OTHER = OFFSET_DATS + SKILL_COLUMNS;
skills.put(PrimarySkillType.TAMING, result.getInt(OFFSET_SKILLS + 1)); skills.put(PrimarySkillType.TAMING, result.getInt(OFFSET_SKILLS + 1));
skills.put(PrimarySkillType.MINING, result.getInt(OFFSET_SKILLS + 2)); 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.TRIDENTS_SUPER_ABILITY, result.getInt(OFFSET_DATS + 15));
skillsDATS.put(SuperAbilityType.MACES_SUPER_ABILITY, result.getInt(OFFSET_DATS + 16)); skillsDATS.put(SuperAbilityType.MACES_SUPER_ABILITY, result.getInt(OFFSET_DATS + 16));
// ORDER IS AS FOLLOWS
// MOB HEALTH BAR
// SCOREBOARD TIPS
// UUID
// USER
try { 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); scoreboardTipsShown = result.getInt(OFFSET_OTHER + 2);
} } catch (Exception e) {
catch (Exception e) {
scoreboardTipsShown = 0; scoreboardTipsShown = 0;
} }
try { try {
uuid = UUID.fromString(result.getString(OFFSET_OTHER + 3)); uuid = UUID.fromString(result.getString(OFFSET_OTHER + 3));
} } catch (Exception e) {
catch (Exception e) {
uuid = null; uuid = null;
} }

@ -1059,9 +1059,12 @@ public class McMMOPlayer implements Identified {
} }
} }
private void tooTiredMultiple(PrimarySkillType primarySkillType, SubSkillType aSubSkill, SuperAbilityType aSuperAbility, SubSkillType bSubSkill, SuperAbilityType bSuperAbility) { private void tooTiredMultiple(PrimarySkillType primarySkillType, SubSkillType aSubSkill,
String aSuperAbilityCD = LocaleLoader.getString("Skills.TooTired.Named", aSubSkill.getLocaleName(), String.valueOf(calculateTimeRemaining(aSuperAbility))); SuperAbilityType aSuperAbility, SubSkillType bSubSkill, SuperAbilityType bSuperAbility) {
String bSuperAbilityCD = LocaleLoader.getString("Skills.TooTired.Named", bSubSkill.getLocaleName(), String.valueOf(calculateTimeRemaining(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; String allCDStr = aSuperAbilityCD + ", " + bSuperAbilityCD;
NotificationManager.sendPlayerInformation(player, NotificationType.TOOL, "Skills.TooTired.Extra", NotificationManager.sendPlayerInformation(player, NotificationType.TOOL, "Skills.TooTired.Extra",

@ -88,7 +88,10 @@ public class PlayerProfile {
this.loaded = isLoaded; this.loaded = isLoaded;
} }
public PlayerProfile(@NotNull String playerName, @Nullable UUID uuid, Map<PrimarySkillType, Integer> levelData, Map<PrimarySkillType, Float> xpData, Map<SuperAbilityType, Integer> cooldownData, int scoreboardTipsShown, Map<UniqueDataType, Integer> uniqueProfileData, @Nullable Long lastLogin) { public PlayerProfile(@NotNull String playerName, @Nullable UUID uuid,
Map<PrimarySkillType, Integer> levelData, Map<PrimarySkillType, Float> xpData,
Map<SuperAbilityType, Integer> cooldownData, int scoreboardTipsShown,
Map<UniqueDataType, Integer> uniqueProfileData, @Nullable Long lastLogin) {
this.playerName = playerName; this.playerName = playerName;
this.uuid = uuid; this.uuid = uuid;
this.scoreboardTipsShown = scoreboardTipsShown; this.scoreboardTipsShown = scoreboardTipsShown;