diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/AbilityCustomEffect.java b/src/main/java/kamkeel/npcs/controllers/data/ability/AbilityCustomEffect.java index 150a42088..22428b704 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/ability/AbilityCustomEffect.java +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/AbilityCustomEffect.java @@ -59,6 +59,7 @@ public class AbilityCustomEffect { nbt.setInteger("effectId", effectId); nbt.setInteger("duration", durationTicks); nbt.setByte("level", level); + nbt.setInteger("index", index); return nbt; } @@ -66,6 +67,7 @@ public class AbilityCustomEffect { this.effectId = nbt.getInteger("effectId"); this.durationTicks = nbt.getInteger("duration"); this.level = nbt.getByte("level"); + this.index = nbt.getInteger("index"); } public static AbilityCustomEffect fromNBT(NBTTagCompound nbt) { @@ -105,6 +107,6 @@ public class AbilityCustomEffect { } public void setIndex(int index) { - this.index = ValueUtil.clamp(index, 0, 1); + this.index = Math.max(0, index); } } diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/gui/AbilityFieldBuilder.java b/src/main/java/kamkeel/npcs/controllers/data/ability/gui/AbilityFieldBuilder.java index 6cbd0b6f9..4aa9d54ae 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/ability/gui/AbilityFieldBuilder.java +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/gui/AbilityFieldBuilder.java @@ -182,17 +182,28 @@ public class AbilityFieldBuilder extends GuiFieldBuilder { } } - private String getCustomEffectName(int effectId) { - HashMap allEffects = CustomEffectController.getInstance().getCustomEffects(); + private String getCustomEffectName(int effectId, int index) { + HashMap allEffects = CustomEffectController.getInstance().getEffectMap(index); if (allEffects != null) { CustomEffect ce = allEffects.get(effectId); if (ce != null && ce.getName() != null && !ce.getName().isEmpty()) { return ce.getName(); } } + // Fallback: check index 0 + if (index != 0) { + return getCustomEffectName(effectId, 0); + } return "?"; } + private boolean hasAnyEffects() { + for (HashMap map : CustomEffectController.getInstance().indexMapper.values()) { + if (map != null && !map.isEmpty()) return true; + } + return false; + } + @SuppressWarnings("unchecked") private int renderCustomEffectsList(FieldDef def, int y) { ensureCustomEffectCache(); @@ -201,7 +212,7 @@ public class AbilityFieldBuilder extends GuiFieldBuilder { sw.addLabel(new GuiNpcLabel(labelId++, def.getLabel(), colLLabel, y + 2, 0xFFFF55)); y += 15; - if (sortedCustomEffectNames.length == 0) { + if (!hasAnyEffects()) { sw.addLabel(new GuiNpcLabel(labelId++, "ability.noCustomEffects", colLLabel, y + 5, 0x888888)); y += rowHeight; return y; @@ -216,7 +227,7 @@ public class AbilityFieldBuilder extends GuiFieldBuilder { AbilityCustomEffect effect = effects.get(e); // Effect name button — opens SubGui picker - String effectName = getCustomEffectName(effect.getEffectId()); + String effectName = getCustomEffectName(effect.getEffectId(), effect.getIndex()); GuiNpcButton nameBtn = new GuiNpcButton(widgetId, colLLabel, y, 100, 20, effectName); sw.addButton(nameBtn); buttonFieldMap.put(widgetId, def); @@ -381,10 +392,13 @@ public class AbilityFieldBuilder extends GuiFieldBuilder { case 0: // Open effect picker SubGui if (idx < effects.size()) { int currentId = effects.get(idx).getEffectId(); - parent.setSubGuiWithResult(new SubGuiCustomEffectSelect(currentId), sub -> { - int selectedId = ((SubGuiCustomEffectSelect) sub).getSelectedEffectId(); + int currentIndex = effects.get(idx).getIndex(); + parent.setSubGuiWithResult(new SubGuiCustomEffectSelect(currentId, currentIndex), sub -> { + SubGuiCustomEffectSelect select = (SubGuiCustomEffectSelect) sub; + int selectedId = select.getSelectedEffectId(); if (selectedId >= 0 && idx < effects.size()) { effects.get(idx).setEffectId(selectedId); + effects.get(idx).setIndex(select.getSelectedIndex()); } }); } @@ -397,11 +411,12 @@ public class AbilityFieldBuilder extends GuiFieldBuilder { if (idx < effects.size()) effects.remove(idx); return true; case 4: // Add - if (effects.size() < 5 && sortedCustomEffectIds.length > 0) { + if (effects.size() < 5) { parent.setSubGuiWithResult(new SubGuiCustomEffectSelect(-1), sub -> { - int selectedId = ((SubGuiCustomEffectSelect) sub).getSelectedEffectId(); + SubGuiCustomEffectSelect select = (SubGuiCustomEffectSelect) sub; + int selectedId = select.getSelectedEffectId(); if (selectedId >= 0 && effects.size() < 5) { - effects.add(new AbilityCustomEffect(selectedId, 60, (byte) 0)); + effects.add(new AbilityCustomEffect(selectedId, 60, (byte) 0, select.getSelectedIndex())); } }); } diff --git a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCAbilities.java b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCAbilities.java index fc4252745..85ef3e5d8 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCAbilities.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCAbilities.java @@ -235,6 +235,14 @@ public class GuiNPCAbilities extends GuiNPCInterface2 implements IScrollData, IC Ability a = sel.getAbility(); if (a != null && a.isBuiltIn()) selectedIsBuiltIn = true; } + // Chain entries referencing built-in abilities are not editable + if (selectedIsChainEntry && sel.isChain()) { + ChainedAbility biChain = sel.isInlineChain() ? sel.getInlineChain() : sel.getChainedAbility(); + if (biChain != null && selectedEntryIndex < biChain.getEntries().size()) { + Ability resolved = biChain.getEntries().get(selectedEntryIndex).resolve(); + if (resolved != null && resolved.isBuiltIn()) selectedIsBuiltIn = true; + } + } // Sub-entries of reference chains are not directly editable from the NPC list if (selectedIsChainEntry && sel.isChainReference()) { selectedIsRefChainEntry = true; @@ -363,6 +371,10 @@ public class GuiNPCAbilities extends GuiNPCInterface2 implements IScrollData, IC ChainedAbility chain = slot.isInlineChain() ? slot.getInlineChain() : slot.getChainedAbility(); if (chain != null && selectedEntryIndex < chain.getEntries().size()) { ChainedAbilityEntry entry = chain.getEntries().get(selectedEntryIndex); + // Built-in abilities are always references — no editing allowed + Ability resolvedEntry = entry.resolve(); + if (resolvedEntry != null && resolvedEntry.isBuiltIn()) return; + if (entry.isInline() && slot.isInlineChain()) { // Inline entry in inline chain — edit directly Ability a = entry.getInlineAbility(); @@ -454,7 +466,7 @@ public class GuiNPCAbilities extends GuiNPCInterface2 implements IScrollData, IC pendingSaveEntryIdx = -1; } - if (abilityToSave != null) { + if (abilityToSave != null && !abilityToSave.isBuiltIn()) { if (abilityToSave.getName() == null || abilityToSave.getName().isEmpty()) { abilityToSave.setNpcInlineEdit(true); setSubGui(abilityToSave.createConfigGui(this)); @@ -972,6 +984,13 @@ public class GuiNPCAbilities extends GuiNPCInterface2 implements IScrollData, IC } } else if (slot.isChain() && selectedEntryIndex >= 0) { // Chain entry reference + // Block all editing for built-in abilities + ChainedAbility resolveChain = slot.isInlineChain() ? slot.getInlineChain() : slot.getChainedAbility(); + if (resolveChain != null && selectedEntryIndex < resolveChain.getEntries().size()) { + Ability entryResolved = resolveChain.getEntries().get(selectedEntryIndex).resolve(); + if (entryResolved != null && entryResolved.isBuiltIn()) return; + } + if (mode == SubGuiAbilityEditMode.MODE_CLONE_MODIFY) { if (slot.isChainReference()) { slot.convertToInline(); @@ -981,7 +1000,7 @@ public class GuiNPCAbilities extends GuiNPCInterface2 implements IScrollData, IC ChainedAbilityEntry entry = chain.getEntries().get(selectedEntryIndex); if (entry.convertToInline()) { Ability a = entry.getInlineAbility(); - if (a != null) { + if (a != null && !a.isBuiltIn()) { editingChainEntry = true; editChainSlotIdx = selectedSlotIndex; editChainEntryIdx = selectedEntryIndex; @@ -1005,9 +1024,11 @@ public class GuiNPCAbilities extends GuiNPCInterface2 implements IScrollData, IC } } else if (mode == SubGuiAbilityEditMode.MODE_CLONE_MODIFY) { // Standalone ability reference → convert to inline + Ability preCheck = slot.getAbility(); + if (preCheck != null && preCheck.isBuiltIn()) return; if (slot.convertToInline()) { Ability ability = slot.getAbility(); - if (ability != null) { + if (ability != null && !ability.isBuiltIn()) { ability.setId(UUID.randomUUID().toString()); ability.setNpcInlineEdit(true); setSubGui(ability.createConfigGui(this)); diff --git a/src/main/java/noppes/npcs/client/gui/advanced/SubGuiAbilitySelect.java b/src/main/java/noppes/npcs/client/gui/advanced/SubGuiAbilitySelect.java index a1d235d51..70faa9059 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/SubGuiAbilitySelect.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/SubGuiAbilitySelect.java @@ -18,18 +18,32 @@ import java.util.List; import java.util.Vector; /** - * Simple ability name picker. Shows all abilities (custom + built-in) in a - * single scroll list with search. Returns the selected ability name. + * Simple ability name picker with optional filter mode. + * Shows custom, built-in, or all abilities in a scroll list with search. + * Returns the selected ability name. */ public class SubGuiAbilitySelect extends SubGuiInterface implements ICustomScrollListener, IScrollData { + /** Show all abilities (custom + built-in). */ + public static final int FILTER_ALL = 0; + /** Show only custom abilities. */ + public static final int FILTER_CUSTOM_ONLY = 1; + /** Show only built-in abilities. */ + public static final int FILTER_BUILTIN_ONLY = 2; + private GuiCustomScroll scroll; private HashMap customData = new HashMap<>(); private HashMap builtInData = new HashMap<>(); private String selectedName = null; private String search = ""; + private final int filterMode; public SubGuiAbilitySelect() { + this(FILTER_ALL); + } + + public SubGuiAbilitySelect(int filterMode) { + this.filterMode = filterMode; setBackground("menubg.png"); xSize = 220; ySize = 216; @@ -72,8 +86,12 @@ public class SubGuiAbilitySelect extends SubGuiInterface implements ICustomScrol private List getFilteredList() { HashMap merged = new HashMap<>(); - merged.putAll(customData); - merged.putAll(builtInData); + if (filterMode != FILTER_BUILTIN_ONLY) { + merged.putAll(customData); + } + if (filterMode != FILTER_CUSTOM_ONLY) { + merged.putAll(builtInData); + } if (search.isEmpty()) { return new ArrayList<>(merged.keySet()); diff --git a/src/main/java/noppes/npcs/client/gui/advanced/SubGuiAbilityTypeSelect.java b/src/main/java/noppes/npcs/client/gui/advanced/SubGuiAbilityTypeSelect.java index 2f3ee97c4..b0c03a811 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/SubGuiAbilityTypeSelect.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/SubGuiAbilityTypeSelect.java @@ -74,6 +74,10 @@ public class SubGuiAbilityTypeSelect extends SubGuiInterface implements ICustomS allDisplayNameToTypeId.clear(); String[] types = AbilityController.Instance.getTypes(); for (String typeId : types) { + // Never show built-in types — they are immutable and cannot be created + if (AbilityController.Instance.isBuiltInType(typeId)) + continue; + // Apply scroll type filter if (!matchesScrollType(typeId)) continue; diff --git a/src/main/java/noppes/npcs/client/gui/advanced/SubGuiChainedAbilityConfig.java b/src/main/java/noppes/npcs/client/gui/advanced/SubGuiChainedAbilityConfig.java index f5179686e..da71dec70 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/SubGuiChainedAbilityConfig.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/SubGuiChainedAbilityConfig.java @@ -556,11 +556,16 @@ public class SubGuiChainedAbilityConfig extends SubGuiInterface implements IText case 0: // Entry name button — reference: clone/modify dialog; inline: edit config ChainedAbilityEntry clickedEntry = entries.get(entryIndex); if (clickedEntry.isReference()) { + // Built-in abilities are always references — no editing allowed + Ability refResolved = clickedEntry.resolve(); + if (refResolved != null && refResolved.isBuiltIn()) return true; editingEntryIndex = entryIndex; setSubGui(new SubGuiAbilityEditMode()); } else if (clickedEntry.isInline() && clickedEntry.getInlineAbility() != null) { + Ability inlineAbility = clickedEntry.getInlineAbility(); + if (inlineAbility.isBuiltIn()) return true; editingEntryIndex = entryIndex; - setSubGui(new SubGuiAbilityConfig(clickedEntry.getInlineAbility(), this)); + setSubGui(new SubGuiAbilityConfig(inlineAbility, this)); } return true; case 2: // Up @@ -726,9 +731,11 @@ public class SubGuiChainedAbilityConfig extends SubGuiInterface implements IText if (source == SubGuiChainedEntrySource.SOURCE_NPC_SLOTS) { setSubGui(new SubGuiNpcSlotPicker(npcSlots)); } else if (source == SubGuiChainedEntrySource.SOURCE_LOAD_PRESET) { - setSubGui(new SubGuiAbilitySelect()); + setSubGui(new SubGuiAbilitySelect(SubGuiAbilitySelect.FILTER_CUSTOM_ONLY)); } else if (source == SubGuiChainedEntrySource.SOURCE_CREATE_NEW) { setSubGui(new SubGuiAbilityTypeSelect()); + } else if (source == SubGuiChainedEntrySource.SOURCE_BUILT_IN) { + setSubGui(new SubGuiAbilitySelect(SubGuiAbilitySelect.FILTER_BUILTIN_ONLY)); } // Don't initGui — we're opening another SubGui } @@ -759,7 +766,7 @@ public class SubGuiChainedAbilityConfig extends SubGuiInterface implements IText return; } Ability newAbility = AbilityController.Instance.create(typeId); - if (newAbility != null) { + if (newAbility != null && !newAbility.isBuiltIn()) { if (variants.size() == 1) { variants.get(0).apply(newAbility); } @@ -775,7 +782,7 @@ public class SubGuiChainedAbilityConfig extends SubGuiInterface implements IText int idx = gui.getSelectedIndex(); if (idx >= 0 && pendingTypeId != null) { Ability newAbility = AbilityController.Instance.create(pendingTypeId); - if (newAbility != null) { + if (newAbility != null && !newAbility.isBuiltIn()) { gui.getVariants().get(idx).apply(newAbility); newAbility.setId(java.util.UUID.randomUUID().toString()); entries.add(ChainedAbilityEntry.inline(newAbility, 0)); @@ -797,10 +804,17 @@ public class SubGuiChainedAbilityConfig extends SubGuiInterface implements IText ChainedAbilityEntry entry = entries.get(editingEntryIndex); + // Block all editing for built-in abilities + Ability preCheck = entry.resolve(); + if (preCheck != null && preCheck.isBuiltIn()) { + editingEntryIndex = -1; + return; + } + if (mode == SubGuiAbilityEditMode.MODE_CLONE_MODIFY) { if (entry.convertToInline()) { Ability a = entry.getInlineAbility(); - if (a != null) { + if (a != null && !a.isBuiltIn()) { a.setId(java.util.UUID.randomUUID().toString()); setSubGui(new SubGuiAbilityConfig(a, this)); return; diff --git a/src/main/java/noppes/npcs/client/gui/advanced/SubGuiChainedEntrySource.java b/src/main/java/noppes/npcs/client/gui/advanced/SubGuiChainedEntrySource.java index 2c544a937..b40753410 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/SubGuiChainedEntrySource.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/SubGuiChainedEntrySource.java @@ -6,7 +6,7 @@ import noppes.npcs.client.gui.util.GuiNpcLabel; /** * Choice dialog for adding an entry to a chain. - * Options: From NPC Slots (optional), Load Preset, Create New. + * Options: By Reference, Create New, Built-in, From NPC Slots (optional). */ public class SubGuiChainedEntrySource extends SubGuiSimpleChoice { @@ -14,6 +14,7 @@ public class SubGuiChainedEntrySource extends SubGuiSimpleChoice { public static final int SOURCE_NPC_SLOTS = 0; public static final int SOURCE_LOAD_PRESET = 1; public static final int SOURCE_CREATE_NEW = 2; + public static final int SOURCE_BUILT_IN = 3; private final boolean showNpcOption; @@ -25,7 +26,7 @@ public class SubGuiChainedEntrySource extends SubGuiSimpleChoice { this.showNpcOption = showNpcOption; setBackground("menubg.png"); xSize = 200; - ySize = showNpcOption ? 110 : 88; + ySize = showNpcOption ? 132 : 110; } @Override @@ -36,21 +37,24 @@ public class SubGuiChainedEntrySource extends SubGuiSimpleChoice { addLabel(new GuiNpcLabel(0, "ability.entrySource", guiLeft + 10, y)); y += 20; - if (showNpcOption) { - addButton(new GuiNpcButton(0, guiLeft + 10, y, 180, 20, "ability.fromNpc")); - y += 22; - } - - addButton(new GuiNpcButton(1, guiLeft + 10, y, 180, 20, "ability.byReference")); + addButton(new GuiNpcButton(SOURCE_LOAD_PRESET, guiLeft + 10, y, 180, 20, "ability.byReference")); y += 22; - addButton(new GuiNpcButton(2, guiLeft + 10, y, 180, 20, "ability.createNew")); + addButton(new GuiNpcButton(SOURCE_CREATE_NEW, guiLeft + 10, y, 180, 20, "ability.createNew")); + + y += 22; + addButton(new GuiNpcButton(SOURCE_BUILT_IN, guiLeft + 10, y, 180, 20, "gui.builtin")); + + if (showNpcOption) { + y += 22; + addButton(new GuiNpcButton(SOURCE_NPC_SLOTS, guiLeft + 10, y, 180, 20, "ability.fromNpc")); + } } @Override public void buttonEvent(GuiButton guibutton) { int id = guibutton.id; - if (id >= 0 && id <= 2) { + if (id >= 0 && id <= 3) { setResult(id); close(); } diff --git a/src/main/java/noppes/npcs/client/gui/advanced/SubGuiCustomEffectSelect.java b/src/main/java/noppes/npcs/client/gui/advanced/SubGuiCustomEffectSelect.java index 093723cae..411d03351 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/SubGuiCustomEffectSelect.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/SubGuiCustomEffectSelect.java @@ -20,6 +20,7 @@ import java.util.Map; /** * SubGui for selecting a custom effect from CustomEffectController. + * Supports switching between effect maps (index 0 = custom, addon indices via toggle button). */ @SideOnly(Side.CLIENT) public class SubGuiCustomEffectSelect extends SubGuiInterface implements ICustomScrollListener, ITextfieldListener { @@ -28,11 +29,25 @@ public class SubGuiCustomEffectSelect extends SubGuiInterface implements ICustom private final HashMap displayNameToId = new HashMap<>(); private final HashMap allDisplayNameToId = new HashMap<>(); private int selectedEffectId = -1; + private int selectedIndex = 0; private String search = ""; private final int preselectedId; + private final int preselectedIndex; + + /** The effect map index currently being viewed */ + private int viewIndex = 0; + + /** Ordered list of available indices for toggling */ + private List availableIndices; public SubGuiCustomEffectSelect(int preselectedId) { + this(preselectedId, 0); + } + + public SubGuiCustomEffectSelect(int preselectedId, int preselectedIndex) { this.preselectedId = preselectedId; + this.preselectedIndex = preselectedIndex; + this.viewIndex = preselectedIndex; setBackground("menubg.png"); xSize = 200; ySize = 216; @@ -42,22 +57,33 @@ public class SubGuiCustomEffectSelect extends SubGuiInterface implements ICustom public void initGui() { super.initGui(); + buildAvailableIndices(); + addTextField(new GuiNpcTextField(10, this, fontRendererObj, guiLeft + 5, guiTop + 5, 190, 18, search)); + // Toggle button for switching between effect lists (only if addon indices exist) + if (availableIndices.size() > 1) { + String label = getViewLabel(); + addButton(new GuiNpcButton(2, guiLeft + 5, guiTop + 26, 190, 20, label)); + } + + int scrollTop = availableIndices.size() > 1 ? guiTop + 49 : guiTop + 26; + int scrollHeight = availableIndices.size() > 1 ? 122 : 145; + if (scroll == null) { scroll = new GuiCustomScroll(this, 0); - scroll.setSize(190, 145); } + scroll.setSize(190, scrollHeight); scroll.guiLeft = guiLeft + 5; - scroll.guiTop = guiTop + 26; + scroll.guiTop = scrollTop; addScroll(scroll); buildAllEffects(); List filtered = getFilteredList(); scroll.setUnsortedList(filtered); - // Pre-select current effect - if (preselectedId >= 0 && !scroll.hasSelected()) { + // Pre-select current effect (only if viewing the same index) + if (preselectedId >= 0 && viewIndex == preselectedIndex && !scroll.hasSelected()) { for (String name : filtered) { Integer id = displayNameToId.get(name); if (id != null && id == preselectedId) { @@ -72,9 +98,40 @@ public class SubGuiCustomEffectSelect extends SubGuiInterface implements ICustom addButton(new GuiNpcButton(1, guiLeft + 105, guiTop + 188, 90, 20, "gui.cancel")); } + private void buildAvailableIndices() { + availableIndices = new ArrayList<>(); + CustomEffectController controller = CustomEffectController.getInstance(); + + // Always include index 0 + availableIndices.add(0); + + // Add any addon indices that have registered labels + HashMap labels = controller.getIndexLabels(); + for (int idx : labels.keySet()) { + if (idx != 0 && controller.getEffectMap(idx) != null) { + availableIndices.add(idx); + } + } + Collections.sort(availableIndices); + + // Ensure viewIndex is valid + if (!availableIndices.contains(viewIndex)) { + viewIndex = 0; + } + } + + private String getViewLabel() { + if (viewIndex == 0) { + return "Custom Effects"; + } + HashMap labels = CustomEffectController.getInstance().getIndexLabels(); + String label = labels.get(viewIndex); + return label != null ? label : "Index " + viewIndex; + } + private void buildAllEffects() { allDisplayNameToId.clear(); - HashMap effects = CustomEffectController.getInstance().getCustomEffects(); + HashMap effects = CustomEffectController.getInstance().getEffectMap(viewIndex); if (effects == null) return; for (CustomEffect ce : effects.values()) { if (ce.getName() != null && !ce.getName().isEmpty()) { @@ -103,10 +160,19 @@ public class SubGuiCustomEffectSelect extends SubGuiInterface implements ICustom String name = scroll.getSelected(); Integer id = displayNameToId.get(name); selectedEffectId = id != null ? id : -1; + selectedIndex = viewIndex; close(); } else if (guibutton.id == 1) { selectedEffectId = -1; close(); + } else if (guibutton.id == 2) { + // Toggle to next available index + int currentPos = availableIndices.indexOf(viewIndex); + int nextPos = (currentPos + 1) % availableIndices.size(); + viewIndex = availableIndices.get(nextPos); + search = ""; + scroll = null; + initGui(); } } @@ -122,6 +188,7 @@ public class SubGuiCustomEffectSelect extends SubGuiInterface implements ICustom if (guiCustomScroll.id == 0 && selection != null) { Integer id = displayNameToId.get(selection); selectedEffectId = id != null ? id : -1; + selectedIndex = viewIndex; close(); } } @@ -146,4 +213,8 @@ public class SubGuiCustomEffectSelect extends SubGuiInterface implements ICustom public int getSelectedEffectId() { return selectedEffectId; } + + public int getSelectedIndex() { + return selectedIndex; + } } diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNpcManageAbilities.java b/src/main/java/noppes/npcs/client/gui/global/GuiNpcManageAbilities.java index 1df1da2b7..f6562e7a5 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNpcManageAbilities.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNpcManageAbilities.java @@ -600,6 +600,7 @@ public class GuiNpcManageAbilities extends GuiAbilityInterface } private void openConfig(Ability ability) { + if (ability.isBuiltIn()) return; // Built-in abilities are immutable selectedAbility = ability; selected = ability.getName(); previewExecutor.stop(); diff --git a/src/main/java/noppes/npcs/controllers/CustomEffectController.java b/src/main/java/noppes/npcs/controllers/CustomEffectController.java index d1036dc70..c5a1f9948 100644 --- a/src/main/java/noppes/npcs/controllers/CustomEffectController.java +++ b/src/main/java/noppes/npcs/controllers/CustomEffectController.java @@ -37,6 +37,7 @@ public class CustomEffectController implements ICustomEffectHandler { public static CustomEffectController Instance = new CustomEffectController(); public HashMap> indexMapper = new HashMap<>(); + private HashMap indexLabels = new HashMap<>(); public HashMap customEffectsSync = new HashMap<>(); @@ -59,6 +60,14 @@ public class CustomEffectController implements ICustomEffectHandler { indexMapper.put(index, (HashMap) effectHashMap); } + public void registerEffectMapLabel(int index, String label) { + indexLabels.put(index, label); + } + + public HashMap getIndexLabels() { + return indexLabels; + } + public HashMap getCustomEffects() { return indexMapper.get(0); } @@ -354,10 +363,7 @@ public class CustomEffectController implements ICustomEffectHandler { } public HashMap getEffectMap(int index) { - if (indexMapper.containsKey(index)) { - return getEffectMap(index); - } - return null; + return indexMapper.get(index); } private File getDir() {