diff --git a/pom.xml b/pom.xml index 1948ba0..f47fe7a 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ glorydark.nukkit DLevelEventPlus - 1.2.1.6 + 1.2.1.7 UTF-8 diff --git a/src/main/java/glorydark/DLevelEventPlus/api/PermissionAPI.java b/src/main/java/glorydark/DLevelEventPlus/api/PermissionAPI.java index 57da9e0..c07b915 100644 --- a/src/main/java/glorydark/DLevelEventPlus/api/PermissionAPI.java +++ b/src/main/java/glorydark/DLevelEventPlus/api/PermissionAPI.java @@ -80,6 +80,13 @@ public static void adminList(CommandSender sender, OperatePermissionType type, S worldcfg.set("list", arrayList); worldcfg.save(); if (player != null) { + Level level = player.getLevel(); + Object forceGameModeObj = LevelSettingsAPI.getLevelObjectSetting(level.getName(), "World", "ForceGameMode"); + int forceGamemode = -1; + if (forceGameModeObj != null) { + forceGamemode = Server.getGamemodeFromString(forceGameModeObj.toString()); + } + player.setGamemode(forceGamemode); player.sendMessage(LevelEventPlusMain.language.translateString("tip_admin_del_success_receiver", playerName)); } sender.sendMessage(LevelEventPlusMain.language.translateString("tip_admin_del_success", playerName)); @@ -125,6 +132,13 @@ public static void operatorList(CommandSender sender, OperatePermissionType type worldcfg.set(levelname, arrayList); worldcfg.save(); if (player != null) { + Level level = player.getLevel(); + Object forceGameModeObj = LevelSettingsAPI.getLevelObjectSetting(level.getName(), "World", "ForceGameMode"); + int forceGamemode = -1; + if (forceGameModeObj != null) { + forceGamemode = Server.getGamemodeFromString(forceGameModeObj.toString()); + } + player.setGamemode(forceGamemode); player.sendMessage(LevelEventPlusMain.language.translateString("tip_operator_del_success_receiver", playerName, levelname)); } sender.sendMessage(LevelEventPlusMain.language.translateString("tip_operator_del_success", playerName, levelname)); diff --git a/src/main/java/glorydark/DLevelEventPlus/event/PlayerEventListener.java b/src/main/java/glorydark/DLevelEventPlus/event/PlayerEventListener.java index 3ea741e..8c2dfc6 100644 --- a/src/main/java/glorydark/DLevelEventPlus/event/PlayerEventListener.java +++ b/src/main/java/glorydark/DLevelEventPlus/event/PlayerEventListener.java @@ -232,14 +232,20 @@ public void PlayerCommandPreprocessEvent(PlayerCommandPreprocessEvent event) { @EventHandler public void PlayerGameModeChangeEvent(PlayerGameModeChangeEvent event) { - Boolean bool = LevelSettingsAPI.getLevelBooleanSetting(event.getPlayer().getLevel().getName(), "Player", "GameModeChange"); + Player player = event.getPlayer(); + Level level = player.getLevel(); + Object forceGameModeObj = LevelSettingsAPI.getLevelObjectSetting(level.getName(), "World", "ForceGameMode"); + if (forceGameModeObj != null) { + return; // 防止腐竹重复设置同种功能,强制游戏模式开启无需禁用模式改变 + } + Boolean bool = LevelSettingsAPI.getLevelBooleanSetting(level.getName(), "Player", "GameModeChange"); if (bool == null) { return; } - if (PermissionAPI.isAdmin(event.getPlayer())) { + if (PermissionAPI.isAdmin(player)) { return; } - if (PermissionAPI.isOperator(event.getPlayer(), event.getPlayer().getLevel())) { + if (PermissionAPI.isOperator(player, player.getLevel())) { return; } if (!bool) { diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 7a0a9ed..8eb83a7 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: DLevelEventPlus main: glorydark.DLevelEventPlus.LevelEventPlusMain -version: "1.2.1.6" +version: "1.2.1.7" author: glorydark api: ["1.0.0"] description: DLevelEventPlus