新增领地怪物生成、动物生成权限控制

This commit is contained in:
zhangyuheng 2024-05-27 09:41:56 +08:00
parent ee59530e0a
commit e859ce9b6b
4 changed files with 29 additions and 5 deletions

View File

@ -6,7 +6,7 @@
<groupId>cn.lunadeer</groupId>
<artifactId>Dominion</artifactId>
<version>1.27.0-beta</version>
<version>1.28.0-beta</version>
<packaging>jar</packaging>
<name>Dominion</name>

View File

@ -12,6 +12,7 @@ import java.util.List;
public enum Flag {
ANCHOR("anchor", "重生锚", "是否允许设置重生锚", false, false, true),
ANIMAL_KILLING("animal_killing", "对动物造成伤害", "是否允许对动物造成伤害", false, false, true),
ANIMAL_SPAWN("animal_spawn", "动物生成", "是否允许动物生成", true, true, false),
ANVIL("anvil", "使用铁砧", "是否允许使用铁砧", false, false, true),
BEACON("beacon", "信标交互", "是否允许与信标交互", false, false, true),
BED("bed", "床交互", "是否允许使用床睡觉或设置重生点", false, false, true),
@ -42,6 +43,7 @@ public enum Flag {
LEVER("lever", "使用拉杆", "是否可以使用拉杆", false, false, true),
MOB_DROP_ITEM("mob_drop_item", "生物战利品掉落", "生物死亡时是否产生凋落物", true, true, true),
MONSTER_KILLING("monster_killing", "对怪物造成伤害", "玩家是否可以对怪物造成伤害", false, false, true),
MONSTER_SPAWN("monster_spawn", "怪物生成", "是否可以生成怪物", false, true, false),
MOVE("move", "移动", "是否可以移动", true, false, true),
PLACE("place", "放置方块", "是否可以放置方块(包括:一般方块、展示框、岩浆、水)", false, false, true),
PRESSURE("pressure", "压力板交互", "是否可以触发各种材质的压力板", false, false, true),

View File

@ -6,9 +6,7 @@ import cn.lunadeer.dominion.dtos.Flag;
import com.destroystokyo.paper.event.entity.EndermanEscapeEvent;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
@ -135,9 +133,29 @@ public class EnvironmentEvents implements Listener {
}
@EventHandler(priority = EventPriority.HIGHEST) // ender_man escape
public void onEnderManEscape(EndermanEscapeEvent event){
public void onEnderManEscape(EndermanEscapeEvent event) {
Entity entity = event.getEntity();
DominionDTO dom = Cache.instance.getDominion(entity.getLocation());
checkFlag(dom, Flag.ENDER_MAN, event);
}
@EventHandler(priority = EventPriority.HIGHEST) // monster_spawn
public void onMonsterSpawn(CreatureSpawnEvent event) {
Entity entity = event.getEntity();
if (!(entity instanceof Monster)) {
return;
}
DominionDTO dom = Cache.instance.getDominion(entity.getLocation());
checkFlag(dom, Flag.MONSTER_SPAWN, event);
}
@EventHandler(priority = EventPriority.HIGHEST) // animal_spawn
public void onAnimalSpawn(CreatureSpawnEvent event) {
Entity entity = event.getEntity();
if (!(entity instanceof Animals)) {
return;
}
DominionDTO dom = Cache.instance.getDominion(entity.getLocation());
checkFlag(dom, Flag.ANIMAL_SPAWN, event);
}
}

View File

@ -169,5 +169,9 @@ public class DatabaseTables {
// 1.26
Dominion.database.addColumnIfNotExists("dominion", "fly", "BOOLEAN NOT NULL DEFAULT FALSE");
Dominion.database.addColumnIfNotExists("player_privilege", "fly", "BOOLEAN NOT NULL DEFAULT FALSE");
// 1.28
Dominion.database.addColumnIfNotExists("dominion", "monster_spawn", "BOOLEAN NOT NULL DEFAULT FALSE");
Dominion.database.addColumnIfNotExists("dominion", "animal_spawn", "BOOLEAN NOT NULL DEFAULT TRUE");
}
}