mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 17:57:38 +00:00
Updated for SpoutAPI changes
This commit is contained in:
parent
bb5f3477c2
commit
30f9fb16ac
@ -18,11 +18,13 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.spout;
|
package com.sk89q.worldedit.spout;
|
||||||
|
|
||||||
|
import org.spout.api.chat.ChatSection;
|
||||||
import org.spout.api.command.Command;
|
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;
|
||||||
import org.spout.api.util.MiscCompatibilityUtils;
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author zml2008
|
* @author zml2008
|
||||||
@ -36,10 +38,15 @@ public class SpoutRawCommandExecutor implements RawCommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(Command cmd, CommandSource source, String[] args, int baseIndex, boolean fuzzyLookup) throws CommandException {
|
public void execute(Command cmd, CommandSource source, String name, List<ChatSection> args, int baseIndex, boolean fuzzyLookup) throws CommandException {
|
||||||
args[baseIndex] = "/" + cmd.getPreferredName();
|
String[] argArray = new String[args.size() - baseIndex + 1];
|
||||||
if (!plugin.getWorldEdit().handleCommand(plugin.wrapCommandSender(source), MiscCompatibilityUtils.arrayCopyOfRange(args, baseIndex, args.length))) {
|
argArray[0] = "/" + cmd.getPreferredName();
|
||||||
throw new CommandException("Unknown command: '" + args[baseIndex] + "'!");
|
for (int i = baseIndex; i < args.size(); ++i) {
|
||||||
|
argArray[i - baseIndex + 1] = args.get(i).getPlainString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!plugin.getWorldEdit().handleCommand(plugin.wrapCommandSender(source), argArray)) {
|
||||||
|
throw new CommandException("Unknown command: '/" + name + "'!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,8 @@ import com.sk89q.worldedit.LocalWorld;
|
|||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldVector;
|
import com.sk89q.worldedit.WorldVector;
|
||||||
import org.spout.api.Spout;
|
import org.spout.api.Spout;
|
||||||
|
import org.spout.api.chat.ChatArguments;
|
||||||
|
import org.spout.api.chat.ChatSection;
|
||||||
import org.spout.api.event.EventHandler;
|
import org.spout.api.event.EventHandler;
|
||||||
import org.spout.api.event.Listener;
|
import org.spout.api.event.Listener;
|
||||||
import org.spout.api.event.Order;
|
import org.spout.api.event.Order;
|
||||||
@ -41,6 +43,8 @@ import org.spout.api.generator.biome.BiomeGenerator;
|
|||||||
import org.spout.api.geo.discrete.Point;
|
import org.spout.api.geo.discrete.Point;
|
||||||
import org.spout.api.scheduler.TaskPriority;
|
import org.spout.api.scheduler.TaskPriority;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@ -89,17 +93,28 @@ public class WorldEditListener implements Listener {
|
|||||||
@EventHandler(order = Order.EARLY)
|
@EventHandler(order = Order.EARLY)
|
||||||
public void onPlayerCommandPreprocess(PreCommandEvent event) {
|
public void onPlayerCommandPreprocess(PreCommandEvent event) {
|
||||||
|
|
||||||
if (event.getMessage().startsWith("nowe:")) {
|
if (event.getCommand().startsWith("nowe:")) {
|
||||||
event.setMessage(event.getMessage().substring(5));
|
event.setCommand(event.getCommand().substring(5));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] split = event.getMessage().split(" ");
|
List<ChatSection> args = event.getArguments().toSections(ChatSection.SplitType.WORD);
|
||||||
|
if (args.size() > 0) {
|
||||||
|
String[] split = new String[args.size() + 1];
|
||||||
|
split[0] = "/" + event.getCommand();
|
||||||
|
for (int i = 0; i < args.size(); ++i) {
|
||||||
|
split[i + 1] = args.get(i).getPlainString();
|
||||||
|
}
|
||||||
|
|
||||||
if (split.length > 0) {
|
String[] newSplit = plugin.getWorldEdit().commandDetection(split);
|
||||||
split[0] = "/" + split[0];
|
if (!Arrays.equals(split, newSplit)) {
|
||||||
split = plugin.getWorldEdit().commandDetection(split);
|
event.setCommand(newSplit[0]);
|
||||||
event.setMessage(StringUtil.joinString(split, " "));
|
ChatArguments newArgs = new ChatArguments();
|
||||||
|
for (int i = 1; i < newSplit.length; ++i) {
|
||||||
|
newArgs.append(newSplit[i]);
|
||||||
|
}
|
||||||
|
event.setArguments(newArgs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,7 +185,7 @@ public class WorldEditListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Matcher matcher = cuipattern.matcher(event.getMessage());
|
Matcher matcher = cuipattern.matcher(event.getMessage().getPlainString());
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
String type = matcher.group(1);
|
String type = matcher.group(1);
|
||||||
String args = matcher.group(2);
|
String args = matcher.group(2);
|
||||||
|
Loading…
Reference in New Issue
Block a user