fix: 修复指令执行时可能导致的权限问题
This commit is contained in:
@@ -14,7 +14,6 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.command.CommandException;
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@@ -391,7 +390,6 @@ public final class CoreBukkitUtils {
|
|||||||
command = PlaceholderAPI.setPlaceholders(player, command);
|
command = PlaceholderAPI.setPlaceholders(player, command);
|
||||||
}
|
}
|
||||||
String[] split = command.split(":", 2);
|
String[] split = command.split(":", 2);
|
||||||
try {
|
|
||||||
switch (split[0]) {
|
switch (split[0]) {
|
||||||
case "player": {
|
case "player": {
|
||||||
Bukkit.dispatchCommand(player, split[1]);
|
Bukkit.dispatchCommand(player, split[1]);
|
||||||
@@ -404,8 +402,11 @@ public final class CoreBukkitUtils {
|
|||||||
case "op": {
|
case "op": {
|
||||||
boolean op = player.isOp();
|
boolean op = player.isOp();
|
||||||
player.setOp(true);
|
player.setOp(true);
|
||||||
|
try {
|
||||||
Bukkit.dispatchCommand(player, split[1]);
|
Bukkit.dispatchCommand(player, split[1]);
|
||||||
|
} finally {
|
||||||
player.setOp(op);
|
player.setOp(op);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
@@ -413,9 +414,6 @@ public final class CoreBukkitUtils {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (CommandException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
Reference in New Issue
Block a user