mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-28 05:26:29 +01:00
Add blockFadeDisabled game rule
This commit is contained in:
parent
790e925e5c
commit
3df0e333ee
@ -151,6 +151,11 @@ public class GameRule<V> {
|
||||
* A whitelist of placeable blocks. placeBlocks is supposed to be set to "true" if this should be used.
|
||||
*/
|
||||
public static final GameRule<Set<ExItem>> PLACE_WHITELIST = new CollectionGameRule<>("placeWhitelist", null, ConfigReader.EX_ITEM_SET_READER, HashSet::new);
|
||||
* A set of blocks that do not fade.
|
||||
*
|
||||
* @see <a href="https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/block/BlockFadeEvent.html">org.bukkit.event.block.BlockFadeEvent</a>
|
||||
*/
|
||||
public static final GameRule<Set<ExItem>> BLOCK_FADE_DISABLED = new CollectionGameRule<>("blockFadeDisabled", null, ConfigReader.EX_ITEM_SET_READER, HashSet::new);
|
||||
/**
|
||||
* This does what the doFireTick Vanilla game rule does.
|
||||
*/
|
||||
|
@ -18,6 +18,7 @@ package de.erethon.dungeonsxl.world;
|
||||
|
||||
import de.erethon.caliburn.CaliburnAPI;
|
||||
import de.erethon.caliburn.category.Category;
|
||||
import de.erethon.caliburn.item.ExItem;
|
||||
import de.erethon.caliburn.item.VanillaItem;
|
||||
import de.erethon.caliburn.mob.ExMob;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
@ -36,6 +37,7 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockFadeEvent;
|
||||
import org.bukkit.event.block.BlockIgniteEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.block.BlockSpreadEvent;
|
||||
@ -183,6 +185,27 @@ public class DWorldListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockFade(BlockFadeEvent event) {
|
||||
GameWorld gameWorld = plugin.getGameWorld(event.getBlock().getWorld());
|
||||
if (gameWorld == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!gameWorld.isPlaying()) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
Set<ExItem> blockFadeDisabled = gameWorld.getGame().getRules().getState(GameRule.BLOCK_FADE_DISABLED);
|
||||
if (blockFadeDisabled == null) {
|
||||
return;
|
||||
}
|
||||
if (gameWorld.getGame() != null && blockFadeDisabled.contains(VanillaItem.get(event.getBlock().getType()))) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWeatherChange(WeatherChangeEvent event) {
|
||||
InstanceWorld instance = plugin.getInstanceWorld(event.getWorld());
|
||||
|
Loading…
Reference in New Issue
Block a user