修复凋零生成时产生的爆炸缺少保护的漏洞(合并在领地环境设置的凋零生成权限中)

This commit is contained in:
zhangyuheng 2024-08-30 15:16:07 +08:00
parent ecd65f611f
commit 968d6dfdff
4 changed files with 26 additions and 6 deletions

View File

@ -4,7 +4,7 @@ plugins {
}
group = "cn.lunadeer"
version = "2.4.1-beta"
version = "2.4.2-beta"
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(21))

View File

@ -77,7 +77,7 @@ public enum Flag {
VEHICLE_SPAWN("vehicle_spawn", "生成载具", "是否可以生成载具(主要是矿车)", false, false, true),
VILLAGER_KILLING("villager_killing", "对村民造成伤害", "是否可以对村民造成伤害", false, false, true),
VILLAGER_SPAWN("villager_spawn", "村民繁殖", "是否允许村民繁殖(包括村民蛋)", true, true, true),
WITHER_SPAWN("wither_spawn", "凋零生成", "凋零生成", false, true, true),
WITHER_SPAWN("wither_spawn", "凋零生成", "凋零生成以及凋零生成时产生的爆炸", false, true, true),
;
private final String flag_name;
private String display_name;

View File

@ -271,6 +271,18 @@ public class EnvironmentEvents implements Listener {
checkFlag(dom, Flag.WITHER_SPAWN, event);
}
@EventHandler(priority = EventPriority.HIGHEST) // wither_spawn - explode
public void onWitherSpawnExplode(EntityExplodeEvent event) {
Entity entity = event.getEntity();
if (entity.getType() != EntityType.WITHER) {
return;
}
event.blockList().removeIf(block -> {
DominionDTO dom = Cache.instance.getDominionByLoc(block.getLocation());
return !checkFlag(dom, Flag.WITHER_SPAWN, null);
});
}
@EventHandler(priority = EventPriority.HIGHEST) // ender_man spawn
public void onEnderManSpawn(CreatureSpawnEvent event) {
Entity entity = event.getEntity();

View File

@ -44,10 +44,6 @@ public class EnvironmentEvents implements Listener {
@EventHandler(priority = EventPriority.HIGHEST) // creeper_explode - bed anchor
public void onBedAnchorExplosion(BlockExplodeEvent event) {
BlockState block = event.getExplodedBlockState();
if (block == null) {
return;
}
event.blockList().removeIf(blockState -> {
DominionDTO dom = Cache.instance.getDominionByLoc(blockState.getLocation());
return !checkFlag(dom, Flag.CREEPER_EXPLODE, null);
@ -271,6 +267,18 @@ public class EnvironmentEvents implements Listener {
checkFlag(dom, Flag.WITHER_SPAWN, event);
}
@EventHandler(priority = EventPriority.HIGHEST) // wither_spawn - explode
public void onWitherSpawnExplode(EntityExplodeEvent event) {
Entity entity = event.getEntity();
if (entity.getType() != EntityType.WITHER) {
return;
}
event.blockList().removeIf(block -> {
DominionDTO dom = Cache.instance.getDominionByLoc(block.getLocation());
return !checkFlag(dom, Flag.WITHER_SPAWN, null);
});
}
@EventHandler(priority = EventPriority.HIGHEST) // ender_man spawn
public void onEnderManSpawn(CreatureSpawnEvent event) {
Entity entity = event.getEntity();