Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable multiple strings to exclude items from the sorting process #38

Merged
merged 2 commits into from
Oct 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/me/ryanhamshire/AutomaticInventory/AutomaticInventory.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class AutomaticInventory extends JavaPlugin
Set<Material> config_noAutoRefill = new HashSet<>();
Set<Material> config_noAutoDeposit = new HashSet<>();
static boolean autosortEnabledByDefault = true;
private static String excludeItemsContainingThisString;
private static List<String> excludeItemsContainingThisString;

//this handles data storage, like player and region data
public DataStore dataStore;
Expand Down Expand Up @@ -104,7 +104,12 @@ public void onEnable()
autosortEnabledByDefault = config.getBoolean("autosortEnabledByDefault", true);
outConfig.set("autosortEnabledByDefault", autosortEnabledByDefault);

excludeItemsContainingThisString = config.getString("excludeItemsContainingThisString", "");
excludeItemsContainingThisString = config.getStringList("excludeItemsContainingThisString");
String legacyExcludedItem = config.getString("excludeItemsContainingThisString");
if (legacyExcludedItem != null && !excludeItemsContainingThisString.toString().equals(legacyExcludedItem))
{
excludeItemsContainingThisString.add(legacyExcludedItem);
}
outConfig.set("excludeItemsContainingThisString", excludeItemsContainingThisString);

try
Expand Down Expand Up @@ -430,9 +435,9 @@ private static boolean isItemExcludedViaName(ItemStack itemStack)
if (!meta.hasDisplayName())
return false;
String name = meta.getDisplayName();
return name.contains(excludeItemsContainingThisString);
return excludeItemsContainingThisString.stream().anyMatch(name::contains);
}

public class FakePlayerInteractEvent extends PlayerInteractEvent
{
public FakePlayerInteractEvent(Player player, Action rightClickBlock, ItemStack itemInHand, Block clickedBlock, BlockFace blockFace)
Expand Down