Skip to content

Commit

Permalink
excludeItemsContainingThisString now contains a list of strings (MLG-…
Browse files Browse the repository at this point in the history
  • Loading branch information
kikelkik committed Oct 25, 2020
1 parent d5ce2c6 commit 6ca03a5
Showing 1 changed file with 9 additions and 4 deletions.
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,11 @@ 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 +434,10 @@ 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

0 comments on commit 6ca03a5

Please sign in to comment.