mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-02 03:16:41 +00:00
Split up source files into several source directories.
This commit is contained in:
@ -1,65 +0,0 @@
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2012 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;
|
||||
|
||||
/**
|
||||
* @author zml2008
|
||||
*/
|
||||
public class CommandInfo {
|
||||
private final String[] aliases;
|
||||
private final Object registeredWith;
|
||||
private final String usage, desc;
|
||||
private final String[] permissions;
|
||||
|
||||
public CommandInfo(String usage, String desc, String[] aliases, Object registeredWith) {
|
||||
this(usage, desc, aliases, registeredWith, null);
|
||||
}
|
||||
|
||||
public CommandInfo(String usage, String desc, String[] aliases, Object registeredWith, String[] permissions) {
|
||||
this.usage = usage;
|
||||
this.desc = desc;
|
||||
this.aliases = aliases;
|
||||
this.permissions = permissions;
|
||||
this.registeredWith = registeredWith;
|
||||
}
|
||||
|
||||
public String[] getAliases() {
|
||||
return aliases;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return aliases[0];
|
||||
}
|
||||
|
||||
public String getUsage() {
|
||||
return usage;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public String[] getPermissions() {
|
||||
return permissions;
|
||||
}
|
||||
|
||||
public Object getRegisteredWith() {
|
||||
return registeredWith;
|
||||
}
|
||||
}
|
@ -1,112 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2011 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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 java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.sk89q.util.ReflectionUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandMap;
|
||||
import org.bukkit.command.SimpleCommandMap;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* @author zml2008
|
||||
*/
|
||||
public class CommandRegistration {
|
||||
|
||||
static {
|
||||
Bukkit.getServer().getHelpMap().registerHelpTopicFactory(DynamicPluginCommand.class, new DynamicPluginCommandHelpTopic.Factory());
|
||||
}
|
||||
|
||||
protected final Plugin plugin;
|
||||
protected final CommandExecutor executor;
|
||||
private CommandMap fallbackCommands;
|
||||
|
||||
public CommandRegistration(Plugin plugin) {
|
||||
this(plugin, plugin);
|
||||
}
|
||||
|
||||
public CommandRegistration(Plugin plugin, CommandExecutor executor) {
|
||||
this.plugin = plugin;
|
||||
this.executor = executor;
|
||||
}
|
||||
|
||||
public boolean register(List<CommandInfo> registered) {
|
||||
CommandMap commandMap = getCommandMap();
|
||||
if (registered == null || commandMap == null) {
|
||||
return false;
|
||||
}
|
||||
for (CommandInfo command : registered) {
|
||||
DynamicPluginCommand cmd = new DynamicPluginCommand(command.getAliases(),
|
||||
command.getDesc(), "/" + command.getAliases()[0] + " " + command.getUsage(), executor, command.getRegisteredWith(), plugin);
|
||||
cmd.setPermissions(command.getPermissions());
|
||||
commandMap.register(plugin.getDescription().getName(), cmd);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public CommandMap getCommandMap() {
|
||||
CommandMap commandMap = ReflectionUtil.getField(plugin.getServer().getPluginManager(), "commandMap");
|
||||
if (commandMap == null) {
|
||||
if (fallbackCommands != null) {
|
||||
commandMap = fallbackCommands;
|
||||
} else {
|
||||
Bukkit.getServer().getLogger().severe(plugin.getDescription().getName() +
|
||||
": Could not retrieve server CommandMap, using fallback instead!");
|
||||
fallbackCommands = commandMap = new SimpleCommandMap(Bukkit.getServer());
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new FallbackRegistrationListener(fallbackCommands), 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).getOwner().equals(executor)) {
|
||||
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;
|
||||
}
|
||||
}
|
@ -1,77 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2011 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.CommandsManager;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author zml2008
|
||||
*/
|
||||
public class CommandsManagerRegistration extends CommandRegistration {
|
||||
protected CommandsManager<?> commands;
|
||||
|
||||
public CommandsManagerRegistration(Plugin plugin, CommandsManager<?> commands) {
|
||||
super(plugin);
|
||||
this.commands = commands;
|
||||
}
|
||||
|
||||
public CommandsManagerRegistration(Plugin plugin, CommandExecutor executor, CommandsManager<?> commands) {
|
||||
super(plugin, executor);
|
||||
this.commands = commands;
|
||||
}
|
||||
|
||||
public boolean register(Class<?> clazz) {
|
||||
return registerAll(commands.registerAndReturn(clazz));
|
||||
}
|
||||
|
||||
public boolean registerAll(List<Command> registered) {
|
||||
List<CommandInfo> toRegister = new ArrayList<CommandInfo>();
|
||||
for (Command command : registered) {
|
||||
List<String> permissions = null;
|
||||
Method cmdMethod = commands.getMethods().get(null).get(command.aliases()[0]);
|
||||
Map<String, Method> childMethods = commands.getMethods().get(cmdMethod);
|
||||
|
||||
if (cmdMethod != null && cmdMethod.isAnnotationPresent(CommandPermissions.class)) {
|
||||
permissions = Arrays.asList(cmdMethod.getAnnotation(CommandPermissions.class).value());
|
||||
} else if (cmdMethod != null && childMethods != null && childMethods.size() > 0) {
|
||||
permissions = new ArrayList<String>();
|
||||
for (Method m : childMethods.values()) {
|
||||
if (m.isAnnotationPresent(CommandPermissions.class)) {
|
||||
permissions.addAll(Arrays.asList(m.getAnnotation(CommandPermissions.class).value()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
toRegister.add(new CommandInfo(command.usage(), command.desc(), command.aliases(), commands, permissions == null ? null : permissions.toArray(new String[permissions.size()])));
|
||||
}
|
||||
|
||||
return register(toRegister);
|
||||
}
|
||||
}
|
@ -1,106 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2011 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.CommandsManager;
|
||||
import com.sk89q.util.StringUtil;
|
||||
import com.sk89q.wepif.PermissionsResolverManager;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.PluginIdentifiableCommand;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* An implementation of a dynamically registered {@link org.bukkit.command.Command} attached to a plugin
|
||||
*/
|
||||
public class DynamicPluginCommand extends org.bukkit.command.Command implements PluginIdentifiableCommand {
|
||||
|
||||
protected final CommandExecutor owner;
|
||||
protected final Object registeredWith;
|
||||
protected final Plugin owningPlugin;
|
||||
protected String[] permissions = new String[0];
|
||||
|
||||
public DynamicPluginCommand(String[] aliases, String desc, String usage, CommandExecutor owner, Object registeredWith, Plugin plugin) {
|
||||
super(aliases[0], desc, usage, Arrays.asList(aliases));
|
||||
this.owner = owner;
|
||||
this.owningPlugin = plugin;
|
||||
this.registeredWith = registeredWith;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String label, String[] args) {
|
||||
return owner.onCommand(sender, this, label, args);
|
||||
}
|
||||
|
||||
public Object getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public Object getRegisteredWith() {
|
||||
return registeredWith;
|
||||
}
|
||||
|
||||
public void setPermissions(String[] permissions) {
|
||||
this.permissions = permissions;
|
||||
if (permissions != null) {
|
||||
super.setPermission(StringUtil.joinString(permissions, ";"));
|
||||
}
|
||||
}
|
||||
|
||||
public String[] getPermissions() {
|
||||
return permissions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin getPlugin() {
|
||||
return owningPlugin;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean testPermissionSilent(CommandSender sender) {
|
||||
if (permissions == null || permissions.length == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (registeredWith instanceof CommandsManager<?>) {
|
||||
try {
|
||||
for (String permission : permissions) {
|
||||
if (((CommandsManager<CommandSender>) registeredWith).hasPermission(sender, permission)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} catch (Throwable ignore) {
|
||||
}
|
||||
} else if (PermissionsResolverManager.isInitialized() && sender instanceof OfflinePlayer) {
|
||||
for (String permission : permissions) {
|
||||
if (PermissionsResolverManager.getInstance().hasPermission((OfflinePlayer) sender, permission)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return super.testPermissionSilent(sender);
|
||||
}
|
||||
}
|
@ -1,139 +0,0 @@
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2012 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.CommandsManager;
|
||||
import com.sk89q.wepif.PermissionsResolverManager;
|
||||
import com.sk89q.wepif.WEPIFRuntimeException;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.help.HelpTopic;
|
||||
import org.bukkit.help.HelpTopicFactory;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author zml2008
|
||||
*/
|
||||
public class DynamicPluginCommandHelpTopic extends HelpTopic {
|
||||
private final DynamicPluginCommand cmd;
|
||||
|
||||
public DynamicPluginCommandHelpTopic(DynamicPluginCommand cmd) {
|
||||
this.cmd = cmd;
|
||||
this.name = "/" + cmd.getName();
|
||||
|
||||
String fullTextTemp = null;
|
||||
StringBuilder fullText = new StringBuilder();
|
||||
|
||||
if (cmd.getRegisteredWith() instanceof CommandsManager) {
|
||||
Map<String, String> helpText = ((CommandsManager<?>) cmd.getRegisteredWith()).getHelpMessages();
|
||||
final String lookupName = cmd.getName().replaceAll("/", "");
|
||||
if (helpText.containsKey(lookupName)) { // We have full help text for this command
|
||||
fullTextTemp = helpText.get(lookupName);
|
||||
}
|
||||
// No full help text, assemble help text from info
|
||||
helpText = ((CommandsManager<?>) cmd.getRegisteredWith()).getCommands();
|
||||
if (helpText.containsKey(cmd.getName())) {
|
||||
final String shortText = helpText.get(cmd.getName());
|
||||
if (fullTextTemp == null) {
|
||||
fullTextTemp = this.name + " " + shortText;
|
||||
}
|
||||
this.shortText = shortText;
|
||||
}
|
||||
} else {
|
||||
this.shortText = cmd.getDescription();
|
||||
}
|
||||
|
||||
// Put the usage in the format: Usage string (newline) Aliases (newline) Help text
|
||||
String[] split = fullTextTemp == null ? new String[2] : fullTextTemp.split("\n", 2);
|
||||
fullText.append(ChatColor.BOLD).append(ChatColor.GOLD).append("Usage: ").append(ChatColor.WHITE);
|
||||
fullText.append(split[0]).append("\n");
|
||||
|
||||
if (cmd.getAliases().size() > 0) {
|
||||
fullText.append(ChatColor.BOLD).append(ChatColor.GOLD).append("Aliases: ").append(ChatColor.WHITE);
|
||||
boolean first = true;
|
||||
for (String alias : cmd.getAliases()) {
|
||||
if (!first) {
|
||||
fullText.append(", ");
|
||||
}
|
||||
fullText.append(alias);
|
||||
first = false;
|
||||
}
|
||||
fullText.append("\n");
|
||||
}
|
||||
if (split.length > 1) {
|
||||
fullText.append(split[1]);
|
||||
}
|
||||
this.fullText = fullText.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean canSee(CommandSender player) {
|
||||
if (cmd.getPermissions() != null && cmd.getPermissions().length > 0) {
|
||||
if (cmd.getRegisteredWith() instanceof CommandsManager) {
|
||||
try {
|
||||
for (String perm : cmd.getPermissions()) {
|
||||
if (((CommandsManager<Object>) cmd.getRegisteredWith()).hasPermission(player, perm)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
// Doesn't take the CommandSender (Hooray for compile-time generics!), we have other methods at our disposal
|
||||
}
|
||||
}
|
||||
if (player instanceof OfflinePlayer) {
|
||||
try {
|
||||
for (String perm : cmd.getPermissions()) {
|
||||
if (PermissionsResolverManager.getInstance().hasPermission((OfflinePlayer) player, perm)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (WEPIFRuntimeException e) {
|
||||
// PermissionsResolverManager not initialized, eat it
|
||||
}
|
||||
}
|
||||
for (String perm : cmd.getPermissions()) {
|
||||
if (player.hasPermission(perm)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFullText(CommandSender forWho) {
|
||||
if (this.fullText == null || this.fullText.length() == 0) {
|
||||
return getShortText();
|
||||
} else {
|
||||
return this.fullText;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Factory implements HelpTopicFactory<DynamicPluginCommand> {
|
||||
|
||||
@Override
|
||||
public HelpTopic createTopic(DynamicPluginCommand command) {
|
||||
return new DynamicPluginCommandHelpTopic(command);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2011 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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 org.bukkit.command.CommandMap;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
/**
|
||||
* @author zml2008
|
||||
*/
|
||||
public class FallbackRegistrationListener implements Listener {
|
||||
|
||||
private final CommandMap commandRegistration;
|
||||
|
||||
public FallbackRegistrationListener(CommandMap commandRegistration) {
|
||||
this.commandRegistration = commandRegistration;
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
if (commandRegistration.dispatch(event.getPlayer(), event.getMessage())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,170 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.wepif;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.sk89q.util.yaml.YAMLNode;
|
||||
import com.sk89q.util.yaml.YAMLProcessor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
public class ConfigurationPermissionsResolver implements PermissionsResolver {
|
||||
private YAMLProcessor config;
|
||||
private Map<String, Set<String>> userPermissionsCache;
|
||||
private Set<String> defaultPermissionsCache;
|
||||
private Map<String, Set<String>> userGroups;
|
||||
|
||||
public ConfigurationPermissionsResolver(YAMLProcessor config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
public static YAMLNode generateDefaultPerms(YAMLNode section) {
|
||||
section.setProperty("groups.default.permissions", new String[] {
|
||||
"worldedit.reload",
|
||||
"worldedit.selection",
|
||||
"worlds.creative.worldedit.region"});
|
||||
section.setProperty("groups.admins.permissions", new String[] { "*" });
|
||||
section.setProperty("users.sk89q.permissions", new String[] { "worldedit" });
|
||||
section.setProperty("users.sk89q.groups", new String[] { "admins" });
|
||||
return section;
|
||||
}
|
||||
|
||||
public void load() {
|
||||
userGroups = new HashMap<String, Set<String>>();
|
||||
userPermissionsCache = new HashMap<String, Set<String>>();
|
||||
defaultPermissionsCache = new HashSet<String>();
|
||||
|
||||
Map<String, Set<String>> userGroupPermissions = new HashMap<String, Set<String>>();
|
||||
|
||||
List<String> groupKeys = config.getStringList("permissions.groups", null);
|
||||
|
||||
if (groupKeys != null) {
|
||||
for (String key : groupKeys) {
|
||||
List<String> permissions =
|
||||
config.getStringList("permissions.groups." + key + ".permissions", null);
|
||||
|
||||
if (permissions.size() > 0) {
|
||||
Set<String> groupPerms = new HashSet<String>(permissions);
|
||||
userGroupPermissions.put(key, groupPerms);
|
||||
|
||||
if (key.equals("default")) {
|
||||
defaultPermissionsCache.addAll(permissions);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<String> userKeys = config.getStringList("permissions.users", null);
|
||||
|
||||
if (userKeys != null) {
|
||||
for (String key : userKeys) {
|
||||
Set<String> permsCache = new HashSet<String>();
|
||||
|
||||
List<String> permissions =
|
||||
config.getStringList("permissions.users." + key + ".permissions", null);
|
||||
|
||||
if (permissions.size() > 0) {
|
||||
permsCache.addAll(permissions);
|
||||
}
|
||||
|
||||
List<String> groups =
|
||||
config.getStringList("permissions.users." + key + ".groups", null);
|
||||
groups.add("default");
|
||||
|
||||
if (groups.size() > 0) {
|
||||
for (String group : groups) {
|
||||
Set<String> groupPerms = userGroupPermissions.get(group);
|
||||
if (groupPerms != null) {
|
||||
permsCache.addAll(groupPerms);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
userPermissionsCache.put(key.toLowerCase(), permsCache);
|
||||
userGroups.put(key.toLowerCase(), new HashSet<String>(groups));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasPermission(String player, String permission) {
|
||||
int dotPos = permission.lastIndexOf(".");
|
||||
if (dotPos > -1) {
|
||||
if (hasPermission(player, permission.substring(0, dotPos))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Set<String> perms = userPermissionsCache.get(player.toLowerCase());
|
||||
if (perms == null) {
|
||||
return defaultPermissionsCache.contains(permission)
|
||||
|| defaultPermissionsCache.contains("*");
|
||||
}
|
||||
|
||||
return perms.contains("*") || perms.contains(permission);
|
||||
}
|
||||
|
||||
public boolean hasPermission(String worldName, String player, String permission) {
|
||||
return hasPermission(player, "worlds." + worldName + "." + permission)
|
||||
|| hasPermission(player, permission);
|
||||
}
|
||||
|
||||
public boolean inGroup(String player, String group) {
|
||||
Set<String> groups = userGroups.get(player.toLowerCase());
|
||||
if (groups == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return groups.contains(group);
|
||||
}
|
||||
|
||||
public String[] getGroups(String player) {
|
||||
Set<String> groups = userGroups.get(player.toLowerCase());
|
||||
if (groups == null) {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
return groups.toArray(new String[groups.size()]);
|
||||
}
|
||||
|
||||
public boolean hasPermission(OfflinePlayer player, String permission) {
|
||||
return hasPermission(player.getName(), permission);
|
||||
}
|
||||
|
||||
public boolean hasPermission(String worldName, OfflinePlayer player, String permission) {
|
||||
return hasPermission(worldName, player.getName(), permission);
|
||||
}
|
||||
|
||||
public boolean inGroup(OfflinePlayer player, String group) {
|
||||
return inGroup(player.getName(), group);
|
||||
}
|
||||
|
||||
public String[] getGroups(OfflinePlayer player) {
|
||||
return getGroups(player.getName());
|
||||
}
|
||||
|
||||
public String getDetectionMessage() {
|
||||
return "No known permissions plugin detected. Using configuration file for permissions.";
|
||||
}
|
||||
|
||||
}
|
@ -1,155 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.wepif;
|
||||
|
||||
import com.sk89q.util.yaml.YAMLProcessor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permissible;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DinnerPermsResolver implements PermissionsResolver {
|
||||
|
||||
public static final String GROUP_PREFIX = "group.";
|
||||
protected final Server server;
|
||||
|
||||
public DinnerPermsResolver(Server server) {
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
public static PermissionsResolver factory(Server server, YAMLProcessor config) {
|
||||
return new DinnerPermsResolver(server);
|
||||
}
|
||||
|
||||
public void load() {
|
||||
}
|
||||
|
||||
public boolean hasPermission(String name, String permission) {
|
||||
return hasPermission(server.getOfflinePlayer(name), permission);
|
||||
}
|
||||
|
||||
public boolean hasPermission(String worldName, String name, String permission) {
|
||||
return hasPermission(worldName, server.getOfflinePlayer(name), permission);
|
||||
}
|
||||
|
||||
public boolean inGroup(String name, String group) {
|
||||
return inGroup(server.getOfflinePlayer(name), group);
|
||||
}
|
||||
|
||||
public String[] getGroups(String name) {
|
||||
return getGroups(server.getOfflinePlayer(name));
|
||||
}
|
||||
|
||||
public boolean hasPermission(OfflinePlayer player, String permission) {
|
||||
Permissible perms = getPermissible(player);
|
||||
if (perms == null) {
|
||||
return false; // Permissions are only registered for objects with a Permissible
|
||||
}
|
||||
switch (internalHasPermission(perms, permission)) {
|
||||
case -1:
|
||||
return false;
|
||||
case 1:
|
||||
return true;
|
||||
}
|
||||
int dotPos = permission.lastIndexOf(".");
|
||||
while (dotPos > -1) {
|
||||
switch (internalHasPermission(perms, permission.substring(0, dotPos + 1) + "*")) {
|
||||
case -1:
|
||||
return false;
|
||||
case 1:
|
||||
return true;
|
||||
}
|
||||
dotPos = permission.lastIndexOf(".", dotPos - 1);
|
||||
}
|
||||
return internalHasPermission(perms, "*") == 1;
|
||||
}
|
||||
|
||||
public boolean hasPermission(String worldName, OfflinePlayer player, String permission) {
|
||||
return hasPermission(player, permission); // no per-world ability to check permissions in dinnerperms
|
||||
}
|
||||
|
||||
public boolean inGroup(OfflinePlayer player, String group) {
|
||||
final Permissible perms = getPermissible(player);
|
||||
if (perms == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final String perm = GROUP_PREFIX + group;
|
||||
return perms.isPermissionSet(perm) && perms.hasPermission(perm);
|
||||
}
|
||||
|
||||
public String[] getGroups(OfflinePlayer player) {
|
||||
Permissible perms = getPermissible(player);
|
||||
if (perms == null) {
|
||||
return new String[0];
|
||||
}
|
||||
List<String> groupNames = new ArrayList<String>();
|
||||
for (PermissionAttachmentInfo permAttach : perms.getEffectivePermissions()) {
|
||||
String perm = permAttach.getPermission();
|
||||
if (!(perm.startsWith(GROUP_PREFIX) && permAttach.getValue())) {
|
||||
continue;
|
||||
}
|
||||
groupNames.add(perm.substring(GROUP_PREFIX.length(), perm.length()));
|
||||
}
|
||||
return groupNames.toArray(new String[groupNames.size()]);
|
||||
}
|
||||
|
||||
public Permissible getPermissible(OfflinePlayer offline) {
|
||||
if (offline == null) return null;
|
||||
Permissible perm = null;
|
||||
if (offline instanceof Permissible) {
|
||||
perm = (Permissible) offline;
|
||||
} else {
|
||||
Player player = offline.getPlayer();
|
||||
if (player != null) perm = player;
|
||||
}
|
||||
return perm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the permission from dinnerperms
|
||||
*
|
||||
* @param perms Permissible to check for
|
||||
* @param permission The permission to check
|
||||
* @return -1 if the permission is explicitly denied, 1 if the permission is allowed,
|
||||
* 0 if the permission is denied by a default.
|
||||
*/
|
||||
public int internalHasPermission(Permissible perms, String permission) {
|
||||
if (perms.isPermissionSet(permission)) {
|
||||
return perms.hasPermission(permission) ? 1 : -1;
|
||||
} else {
|
||||
Permission perm = server.getPluginManager().getPermission(permission);
|
||||
if (perm != null) {
|
||||
return perm.getDefault().getValue(perms.isOp()) ? 1 : 0;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getDetectionMessage() {
|
||||
return "Using the Bukkit Permissions API.";
|
||||
}
|
||||
}
|
@ -1,237 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.wepif;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.sk89q.util.yaml.YAMLProcessor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
|
||||
public class FlatFilePermissionsResolver implements PermissionsResolver {
|
||||
private Map<String, Set<String>> userPermissionsCache;
|
||||
private Set<String> defaultPermissionsCache;
|
||||
private Map<String, Set<String>> userGroups;
|
||||
|
||||
protected File groupFile;
|
||||
protected File userFile;
|
||||
|
||||
public static PermissionsResolver factory(Server server, YAMLProcessor config) {
|
||||
File groups = new File("perms_groups.txt");
|
||||
File users = new File("perms_users.txt");
|
||||
|
||||
if (!groups.exists() || !users.exists()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new FlatFilePermissionsResolver(groups, users);
|
||||
}
|
||||
|
||||
public FlatFilePermissionsResolver() {
|
||||
this(new File("perms_groups.txt"), new File("perms_users.txt"));
|
||||
}
|
||||
|
||||
public FlatFilePermissionsResolver(File groupFile, File userFile) {
|
||||
this.groupFile = groupFile;
|
||||
this.userFile = userFile;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static boolean filesExists() {
|
||||
return (new File("perms_groups.txt")).exists() && (new File("perms_users.txt")).exists();
|
||||
}
|
||||
|
||||
public Map<String, Set<String>> loadGroupPermissions() {
|
||||
Map<String, Set<String>> userGroupPermissions = new HashMap<String, Set<String>>();
|
||||
|
||||
BufferedReader buff = null;
|
||||
|
||||
try {
|
||||
FileReader input = new FileReader(this.groupFile);
|
||||
buff = new BufferedReader(input);
|
||||
|
||||
String line;
|
||||
while ((line = buff.readLine()) != null) {
|
||||
line = line.trim();
|
||||
|
||||
// Blank line
|
||||
if (line.length() == 0) {
|
||||
continue;
|
||||
} else if (line.charAt(0) == ';' || line.charAt(0) == '#') {
|
||||
continue;
|
||||
}
|
||||
|
||||
String[] parts = line.split(":");
|
||||
|
||||
String key = parts[0];
|
||||
|
||||
if (parts.length > 1) {
|
||||
String[] perms = parts[1].split(",");
|
||||
|
||||
Set<String> groupPerms = new HashSet<String>(Arrays.asList(perms));
|
||||
userGroupPermissions.put(key, groupPerms);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (buff != null) {
|
||||
buff.close();
|
||||
}
|
||||
} catch (IOException e2) {
|
||||
}
|
||||
}
|
||||
|
||||
return userGroupPermissions;
|
||||
}
|
||||
|
||||
public void load() {
|
||||
userGroups = new HashMap<String, Set<String>>();
|
||||
userPermissionsCache = new HashMap<String, Set<String>>();
|
||||
defaultPermissionsCache = new HashSet<String>();
|
||||
|
||||
Map<String, Set<String>> userGroupPermissions = loadGroupPermissions();
|
||||
|
||||
if (userGroupPermissions.containsKey("default")) {
|
||||
defaultPermissionsCache = userGroupPermissions.get("default");
|
||||
}
|
||||
|
||||
BufferedReader buff = null;
|
||||
|
||||
try {
|
||||
FileReader input = new FileReader(this.userFile);
|
||||
buff = new BufferedReader(input);
|
||||
|
||||
String line;
|
||||
while ((line = buff.readLine()) != null) {
|
||||
Set<String> permsCache = new HashSet<String>();
|
||||
|
||||
line = line.trim();
|
||||
|
||||
// Blank line
|
||||
if (line.length() == 0) {
|
||||
continue;
|
||||
} else if (line.charAt(0) == ';' || line.charAt(0) == '#') {
|
||||
continue;
|
||||
}
|
||||
|
||||
String[] parts = line.split(":");
|
||||
|
||||
String key = parts[0];
|
||||
|
||||
if (parts.length > 1) {
|
||||
String[] groups = (parts[1] + ",default").split(",");
|
||||
String[] perms = parts.length > 2 ? parts[2].split(",") : new String[0];
|
||||
|
||||
permsCache.addAll(Arrays.asList(perms));
|
||||
|
||||
for (String group : groups) {
|
||||
Set<String> groupPerms = userGroupPermissions.get(group);
|
||||
if (groupPerms != null) {
|
||||
permsCache.addAll(groupPerms);
|
||||
}
|
||||
}
|
||||
|
||||
userPermissionsCache.put(key.toLowerCase(), permsCache);
|
||||
userGroups.put(key.toLowerCase(), new HashSet<String>(Arrays.asList(groups)));
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (buff != null) {
|
||||
buff.close();
|
||||
}
|
||||
} catch (IOException e2) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasPermission(String player, String permission) {
|
||||
int dotPos = permission.lastIndexOf(".");
|
||||
if (dotPos > -1) {
|
||||
if (hasPermission(player, permission.substring(0, dotPos))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Set<String> perms = userPermissionsCache.get(player.toLowerCase());
|
||||
if (perms == null) {
|
||||
return defaultPermissionsCache.contains(permission)
|
||||
|| defaultPermissionsCache.contains("*");
|
||||
}
|
||||
|
||||
return perms.contains("*") || perms.contains(permission);
|
||||
}
|
||||
|
||||
public boolean hasPermission(String worldName, String player, String permission) {
|
||||
return hasPermission(player, "worlds." + worldName + "." + permission)
|
||||
|| hasPermission(player, permission);
|
||||
}
|
||||
|
||||
public boolean inGroup(String player, String group) {
|
||||
Set<String> groups = userGroups.get(player.toLowerCase());
|
||||
if (groups == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return groups.contains(group);
|
||||
}
|
||||
|
||||
public String[] getGroups(String player) {
|
||||
Set<String> groups = userGroups.get(player.toLowerCase());
|
||||
if (groups == null) {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
return groups.toArray(new String[groups.size()]);
|
||||
}
|
||||
|
||||
public boolean hasPermission(OfflinePlayer player, String permission) {
|
||||
return hasPermission(player.getName(), permission);
|
||||
}
|
||||
|
||||
public boolean hasPermission(String worldName, OfflinePlayer player, String permission) {
|
||||
return hasPermission(worldName, player.getName(), permission);
|
||||
}
|
||||
|
||||
public boolean inGroup(OfflinePlayer player, String group) {
|
||||
return inGroup(player.getName(), group);
|
||||
}
|
||||
|
||||
public String[] getGroups(OfflinePlayer player) {
|
||||
return getGroups(player.getName());
|
||||
}
|
||||
|
||||
public String getDetectionMessage() {
|
||||
return "perms_groups.txt and perms_users.txt detected! Using flat file permissions.";
|
||||
}
|
||||
|
||||
}
|
@ -1,128 +0,0 @@
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.wepif;
|
||||
|
||||
import com.sk89q.util.yaml.YAMLProcessor;
|
||||
import org.anjocaido.groupmanager.dataholder.worlds.WorldsHolder;
|
||||
import org.anjocaido.groupmanager.permissions.AnjoPermissionsHandler;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class GroupManagerResolver implements PermissionsResolver {
|
||||
private final WorldsHolder worldsHolder;
|
||||
private final Server server;
|
||||
|
||||
public static PermissionsResolver factory(Server server, YAMLProcessor config) {
|
||||
try {
|
||||
WorldsHolder worldsHolder = server.getServicesManager().load(WorldsHolder.class);
|
||||
|
||||
if (worldsHolder == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new GroupManagerResolver(server, worldsHolder);
|
||||
} catch (Throwable t) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public GroupManagerResolver(Server server, WorldsHolder worldsHolder) {
|
||||
this.server = server;
|
||||
this.worldsHolder = worldsHolder;
|
||||
}
|
||||
|
||||
public void load() {
|
||||
|
||||
}
|
||||
|
||||
private AnjoPermissionsHandler getPermissionHandler(String name, String worldName) {
|
||||
if (name == null || name.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
if (worldName == null || worldName.isEmpty()) {
|
||||
Player player = server.getPlayerExact(name);
|
||||
if (player == null) {
|
||||
return null;
|
||||
}
|
||||
World world = player.getWorld();
|
||||
if (world == null) {
|
||||
return worldsHolder.getDefaultWorld().getPermissionsHandler();
|
||||
}
|
||||
return worldsHolder.getWorldPermissions(world.getName());
|
||||
} else {
|
||||
return worldsHolder.getWorldPermissions(worldName);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasPermission(String name, String permission) {
|
||||
return hasPermission(null, name, permission);
|
||||
}
|
||||
|
||||
public boolean hasPermission(String worldName, String name, String permission) {
|
||||
if (permission == null || permission.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
AnjoPermissionsHandler permissionHandler = getPermissionHandler(name, worldName);
|
||||
if (permissionHandler == null) {
|
||||
return false;
|
||||
}
|
||||
return permissionHandler.permission(name, permission);
|
||||
}
|
||||
|
||||
public boolean inGroup(String name, String group) {
|
||||
if (group == null || group.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
AnjoPermissionsHandler permissionHandler = getPermissionHandler(name, null);
|
||||
if (permissionHandler == null) {
|
||||
return false;
|
||||
}
|
||||
return permissionHandler.inGroup(name, group);
|
||||
}
|
||||
|
||||
public String[] getGroups(String name) {
|
||||
AnjoPermissionsHandler permissionHandler = getPermissionHandler(name, null);
|
||||
if (permissionHandler == null) {
|
||||
return new String[0];
|
||||
}
|
||||
return permissionHandler.getGroups(name);
|
||||
}
|
||||
|
||||
public boolean hasPermission(OfflinePlayer player, String permission) {
|
||||
return hasPermission(player.getName(), permission);
|
||||
}
|
||||
|
||||
public boolean hasPermission(String worldName, OfflinePlayer player, String permission) {
|
||||
return hasPermission(worldName, player.getName(), permission);
|
||||
}
|
||||
|
||||
public boolean inGroup(OfflinePlayer player, String group) {
|
||||
return inGroup(player.getName(), group);
|
||||
}
|
||||
|
||||
public String[] getGroups(OfflinePlayer player) {
|
||||
return getGroups(player.getName());
|
||||
}
|
||||
|
||||
public String getDetectionMessage() {
|
||||
return "GroupManager detected! Using GroupManager for permissions.";
|
||||
}
|
||||
}
|
@ -1,161 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.wepif;
|
||||
|
||||
import com.sk89q.util.yaml.YAMLProcessor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||
|
||||
public class NijiPermissionsResolver implements PermissionsResolver {
|
||||
private Server server;
|
||||
private Permissions api;
|
||||
|
||||
public static PermissionsResolver factory(Server server, YAMLProcessor config) {
|
||||
PluginManager pluginManager = server.getPluginManager();
|
||||
try {
|
||||
Class.forName("com.nijikokun.bukkit.Permissions.Permissions");
|
||||
} catch (ClassNotFoundException e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Plugin plugin = pluginManager.getPlugin("Permissions");
|
||||
|
||||
// Check if plugin is loaded and has Permissions interface
|
||||
if (plugin == null || !(plugin instanceof Permissions)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Check for fake permissions
|
||||
if (config.getBoolean("ignore-nijiperms-bridges", true) && isFakeNijiPerms(plugin)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new NijiPermissionsResolver(server, (Permissions) plugin);
|
||||
}
|
||||
|
||||
public void load() {
|
||||
|
||||
}
|
||||
|
||||
public NijiPermissionsResolver(Server server, Permissions plugin) {
|
||||
this.server = server;
|
||||
this.api = plugin;
|
||||
}
|
||||
|
||||
@SuppressWarnings("static-access")
|
||||
public boolean hasPermission(String name, String permission) {
|
||||
try {
|
||||
Player player = server.getPlayerExact(name);
|
||||
if (player == null) return false;
|
||||
try {
|
||||
return api.getHandler().has(player, permission);
|
||||
} catch (Throwable t) {
|
||||
return api.Security.permission(player, permission);
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasPermission(String worldName, String name, String permission) {
|
||||
try {
|
||||
try {
|
||||
return api.getHandler().has(worldName, name, permission);
|
||||
} catch (Throwable t) {
|
||||
return api.getHandler().has(server.getPlayerExact(name), permission);
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("static-access")
|
||||
public boolean inGroup(String name, String group) {
|
||||
try {
|
||||
Player player = server.getPlayerExact(name);
|
||||
if (player == null) return false;
|
||||
try {
|
||||
return api.getHandler().inGroup(player.getWorld().getName(), name, group);
|
||||
} catch (Throwable t) {
|
||||
return api.Security.inGroup(name, group);
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("static-access")
|
||||
public String[] getGroups(String name) {
|
||||
try {
|
||||
Player player = server.getPlayerExact(name);
|
||||
if (player == null) return new String[0];
|
||||
String[] groups = null;
|
||||
try {
|
||||
groups = api.getHandler().getGroups(player.getWorld().getName(), player.getName());
|
||||
} catch (Throwable t) {
|
||||
String group = api.Security.getGroup(player.getWorld().getName(), player.getName());
|
||||
if (group != null) groups = new String[] { group };
|
||||
}
|
||||
if (groups == null) {
|
||||
return new String[0];
|
||||
} else {
|
||||
return groups;
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasPermission(OfflinePlayer player, String permission) {
|
||||
return hasPermission(player.getName(), permission);
|
||||
}
|
||||
|
||||
public boolean hasPermission(String worldName, OfflinePlayer player, String permission) {
|
||||
return hasPermission(worldName, player.getName(), permission);
|
||||
}
|
||||
|
||||
public boolean inGroup(OfflinePlayer player, String group) {
|
||||
return inGroup(player.getName(), group);
|
||||
}
|
||||
|
||||
public String[] getGroups(OfflinePlayer player) {
|
||||
return getGroups(player.getName());
|
||||
}
|
||||
|
||||
public static boolean isFakeNijiPerms(Plugin plugin) {
|
||||
PluginCommand permsCommand = Bukkit.getServer().getPluginCommand("permissions");
|
||||
|
||||
return permsCommand == null || !(permsCommand.getPlugin().equals(plugin));
|
||||
}
|
||||
|
||||
public String getDetectionMessage() {
|
||||
return "Permissions plugin detected! Using Permissions plugin for permissions.";
|
||||
}
|
||||
}
|
@ -1,87 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.wepif;
|
||||
|
||||
import com.sk89q.util.yaml.YAMLProcessor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.permissions.Permissible;
|
||||
import ru.tehkode.permissions.PermissionManager;
|
||||
import ru.tehkode.permissions.PermissionUser;
|
||||
|
||||
public class PermissionsExResolver extends DinnerPermsResolver {
|
||||
private final PermissionManager manager;
|
||||
|
||||
public static PermissionsResolver factory(Server server, YAMLProcessor config) {
|
||||
try {
|
||||
PermissionManager manager = server.getServicesManager().load(PermissionManager.class);
|
||||
|
||||
if (manager == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new PermissionsExResolver(server, manager);
|
||||
} catch (Throwable t) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public PermissionsExResolver(Server server, PermissionManager manager) {
|
||||
super(server);
|
||||
this.manager = manager;
|
||||
}
|
||||
|
||||
public boolean hasPermission(String worldName, String name, String permission) {
|
||||
return manager.has(name, permission, worldName);
|
||||
}
|
||||
|
||||
public boolean hasPermission(OfflinePlayer player, String permission) {
|
||||
Permissible permissible = getPermissible(player);
|
||||
if (permissible == null) {
|
||||
return manager.has(player.getName(), permission, null);
|
||||
} else {
|
||||
return permissible.hasPermission(permission);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasPermission(String worldName, OfflinePlayer player, String permission) {
|
||||
return hasPermission(worldName, player.getName(), permission);
|
||||
}
|
||||
|
||||
public boolean inGroup(OfflinePlayer player, String group) {
|
||||
return super.inGroup(player, group) || manager.getUser(player.getName()).inGroup(group);
|
||||
}
|
||||
|
||||
public String[] getGroups(OfflinePlayer player) {
|
||||
if (getPermissible(player) == null) {
|
||||
PermissionUser user = manager.getUser(player.getName());
|
||||
if (user == null) {
|
||||
return new String[0];
|
||||
}
|
||||
return user.getGroupsNames();
|
||||
} else {
|
||||
return super.getGroups(player);
|
||||
}
|
||||
}
|
||||
|
||||
public String getDetectionMessage() {
|
||||
return "PermissionsEx detected! Using PermissionsEx for permissions.";
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.wepif;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
public interface PermissionsProvider {
|
||||
public boolean hasPermission(String name, String permission);
|
||||
|
||||
public boolean hasPermission(String worldName, String name, String permission);
|
||||
|
||||
public boolean inGroup(String player, String group);
|
||||
|
||||
public String[] getGroups(String player);
|
||||
|
||||
public boolean hasPermission(OfflinePlayer player, String permission);
|
||||
|
||||
public boolean hasPermission(String worldName, OfflinePlayer player, String permission);
|
||||
|
||||
public boolean inGroup(OfflinePlayer player, String group);
|
||||
|
||||
public String[] getGroups(OfflinePlayer player);
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.wepif;
|
||||
|
||||
public interface PermissionsResolver extends PermissionsProvider {
|
||||
public void load();
|
||||
|
||||
public String getDetectionMessage();
|
||||
}
|
@ -1,298 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.wepif;
|
||||
|
||||
import com.sk89q.util.yaml.YAMLFormat;
|
||||
import com.sk89q.util.yaml.YAMLProcessor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class PermissionsResolverManager implements PermissionsResolver {
|
||||
private static final String CONFIG_HEADER = "#\r\n" +
|
||||
"# WEPIF Configuration File\r\n" +
|
||||
"#\r\n" +
|
||||
"# This file handles permissions configuration for every plugin using WEPIF\r\n" +
|
||||
"#\r\n" +
|
||||
"# About editing this file:\r\n" +
|
||||
"# - DO NOT USE TABS. You MUST use spaces or Bukkit will complain. If\r\n" +
|
||||
"# you use an editor like Notepad++ (recommended for Windows users), you\r\n" +
|
||||
"# must configure it to \"replace tabs with spaces.\" In Notepad++, this can\r\n" +
|
||||
"# be changed in Settings > Preferences > Language Menu.\r\n" +
|
||||
"# - Don't get rid of the indents. They are indented so some entries are\r\n" +
|
||||
"# in categories (like \"enforce-single-session\" is in the \"protection\"\r\n" +
|
||||
"# category.\r\n" +
|
||||
"# - If you want to check the format of this file before putting it\r\n" +
|
||||
"# into WEPIF, paste it into http://yaml-online-parser.appspot.com/\r\n" +
|
||||
"# and see if it gives \"ERROR:\".\r\n" +
|
||||
"# - Lines starting with # are comments and so they are ignored.\r\n" +
|
||||
"#\r\n" +
|
||||
"# About Configuration Permissions\r\n" +
|
||||
"# - See http://wiki.sk89q.com/wiki/WorldEdit/Permissions/Bukkit\r\n" +
|
||||
"# - Now with multiworld support (see example)\r\n" +
|
||||
"\r\n";
|
||||
|
||||
private static PermissionsResolverManager instance;
|
||||
|
||||
public static void initialize(Plugin plugin) {
|
||||
if (!isInitialized()) {
|
||||
instance = new PermissionsResolverManager(plugin);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isInitialized() {
|
||||
return instance != null;
|
||||
}
|
||||
|
||||
public static PermissionsResolverManager getInstance() {
|
||||
if (!isInitialized()) {
|
||||
throw new WEPIFRuntimeException("WEPIF has not yet been initialized!");
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private Server server;
|
||||
private PermissionsResolver permissionResolver;
|
||||
private YAMLProcessor config;
|
||||
private Logger logger = Logger.getLogger(getClass().getCanonicalName());
|
||||
private List<Class<? extends PermissionsResolver>> enabledResolvers = new ArrayList<Class<? extends PermissionsResolver>>();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected Class<? extends PermissionsResolver>[] availableResolvers = new Class[] {
|
||||
PluginPermissionsResolver.class,
|
||||
PermissionsExResolver.class,
|
||||
bPermissionsResolver.class,
|
||||
GroupManagerResolver.class,
|
||||
NijiPermissionsResolver.class,
|
||||
DinnerPermsResolver.class,
|
||||
FlatFilePermissionsResolver.class
|
||||
};
|
||||
|
||||
protected PermissionsResolverManager(Plugin plugin) {
|
||||
this.server = plugin.getServer();
|
||||
(new ServerListener()).register(plugin); // Register the events
|
||||
|
||||
loadConfig(new File("wepif.yml"));
|
||||
findResolver();
|
||||
}
|
||||
|
||||
public void findResolver() {
|
||||
for (Class<? extends PermissionsResolver> resolverClass : enabledResolvers) {
|
||||
try {
|
||||
Method factoryMethod = resolverClass.getMethod("factory", Server.class, YAMLProcessor.class);
|
||||
|
||||
this.permissionResolver = (PermissionsResolver) factoryMethod.invoke(null, this.server, this.config);
|
||||
|
||||
if (this.permissionResolver != null) {
|
||||
break;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
logger.warning("Error in factory method for " + resolverClass.getSimpleName() + ": " + e);
|
||||
e.printStackTrace();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (permissionResolver == null) {
|
||||
permissionResolver = new ConfigurationPermissionsResolver(config);
|
||||
}
|
||||
permissionResolver.load();
|
||||
logger.info("WEPIF: " + permissionResolver.getDetectionMessage());
|
||||
}
|
||||
|
||||
public void setPluginPermissionsResolver(Plugin plugin) {
|
||||
if (!(plugin instanceof PermissionsProvider)) {
|
||||
return;
|
||||
}
|
||||
|
||||
permissionResolver = new PluginPermissionsResolver((PermissionsProvider) plugin, plugin);
|
||||
logger.info("WEPIF: " + permissionResolver.getDetectionMessage());
|
||||
}
|
||||
|
||||
public void load() {
|
||||
findResolver();
|
||||
}
|
||||
|
||||
public boolean hasPermission(String name, String permission) {
|
||||
return permissionResolver.hasPermission(name, permission);
|
||||
}
|
||||
|
||||
public boolean hasPermission(String worldName, String name, String permission) {
|
||||
return permissionResolver.hasPermission(worldName, name, permission);
|
||||
}
|
||||
|
||||
public boolean inGroup(String player, String group) {
|
||||
return permissionResolver.inGroup(player, group);
|
||||
}
|
||||
|
||||
public String[] getGroups(String player) {
|
||||
return permissionResolver.getGroups(player);
|
||||
}
|
||||
|
||||
public boolean hasPermission(OfflinePlayer player, String permission) {
|
||||
return permissionResolver.hasPermission(player, permission);
|
||||
}
|
||||
|
||||
public boolean hasPermission(String worldName, OfflinePlayer player, String permission) {
|
||||
return permissionResolver.hasPermission(worldName, player, permission);
|
||||
}
|
||||
|
||||
public boolean inGroup(OfflinePlayer player, String group) {
|
||||
return permissionResolver.inGroup(player, group);
|
||||
}
|
||||
|
||||
public String[] getGroups(OfflinePlayer player) {
|
||||
return permissionResolver.getGroups(player);
|
||||
}
|
||||
|
||||
public String getDetectionMessage() {
|
||||
return "Using WEPIF for permissions";
|
||||
}
|
||||
|
||||
private boolean loadConfig(File file) {
|
||||
boolean isUpdated = false;
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
file.createNewFile();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
config = new YAMLProcessor(file, false, YAMLFormat.EXTENDED);
|
||||
try {
|
||||
config.load();
|
||||
} catch (IOException e) {
|
||||
logger.severe("Error loading WEPIF Config: " + e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
List<String> keys = config.getKeys(null);
|
||||
config.setHeader(CONFIG_HEADER);
|
||||
|
||||
if (!keys.contains("ignore-nijiperms-bridges")) {
|
||||
config.setProperty("ignore-nijiperms-bridges", true);
|
||||
isUpdated = true;
|
||||
}
|
||||
|
||||
if (!keys.contains("resolvers")) {
|
||||
//List<String> resolverKeys = config.getKeys("resolvers");
|
||||
List<String> resolvers = new ArrayList<String>();
|
||||
for (Class<?> clazz : availableResolvers) {
|
||||
resolvers.add(clazz.getSimpleName());
|
||||
}
|
||||
enabledResolvers.addAll(Arrays.asList(availableResolvers));
|
||||
config.setProperty("resolvers.enabled", resolvers);
|
||||
isUpdated = true;
|
||||
} else {
|
||||
List<String> disabledResolvers = config.getStringList("resolvers.disabled", new ArrayList<String>());
|
||||
List<String> stagedEnabled = config.getStringList("resolvers.enabled", null);
|
||||
for (Iterator<String> i = stagedEnabled.iterator(); i.hasNext();) {
|
||||
String nextName = i.next();
|
||||
Class<?> next = null;
|
||||
try {
|
||||
next = Class.forName(getClass().getPackage().getName() + "." + nextName);
|
||||
} catch (ClassNotFoundException e) {}
|
||||
|
||||
if (next == null || !PermissionsResolver.class.isAssignableFrom(next)) {
|
||||
logger.warning("WEPIF: Invalid or unknown class found in enabled resolvers: "
|
||||
+ nextName + ". Moving to disabled resolvers list.");
|
||||
i.remove();
|
||||
disabledResolvers.add(nextName);
|
||||
isUpdated = true;
|
||||
continue;
|
||||
}
|
||||
enabledResolvers.add(next.asSubclass(PermissionsResolver.class));
|
||||
}
|
||||
|
||||
for (Class<?> clazz : availableResolvers) {
|
||||
if (!stagedEnabled.contains(clazz.getSimpleName()) &&
|
||||
!disabledResolvers.contains(clazz.getSimpleName())) {
|
||||
disabledResolvers.add(clazz.getSimpleName());
|
||||
logger.info("New permissions resolver: "
|
||||
+ clazz.getSimpleName() + " detected. " +
|
||||
"Added to disabled resolvers list.");
|
||||
isUpdated = true;
|
||||
}
|
||||
}
|
||||
config.setProperty("resolvers.disabled", disabledResolvers);
|
||||
config.setProperty("resolvers.enabled", stagedEnabled);
|
||||
}
|
||||
|
||||
if (keys.contains("dinner-perms") || keys.contains("dinnerperms")) {
|
||||
config.removeProperty("dinner-perms");
|
||||
config.removeProperty("dinnerperms");
|
||||
isUpdated = true;
|
||||
}
|
||||
if (!keys.contains("permissions")) {
|
||||
ConfigurationPermissionsResolver.generateDefaultPerms(
|
||||
config.addNode("permissions"));
|
||||
isUpdated = true;
|
||||
}
|
||||
if (isUpdated) {
|
||||
logger.info("WEPIF: Updated config file");
|
||||
config.save();
|
||||
}
|
||||
return isUpdated;
|
||||
}
|
||||
|
||||
public static class MissingPluginException extends Exception {
|
||||
private static final long serialVersionUID = 7044832912491608706L;
|
||||
}
|
||||
|
||||
class ServerListener implements org.bukkit.event.Listener {
|
||||
@EventHandler
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
Plugin plugin = event.getPlugin();
|
||||
String name = plugin.getDescription().getName();
|
||||
if (plugin instanceof PermissionsProvider) {
|
||||
setPluginPermissionsResolver(plugin);
|
||||
} else if ("permissions".equalsIgnoreCase(name) || "permissionsex".equalsIgnoreCase(name)
|
||||
|| "bpermissions".equalsIgnoreCase(name) || "groupmanager".equalsIgnoreCase(name)) {
|
||||
load();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
String name = event.getPlugin().getDescription().getName();
|
||||
|
||||
if (event.getPlugin() instanceof PermissionsProvider
|
||||
|| "permissions".equalsIgnoreCase(name) || "permissionsex".equalsIgnoreCase(name)
|
||||
|| "bpermissions".equalsIgnoreCase(name) || "groupmanager".equalsIgnoreCase(name)) {
|
||||
load();
|
||||
}
|
||||
}
|
||||
|
||||
void register(Plugin plugin) {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,95 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.wepif;
|
||||
|
||||
import com.sk89q.util.yaml.YAMLProcessor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
public class PluginPermissionsResolver implements PermissionsResolver {
|
||||
|
||||
protected PermissionsProvider resolver;
|
||||
protected Plugin plugin;
|
||||
|
||||
public static PermissionsResolver factory(Server server, YAMLProcessor config) {
|
||||
// Looking for service
|
||||
RegisteredServiceProvider<PermissionsProvider> serviceProvider = server.getServicesManager().getRegistration(PermissionsProvider.class);
|
||||
|
||||
if (serviceProvider != null) {
|
||||
return new PluginPermissionsResolver(serviceProvider.getProvider(), serviceProvider.getPlugin());
|
||||
}
|
||||
|
||||
// Looking for plugin
|
||||
for (Plugin plugin : server.getPluginManager().getPlugins()) {
|
||||
if (plugin instanceof PermissionsProvider) {
|
||||
return new PluginPermissionsResolver((PermissionsProvider) plugin, plugin);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public PluginPermissionsResolver(PermissionsProvider resolver, Plugin permissionsPlugin) {
|
||||
this.resolver = resolver;
|
||||
this.plugin = permissionsPlugin;
|
||||
}
|
||||
|
||||
public void load() {
|
||||
}
|
||||
|
||||
public boolean hasPermission(String name, String permission) {
|
||||
return resolver.hasPermission(name, permission);
|
||||
}
|
||||
|
||||
public boolean hasPermission(String worldName, String name, String permission) {
|
||||
return resolver.hasPermission(worldName, name, permission);
|
||||
}
|
||||
|
||||
public boolean inGroup(String player, String group) {
|
||||
return resolver.inGroup(player, group);
|
||||
}
|
||||
|
||||
public String[] getGroups(String player) {
|
||||
return resolver.getGroups(player);
|
||||
}
|
||||
|
||||
public boolean hasPermission(OfflinePlayer player, String permission) {
|
||||
return resolver.hasPermission(player, permission);
|
||||
}
|
||||
|
||||
public boolean hasPermission(String worldName, OfflinePlayer player, String permission) {
|
||||
return resolver.hasPermission(worldName, player, permission);
|
||||
}
|
||||
|
||||
public boolean inGroup(OfflinePlayer player, String group) {
|
||||
return resolver.inGroup(player, group);
|
||||
}
|
||||
|
||||
public String[] getGroups(OfflinePlayer player) {
|
||||
return resolver.getGroups(player);
|
||||
}
|
||||
|
||||
public String getDetectionMessage() {
|
||||
return "Using plugin '" + this.plugin.getDescription().getName() + "' for permissions.";
|
||||
}
|
||||
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.wepif;
|
||||
|
||||
/**
|
||||
* @author zml2008
|
||||
*/
|
||||
public class WEPIFRuntimeException extends RuntimeException {
|
||||
private static final long serialVersionUID = 5092745960439109699L;
|
||||
|
||||
public WEPIFRuntimeException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
@ -1,102 +0,0 @@
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2012 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.wepif;
|
||||
|
||||
import com.sk89q.util.yaml.YAMLProcessor;
|
||||
import de.bananaco.bpermissions.api.ApiLayer;
|
||||
import de.bananaco.bpermissions.api.util.CalculableType;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @author zml2008
|
||||
*/
|
||||
public class bPermissionsResolver implements PermissionsResolver {
|
||||
|
||||
public static PermissionsResolver factory(Server server, YAMLProcessor config) {
|
||||
try {
|
||||
Class.forName("de.bananaco.bpermissions.api.ApiLayer");
|
||||
} catch (ClassNotFoundException e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new bPermissionsResolver(server);
|
||||
}
|
||||
|
||||
private final Server server;
|
||||
|
||||
public bPermissionsResolver(Server server) {
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
public void load() {
|
||||
}
|
||||
|
||||
public String getDetectionMessage() {
|
||||
return "bPermissions detected! Using bPermissions for permissions";
|
||||
}
|
||||
|
||||
public boolean hasPermission(String name, String permission) {
|
||||
return hasPermission(server.getOfflinePlayer(name), permission);
|
||||
}
|
||||
|
||||
public boolean hasPermission(String worldName, String name, String permission) {
|
||||
return ApiLayer.hasPermission(worldName, CalculableType.USER, name, permission);
|
||||
}
|
||||
|
||||
public boolean inGroup(String player, String group) {
|
||||
return inGroup(server.getOfflinePlayer(player), group);
|
||||
}
|
||||
|
||||
public String[] getGroups(String player) {
|
||||
return getGroups(server.getOfflinePlayer(player));
|
||||
}
|
||||
|
||||
public boolean hasPermission(OfflinePlayer player, String permission) {
|
||||
Player onlinePlayer = player.getPlayer();
|
||||
if (onlinePlayer == null) {
|
||||
return ApiLayer.hasPermission(null, CalculableType.USER, player.getName(), permission);
|
||||
} else {
|
||||
return ApiLayer.hasPermission(onlinePlayer.getWorld().getName(), CalculableType.USER, player.getName(), permission);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasPermission(String worldName, OfflinePlayer player, String permission) {
|
||||
return hasPermission(worldName, player.getName(), permission);
|
||||
}
|
||||
|
||||
public boolean inGroup(OfflinePlayer player, String group) {
|
||||
Player onlinePlayer = player.getPlayer();
|
||||
if (onlinePlayer == null) {
|
||||
return ApiLayer.hasGroupRecursive(null, CalculableType.USER, player.getName(), group);
|
||||
} else {
|
||||
return ApiLayer.hasGroupRecursive(onlinePlayer.getWorld().getName(), CalculableType.USER, player.getName(), group);
|
||||
}
|
||||
}
|
||||
|
||||
public String[] getGroups(OfflinePlayer player) {
|
||||
Player onlinePlayer = player.getPlayer();
|
||||
if (onlinePlayer == null) {
|
||||
return ApiLayer.getGroups(null, CalculableType.USER, player.getName());
|
||||
} else {
|
||||
return ApiLayer.getGroups(onlinePlayer.getWorld().getName(), CalculableType.USER, player.getName());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,87 +0,0 @@
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import com.sk89q.worldedit.BiomeType;
|
||||
|
||||
public enum BukkitBiomeType implements BiomeType {
|
||||
|
||||
SWAMPLAND(Biome.SWAMPLAND),
|
||||
FOREST(Biome.FOREST),
|
||||
TAIGA(Biome.TAIGA),
|
||||
DESERT(Biome.DESERT),
|
||||
PLAINS(Biome.PLAINS),
|
||||
HELL(Biome.HELL),
|
||||
SKY(Biome.SKY),
|
||||
RIVER(Biome.RIVER),
|
||||
EXTREME_HILLS(Biome.EXTREME_HILLS),
|
||||
OCEAN(Biome.OCEAN),
|
||||
FROZEN_OCEAN(Biome.FROZEN_OCEAN),
|
||||
FROZEN_RIVER(Biome.FROZEN_RIVER),
|
||||
ICE_PLAINS(Biome.ICE_PLAINS),
|
||||
ICE_MOUNTAINS(Biome.ICE_MOUNTAINS),
|
||||
MUSHROOM_ISLAND(Biome.MUSHROOM_ISLAND),
|
||||
MUSHROOM_SHORE(Biome.MUSHROOM_SHORE),
|
||||
BEACH(Biome.BEACH),
|
||||
DESERT_HILLS(Biome.DESERT_HILLS),
|
||||
FOREST_HILLS(Biome.FOREST_HILLS),
|
||||
TAIGA_HILLS(Biome.TAIGA_HILLS),
|
||||
SMALL_MOUNTAINS(Biome.SMALL_MOUNTAINS),
|
||||
JUNGLE(Biome.JUNGLE),
|
||||
JUNGLE_HILLS(Biome.JUNGLE_HILLS),
|
||||
JUNGLE_EDGE(Biome.JUNGLE_EDGE),
|
||||
DEEP_OCEAN(Biome.DEEP_OCEAN),
|
||||
STONE_BEACH(Biome.STONE_BEACH),
|
||||
COLD_BEACH(Biome.COLD_BEACH),
|
||||
BIRCH_FOREST(Biome.BIRCH_FOREST),
|
||||
BIRCH_FOREST_HILLS(Biome.BIRCH_FOREST_HILLS),
|
||||
ROOFED_FOREST(Biome.ROOFED_FOREST),
|
||||
COLD_TAIGA(Biome.COLD_TAIGA),
|
||||
COLD_TAIGA_HILLS(Biome.COLD_TAIGA_HILLS),
|
||||
MEGA_TAIGA(Biome.MEGA_TAIGA),
|
||||
MEGA_TAIGA_HILLS(Biome.MEGA_TAIGA_HILLS),
|
||||
EXTREME_HILLS_PLUS(Biome.EXTREME_HILLS_PLUS),
|
||||
SAVANNA(Biome.SAVANNA),
|
||||
SAVANNA_PLATEAU(Biome.SAVANNA_PLATEAU),
|
||||
MESA(Biome.MESA),
|
||||
MESA_PLATEAU_FOREST(Biome.MESA_PLATEAU_FOREST),
|
||||
MESA_PLATEAU(Biome.MESA_PLATEAU),
|
||||
SUNFLOWER_PLAINS(Biome.SUNFLOWER_PLAINS),
|
||||
DESERT_MOUNTAINS(Biome.DESERT_MOUNTAINS),
|
||||
FLOWER_FOREST(Biome.FLOWER_FOREST),
|
||||
TAIGA_MOUNTAINS(Biome.TAIGA_MOUNTAINS),
|
||||
SWAMPLAND_MOUNTAINS(Biome.SWAMPLAND_MOUNTAINS),
|
||||
ICE_PLAINS_SPIKES(Biome.ICE_PLAINS_SPIKES),
|
||||
JUNGLE_MOUNTAINS(Biome.JUNGLE_MOUNTAINS),
|
||||
JUNGLE_EDGE_MOUNTAINS(Biome.JUNGLE_EDGE_MOUNTAINS),
|
||||
COLD_TAIGA_MOUNTAINS(Biome.COLD_TAIGA_MOUNTAINS),
|
||||
SAVANNA_MOUNTAINS(Biome.SAVANNA_MOUNTAINS),
|
||||
SAVANNA_PLATEAU_MOUNTAINS(Biome.SAVANNA_PLATEAU_MOUNTAINS),
|
||||
MESA_BRYCE(Biome.MESA_BRYCE),
|
||||
MESA_PLATEAU_FOREST_MOUNTAINS(Biome.MESA_PLATEAU_FOREST_MOUNTAINS),
|
||||
MESA_PLATEAU_MOUNTAINS(Biome.MESA_PLATEAU_MOUNTAINS),
|
||||
BIRCH_FOREST_MOUNTAINS(Biome.BIRCH_FOREST_MOUNTAINS),
|
||||
BIRCH_FOREST_HILLS_MOUNTAINS(Biome.BIRCH_FOREST_HILLS_MOUNTAINS),
|
||||
ROOFED_FOREST_MOUNTAINS(Biome.ROOFED_FOREST_MOUNTAINS),
|
||||
MEGA_SPRUCE_TAIGA(Biome.MEGA_SPRUCE_TAIGA),
|
||||
EXTREME_HILLS_MOUNTAINS(Biome.EXTREME_HILLS_MOUNTAINS),
|
||||
EXTREME_HILLS_PLUS_MOUNTAINS(Biome.EXTREME_HILLS_PLUS_MOUNTAINS),
|
||||
MEGA_SPRUCE_TAIGA_HILLS(Biome.MEGA_SPRUCE_TAIGA_HILLS);
|
||||
|
||||
private Biome bukkitBiome;
|
||||
|
||||
private BukkitBiomeType(Biome biome) {
|
||||
this.bukkitBiome = biome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
public Biome getBukkitBiome() {
|
||||
return bukkitBiome;
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.sk89q.worldedit.BiomeType;
|
||||
import com.sk89q.worldedit.BiomeTypes;
|
||||
import com.sk89q.worldedit.UnknownBiomeTypeException;
|
||||
|
||||
public class BukkitBiomeTypes implements BiomeTypes {
|
||||
|
||||
public BukkitBiomeTypes() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String name) {
|
||||
try {
|
||||
BukkitBiomeType.valueOf(name.toUpperCase(Locale.ENGLISH));
|
||||
return true;
|
||||
} catch (IllegalArgumentException exc) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeType get(String name) throws UnknownBiomeTypeException {
|
||||
try {
|
||||
return BukkitBiomeType.valueOf(name.toUpperCase(Locale.ENGLISH));
|
||||
} catch (IllegalArgumentException exc) {
|
||||
throw new UnknownBiomeTypeException(name);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BiomeType> all() {
|
||||
return Arrays.<BiomeType>asList(BukkitBiomeType.values());
|
||||
}
|
||||
|
||||
}
|
@ -1,134 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.worldedit.bukkit;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.PlayerNeededException;
|
||||
import com.sk89q.worldedit.ServerInterface;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldVector;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
|
||||
public class BukkitCommandSender extends LocalPlayer {
|
||||
private CommandSender sender;
|
||||
private WorldEditPlugin plugin;
|
||||
|
||||
public BukkitCommandSender(WorldEditPlugin plugin, ServerInterface server, CommandSender sender) {
|
||||
super(server);
|
||||
this.plugin = plugin;
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return sender.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printRaw(String msg) {
|
||||
for (String part : msg.split("\n")) {
|
||||
sender.sendMessage(part);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(String 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
|
||||
public void printError(String msg) {
|
||||
for (String part : msg.split("\n")) {
|
||||
sender.sendMessage("\u00A7c" + part);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String perm) {
|
||||
if (!plugin.getLocalConfiguration().noOpPermissions && sender.isOp()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return plugin.getPermissionsResolver().hasPermission(null, sender.getName(), perm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayer() {
|
||||
return sender instanceof Player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemInHand() {
|
||||
throw new PlayerNeededException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldVector getPosition() {
|
||||
throw new PlayerNeededException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalWorld getWorld() {
|
||||
throw new PlayerNeededException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPitch() {
|
||||
throw new PlayerNeededException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getYaw() {
|
||||
throw new PlayerNeededException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveItem(int type, int amt) {
|
||||
throw new PlayerNeededException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(Vector pos, float pitch, float yaw) {
|
||||
throw new PlayerNeededException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockBag getInventoryBlockBag() {
|
||||
throw new PlayerNeededException();
|
||||
}
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2011 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.worldedit.bukkit;
|
||||
|
||||
import com.sk89q.util.yaml.YAMLProcessor;
|
||||
import com.sk89q.worldedit.util.YAMLConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* YAMLConfiguration but with setting for no op permissions and plugin root data folder
|
||||
*/
|
||||
public class BukkitConfiguration extends YAMLConfiguration {
|
||||
|
||||
public boolean noOpPermissions = false;
|
||||
private final WorldEditPlugin plugin;
|
||||
|
||||
public BukkitConfiguration(YAMLProcessor config, WorldEditPlugin plugin) {
|
||||
super(config, plugin.getLogger());
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
super.load();
|
||||
noOpPermissions = config.getBoolean("no-op-permissions", false);
|
||||
migrateLegacyFolders();
|
||||
}
|
||||
|
||||
private void migrateLegacyFolders() {
|
||||
migrate(scriptsDir, "craftscripts");
|
||||
migrate(saveDir, "schematics");
|
||||
migrate("drawings", "draw.js images");
|
||||
}
|
||||
|
||||
private void migrate(String file, String name) {
|
||||
File fromDir = new File(".", file);
|
||||
File toDir = new File(getWorkingDirectory(), file);
|
||||
if (fromDir.exists() & !toDir.exists()) {
|
||||
if (fromDir.renameTo(toDir)) {
|
||||
plugin.getLogger().info("Migrated " + name + " folder '" + file +
|
||||
"' from server root to plugin data folder.");
|
||||
} else {
|
||||
plugin.getLogger().warning("Error while migrating " + name + " folder!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getWorkingDirectory() {
|
||||
return plugin.getDataFolder();
|
||||
}
|
||||
}
|
@ -1,171 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.worldedit.bukkit;
|
||||
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.sk89q.util.StringUtil;
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.ServerInterface;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldVector;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
||||
|
||||
public class BukkitPlayer extends LocalPlayer {
|
||||
private Player player;
|
||||
private WorldEditPlugin plugin;
|
||||
|
||||
public BukkitPlayer(WorldEditPlugin plugin, ServerInterface server, Player player) {
|
||||
super(server);
|
||||
this.plugin = plugin;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemInHand() {
|
||||
ItemStack itemStack = player.getItemInHand();
|
||||
return itemStack != null ? itemStack.getTypeId() : 0;
|
||||
}
|
||||
|
||||
public BaseBlock getBlockInHand() throws WorldEditException {
|
||||
ItemStack itemStack = player.getItemInHand();
|
||||
return BukkitUtil.toBlock(getWorld(), itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return player.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldVector getPosition() {
|
||||
Location loc = player.getLocation();
|
||||
return new WorldVector(BukkitUtil.getLocalWorld(loc.getWorld()),
|
||||
loc.getX(), loc.getY(), loc.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPitch() {
|
||||
return player.getLocation().getPitch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getYaw() {
|
||||
return player.getLocation().getYaw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveItem(int type, int amt) {
|
||||
player.getInventory().addItem(new ItemStack(type, amt));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printRaw(String msg) {
|
||||
for (String part : msg.split("\n")) {
|
||||
player.sendMessage(part);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(String msg) {
|
||||
for (String part : msg.split("\n")) {
|
||||
player.sendMessage("\u00A7d" + part);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printDebug(String msg) {
|
||||
for (String part : msg.split("\n")) {
|
||||
player.sendMessage("\u00A77" + part);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printError(String msg) {
|
||||
for (String part : msg.split("\n")) {
|
||||
player.sendMessage("\u00A7c" + part);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(Vector pos, float pitch, float yaw) {
|
||||
player.teleport(new Location(player.getWorld(), pos.getX(), pos.getY(),
|
||||
pos.getZ(), yaw, pitch));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
return plugin.getPermissionsResolver().getGroups(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockBag getInventoryBlockBag() {
|
||||
return new BukkitPlayerBlockBag(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String perm) {
|
||||
return (!plugin.getLocalConfiguration().noOpPermissions && player.isOp())
|
||||
|| plugin.getPermissionsResolver().hasPermission(
|
||||
player.getWorld().getName(), player, perm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalWorld getWorld() {
|
||||
return BukkitUtil.getLocalWorld(player.getWorld());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispatchCUIEvent(CUIEvent event) {
|
||||
String[] params = event.getParameters();
|
||||
String send = event.getTypeId();
|
||||
if (params.length > 0) {
|
||||
send = send + "|" + StringUtil.joinString(params, "|");
|
||||
}
|
||||
player.sendPluginMessage(plugin, WorldEditPlugin.CUI_PLUGIN_CHANNEL, send.getBytes(CUIChannelListener.UTF_8_CHARSET));
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCreativeMode() {
|
||||
return player.getGameMode() == GameMode.CREATIVE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void floatAt(int x, int y, int z, boolean alwaysGlass) {
|
||||
if (alwaysGlass || !player.getAllowFlight()) {
|
||||
super.floatAt(x, y, z, alwaysGlass);
|
||||
return;
|
||||
}
|
||||
|
||||
setPosition(new Vector(x + 0.5, y, z + 0.5));
|
||||
player.setFlying(true);
|
||||
}
|
||||
}
|
@ -1,228 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.worldedit.bukkit;
|
||||
|
||||
import com.sk89q.worldedit.WorldVector;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import com.sk89q.worldedit.extent.inventory.*;
|
||||
import com.sk89q.worldedit.blocks.BaseItem;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import com.sk89q.worldedit.blocks.ItemType;
|
||||
|
||||
public class BukkitPlayerBlockBag extends BlockBag {
|
||||
/**
|
||||
* Player instance.
|
||||
*/
|
||||
private Player player;
|
||||
/**
|
||||
* The player's inventory;
|
||||
*/
|
||||
private ItemStack[] items;
|
||||
|
||||
/**
|
||||
* Construct the object.
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
public BukkitPlayerBlockBag(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads inventory on first use.
|
||||
*/
|
||||
private void loadInventory() {
|
||||
if (items == null) {
|
||||
items = player.getInventory().getContents();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the player.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a block.
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
@Override
|
||||
public void fetchItem(BaseItem item) throws BlockBagException {
|
||||
final int id = item.getType();
|
||||
final int damage = item.getData();
|
||||
int amount = (item instanceof BaseItemStack) ? ((BaseItemStack) item).getAmount() : 1;
|
||||
assert(amount == 1);
|
||||
boolean usesDamageValue = ItemType.usesDamageValue(id);
|
||||
|
||||
if (id == BlockID.AIR) {
|
||||
throw new IllegalArgumentException("Can't fetch air block");
|
||||
}
|
||||
|
||||
loadInventory();
|
||||
|
||||
boolean found = false;
|
||||
|
||||
for (int slot = 0; slot < items.length; ++slot) {
|
||||
ItemStack bukkitItem = items[slot];
|
||||
|
||||
if (bukkitItem == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (bukkitItem.getTypeId() != id) {
|
||||
// Type id doesn't fit
|
||||
continue;
|
||||
}
|
||||
|
||||
if (usesDamageValue && bukkitItem.getDurability() != damage) {
|
||||
// Damage value doesn't fit.
|
||||
continue;
|
||||
}
|
||||
|
||||
int currentAmount = bukkitItem.getAmount();
|
||||
if (currentAmount < 0) {
|
||||
// Unlimited
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentAmount > 1) {
|
||||
bukkitItem.setAmount(currentAmount - 1);
|
||||
found = true;
|
||||
} else {
|
||||
items[slot] = null;
|
||||
found = true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
throw new OutOfBlocksException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a block.
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
@Override
|
||||
public void storeItem(BaseItem item) throws BlockBagException {
|
||||
final int id = item.getType();
|
||||
final int damage = item.getData();
|
||||
int amount = (item instanceof BaseItemStack) ? ((BaseItemStack) item).getAmount() : 1;
|
||||
assert(amount <= 64);
|
||||
boolean usesDamageValue = ItemType.usesDamageValue(id);
|
||||
|
||||
if (id == BlockID.AIR) {
|
||||
throw new IllegalArgumentException("Can't store air block");
|
||||
}
|
||||
|
||||
loadInventory();
|
||||
|
||||
int freeSlot = -1;
|
||||
|
||||
for (int slot = 0; slot < items.length; ++slot) {
|
||||
ItemStack bukkitItem = items[slot];
|
||||
|
||||
if (bukkitItem == null) {
|
||||
// Delay using up a free slot until we know there are no stacks
|
||||
// of this item to merge into
|
||||
|
||||
if (freeSlot == -1) {
|
||||
freeSlot = slot;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (bukkitItem.getTypeId() != id) {
|
||||
// Type id doesn't fit
|
||||
continue;
|
||||
}
|
||||
|
||||
if (usesDamageValue && bukkitItem.getDurability() != damage) {
|
||||
// Damage value doesn't fit.
|
||||
continue;
|
||||
}
|
||||
|
||||
int currentAmount = bukkitItem.getAmount();
|
||||
if (currentAmount < 0) {
|
||||
// Unlimited
|
||||
return;
|
||||
}
|
||||
if (currentAmount >= 64) {
|
||||
// Full stack
|
||||
continue;
|
||||
}
|
||||
|
||||
int spaceLeft = 64 - currentAmount;
|
||||
if (spaceLeft >= amount) {
|
||||
bukkitItem.setAmount(currentAmount + amount);
|
||||
return;
|
||||
}
|
||||
|
||||
bukkitItem.setAmount(64);
|
||||
amount -= spaceLeft;
|
||||
}
|
||||
|
||||
if (freeSlot > -1) {
|
||||
items[freeSlot] = new ItemStack(id, amount);
|
||||
return;
|
||||
}
|
||||
|
||||
throw new OutOfSpaceException(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush any changes. This is called at the end.
|
||||
*/
|
||||
@Override
|
||||
public void flushChanges() {
|
||||
if (items != null) {
|
||||
player.getInventory().setContents(items);
|
||||
items = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a position to be used a source.
|
||||
*
|
||||
* @param pos
|
||||
*/
|
||||
@Override
|
||||
public void addSourcePosition(WorldVector pos) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a position to be used a source.
|
||||
*
|
||||
* @param pos
|
||||
*/
|
||||
@Override
|
||||
public void addSingleSourcePosition(WorldVector pos) {
|
||||
}
|
||||
}
|
@ -1,125 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.worldedit.bukkit;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sk89q.bukkit.util.CommandInfo;
|
||||
import com.sk89q.bukkit.util.CommandRegistration;
|
||||
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 org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import com.sk89q.worldedit.BiomeTypes;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.ServerInterface;
|
||||
|
||||
public class BukkitServerInterface extends ServerInterface {
|
||||
public Server server;
|
||||
public WorldEditPlugin plugin;
|
||||
private CommandRegistration dynamicCommands;
|
||||
private BukkitBiomeTypes biomes;
|
||||
|
||||
public BukkitServerInterface(WorldEditPlugin plugin, Server server) {
|
||||
this.plugin = plugin;
|
||||
this.server = server;
|
||||
this.biomes = new BukkitBiomeTypes();
|
||||
dynamicCommands = new CommandRegistration(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int resolveItem(String name) {
|
||||
Material mat = Material.matchMaterial(name);
|
||||
return mat == null ? 0 : mat.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidMobType(String type) {
|
||||
final EntityType entityType = EntityType.fromName(type);
|
||||
return entityType != null && entityType.isAlive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
plugin.loadConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeTypes getBiomes() {
|
||||
return biomes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int schedule(long delay, long period, Runnable task) {
|
||||
return Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, task, delay, period);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LocalWorld> getWorlds() {
|
||||
List<World> worlds = server.getWorlds();
|
||||
List<LocalWorld> ret = new ArrayList<LocalWorld>(worlds.size());
|
||||
|
||||
for (World world : worlds) {
|
||||
ret.add(BukkitUtil.getLocalWorld(world));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandRegistration(List<Command> commands, CommandsManager<LocalPlayer> manager) {
|
||||
List<CommandInfo> toRegister = new ArrayList<CommandInfo>();
|
||||
for (Command command : commands) {
|
||||
List<String> permissions = null;
|
||||
Method cmdMethod = manager.getMethods().get(null).get(command.aliases()[0]);
|
||||
Map<String, Method> childMethods = manager.getMethods().get(cmdMethod);
|
||||
|
||||
if (cmdMethod != null && cmdMethod.isAnnotationPresent(CommandPermissions.class)) {
|
||||
permissions = Arrays.asList(cmdMethod.getAnnotation(CommandPermissions.class).value());
|
||||
} else if (cmdMethod != null && childMethods != null && childMethods.size() > 0) {
|
||||
permissions = new ArrayList<String>();
|
||||
for (Method m : childMethods.values()) {
|
||||
if (m.isAnnotationPresent(CommandPermissions.class)) {
|
||||
permissions.addAll(Arrays.asList(m.getAnnotation(CommandPermissions.class).value()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
toRegister.add(new CommandInfo(command.usage(), command.desc(), command.aliases(), commands, permissions == null ? null : permissions.toArray(new String[permissions.size()])));
|
||||
}
|
||||
|
||||
dynamicCommands.register(toRegister);
|
||||
}
|
||||
|
||||
public void unregisterCommands() {
|
||||
dynamicCommands.unregisterCommands();
|
||||
}
|
||||
}
|
@ -1,195 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.worldedit.bukkit;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.sk89q.worldedit.NotABlockException;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import com.sk89q.worldedit.blocks.BlockType;
|
||||
import com.sk89q.worldedit.blocks.ItemID;
|
||||
import com.sk89q.worldedit.blocks.SkullBlock;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.ExperienceOrb;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Painting;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.BlockWorldVector;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.Location;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldVector;
|
||||
import com.sk89q.worldedit.bukkit.entity.BukkitEntity;
|
||||
import com.sk89q.worldedit.bukkit.entity.BukkitExpOrb;
|
||||
import com.sk89q.worldedit.bukkit.entity.BukkitItem;
|
||||
import com.sk89q.worldedit.bukkit.entity.BukkitPainting;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.Dye;
|
||||
|
||||
public class BukkitUtil {
|
||||
private BukkitUtil() {
|
||||
}
|
||||
|
||||
public static LocalWorld getLocalWorld(World w) {
|
||||
return new BukkitWorld(w);
|
||||
}
|
||||
|
||||
public static BlockVector toVector(Block block) {
|
||||
return new BlockVector(block.getX(), block.getY(), block.getZ());
|
||||
}
|
||||
|
||||
public static BlockVector toVector(BlockFace face) {
|
||||
return new BlockVector(face.getModX(), face.getModY(), face.getModZ());
|
||||
}
|
||||
|
||||
public static BlockWorldVector toWorldVector(Block block) {
|
||||
return new BlockWorldVector(getLocalWorld(block.getWorld()), block.getX(), block.getY(), block.getZ());
|
||||
}
|
||||
|
||||
public static Vector toVector(org.bukkit.Location loc) {
|
||||
return new Vector(loc.getX(), loc.getY(), loc.getZ());
|
||||
}
|
||||
|
||||
public static Location toLocation(org.bukkit.Location loc) {
|
||||
return new Location(
|
||||
getLocalWorld(loc.getWorld()),
|
||||
new Vector(loc.getX(), loc.getY(), loc.getZ()),
|
||||
loc.getYaw(), loc.getPitch()
|
||||
);
|
||||
}
|
||||
|
||||
public static Vector toVector(org.bukkit.util.Vector vector) {
|
||||
return new Vector(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
|
||||
public static org.bukkit.Location toLocation(WorldVector pt) {
|
||||
return new org.bukkit.Location(toWorld(pt), pt.getX(), pt.getY(), pt.getZ());
|
||||
}
|
||||
|
||||
public static org.bukkit.Location toLocation(World world, Vector pt) {
|
||||
return new org.bukkit.Location(world, pt.getX(), pt.getY(), pt.getZ());
|
||||
}
|
||||
|
||||
public static org.bukkit.Location center(org.bukkit.Location loc) {
|
||||
return new org.bukkit.Location(
|
||||
loc.getWorld(),
|
||||
loc.getBlockX() + 0.5,
|
||||
loc.getBlockY() + 0.5,
|
||||
loc.getBlockZ() + 0.5,
|
||||
loc.getPitch(),
|
||||
loc.getYaw()
|
||||
);
|
||||
}
|
||||
|
||||
public static Player matchSinglePlayer(Server server, String name) {
|
||||
List<Player> players = server.matchPlayer(name);
|
||||
if (players.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
return players.get(0);
|
||||
}
|
||||
|
||||
public static Block toBlock(BlockWorldVector pt) {
|
||||
return toWorld(pt).getBlockAt(toLocation(pt));
|
||||
}
|
||||
|
||||
public static World toWorld(WorldVector pt) {
|
||||
return ((BukkitWorld) pt.getWorld()).getWorld();
|
||||
}
|
||||
|
||||
/**
|
||||
* Bukkit's Location class has serious problems with floating point
|
||||
* precision.
|
||||
*/
|
||||
@SuppressWarnings("RedundantIfStatement")
|
||||
public static boolean equals(org.bukkit.Location a, org.bukkit.Location b) {
|
||||
if (Math.abs(a.getX() - b.getX()) > EQUALS_PRECISION) return false;
|
||||
if (Math.abs(a.getY() - b.getY()) > EQUALS_PRECISION) return false;
|
||||
if (Math.abs(a.getZ() - b.getZ()) > EQUALS_PRECISION) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static final double EQUALS_PRECISION = 0.0001;
|
||||
|
||||
public static org.bukkit.Location toLocation(Location location) {
|
||||
Vector pt = location.getPosition();
|
||||
return new org.bukkit.Location(
|
||||
toWorld(location.getWorld()),
|
||||
pt.getX(), pt.getY(), pt.getZ(),
|
||||
location.getYaw(), location.getPitch()
|
||||
);
|
||||
}
|
||||
|
||||
public static World toWorld(final LocalWorld world) {
|
||||
return ((BukkitWorld) world).getWorld();
|
||||
}
|
||||
|
||||
public static BukkitEntity toLocalEntity(Entity e) {
|
||||
switch (e.getType()) {
|
||||
case EXPERIENCE_ORB:
|
||||
return new BukkitExpOrb(toLocation(e.getLocation()), e.getUniqueId(), ((ExperienceOrb)e).getExperience());
|
||||
case PAINTING:
|
||||
Painting paint = (Painting) e;
|
||||
return new BukkitPainting(toLocation(e.getLocation()), paint.getArt(), paint.getFacing(), e.getUniqueId());
|
||||
case DROPPED_ITEM:
|
||||
return new BukkitItem(toLocation(e.getLocation()), ((Item)e).getItemStack(), e.getUniqueId());
|
||||
default:
|
||||
return new BukkitEntity(toLocation(e.getLocation()), e.getType(), e.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
public static BaseBlock toBlock(LocalWorld world, ItemStack itemStack) throws WorldEditException {
|
||||
final int typeId = itemStack.getTypeId();
|
||||
|
||||
switch (typeId) {
|
||||
case ItemID.INK_SACK:
|
||||
final Dye materialData = (Dye) itemStack.getData();
|
||||
if (materialData.getColor() == DyeColor.BROWN) {
|
||||
return new BaseBlock(BlockID.COCOA_PLANT, -1);
|
||||
}
|
||||
break;
|
||||
|
||||
case ItemID.HEAD:
|
||||
return new SkullBlock(0, (byte) itemStack.getDurability());
|
||||
|
||||
default:
|
||||
final BaseBlock baseBlock = BlockType.getBlockForItem(typeId, itemStack.getDurability());
|
||||
if (baseBlock != null) {
|
||||
return baseBlock;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (world.isValidBlockType(typeId)) {
|
||||
return new BaseBlock(typeId, -1);
|
||||
}
|
||||
|
||||
throw new NotABlockException(typeId);
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,49 +0,0 @@
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.worldedit.bukkit;
|
||||
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
/**
|
||||
* Handles incoming WorldEditCui init message
|
||||
* @author zml2008
|
||||
*/
|
||||
public class CUIChannelListener implements PluginMessageListener {
|
||||
public static final Charset UTF_8_CHARSET = Charset.forName("UTF-8");
|
||||
private final WorldEditPlugin plugin;
|
||||
|
||||
public CUIChannelListener(WorldEditPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
|
||||
LocalSession session = plugin.getSession(player);
|
||||
if (session.hasCUISupport()) { // Already initialized
|
||||
return;
|
||||
}
|
||||
|
||||
String text = new String(message, UTF_8_CHARSET);
|
||||
session.handleCUIInitializationMessage(text);
|
||||
}
|
||||
}
|
@ -1,436 +0,0 @@
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
// $Id$
|
||||
/*
|
||||
* This file is a part of WorldEdit.
|
||||
* Copyright (c) sk89q <http://www.sk89q.com>
|
||||
* Copyright (c) the WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* (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
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import com.sk89q.jnbt.*;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.TileEntityBlock;
|
||||
import com.sk89q.worldedit.world.DataException;
|
||||
import com.sk89q.worldedit.foundation.Block;
|
||||
import net.minecraft.server.v1_7_R2.*;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_7_R2.CraftWorld;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* A blind handler of blocks with TileEntity data that directly access Minecraft's
|
||||
* classes through CraftBukkit.
|
||||
* </p>
|
||||
* Usage of this class may break terribly in the future, and therefore usage should
|
||||
* be trapped in a handler for {@link Throwable}.
|
||||
*/
|
||||
public class DefaultNmsBlock extends NmsBlock {
|
||||
|
||||
private static final Logger logger = WorldEdit.logger;
|
||||
private static Field compoundMapField;
|
||||
private static final Field nmsBlock_isTileEntityField; // The field is deobfuscated but the method isn't. No idea why.
|
||||
private NBTTagCompound nbtData = null;
|
||||
|
||||
static {
|
||||
Field field;
|
||||
try {
|
||||
field = net.minecraft.server.v1_7_R2.Block.class.getDeclaredField("isTileEntity");
|
||||
field.setAccessible(true);
|
||||
} catch (NoSuchFieldException e) {
|
||||
// logger.severe("Could not find NMS block tile entity field!");
|
||||
field = null;
|
||||
}
|
||||
nmsBlock_isTileEntityField = field;
|
||||
}
|
||||
|
||||
public static boolean verify() {
|
||||
return nmsBlock_isTileEntityField != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance with a given type ID, data value, and previous
|
||||
* {@link TileEntityBlock}-implementing object.
|
||||
*
|
||||
* @param type block type ID
|
||||
* @param data data value
|
||||
* @param tileEntityBlock tile entity block
|
||||
*/
|
||||
public DefaultNmsBlock(int type, int data, TileEntityBlock tileEntityBlock) {
|
||||
super(type, data);
|
||||
|
||||
nbtData = (NBTTagCompound) fromNative(tileEntityBlock.getNbtData());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance with a given type ID, data value, and raw
|
||||
* {@link NBTTagCompound} copy.
|
||||
*
|
||||
* @param type block type ID
|
||||
* @param data data value
|
||||
* @param nbtData raw NBT data
|
||||
*/
|
||||
public DefaultNmsBlock(int type, int data, NBTTagCompound nbtData) {
|
||||
super(type, data);
|
||||
|
||||
this.nbtData = nbtData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a {@link NBTTagCompound} that has valid coordinates.
|
||||
*
|
||||
* @param pt coordinates to set
|
||||
* @return the tag compound
|
||||
*/
|
||||
private NBTTagCompound getNmsData(Vector pt) {
|
||||
if (nbtData == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
nbtData.set("x", new NBTTagInt(pt.getBlockX()));
|
||||
nbtData.set("y", new NBTTagInt(pt.getBlockY()));
|
||||
nbtData.set("z", new NBTTagInt(pt.getBlockZ()));
|
||||
|
||||
return nbtData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNbtData() {
|
||||
return nbtData != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNbtId() {
|
||||
if (nbtData == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return nbtData.getString("id");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag getNbtData() {
|
||||
if (nbtData == null) {
|
||||
return new CompoundTag(getNbtId(),
|
||||
new HashMap<String, Tag>());
|
||||
}
|
||||
return (CompoundTag) toNative(nbtData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNbtData(CompoundTag tag) throws DataException {
|
||||
if (tag == null) {
|
||||
this.nbtData = null;
|
||||
}
|
||||
this.nbtData = (NBTTagCompound) fromNative(tag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an instance from the given information.
|
||||
*
|
||||
* @param world world to get the block from
|
||||
* @param position position to get the block at
|
||||
* @param type type ID of block
|
||||
* @param data data value of block
|
||||
* @return the block, or null
|
||||
*/
|
||||
public static DefaultNmsBlock get(World world, Vector position, int type, int data) {
|
||||
if (!hasTileEntity(type)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
TileEntity te = ((CraftWorld) world).getHandle().getTileEntity(
|
||||
position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
||||
|
||||
if (te != null) {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
te.b(tag); // Load data
|
||||
return new DefaultNmsBlock(type, data, tag);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an instance or a {@link TileEntityBlock} to the given position.
|
||||
*
|
||||
* @param world world to set the block in
|
||||
* @param position position to set the block at
|
||||
* @param block the block to set
|
||||
* @return true if tile entity data was copied to the world
|
||||
*/
|
||||
public static boolean set(World world, Vector position, BaseBlock block) {
|
||||
NBTTagCompound data = null;
|
||||
if (!hasTileEntity(world.getBlockTypeIdAt(position.getBlockX(), position.getBlockY(), position.getBlockZ()))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (block instanceof DefaultNmsBlock) {
|
||||
DefaultNmsBlock nmsProxyBlock = (DefaultNmsBlock) block;
|
||||
data = nmsProxyBlock.getNmsData(position);
|
||||
} else if (block instanceof TileEntityBlock) {
|
||||
DefaultNmsBlock nmsProxyBlock = new DefaultNmsBlock(
|
||||
block.getId(), block.getData(), block);
|
||||
data = nmsProxyBlock.getNmsData(position);
|
||||
}
|
||||
|
||||
if (data != null) {
|
||||
TileEntity te = ((CraftWorld) world).getHandle().getTileEntity(
|
||||
position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
||||
if (te != null) {
|
||||
te.a(data); // Load data
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to set a block 'safely', as in setting the block data to the location, and
|
||||
* then triggering physics only at the end.
|
||||
*
|
||||
* @param world world to set the block in
|
||||
* @param position position to set the block at
|
||||
* @param block the block to set
|
||||
* @param notifyAdjacent true to notify physics and what not
|
||||
* @return true if block id or data was changed
|
||||
*/
|
||||
public static boolean setSafely(BukkitWorld world, Vector position,
|
||||
Block block, boolean notifyAdjacent) {
|
||||
|
||||
int x = position.getBlockX();
|
||||
int y = position.getBlockY();
|
||||
int z = position.getBlockZ();
|
||||
|
||||
CraftWorld craftWorld = ((CraftWorld) world.getWorld());
|
||||
// TileEntity te = craftWorld.getHandle().getTileEntity(x, y, z);
|
||||
// craftWorld.getHandle().tileEntityList.remove(te);
|
||||
|
||||
boolean changed = craftWorld.getHandle().setTypeAndData(x, y, z, getNmsBlock(block.getId()), block.getData(), 0);
|
||||
|
||||
if (block instanceof BaseBlock) {
|
||||
world.copyToWorld(position, (BaseBlock) block);
|
||||
}
|
||||
|
||||
changed = craftWorld.getHandle().setData(x, y, z, block.getData(), 0) || changed;
|
||||
if (changed && notifyAdjacent) {
|
||||
craftWorld.getHandle().notify(x, y, z);
|
||||
craftWorld.getHandle().update(x, y, z, getNmsBlock(block.getId()));
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
public static boolean hasTileEntity(int type) {
|
||||
net.minecraft.server.v1_7_R2.Block nmsBlock = getNmsBlock(type);
|
||||
if (nmsBlock == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
return nmsBlock_isTileEntityField.getBoolean(nmsBlock); // Once we have the field stord, gets are fast
|
||||
} catch (IllegalAccessException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static net.minecraft.server.v1_7_R2.Block getNmsBlock(int type) {
|
||||
return net.minecraft.server.v1_7_R2.Block.e(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts from a non-native NMS NBT structure to a native WorldEdit NBT
|
||||
* structure.
|
||||
*
|
||||
* @param foreign non-native NMS NBT structure
|
||||
* @return native WorldEdit NBT structure
|
||||
*/
|
||||
private static Tag toNative(NBTBase foreign) {
|
||||
// temporary fix since mojang removed names from tags
|
||||
// our nbt spec will need to be updated to theirs
|
||||
return toNative(NBTBase.getTagName(foreign.getTypeId()), foreign);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts from a non-native NMS NBT structure to a native WorldEdit NBT
|
||||
* structure.
|
||||
*
|
||||
* @param foreign non-native NMS NBT structure
|
||||
* @param name name for the tag, if it has one
|
||||
* @return native WorldEdit NBT structure
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private static Tag toNative(String name, NBTBase foreign) {
|
||||
if (foreign == null) {
|
||||
return null;
|
||||
}
|
||||
if (foreign instanceof NBTTagCompound) {
|
||||
Map<String, Tag> values = new HashMap<String, Tag>();
|
||||
Collection<Object> foreignKeys = null;
|
||||
|
||||
if (compoundMapField == null) {
|
||||
try {
|
||||
// Method name may change!
|
||||
foreignKeys = ((NBTTagCompound) foreign).c();
|
||||
} catch (Throwable t) {
|
||||
try {
|
||||
logger.warning("WorldEdit: Couldn't get NBTTagCompound.c(), " +
|
||||
"so we're going to try to get at the 'map' field directly from now on");
|
||||
|
||||
if (compoundMapField == null) {
|
||||
compoundMapField = NBTTagCompound.class.getDeclaredField("map");
|
||||
compoundMapField.setAccessible(true);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
// Can't do much beyond this
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (compoundMapField != null) {
|
||||
try {
|
||||
foreignKeys = ((HashMap<Object, Object>) compoundMapField.get(foreign)).keySet();
|
||||
} catch (Throwable e) {
|
||||
// Can't do much beyond this
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
for (Object obj : foreignKeys) {
|
||||
String key = (String) obj;
|
||||
NBTBase base = (NBTBase) ((NBTTagCompound) foreign).get(key);
|
||||
values.put(key, toNative(key, base));
|
||||
}
|
||||
return new CompoundTag(name, values);
|
||||
} else if (foreign instanceof NBTTagByte) {
|
||||
return new ByteTag(name, ((NBTTagByte) foreign).f()); // getByte
|
||||
} else if (foreign instanceof NBTTagByteArray) {
|
||||
return new ByteArrayTag(name,
|
||||
((NBTTagByteArray) foreign).c()); // data
|
||||
} else if (foreign instanceof NBTTagDouble) {
|
||||
return new DoubleTag(name,
|
||||
((NBTTagDouble) foreign).g()); // getDouble
|
||||
} else if (foreign instanceof NBTTagFloat) {
|
||||
return new FloatTag(name, ((NBTTagFloat) foreign).h()); // getFloat
|
||||
} else if (foreign instanceof NBTTagInt) {
|
||||
return new IntTag(name, ((NBTTagInt) foreign).d()); // getInt
|
||||
} else if (foreign instanceof NBTTagIntArray) {
|
||||
return new IntArrayTag(name,
|
||||
((NBTTagIntArray) foreign).c()); // data
|
||||
} else if (foreign instanceof NBTTagList) {
|
||||
try {
|
||||
return transmorgifyList(name, (NBTTagList) foreign);
|
||||
} catch (NoSuchFieldException e) {
|
||||
} catch (SecurityException e) {
|
||||
} catch (IllegalArgumentException e) {
|
||||
} catch (IllegalAccessException e) {}
|
||||
return new ListTag(name, ByteTag.class, new ArrayList<ByteTag>());
|
||||
} else if (foreign instanceof NBTTagLong) {
|
||||
return new LongTag(name, ((NBTTagLong) foreign).c()); // getLong
|
||||
} else if (foreign instanceof NBTTagShort) {
|
||||
return new ShortTag(name, ((NBTTagShort) foreign).e()); // getShort
|
||||
} else if (foreign instanceof NBTTagString) {
|
||||
return new StringTag(name,
|
||||
((NBTTagString) foreign).a_()); // data
|
||||
} else if (foreign instanceof NBTTagEnd) {
|
||||
return new EndTag();
|
||||
} else {
|
||||
throw new IllegalArgumentException("Don't know how to make native "
|
||||
+ foreign.getClass().getCanonicalName());
|
||||
}
|
||||
}
|
||||
|
||||
private static ListTag transmorgifyList(String name, NBTTagList foreign)
|
||||
throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
|
||||
List<Tag> values = new ArrayList<Tag>();
|
||||
int type = foreign.d();
|
||||
Field listField = NBTTagList.class.getDeclaredField("list");
|
||||
listField.setAccessible(true);
|
||||
List foreignList;
|
||||
foreignList = (List) listField.get(foreign);
|
||||
for (int i = 0; i < foreign.size(); i++) {
|
||||
NBTBase element = (NBTBase) foreignList.get(i);
|
||||
values.add(toNative(null, element)); // list elements shouldn't have names
|
||||
}
|
||||
Class<? extends Tag> cls = NBTConstants.getClassFromType(type);
|
||||
return new ListTag(name, cls, values);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a WorldEdit-native NBT structure to a NMS structure.
|
||||
*
|
||||
* @param foreign structure to convert
|
||||
* @return non-native structure
|
||||
*/
|
||||
private static NBTBase fromNative(Tag foreign) {
|
||||
if (foreign == null) {
|
||||
return null;
|
||||
}
|
||||
if (foreign instanceof CompoundTag) {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
for (Map.Entry<String, Tag> entry : ((CompoundTag) foreign)
|
||||
.getValue().entrySet()) {
|
||||
tag.set(entry.getKey(), fromNative(entry.getValue()));
|
||||
}
|
||||
return tag;
|
||||
} else if (foreign instanceof ByteTag) {
|
||||
return new NBTTagByte(((ByteTag) foreign).getValue());
|
||||
} else if (foreign instanceof ByteArrayTag) {
|
||||
return new NBTTagByteArray(((ByteArrayTag) foreign).getValue());
|
||||
} else if (foreign instanceof DoubleTag) {
|
||||
return new NBTTagDouble(((DoubleTag) foreign).getValue());
|
||||
} else if (foreign instanceof FloatTag) {
|
||||
return new NBTTagFloat(((FloatTag) foreign).getValue());
|
||||
} else if (foreign instanceof IntTag) {
|
||||
return new NBTTagInt(((IntTag) foreign).getValue());
|
||||
} else if (foreign instanceof IntArrayTag) {
|
||||
return new NBTTagIntArray(((IntArrayTag) foreign).getValue());
|
||||
} else if (foreign instanceof ListTag) {
|
||||
NBTTagList tag = new NBTTagList();
|
||||
ListTag foreignList = (ListTag) foreign;
|
||||
for (Tag t : foreignList.getValue()) {
|
||||
tag.add(fromNative(t));
|
||||
}
|
||||
return tag;
|
||||
} else if (foreign instanceof LongTag) {
|
||||
return new NBTTagLong(((LongTag) foreign).getValue());
|
||||
} else if (foreign instanceof ShortTag) {
|
||||
return new NBTTagShort(((ShortTag) foreign).getValue());
|
||||
} else if (foreign instanceof StringTag) {
|
||||
return new NBTTagString(((StringTag) foreign).getValue());
|
||||
} else if (foreign instanceof EndTag) {
|
||||
try {
|
||||
Method tagMaker = NBTBase.class.getDeclaredMethod("createTag", byte.class);
|
||||
tagMaker.setAccessible(true);
|
||||
return (NBTBase) tagMaker.invoke(null, (byte) 0);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("Don't know how to make NMS "
|
||||
+ foreign.getClass().getCanonicalName());
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isValidBlockType(int type) throws NoClassDefFoundError {
|
||||
return type == 0 || (type >= 1 && net.minecraft.server.v1_7_R2.Block.e(type) != null);
|
||||
}
|
||||
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.worldedit.bukkit;
|
||||
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import org.bukkit.BlockChangeDelegate;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
|
||||
/**
|
||||
* Proxy class to catch calls to set blocks.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class EditSessionBlockChangeDelegate implements BlockChangeDelegate {
|
||||
private EditSession editSession;
|
||||
|
||||
public EditSessionBlockChangeDelegate(EditSession editSession) {
|
||||
this.editSession = editSession;
|
||||
}
|
||||
|
||||
public boolean setRawTypeId(int x, int y, int z, int typeId) {
|
||||
try {
|
||||
return editSession.setBlock(new Vector(x, y, z), new BaseBlock(typeId));
|
||||
} catch (MaxChangedBlocksException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean setRawTypeIdAndData(int x, int y, int z, int typeId, int data) {
|
||||
try {
|
||||
return editSession.setBlock(new Vector(x, y, z), new BaseBlock(typeId, data));
|
||||
} catch (MaxChangedBlocksException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean setTypeId(int x, int y, int z, int typeId) {
|
||||
return setRawTypeId(x, y, z, typeId);
|
||||
}
|
||||
|
||||
public boolean setTypeIdAndData(int x, int y, int z, int typeId, int data) {
|
||||
return setRawTypeIdAndData(x, y, z, typeId, data);
|
||||
}
|
||||
|
||||
public int getTypeId(int x, int y, int z) {
|
||||
return editSession.getBlockType(new Vector(x, y, z));
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return editSession.getWorld().getMaxY() + 1;
|
||||
}
|
||||
|
||||
public boolean isEmpty(int x, int y, int z) {
|
||||
return editSession.getBlockType(new Vector(x, y, z)) == BlockID.AIR;
|
||||
}
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import org.bukkit.World;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.foundation.Block;
|
||||
|
||||
public abstract class NmsBlock extends BaseBlock {
|
||||
|
||||
protected NmsBlock(int type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
protected NmsBlock(int type, int data) {
|
||||
super(type, data);
|
||||
}
|
||||
|
||||
public static boolean verify() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static NmsBlock get(World world, Vector vector, int type, int data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean set(World world, Vector vector, Block block) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean setSafely(World world, Vector vector, Block block, boolean notify) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean hasTileEntity(int type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isValidBlockType(int type) {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.worldedit.bukkit;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
import com.sk89q.worldedit.SessionCheck;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
|
||||
/**
|
||||
* Used to remove expired sessions in Bukkit.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class SessionTimer implements Runnable {
|
||||
|
||||
private WorldEdit worldEdit;
|
||||
private SessionCheck checker;
|
||||
|
||||
public SessionTimer(WorldEdit worldEdit, final Server server) {
|
||||
this.worldEdit = worldEdit;
|
||||
this.checker = new SessionCheck() {
|
||||
public boolean isOnlinePlayer(String name) {
|
||||
Player player = server.getPlayer(name);
|
||||
return player != null && player.isOnline();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void run() {
|
||||
worldEdit.flushExpiredSessions(checker);
|
||||
}
|
||||
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.worldedit.bukkit;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
|
||||
public class WorldEditAPI {
|
||||
private WorldEditPlugin plugin;
|
||||
|
||||
public WorldEditAPI(WorldEditPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the session for a player.
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public LocalSession getSession(Player player) {
|
||||
return plugin.getWorldEdit().getSession(
|
||||
new BukkitPlayer(plugin, plugin.getServerInterface(), player));
|
||||
}
|
||||
}
|
@ -1,178 +0,0 @@
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2012 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/>.
|
||||
*/
|
||||
|
||||
// $Id$
|
||||
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.Event.Result;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerGameModeChangeEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import com.sk89q.util.StringUtil;
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldVector;
|
||||
|
||||
/**
|
||||
* Handles all events thrown in relation to a Player
|
||||
*/
|
||||
public class WorldEditListener implements Listener {
|
||||
|
||||
private WorldEditPlugin plugin;
|
||||
private boolean ignoreLeftClickAir = false;
|
||||
|
||||
/**
|
||||
* Called when a player plays an animation, such as an arm swing
|
||||
*
|
||||
* @param event Relevant event details
|
||||
*/
|
||||
|
||||
/**
|
||||
* Construct the object;
|
||||
*
|
||||
* @param plugin
|
||||
*/
|
||||
public WorldEditListener(WorldEditPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player leaves a server
|
||||
*
|
||||
* @param event Relevant event details
|
||||
*/
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
plugin.getWorldEdit().markExpire(plugin.wrapPlayer(event.getPlayer()));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onGamemode(PlayerGameModeChangeEvent event) {
|
||||
// this will automatically refresh their sesssion, we don't have to do anything
|
||||
WorldEdit.getInstance().getSession(plugin.wrapPlayer(event.getPlayer()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player attempts to use a command
|
||||
*
|
||||
* @param event Relevant event details
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
String[] split = event.getMessage().split(" ");
|
||||
|
||||
if (split.length > 0) {
|
||||
split = plugin.getWorldEdit().commandDetection(split);
|
||||
split[0] = "/" + split[0];
|
||||
}
|
||||
|
||||
final String newMessage = StringUtil.joinString(split, " ");
|
||||
|
||||
if (!newMessage.equals(event.getMessage())) {
|
||||
event.setMessage(newMessage);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
if (event.getMessage().length() > 0) {
|
||||
plugin.getServer().dispatchCommand(event.getPlayer(),
|
||||
event.getMessage().substring(1));
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player interacts
|
||||
*
|
||||
* @param event Relevant event details
|
||||
*/
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if (event.useItemInHand() == Result.DENY) {
|
||||
return;
|
||||
}
|
||||
|
||||
final LocalPlayer player = plugin.wrapPlayer(event.getPlayer());
|
||||
final LocalWorld world = player.getWorld();
|
||||
final WorldEdit we = plugin.getWorldEdit();
|
||||
|
||||
Action action = event.getAction();
|
||||
if (action == Action.LEFT_CLICK_BLOCK) {
|
||||
final Block clickedBlock = event.getClickedBlock();
|
||||
final WorldVector pos = new WorldVector(world, clickedBlock.getX(),
|
||||
clickedBlock.getY(), clickedBlock.getZ());
|
||||
|
||||
if (we.handleBlockLeftClick(player, pos)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
if (we.handleArmSwing(player)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
if (!ignoreLeftClickAir) {
|
||||
final int taskId = Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ignoreLeftClickAir = false;
|
||||
}
|
||||
}, 2);
|
||||
|
||||
if (taskId != -1) {
|
||||
ignoreLeftClickAir = true;
|
||||
}
|
||||
}
|
||||
} else if (action == Action.LEFT_CLICK_AIR) {
|
||||
if (ignoreLeftClickAir) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (we.handleArmSwing(player)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
||||
} else if (action == Action.RIGHT_CLICK_BLOCK) {
|
||||
final Block clickedBlock = event.getClickedBlock();
|
||||
final WorldVector pos = new WorldVector(world, clickedBlock.getX(),
|
||||
clickedBlock.getY(), clickedBlock.getZ());
|
||||
|
||||
if (we.handleBlockRightClick(player, pos)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
if (we.handleRightClick(player)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (action == Action.RIGHT_CLICK_AIR) {
|
||||
if (we.handleRightClick(player)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,430 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.worldedit.bukkit;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Enumeration;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.logging.Handler;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.sk89q.util.yaml.YAMLProcessor;
|
||||
import com.sk89q.wepif.PermissionsResolverManager;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.ServerInterface;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditOperation;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
|
||||
import com.sk89q.worldedit.bukkit.selections.Polygonal2DSelection;
|
||||
import com.sk89q.worldedit.bukkit.selections.Selection;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Polygonal2DRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
|
||||
/**
|
||||
* Plugin for Bukkit.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class WorldEditPlugin extends JavaPlugin {
|
||||
|
||||
/**
|
||||
* The name of the CUI's plugin channel registration
|
||||
*/
|
||||
public static final String CUI_PLUGIN_CHANNEL = "WECUI";
|
||||
|
||||
/**
|
||||
* The server interface that all server-related API goes through.
|
||||
*/
|
||||
private BukkitServerInterface server;
|
||||
/**
|
||||
* Main WorldEdit instance.
|
||||
*/
|
||||
private WorldEdit controller;
|
||||
/**
|
||||
* Deprecated API.
|
||||
*/
|
||||
private WorldEditAPI api;
|
||||
|
||||
/**
|
||||
* Holds the configuration for WorldEdit.
|
||||
*/
|
||||
private BukkitConfiguration config;
|
||||
|
||||
/**
|
||||
* Called on plugin enable.
|
||||
*/
|
||||
@Override
|
||||
public void onEnable() {
|
||||
final String pluginYmlVersion = getDescription().getVersion();
|
||||
final String manifestVersion = WorldEdit.getVersion();
|
||||
|
||||
if (!manifestVersion.equalsIgnoreCase(pluginYmlVersion)) {
|
||||
WorldEdit.setVersion(manifestVersion + " (" + pluginYmlVersion + ")");
|
||||
}
|
||||
|
||||
// Make the data folders that WorldEdit uses
|
||||
getDataFolder().mkdirs();
|
||||
File targetDir = new File(getDataFolder() + File.separator + "nmsblocks");
|
||||
targetDir.mkdir();
|
||||
copyNmsBlockClasses(targetDir);
|
||||
|
||||
// Create the default configuration file
|
||||
createDefaultConfiguration("config.yml");
|
||||
|
||||
// Set up configuration and such, including the permissions
|
||||
// resolver
|
||||
config = new BukkitConfiguration(new YAMLProcessor(new File(getDataFolder(), "config.yml"), true), this);
|
||||
PermissionsResolverManager.initialize(this);
|
||||
|
||||
// Load the configuration
|
||||
config.load();
|
||||
|
||||
// Setup interfaces
|
||||
server = new BukkitServerInterface(this, getServer());
|
||||
controller = new WorldEdit(server, config);
|
||||
WorldEdit.logger.setParent(Bukkit.getLogger());
|
||||
api = new WorldEditAPI(this);
|
||||
getServer().getMessenger().registerIncomingPluginChannel(this, CUI_PLUGIN_CHANNEL, new CUIChannelListener(this));
|
||||
getServer().getMessenger().registerOutgoingPluginChannel(this, CUI_PLUGIN_CHANNEL);
|
||||
// Now we can register events!
|
||||
getServer().getPluginManager().registerEvents(new WorldEditListener(this), this);
|
||||
|
||||
getServer().getScheduler().runTaskTimerAsynchronously(this,
|
||||
new SessionTimer(controller, getServer()), 120, 120);
|
||||
}
|
||||
|
||||
private void copyNmsBlockClasses(File target) {
|
||||
try {
|
||||
JarFile jar = new JarFile(getFile());
|
||||
@SuppressWarnings("rawtypes")
|
||||
Enumeration entries = jar.entries();
|
||||
while (entries.hasMoreElements()) {
|
||||
JarEntry jarEntry = (JarEntry) entries.nextElement();
|
||||
if (!jarEntry.getName().startsWith("nmsblocks") || jarEntry.isDirectory()) continue;
|
||||
|
||||
File file = new File(target + File.separator + jarEntry.getName().replace("nmsblocks", ""));
|
||||
if (file.exists()) continue;
|
||||
|
||||
InputStream is = jar.getInputStream(jarEntry);
|
||||
FileOutputStream fos = new FileOutputStream(file);
|
||||
|
||||
fos = new FileOutputStream(file);
|
||||
byte[] buf = new byte[8192];
|
||||
int length = 0;
|
||||
while ((length = is.read(buf)) > 0) {
|
||||
fos.write(buf, 0, length);
|
||||
}
|
||||
fos.close();
|
||||
is.close();
|
||||
}
|
||||
} catch (Throwable e) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on plugin disable.
|
||||
*/
|
||||
@Override
|
||||
public void onDisable() {
|
||||
controller.clearSessions();
|
||||
for (Handler h : controller.commandLogger.getHandlers()) {
|
||||
h.close();
|
||||
}
|
||||
config.unload();
|
||||
server.unregisterCommands();
|
||||
this.getServer().getScheduler().cancelTasks(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads and reloads all configuration.
|
||||
*/
|
||||
protected void loadConfiguration() {
|
||||
config.unload();
|
||||
config.load();
|
||||
getPermissionsResolver().load();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a default configuration file from the .jar.
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
protected void createDefaultConfiguration(String name) {
|
||||
File actual = new File(getDataFolder(), name);
|
||||
if (!actual.exists()) {
|
||||
InputStream input =
|
||||
null;
|
||||
try {
|
||||
JarFile file = new JarFile(getFile());
|
||||
ZipEntry copy = file.getEntry("defaults/" + name);
|
||||
if (copy == null) throw new FileNotFoundException();
|
||||
input = file.getInputStream(copy);
|
||||
} catch (IOException e) {
|
||||
getLogger().severe("Unable to read default configuration: " + name);
|
||||
}
|
||||
if (input != null) {
|
||||
FileOutputStream output = null;
|
||||
|
||||
try {
|
||||
output = new FileOutputStream(actual);
|
||||
byte[] buf = new byte[8192];
|
||||
int length = 0;
|
||||
while ((length = input.read(buf)) > 0) {
|
||||
output.write(buf, 0, length);
|
||||
}
|
||||
|
||||
getLogger().info("Default configuration file written: " + name);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (input != null) {
|
||||
input.close();
|
||||
}
|
||||
} catch (IOException e) {}
|
||||
|
||||
try {
|
||||
if (output != null) {
|
||||
output.close();
|
||||
}
|
||||
} catch (IOException e) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on WorldEdit command.
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, org.bukkit.command.Command cmd,
|
||||
String commandLabel, String[] args) {
|
||||
|
||||
// Add the command to the array because the underlying command handling
|
||||
// code of WorldEdit expects it
|
||||
String[] split = new String[args.length + 1];
|
||||
System.arraycopy(args, 0, split, 1, args.length);
|
||||
split[0] = "/" + cmd.getName();
|
||||
|
||||
controller.handleCommand(wrapCommandSender(sender), split);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the session for the player.
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public LocalSession getSession(Player player) {
|
||||
return controller.getSession(wrapPlayer(player));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the session for the player.
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public EditSession createEditSession(Player player) {
|
||||
LocalPlayer wePlayer = wrapPlayer(player);
|
||||
LocalSession session = controller.getSession(wePlayer);
|
||||
BlockBag blockBag = session.getBlockBag(wePlayer);
|
||||
|
||||
EditSession editSession = controller.getEditSessionFactory()
|
||||
.getEditSession(wePlayer.getWorld(), session.getBlockChangeLimit(), blockBag, wePlayer);
|
||||
editSession.enableQueue();
|
||||
|
||||
return editSession;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remember an edit session.
|
||||
*
|
||||
* @param player
|
||||
* @param editSession
|
||||
*/
|
||||
public void remember(Player player, EditSession editSession) {
|
||||
LocalPlayer wePlayer = wrapPlayer(player);
|
||||
LocalSession session = controller.getSession(wePlayer);
|
||||
|
||||
session.remember(editSession);
|
||||
editSession.flushQueue();
|
||||
|
||||
controller.flushBlockBag(wePlayer, editSession);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap an operation into an EditSession.
|
||||
*
|
||||
* @param player
|
||||
* @param op
|
||||
* @throws Throwable
|
||||
*/
|
||||
public void perform(Player player, WorldEditOperation op)
|
||||
throws Throwable {
|
||||
LocalPlayer wePlayer = wrapPlayer(player);
|
||||
LocalSession session = controller.getSession(wePlayer);
|
||||
|
||||
EditSession editSession = createEditSession(player);
|
||||
try {
|
||||
op.run(session, wePlayer, editSession);
|
||||
} finally {
|
||||
remember(player, editSession);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the API.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public WorldEditAPI getAPI() {
|
||||
return api;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the configuration used by WorldEdit.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public BukkitConfiguration getLocalConfiguration() {
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the permissions resolver in use.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public PermissionsResolverManager getPermissionsResolver() {
|
||||
return PermissionsResolverManager.getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to wrap a Bukkit Player as a LocalPlayer.
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public BukkitPlayer wrapPlayer(Player player) {
|
||||
return new BukkitPlayer(this, this.server, player);
|
||||
}
|
||||
|
||||
public LocalPlayer wrapCommandSender(CommandSender sender) {
|
||||
if (sender instanceof Player) {
|
||||
return wrapPlayer((Player) sender);
|
||||
}
|
||||
|
||||
return new BukkitCommandSender(this, this.server, sender);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the server interface.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public ServerInterface getServerInterface() {
|
||||
return server;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get WorldEdit.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public WorldEdit getWorldEdit() {
|
||||
return controller;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the region selection for the player.
|
||||
*
|
||||
* @param player
|
||||
* @return the selection or null if there was none
|
||||
*/
|
||||
public Selection getSelection(Player player) {
|
||||
if (player == null) {
|
||||
throw new IllegalArgumentException("Null player not allowed");
|
||||
}
|
||||
if (!player.isOnline()) {
|
||||
throw new IllegalArgumentException("Offline player not allowed");
|
||||
}
|
||||
|
||||
LocalSession session = controller.getSession(wrapPlayer(player));
|
||||
RegionSelector selector = session.getRegionSelector(BukkitUtil.getLocalWorld(player.getWorld()));
|
||||
|
||||
try {
|
||||
Region region = selector.getRegion();
|
||||
World world = ((BukkitWorld) session.getSelectionWorld()).getWorld();
|
||||
|
||||
if (region instanceof CuboidRegion) {
|
||||
return new CuboidSelection(world, selector, (CuboidRegion) region);
|
||||
} else if (region instanceof Polygonal2DRegion) {
|
||||
return new Polygonal2DSelection(world, selector, (Polygonal2DRegion) region);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} catch (IncompleteRegionException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the region selection for a player.
|
||||
*
|
||||
* @param player
|
||||
* @param selection
|
||||
*/
|
||||
public void setSelection(Player player, Selection selection) {
|
||||
if (player == null) {
|
||||
throw new IllegalArgumentException("Null player not allowed");
|
||||
}
|
||||
if (!player.isOnline()) {
|
||||
throw new IllegalArgumentException("Offline player not allowed");
|
||||
}
|
||||
if (selection == null) {
|
||||
throw new IllegalArgumentException("Null selection not allowed");
|
||||
}
|
||||
|
||||
LocalSession session = controller.getSession(wrapPlayer(player));
|
||||
RegionSelector sel = selection.getRegionSelector();
|
||||
session.setRegionSelector(BukkitUtil.getLocalWorld(player.getWorld()), sel);
|
||||
session.dispatchCUISelection(wrapPlayer(player));
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.worldedit.bukkit.entity;
|
||||
|
||||
import com.sk89q.worldedit.LocalEntity;
|
||||
import com.sk89q.worldedit.Location;
|
||||
import com.sk89q.worldedit.bukkit.BukkitUtil;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author zml2008
|
||||
*/
|
||||
public class BukkitEntity extends LocalEntity {
|
||||
private final EntityType type;
|
||||
private final UUID entityId;
|
||||
|
||||
public BukkitEntity(Location loc, EntityType type, UUID entityId) {
|
||||
super(loc);
|
||||
this.type = type;
|
||||
this.entityId = entityId;
|
||||
}
|
||||
|
||||
public UUID getEntityId() {
|
||||
return entityId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean spawn(Location weLoc) {
|
||||
org.bukkit.Location loc = BukkitUtil.toLocation(weLoc);
|
||||
return loc.getWorld().spawn(loc, type.getEntityClass()) != null;
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.worldedit.bukkit.entity;
|
||||
|
||||
import com.sk89q.worldedit.Location;
|
||||
import com.sk89q.worldedit.bukkit.BukkitUtil;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.ExperienceOrb;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author zml2008
|
||||
*/
|
||||
public class BukkitExpOrb extends BukkitEntity {
|
||||
private final int amount;
|
||||
|
||||
public BukkitExpOrb(Location loc, UUID entityId, int amount) {
|
||||
super(loc, EntityType.EXPERIENCE_ORB, entityId);
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean spawn(Location weLoc) {
|
||||
org.bukkit.Location loc = BukkitUtil.toLocation(weLoc);
|
||||
ExperienceOrb orb = loc.getWorld().spawn(loc, ExperienceOrb.class);
|
||||
if (orb != null) {
|
||||
orb.setExperience(amount);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.worldedit.bukkit.entity;
|
||||
|
||||
import com.sk89q.worldedit.Location;
|
||||
import com.sk89q.worldedit.bukkit.BukkitUtil;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author zml2008
|
||||
*/
|
||||
public class BukkitItem extends BukkitEntity {
|
||||
private final ItemStack stack;
|
||||
public BukkitItem(Location loc, ItemStack stack, UUID entityId) {
|
||||
super(loc, EntityType.DROPPED_ITEM, entityId);
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean spawn(Location weLoc) {
|
||||
org.bukkit.Location loc = BukkitUtil.toLocation(weLoc);
|
||||
return loc.getWorld().dropItem(loc, stack) != null;
|
||||
}
|
||||
}
|
@ -1,104 +0,0 @@
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.worldedit.bukkit.entity;
|
||||
|
||||
import com.sk89q.worldedit.Location;
|
||||
import com.sk89q.worldedit.bukkit.BukkitUtil;
|
||||
import org.bukkit.Art;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Painting;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Deque;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author zml2008
|
||||
*/
|
||||
public class BukkitPainting extends BukkitEntity {
|
||||
private static int spawnTask = -1;
|
||||
private static final Deque<QueuedPaintingSpawn> spawnQueue = new ArrayDeque<QueuedPaintingSpawn>();
|
||||
|
||||
private class QueuedPaintingSpawn {
|
||||
private final Location weLoc;
|
||||
|
||||
public QueuedPaintingSpawn(Location weLoc) {
|
||||
this.weLoc = weLoc;
|
||||
}
|
||||
|
||||
public void spawn() {
|
||||
spawnRaw(weLoc);
|
||||
}
|
||||
}
|
||||
private static class PaintingSpawnRunnable implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
synchronized (spawnQueue) {
|
||||
QueuedPaintingSpawn spawn;
|
||||
while ((spawn = spawnQueue.poll()) != null) {
|
||||
try {
|
||||
spawn.spawn();
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
spawnTask = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final Art art;
|
||||
private final BlockFace facingDirection;
|
||||
public BukkitPainting(Location loc, Art art, BlockFace facingDirection, UUID entityId) {
|
||||
super(loc, EntityType.PAINTING, entityId);
|
||||
this.art = art;
|
||||
this.facingDirection = facingDirection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Queue the painting to be spawned at the specified location.
|
||||
* This operation is delayed so that the block changes that may be applied can be applied before the painting spawn is attempted.
|
||||
*
|
||||
* @param weLoc The WorldEdit location
|
||||
* @return Whether the spawn as successful
|
||||
*/
|
||||
public boolean spawn(Location weLoc) {
|
||||
synchronized (spawnQueue) {
|
||||
spawnQueue.add(new QueuedPaintingSpawn(weLoc));
|
||||
if (spawnTask == -1) {
|
||||
spawnTask = Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Bukkit.getServer().getPluginManager().getPlugin("WorldEdit"), new PaintingSpawnRunnable(), 1L);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean spawnRaw(Location weLoc) {
|
||||
org.bukkit.Location loc = BukkitUtil.toLocation(weLoc);
|
||||
Painting paint = loc.getWorld().spawn(loc, Painting.class);
|
||||
if (paint != null) {
|
||||
paint.setFacingDirection(facingDirection, true);
|
||||
paint.setArt(art, true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.worldedit.bukkit.selections;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.bukkit.BukkitUtil;
|
||||
import com.sk89q.worldedit.regions.*;
|
||||
|
||||
public class CuboidSelection extends RegionSelection {
|
||||
|
||||
protected CuboidRegion cuboid;
|
||||
|
||||
public CuboidSelection(World world, Location pt1, Location pt2) {
|
||||
this(world, BukkitUtil.toVector(pt1), BukkitUtil.toVector(pt2));
|
||||
}
|
||||
|
||||
public CuboidSelection(World world, Vector pt1, Vector pt2) {
|
||||
super(world);
|
||||
|
||||
// Validate input
|
||||
if (pt1 == null) {
|
||||
throw new IllegalArgumentException("Null point 1 not permitted");
|
||||
}
|
||||
|
||||
if (pt2 == null) {
|
||||
throw new IllegalArgumentException("Null point 2 not permitted");
|
||||
}
|
||||
|
||||
// Create new selector
|
||||
CuboidRegionSelector sel = new CuboidRegionSelector(BukkitUtil.getLocalWorld(world));
|
||||
|
||||
// set up selector
|
||||
sel.selectPrimary(pt1);
|
||||
sel.selectSecondary(pt2);
|
||||
|
||||
// set up CuboidSelection
|
||||
cuboid = sel.getIncompleteRegion();
|
||||
|
||||
// set up RegionSelection
|
||||
setRegionSelector(sel);
|
||||
setRegion(cuboid);
|
||||
}
|
||||
|
||||
public CuboidSelection(World world, RegionSelector sel, CuboidRegion region) {
|
||||
super(world, sel, region);
|
||||
this.cuboid = region;
|
||||
}
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.worldedit.bukkit.selections;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import org.bukkit.World;
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.bukkit.BukkitUtil;
|
||||
import com.sk89q.worldedit.regions.*;
|
||||
|
||||
public class Polygonal2DSelection extends RegionSelection {
|
||||
|
||||
protected Polygonal2DRegion poly2d;
|
||||
|
||||
public Polygonal2DSelection(World world, RegionSelector sel, Polygonal2DRegion region) {
|
||||
super(world, sel, region);
|
||||
this.poly2d = region;
|
||||
}
|
||||
|
||||
public Polygonal2DSelection(World world, List<BlockVector2D> points, int minY, int maxY) {
|
||||
super(world);
|
||||
LocalWorld lWorld = BukkitUtil.getLocalWorld(world);
|
||||
|
||||
// Validate input
|
||||
minY = Math.min(Math.max(0, minY), world.getMaxHeight());
|
||||
maxY = Math.min(Math.max(0, maxY), world.getMaxHeight());
|
||||
|
||||
// Create and set up new selector
|
||||
Polygonal2DRegionSelector sel = new Polygonal2DRegionSelector(lWorld, points, minY, maxY);
|
||||
|
||||
// set up CuboidSelection
|
||||
poly2d = sel.getIncompleteRegion();
|
||||
|
||||
// set up RegionSelection
|
||||
setRegionSelector(sel);
|
||||
setRegion(poly2d);
|
||||
}
|
||||
|
||||
public List<BlockVector2D> getNativePoints() {
|
||||
return Collections.unmodifiableList(poly2d.getPoints());
|
||||
}
|
||||
}
|
@ -1,106 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.worldedit.bukkit.selections;
|
||||
|
||||
import static com.sk89q.worldedit.bukkit.BukkitUtil.toLocation;
|
||||
import static com.sk89q.worldedit.bukkit.BukkitUtil.toVector;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
|
||||
public abstract class RegionSelection implements Selection {
|
||||
|
||||
private World world;
|
||||
private RegionSelector selector;
|
||||
private Region region;
|
||||
|
||||
public RegionSelection(World world) {
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
public RegionSelection(World world, RegionSelector selector, Region region) {
|
||||
this.world = world;
|
||||
this.region = region;
|
||||
this.selector = selector;
|
||||
}
|
||||
|
||||
protected Region getRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
protected void setRegion(Region region) {
|
||||
this.region = region;
|
||||
}
|
||||
|
||||
public RegionSelector getRegionSelector() {
|
||||
return selector;
|
||||
}
|
||||
|
||||
protected void setRegionSelector(RegionSelector selector) {
|
||||
this.selector = selector;
|
||||
}
|
||||
|
||||
public Location getMinimumPoint() {
|
||||
return toLocation(world, region.getMinimumPoint());
|
||||
}
|
||||
|
||||
public Vector getNativeMinimumPoint() {
|
||||
return region.getMinimumPoint();
|
||||
}
|
||||
|
||||
public Location getMaximumPoint() {
|
||||
return toLocation(world, region.getMaximumPoint());
|
||||
}
|
||||
|
||||
public Vector getNativeMaximumPoint() {
|
||||
return region.getMaximumPoint();
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
public int getArea() {
|
||||
return region.getArea();
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return region.getWidth();
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return region.getHeight();
|
||||
}
|
||||
|
||||
public int getLength() {
|
||||
return region.getLength();
|
||||
}
|
||||
|
||||
public boolean contains(Location pt) {
|
||||
if (!pt.getWorld().equals(world)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return region.contains(toVector(pt));
|
||||
}
|
||||
|
||||
}
|
@ -1,105 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.worldedit.bukkit.selections;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
|
||||
public interface Selection {
|
||||
/**
|
||||
* Get the lower point of a region.
|
||||
*
|
||||
* @return min. point
|
||||
*/
|
||||
public Location getMinimumPoint();
|
||||
|
||||
/**
|
||||
* Get the lower point of a region.
|
||||
*
|
||||
* @return min. point
|
||||
*/
|
||||
public Vector getNativeMinimumPoint();
|
||||
|
||||
/**
|
||||
* Get the upper point of a region.
|
||||
*
|
||||
* @return max. point
|
||||
*/
|
||||
public Location getMaximumPoint();
|
||||
|
||||
/**
|
||||
* Get the upper point of a region.
|
||||
*
|
||||
* @return max. point
|
||||
*/
|
||||
public Vector getNativeMaximumPoint();
|
||||
|
||||
/**
|
||||
* Get the region selector. This is for internal use.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public RegionSelector getRegionSelector();
|
||||
|
||||
/**
|
||||
* Get the world.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public World getWorld();
|
||||
|
||||
/**
|
||||
* Get the number of blocks in the region.
|
||||
*
|
||||
* @return number of blocks
|
||||
*/
|
||||
public int getArea();
|
||||
|
||||
/**
|
||||
* Get X-size.
|
||||
*
|
||||
* @return width
|
||||
*/
|
||||
public int getWidth();
|
||||
|
||||
/**
|
||||
* Get Y-size.
|
||||
*
|
||||
* @return height
|
||||
*/
|
||||
public int getHeight();
|
||||
|
||||
/**
|
||||
* Get Z-size.
|
||||
*
|
||||
* @return length
|
||||
*/
|
||||
public int getLength();
|
||||
|
||||
/**
|
||||
* Returns true based on whether the region contains the point,
|
||||
*
|
||||
* @param pt
|
||||
* @return
|
||||
*/
|
||||
public boolean contains(Location pt);
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
package com.sk89q.worldedit.masks;
|
||||
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
|
||||
/**
|
||||
* @deprecated Switch to {@link com.sk89q.worldedit.function.mask.AbstractMask}
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class AbstractMask implements Mask {
|
||||
@Override
|
||||
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
|
||||
}
|
||||
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
package com.sk89q.worldedit.masks;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.sk89q.worldedit.BiomeType;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
|
||||
public class BiomeTypeMask extends AbstractMask {
|
||||
private final Set<BiomeType> biomes;
|
||||
|
||||
public BiomeTypeMask() {
|
||||
this(new HashSet<BiomeType>());
|
||||
}
|
||||
|
||||
public BiomeTypeMask(Set<BiomeType> biomes) {
|
||||
this.biomes = biomes;
|
||||
}
|
||||
|
||||
public boolean matches2D(EditSession editSession, Vector2D pos) {
|
||||
BiomeType biome = editSession.getWorld().getBiome(pos);
|
||||
return biomes.contains(biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(EditSession editSession, Vector pos) {
|
||||
return matches2D(editSession, pos.toVector2D());
|
||||
}
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
package com.sk89q.worldedit.masks;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link com.sk89q.worldedit.function.mask.BlockMask}
|
||||
*/
|
||||
@Deprecated
|
||||
public class BlockMask extends AbstractMask {
|
||||
|
||||
private final Set<BaseBlock> blocks;
|
||||
|
||||
public BlockMask() {
|
||||
blocks = new HashSet<BaseBlock>();
|
||||
}
|
||||
|
||||
public BlockMask(Set<BaseBlock> types) {
|
||||
this.blocks = types;
|
||||
}
|
||||
|
||||
public BlockMask(BaseBlock... block) {
|
||||
blocks = new HashSet<BaseBlock>();
|
||||
for (BaseBlock b : block) {
|
||||
add(b);
|
||||
}
|
||||
}
|
||||
|
||||
public BlockMask(BaseBlock block) {
|
||||
this();
|
||||
add(block);
|
||||
}
|
||||
|
||||
public void add(BaseBlock block) {
|
||||
blocks.add(block);
|
||||
}
|
||||
|
||||
public void addAll(Collection<BaseBlock> blocks) {
|
||||
blocks.addAll(blocks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(EditSession editSession, Vector pos) {
|
||||
BaseBlock block = editSession.getBlock(pos);
|
||||
return blocks.contains(block)
|
||||
|| blocks.contains(new BaseBlock(block.getType(), -1));
|
||||
}
|
||||
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.worldedit.masks;
|
||||
|
||||
import java.util.Set;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
|
||||
/**
|
||||
* A filter that matches blocks based on block types.
|
||||
*
|
||||
* @deprecated replaced by {@link #BlockMask}
|
||||
* @author sk89q
|
||||
*/
|
||||
@Deprecated
|
||||
public class BlockTypeMask extends BlockMask {
|
||||
public BlockTypeMask() {
|
||||
super();
|
||||
}
|
||||
|
||||
public BlockTypeMask(Set<Integer> types) {
|
||||
super();
|
||||
for (int type : types) {
|
||||
add(type);
|
||||
}
|
||||
}
|
||||
|
||||
public BlockTypeMask(int type) {
|
||||
this();
|
||||
add(type);
|
||||
}
|
||||
|
||||
public void add(int type) {
|
||||
add(new BaseBlock(type));
|
||||
}
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.worldedit.masks;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.function.mask.MaskIntersection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @deprecated See {@link MaskIntersection}
|
||||
*/
|
||||
@Deprecated
|
||||
public class CombinedMask extends AbstractMask {
|
||||
private final List<Mask> masks = new ArrayList<Mask>();
|
||||
|
||||
public CombinedMask() {
|
||||
}
|
||||
|
||||
public CombinedMask(Mask mask) {
|
||||
add(mask);
|
||||
}
|
||||
|
||||
public CombinedMask(Mask ...mask) {
|
||||
for (Mask m : mask) {
|
||||
add(m);
|
||||
}
|
||||
}
|
||||
|
||||
public CombinedMask(List<Mask> masks) {
|
||||
this.masks.addAll(masks);
|
||||
}
|
||||
|
||||
public void add(Mask mask) {
|
||||
masks.add(mask);
|
||||
}
|
||||
|
||||
public boolean remove(Mask mask) {
|
||||
return masks.remove(mask);
|
||||
}
|
||||
|
||||
public boolean has(Mask mask) {
|
||||
return masks.contains(mask);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
|
||||
for (Mask mask : masks) {
|
||||
mask.prepare(session, player, target);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(EditSession editSession, Vector pos) {
|
||||
for (Mask mask : masks) {
|
||||
if (!mask.matches(editSession, pos)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package com.sk89q.worldedit.masks;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
public class DynamicRegionMask extends AbstractMask {
|
||||
private Region region;
|
||||
|
||||
@Override
|
||||
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
|
||||
try {
|
||||
region = session.getSelection(player.getWorld());
|
||||
} catch (IncompleteRegionException exc) {
|
||||
region = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(EditSession editSession, Vector pos) {
|
||||
return region == null || region.contains(pos);
|
||||
}
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.worldedit.masks;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
|
||||
/**
|
||||
* @deprecated See {@link com.sk89q.worldedit.function.mask.ExistingBlockMask}
|
||||
*/
|
||||
@Deprecated
|
||||
public class ExistingBlockMask extends AbstractMask {
|
||||
@Override
|
||||
public boolean matches(EditSession editSession, Vector pos) {
|
||||
return editSession.getBlockType(pos) != BlockID.AIR;
|
||||
}
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* 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.worldedit.masks;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @deprecated See {@link com.sk89q.worldedit.function.mask.FuzzyBlockMask}
|
||||
*/
|
||||
@Deprecated
|
||||
public class FuzzyBlockMask extends AbstractMask {
|
||||
|
||||
private final Set<BaseBlock> filter;
|
||||
|
||||
/**
|
||||
* Create a new fuzzy block mask.
|
||||
*
|
||||
* @param filter a list of block types to match
|
||||
*/
|
||||
public FuzzyBlockMask(Set<BaseBlock> filter) {
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new fuzzy block mask.
|
||||
*
|
||||
* @param block a list of block types to match
|
||||
*/
|
||||
public FuzzyBlockMask(BaseBlock... block) {
|
||||
Set<BaseBlock> filter = new HashSet<BaseBlock>();
|
||||
for (BaseBlock b : block) {
|
||||
filter.add(b);
|
||||
}
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(EditSession editSession, Vector pos) {
|
||||
BaseBlock compare = new BaseBlock(editSession.getBlockType(pos), editSession.getBlockData(pos));
|
||||
return BaseBlock.containsFuzzy(filter, compare);
|
||||
}
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.worldedit.masks;
|
||||
|
||||
import java.util.Set;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
|
||||
/**
|
||||
* A block type mask that only matches blocks that are not in the list.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
@Deprecated
|
||||
public class InvertedBlockTypeMask extends BlockTypeMask {
|
||||
public InvertedBlockTypeMask() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param types
|
||||
*/
|
||||
public InvertedBlockTypeMask(Set<Integer> types) {
|
||||
super(types);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type
|
||||
*/
|
||||
public InvertedBlockTypeMask(int type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(EditSession editSession, Vector pos) {
|
||||
return !super.matches(editSession, pos);
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package com.sk89q.worldedit.masks;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.function.mask.Masks;
|
||||
|
||||
/**
|
||||
* @deprecated See {@link Masks#negate(com.sk89q.worldedit.function.mask.Mask)}
|
||||
*/
|
||||
@Deprecated
|
||||
public class InvertedMask extends AbstractMask {
|
||||
private final Mask mask;
|
||||
|
||||
public InvertedMask(Mask mask) {
|
||||
this.mask = mask;
|
||||
}
|
||||
|
||||
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
|
||||
mask.prepare(session, player, target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(EditSession editSession, Vector pos) {
|
||||
return !mask.matches(editSession, pos);
|
||||
}
|
||||
|
||||
public Mask getInvertedMask() {
|
||||
return mask;
|
||||
}
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.worldedit.masks;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link com.sk89q.worldedit.function.mask.Mask}
|
||||
*/
|
||||
@Deprecated
|
||||
public interface Mask {
|
||||
|
||||
/**
|
||||
* Called one time before each edit session.
|
||||
*
|
||||
* @param session
|
||||
* @param player
|
||||
* @param target target of the brush, null if not a brush mask
|
||||
*/
|
||||
void prepare(LocalSession session, LocalPlayer player, Vector target);
|
||||
|
||||
/**
|
||||
* Given a block position, this method returns true if the block at
|
||||
* that position matches the filter. Block information is not provided
|
||||
* as getting a BaseBlock has unneeded overhead in most block querying
|
||||
* situations (enumerating a chest's contents is a waste, for example).
|
||||
*
|
||||
* @param editSession
|
||||
* @param pos
|
||||
* @return
|
||||
*/
|
||||
boolean matches(EditSession editSession, Vector pos);
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package com.sk89q.worldedit.masks;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.function.mask.NoiseFilter;
|
||||
|
||||
/**
|
||||
* @deprecated See {@link NoiseFilter}
|
||||
*/
|
||||
@Deprecated
|
||||
public class RandomMask extends AbstractMask {
|
||||
private final double ratio;
|
||||
|
||||
public RandomMask(double ratio) {
|
||||
this.ratio = ratio;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(EditSession editSession, Vector pos) {
|
||||
return Math.random() < ratio;
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.worldedit.masks;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
/**
|
||||
* @deprecated See {@link com.sk89q.worldedit.function.mask.RegionMask}
|
||||
*/
|
||||
@Deprecated
|
||||
public class RegionMask extends AbstractMask {
|
||||
private final Region region;
|
||||
|
||||
public RegionMask(Region region) {
|
||||
this.region = region.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(EditSession editSession, Vector pos) {
|
||||
return region.contains(pos);
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
package com.sk89q.worldedit.masks;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BlockType;
|
||||
|
||||
/**
|
||||
* @deprecated See {@link com.sk89q.worldedit.function.mask.SolidBlockMask}
|
||||
*/
|
||||
@Deprecated
|
||||
public class SolidBlockMask extends AbstractMask {
|
||||
@Override
|
||||
public boolean matches(EditSession editSession, Vector pos) {
|
||||
return !BlockType.canPassThrough(editSession.getBlockType(pos), editSession.getBlockData(pos));
|
||||
}
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.worldedit.masks;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 1337
|
||||
*/
|
||||
public class UnderOverlayMask extends AbstractMask {
|
||||
private final int yMod;
|
||||
private Mask mask;
|
||||
|
||||
@Deprecated
|
||||
public UnderOverlayMask(Set<Integer> ids, boolean overlay) {
|
||||
this(new BlockTypeMask(ids), overlay);
|
||||
}
|
||||
|
||||
public UnderOverlayMask(Mask mask, boolean overlay) {
|
||||
this.yMod = overlay ? -1 : 1;
|
||||
this.mask = mask;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void addAll(Set<Integer> ids) {
|
||||
if (mask instanceof BlockMask) {
|
||||
final BlockMask blockTypeMask = (BlockMask) mask;
|
||||
for (Integer id : ids) {
|
||||
blockTypeMask.add(new BaseBlock(id));
|
||||
}
|
||||
} else if (mask instanceof ExistingBlockMask) {
|
||||
final BlockMask blockMask = new BlockMask();
|
||||
for (int type : ids) {
|
||||
blockMask.add(new BaseBlock(type));
|
||||
}
|
||||
mask = blockMask;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
|
||||
mask.prepare(session, player, target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(EditSession editSession, Vector pos) {
|
||||
return !mask.matches(editSession, pos) && mask.matches(editSession, pos.add(0, yMod, 0));
|
||||
}
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.worldedit.patterns;
|
||||
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
|
||||
/**
|
||||
* @deprecated Will be removed in the future -- there is no replacement
|
||||
*/
|
||||
@Deprecated
|
||||
public class BlockChance {
|
||||
/**
|
||||
* Block.
|
||||
*/
|
||||
private BaseBlock block;
|
||||
/**
|
||||
* Chance. Can be any positive value.
|
||||
*/
|
||||
private double chance;
|
||||
|
||||
/**
|
||||
* Construct the object.
|
||||
*
|
||||
* @param block
|
||||
* @param chance
|
||||
*/
|
||||
public BlockChance(BaseBlock block, double chance) {
|
||||
this.block = block;
|
||||
this.chance = chance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the block
|
||||
*/
|
||||
public BaseBlock getBlock() {
|
||||
return block;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the chance
|
||||
*/
|
||||
public double getChance() {
|
||||
return chance;
|
||||
}
|
||||
}
|
@ -1,75 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.worldedit.patterns;
|
||||
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
|
||||
/**
|
||||
* Pattern that repeats the clipboard.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class ClipboardPattern implements Pattern {
|
||||
/**
|
||||
* Clipboard.
|
||||
*/
|
||||
private CuboidClipboard clipboard;
|
||||
/**
|
||||
* Size of the clipboard.
|
||||
*/
|
||||
private Vector size;
|
||||
|
||||
/**
|
||||
* Construct the object.
|
||||
*
|
||||
* @param clipboard
|
||||
*/
|
||||
public ClipboardPattern(CuboidClipboard clipboard) {
|
||||
this.clipboard = clipboard;
|
||||
this.size = clipboard.getSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get next block.
|
||||
*
|
||||
* @param pos
|
||||
* @return
|
||||
*/
|
||||
public BaseBlock next(Vector pos) {
|
||||
return next(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get next block.
|
||||
*
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @return
|
||||
*/
|
||||
public BaseBlock next(int x, int y, int z) {
|
||||
int xp = Math.abs(x) % size.getBlockX();
|
||||
int yp = Math.abs(y) % size.getBlockY();
|
||||
int zp = Math.abs(z) % size.getBlockZ();
|
||||
|
||||
return clipboard.getPoint(new Vector(xp, yp, zp));
|
||||
}
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.worldedit.patterns;
|
||||
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
|
||||
/**
|
||||
* @deprecated See {@link com.sk89q.worldedit.function.pattern.Pattern}
|
||||
*/
|
||||
@Deprecated
|
||||
public interface Pattern {
|
||||
/**
|
||||
* Get a block for a position. This return value of this method does
|
||||
* not have to be consistent for the same position.
|
||||
*
|
||||
* @param pos
|
||||
* @return
|
||||
*/
|
||||
public BaseBlock next(Vector pos);
|
||||
|
||||
/**
|
||||
* Get a block for a position. This return value of this method does
|
||||
* not have to be consistent for the same position.
|
||||
*
|
||||
* @param pos
|
||||
* @return
|
||||
*/
|
||||
public BaseBlock next(int x, int y, int z);
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.worldedit.patterns;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.function.pattern.RandomPattern;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* @deprecated See {@link RandomPattern}
|
||||
*/
|
||||
@Deprecated
|
||||
public class RandomFillPattern implements Pattern {
|
||||
/**
|
||||
* Random number generator.
|
||||
*/
|
||||
private static final Random random = new Random();
|
||||
/**
|
||||
* Blocks and their proportions.
|
||||
*/
|
||||
private List<BlockChance> blocks;
|
||||
|
||||
/**
|
||||
* Construct the object.
|
||||
*
|
||||
* @param blocks
|
||||
*/
|
||||
public RandomFillPattern(List<BlockChance> blocks) {
|
||||
double max = 0;
|
||||
|
||||
for (BlockChance block : blocks) {
|
||||
max += block.getChance();
|
||||
}
|
||||
|
||||
List<BlockChance> finalBlocks = new ArrayList<BlockChance>();
|
||||
|
||||
double i = 0;
|
||||
|
||||
for (BlockChance block : blocks) {
|
||||
double v = block.getChance() / max;
|
||||
i += v;
|
||||
finalBlocks.add(new BlockChance(block.getBlock(), i));
|
||||
}
|
||||
|
||||
this.blocks = finalBlocks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get next block.
|
||||
*
|
||||
* @param pos
|
||||
* @return
|
||||
*/
|
||||
public BaseBlock next(Vector pos) {
|
||||
double r = random.nextDouble();
|
||||
|
||||
for (BlockChance block : blocks) {
|
||||
if (r <= block.getChance()) {
|
||||
return block.getBlock();
|
||||
}
|
||||
}
|
||||
|
||||
throw new RuntimeException("ProportionalFillPattern");
|
||||
}
|
||||
|
||||
public BaseBlock next(int x, int y, int z) {
|
||||
return next(null);
|
||||
}
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* 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.worldedit.patterns;
|
||||
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||
|
||||
/**
|
||||
* @deprecated See {@link BlockPattern}
|
||||
*/
|
||||
@Deprecated
|
||||
public class SingleBlockPattern implements Pattern {
|
||||
/**
|
||||
* Block type.
|
||||
*/
|
||||
private BaseBlock block;
|
||||
|
||||
/**
|
||||
* Construct the object.
|
||||
*
|
||||
* @param block
|
||||
*/
|
||||
public SingleBlockPattern(BaseBlock block) {
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get next block.
|
||||
*
|
||||
* @param pos
|
||||
* @return
|
||||
*/
|
||||
public BaseBlock next(Vector pos) {
|
||||
return block;
|
||||
}
|
||||
|
||||
public BaseBlock next(int x, int y, int z) {
|
||||
return block;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the block.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public BaseBlock getBlock() {
|
||||
return block;
|
||||
}
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
#
|
||||
# WorldEdit's configuration file
|
||||
#
|
||||
# About editing this file:
|
||||
# - DO NOT USE TABS. You MUST use spaces or Bukkit will complain. If
|
||||
# you use an editor like Notepad++ (recommended for Windows users), you
|
||||
# must configure it to "replace tabs with spaces." In Notepad++, this can
|
||||
# be changed in Settings > Preferences > Language Menu.
|
||||
# - Don't get rid of the indents. They are indented so some entries are
|
||||
# in categories (like "max-blocks-changed" is in the "limits"
|
||||
# category.
|
||||
# - If you want to check the format of this file before putting it
|
||||
# into WorldEdit, paste it into http://yaml-online-parser.appspot.com/
|
||||
# and see if it gives "ERROR:".
|
||||
# - Lines starting with # are commentsand so they are ignored.
|
||||
#
|
||||
|
||||
limits:
|
||||
allow-extra-data-values: false
|
||||
max-blocks-changed:
|
||||
default: -1
|
||||
maximum: -1
|
||||
max-polygonal-points:
|
||||
default: -1
|
||||
maximum: 20
|
||||
max-radius: -1
|
||||
max-super-pickaxe-size: 5
|
||||
max-brush-radius: 5
|
||||
butcher-radius:
|
||||
default: -1
|
||||
maximum: -1
|
||||
disallowed-blocks: [6, 7, 14, 15, 16, 26, 27, 28, 29, 39, 31, 32, 33, 34, 36, 37, 38, 39, 40, 46, 50, 51, 56, 59, 69, 73, 74, 75, 76, 77, 81, 83]
|
||||
|
||||
use-inventory:
|
||||
enable: false
|
||||
allow-override: true
|
||||
creative-mode-overrides: false
|
||||
|
||||
logging:
|
||||
log-commands: false
|
||||
file: worldedit.log
|
||||
|
||||
super-pickaxe:
|
||||
drop-items: true
|
||||
many-drop-items: false
|
||||
|
||||
snapshots:
|
||||
directory:
|
||||
|
||||
navigation-wand:
|
||||
item: 345
|
||||
max-distance: 100
|
||||
|
||||
scripting:
|
||||
timeout: 3000
|
||||
dir: craftscripts
|
||||
|
||||
saving:
|
||||
dir: schematics
|
||||
|
||||
files:
|
||||
allow-symbolic-links: false
|
||||
|
||||
history:
|
||||
size: 15
|
||||
expiration: 10
|
||||
|
||||
wand-item: 271
|
||||
shell-save-type:
|
||||
no-double-slash: false
|
||||
no-op-permissions: false
|
||||
debug: false
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,7 +0,0 @@
|
||||
name: WorldEdit
|
||||
main: com.sk89q.worldedit.bukkit.WorldEditPlugin
|
||||
version: ${project.version}
|
||||
softdepend: [Spout] #hack to fix trove errors
|
||||
|
||||
# Permissions aren't here. Read http://wiki.sk89q.com/wiki/WEPIF/DinnerPerms
|
||||
# for how WorldEdit permissions actually work.
|
Reference in New Issue
Block a user