Skip to content

Commit

Permalink
cleanup block listener
Browse files Browse the repository at this point in the history
  • Loading branch information
me4502 committed Jan 12, 2019
1 parent 3ea7c9f commit 60731f9
Showing 1 changed file with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}

/**
Expand All @@ -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());
}

Expand All @@ -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();
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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()) {
Expand All @@ -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();
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 60731f9

Please sign in to comment.