Fix AbstractMethodError when using NULL command source (#497)

This commit is contained in:
sandtechnology 2022-03-07 17:23:07 +08:00 committed by GitHub
parent 6c1ad867d2
commit ff83ef6eaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,49 @@
package io.izzel.arclight.common.mixin.core.commands;
import io.izzel.arclight.common.bridge.core.command.ICommandSourceBridge;
import net.minecraft.commands.CommandSourceStack;
import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.v.command.ServerCommandSender;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Mixin;
@Mixin(targets = "net/minecraft/commands/CommandSource$1")
public class CommandSource1Mixin implements ICommandSourceBridge {
public CommandSender getBukkitSender(CommandSourceStack wrapper) {
return new ServerCommandSender() {
private final boolean isOp = wrapper.hasPermission(wrapper.getServer().getOperatorUserPermissionLevel());
@Override
public boolean isOp() {
return isOp;
}
@Override
public void setOp(boolean value) {
}
@Override
public void sendMessage(@NotNull String message) {
}
@Override
public void sendMessage(@NotNull String[] messages) {
}
@NotNull
@Override
public String getName() {
return "NULL";
}
};
}
@Override
public CommandSender bridge$getBukkitSender(CommandSourceStack wrapper) {
return getBukkitSender(wrapper);
}
}

View File

@ -19,6 +19,7 @@
"advancements.AdvancementMixin",
"commands.CommandsMixin",
"commands.CommandSourceMixin",
"commands.CommandSource1Mixin",
"commands.CommandSourceStackMixin",
"commands.arguments.EntityArgumentMixin",
"commands.arguments.blocks.BlockStateParserMixin",