Przeglądaj źródła

Prevent commands from setting players to negative levels

nossr50 6 lat temu
rodzic
commit
da6b6841b7

+ 1 - 0
Changelog.txt

@@ -46,6 +46,7 @@ Version 2.1.0
  - (Locale) Removed localizations with the following codes for being almost empty: id, HR_hr, et_EE, lv, lt, no, pl_PL, pt_PT, tr_TR
  - (Locale) Removed localizations with the following codes for being almost empty: id, HR_hr, et_EE, lv, lt, no, pl_PL, pt_PT, tr_TR
  - (Config) Removed SkillShot's IncreaseLevel & IncreasePercentage (replaced by RankDamageMultiplier)
  - (Config) Removed SkillShot's IncreaseLevel & IncreasePercentage (replaced by RankDamageMultiplier)
  - (Config) Removed AxeMastery's MaxBonus & MaxBonusLevel (replaced by RankDamageMultiplier)
  - (Config) Removed AxeMastery's MaxBonus & MaxBonusLevel (replaced by RankDamageMultiplier)
+ = (Experience) Fixed a bug where you could set a players levels into the negative and bad things would happen
  = (Plugin Compatibility) mcMMO now fires new custom events relating to changes it makes to player scoreboards, plugin authors can listen to these events to improve compatibility
  = (Plugin Compatibility) mcMMO now fires new custom events relating to changes it makes to player scoreboards, plugin authors can listen to these events to improve compatibility
  = (Items) Chimaera Wing now tracks cooldowns between sessions for players (no more disconnect abuse)
  = (Items) Chimaera Wing now tracks cooldowns between sessions for players (no more disconnect abuse)
  = (Skills) Added missing mushroom blocks to experience.yml defaults
  = (Skills) Added missing mushroom blocks to experience.yml defaults

+ 1 - 1
src/main/java/com/gmail/nossr50/config/Config.java

@@ -245,7 +245,7 @@ public class Config extends AutoUpdateConfigLoader {
 
 
     /* General Settings */
     /* General Settings */
 
 
-    //Classic mode will default the value to true if the config file doesn't contain the entry (server is from a previous mcMMO install)
+    //Retro mode will default the value to true if the config file doesn't contain the entry (server is from a previous mcMMO install)
     public boolean getIsRetroMode() { return config.getBoolean("General.RetroMode", true); }
     public boolean getIsRetroMode() { return config.getBoolean("General.RetroMode", true); }
 
 
     //XP needed to level is multiplied by this when using classic mode
     //XP needed to level is multiplied by this when using classic mode

+ 4 - 0
src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java

@@ -280,6 +280,10 @@ public class PlayerProfile {
 
 
         changed = true;
         changed = true;
 
 
+        //Don't allow levels to be negative
+        if(level < 0)
+            level = 0;
+
         skills.put(skill, level);
         skills.put(skill, level);
         skillsXp.put(skill, 0F);
         skillsXp.put(skill, 0F);
     }
     }