diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/variables/Constants.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/variables/Constants.java index bda3bf50..ed242ace 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/variables/Constants.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/variables/Constants.java @@ -10,6 +10,7 @@ import de.steamwar.bausystem.region.flags.flagvalues.TNTMode; import lombok.experimental.UtilityClass; import org.bukkit.Location; import org.bukkit.entity.Player; +import org.bukkit.inventory.meta.ItemMeta; import java.util.HashMap; import java.util.Map; @@ -26,7 +27,8 @@ public class Constants { private static class ConstantDoubleValue extends Value.DoubleValue { private Supplier doubleSupplier; - private Consumer doubleConsumer = ignored -> {}; + private Consumer doubleConsumer = ignored -> { + }; public ConstantDoubleValue(Supplier doubleSupplier) { super(doubleSupplier.get()); @@ -73,7 +75,8 @@ public class Constants { private static class ConstantLongValue extends Value.LongValue { private Supplier longSupplier; - private Consumer longConsumer = ignored -> {}; + private Consumer longConsumer = ignored -> { + }; public ConstantLongValue(Supplier longSupplier) { super(longSupplier.get()); @@ -120,7 +123,8 @@ public class Constants { private static class ConstantBooleanValue extends Value.BooleanValue { private Supplier booleanSupplier; - private Consumer booleanConsumer = ignored -> {}; + private Consumer booleanConsumer = ignored -> { + }; public ConstantBooleanValue(Supplier booleanSupplier) { super(booleanSupplier.get()); @@ -167,7 +171,8 @@ public class Constants { private static class ConstantStringValue extends Value.StringValue { private Supplier stringSupplier; - private Consumer stringConsumer = ignored -> {}; + private Consumer stringConsumer = ignored -> { + }; public ConstantStringValue(Supplier stringSupplier) { super(stringSupplier.get()); @@ -281,10 +286,22 @@ public class Constants { return new ConstantStringValue(() -> player.getInventory().getItemInOffHand().getType().name()); }); CONSTANTS.put("materialname", player -> { - return new ConstantStringValue(() -> player.getInventory().getItemInMainHand().getItemMeta().getDisplayName()); + return new ConstantStringValue(() -> { + ItemMeta itemMeta = player.getInventory().getItemInMainHand().getItemMeta(); + if (itemMeta == null) { + return ""; + } + return itemMeta.getDisplayName(); + }); }); CONSTANTS.put("offmaterialname", player -> { - return new ConstantStringValue(() -> player.getInventory().getItemInOffHand().getItemMeta().getDisplayName()); + return new ConstantStringValue(() -> { + ItemMeta itemMeta = player.getInventory().getItemInOffHand().getItemMeta(); + if (itemMeta == null) { + return ""; + } + return itemMeta.getDisplayName(); + }); }); CONSTANTS.put("region-type", player -> { Region region = Region.getRegion(player.getLocation());