mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-30 04:19:27 +00:00
添加以op身份执行
This commit is contained in:
@@ -34,7 +34,6 @@ import java.lang.invoke.MethodHandles;
|
||||
import java.lang.invoke.MethodType;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
public final class BlockGenerator {
|
||||
|
||||
@@ -956,8 +956,20 @@ public class BukkitServerPlayer extends Player {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performCommand(String command) {
|
||||
platformPlayer().performCommand(command);
|
||||
public void performCommand(String command, boolean asOp) {
|
||||
org.bukkit.entity.Player player = platformPlayer();
|
||||
if (asOp) {
|
||||
boolean isOp = player.isOp();
|
||||
player.setOp(true);
|
||||
try {
|
||||
player.performCommand(command);
|
||||
} catch (Throwable t) {
|
||||
this.plugin.logger().warn("Failed to perform command '" + command + "' for " + this.name() + " as operator", t);
|
||||
}
|
||||
player.setOp(isOp);
|
||||
} else {
|
||||
player.performCommand(command);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,9 +18,7 @@ import net.momirealms.craftengine.core.world.ExistingBlock;
|
||||
import net.momirealms.craftengine.core.world.World;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user