mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-20 09:59:42 +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
@@ -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();
|
||||
|
||||
Reference in new issue
Block a user