From f8f51e0f29d878e329b93e12ee83c89cbeeaf368 Mon Sep 17 00:00:00 2001 From: Ka0rX Date: Sat, 2 Jul 2022 08:25:28 +0200 Subject: [PATCH] Shift Click Attribute View --- .../java/net/Indyuce/mmocore/gui/AttributeView.java | 12 +++++++----- .../java/net/Indyuce/mmocore/gui/SkillList.java | 13 +++++++------ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/spigot-plugin/src/main/java/net/Indyuce/mmocore/gui/AttributeView.java b/spigot-plugin/src/main/java/net/Indyuce/mmocore/gui/AttributeView.java index 63a356eb..4cd7409f 100644 --- a/spigot-plugin/src/main/java/net/Indyuce/mmocore/gui/AttributeView.java +++ b/spigot-plugin/src/main/java/net/Indyuce/mmocore/gui/AttributeView.java @@ -47,17 +47,19 @@ public class AttributeView extends EditableInventory { public static class AttributeItem extends InventoryItem { private final PlayerAttribute attribute; - private int shiftCost; + private int shiftCost=1; public AttributeItem(String function, ConfigurationSection config) { super(config); attribute = MMOCore.plugin.attributeManager .get(function.substring("attribute_".length()).toLowerCase().replace(" ", "-").replace("_", "-")); - shiftCost = config.getInt("shift-cost"); - if (shiftCost < 1) { - MMOCore.log(Level.WARNING, "Level up points cost must not be less than 1. Using default value: 1"); - shiftCost = 1; + if(config.contains("shift-cost")) { + shiftCost = config.getInt("shift-cost"); + if (shiftCost < 1) { + MMOCore.log(Level.WARNING, "Level up points cost must not be less than 1. Using default value: 1"); + shiftCost = 1; + } } } diff --git a/spigot-plugin/src/main/java/net/Indyuce/mmocore/gui/SkillList.java b/spigot-plugin/src/main/java/net/Indyuce/mmocore/gui/SkillList.java index 03507694..ee4393ea 100644 --- a/spigot-plugin/src/main/java/net/Indyuce/mmocore/gui/SkillList.java +++ b/spigot-plugin/src/main/java/net/Indyuce/mmocore/gui/SkillList.java @@ -225,15 +225,16 @@ public class SkillList extends EditableInventory { } public class UpgradeItem extends InventoryItem { - private int shiftCost; + private int shiftCost=1; public UpgradeItem(ConfigurationSection config) { super(config); - - this.shiftCost = config.getInt("shift-cost"); - if (shiftCost < 1) { - MMOCore.log(Level.WARNING, "Upgrade shift-cost cannot be less than 1. Using default value: 1"); - shiftCost = 1; + if(config.contains("shift-cost")) { + this.shiftCost = config.getInt("shift-cost"); + if (shiftCost < 1) { + MMOCore.log(Level.WARNING, "Upgrade shift-cost cannot be less than 1. Using default value: 1"); + shiftCost = 1; + } } }