ソースを参照

Fix a NPE with getFlowerAndGrassXp()

Fixes #1975
TfT_02 11 年 前
コミット
4b20f12eff

+ 1 - 0
Changelog.txt

@@ -26,6 +26,7 @@ Version 1.5.01-dev
  = Fixed bug where SaveTimerTask would produce an IndexOutOfBoundsException
  = Fixed bug where Alchemy would not fire BrewEvents
  = Fixed bug with setting custom names and lore in treasures config
+ = Fixed bug which would cause a NullPointerException with getFlowerAndGrassXp()
  ! Changed player data saving. Save tasks are now asynchronous
  ! Vanished players no longer get hit by AoE effects
  ! Changed Alchemy config option 'Prevent_Hopper_Transfer' renamed to 'Prevent_Hopper_Transfer_Ingredients'

+ 7 - 1
src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java

@@ -3,6 +3,7 @@ package com.gmail.nossr50.config.experience;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.bukkit.GrassSpecies;
 import org.bukkit.Material;
 import org.bukkit.TreeSpecies;
 import org.bukkit.entity.EntityType;
@@ -267,7 +268,12 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
 
         }
         else if (type == Material.LONG_GRASS) {
-            switch (((LongGrass) data).getSpecies()) {
+            GrassSpecies species = ((LongGrass) data).getSpecies();
+            if (species == null) {
+                return 0;
+            }
+
+            switch (species) {
                 case DEAD:
                     return config.getInt("Experience.Herbalism.Dead_Bush", 30);