Skip to content

Commit

Permalink
二次修改:调整模式还原到给予权限部分
Browse files Browse the repository at this point in the history
  • Loading branch information
glorydark committed Feb 20, 2024
1 parent ac207dd commit 691712a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
6 changes: 1 addition & 5 deletions src/main/java/glorydark/DLevelEventPlus/CheckTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,12 @@ public void onRun(int i) {
}
}
if (PermissionAPI.isAdmin(player)) {
player.setGamemode(Server.getInstance().getDefaultGamemode());
if (player.isImmobile()) {
player.setImmobile(false);
}
return;
}
if (PermissionAPI.isOperator(player, player.getLevel())) {
player.setGamemode(Server.getInstance().getDefaultGamemode());
if (player.isImmobile()) {
player.setImmobile(false);
}
Expand All @@ -68,9 +66,7 @@ public void onRun(int i) {
player.setImmobile(!movable);
}
}
if (forceGamemode != -1) {
player.setGamemode(forceGamemode);
}
player.setGamemode(forceGamemode);
}
}
}
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/glorydark/DLevelEventPlus/api/PermissionAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,6 @@ public static void whiteList(CommandSender sender, OperatePermissionType type, S
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());
}
if (player.getGamemode() == forceGamemode) {
player.setGamemode(Server.getInstance().getDefaultGamemode());
}
player.sendMessage(LevelEventPlusMain.language.translateString("tip_whitelist_add_success_receiver", playerName, levelname));
}
sender.sendMessage(LevelEventPlusMain.language.translateString("tip_whitelist_add_success", playerName, levelname));
Expand Down Expand Up @@ -111,6 +102,15 @@ 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());
}
if (player.getGamemode() == forceGamemode) {
player.setGamemode(Server.getInstance().getDefaultGamemode());
}
player.sendMessage(LevelEventPlusMain.language.translateString("tip_operator_add_success_receiver", playerName, levelname));
}
sender.sendMessage(LevelEventPlusMain.language.translateString("tip_operator_add_success", playerName, levelname));
Expand Down

0 comments on commit 691712a

Please sign in to comment.