mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
Handle all commands like pre-1.13 for now
This commit is contained in:
parent
4878f38250
commit
bb33897221
@ -24,6 +24,8 @@ import com.mojang.brigadier.CommandDispatcher;
|
|||||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||||
import com.mojang.brigadier.builder.ArgumentBuilder;
|
import com.mojang.brigadier.builder.ArgumentBuilder;
|
||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
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.CommandNode;
|
||||||
import com.mojang.brigadier.tree.LiteralCommandNode;
|
import com.mojang.brigadier.tree.LiteralCommandNode;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
@ -114,19 +116,17 @@ public class CommandWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Command<CommandSource> commandFor(CommandMapping mapping) {
|
private static Command<CommandSource> commandFor(CommandMapping mapping) {
|
||||||
return ctx -> {
|
return FAKE_COMMAND;
|
||||||
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;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
private static Predicate<CommandSource> requirementsFor(CommandMapping mapping) {
|
||||||
return ctx -> {
|
return ctx -> {
|
||||||
ForgePermissionsProvider permsProvider = ForgeWorldEdit.inst.getPermissionsProvider();
|
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 static com.sk89q.worldedit.forge.ForgeAdapter.adaptPlayer;
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
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.LocalSession;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.event.platform.PlatformReadyEvent;
|
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.ItemCategory;
|
||||||
import com.sk89q.worldedit.world.item.ItemType;
|
import com.sk89q.worldedit.world.item.ItemType;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.command.CommandSource;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.tags.BlockTags;
|
import net.minecraft.tags.BlockTags;
|
||||||
import net.minecraft.tags.ItemTags;
|
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.
|
* Get the configuration.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user