mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 18:57:32 +00:00
Small Bug Fixes to Flight, Command Handling, Linked Items
This commit is contained in:
1 parent
109e31fd2d
commit
702dec9c40
4 files changed
+28
-6
No files matched your search
+1
-1
Submodule src/api updated: 22135344e8...9fbd1eceff.
@@ -136,13 +136,13 @@ public class CommandKamkeel extends CommandBase {
|
||||
List<String> keys = new ArrayList<>(RequirementCheckerRegistry.getAllKeys());
|
||||
return CommandBase.getListOfStringsMatchingLastWord(args, keys.toArray(new String[keys.size()]));
|
||||
} else if (usage.equals("<effectName>")) {
|
||||
List<String> keys = getSortedEffectNames();
|
||||
List<String> keys = stripColorCodes(getSortedEffectNames());
|
||||
return CommandBase.getListOfStringsMatchingLastWord(args, keys.toArray(new String[keys.size()]));
|
||||
} else if (usage.equals("<ability>")) {
|
||||
List<String> keys = getPlayerAbilityNames();
|
||||
List<String> keys = stripColorCodes(getPlayerAbilityNames());
|
||||
return CommandBase.getListOfStringsMatchingLastWord(args, keys.toArray(new String[keys.size()]));
|
||||
} else if (usage.equals("<chain>")) {
|
||||
List<String> keys = getPlayerChainNames();
|
||||
List<String> 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<String> stripColorCodes(List<String> list) {
|
||||
List<String> 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;
|
||||
|
||||
@@ -308,6 +308,7 @@ public class EffectCommand extends CommandKamkeelBase {
|
||||
|
||||
// Helper method to find effects by name.
|
||||
private List<EffectEntry> findEffectsByName(String name) {
|
||||
String strippedName = stripColorCodes(name);
|
||||
List<EffectEntry> matches = new ArrayList<>();
|
||||
CustomEffectController controller = CustomEffectController.getInstance();
|
||||
for (Map.Entry<Integer, HashMap<Integer, CustomEffect>> entry : controller.indexMapper.entrySet()) {
|
||||
@@ -317,11 +318,12 @@ public class EffectCommand extends CommandKamkeelBase {
|
||||
for (Map.Entry<Integer, CustomEffect> 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<EffectEntry> 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<String> getSortedEffectNames() {
|
||||
List<EffectEntry> entries = new ArrayList<>();
|
||||
CustomEffectController controller = CustomEffectController.getInstance();
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user