mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-17 02:55:04 +00:00
Allow any character to be used as prefix
This commit is contained in:
1 parent
e0171adc65
commit
a9e069166f
8 files changed
+125
-133
No files matched your search
@@ -139,7 +139,7 @@ public class ItemList {
|
||||
@Override
|
||||
public boolean matches(ItemStack item) {
|
||||
for (ItemFilter filter : filters) try {
|
||||
if (filter.matches(item)) return true;
|
||||
if (filter != null && filter.matches(item)) return true;
|
||||
} catch (Exception e) {
|
||||
NEIClientConfig.logger.error("Exception filtering " + item + " with " + filter, e);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.storage.SaveFormatComparator;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
@@ -183,60 +182,105 @@ public class NEIClientConfig {
|
||||
tag.getTag("inventory.search.quoteDropItemName").setComment("Quote Drop Item Name").getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.search.quoteDropItemName", true));
|
||||
|
||||
tag.getTag("inventory.search.modNameSearchMode").setComment("Search mode for Mod Names (prefix: @)")
|
||||
.getIntValue(1);
|
||||
API.addOption(new OptionCycled("inventory.search.modNameSearchMode", 3, true) {
|
||||
String preModName = tag.getTag("inventory.search.modNameSearchPrefix").setComment(
|
||||
"Search prefix for Mod Names (leave empty to always search for Mod Names, enter anything longer than one character to disable)")
|
||||
.getValue("@");
|
||||
|
||||
@Override
|
||||
public String getButtonText() {
|
||||
return translateN(name + "." + value(), EnumChatFormatting.LIGHT_PURPLE + "@");
|
||||
String preTooltip = tag.getTag("inventory.search.tooltipSearchPrefix").setComment(
|
||||
"Search mode for Tooltips (leave empty to always search for Tooltips, enter anything longer than one character to disable)")
|
||||
.getValue("");
|
||||
if (preTooltip.length() == 1 && preTooltip.equals(preModName)) {
|
||||
// conflicting prefix char
|
||||
logger.warn(
|
||||
"Search prefix inventory.search.tooltipSearchPrefix conflicts with inventory.search.modNameSearchPrefix ({})! Resetting to default.",
|
||||
preTooltip);
|
||||
preTooltip = "";
|
||||
tag.getTag("inventory.search.tooltipSearchPrefix").setValue(preTooltip);
|
||||
}
|
||||
|
||||
String preIdentifier = tag.getTag("inventory.search.identifierSearchPrefix").setComment(
|
||||
"Search mode for identifier (leave empty to always search for identifier, enter anything longer than one character to disable)")
|
||||
.getValue("");
|
||||
if (preIdentifier.length() == 1) {
|
||||
if (preIdentifier.equals(preModName)) {
|
||||
// conflicting prefix char
|
||||
logger.warn(
|
||||
"Search prefix inventory.search.identifierSearchPrefix conflicts with inventory.search.modNameSearchPrefix ({})! Resetting to default.",
|
||||
preIdentifier);
|
||||
preIdentifier = "";
|
||||
tag.getTag("inventory.search.identifierSearchPrefix").setValue(preIdentifier);
|
||||
} else if (preIdentifier.equals(preTooltip)) {
|
||||
// conflicting prefix char
|
||||
logger.warn(
|
||||
"Search prefix inventory.search.identifierSearchPrefix conflicts with inventory.search.tooltipSearchPrefix ({})! Resetting to default.",
|
||||
preIdentifier);
|
||||
preIdentifier = "";
|
||||
tag.getTag("inventory.search.identifierSearchPrefix").setValue(preIdentifier);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
tag.getTag("inventory.search.tooltipSearchMode").setComment("Search mode for Tooltips (prefix: #)")
|
||||
.getIntValue(0);
|
||||
API.addOption(new OptionCycled("inventory.search.tooltipSearchMode", 3, true) {
|
||||
|
||||
@Override
|
||||
public String getButtonText() {
|
||||
return translateN(name + "." + value(), EnumChatFormatting.YELLOW + "#");
|
||||
String preODName = tag.getTag("inventory.search.oreDictSearchPrefix").setComment(
|
||||
"Search mode for Ore Dictionary Tags (leave empty to always search for Ore Dictionary Tags, enter anything longer than one character to disable)")
|
||||
.getValue("");
|
||||
if (preODName.length() == 1) {
|
||||
if (preODName.equals(preModName)) {
|
||||
// conflicting prefix char
|
||||
logger.warn(
|
||||
"Search prefix inventory.search.oreDictSearchPrefix conflicts with inventory.search.modNameSearchPrefix ({})! Resetting to default.",
|
||||
preIdentifier);
|
||||
preODName = "";
|
||||
tag.getTag("inventory.search.oreDictSearchPrefix").setValue(preODName);
|
||||
} else if (preODName.equals(preTooltip)) {
|
||||
// conflicting prefix char
|
||||
logger.warn(
|
||||
"Search prefix inventory.search.oreDictSearchPrefix conflicts with inventory.search.tooltipSearchPrefix ({})! Resetting to default.",
|
||||
preIdentifier);
|
||||
preODName = "";
|
||||
tag.getTag("inventory.search.oreDictSearchPrefix").setValue(preODName);
|
||||
} else if (preODName.equals(preIdentifier)) {
|
||||
// conflicting prefix char
|
||||
logger.warn(
|
||||
"Search prefix inventory.search.oreDictSearchPrefix conflicts with inventory.search.identifierSearchPrefix ({})! Resetting to default.",
|
||||
preIdentifier);
|
||||
preODName = "";
|
||||
tag.getTag("inventory.search.oreDictSearchPrefix").setValue(preODName);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
tag.getTag("inventory.search.identifierSearchMode").setComment("Search mode for identifier (prefix: &)")
|
||||
.getIntValue(0);
|
||||
API.addOption(new OptionCycled("inventory.search.identifierSearchMode", 3, true) {
|
||||
|
||||
@Override
|
||||
public String getButtonText() {
|
||||
return translateN(name + "." + value(), EnumChatFormatting.GOLD + "&");
|
||||
String preSubset = tag.getTag("inventory.search.subsetsSearchPrefix").setComment(
|
||||
"Search mode for Item Subsets (leave empty to always search for Item Subsets, enter anything longer than one character to disable)")
|
||||
.getValue("DISABLE");
|
||||
if (preSubset.length() == 1) {
|
||||
if (preSubset.equals(preModName)) {
|
||||
// conflicting prefix char
|
||||
logger.warn(
|
||||
"Search prefix inventory.search.subsetsSearchPrefix conflicts with inventory.search.modNameSearchPrefix ({})! Resetting to default.",
|
||||
preIdentifier);
|
||||
preSubset = "";
|
||||
tag.getTag("inventory.search.subsetsSearchPrefix").setValue(preSubset);
|
||||
} else if (preSubset.equals(preTooltip)) {
|
||||
// conflicting prefix char
|
||||
logger.warn(
|
||||
"Search prefix inventory.search.subsetsSearchPrefix conflicts with inventory.search.tooltipSearchPrefix ({})! Resetting to default.",
|
||||
preIdentifier);
|
||||
preSubset = "";
|
||||
tag.getTag("inventory.search.subsetsSearchPrefix").setValue(preSubset);
|
||||
} else if (preSubset.equals(preIdentifier)) {
|
||||
// conflicting prefix char
|
||||
logger.warn(
|
||||
"Search prefix inventory.search.subsetsSearchPrefix conflicts with inventory.search.identifierSearchPrefix ({})! Resetting to default.",
|
||||
preIdentifier);
|
||||
preSubset = "";
|
||||
tag.getTag("inventory.search.subsetsSearchPrefix").setValue(preSubset);
|
||||
} else if (preSubset.equals(preODName)) {
|
||||
// conflicting prefix char
|
||||
logger.warn(
|
||||
"Search prefix inventory.search.subsetsSearchPrefix conflicts with inventory.search.oreDictSearchPrefix ({})! Resetting to default.",
|
||||
preIdentifier);
|
||||
preSubset = "";
|
||||
tag.getTag("inventory.search.subsetsSearchPrefix").setValue(preSubset);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
tag.getTag("inventory.search.oreDictSearchMode").setComment("Search mode for Tag Names (prefix: $)")
|
||||
.getIntValue(0);
|
||||
API.addOption(new OptionCycled("inventory.search.oreDictSearchMode", 3, true) {
|
||||
|
||||
@Override
|
||||
public String getButtonText() {
|
||||
return translateN(name + "." + value(), EnumChatFormatting.AQUA + "$");
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
tag.getTag("inventory.search.subsetsSearchMode").setComment("Search mode for Item Subsets (prefix: %)")
|
||||
.getIntValue(2);
|
||||
API.addOption(new OptionCycled("inventory.search.subsetsSearchMode", 3, true) {
|
||||
|
||||
@Override
|
||||
public String getButtonText() {
|
||||
return translateN(name + "." + value(), EnumChatFormatting.DARK_PURPLE + "%");
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
tag.getTag("inventory.bookmarks.enabled").setComment("Enable/Disable Bookmark Panel").getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.bookmarks.enabled", true));
|
||||
|
||||
@@ -44,12 +44,12 @@ public class SearchField extends TextField implements ItemFilterProvider {
|
||||
|
||||
protected final Function<Pattern, ItemFilter> createFilter;
|
||||
protected final String name;
|
||||
protected final char prefix;
|
||||
protected final char defaultPrefix;
|
||||
protected final EnumChatFormatting highlightedColor;
|
||||
|
||||
public SearchParserProvider(char prefix, String name, EnumChatFormatting highlightedColor,
|
||||
public SearchParserProvider(char defaultPrefix, String name, EnumChatFormatting highlightedColor,
|
||||
Function<Pattern, ItemFilter> createFilter) {
|
||||
this.prefix = prefix;
|
||||
this.defaultPrefix = defaultPrefix;
|
||||
this.name = name;
|
||||
this.highlightedColor = highlightedColor;
|
||||
this.createFilter = createFilter;
|
||||
@@ -74,7 +74,11 @@ public class SearchField extends TextField implements ItemFilterProvider {
|
||||
|
||||
@Override
|
||||
public char getPrefix() {
|
||||
return this.prefix;
|
||||
String prefix = NEIClientConfig.getStringSetting("inventory.search." + this.name + "SearchPrefix");
|
||||
if (prefix.length() == 1) {
|
||||
return prefix.charAt(0);
|
||||
}
|
||||
return this.defaultPrefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -84,7 +88,8 @@ public class SearchField extends TextField implements ItemFilterProvider {
|
||||
|
||||
@Override
|
||||
public SearchMode getSearchMode() {
|
||||
return SearchMode.fromInt(NEIClientConfig.getIntSetting("inventory.search." + this.name + "SearchMode"));
|
||||
return SearchMode
|
||||
.fromString(NEIClientConfig.getStringSetting("inventory.search." + this.name + "SearchPrefix"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,17 +29,12 @@ public class SearchTokenParser {
|
||||
PREFIX,
|
||||
NEVER;
|
||||
|
||||
public static SearchMode fromInt(int value) {
|
||||
switch (value) {
|
||||
case 0:
|
||||
return ALWAYS;
|
||||
case 1:
|
||||
return PREFIX;
|
||||
case 2:
|
||||
return NEVER;
|
||||
default:
|
||||
return ALWAYS;
|
||||
}
|
||||
public static SearchMode fromString(String value) {
|
||||
return switch (value.length()) {
|
||||
case 0 -> ALWAYS;
|
||||
case 1 -> PREFIX;
|
||||
default -> NEVER;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -381,6 +381,10 @@ public class SubsetWidget extends Button implements ItemFilterProvider, ItemsLoa
|
||||
}
|
||||
|
||||
public char getPrefix() {
|
||||
String prefix = NEIClientConfig.getStringSetting("inventory.search.subsetsSearchPrefix");
|
||||
if (prefix.length() == 1) {
|
||||
return prefix.charAt(0);
|
||||
}
|
||||
return '%';
|
||||
}
|
||||
|
||||
@@ -390,7 +394,7 @@ public class SubsetWidget extends Button implements ItemFilterProvider, ItemsLoa
|
||||
|
||||
@Override
|
||||
public SearchMode getSearchMode() {
|
||||
return SearchMode.fromInt(NEIClientConfig.getIntSetting("inventory.search.subsetsSearchMode"));
|
||||
return SearchMode.fromString(NEIClientConfig.getStringSetting("inventory.search.subsetsSearchPrefix"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -141,11 +141,12 @@ public class ItemInfo {
|
||||
|
||||
private static void addSearchProviders() {
|
||||
API.addSearchProvider(
|
||||
new SearchParserProvider(
|
||||
'\0',
|
||||
"default",
|
||||
EnumChatFormatting.RESET,
|
||||
(pattern) -> new PatternItemFilter(pattern)) {
|
||||
new SearchParserProvider('\0', "default", EnumChatFormatting.RESET, PatternItemFilter::new) {
|
||||
|
||||
@Override
|
||||
public char getPrefix() {
|
||||
return defaultPrefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SearchMode getSearchMode() {
|
||||
@@ -154,29 +155,12 @@ public class ItemInfo {
|
||||
|
||||
});
|
||||
API.addSearchProvider(
|
||||
new SearchParserProvider(
|
||||
'@',
|
||||
"modName",
|
||||
EnumChatFormatting.LIGHT_PURPLE,
|
||||
(pattern) -> new ModNameFilter(pattern)));
|
||||
new SearchParserProvider('@', "modName", EnumChatFormatting.LIGHT_PURPLE, ModNameFilter::new));
|
||||
API.addSearchProvider(
|
||||
new SearchParserProvider(
|
||||
'$',
|
||||
"oreDict",
|
||||
EnumChatFormatting.AQUA,
|
||||
(pattern) -> new OreDictionaryFilter(pattern)));
|
||||
new SearchParserProvider('$', "oreDict", EnumChatFormatting.AQUA, OreDictionaryFilter::new));
|
||||
API.addSearchProvider(new SearchParserProvider('#', "tooltip", EnumChatFormatting.YELLOW, TooltipFilter::new));
|
||||
API.addSearchProvider(
|
||||
new SearchParserProvider(
|
||||
'#',
|
||||
"tooltip",
|
||||
EnumChatFormatting.YELLOW,
|
||||
(pattern) -> new TooltipFilter(pattern)));
|
||||
API.addSearchProvider(
|
||||
new SearchParserProvider(
|
||||
'&',
|
||||
"identifier",
|
||||
EnumChatFormatting.GOLD,
|
||||
(pattern) -> new IdentifierFilter(pattern)));
|
||||
new SearchParserProvider('&', "identifier", EnumChatFormatting.GOLD, IdentifierFilter::new));
|
||||
}
|
||||
|
||||
private static void addIDDumps() {
|
||||
|
||||
Reference in new issue
Block a user