Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-12 22:20:08 +01:00
Added support for dynamic command registration.
Dieser Commit ist enthalten in:
Ursprung
a1e239d08c
Commit
c8c0c69f6d
96
src/main/java/com/sk89q/bukkit/util/CommandRegistration.java
Normale Datei
96
src/main/java/com/sk89q/bukkit/util/CommandRegistration.java
Normale Datei
@ -0,0 +1,96 @@
|
|||||||
|
/*
|
||||||
|
* WorldEdit
|
||||||
|
* Copyright (C) 2011 sk89q <http://www.sk89q.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sk89q.bukkit.util;
|
||||||
|
|
||||||
|
import com.sk89q.minecraft.util.commands.Command;
|
||||||
|
import com.sk89q.minecraft.util.commands.CommandsManager;
|
||||||
|
import com.sk89q.util.ReflectionUtil;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.CommandMap;
|
||||||
|
import org.bukkit.command.SimpleCommandMap;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zml2008
|
||||||
|
*/
|
||||||
|
public class CommandRegistration {
|
||||||
|
private final Plugin plugin;
|
||||||
|
private CommandMap fallbackCommands;
|
||||||
|
|
||||||
|
public CommandRegistration(Plugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean registerAll(List<Command> registered) {
|
||||||
|
CommandMap commandMap = getCommandMap();
|
||||||
|
if (registered == null || commandMap == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (Command command : registered) {
|
||||||
|
commandMap.register(plugin.getDescription().getName(), new DynamicPluginCommand(command, plugin));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private CommandMap getCommandMap() {
|
||||||
|
CommandMap commandMap = ReflectionUtil.getField(plugin.getServer().getPluginManager(), "commandMap");
|
||||||
|
if (commandMap == null) {
|
||||||
|
if (fallbackCommands != null) {
|
||||||
|
commandMap = fallbackCommands;
|
||||||
|
} else {
|
||||||
|
Bukkit.getServer().getLogger().warning(plugin.getDescription().getName() +
|
||||||
|
": Could not retrieve server CommandMap, using fallback instead! Please report to http://redmine.sk89q.com");
|
||||||
|
fallbackCommands = commandMap = new SimpleCommandMap(Bukkit.getServer());
|
||||||
|
Bukkit.getServer().getPluginManager().registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESS,
|
||||||
|
new FallbackRegistrationListener(fallbackCommands), Event.Priority.Normal, plugin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return commandMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean unregisterCommands() {
|
||||||
|
CommandMap commandMap = getCommandMap();
|
||||||
|
List<String> toRemove = new ArrayList<String>();
|
||||||
|
Map<String, org.bukkit.command.Command> knownCommands = ReflectionUtil.getField(commandMap, "knownCommands");
|
||||||
|
Set<String> aliases = ReflectionUtil.getField(commandMap, "aliases");
|
||||||
|
if (knownCommands == null || aliases == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (Iterator<org.bukkit.command.Command> i = knownCommands.values().iterator(); i.hasNext();) {
|
||||||
|
org.bukkit.command.Command cmd = i.next();
|
||||||
|
if (cmd instanceof DynamicPluginCommand && ((DynamicPluginCommand) cmd).getPlugin().equals(plugin)) {
|
||||||
|
i.remove();
|
||||||
|
for (String alias : cmd.getAliases()) {
|
||||||
|
org.bukkit.command.Command aliasCmd = knownCommands.get(alias);
|
||||||
|
if (cmd.equals(aliasCmd)) {
|
||||||
|
aliases.remove(alias);
|
||||||
|
toRemove.add(alias);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (String string : toRemove) {
|
||||||
|
knownCommands.remove(string);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
42
src/main/java/com/sk89q/bukkit/util/CommandsManagerRegistration.java
Normale Datei
42
src/main/java/com/sk89q/bukkit/util/CommandsManagerRegistration.java
Normale Datei
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* WorldEdit
|
||||||
|
* Copyright (C) 2011 sk89q <http://www.sk89q.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sk89q.bukkit.util;
|
||||||
|
|
||||||
|
import com.sk89q.minecraft.util.commands.Command;
|
||||||
|
import com.sk89q.minecraft.util.commands.CommandsManager;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zml2008
|
||||||
|
*/
|
||||||
|
public class CommandsManagerRegistration extends CommandRegistration {
|
||||||
|
protected CommandsManager<?> commands;
|
||||||
|
|
||||||
|
public CommandsManagerRegistration(Plugin plugin, CommandsManager<?> commands) {
|
||||||
|
super(plugin);
|
||||||
|
this.commands = commands;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean register(Class<?> clazz) {
|
||||||
|
List<Command> registered = commands.registerAndReturn(clazz);
|
||||||
|
return registerAll(registered);
|
||||||
|
}
|
||||||
|
}
|
47
src/main/java/com/sk89q/bukkit/util/DynamicPluginCommand.java
Normale Datei
47
src/main/java/com/sk89q/bukkit/util/DynamicPluginCommand.java
Normale Datei
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* WorldEdit
|
||||||
|
* Copyright (C) 2011 sk89q <http://www.sk89q.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sk89q.bukkit.util;
|
||||||
|
|
||||||
|
import com.sk89q.minecraft.util.commands.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zml2008
|
||||||
|
*/
|
||||||
|
public class DynamicPluginCommand extends org.bukkit.command.Command {
|
||||||
|
|
||||||
|
protected final Plugin plugin;
|
||||||
|
|
||||||
|
public DynamicPluginCommand(Command command, Plugin plugin) {
|
||||||
|
super(command.aliases()[0], command.desc(), command.usage(), Arrays.asList(command.aliases()));
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean execute(CommandSender sender, String label, String[] args) {
|
||||||
|
return plugin.onCommand(sender, this, label, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Plugin getPlugin() {
|
||||||
|
return plugin;
|
||||||
|
}
|
||||||
|
}
|
@ -1,3 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* WorldEdit
|
||||||
|
* Copyright (C) 2011 sk89q <http://www.sk89q.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.sk89q.bukkit.util;
|
package com.sk89q.bukkit.util;
|
||||||
|
|
||||||
import org.bukkit.command.CommandMap;
|
import org.bukkit.command.CommandMap;
|
||||||
|
40
src/main/java/com/sk89q/util/ReflectionUtil.java
Normale Datei
40
src/main/java/com/sk89q/util/ReflectionUtil.java
Normale Datei
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* WorldGuard
|
||||||
|
* Copyright (C) 2011 sk89q <http://www.sk89q.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sk89q.util;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zml2008
|
||||||
|
*/
|
||||||
|
public class ReflectionUtil {
|
||||||
|
public static <T> T getField(Object from, String name) {
|
||||||
|
Class<?> checkClass = from.getClass();
|
||||||
|
do {
|
||||||
|
try {
|
||||||
|
Field field = checkClass.getDeclaredField(name);
|
||||||
|
field.setAccessible(true);
|
||||||
|
return (T) field.get(from);
|
||||||
|
} catch (NoSuchFieldException e) {
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
}
|
||||||
|
} while (checkClass.getSuperclass() != Object.class && ((checkClass = checkClass.getSuperclass()) != null));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit;
|
package com.sk89q.worldedit;
|
||||||
|
|
||||||
|
import com.sk89q.minecraft.util.commands.Command;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -64,4 +66,8 @@ public abstract class ServerInterface {
|
|||||||
public List<LocalWorld> getWorlds() {
|
public List<LocalWorld> getWorlds() {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onCommandRegistration(List<Command> commands) {
|
||||||
|
// Do nothing :)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -176,19 +176,19 @@ public class WorldEdit {
|
|||||||
|
|
||||||
commands.setInjector(new SimpleInjector(this));
|
commands.setInjector(new SimpleInjector(this));
|
||||||
|
|
||||||
commands.register(ChunkCommands.class);
|
server.onCommandRegistration(commands.registerAndReturn(ChunkCommands.class));
|
||||||
commands.register(ClipboardCommands.class);
|
server.onCommandRegistration(commands.registerAndReturn(ClipboardCommands.class));
|
||||||
commands.register(GeneralCommands.class);
|
server.onCommandRegistration(commands.registerAndReturn(GeneralCommands.class));
|
||||||
commands.register(GenerationCommands.class);
|
server.onCommandRegistration(commands.registerAndReturn(GenerationCommands.class));
|
||||||
commands.register(HistoryCommands.class);
|
server.onCommandRegistration(commands.registerAndReturn(HistoryCommands.class));
|
||||||
commands.register(NavigationCommands.class);
|
server.onCommandRegistration(commands.registerAndReturn(NavigationCommands.class));
|
||||||
commands.register(RegionCommands.class);
|
server.onCommandRegistration(commands.registerAndReturn(RegionCommands.class));
|
||||||
commands.register(ScriptingCommands.class);
|
server.onCommandRegistration(commands.registerAndReturn(ScriptingCommands.class));
|
||||||
commands.register(SelectionCommands.class);
|
server.onCommandRegistration(commands.registerAndReturn(SelectionCommands.class));
|
||||||
commands.register(SnapshotUtilCommands.class);
|
server.onCommandRegistration(commands.registerAndReturn(SnapshotUtilCommands.class));
|
||||||
commands.register(ToolUtilCommands.class);
|
server.onCommandRegistration(commands.registerAndReturn(ToolUtilCommands.class));
|
||||||
commands.register(ToolCommands.class);
|
server.onCommandRegistration(commands.registerAndReturn(ToolCommands.class));
|
||||||
commands.register(UtilityCommands.class);
|
server.onCommandRegistration(commands.registerAndReturn(UtilityCommands.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1222,27 +1222,7 @@ public class WorldEdit {
|
|||||||
*/
|
*/
|
||||||
public boolean handleCommand(LocalPlayer player, String[] split) {
|
public boolean handleCommand(LocalPlayer player, String[] split) {
|
||||||
try {
|
try {
|
||||||
split[0] = split[0].substring(1);
|
split = commandDetection(split);
|
||||||
|
|
||||||
// Quick script shortcut
|
|
||||||
if (split[0].matches("^[^/].*\\.js$")) {
|
|
||||||
String[] newSplit = new String[split.length + 1];
|
|
||||||
System.arraycopy(split, 0, newSplit, 1, split.length);
|
|
||||||
newSplit[0] = "cs";
|
|
||||||
newSplit[1] = newSplit[1];
|
|
||||||
split = newSplit;
|
|
||||||
}
|
|
||||||
|
|
||||||
String searchCmd = split[0].toLowerCase();
|
|
||||||
|
|
||||||
// Try to detect the command
|
|
||||||
if (commands.hasCommand(searchCmd)) {
|
|
||||||
} else if (config.noDoubleSlash && commands.hasCommand("/" + searchCmd)) {
|
|
||||||
split[0] = "/" + split[0];
|
|
||||||
} else if (split[0].length() >= 2 && split[0].charAt(0) == '/'
|
|
||||||
&& commands.hasCommand(searchCmd.substring(1))) {
|
|
||||||
split[0] = split[0].substring(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// No command found!
|
// No command found!
|
||||||
if (!commands.hasCommand(split[0])) {
|
if (!commands.hasCommand(split[0])) {
|
||||||
@ -1337,6 +1317,31 @@ public class WorldEdit {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String[] commandDetection(String[] split) {
|
||||||
|
split[0] = split[0].substring(1);
|
||||||
|
|
||||||
|
// Quick script shortcut
|
||||||
|
if (split[0].matches("^[^/].*\\.js$")) {
|
||||||
|
String[] newSplit = new String[split.length + 1];
|
||||||
|
System.arraycopy(split, 0, newSplit, 1, split.length);
|
||||||
|
newSplit[0] = "cs";
|
||||||
|
newSplit[1] = newSplit[1];
|
||||||
|
split = newSplit;
|
||||||
|
}
|
||||||
|
|
||||||
|
String searchCmd = split[0].toLowerCase();
|
||||||
|
|
||||||
|
// Try to detect the command
|
||||||
|
if (commands.hasCommand(searchCmd)) {
|
||||||
|
} else if (config.noDoubleSlash && commands.hasCommand("/" + searchCmd)) {
|
||||||
|
split[0] = "/" + split[0];
|
||||||
|
} else if (split[0].length() >= 2 && split[0].charAt(0) == '/'
|
||||||
|
&& commands.hasCommand(searchCmd.substring(1))) {
|
||||||
|
split[0] = split[0].substring(1);
|
||||||
|
}
|
||||||
|
return split;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes a WorldEdit script.
|
* Executes a WorldEdit script.
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package com.sk89q.worldedit.bukkit;
|
package com.sk89q.worldedit.bukkit;
|
||||||
|
|
||||||
import java.util.logging.Level;
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -31,23 +29,30 @@ public class BukkitCommandSender extends LocalPlayer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void printRaw(String msg) {
|
public void printRaw(String msg) {
|
||||||
System.out.println(msg);
|
for (String part : msg.split("\n")) {
|
||||||
}
|
sender.sendMessage(part);
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public void printDebug(String msg) {
|
|
||||||
Bukkit.getLogger().log(Level.WARNING, msg);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void print(String msg) {
|
public void print(String msg) {
|
||||||
Bukkit.getLogger().info(msg);
|
for (String part : msg.split("\n")) {
|
||||||
|
sender.sendMessage("\u00A7d" + part);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void printDebug(String msg) {
|
||||||
|
for (String part : msg.split("\n")) {
|
||||||
|
sender.sendMessage("\u00A77" + part);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void printError(String msg) {
|
public void printError(String msg) {
|
||||||
Bukkit.getLogger().log(Level.SEVERE, msg);
|
for (String part : msg.split("\n")) {
|
||||||
|
sender.sendMessage("\u00A7c" + part);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -22,18 +22,30 @@ package com.sk89q.worldedit.bukkit;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.sk89q.bukkit.util.CommandRegistration;
|
||||||
|
import com.sk89q.bukkit.util.DynamicPluginCommand;
|
||||||
|
import com.sk89q.bukkit.util.FallbackRegistrationListener;
|
||||||
|
import com.sk89q.util.ReflectionUtil;
|
||||||
|
import com.sk89q.minecraft.util.commands.Command;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
|
import org.bukkit.command.CommandMap;
|
||||||
|
import org.bukkit.command.SimpleCommandMap;
|
||||||
import org.bukkit.entity.CreatureType;
|
import org.bukkit.entity.CreatureType;
|
||||||
import com.sk89q.worldedit.LocalWorld;
|
import com.sk89q.worldedit.LocalWorld;
|
||||||
import com.sk89q.worldedit.ServerInterface;
|
import com.sk89q.worldedit.ServerInterface;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
import org.bukkit.event.player.PlayerListener;
|
||||||
|
|
||||||
public class BukkitServerInterface extends ServerInterface {
|
public class BukkitServerInterface extends ServerInterface {
|
||||||
public Server server;
|
public Server server;
|
||||||
public WorldEditPlugin plugin;
|
public WorldEditPlugin plugin;
|
||||||
|
private CommandRegistration dynamicCommands;
|
||||||
|
|
||||||
public BukkitServerInterface(WorldEditPlugin plugin, Server server) {
|
public BukkitServerInterface(WorldEditPlugin plugin, Server server) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.server = server;
|
this.server = server;
|
||||||
|
dynamicCommands = new CommandRegistration(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -68,4 +80,13 @@ public class BukkitServerInterface extends ServerInterface {
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCommandRegistration(List<Command> commands) {
|
||||||
|
dynamicCommands.registerAll(commands);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unregisterCommands() {
|
||||||
|
dynamicCommands.unregisterCommands();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.bukkit;
|
package com.sk89q.worldedit.bukkit;
|
||||||
|
|
||||||
|
import com.sk89q.util.StringUtil;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
@ -57,7 +58,7 @@ public class WorldEditPlayerListener extends PlayerListener {
|
|||||||
|
|
||||||
plugin.registerEvent("PLAYER_QUIT", this);
|
plugin.registerEvent("PLAYER_QUIT", this);
|
||||||
plugin.registerEvent("PLAYER_INTERACT", this);
|
plugin.registerEvent("PLAYER_INTERACT", this);
|
||||||
plugin.registerEvent("PLAYER_COMMAND_PREPROCESS", this);
|
plugin.registerEvent("PLAYER_COMMAND_PREPROCESS", this, Event.Priority.Low);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -83,9 +84,12 @@ public class WorldEditPlayerListener extends PlayerListener {
|
|||||||
|
|
||||||
String[] split = event.getMessage().split(" ");
|
String[] split = event.getMessage().split(" ");
|
||||||
|
|
||||||
if (plugin.getWorldEdit().handleCommand(plugin.wrapPlayer(event.getPlayer()), split)) {
|
if (split.length > 0) {
|
||||||
event.setCancelled(true);
|
split = plugin.getWorldEdit().commandDetection(split);
|
||||||
|
split[0] += "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event.setMessage(StringUtil.joinString(split, " "));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean ignoreLeftClickAir = false;
|
private boolean ignoreLeftClickAir = false;
|
||||||
|
@ -56,7 +56,7 @@ public class WorldEditPlugin extends JavaPlugin {
|
|||||||
/**
|
/**
|
||||||
* The server interface that all server-related API goes through.
|
* The server interface that all server-related API goes through.
|
||||||
*/
|
*/
|
||||||
private ServerInterface server;
|
private BukkitServerInterface server;
|
||||||
/**
|
/**
|
||||||
* Main WorldEdit instance.
|
* Main WorldEdit instance.
|
||||||
*/
|
*/
|
||||||
@ -121,6 +121,7 @@ public class WorldEditPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
controller.clearSessions();
|
controller.clearSessions();
|
||||||
config.unload();
|
config.unload();
|
||||||
|
server.unregisterCommands();
|
||||||
this.getServer().getScheduler().cancelTasks(this);
|
this.getServer().getScheduler().cancelTasks(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,328 +1,6 @@
|
|||||||
name: WorldEdit
|
name: WorldEdit
|
||||||
main: com.sk89q.worldedit.bukkit.WorldEditPlugin
|
main: com.sk89q.worldedit.bukkit.WorldEditPlugin
|
||||||
version: ${project.version}
|
version: ${project.version}
|
||||||
commands:
|
|
||||||
chunkinfo:
|
|
||||||
description: Get information about the chunk that you are inside
|
|
||||||
usage: /<command>
|
|
||||||
listchunks:
|
|
||||||
description: List chunks that your selection includes
|
|
||||||
usage: /<command>
|
|
||||||
delchunks:
|
|
||||||
description: Delete chunks that your selection includes
|
|
||||||
usage: /<command>
|
|
||||||
/load:
|
|
||||||
description: Load a schematic into your clipboard
|
|
||||||
usage: /<command> <filename>
|
|
||||||
/save:
|
|
||||||
description: Save a schematic into your clipboard
|
|
||||||
usage: /<command> <filename>
|
|
||||||
/copy:
|
|
||||||
description: Copy the selection to the clipboard
|
|
||||||
usage: /<command>
|
|
||||||
/flip:
|
|
||||||
description: Flip the contents of the clipboard.
|
|
||||||
usage: /<command> [-p] [dir]
|
|
||||||
/rotate:
|
|
||||||
description: Rotate the contents of the clipboard
|
|
||||||
usage: /<command> <angle-in-degrees>
|
|
||||||
/cut:
|
|
||||||
description: Cut the selection to the clipboard
|
|
||||||
usage: /<command> [leave-id]
|
|
||||||
/paste:
|
|
||||||
description: Paste the clipboard's contents
|
|
||||||
usage: /<command> [-ao]
|
|
||||||
clearclipboard:
|
|
||||||
description: Clear your clipboard
|
|
||||||
usage: /<command>
|
|
||||||
/limit:
|
|
||||||
description: Modify block change limit
|
|
||||||
usage: /<command> <limit>
|
|
||||||
/gmask:
|
|
||||||
description: Set the global mask
|
|
||||||
usage: /<command> [mask]
|
|
||||||
aliases: ['gmask']
|
|
||||||
we:
|
|
||||||
description: WorldEdit commands
|
|
||||||
usage: /<command>
|
|
||||||
aliases: ['worldedit']
|
|
||||||
/fast:
|
|
||||||
description: Toggle fast mode
|
|
||||||
usage: /<command>
|
|
||||||
/toggleplace:
|
|
||||||
description: Switch between your position and pos1 for placement
|
|
||||||
usage: /<command>
|
|
||||||
aliases: ['toggleplace']
|
|
||||||
/searchitem:
|
|
||||||
description: Search for an item
|
|
||||||
usage: /<command> [-bi] <query>
|
|
||||||
aliases: ['/l', '/search', 'searchitem', 'search']
|
|
||||||
/hcyl:
|
|
||||||
description: Generate a hollow cylinder
|
|
||||||
usage: /<command> <block> <radius> [height]
|
|
||||||
/cyl:
|
|
||||||
description: Generate a cylinder
|
|
||||||
usage: /<command> <block> <radius> [height]
|
|
||||||
/hsphere:
|
|
||||||
description: Generate a hollow sphere.
|
|
||||||
usage: /<command> [-q] <block> <radius>[,<radius>,<radius>] [raised?]
|
|
||||||
/sphere:
|
|
||||||
description: Generate a filled sphere.
|
|
||||||
usage: /<command> [-q] <block> <radius>[,<radius>,<radius>] [raised?]
|
|
||||||
forestgen:
|
|
||||||
description: Generate a forest
|
|
||||||
usage: /<command> [size] [type] [density]
|
|
||||||
pumpkins:
|
|
||||||
description: Generate pumpkin patches
|
|
||||||
usage: /<command> [size]
|
|
||||||
/pyramid:
|
|
||||||
description: Generate a filled pyramid
|
|
||||||
usage: /<command> <block> <range>
|
|
||||||
/hpyramid:
|
|
||||||
description: Generate a hollow pyramid
|
|
||||||
usage: /<command> <block> <range>
|
|
||||||
/undo:
|
|
||||||
description: Undoes the last action
|
|
||||||
usage: /<command> [times] [player]
|
|
||||||
aliases: ['undo']
|
|
||||||
/redo:
|
|
||||||
description: Redoes the last action (from history)
|
|
||||||
usage: /<command> [times] [player]
|
|
||||||
aliases: ['redo']
|
|
||||||
/clearhistory:
|
|
||||||
description: Clear your history
|
|
||||||
usage: /<command>
|
|
||||||
aliases: ['clearhistory']
|
|
||||||
unstuck:
|
|
||||||
description: Escape from being stuck inside a block
|
|
||||||
usage: /<command>
|
|
||||||
aliases: ['!']
|
|
||||||
ascend:
|
|
||||||
description: Go up a floor
|
|
||||||
usage: /<command> [# of levels]
|
|
||||||
descend:
|
|
||||||
description: Go down a floor
|
|
||||||
usage: /<command> [# of floors]
|
|
||||||
ceil:
|
|
||||||
description: Go to the celing
|
|
||||||
usage: /<command> [clearance]
|
|
||||||
thru:
|
|
||||||
description: Passthrough walls
|
|
||||||
usage: /<command>
|
|
||||||
jumpto:
|
|
||||||
description: Teleport to a location
|
|
||||||
usage: /<command>
|
|
||||||
up:
|
|
||||||
description: Go upwards some distance
|
|
||||||
usage: /<command> <block>
|
|
||||||
/replace:
|
|
||||||
description: Replace all blocks in the selection with another
|
|
||||||
usage: /<command> [-f] [from-block] <to-block>
|
|
||||||
/stack:
|
|
||||||
description: Repeat the contents of the selection
|
|
||||||
usage: /<command> [-sa] [count] [direction]
|
|
||||||
/set:
|
|
||||||
description: Set all the blocks inside the selection to a block
|
|
||||||
usage: /<command> <block>
|
|
||||||
/overlay:
|
|
||||||
description: Set a block on top of blocks in the region
|
|
||||||
usage: /<command> <block>
|
|
||||||
/naturalize:
|
|
||||||
description: 3 layers of dirt on top then rock below
|
|
||||||
usage: /<command>
|
|
||||||
/walls:
|
|
||||||
description: Build the four sides of the selection
|
|
||||||
usage: /<command> <block>
|
|
||||||
/faces:
|
|
||||||
description: Build the walls, ceiling, and floor of a selection
|
|
||||||
usage: /<command> <block>
|
|
||||||
aliases: ['/outline']
|
|
||||||
/smooth:
|
|
||||||
description: Smooth the elevation in the selection
|
|
||||||
usage: /<command> [-n] [iterations]
|
|
||||||
/move:
|
|
||||||
description: Move the contents of the selection
|
|
||||||
usage: /<command> [-s] [count] [direction] [leave-id]
|
|
||||||
/regen:
|
|
||||||
description: Regenerates the contents of the selection
|
|
||||||
usage: /<command>
|
|
||||||
cs:
|
|
||||||
description: Execute a CraftScript
|
|
||||||
usage: /<command> <filename> [args...]
|
|
||||||
.s:
|
|
||||||
description: Execute last CraftScript
|
|
||||||
usage: /<command> [args...]
|
|
||||||
/count:
|
|
||||||
description: Counts the number of a certain type of block
|
|
||||||
usage: /<command> <block>
|
|
||||||
/size:
|
|
||||||
description: Get information about the selection
|
|
||||||
usage: /<command>
|
|
||||||
/shift:
|
|
||||||
description: Shift the selection area
|
|
||||||
usage: /<command> <amount> [direction]
|
|
||||||
/chunk:
|
|
||||||
description: Set the selection to your current chunk.
|
|
||||||
usage: /<command> [-s]
|
|
||||||
/expand:
|
|
||||||
description: Expand the selection area
|
|
||||||
usage: /<command> <amount> [reverse-amount] <direction>
|
|
||||||
/contract:
|
|
||||||
description: Contract the selection area
|
|
||||||
usage: /<command> <amount> [reverse-amount] [direction]
|
|
||||||
/pos1:
|
|
||||||
description: Set position 1
|
|
||||||
usage: /<command> [coordinates]
|
|
||||||
/pos2:
|
|
||||||
description: Set position 2
|
|
||||||
usage: /<command> [coordinates]
|
|
||||||
/hpos1:
|
|
||||||
description: Set position 1 to targeted block
|
|
||||||
usage: /<command>
|
|
||||||
/hpos2:
|
|
||||||
description: Set position 2 to targeted block
|
|
||||||
usage: /<command>
|
|
||||||
/wand:
|
|
||||||
description: Get the wand object
|
|
||||||
usage: /<command>
|
|
||||||
toggleeditwand:
|
|
||||||
description: Toggle functionality of the edit wand
|
|
||||||
usage: /<command>
|
|
||||||
/outset:
|
|
||||||
description: Outset the selection area
|
|
||||||
usage: /<command> [-hv] <amount>
|
|
||||||
/inset:
|
|
||||||
description: Inset the selection area
|
|
||||||
usage: /<command> [-hv] <amount>
|
|
||||||
/distr:
|
|
||||||
description: Get the distribution of blocks in the selection
|
|
||||||
usage: /<command> [-c]
|
|
||||||
/sel:
|
|
||||||
description: Choose a region selector
|
|
||||||
usage: /<command> [type]
|
|
||||||
aliases: [';']
|
|
||||||
snapshot:
|
|
||||||
description: Snapshot commands
|
|
||||||
usage: /<command>
|
|
||||||
aliases: ['snap']
|
|
||||||
restore:
|
|
||||||
description: Restore the selection from a snapshot
|
|
||||||
usage: /<command> [snapshot]
|
|
||||||
aliases: ['/restore']
|
|
||||||
size:
|
|
||||||
description: Set the brush size
|
|
||||||
usage: /<command> [pattern]
|
|
||||||
mask:
|
|
||||||
description: Set the brush mask
|
|
||||||
usage: /<command> [mask]
|
|
||||||
/:
|
|
||||||
description: Toggle the super pickaxe pickaxe function
|
|
||||||
usage: /<command> [on|off]
|
|
||||||
aliases: [',']
|
|
||||||
superpickaxe:
|
|
||||||
description: Select super pickaxe mode
|
|
||||||
usage: /<command>
|
|
||||||
aliases: ['pickaxe', 'sp']
|
|
||||||
tool:
|
|
||||||
description: Select a tool to bind
|
|
||||||
usage: /<command>
|
|
||||||
mat:
|
|
||||||
description: Set the brush material
|
|
||||||
usage: /<command> [pattern]
|
|
||||||
aliases: ['material', 'fill']
|
|
||||||
range:
|
|
||||||
description: Set the brush range
|
|
||||||
usage: /<command> [pattern]
|
|
||||||
info:
|
|
||||||
description: Block information tool
|
|
||||||
usage: /<command>
|
|
||||||
none:
|
|
||||||
description: Unbind all bound tools
|
|
||||||
usage: /<command>
|
|
||||||
tree:
|
|
||||||
description: Tree generator tool
|
|
||||||
usage: /<command> [type]
|
|
||||||
repl:
|
|
||||||
description: Block replacer tool
|
|
||||||
usage: /<command> <block>
|
|
||||||
cycler:
|
|
||||||
description: Block data cycler tool
|
|
||||||
usage: /<command>
|
|
||||||
floodfill:
|
|
||||||
description: Flood fill tool
|
|
||||||
usage: /<command> <pattern> <range>
|
|
||||||
aliases: ['flood']
|
|
||||||
brush:
|
|
||||||
description: Brush tool
|
|
||||||
usage: /<command>
|
|
||||||
aliases: ['br']
|
|
||||||
deltree:
|
|
||||||
description: Floating tree remover tool
|
|
||||||
usage: /<command>
|
|
||||||
farwand:
|
|
||||||
description: Wand at a distance tool
|
|
||||||
usage: /<command>
|
|
||||||
lrbuild:
|
|
||||||
description: Long-range building tool
|
|
||||||
usage: /<command> <leftclick block> <rightclick block>
|
|
||||||
aliases: ['/lrbuild']
|
|
||||||
remove:
|
|
||||||
description: Remove all entities of a type
|
|
||||||
usage: /<command> <type> <radius>
|
|
||||||
aliases: ['rem', 'rement']
|
|
||||||
/fill:
|
|
||||||
description: Fill a hole
|
|
||||||
usage: /<command> <block> <radius> [depth]
|
|
||||||
/fillr:
|
|
||||||
description: Fill a hole recursively
|
|
||||||
usage: /<command> <block> <radius> [depth]
|
|
||||||
/drain:
|
|
||||||
description: Drain a pool
|
|
||||||
usage: /<command> <radius>
|
|
||||||
/fixlava:
|
|
||||||
description: Fix lava to be stationary
|
|
||||||
usage: /<command> <radius>
|
|
||||||
aliases: ['fixlava']
|
|
||||||
/fixwater:
|
|
||||||
description: Fix water to be stationary
|
|
||||||
usage: /<command> <radius>
|
|
||||||
aliases: ['fixwater']
|
|
||||||
/removeabove:
|
|
||||||
description: Remove blocks above your head.
|
|
||||||
usage: /<command> [size] [height]
|
|
||||||
aliases: ['removeabove']
|
|
||||||
/removebelow:
|
|
||||||
description: Remove blocks below you.
|
|
||||||
usage: /<command> [size] [height]
|
|
||||||
aliases: ['removebelow']
|
|
||||||
/removenear:
|
|
||||||
description: Remove blocks near you.
|
|
||||||
usage: /<command> <block> [size]
|
|
||||||
aliases: ['removenear']
|
|
||||||
/replacenear:
|
|
||||||
description: Replace nearby blocks
|
|
||||||
usage: /<command> [-f] <size> <from-id> <to-id>
|
|
||||||
aliases: ['replacenear']
|
|
||||||
/snow:
|
|
||||||
description: Simulates snow
|
|
||||||
usage: /<command> [radius]
|
|
||||||
aliases: ['snow']
|
|
||||||
/thaw:
|
|
||||||
description: Thaws the area
|
|
||||||
usage: /<command> [radius]
|
|
||||||
aliases: ['thaw']
|
|
||||||
/green:
|
|
||||||
description: Greens the area
|
|
||||||
usage: /<command> [radius]
|
|
||||||
aliases: ['green']
|
|
||||||
/ex:
|
|
||||||
description: Extinguish nearby fire
|
|
||||||
usage: /<command> [radius]
|
|
||||||
aliases: ['/ext', '/extinguish', 'ex', 'ext', 'extinguish']
|
|
||||||
butcher:
|
|
||||||
description: Kill all or nearby mobs
|
|
||||||
usage: /<command> [-p] [radius]
|
|
||||||
|
|
||||||
|
|
||||||
# Permissions aren't here. Read http://wiki.sk89q.com/wiki/WEPIF/DinnerPerms
|
# Permissions aren't here. Read http://wiki.sk89q.com/wiki/WEPIF/DinnerPerms
|
||||||
# for how WorldEdit permissions actually work.
|
# for how WorldEdit permissions actually work.
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren