mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-18 19:29:31 +00:00
Fixed the Corporea Index kicking you out of the server if you try requesting an item with control codes in the name (such as brews). Closes #1276
This commit is contained in:
1 parent
591db477a0
commit
66f19f35be
2 files changed
+13
-3
No files matched your search
@@ -15,6 +15,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
@@ -31,6 +32,8 @@ public final class CorporeaHelper {
|
||||
private static final WeakHashMap<List<ICorporeaSpark>, List<IInventory>> cachedNetworks = new WeakHashMap();
|
||||
private static final List<ICorporeaAutoCompleteController> autoCompleteControllers = new ArrayList<ICorporeaAutoCompleteController>();
|
||||
|
||||
private static final Pattern patternControlCode = Pattern.compile("(?i)\\u00A7[0-9A-FK-OR]");
|
||||
|
||||
public static final String[] WILDCARD_STRINGS = new String[] {
|
||||
"...", "~", "+", "?" , "*"
|
||||
};
|
||||
@@ -291,7 +294,7 @@ public final class CorporeaHelper {
|
||||
}
|
||||
|
||||
|
||||
String name = stack.getDisplayName().toLowerCase().trim();
|
||||
String name = stripControlCodes(stack.getDisplayName().toLowerCase().trim());
|
||||
return equalOrContain(name, s, contains) || equalOrContain(name + "s", s, contains) || equalOrContain(name + "es", s, contains) || name.endsWith("y") && equalOrContain(name.substring(0, name.length() - 1) + "ies", s, contains);
|
||||
}
|
||||
|
||||
@@ -337,4 +340,9 @@ public final class CorporeaHelper {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Copy from StringUtils
|
||||
public static String stripControlCodes(String str) {
|
||||
return patternControlCode.matcher(str).replaceAll("");
|
||||
}
|
||||
}
|
||||
@@ -42,6 +42,8 @@ public class CorporeaAutoCompleteHandler {
|
||||
List<CompletionData> completions = new ArrayList<CompletionData>();
|
||||
int position;
|
||||
|
||||
private static final String __OBFID = "CL_00001501";
|
||||
|
||||
static TreeSet<String> itemNames = new TreeSet<String>(
|
||||
new Comparator<String>() {
|
||||
@Override
|
||||
@@ -65,7 +67,7 @@ public class CorporeaAutoCompleteHandler {
|
||||
try {
|
||||
item.getSubItems(item, (CreativeTabs) null, curList);
|
||||
for(ItemStack stack : curList)
|
||||
itemNames.add(stack.getDisplayName().trim());
|
||||
itemNames.add(CorporeaHelper.stripControlCodes(stack.getDisplayName().trim()));
|
||||
}
|
||||
catch (Exception e) {}
|
||||
}
|
||||
@@ -166,7 +168,7 @@ public class CorporeaAutoCompleteHandler {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private static class CompletionData implements Comparable<CompletionData> {
|
||||
|
||||
private String string;
|
||||
|
||||
Reference in new issue
Block a user