Additional dupe failsafes

This commit is contained in:
nossr50 2019-10-18 15:37:36 -07:00
parent 335d708848
commit 76ca7cc88f

View File

@ -58,9 +58,15 @@ public class BlockListener implements Listener {
//Track how many "things" are being dropped //Track how many "things" are being dropped
HashSet<Material> uniqueMaterials = new HashSet<>(); HashSet<Material> uniqueMaterials = new HashSet<>();
boolean dontRewardTE = false; //If we suspect TEs are mixed in with other things don't reward bonus drops for anything that isn't a block boolean dontRewardTE = false; //If we suspect TEs are mixed in with other things don't reward bonus drops for anything that isn't a block
int blockCount = 0;
for(Item item : event.getItems()) { for(Item item : event.getItems()) {
//Track unique materials
uniqueMaterials.add(item.getItemStack().getType()); uniqueMaterials.add(item.getItemStack().getType());
//Count blocks as a second failsafe
if(item.getItemStack().getType().isBlock())
blockCount++;
} }
if(uniqueMaterials.size() > 1) { if(uniqueMaterials.size() > 1) {
@ -69,6 +75,8 @@ public class BlockListener implements Listener {
dontRewardTE = true; dontRewardTE = true;
} }
//If there are more than one block in the item list we can't really trust it and will back out of rewarding bonus drops
if(blockCount <= 1) {
for(Item item : event.getItems()) for(Item item : event.getItems())
{ {
ItemStack is = new ItemStack(item.getItemStack()); ItemStack is = new ItemStack(item.getItemStack());
@ -98,6 +106,7 @@ public class BlockListener implements Listener {
} }
} }
} }
}
if(event.getBlock().hasMetadata(mcMMO.BONUS_DROPS_METAKEY)) if(event.getBlock().hasMetadata(mcMMO.BONUS_DROPS_METAKEY))
event.getBlock().removeMetadata(mcMMO.BONUS_DROPS_METAKEY, plugin); event.getBlock().removeMetadata(mcMMO.BONUS_DROPS_METAKEY, plugin);