Skip to content

Commit 4a97c44

Browse files
committed
fix ability-specific mods
1 parent d85fbdf commit 4a97c44

File tree

4 files changed

+15
-19
lines changed

4 files changed

+15
-19
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>project</groupId>
44
<artifactId>items</artifactId>
5-
<version>1.6.1</version>
5+
<version>1.6.2</version>
66
<name>BendingItems</name>
77

88
<repositories>

src/me/simplicitee/project/items/BendingItem.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.util.Collections;
55
import java.util.List;
66
import java.util.Map;
7+
import java.util.Map.Entry;
78
import java.util.concurrent.ThreadLocalRandom;
89

910
import org.bukkit.entity.Player;
@@ -26,9 +27,9 @@ public enum Usage {
2627
private ItemStack item;
2728
private Usage usage;
2829
private Element element;
29-
private Map<CoreAbility, List<BendingModifier>> mods;
30+
private Map<String, List<BendingModifier>> mods;
3031

31-
public BendingItem(String name, ItemStack item, Usage usage, Element element, Map<CoreAbility, List<BendingModifier>> mods) {
32+
public BendingItem(String name, ItemStack item, Usage usage, Element element, Map<String, List<BendingModifier>> mods) {
3233
this.name = name;
3334
this.item = item;
3435
this.usage = usage;
@@ -73,9 +74,12 @@ public ItemStack newStack() {
7374
public List<String> listMods() {
7475
List<String> mods = new ArrayList<>();
7576
mods.add("Stats:");
76-
for (CoreAbility ability : this.mods.keySet()) {
77-
for (BendingModifier mod : this.mods.get(ability)) {
78-
mods.add("- " + (ability != null ? ability.getName() : "Base") + mod.toString());
77+
78+
for (Entry<String, List<BendingModifier>> entry : this.mods.entrySet()) {
79+
String ability = entry.getKey();
80+
81+
for (BendingModifier mod : entry.getValue()) {
82+
mods.add("- " + (ability != null ? ability : "Base") + "." + mod.toString());
7983
}
8084
}
8185

@@ -91,7 +95,7 @@ public void applyMods(CoreAbility abil, ItemStack stack) {
9195

9296
List<BendingModifier> specific = new ArrayList<>();
9397

94-
specific.addAll(mods.getOrDefault(abil, Collections.emptyList()));
98+
specific.addAll(mods.getOrDefault(abil.getName().toLowerCase(), Collections.emptyList()));
9599
specific.addAll(mods.getOrDefault(null, Collections.emptyList()));
96100

97101
if (specific.isEmpty()) {

src/me/simplicitee/project/items/ItemManager.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -275,21 +275,13 @@ public static BendingItem register(File file) throws IllegalArgumentException {
275275
meta.getPersistentDataContainer().set(ID_KEY, PersistentDataType.INTEGER, id);
276276
item.setItemMeta(meta);
277277

278-
Map<CoreAbility, List<BendingModifier>> mods = null;
278+
Map<String, List<BendingModifier>> mods = null;
279279
if (config.contains("Mods")) {
280280
mods = new HashMap<>();
281281

282-
if (config.contains("Mods.Base")) {
283-
mods.put(null, loadMods(config.getConfigurationSection("Mods.Base")));
284-
}
285-
286282
for (String key : config.getConfigurationSection("Mods").getKeys(false)) {
287-
CoreAbility ability = CoreAbility.getAbility(key);
288-
289-
if (ability == null) {
290-
continue;
291-
}
292-
283+
String ability = key.equalsIgnoreCase("Base") ? null : key.toLowerCase();
284+
293285
mods.put(ability, loadMods(config.getConfigurationSection("Mods." + key)));
294286
}
295287
}

src/plugin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: BendingItems
22
author: Simplicitee
33
api-version: 1.16
4-
version: 1.6.1
4+
version: 1.6.2
55
main: me.simplicitee.project.items.ItemsPlugin
66
depend: [ProjectKorra]
77
permissions:

0 commit comments

Comments
 (0)