From 321684e5f65c9c8a5033f1e330f58fcf64dee63a Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sun, 19 May 2019 17:34:51 -0700 Subject: [PATCH 01/11] Fixed a bug where creative players could gain XP if they qualified for early game XP boosts --- Changelog.txt | 3 +++ pom.xml | 2 +- .../java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java | 5 ++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index de1efab67..5d6ae0dec 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,3 +1,6 @@ +Version 2.1.63 + Fixed a bug that caused creative mode players to gain XP when qualifying for early game XP boosts + Version 2.1.62 Added a new admin notification system, sensitive commands will print chat messages to "admins" (players with either Operator status or admin chat permission) Added a setting to disable the new admin notifications to config.yml 'General.AdminNotifications' (this will be more configurable in 2.2) diff --git a/pom.xml b/pom.xml index 9366ee06a..27908eafa 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.62 + 2.1.63-SNAPSHOT mcMMO https://github.com/mcMMO-Dev/mcMMO 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 7cc518a51..68b1d911c 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -495,6 +495,9 @@ public class McMMOPlayer { * @param xp Experience amount to process */ public void beginUnsharedXpGain(PrimarySkillType skill, float xp, XPGainReason xpGainReason, XPGainSource xpGainSource) { + if(player.getGameMode() == GameMode.CREATIVE) + return; + applyXpGain(skill, modifyXpGain(skill, xp), xpGainReason, xpGainSource); if (party == null) { @@ -750,7 +753,7 @@ public class McMMOPlayer { * @return Modified experience */ private float modifyXpGain(PrimarySkillType primarySkillType, float xp) { - if (player.getGameMode() == GameMode.CREATIVE || (primarySkillType.getMaxLevel() <= getSkillLevel(primarySkillType)) || (Config.getInstance().getPowerLevelCap() <= getPowerLevel())) { + if ((primarySkillType.getMaxLevel() <= getSkillLevel(primarySkillType)) || (Config.getInstance().getPowerLevelCap() <= getPowerLevel())) { return 0; } From 8cd39301a3939c106e731e833ff7d005cf8d40b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20Marczink=C3=B3?= Date: Tue, 21 May 2019 19:11:28 +0200 Subject: [PATCH 02/11] Update locale_hu_HU.properties --- .../resources/locale/locale_hu_HU.properties | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/main/resources/locale/locale_hu_HU.properties b/src/main/resources/locale/locale_hu_HU.properties index d898e423e..0ae38bbdd 100644 --- a/src/main/resources/locale/locale_hu_HU.properties +++ b/src/main/resources/locale/locale_hu_HU.properties @@ -223,10 +223,10 @@ Excavation.Skills.GigaDrillBreaker.Refresh=[[GREEN]]A [[YELLOW]]Giga F\u00FAr\u0 Excavation.Skills.GigaDrillBreaker.Other.Off=Giga F\u00FAr\u00F3-T\u00F6r\u0151[[GREEN]] kikapcsolva: [[YELLOW]]{0} Excavation.Skills.GigaDrillBreaker.Other.On=[[GREEN]]{0}[[DARK_GREEN]] haszn\u00E1lta a [[RED]]Giga F\u00FAr\u00F3-T\u00F6r\u0151 [[DARK_GREEN]]k\u00E9pess\u00E9get! #FISHING -Fishing.Scarcity=[[YELLOW]]&oEz a ter\u00FClet t\u00FAlhal\u00E1szott. Pr\u00F3b\u00E1lj meg \u00FAj ter\u00FCleten hal\u00E1szni. +Fishing.ScarcityTip=[[YELLOW]]&oEz a ter\u00FClet t\u00FAlhal\u00E1szott. Horg\u00E1ssz egy m\u00E1sik helyen, ha t\u00F6bb halat szeretn\u00E9l. Legal\u00E1bb {0} blokknyira. Fishing.Scared=[[GRAY]]&oA Zavaros mozg\u00E1sok megijesztik a halakat! Fishing.Exhausting=[[RED]]&oA horg\u00E1szbot helytelen haszn\u00E1lata f\u00E1radts\u00E1got okoz, \u00E9s elhaszn\u00E1l\u00F3dik a r\u00FAd! -Fishing.LowResources=[[GRAY]]\u00DAgy \u00E9rzem nem sok hal maradt ezen a ter\u00FCleten. +Fishing.LowResourcesTip=[[GRAY]]\u00DAgy \u00E9rzem nem sok hal maradt ezen a ter\u00FCleten. Pr\u00F3b\u00E1lj meg horg\u00E1szni legal\u00E1bb {0} blokknyira. Fishing.Ability.Info=M\u00E1gikus Vad\u00E1sz: [[GRAY]] **A Kincsvad\u00E1sz Szinttel Egy\u00FCtt Fejl\u0151dik** Fishing.Ability.Locked.0=LEZ\u00C1RVA {0}+ K\u00C9PESS\u00C9G SZINTIG (R\u00C1Z\u00C1S) Fishing.Ability.Locked.1=LEZ\u00C1RVA {0}+ K\u00C9PESS\u00C9G SZINTIG (J\u00C9G HORG\u00C1SZAT) @@ -395,7 +395,7 @@ Anvil.Unbreakable=Ez a t\u00E1rgy t\u00F6rhetetlen! #SWORDS Swords.Ability.Lower=[[GRAY]]Leengeded a kardod. Swords.Ability.Ready=[[GOLD]]El\u0151k\u00E9sz\u00EDted[[DARK_AQUA]] a kardod. -Swords.Combat.Bleed.Note=[[GRAY]]Megj.: [[YELLOW]]1 Tick t\u00F6rt\u00E9nik minden 0,5 m\u00E1sodpercenk\u00E9nt +Swords.Combat.Rupture.Note=[[GRAY]]MEGJ.: [[YELLOW]]1 Tick t\u00F6rt\u00E9nik minden 0,5 m\u00E1sodpercenk\u00E9nt Swords.Combat.Bleeding.Started=[[DARK_RED]] V\u00E9rzel! Swords.Combat.Bleeding.Stopped=[[GRAY]]A v\u00E9rz\u00E9s [[GREEN]]el\u00E1llt[[GRAY]]! Swords.Combat.Bleeding=[[GREEN]]**AZ ELLENS\u00C9G V\u00C9RZIK** @@ -826,7 +826,18 @@ Commands.Event.Stop.Subtitle=[[GREEN]]Rem\u00E9lem j\u00F3l \u00E9rezted magad! Commands.Event.XP=[[DARK_AQUA]]Az XP szorz\u00F3 [[GOLD]]{0}[[DARK_AQUA]]x! Commands.xprate.started.0=[[GOLD]]mcMMO XP szorz\u00F3 esem\u00E9ny kezd\u0151d\u00F6tt! Commands.xprate.started.1=[[GOLD]]mcMMO XP Ar\u00E1nya most: {0}x! -XPRate.Event= [[GOLD]]mcMMO XP szorz\u00F3 esem\u00E9ny! XP ar\u00E1nya {0}x! + +# Admin Notifications +Server.ConsoleName=[[YELLOW]][Szerver] +Notifications.Admin.XPRate.Start.Self=[[GRAY]]Be\u00E1ll\u00EDtottad a glob\u00E1lis XP szorz\u00F3t erre [[GOLD]]{0}x +Notifications.Admin.XPRate.End.Self=[[GRAY]]Megszak\u00EDtottad az XP szorz\u00F3 eventet. +Notifications.Admin.XPRate.End.Others={0} [[GRAY]]megszak\u00EDtotta az XP szorz\u00F3 eventet. +Notifications.Admin.XPRate.Start.Others={0} [[GRAY]]elind\u00EDtotta vagy m\u00F3dos\u00EDtotta az XP szorz\u00F3 eventet glob\u00E1lis {1}x szorz\u00F3val +Notifications.Admin.Format.Others=[[GOLD]]([[GREEN]]mcMMO [[DARK_AQUA]]Admin[[GOLD]]) [[GRAY]]{0} +Notifications.Admin.Format.Self=[[GOLD]]([[GREEN]]mcMMO[[GOLD]]) [[GRAY]]{0} + +# Event +XPRate.Event= [[GOLD]]mcMMO XP szorz\u00F3 event! Az XP ar\u00E1nya {0}x! #GUIDES Guides.Available=[[GRAY]]A {0} seg\u00EDts\u00E9g el\u00E9rhet\u0151 - haszn\u00E1lat: /{1} ? [oldal] @@ -1070,8 +1081,8 @@ Scoreboard.Misc.Ability=K\u00E9pess\u00E9g #DATABASE RECOVERY Profile.PendingLoad=[[RED]]Az mcMMO j\u00E1t\u00E9kos adatod m\u00E9g nincs bet\u00F6ltve. Profile.Loading.Success=[[GREEN]]mcMMO profil sikeresen bet\u00F6ltve. -Profile.Loading.Failure=[[RED]]Az mcMMO nem tudja bet\u00F6lteni az adataidat. Besz\u00E9lj a [[AQUA]]szerver tulajdonossal.\n[[YELLOW]]\u00CDgy is tudsz j\u00E1tszani a szerveren, [[BOLD]]de nem lesz mcMMO szinted[[YELLOW]] \u00E9s ami XP-t szerzel [[BOLD]]mentetlen\u00FCl marad[[YELLOW]]. -Profile.Loading.AdminFailureNotice=[[DARK_RED]][A][[RED]]Az mcMMO nem tudta bet\u00F6lteni [[YELLOW]]{0}[[RED]] adatait. [[LIGHT_PURPLE]]K\u00E9rlek n\u00E9zd \u00E1t az adatb\u00E1zisod. +Profile.Loading.FailurePlayer=[[RED]]Az mcMMO-nak probl\u00E9m\u00E1i vannak az adataid bet\u00F6lt\u00E9sekor, megpr\u00F3b\u00E1ltuk bet\u00F6lteni [[GREEN]]{0}[[RED]]x.[[LIGHT_GRAY]] Ezzel kapcsolatban \u00E9rdemes kapcsolatba l\u00E9pni a szerver adminisztr\u00E1torokkal. Az mcMMO megpr\u00F3b\u00E1lja bet\u00F6lteni az adatait mindaddig, am\u00EDg nem kapcsol\u00F3dsz le. Nem kapsz XP-t, \u00E9s nem tudod haszn\u00E1lni a k\u00E9pess\u00E9geket, am\u00EDg az adataid nem t\u00F6lt\u0151dnek be. +Profile.Loading.FailureNotice=[[DARK_RED]][A][[RED]] az mcMMO nem tudta bet\u00F6lteni ennek a j\u00E1t\u00E9kosnak az adatait [[YELLOW]]{0}[[RED]]. [[LIGHT_PURPLE]]K\u00E9rj\u00FCk, ellen\u0151rizd az adatb\u00E1zis be\u00E1ll\u00EDt\u00E1sait. Eddig tett k\u00EDs\u00E9rletek {1}. #Holiday Holiday.AprilFools.Levelup=[[GOLD]]{0} jelenlegi szint [[GREEN]]{1}[[GOLD]]! Holiday.Anniversary=[[BLUE]]Boldog {0}. \u00C9vfordul\u00F3t!\n[[BLUE]]nossr50, \u00E9s az \u00F6sszes fejleszt\u0151 tisztelet\u00E9re itt egy t\u0171zij\u00E1t\u00E9k show! From bfb48ccea3f6eb410c732d0ef3b0bd2b28e22ffa Mon Sep 17 00:00:00 2001 From: nossr50 Date: Tue, 21 May 2019 13:13:17 -0700 Subject: [PATCH 03/11] Buffed Impact durability damage and fixed it --- Changelog.txt | 9 +++++++++ .../gmail/nossr50/config/AdvancedConfig.java | 19 +------------------ .../com/gmail/nossr50/skills/axes/Axes.java | 2 -- .../nossr50/skills/axes/AxesManager.java | 9 +++++---- .../gmail/nossr50/util/skills/SkillUtils.java | 2 +- src/main/resources/advanced.yml | 5 ++--- 6 files changed, 18 insertions(+), 28 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 5d6ae0dec..1c8cb80c8 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,5 +1,14 @@ Version 2.1.63 + Fixed Armor Impact not scaling by skill rank + Significantly Buffed the amount of durability damage incurred by a successful Armor Impact + Added new setting to advanced.yml 'Skills.Axes.ArmorImpact.DamagePerRank' which is multiplied against Armor Impact's skill level to determine damage done to armor Fixed a bug that caused creative mode players to gain XP when qualifying for early game XP boosts + Removed the damage cap setting for Armor Impact, it is inherently capped now based on its max rank and damage setting + + NOTES: + Armor Impact only has a 25% chance to go off, and for it to only incur 20 durability damage seemed incredibly underwhelming, I've buffed it quite a bit. + You can change it back to its underwhelming self by setting DamagePerRank to 1.0 + Based on feedback I may tweak the number again or other properties of this skill Version 2.1.62 Added a new admin notification system, sensitive commands will print chat messages to "admins" (players with either Operator status or admin chat permission) diff --git a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java index aff6e7ae7..fe9a9f46f 100644 --- a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java +++ b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java @@ -164,18 +164,10 @@ public class AdvancedConfig extends AutoUpdateConfigLoader { reason.add("Skills.Axes.GreaterImpact.BonusDamage should be at least 1!"); } - if (getArmorImpactIncreaseLevel() < 1) { - reason.add("Skills.Axes.ArmorImpact.IncreaseLevel should be at least 1!"); - } - if (getImpactChance() < 1) { reason.add("Skills.Axes.ArmorImpact.Chance should be at least 1!"); } - if (getArmorImpactMaxDurabilityDamage() < 1) { - reason.add("Skills.Axes.ArmorImpact.MaxPercentageDurabilityDamage should be at least 1!"); - } - if (getSkullSplitterModifier() < 1) { reason.add("Skills.Axes.SkullSplitter.DamageModifier should be at least 1!"); } @@ -871,17 +863,8 @@ public class AdvancedConfig extends AutoUpdateConfigLoader { public double getGreaterImpactModifier() { return config.getDouble("Skills.Axes.GreaterImpact.KnockbackModifier", 1.5D); } public double getGreaterImpactBonusDamage() { return config.getDouble("Skills.Axes.GreaterImpact.BonusDamage", 2.0D); } - public int getArmorImpactIncreaseLevel() { - int increaseLevel = config.getInt("Skills.Axes.ArmorImpact.IncreaseLevel", 5); - - if(mcMMO.isRetroModeEnabled()) - return increaseLevel * 10; - - return increaseLevel; - } - public double getImpactChance() { return config.getDouble("Skills.Axes.ArmorImpact.Chance", 25.0D); } - public double getArmorImpactMaxDurabilityDamage() { return config.getDouble("Skills.Axes.ArmorImpact.MaxPercentageDurabilityDamage", 20.0D); } + public double getImpactDurabilityDamageMultiplier() { return config.getDouble("Skills.Axes.ArmorImpact.DamagePerRank", 6.5D); } public double getSkullSplitterModifier() { return config.getDouble("Skills.Axes.SkullSplitter.DamageModifier", 2.0D); } diff --git a/src/main/java/com/gmail/nossr50/skills/axes/Axes.java b/src/main/java/com/gmail/nossr50/skills/axes/Axes.java index 2dd7e0e29..939d175bd 100644 --- a/src/main/java/com/gmail/nossr50/skills/axes/Axes.java +++ b/src/main/java/com/gmail/nossr50/skills/axes/Axes.java @@ -14,9 +14,7 @@ public class Axes { public static double criticalHitPVPModifier = AdvancedConfig.getInstance().getCriticalStrikesPVPModifier(); public static double criticalHitPVEModifier = AdvancedConfig.getInstance().getCriticalStrikesPVEModifier(); - public static int impactIncreaseLevel = AdvancedConfig.getInstance().getArmorImpactIncreaseLevel(); public static double impactChance = AdvancedConfig.getInstance().getImpactChance(); - public static double impactMaxDurabilityModifier = AdvancedConfig.getInstance().getArmorImpactMaxDurabilityDamage() / 100D; public static double greaterImpactBonusDamage = AdvancedConfig.getInstance().getGreaterImpactBonusDamage(); public static double greaterImpactChance = AdvancedConfig.getInstance().getGreaterImpactChance(); diff --git a/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java b/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java index 2346faa9c..5cdad3a57 100644 --- a/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java +++ b/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java @@ -1,5 +1,6 @@ package com.gmail.nossr50.skills.axes; +import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; @@ -113,19 +114,19 @@ public class AxesManager extends SkillManager { * @param target The {@link LivingEntity} being affected by Impact */ public void impactCheck(LivingEntity target) { - int durabilityDamage = getImpactDurabilityDamage(); + double durabilityDamage = getImpactDurabilityDamage(); for (ItemStack armor : target.getEquipment().getArmorContents()) { if (armor != null && ItemUtils.isArmor(armor)) { if (RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_STATIC_CHANCE, SubSkillType.AXES_ARMOR_IMPACT, getPlayer())) { - SkillUtils.handleDurabilityChange(armor, durabilityDamage, Axes.impactMaxDurabilityModifier); + SkillUtils.handleDurabilityChange(armor, durabilityDamage, 1); } } } } - public int getImpactDurabilityDamage() { - return 1 + (getSkillLevel() / Axes.impactIncreaseLevel); + public double getImpactDurabilityDamage() { + return AdvancedConfig.getInstance().getImpactDurabilityDamageMultiplier() * RankUtils.getRank(getPlayer(), SubSkillType.AXES_ARMOR_IMPACT); } /** diff --git a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java index da495346f..d9d345694 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java @@ -240,7 +240,7 @@ public class SkillUtils { * @param durabilityModifier the amount to modify the durability by * @param maxDamageModifier the amount to adjust the max damage by */ - public static void handleDurabilityChange(ItemStack itemStack, int durabilityModifier, double maxDamageModifier) { + public static void handleDurabilityChange(ItemStack itemStack, double durabilityModifier, double maxDamageModifier) { if (itemStack.hasItemMeta() && itemStack.getItemMeta().isUnbreakable()) { return; } diff --git a/src/main/resources/advanced.yml b/src/main/resources/advanced.yml index bd651b3ba..6e528e90f 100644 --- a/src/main/resources/advanced.yml +++ b/src/main/resources/advanced.yml @@ -186,13 +186,12 @@ Skills: BonusDamage: 2.0 ArmorImpact: + # Multiplied against the skill rank to determine how much damage to do + DamagePerRank: 6.5 # IncreaseLevel: Every the durability damage goes up with 1 # Chance: Chance of hitting with ArmorImpact # MaxPercentageDurabilityDamage: Durability damage cap for ArmorImpact, 20% means that you can never destroy a piece of armor in less than 5 hits - IncreaseLevel: 5 Chance: 25.0 - MaxPercentageDurabilityDamage: 20.0 - SkullSplitter: # DamageModifier: Damage will get divided by this modifier DamageModifier: 2.0 From ce230bf403fb568c2a421d9ab89cbb987af79fde Mon Sep 17 00:00:00 2001 From: nossr50 Date: Tue, 21 May 2019 13:28:22 -0700 Subject: [PATCH 04/11] 2.1.63 --- Changelog.txt | 1 + pom.xml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index 1c8cb80c8..a49cc433f 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -4,6 +4,7 @@ Version 2.1.63 Added new setting to advanced.yml 'Skills.Axes.ArmorImpact.DamagePerRank' which is multiplied against Armor Impact's skill level to determine damage done to armor Fixed a bug that caused creative mode players to gain XP when qualifying for early game XP boosts Removed the damage cap setting for Armor Impact, it is inherently capped now based on its max rank and damage setting + Updated hu_HU locale (thanks andris155) NOTES: Armor Impact only has a 25% chance to go off, and for it to only incur 20 durability damage seemed incredibly underwhelming, I've buffed it quite a bit. diff --git a/pom.xml b/pom.xml index 27908eafa..6670f853a 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.63-SNAPSHOT + 2.1.63 mcMMO https://github.com/mcMMO-Dev/mcMMO From 33dd34931c898be6699dc7680ecdf81ba71a94ea Mon Sep 17 00:00:00 2001 From: nossr50 Date: Tue, 21 May 2019 15:24:45 -0700 Subject: [PATCH 05/11] Add missing credits to snake for ja_JP --- Changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Changelog.txt b/Changelog.txt index a49cc433f..188e1f93b 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -5,6 +5,7 @@ Version 2.1.63 Fixed a bug that caused creative mode players to gain XP when qualifying for early game XP boosts Removed the damage cap setting for Armor Impact, it is inherently capped now based on its max rank and damage setting Updated hu_HU locale (thanks andris155) + Updated ja_JP locale (thanks snake) NOTES: Armor Impact only has a 25% chance to go off, and for it to only incur 20 durability damage seemed incredibly underwhelming, I've buffed it quite a bit. From 50e4e971d96f2e215f5de7a224d2b5831dd0e3e3 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Mon, 27 May 2019 17:37:54 -0700 Subject: [PATCH 06/11] Standard level scaling now mirrors RetroMode in a true 1:10 parity --- Changelog.txt | 8 ++ pom.xml | 4 +- .../com/gmail/nossr50/api/ExperienceAPI.java | 21 +++- .../gmail/nossr50/datatypes/party/Party.java | 2 +- .../datatypes/player/PlayerProfile.java | 2 +- .../datatypes/skills/PrimarySkillType.java | 12 +- .../util/experience/FormulaManager.java | 118 ++++++++++++++---- 7 files changed, 130 insertions(+), 37 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 188e1f93b..14c4c9b61 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,3 +1,11 @@ +Version 2.1.64 + (API) method to get XP in FormulaManager has been renamed to getXPtoNextLevel(...), this shouldn't break anything as plugins should be using our Experience API methods instead of this + (API) Added method getLevel(Player player, PrimarySkillType primarySkillType) to ExperienceAPI.java + Corrected how Standard mode (1-100 scaling) XP to next level was calculated, it is now a true 1:10 ratio with Retro (1-1000) scale, which is how it was intended to be to begin with + + NOTE: The net result of this change is it will take a bit longer to level with Standard, but it should not be a drastic change. You might not even notice it. + Standard is meant to take the same amount of time to level from levels 1-100 as it takes Retro to do 1-1000, this change corrects from errors in the code that made Standard actually take less XP than Retro despite intending for it to be a cosmetic difference in progression. + Version 2.1.63 Fixed Armor Impact not scaling by skill rank Significantly Buffed the amount of durability damage incurred by a successful Armor Impact diff --git a/pom.xml b/pom.xml index 6670f853a..d7cd7c2de 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.63 + 2.1.64-SNAPSHOT mcMMO https://github.com/mcMMO-Dev/mcMMO @@ -167,7 +167,7 @@ org.spigotmc spigot-api - 1.14.1-R0.1-SNAPSHOT + 1.14.2-R0.1-SNAPSHOT provided diff --git a/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java b/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java index 93eaef9a3..e018a4cc2 100644 --- a/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java +++ b/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java @@ -649,11 +649,28 @@ public final class ExperienceAPI { * @return the level of a given skill * * @throws InvalidSkillException if the given skill is not valid + * @deprecated Use getLevel(Player player, PrimarySkillType skillType) instead */ + @Deprecated public static int getLevel(Player player, String skillType) { return getPlayer(player).getSkillLevel(getSkillType(skillType)); } + /** + * Get the level a player has in a specific skill. + *
+ * This function is designed for API usage. + * + * @param player The player to get the level for + * @param skillType The skill to get the level for + * @return the level of a given skill + * + * @throws InvalidSkillException if the given skill is not valid + */ + public static int getLevel(Player player, PrimarySkillType skillType) { + return getPlayer(player).getSkillLevel(skillType); + } + /** * Get the level an offline player has in a specific skill. *
@@ -995,7 +1012,7 @@ public final class ExperienceAPI { * @throws InvalidFormulaTypeException if the given formulaType is not valid */ public static int getXpNeededToLevel(int level) { - return mcMMO.getFormulaManager().getCachedXpToLevel(level, ExperienceConfig.getInstance().getFormulaType()); + return mcMMO.getFormulaManager().getXPtoNextLevel(level, ExperienceConfig.getInstance().getFormulaType()); } /** @@ -1009,7 +1026,7 @@ public final class ExperienceAPI { * @throws InvalidFormulaTypeException if the given formulaType is not valid */ public static int getXpNeededToLevel(int level, String formulaType) { - return mcMMO.getFormulaManager().getCachedXpToLevel(level, getFormulaType(formulaType)); + return mcMMO.getFormulaManager().getXPtoNextLevel(level, getFormulaType(formulaType)); } /** diff --git a/src/main/java/com/gmail/nossr50/datatypes/party/Party.java b/src/main/java/com/gmail/nossr50/datatypes/party/Party.java index f30d8b0a1..6629adc2d 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/party/Party.java +++ b/src/main/java/com/gmail/nossr50/datatypes/party/Party.java @@ -203,7 +203,7 @@ public class Party { public int getXpToLevel() { FormulaType formulaType = ExperienceConfig.getInstance().getFormulaType(); - return (mcMMO.getFormulaManager().getCachedXpToLevel(level, formulaType)) * (getOnlineMembers().size() + Config.getInstance().getPartyXpCurveMultiplier()); + return (mcMMO.getFormulaManager().getXPtoNextLevel(level, formulaType)) * (getOnlineMembers().size() + Config.getInstance().getPartyXpCurveMultiplier()); } public String getXpToLevelPercentage() { 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 f71ceeca1..b2b0f7803 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java @@ -397,7 +397,7 @@ public class PlayerProfile { int level = (ExperienceConfig.getInstance().getCumulativeCurveEnabled()) ? UserManager.getPlayer(playerName).getPowerLevel() : skills.get(primarySkillType); FormulaType formulaType = ExperienceConfig.getInstance().getFormulaType(); - return mcMMO.getFormulaManager().getCachedXpToLevel(level, formulaType); + return mcMMO.getFormulaManager().getXPtoNextLevel(level, formulaType); } private int getChildSkillLevel(PrimarySkillType primarySkillType) { diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/PrimarySkillType.java b/src/main/java/com/gmail/nossr50/datatypes/skills/PrimarySkillType.java index 85f29d893..c756017bf 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/PrimarySkillType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/PrimarySkillType.java @@ -66,7 +66,7 @@ public enum PrimarySkillType { ImmutableList.of(SubSkillType.WOODCUTTING_LEAF_BLOWER, SubSkillType.WOODCUTTING_TREE_FELLER, SubSkillType.WOODCUTTING_HARVEST_LUMBER)); private Class managerClass; - private Color runescapeColor; + private Color skillColor; private SuperAbilityType ability; private ToolType tool; private List subSkillTypes; @@ -110,13 +110,13 @@ public enum PrimarySkillType { NON_CHILD_SKILLS = ImmutableList.copyOf(nonChildSkills); } - private PrimarySkillType(Class managerClass, Color runescapeColor, List subSkillTypes) { - this(managerClass, runescapeColor, null, null, subSkillTypes); + private PrimarySkillType(Class managerClass, Color skillColor, List subSkillTypes) { + this(managerClass, skillColor, null, null, subSkillTypes); } - private PrimarySkillType(Class managerClass, Color runescapeColor, SuperAbilityType ability, ToolType tool, List subSkillTypes) { + private PrimarySkillType(Class managerClass, Color skillColor, SuperAbilityType ability, ToolType tool, List subSkillTypes) { this.managerClass = managerClass; - this.runescapeColor = runescapeColor; + this.skillColor = skillColor; this.ability = ability; this.tool = tool; this.subSkillTypes = subSkillTypes; @@ -243,7 +243,7 @@ public enum PrimarySkillType { } /* public void celebrateLevelUp(Player player) { - ParticleEffectUtils.fireworkParticleShower(player, runescapeColor); + ParticleEffectUtils.fireworkParticleShower(player, skillColor); }*/ public boolean shouldProcess(Entity target) { diff --git a/src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java b/src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java index ad2145f05..5d770be6d 100644 --- a/src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java +++ b/src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java @@ -15,8 +15,10 @@ public class FormulaManager { private static File formulaFile = new File(mcMMO.getFlatFileDirectory() + "formula.yml"); // Experience needed to reach a level, cached values to improve conversion speed - private final Map experienceNeededLinear = new HashMap(); - private final Map experienceNeededExponential = new HashMap(); + private Map experienceNeededRetroLinear; + private Map experienceNeededStandardLinear; + private Map experienceNeededRetroExponential; + private Map experienceNeededStandardExponential; private FormulaType previousFormula; @@ -26,9 +28,20 @@ public class FormulaManager { public FormulaManager() { /* Setting for Classic Mode (Scales a lot of stuff up by * 10) */ retroModeEnabled = Config.getInstance().getIsRetroMode(); + initExperienceNeededMaps(); loadFormula(); } + /** + * Initialize maps used for XP to next level + */ + private void initExperienceNeededMaps() { + experienceNeededRetroLinear = new HashMap<>(); + experienceNeededRetroExponential = new HashMap<>(); + experienceNeededStandardLinear = new HashMap<>(); + experienceNeededStandardExponential = new HashMap<>(); + } + /** * Get the formula type that was used before converting * @@ -60,7 +73,7 @@ public class FormulaManager { int totalXP = 0; for (int level = 0; level < skillLevel; level++) { - totalXP += getCachedXpToLevel(level, previousFormula); + totalXP += getXPtoNextLevel(level, previousFormula); } totalXP += skillXPLevel; @@ -83,7 +96,7 @@ public class FormulaManager { int maxLevel = Config.getInstance().getLevelCap(primarySkillType); while (experience > 0 && newLevel < maxLevel) { - int experienceToNextLevel = getCachedXpToLevel(newLevel, formulaType); + int experienceToNextLevel = getXPtoNextLevel(newLevel, formulaType); if (experience - experienceToNextLevel < 0) { remainder = experience; @@ -106,42 +119,97 @@ public class FormulaManager { * @param formulaType The {@link FormulaType} used * @return amount of experience needed to reach next level */ - public int getCachedXpToLevel(int level, FormulaType formulaType) { - int experience; - + public int getXPtoNextLevel(int level, FormulaType formulaType) { /** * Retro mode XP requirements are the default requirements * Standard mode XP requirements are multiplied by a factor of 10 */ - int xpNeededMultiplier = retroModeEnabled ? 1 : 10; + //TODO: When the heck is Unknown used? if (formulaType == FormulaType.UNKNOWN) { formulaType = FormulaType.LINEAR; } + return processXPToNextLevel(level, formulaType); + } + + /** + * Gets the value of XP needed for the next level based on the level Scaling, the level, and the formula type + * @param level target level + * @param formulaType target formulaType + */ + private int processXPToNextLevel(int level, FormulaType formulaType) { + if(mcMMO.isRetroModeEnabled()) + { + return processXPRetroToNextLevel(level, formulaType); + } else { + return processStandardXPToNextLevel(level, formulaType); + } + } + + /** + * Calculate the XP needed for the next level for the linear formula for Standard scaling (1-100) + * @param level target level + * @return raw xp needed to reach the next level + */ + private int processStandardXPToNextLevel(int level, FormulaType formulaType) { + Map experienceMapRef = formulaType == FormulaType.LINEAR ? experienceNeededStandardLinear : experienceNeededStandardExponential; + + if(!experienceMapRef.containsKey(level)) { + int experienceSum = 0; + int retroIndex = (level * 10) + 1; + + //Sum the range of levels in Retro that this Standard level would represent + for(int x = retroIndex; x < (retroIndex + 10); x++) { + //calculateXPNeeded doesn't cache results so we use that instead of invoking the Retro XP methods to avoid memory bloat + experienceSum += calculateXPNeeded(x, formulaType); + } + + experienceMapRef.put(level, experienceSum); + } + + return experienceMapRef.get(level); + } + + /** + * Calculates the XP to next level for Retro Mode scaling + * Results are cached to reduce needless operations + * @param level target level + * @param formulaType target formula type + * @return raw xp needed to reach the next level based on formula type + */ + private int processXPRetroToNextLevel(int level, FormulaType formulaType) { + Map experienceMapRef = formulaType == FormulaType.LINEAR ? experienceNeededRetroLinear : experienceNeededRetroExponential; + + if (!experienceMapRef.containsKey(level)) { + int experience = calculateXPNeeded(level, FormulaType.LINEAR); + experienceMapRef.put(level, experience); + } + + return experienceMapRef.get(level); + } + + /** + * Does the actual math to get the XP needed for a level in RetroMode scaling + * Standard uses a sum of RetroMode XP needed levels for its own thing, so it uses this too + * @param level target level + * @param formulaType target formulatype + * @return the raw XP needed for the next level based on formula type + */ + private int calculateXPNeeded(int level, FormulaType formulaType) { int base = ExperienceConfig.getInstance().getBase(formulaType); double multiplier = ExperienceConfig.getInstance().getMultiplier(formulaType); - double exponent = ExperienceConfig.getInstance().getExponent(formulaType); - switch (formulaType) { + switch(formulaType) { case LINEAR: - if (!experienceNeededLinear.containsKey(level)) { - experience = (int) Math.floor( xpNeededMultiplier * (base + level * multiplier)); - experienceNeededLinear.put(level, experience); - } - - return experienceNeededLinear.get(level); - + return (int) Math.floor(base + level * multiplier); case EXPONENTIAL: - if (!experienceNeededExponential.containsKey(level)) { - experience = (int) Math.floor( xpNeededMultiplier * (multiplier * Math.pow(level, exponent) + base)); - experienceNeededExponential.put(level, experience); - } - - return experienceNeededExponential.get(level); - + double exponent = ExperienceConfig.getInstance().getExponent(formulaType); + return (int) Math.floor(multiplier * Math.pow(level, exponent) + base); default: - return 0; + //TODO: Should never be called + mcMMO.p.getLogger().severe("Invalid formula specified for calculation, defaulting to Linear"); + return calculateXPNeeded(level, FormulaType.LINEAR); } } From 1cda612e86332c1cbcac7c71e1a740c8aa030d85 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Mon, 27 May 2019 19:25:36 -0700 Subject: [PATCH 07/11] Fixed a bug that would spam other players when someone used an ability --- Changelog.txt | 5 ++++- .../nossr50/util/player/NotificationManager.java | 11 +++-------- .../com/gmail/nossr50/util/skills/SkillUtils.java | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 14c4c9b61..edbafa395 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,10 +1,13 @@ Version 2.1.64 + Corrected how Standard mode (1-100 scaling) XP to next level was calculated, it is now a true 1:10 ratio with Retro (1-1000) scale, which is how it was intended to be to begin with + Fixed a bug that caused skill messages to spam nearby players (API) method to get XP in FormulaManager has been renamed to getXPtoNextLevel(...), this shouldn't break anything as plugins should be using our Experience API methods instead of this (API) Added method getLevel(Player player, PrimarySkillType primarySkillType) to ExperienceAPI.java - Corrected how Standard mode (1-100 scaling) XP to next level was calculated, it is now a true 1:10 ratio with Retro (1-1000) scale, which is how it was intended to be to begin with + NOTE: The net result of this change is it will take a bit longer to level with Standard, but it should not be a drastic change. You might not even notice it. Standard is meant to take the same amount of time to level from levels 1-100 as it takes Retro to do 1-1000, this change corrects from errors in the code that made Standard actually take less XP than Retro despite intending for it to be a cosmetic difference in progression. + I made a google sheet visualizing the difference between Standard and Retro Mode using default settings and Linear formula - https://docs.google.com/spreadsheets/d/1VlJtvNHlypACHyz_zulEdhgLwFjL01xMPkqlnu0XBSs/edit?usp=sharing Version 2.1.63 Fixed Armor Impact not scaling by skill rank diff --git a/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java b/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java index f350de361..272cfbb32 100644 --- a/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java +++ b/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java @@ -55,19 +55,14 @@ public class NotificationManager { * Sends players notifications from mcMMO * This does this by sending out an event so other plugins can cancel it * This event in particular is provided with a source player, and players near the source player are sent the information - * @param source the source player for this event + * @param targetPlayer the recipient player for this message * @param notificationType type of notification * @param key Locale Key for the string to use with this event * @param values values to be injected into the locale string */ - public static void sendNearbyPlayersInformation(Player source, NotificationType notificationType, String key, String... values) + public static void sendNearbyPlayersInformation(Player targetPlayer, NotificationType notificationType, String key, String... values) { - Location location = source.getLocation(); - for (Player otherPlayer : source.getWorld().getPlayers()) { - if (otherPlayer != source && Misc.isNear(location, otherPlayer.getLocation(), Misc.SKILL_MESSAGE_MAX_SENDING_DISTANCE)) { - sendPlayerInformation(otherPlayer, notificationType, key, values); - } - } + sendPlayerInformation(targetPlayer, notificationType, key, values); } public static void sendPlayerInformation(Player player, NotificationType notificationType, String key, String... values) diff --git a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java index d9d345694..326d6d6f0 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java @@ -125,7 +125,7 @@ public class SkillUtils { for (Player otherPlayer : player.getWorld().getPlayers()) { if (otherPlayer != player && Misc.isNear(location, otherPlayer.getLocation(), Misc.SKILL_MESSAGE_MAX_SENDING_DISTANCE)) { - NotificationManager.sendNearbyPlayersInformation(player, notificationType, key, player.getName()); + NotificationManager.sendNearbyPlayersInformation(otherPlayer, notificationType, key, player.getName()); } } } From 11f669f8f48edf48284bdcb51e9b9453e642f1fd Mon Sep 17 00:00:00 2001 From: nossr50 Date: Mon, 27 May 2019 19:27:35 -0700 Subject: [PATCH 08/11] 2.1.64 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d7cd7c2de..41183dea6 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.64-SNAPSHOT + 2.1.64 mcMMO https://github.com/mcMMO-Dev/mcMMO From 54eca5b8bab9b202890a73664e5a69cd7ee1ce14 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Mon, 27 May 2019 20:13:22 -0700 Subject: [PATCH 09/11] Fixed a bug where RetroMode would always use Linear formula --- Changelog.txt | 3 +++ pom.xml | 2 +- .../com/gmail/nossr50/util/experience/FormulaManager.java | 6 +----- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index edbafa395..40ce18c04 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,3 +1,6 @@ +Version 2.1.65 + Corrected a bug that would cause RetroMode to use Linear formula regardless of setting + Version 2.1.64 Corrected how Standard mode (1-100 scaling) XP to next level was calculated, it is now a true 1:10 ratio with Retro (1-1000) scale, which is how it was intended to be to begin with Fixed a bug that caused skill messages to spam nearby players diff --git a/pom.xml b/pom.xml index 41183dea6..a5032ca57 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.64 + 2.1.65 mcMMO https://github.com/mcMMO-Dev/mcMMO diff --git a/src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java b/src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java index 5d770be6d..eda9dc52c 100644 --- a/src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java +++ b/src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java @@ -22,12 +22,8 @@ public class FormulaManager { private FormulaType previousFormula; - //Used for XP formula scaling - private boolean retroModeEnabled; - public FormulaManager() { /* Setting for Classic Mode (Scales a lot of stuff up by * 10) */ - retroModeEnabled = Config.getInstance().getIsRetroMode(); initExperienceNeededMaps(); loadFormula(); } @@ -182,7 +178,7 @@ public class FormulaManager { Map experienceMapRef = formulaType == FormulaType.LINEAR ? experienceNeededRetroLinear : experienceNeededRetroExponential; if (!experienceMapRef.containsKey(level)) { - int experience = calculateXPNeeded(level, FormulaType.LINEAR); + int experience = calculateXPNeeded(level, formulaType); experienceMapRef.put(level, experience); } From 4795143fca715b0520cc98552f69487ff7576ceb Mon Sep 17 00:00:00 2001 From: nossr50 Date: Wed, 29 May 2019 10:14:04 -0700 Subject: [PATCH 10/11] Fixed a memory leak in MySQL that would cause errors if users were removed from the DB --- Changelog.txt | 4 ++++ pom.xml | 2 +- .../nossr50/commands/database/McremoveCommand.java | 10 +++++++++- .../com/gmail/nossr50/database/DatabaseManager.java | 10 +++++++++- .../nossr50/database/FlatfileDatabaseManager.java | 8 +++++++- .../gmail/nossr50/database/SQLDatabaseManager.java | 11 ++++++++++- .../gmail/nossr50/datatypes/player/McMMOPlayer.java | 3 +++ 7 files changed, 43 insertions(+), 5 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 40ce18c04..f3159210a 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,3 +1,7 @@ +Version 2.1.66 + Fixed a bug that could happen if a player was removed from the DB when using MySQL/MariaDB when the user was offline + Fixed a minor memory leak for MySQL + Version 2.1.65 Corrected a bug that would cause RetroMode to use Linear formula regardless of setting diff --git a/pom.xml b/pom.xml index a5032ca57..c3640a50b 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.65 + 2.1.66-SNAPSHOT mcMMO https://github.com/mcMMO-Dev/mcMMO diff --git a/src/main/java/com/gmail/nossr50/commands/database/McremoveCommand.java b/src/main/java/com/gmail/nossr50/commands/database/McremoveCommand.java index 5fe1ca89a..ba02d762c 100644 --- a/src/main/java/com/gmail/nossr50/commands/database/McremoveCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/database/McremoveCommand.java @@ -5,6 +5,7 @@ import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; import com.google.common.collect.ImmutableList; +import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.TabExecutor; @@ -12,6 +13,7 @@ import org.bukkit.util.StringUtil; import java.util.ArrayList; import java.util.List; +import java.util.UUID; public class McremoveCommand implements TabExecutor { @Override @@ -24,7 +26,13 @@ public class McremoveCommand implements TabExecutor { return true; } - if (mcMMO.getDatabaseManager().removeUser(playerName)) { + UUID uuid = null; + + if(Bukkit.getPlayer(playerName) != null) { + uuid = Bukkit.getPlayer(playerName).getUniqueId(); + } + + if (mcMMO.getDatabaseManager().removeUser(playerName, uuid)) { sender.sendMessage(LocaleLoader.getString("Commands.mcremove.Success", playerName)); } else { diff --git a/src/main/java/com/gmail/nossr50/database/DatabaseManager.java b/src/main/java/com/gmail/nossr50/database/DatabaseManager.java index 47be98437..314b91800 100644 --- a/src/main/java/com/gmail/nossr50/database/DatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/DatabaseManager.java @@ -30,9 +30,17 @@ public interface DatabaseManager { * Remove a user from the database. * * @param playerName The name of the user to remove + * @param uuid player UUID, can be null * @return true if the user was successfully removed, false otherwise */ - public boolean removeUser(String playerName); + public boolean removeUser(String playerName, UUID uuid); + + /** + * Removes any cache used for faster lookups + * Currently only used for SQL + * @param uuid target UUID to cleanup + */ + public void cleanupUser(UUID uuid); /** * Save a user to the database. diff --git a/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java b/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java index 907638b54..c9e305a14 100644 --- a/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java @@ -185,7 +185,8 @@ public final class FlatfileDatabaseManager implements DatabaseManager { mcMMO.p.getLogger().info("Purged " + removedPlayers + " users from the database."); } - public boolean removeUser(String playerName) { + public boolean removeUser(String playerName, UUID uuid) { + //NOTE: UUID is unused for FlatFile for this interface implementation boolean worked = false; BufferedReader in = null; @@ -240,6 +241,11 @@ public final class FlatfileDatabaseManager implements DatabaseManager { return worked; } + @Override + public void cleanupUser(UUID uuid) { + //Not used in FlatFile + } + public boolean saveUser(PlayerProfile profile) { String playerName = profile.getPlayerName(); UUID uuid = profile.getUniqueId(); diff --git a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java index 04c8d533b..6d2fe9728 100644 --- a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java @@ -15,6 +15,7 @@ import com.gmail.nossr50.runnables.database.UUIDUpdateAsyncTask; import com.gmail.nossr50.util.Misc; import org.apache.tomcat.jdbc.pool.DataSource; import org.apache.tomcat.jdbc.pool.PoolProperties; +import org.bukkit.Bukkit; import org.bukkit.scheduler.BukkitRunnable; import java.sql.*; @@ -172,7 +173,7 @@ public final class SQLDatabaseManager implements DatabaseManager { mcMMO.p.getLogger().info("Purged " + purged + " users from the database."); } - public boolean removeUser(String playerName) { + public boolean removeUser(String playerName, UUID uuid) { boolean success = false; Connection connection = null; PreparedStatement statement = null; @@ -200,12 +201,20 @@ public final class SQLDatabaseManager implements DatabaseManager { } if (success) { + if(uuid != null) + cleanupUser(uuid); + Misc.profileCleanup(playerName); } return success; } + public void cleanupUser(UUID uuid) { + if(cachedUserIDs.containsKey(uuid)) + cachedUserIDs.remove(uuid); + } + public boolean saveUser(PlayerProfile profile) { boolean success = true; PreparedStatement statement = 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 68b1d911c..548536fc2 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -1008,5 +1008,8 @@ public class McMMOPlayer { if (inParty()) { party.removeOnlineMember(thisPlayer); } + + //Remove user from cache + mcMMO.getDatabaseManager().cleanupUser(thisPlayer.getUniqueId()); } } From ff1bb0deed61cda7daa75a374da3942de9e2e172 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Wed, 29 May 2019 11:01:02 -0700 Subject: [PATCH 11/11] 2.1.66 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c3640a50b..183d97c51 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.66-SNAPSHOT + 2.1.66 mcMMO https://github.com/mcMMO-Dev/mcMMO