Skip to content

Commit

Permalink
Stuff
Browse files Browse the repository at this point in the history
防止重复设置模式切换同功能
移除权限立即改模式,防止腐竹设置的refresh_tick过慢或者直接设为0(nt行为)导致无法更新
  • Loading branch information
glorydark committed Feb 21, 2024
1 parent 4920704 commit 0fa9efa
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>glorydark.nukkit</groupId>
<artifactId>DLevelEventPlus</artifactId>
<version>1.2.1.6</version>
<version>1.2.1.7</version>

<properties>
<maven.complier.sourceEncoding>UTF-8</maven.complier.sourceEncoding>
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/glorydark/DLevelEventPlus/api/PermissionAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 0fa9efa

Please sign in to comment.