From c0041e60e27d5933655bd26653ceced355e759d8 Mon Sep 17 00:00:00 2001 From: Magnus Ulf Date: Sat, 22 Dec 2018 23:59:12 +0100 Subject: [PATCH] 1.13 update Mostly changes with Material.java --- plugin.yml | 3 +- .../factions/cmd/CmdFactionsSeeChunkOld.java | 4 +- .../factions/engine/EngineExploit.java | 51 +------ .../massivecraft/factions/entity/MConf.java | 1 - .../worldguard/EngineWorldGuard.java | 2 +- .../factions/util/EnumerationUtil.java | 135 +++++++++--------- .../factions/util/VisualizeUtil.java | 23 +-- 7 files changed, 94 insertions(+), 125 deletions(-) diff --git a/plugin.yml b/plugin.yml index 2b25965b..084cbd57 100644 --- a/plugin.yml +++ b/plugin.yml @@ -6,7 +6,8 @@ website: ${project.url} description: ${project.description} authors: [Cayorion, Madus, Ulumulu1510, MarkehMe, Brettflan] depend: [MassiveCore] -softdepend: [PermissionsEx, Permissions, Essentials, EssentialsChat, HeroChat, iChat, LocalAreaChat, LWC, nChat, ChatManager, AuthMe, Vault, Spout, WorldEdit, WorldGuard, AuthDB, CaptureThePoints, CombatTag] +softdepend: [PermissionsEx, Permissions, Essentials, EssentialsChat, HeroChat, LocalAreaChat, LWC, ChatManager, AuthMe, Vault, WorldEdit, WorldGuard] +api-version: 1.13 permissions: # -------------------------------------------- # # THE REAL NODES diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsSeeChunkOld.java b/src/com/massivecraft/factions/cmd/CmdFactionsSeeChunkOld.java index a707383e..96bf5777 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsSeeChunkOld.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsSeeChunkOld.java @@ -68,8 +68,8 @@ public class CmdFactionsSeeChunkOld extends FactionsCommand { Location loc = new Location(world, blockX, blockY, blockZ); if (loc.getBlock().getType() != Material.AIR) continue; - int typeId = blockY % 5 == 0 ? Material.GLOWSTONE.getId() : Material.GLASS.getId(); - VisualizeUtil.addLocation(player, loc, typeId); + Material type = blockY % 5 == 0 ? Material.GLOWSTONE : Material.GLASS; + VisualizeUtil.addLocation(player, loc, type); } } diff --git a/src/com/massivecraft/factions/engine/EngineExploit.java b/src/com/massivecraft/factions/engine/EngineExploit.java index 5dc683ea..70d0d917 100644 --- a/src/com/massivecraft/factions/engine/EngineExploit.java +++ b/src/com/massivecraft/factions/engine/EngineExploit.java @@ -10,16 +10,13 @@ import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.entity.Player; -import org.bukkit.entity.TNTPrimed; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockFromToEvent; -import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.UUID; @@ -45,9 +42,9 @@ public class EngineExploit extends Engine // thanks to ObGenBlocker and WorldGuard for this method Block block = event.getToBlock(); - int source = event.getBlock().getTypeId(); - int target = block.getTypeId(); - if ((target == 55 || target == 132) && (source == 0 || source == 10 || source == 11)) + Material source = event.getBlock().getType(); + Material target = block.getType(); + if ((target == Material.REDSTONE_WIRE || target == Material.TRIPWIRE) && (source == Material.AIR || source == Material.LAVA)) { block.setType(Material.AIR); } @@ -70,8 +67,8 @@ public class EngineExploit extends Engine // blocks who occupy less than 1 block width or length wise need to be handled differently Material mat = event.getTo().getBlock().getType(); if ( - ((mat == Material.THIN_GLASS || mat == Material.IRON_FENCE) && clippingThrough(target, from, 0.65)) - || ((mat == Material.FENCE || mat == Material.NETHER_FENCE) && clippingThrough(target, from, 0.45)) + ((mat == Material.GLASS_PANE || mat == Material.IRON_BARS) && clippingThrough(target, from, 0.65)) + || ((MUtil.list(Material.ACACIA_FENCE, Material.BIRCH_FENCE, Material.DARK_OAK_FENCE, Material.JUNGLE_FENCE, Material.NETHER_BRICK_FENCE, Material.OAK_FENCE, Material.SPRUCE_FENCE).contains(mat)) && clippingThrough(target, from, 0.45)) ) { event.setTo(from); @@ -95,42 +92,6 @@ public class EngineExploit extends Engine || (target.getZ() > from.getZ() && (target.getZ() - from.getZ() < thickness)) ); } - - // -------------------------------------------- // - // TNT WATERLOG - // -------------------------------------------- // - // TNT in water/lava doesn't normally destroy any surrounding blocks, which is usually desired behavior. - // But this optional change below provides workaround for waterwalling providing perfect protection, - // and makes cheap (non-obsidian) TNT cannons require minor maintenance between shots. - - @SuppressWarnings("deprecation") - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void tntWaterlog(EntityExplodeEvent event) - { - if (!MConf.get().handleExploitTNTWaterlog) return; - if (!(event.getEntity() instanceof TNTPrimed)) return; - - Block center = event.getLocation().getBlock(); - if (!center.isLiquid()) return; - - // a single surrounding block in all 6 directions is broken if the material is weak enough - List targets = new ArrayList<>(); - targets.add(center.getRelative(0, 0, 1)); - targets.add(center.getRelative(0, 0, -1)); - targets.add(center.getRelative(0, 1, 0)); - targets.add(center.getRelative(0, -1, 0)); - targets.add(center.getRelative(1, 0, 0)); - targets.add(center.getRelative(-1, 0, 0)); - for (Block target : targets) - { - int id = target.getTypeId(); - // ignore air, bedrock, water, lava, obsidian, enchanting table, etc.... too bad we can't get a blast resistance value through Bukkit yet - if (id != 0 && (id < 7 || id > 11) && id != 49 && id != 90 && id != 116 && id != 119 && id != 120 && id != 130) - { - target.breakNaturally(); - } - } - } // -------------------------------------------- // // NETHER PORTAL TRAP @@ -240,7 +201,7 @@ public class EngineExploit extends Engine { for (int z = -(NETHER_TRAP_RADIUS_CHECK); z <= NETHER_TRAP_RADIUS_CHECK; z ++) { - if (from.getRelative(x, y, z).getType() == Material.PORTAL) ret.add(from.getRelative(x, y, z)); + if (from.getRelative(x, y, z).getType() == Material.NETHER_PORTAL) ret.add(from.getRelative(x, y, z)); } } } diff --git a/src/com/massivecraft/factions/entity/MConf.java b/src/com/massivecraft/factions/entity/MConf.java index 2f010635..17c5e605 100644 --- a/src/com/massivecraft/factions/entity/MConf.java +++ b/src/com/massivecraft/factions/entity/MConf.java @@ -487,7 +487,6 @@ public class MConf extends Entity public boolean handleExploitObsidianGenerators = true; public boolean handleExploitEnderPearlClipping = true; - public boolean handleExploitTNTWaterlog = false; public boolean handleNetherPortalTrap = true; // -------------------------------------------- // diff --git a/src/com/massivecraft/factions/integration/worldguard/EngineWorldGuard.java b/src/com/massivecraft/factions/integration/worldguard/EngineWorldGuard.java index 56b5b8e7..fd8f7198 100644 --- a/src/com/massivecraft/factions/integration/worldguard/EngineWorldGuard.java +++ b/src/com/massivecraft/factions/integration/worldguard/EngineWorldGuard.java @@ -61,7 +61,7 @@ public class EngineWorldGuard extends Engine // Only do this for players if (player == null) return; - LocalPlayer wrapperPlayer = WorldGuardPlugin.inst().wrapPlayer(player); + LocalPlayer wrapperPlayer = WorldGuardPlugin.inst() .wrapPlayer(player); if ( ! MConf.get().worldguardCheckWorldsEnabled.contains(player)) return; diff --git a/src/com/massivecraft/factions/util/EnumerationUtil.java b/src/com/massivecraft/factions/util/EnumerationUtil.java index e7d61774..5b14e256 100644 --- a/src/com/massivecraft/factions/util/EnumerationUtil.java +++ b/src/com/massivecraft/factions/util/EnumerationUtil.java @@ -12,15 +12,12 @@ public class EnumerationUtil // -------------------------------------------- // public static final BackstringSet MATERIALS_EDIT_ON_INTERACT = new BackstringSet<>(Material.class, - "DIODE_BLOCK_OFF", // Minecraft 1.? - "DIODE_BLOCK_ON", // Minecraft 1.? + "REPEATER", // Minecraft 1.? "NOTE_BLOCK", // Minecraft 1.? "CAULDRON", // Minecraft 1.? - "SOIL", // Minecraft 1.? + "FARMLAND", // Minecraft 1.? "DAYLIGHT_DETECTOR", // Minecraft 1.5 - "DAYLIGHT_DETECTOR_INVERTED", // Minecraft 1.5 - "REDSTONE_COMPARATOR_OFF", // Minecraft 1.? - "REDSTONE_COMPARATOR_ON" // Minecraft 1.? + "COMPARATOR" // Minecraft 1.? ); public static boolean isMaterialEditOnInteract(Material material) @@ -33,17 +30,21 @@ public class EnumerationUtil // -------------------------------------------- // public static final BackstringSet MATERIALS_EDIT_TOOL = new BackstringSet<>(Material.class, - "FIREBALL", // Minecraft 1.? + "FIRE_CHARGE", // Minecraft 1.? "FLINT_AND_STEEL", // Minecraft 1.? - "BUCKET", // Minecraft 1.? + "BUCKET", "WATER_BUCKET", // Minecraft 1.? - "LAVA_BUCKET", // Minecraft 1.? + "LAVA_BUCKET",// Minecraft 1.? + "COD_BUCKET",// Minecraft 1.13 + "PUFFERFISH_BUCKET", // Minecraft 1.13 + "SALMON_BUCKET", // Minecraft 1.13 + "TROPICAL_FISH_BUCKET", // Minecraft 1.13 "ARMOR_STAND", // Minecraft 1.8 "END_CRYSTAL", // Minecraft 1.10 // The duplication bug found in Spigot 1.8 protocol patch // https://github.com/MassiveCraft/Factions/issues/693 - "CHEST", // Minecraft 1.? + "CHEST", // Minecraft 1.? // TODO why chest? "SIGN_POST", // Minecraft 1.? "TRAPPED_CHEST", // Minecraft 1.? "SIGN", // Minecraft 1.? @@ -62,19 +63,24 @@ public class EnumerationUtil // Interacting with these materials placed in the terrain results in door toggling. public static final BackstringSet MATERIALS_DOOR = new BackstringSet<>(Material.class, - "WOODEN_DOOR", // Minecraft 1.? - "ACACIA_DOOR", // Minecraft 1.8 - "BIRCH_DOOR", // Minecraft 1.8 - "DARK_OAK_DOOR", // Minecraft 1.8 - "JUNGLE_DOOR", // Minecraft 1.8 - "SPRUCE_DOOR", // Minecraft 1.8 - "TRAP_DOOR", // Minecraft 1.? - "FENCE_GATE", // Minecraft 1.? - "ACACIA_FENCE_GATE", // Minecraft 1.8 - "BIRCH_FENCE_GATE", // Minecraft 1.8 - "DARK_OAK_FENCE_GATE", // Minecraft 1.8 - "JUNGLE_FENCE_GATE", // Minecraft 1.8 - "SPRUCE_FENCE_GATE" // Minecraft 1.8 + "OAK_DOOR", + "OAK_TRAPDOOR", + "OAK_FENCE_GATE", + "ACACIA_DOOR", + "ACACIA_TRAPDOOR", + "AKACIA_FENCE_GATE", + "BIRCH_DOOR", + "BIRCH_TRAPDOOR", + "BIRCH_FENCE_GATE", + "DARK_OAK_DOOR", + "DARK_OAK_TRAPDOOR", + "DARK_OAK_FENCE_GATE", + "JUNGLE_DOOR", + "JUNGLE_TRAPDOOR", + "JUNGLE_FENCE_GATE", + "SPRUCE_DOOR", + "SPRUCE_TRAPDOOR", + "SPRUCE_FENCE_GATE" ); public static boolean isMaterialDoor(Material material) @@ -87,36 +93,37 @@ public class EnumerationUtil // -------------------------------------------- // public static final BackstringSet MATERIALS_CONTAINER = new BackstringSet<>(Material.class, - "DISPENSER", // Minecraft 1.? - "CHEST", // Minecraft 1.? - "FURNACE", // Minecraft 1.? - "BURNING_FURNACE", // Minecraft 1.? - "JUKEBOX", // Minecraft 1.? - "BREWING_STAND", // Minecraft 1.? - "ENCHANTMENT_TABLE", // Minecraft 1.? - "ANVIL", // Minecraft 1.? - "BEACON", // Minecraft 1.? - "TRAPPED_CHEST", // Minecraft 1.? - "HOPPER", // Minecraft 1.? - "DROPPER", // Minecraft 1.? + "DISPENSER", + "CHEST", + "TRAPPED_CHEST", + "FURNACE", + "JUKEBOX", + "BREWING_STAND", + "ENCHANTING_TABLE", + "ANVIL", + "CHIPPED_ANVIL", + "DAMAGED_ANVIL", + "BEACON", + "HOPPER", + "DROPPER", // The various shulker boxes, they had to make each one a different material -.- - "BLACK_SHULKER_BOX", // Minecraft 1.11 - "BLUE_SHULKER_BOX", // Minecraft 1.11 - "BROWN_SHULKER_BOX", // Minecraft 1.11 - "CYAN_SHULKER_BOX", // Minecraft 1.11 - "GRAY_SHULKER_BOX", // Minecraft 1.11 - "GREEN_SHULKER_BOX", // Minecraft 1.11 - "LIGHT_BLUE_SHULKER_BOX", // Minecraft 1.11 - "LIME_SHULKER_BOX", // Minecraft 1.11 - "MAGENTA_SHULKER_BOX", // Minecraft 1.11 - "ORANGE_SHULKER_BOX", // Minecraft 1.11 - "PINK_SHULKER_BOX", // Minecraft 1.11 - "PURPLE_SHULKER_BOX", // Minecraft 1.11 - "RED_SHULKER_BOX", // Minecraft 1.11 - "SILVER_SHULKER_BOX", // Minecraft 1.11 - "WHITE_SHULKER_BOX", // Minecraft 1.11 - "YELLOW_SHULKER_BOX" // Minecraft 1.11 + "BLACK_SHULKER_BOX", + "BLUE_SHULKER_BOX", + "BROWN_SHULKER_BOX", + "CYAN_SHULKER_BOX", + "GRAY_SHULKER_BOX", + "GREEN_SHULKER_BOX", + "LIGHT_BLUE_SHULKER_BOX", + "LIME_SHULKER_BOX", + "MAGENTA_SHULKER_BOX", + "ORANGE_SHULKER_BOX", + "PINK_SHULKER_BOX", + "PURPLE_SHULKER_BOX", + "RED_SHULKER_BOX", + "SILVER_SHULKER_BOX", + "WHITE_SHULKER_BOX", + "YELLOW_SHULKER_BOX" ); public static boolean isMaterialContainer(Material material) @@ -177,15 +184,15 @@ public class EnumerationUtil "BLAZE", // Minecraft 1.? "CAVE_SPIDER", // Minecraft 1.? "CREEPER", // Minecraft 1.? - "ELDER_GUARDIAN", // minecraft 1.11 + "ELDER_GUARDIAN", "ENDERMAN", // Minecraft 1.? "ENDERMITE", // Minecraft 1.8 "ENDER_DRAGON", // Minecraft 1.? - "EVOKER", // Minecraft 1.11 + "EVOKER", "GUARDIAN", // Minecraft 1.8 "GHAST", // Minecraft 1.? "GIANT", // Minecraft 1.? - "HUSK", // Minecraft 1.11 + "HUSK", "MAGMA_CUBE", // Minecraft 1.? "PIG_ZOMBIE", // Minecraft 1.? "POLAR_BEAR", // Minecraft 1.10 @@ -194,14 +201,14 @@ public class EnumerationUtil "SKELETON", // Minecraft 1.? "SLIME", // Minecraft 1.? "SPIDER", // Minecraft 1.? - "STRAY", // Minecraft 1.11 - "VINDICATOR", // Minecraft 1.11 - "VEX", // Minecraft 1.11 + "STRAY", + "VINDICATOR", + "VEX", "WITCH", // Minecraft 1.? "WITHER", // Minecraft 1.? - "WITHER_SKELETON", // Minecraft 1.11 + "WITHER_SKELETON", "ZOMBIE", // Minecraft 1.? - "ZOMBIE_VILLAGER", // Minecraft 1.11 + "ZOMBIE_VILLAGER", "ILLUSIONER" // Minecraft 1.12 ); @@ -218,19 +225,19 @@ public class EnumerationUtil "BAT", // Minecraft 1.? "CHICKEN", // Minecraft 1.? "COW", // Minecraft 1.? - "DONKEY", // Minecraft 1.11 + "DONKEY", "HORSE", // Minecraft 1.? - "LLAMA", // Minecraft 1.11 - "MULE", // Minecraft 1.11 + "LLAMA", + "MULE", "MUSHROOM_COW", // Minecraft 1.? "OCELOT", // Minecraft 1.? "PIG", // Minecraft 1.? "RABBIT", // Minecraft 1.? "SHEEP", // Minecraft 1.? - "SKELETON_HORSE", // Minecraft 1.11 + "SKELETON_HORSE", "SQUID", // Minecraft 1.? "WOLF", // Minecraft 1.? - "ZOMBIE_HORSE", // Minecraft 1.11 + "ZOMBIE_HORSE", "PARROT" // Minecraft 1.12 ); diff --git a/src/com/massivecraft/factions/util/VisualizeUtil.java b/src/com/massivecraft/factions/util/VisualizeUtil.java index 1f998a2d..7cfc0dd2 100644 --- a/src/com/massivecraft/factions/util/VisualizeUtil.java +++ b/src/com/massivecraft/factions/util/VisualizeUtil.java @@ -1,6 +1,7 @@ package com.massivecraft.factions.util; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Player; @@ -39,17 +40,17 @@ public class VisualizeUtil // -------------------------------------------- // @SuppressWarnings("deprecation") - public static void addLocation(Player player, Location location, int typeId, byte data) + public static void addLocation(Player player, Location location, Material material, byte data) { getPlayerLocations(player).add(location); - player.sendBlockChange(location, typeId, data); + player.sendBlockChange(location, material, data); } @SuppressWarnings("deprecation") - public static void addLocation(Player player, Location location, int typeId) + public static void addLocation(Player player, Location location, Material material) { getPlayerLocations(player).add(location); - player.sendBlockChange(location, typeId, (byte) 0); + player.sendBlockChange(location, material, (byte) 0); } // -------------------------------------------- // @@ -57,10 +58,10 @@ public class VisualizeUtil // -------------------------------------------- // @SuppressWarnings("deprecation") - public static void addLocations(Player player, Map locationMaterialIds) + public static void addLocations(Player player, Map locationMaterialIds) { Set ploc = getPlayerLocations(player); - for (Entry entry : locationMaterialIds.entrySet()) + for (Entry entry : locationMaterialIds.entrySet()) { ploc.add(entry.getKey()); player.sendBlockChange(entry.getKey(), entry.getValue(), (byte) 0); @@ -68,25 +69,25 @@ public class VisualizeUtil } @SuppressWarnings("deprecation") - public static void addLocations(Player player, Collection locations, int typeId) + public static void addLocations(Player player, Collection locations, Material material) { Set ploc = getPlayerLocations(player); for (Location location : locations) { ploc.add(location); - player.sendBlockChange(location, typeId, (byte) 0); + player.sendBlockChange(location, material, (byte) 0); } } @SuppressWarnings("deprecation") - public static void addBlocks(Player player, Collection blocks, int typeId) + public static void addBlocks(Player player, Collection blocks, Material material) { Set ploc = getPlayerLocations(player); for (Block block : blocks) { Location location = block.getLocation(); ploc.add(location); - player.sendBlockChange(location, typeId, (byte) 0); + player.sendBlockChange(location, material, (byte) 0); } } @@ -102,7 +103,7 @@ public class VisualizeUtil for (Location location : locations) { Block block = location.getWorld().getBlockAt(location); - player.sendBlockChange(location, block.getTypeId(), block.getData()); + player.sendBlockChange(location, block.getType(), block.getData()); } locations.clear(); }