mirror of
https://github.com/garbagemule/MobArena.git
synced 2024-11-26 12:36:00 +01:00
Prevent snow and ice from melting in arenas.
The block fade event is called when a block fades from one state to another, such as when snow melts and becomes air, or ice melts and becomes water. Cancelling it solves the issue of snow and ice melting in arenas. Fixes #249.
This commit is contained in:
parent
e484583b7e
commit
85687c86b5
@ -43,6 +43,7 @@ import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockBurnEvent;
|
||||
import org.bukkit.event.block.BlockEvent;
|
||||
import org.bukkit.event.block.BlockFadeEvent;
|
||||
import org.bukkit.event.block.BlockFormEvent;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
import org.bukkit.event.block.BlockIgniteEvent;
|
||||
@ -334,6 +335,21 @@ public class ArenaListener
|
||||
arena.addBlock(event.getBlock());
|
||||
}
|
||||
|
||||
public void onBlockFade(BlockFadeEvent event) {
|
||||
if (!protect) {
|
||||
return;
|
||||
}
|
||||
if (!arena.getRegion().contains(event.getBlock().getLocation())) {
|
||||
return;
|
||||
}
|
||||
switch (event.getBlock().getType()) {
|
||||
case ICE:
|
||||
case SNOW:
|
||||
event.setCancelled(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: Figure out a solution to this problem with soft-restore.
|
||||
*
|
||||
|
@ -14,6 +14,7 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockBurnEvent;
|
||||
import org.bukkit.event.block.BlockExplodeEvent;
|
||||
import org.bukkit.event.block.BlockFadeEvent;
|
||||
import org.bukkit.event.block.BlockFormEvent;
|
||||
import org.bukkit.event.block.BlockIgniteEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
@ -105,6 +106,13 @@ public class MAGlobalListener implements Listener
|
||||
// arena.getEventListener().onBlockFromTo(event);
|
||||
// }
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void blockFade(BlockFadeEvent event) {
|
||||
for (Arena arena : am.getArenas()) {
|
||||
arena.getEventListener().onBlockFade(event);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void blockIgnite(BlockIgniteEvent event) {
|
||||
for (Arena arena : am.getArenas())
|
||||
|
Loading…
Reference in New Issue
Block a user