mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 09:47:38 +00:00
Updated SpoutRawCommandExecutor for changes in SpoutAPI and register command permissions with the Spout commands system
This commit is contained in:
parent
ba1d2c751b
commit
d2968b1976
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.spout;
|
package com.sk89q.worldedit.spout;
|
||||||
|
|
||||||
|
import org.spout.api.command.Command;
|
||||||
import org.spout.api.command.CommandSource;
|
import org.spout.api.command.CommandSource;
|
||||||
import org.spout.api.command.RawCommandExecutor;
|
import org.spout.api.command.RawCommandExecutor;
|
||||||
import org.spout.api.exception.CommandException;
|
import org.spout.api.exception.CommandException;
|
||||||
@ -35,8 +36,8 @@ public class SpoutRawCommandExecutor implements RawCommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSource source, String[] args, int baseIndex, boolean fuzzyLookup) throws CommandException {
|
public void execute(Command cmd, CommandSource source, String[] args, int baseIndex, boolean fuzzyLookup) throws CommandException {
|
||||||
args[baseIndex] = "/" + args[baseIndex];
|
args[baseIndex] = "/" + cmd.getPreferredName();
|
||||||
if (!plugin.getWorldEdit().handleCommand(plugin.wrapCommandSender(source), MiscCompatibilityUtils.arrayCopyOfRange(args, baseIndex, args.length))) {
|
if (!plugin.getWorldEdit().handleCommand(plugin.wrapCommandSender(source), MiscCompatibilityUtils.arrayCopyOfRange(args, baseIndex, args.length))) {
|
||||||
throw new CommandException("Unknown command: '" + args[baseIndex] + "'!");
|
throw new CommandException("Unknown command: '" + args[baseIndex] + "'!");
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,9 @@
|
|||||||
package com.sk89q.worldedit.spout;
|
package com.sk89q.worldedit.spout;
|
||||||
|
|
||||||
import com.sk89q.minecraft.util.commands.Command;
|
import com.sk89q.minecraft.util.commands.Command;
|
||||||
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||||
|
import com.sk89q.minecraft.util.commands.CommandsManager;
|
||||||
|
import com.sk89q.worldedit.LocalPlayer;
|
||||||
import com.sk89q.worldedit.LocalWorld;
|
import com.sk89q.worldedit.LocalWorld;
|
||||||
import com.sk89q.worldedit.ServerInterface;
|
import com.sk89q.worldedit.ServerInterface;
|
||||||
import org.spout.api.Game;
|
import org.spout.api.Game;
|
||||||
@ -28,6 +31,7 @@ import org.spout.api.geo.World;
|
|||||||
import org.spout.api.material.Material;
|
import org.spout.api.material.Material;
|
||||||
import org.spout.api.material.MaterialData;
|
import org.spout.api.material.MaterialData;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -76,13 +80,18 @@ public class SpoutServerInterface extends ServerInterface {
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCommandRegistration(List<Command> commands) {
|
public void onCommandRegistration(List<Command> commands, CommandsManager<LocalPlayer> manager) {
|
||||||
for (Command command : commands) {
|
for (Command command : commands) {
|
||||||
Spout.getGame().getRootCommand().addSubCommand(plugin, command.aliases()[0])
|
org.spout.api.command.Command spoutCommand = Spout.getGame().getRootCommand().addSubCommand(plugin, command.aliases()[0])
|
||||||
.addAlias(command.aliases()).setRawExecutor(executor).
|
.addAlias(command.aliases()).setRawExecutor(executor).
|
||||||
setUsage(command.usage()).setHelp(command.desc()).closeSubCommand();
|
setUsage(command.usage()).setHelp(command.desc());
|
||||||
|
Method cmdMethod = manager.getMethods().get(null).get(command.aliases()[0]);
|
||||||
|
if (cmdMethod != null && cmdMethod.isAnnotationPresent(CommandPermissions.class)) {
|
||||||
|
spoutCommand.setPermissions(false, cmdMethod.getAnnotation(CommandPermissions.class).value());
|
||||||
|
}
|
||||||
|
spoutCommand.closeSubCommand();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user