From fb336f27bb621485628562899457d5a72c183b61 Mon Sep 17 00:00:00 2001 From: ZeroEpoch1969 <13510767+ZeroEpoch1969@users.noreply.github.com> Date: Wed, 7 Aug 2019 00:31:05 -0700 Subject: [PATCH] block spawn eggs --- TotalFreedomMod.iml | 68 +++++++++++++++++-- .../blocking/BlockBlocker.java | 3 - .../blocking/EventBlocker.java | 14 +--- .../blocking/InteractBlocker.java | 9 +++ .../totalfreedommod/util/Groups.java | 60 ++++++++++++++++ 5 files changed, 135 insertions(+), 19 deletions(-) diff --git a/TotalFreedomMod.iml b/TotalFreedomMod.iml index 8668eadf..9fb36052 100644 --- a/TotalFreedomMod.iml +++ b/TotalFreedomMod.iml @@ -1,5 +1,5 @@ - + @@ -17,7 +17,6 @@ - @@ -25,7 +24,6 @@ - @@ -46,7 +44,69 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/me/totalfreedom/totalfreedommod/blocking/BlockBlocker.java b/src/main/java/me/totalfreedom/totalfreedommod/blocking/BlockBlocker.java index 27dd90d1..f00176ac 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/blocking/BlockBlocker.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/blocking/BlockBlocker.java @@ -7,13 +7,11 @@ import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FUtil; import org.bukkit.ChatColor; import org.bukkit.Material; -import org.bukkit.entity.Egg; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.inventory.ItemStack; -import static net.minecraft.server.v1_14_R1.EnumMobSpawn.SPAWN_EGG; public class BlockBlocker extends FreedomService { @@ -105,7 +103,6 @@ public class BlockBlocker extends FreedomService event.setCancelled(true); break; } - //TODO: seth block eggs thanks } } } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/blocking/EventBlocker.java b/src/main/java/me/totalfreedom/totalfreedommod/blocking/EventBlocker.java index 3efdf873..bbdc1754 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/blocking/EventBlocker.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/blocking/EventBlocker.java @@ -218,19 +218,9 @@ public class EventBlocker extends FreedomService @EventHandler(priority = EventPriority.NORMAL) public void onBlockDispense(BlockDispenseEvent event) { - ItemStack item = event.getItem(); - if (Groups.SHULKER_BOXES.contains(item.getType())) + if (Groups.SPAWN_EGGS.contains(event.getItem().getType())) { - BlockStateMeta blockStateMeta = (BlockStateMeta)item.getItemMeta(); - ShulkerBox shulkerBox = (ShulkerBox)blockStateMeta.getBlockState(); - for (ItemStack itemStack : shulkerBox.getInventory().getContents()) - { - if (itemStack != null) - { - event.setCancelled(true); - break; - } - } + event.setCancelled(true); } } } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/blocking/InteractBlocker.java b/src/main/java/me/totalfreedom/totalfreedommod/blocking/InteractBlocker.java index 9dae6290..cc71cd4f 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/blocking/InteractBlocker.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/blocking/InteractBlocker.java @@ -4,6 +4,7 @@ import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.util.FLog; +import me.totalfreedom.totalfreedommod.util.Groups; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -79,6 +80,14 @@ public class InteractBlocker extends FreedomService } } + if (Groups.SPAWN_EGGS.contains(event.getMaterial())) + { + player.getInventory().clear(player.getInventory().getHeldItemSlot()); + player.sendMessage(ChatColor.GRAY + "Spawn eggs are currently disabled."); + event.setCancelled(true); + return; + } + switch (event.getMaterial()) { case WATER_BUCKET: diff --git a/src/main/java/me/totalfreedom/totalfreedommod/util/Groups.java b/src/main/java/me/totalfreedom/totalfreedommod/util/Groups.java index 4cbc8ec0..5b9f2e55 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/util/Groups.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/util/Groups.java @@ -98,4 +98,64 @@ public class Groups EntityType.WANDERING_TRADER, EntityType.WOLF, EntityType.ZOMBIE); + + public static final List SPAWN_EGGS = Arrays.asList( + Material.BAT_SPAWN_EGG, + Material.BLAZE_SPAWN_EGG, + Material.CAVE_SPIDER_SPAWN_EGG, + Material.CHICKEN_SPAWN_EGG, + Material.CAT_SPAWN_EGG, + Material.COD_SPAWN_EGG, + Material.COW_SPAWN_EGG, + Material.CREEPER_SPAWN_EGG, + Material.DOLPHIN_SPAWN_EGG, + Material.DONKEY_SPAWN_EGG, + Material.DROWNED_SPAWN_EGG, + Material.ELDER_GUARDIAN_SPAWN_EGG, + Material.ENDERMAN_SPAWN_EGG, + Material.ENDERMITE_SPAWN_EGG, + Material.EVOKER_SPAWN_EGG, + Material.FOX_SPAWN_EGG, + Material.GHAST_SPAWN_EGG, + Material.GUARDIAN_SPAWN_EGG, + Material.HORSE_SPAWN_EGG, + Material.HUSK_SPAWN_EGG, + Material.LLAMA_SPAWN_EGG, + Material.MAGMA_CUBE_SPAWN_EGG, + Material.MOOSHROOM_SPAWN_EGG, + Material.MULE_SPAWN_EGG, + Material.OCELOT_SPAWN_EGG, + Material.PANDA_SPAWN_EGG, + Material.PARROT_SPAWN_EGG, + Material.PHANTOM_SPAWN_EGG, + Material.PIG_SPAWN_EGG, + Material.PILLAGER_SPAWN_EGG, + Material.POLAR_BEAR_SPAWN_EGG, + Material.PUFFERFISH_SPAWN_EGG, + Material.RABBIT_SPAWN_EGG, + Material.RAVAGER_SPAWN_EGG, + Material.SALMON_SPAWN_EGG, + Material.SHEEP_SPAWN_EGG, + Material.SHULKER_SPAWN_EGG, + Material.SILVERFISH_SPAWN_EGG, + Material.SKELETON_SPAWN_EGG, + Material.SKELETON_HORSE_SPAWN_EGG, + Material.SLIME_SPAWN_EGG, + Material.SPIDER_SPAWN_EGG, + Material.SQUID_SPAWN_EGG, + Material.STRAY_SPAWN_EGG, + Material.TRADER_LLAMA_SPAWN_EGG, + Material.TROPICAL_FISH_SPAWN_EGG, + Material.TURTLE_SPAWN_EGG, + Material.VEX_SPAWN_EGG, + Material.VILLAGER_SPAWN_EGG, + Material.VINDICATOR_SPAWN_EGG, + Material.WANDERING_TRADER_SPAWN_EGG, + Material.WITCH_SPAWN_EGG, + Material.WITHER_SKELETON_SPAWN_EGG, + Material.WOLF_SPAWN_EGG, + Material.ZOMBIE_SPAWN_EGG, + Material.ZOMBIE_HORSE_SPAWN_EGG, + Material.ZOMBIE_PIGMAN_SPAWN_EGG, + Material.ZOMBIE_VILLAGER_SPAWN_EGG); }