Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-09-06 16:12:51 +02:00
Handle all commands like pre-1.13 for now
Dieser Commit ist enthalten in:
Ursprung
4878f38250
Commit
bb33897221
@ -24,6 +24,8 @@ import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.builder.ArgumentBuilder;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.mojang.brigadier.tree.CommandNode;
|
||||
import com.mojang.brigadier.tree.LiteralCommandNode;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
@ -114,19 +116,17 @@ public class CommandWrapper {
|
||||
}
|
||||
|
||||
private static Command<CommandSource> commandFor(CommandMapping mapping) {
|
||||
return ctx -> {
|
||||
EntityPlayerMP player = ctx.getSource().asPlayer();
|
||||
if (player.world.isRemote()) {
|
||||
return 0;
|
||||
}
|
||||
WorldEdit.getInstance().getEventBus().post(new CommandEvent(
|
||||
adaptPlayer(player),
|
||||
ctx.getRange().get(ctx.getInput())
|
||||
));
|
||||
return 1;
|
||||
};
|
||||
return FAKE_COMMAND;
|
||||
}
|
||||
|
||||
public static final Command<CommandSource> FAKE_COMMAND = ctx -> {
|
||||
EntityPlayerMP player = ctx.getSource().asPlayer();
|
||||
if (player.world.isRemote()) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
};
|
||||
|
||||
private static Predicate<CommandSource> requirementsFor(CommandMapping mapping) {
|
||||
return ctx -> {
|
||||
ForgePermissionsProvider permsProvider = ForgeWorldEdit.inst.getPermissionsProvider();
|
||||
|
@ -23,6 +23,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.sk89q.worldedit.forge.ForgeAdapter.adaptPlayer;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.mojang.brigadier.ParseResults;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.event.platform.PlatformReadyEvent;
|
||||
@ -37,6 +39,7 @@ import com.sk89q.worldedit.world.entity.EntityType;
|
||||
import com.sk89q.worldedit.world.item.ItemCategory;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
@ -270,6 +273,26 @@ public class ForgeWorldEdit {
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onCommandEvent(CommandEvent event) throws CommandSyntaxException {
|
||||
ParseResults<CommandSource> parseResults = event.getParseResults();
|
||||
if (!(parseResults.getContext().getSource().getEntity() instanceof EntityPlayerMP)) {
|
||||
return;
|
||||
}
|
||||
EntityPlayerMP player = parseResults.getContext().getSource().asPlayer();
|
||||
if (player.world.isRemote()) {
|
||||
return;
|
||||
}
|
||||
if (parseResults.getContext().getCommand() != CommandWrapper.FAKE_COMMAND) {
|
||||
return;
|
||||
}
|
||||
event.setCanceled(true);
|
||||
WorldEdit.getInstance().getEventBus().post(new com.sk89q.worldedit.event.platform.CommandEvent(
|
||||
adaptPlayer(parseResults.getContext().getSource().asPlayer()),
|
||||
parseResults.getReader().getString()
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the configuration.
|
||||
*
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren