Permalink
Browse files

cleanup block listener

  • Loading branch information...
me4502 committed Jan 12, 2019
1 parent 3ea7c9f commit 60731f9836f886159854286e4fb351ac12533482
@@ -25,6 +25,7 @@
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.bukkit.util.Materials;
import com.sk89q.worldguard.config.ConfigurationManager;
import com.sk89q.worldguard.config.WorldConfiguration;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.association.RegionAssociable;
import com.sk89q.worldguard.protection.flags.Flags;
@@ -85,8 +86,8 @@ public void registerEvents() {
* @param world The world to get the configuration for.
* @return The configuration for {@code world}
*/
protected BukkitWorldConfiguration getWorldConfig(World world) {
return (BukkitWorldConfiguration) WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(BukkitAdapter.adapt(world));
protected WorldConfiguration getWorldConfig(World world) {
return WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(BukkitAdapter.adapt(world));
}

/**
@@ -95,7 +96,7 @@ protected BukkitWorldConfiguration getWorldConfig(World world) {
* @param player The player to get the wold from
* @return The {@link BukkitWorldConfiguration} for the player's world
*/
protected BukkitWorldConfiguration getWorldConfig(Player player) {
protected WorldConfiguration getWorldConfig(Player player) {
return getWorldConfig(player.getWorld());
}

@@ -105,8 +106,7 @@ protected BukkitWorldConfiguration getWorldConfig(Player player) {
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) {
Player player = event.getPlayer();
Block target = event.getBlock();
BukkitWorldConfiguration wcfg = getWorldConfig(player);
WorldConfiguration wcfg = getWorldConfig(player);

if (!wcfg.itemDurability) {
ItemStack held = player.getItemInHand();
@@ -131,7 +131,7 @@ public void onBlockFromTo(BlockFromToEvent event) {
boolean isAir = blockFrom.getType() == Material.AIR;

ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
BukkitWorldConfiguration wcfg = getWorldConfig(event.getBlock().getWorld());
WorldConfiguration wcfg = getWorldConfig(event.getBlock().getWorld());

if (cfg.activityHaltToggle) {
event.setCancelled(true);
@@ -219,7 +219,7 @@ public void onBlockIgnite(BlockIgniteEvent event) {
World world = block.getWorld();

ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
BukkitWorldConfiguration wcfg = getWorldConfig(world);
WorldConfiguration wcfg = getWorldConfig(world);

if (cfg.activityHaltToggle) {
event.setCancelled(true);
@@ -306,7 +306,7 @@ public void onBlockIgnite(BlockIgniteEvent event) {
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBlockBurn(BlockBurnEvent event) {
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
BukkitWorldConfiguration wcfg = getWorldConfig(event.getBlock().getWorld());
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) getWorldConfig(event.getBlock().getWorld());

if (cfg.activityHaltToggle) {
event.setCancelled(true);
@@ -377,7 +377,7 @@ private void checkAndDestroy(World world, int x, int y, int z, Material required
@EventHandler(ignoreCancelled = true)
public void onBlockPhysics(BlockPhysicsEvent event) {
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
BukkitWorldConfiguration wcfg = getWorldConfig(event.getBlock().getWorld());
WorldConfiguration wcfg = getWorldConfig(event.getBlock().getWorld());

if (cfg.activityHaltToggle) {
event.setCancelled(true);
@@ -417,7 +417,7 @@ public void onBlockPlace(BlockPlaceEvent event) {
Block target = event.getBlock();
World world = target.getWorld();

BukkitWorldConfiguration wcfg = getWorldConfig(world);
WorldConfiguration wcfg = getWorldConfig(world);

if (wcfg.simulateSponge && target.getType() == Material.SPONGE) {
if (wcfg.redstoneSponges && target.isBlockIndirectlyPowered()) {
@@ -440,7 +440,7 @@ public void onBlockRedstoneChange(BlockRedstoneEvent event) {
Block blockTo = event.getBlock();
World world = blockTo.getWorld();

BukkitWorldConfiguration wcfg = getWorldConfig(world);
WorldConfiguration wcfg = getWorldConfig(world);

if (wcfg.simulateSponge && wcfg.redstoneSponges) {
int ox = blockTo.getX();
@@ -469,7 +469,7 @@ public void onBlockRedstoneChange(BlockRedstoneEvent event) {
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onLeavesDecay(LeavesDecayEvent event) {
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
BukkitWorldConfiguration wcfg = getWorldConfig(event.getBlock().getWorld());
WorldConfiguration wcfg = getWorldConfig(event.getBlock().getWorld());

if (cfg.activityHaltToggle) {
event.setCancelled(true);
@@ -494,7 +494,7 @@ public void onLeavesDecay(LeavesDecayEvent event) {
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBlockForm(BlockFormEvent event) {
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
BukkitWorldConfiguration wcfg = getWorldConfig(event.getBlock().getWorld());
WorldConfiguration wcfg = getWorldConfig(event.getBlock().getWorld());

if (cfg.activityHaltToggle) {
event.setCancelled(true);
@@ -552,7 +552,7 @@ public void onBlockForm(BlockFormEvent event) {
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBlockSpread(BlockSpreadEvent event) {
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
BukkitWorldConfiguration wcfg = getWorldConfig(event.getBlock().getWorld());
WorldConfiguration wcfg = getWorldConfig(event.getBlock().getWorld());

if (cfg.activityHaltToggle) {
event.setCancelled(true);
@@ -618,7 +618,7 @@ public void onBlockSpread(BlockSpreadEvent event) {
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBlockFade(BlockFadeEvent event) {

BukkitWorldConfiguration wcfg = getWorldConfig(event.getBlock().getWorld());
WorldConfiguration wcfg = getWorldConfig(event.getBlock().getWorld());

if (Tag.ICE.isTagged(event.getBlock().getType())) {
if (wcfg.disableIceMelting) {

0 comments on commit 60731f9

Please sign in to comment.