Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-25 18:40:05 +01:00
Updated SpoutRawCommandExecutor for changes in SpoutAPI and register command permissions with the Spout commands system
Dieser Commit ist enthalten in:
Ursprung
ba1d2c751b
Commit
d2968b1976
@ -18,6 +18,7 @@
|
||||
|
||||
package com.sk89q.worldedit.spout;
|
||||
|
||||
import org.spout.api.command.Command;
|
||||
import org.spout.api.command.CommandSource;
|
||||
import org.spout.api.command.RawCommandExecutor;
|
||||
import org.spout.api.exception.CommandException;
|
||||
@ -35,8 +36,8 @@ public class SpoutRawCommandExecutor implements RawCommandExecutor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSource source, String[] args, int baseIndex, boolean fuzzyLookup) throws CommandException {
|
||||
args[baseIndex] = "/" + args[baseIndex];
|
||||
public void execute(Command cmd, CommandSource source, String[] args, int baseIndex, boolean fuzzyLookup) throws CommandException {
|
||||
args[baseIndex] = "/" + cmd.getPreferredName();
|
||||
if (!plugin.getWorldEdit().handleCommand(plugin.wrapCommandSender(source), MiscCompatibilityUtils.arrayCopyOfRange(args, baseIndex, args.length))) {
|
||||
throw new CommandException("Unknown command: '" + args[baseIndex] + "'!");
|
||||
}
|
||||
|
@ -20,6 +20,9 @@
|
||||
package com.sk89q.worldedit.spout;
|
||||
|
||||
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.ServerInterface;
|
||||
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.MaterialData;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@ -78,11 +82,16 @@ public class SpoutServerInterface extends ServerInterface {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandRegistration(List<Command> commands) {
|
||||
public void onCommandRegistration(List<Command> commands, CommandsManager<LocalPlayer> manager) {
|
||||
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).
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren