This commit is contained in:
Magnus Ulf Jørgensen 2017-12-22 13:55:16 +01:00
parent 3145777fc5
commit dd30d960f0

View File

@ -22,6 +22,7 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
public class EngineExploit extends Engine public class EngineExploit extends Engine
@ -37,7 +38,6 @@ public class EngineExploit extends Engine
// OBSIDIAN GENERATORS // OBSIDIAN GENERATORS
// -------------------------------------------- // // -------------------------------------------- //
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void obsidianGenerators(BlockFromToEvent event) public void obsidianGenerators(BlockFromToEvent event)
{ {
@ -45,9 +45,9 @@ public class EngineExploit extends Engine
// thanks to ObGenBlocker and WorldGuard for this method // thanks to ObGenBlocker and WorldGuard for this method
Block block = event.getToBlock(); Block block = event.getToBlock();
int source = event.getBlock().getTypeId(); Material source = event.getBlock().getType();
int target = block.getTypeId(); Material target = block.getType();
if ((target == 55 || target == 132) && (source == 0 || source == 10 || source == 11)) if ((target == Material.REDSTONE_WIRE || target == Material.TRIPWIRE) && (source == Material.AIR || source == Material.LAVA || source == Material.STATIONARY_LAVA))
{ {
block.setType(Material.AIR); block.setType(Material.AIR);
} }
@ -103,7 +103,8 @@ public class EngineExploit extends Engine
// But this optional change below provides workaround for waterwalling providing perfect protection, // But this optional change below provides workaround for waterwalling providing perfect protection,
// and makes cheap (non-obsidian) TNT cannons require minor maintenance between shots. // and makes cheap (non-obsidian) TNT cannons require minor maintenance between shots.
@SuppressWarnings("deprecation") private static final Set<Material> blastProtected = MUtil.set(Material.AIR, Material.WATER, Material.STATIONARY_WATER, Material.LAVA, Material.STATIONARY_LAVA, Material.OBSIDIAN, Material.PORTAL, Material.ENCHANTMENT_TABLE, Material.ENDER_PORTAL, Material.ENDER_PORTAL_FRAME, Material.ENDER_CHEST);
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void tntWaterlog(EntityExplodeEvent event) public void tntWaterlog(EntityExplodeEvent event)
{ {
@ -123,12 +124,10 @@ public class EngineExploit extends Engine
targets.add(center.getRelative(-1, 0, 0)); targets.add(center.getRelative(-1, 0, 0));
for (Block target : targets) for (Block target : targets)
{ {
int id = target.getTypeId(); Material id = target.getType();
// ignore air, bedrock, water, lava, obsidian, enchanting table, etc.... too bad we can't get a blast resistance value through Bukkit yet // 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) if (blastProtected.contains(id)) continue;
{ target.breakNaturally();
target.breakNaturally();
}
} }
} }