diff --git a/src/api b/src/api index 22135344e..9fbd1ecef 160000 --- a/src/api +++ b/src/api @@ -1 +1 @@ -Subproject commit 22135344e85a368af2cacc622bc7f50f32505b72 +Subproject commit 9fbd1eceffaa32f088676ff89d13fe3ca4ba1155 diff --git a/src/main/java/kamkeel/npcs/command/CommandKamkeel.java b/src/main/java/kamkeel/npcs/command/CommandKamkeel.java index fb3b75ede..f87068968 100644 --- a/src/main/java/kamkeel/npcs/command/CommandKamkeel.java +++ b/src/main/java/kamkeel/npcs/command/CommandKamkeel.java @@ -136,13 +136,13 @@ public class CommandKamkeel extends CommandBase { List keys = new ArrayList<>(RequirementCheckerRegistry.getAllKeys()); return CommandBase.getListOfStringsMatchingLastWord(args, keys.toArray(new String[keys.size()])); } else if (usage.equals("")) { - List keys = getSortedEffectNames(); + List keys = stripColorCodes(getSortedEffectNames()); return CommandBase.getListOfStringsMatchingLastWord(args, keys.toArray(new String[keys.size()])); } else if (usage.equals("")) { - List keys = getPlayerAbilityNames(); + List keys = stripColorCodes(getPlayerAbilityNames()); return CommandBase.getListOfStringsMatchingLastWord(args, keys.toArray(new String[keys.size()])); } else if (usage.equals("")) { - List keys = getPlayerChainNames(); + List keys = stripColorCodes(getPlayerChainNames()); return CommandBase.getListOfStringsMatchingLastWord(args, keys.toArray(new String[keys.size()])); } } @@ -150,6 +150,14 @@ public class CommandKamkeel extends CommandBase { return command.addTabCompletionOptions(sender, Arrays.copyOfRange(args, 1, args.length)); } + private static List stripColorCodes(List list) { + List result = new ArrayList<>(list.size()); + for (String s : list) { + result.add(s.replaceAll("\u00A7[0-9a-fk-or]", "")); + } + return result; + } + public CommandKamkeelBase getCommand(String[] args) { if (args.length == 0) return null; diff --git a/src/main/java/kamkeel/npcs/command/EffectCommand.java b/src/main/java/kamkeel/npcs/command/EffectCommand.java index 8a6a2e669..3d7cdbec8 100644 --- a/src/main/java/kamkeel/npcs/command/EffectCommand.java +++ b/src/main/java/kamkeel/npcs/command/EffectCommand.java @@ -308,6 +308,7 @@ public class EffectCommand extends CommandKamkeelBase { // Helper method to find effects by name. private List findEffectsByName(String name) { + String strippedName = stripColorCodes(name); List matches = new ArrayList<>(); CustomEffectController controller = CustomEffectController.getInstance(); for (Map.Entry> entry : controller.indexMapper.entrySet()) { @@ -317,11 +318,12 @@ public class EffectCommand extends CommandKamkeelBase { for (Map.Entry effectEntry : effects.entrySet()) { int id = effectEntry.getKey(); CustomEffect effect = effectEntry.getValue(); - if (effect.getName().equalsIgnoreCase(name)) { + String effectName = stripColorCodes(effect.getName()); + if (effectName.equalsIgnoreCase(strippedName)) { List exact = new ArrayList<>(); exact.add(new EffectEntry(idx, id, effect)); return exact; - } else if (effect.getName().toLowerCase().contains(name.toLowerCase())) { + } else if (effectName.toLowerCase().contains(strippedName.toLowerCase())) { matches.add(new EffectEntry(idx, id, effect)); } } @@ -329,6 +331,10 @@ public class EffectCommand extends CommandKamkeelBase { return matches; } + private static String stripColorCodes(String s) { + return s.replaceAll("\u00A7[0-9a-fk-or]", ""); + } + public static List getSortedEffectNames() { List entries = new ArrayList<>(); CustomEffectController controller = CustomEffectController.getInstance(); diff --git a/src/main/java/noppes/npcs/scripted/item/ScriptLinkedItem.java b/src/main/java/noppes/npcs/scripted/item/ScriptLinkedItem.java index 1c4a2ac91..f86d5c113 100644 --- a/src/main/java/noppes/npcs/scripted/item/ScriptLinkedItem.java +++ b/src/main/java/noppes/npcs/scripted/item/ScriptLinkedItem.java @@ -87,6 +87,11 @@ public class ScriptLinkedItem extends ScriptCustomizableItem implements IItemLin return this.durabilityValue; } + public void setDurabilityValue(float value) { + this.durabilityValue = (double) value; + saveItemData(); + } + @Override public int getMaxItemUseDuration() { return this.linkedItem.maxItemUseDuration; @@ -217,6 +222,7 @@ public class ScriptLinkedItem extends ScriptCustomizableItem implements IItemLin this.itemDisplay.writeToNBT(compound); compound.setTag(LinkedItem.LINKED_DATA_NBT_TAG, this.linkedItem.writeToNBT(false)); compound.setInteger(LinkedItem.LINKED_VERSION_VERSION_TAG, this.linkedVersion); + compound.setDouble("DurabilityValue", this.durabilityValue); return compound; } @@ -224,5 +230,7 @@ public class ScriptLinkedItem extends ScriptCustomizableItem implements IItemLin this.itemDisplay.readFromNBT(compound); this.linkedItem.readFromNBT(compound.getCompoundTag(LinkedItem.LINKED_DATA_NBT_TAG)); this.linkedVersion = compound.getInteger(LinkedItem.LINKED_VERSION_VERSION_TAG); + if (compound.hasKey("DurabilityValue")) + this.durabilityValue = compound.getDouble("DurabilityValue"); } }