Merge branch 'master' into feature/mapping

Conflicts:
	src/bukkit/java/com/sk89q/worldedit/bukkit/BukkitWorld.java
	src/main/java/com/sk89q/worldedit/command/SelectionCommands.java
This commit is contained in:
sk89q
2014-07-06 21:06:10 -07:00
22 changed files with 409 additions and 62 deletions

View File

@ -42,6 +42,26 @@ public class ParserContext {
private boolean restricted = true;
private boolean preferringWildcard;
/**
* Create a new instance.
*/
public ParserContext() {
}
/**
* Creates a copy of another instance.
*
* @param other the other instance
*/
public ParserContext(ParserContext other) {
setExtent(other.getExtent());
setSession(other.getSession());
setWorld(other.getWorld());
setActor(other.getActor());
setRestricted(other.isRestricted());
setPreferringWildcard(other.isPreferringWildcard());
}
/**
* Get the {@link Extent} set on this context.
*

View File

@ -65,6 +65,11 @@ public enum Capability {
*/
PERMISSIONS,
/**
* The capability of a platform to dispatch WorldEditCUI events.
*/
WORLDEDIT_CUI,
/**
* The capability of a platform to perform modifications to a world.
*/

View File

@ -33,6 +33,7 @@ import com.sk89q.worldedit.event.platform.CommandEvent;
import com.sk89q.worldedit.event.platform.CommandSuggestionEvent;
import com.sk89q.worldedit.internal.command.ActorAuthorizer;
import com.sk89q.worldedit.internal.command.CommandLoggingHandler;
import com.sk89q.worldedit.internal.command.UserCommandCompleter;
import com.sk89q.worldedit.internal.command.WorldEditBinding;
import com.sk89q.worldedit.internal.command.WorldEditExceptionConverter;
import com.sk89q.worldedit.session.request.Request;
@ -93,6 +94,7 @@ public final class CommandManager {
// Set up the commands manager
ParametricBuilder builder = new ParametricBuilder();
builder.setAuthorizer(new ActorAuthorizer());
builder.setDefaultCompleter(new UserCommandCompleter(platformManager));
builder.addBinding(new WorldEditBinding(worldEdit));
builder.addExceptionConverter(new WorldEditExceptionConverter(worldEdit));
builder.addInvokeListener(new LegacyCommandsHandler());

View File

@ -0,0 +1,36 @@
/*
* 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 Lesser 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 Lesser 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/>.
*/
package com.sk89q.worldedit.extension.platform;
import java.util.Collection;
/**
* Implements a platform with multiple connected users.
*/
public interface MultiUserPlatform extends Platform {
/**
* Get a list of connected users.
*
* @return a list of connected users
*/
Collection<Actor> getConnectedUsers();
}

View File

@ -240,7 +240,12 @@ public class PlatformManager {
permActor = player;
}
return (T) new PlayerProxy(player, permActor, getWorldForEditing(player.getWorld()));
Player cuiActor = queryCapability(Capability.WORLDEDIT_CUI).matchPlayer(player);
if (cuiActor == null) {
cuiActor = player;
}
return (T) new PlayerProxy(player, permActor, cuiActor, getWorldForEditing(player.getWorld()));
} else {
return base;
}

View File

@ -24,6 +24,7 @@ import com.sk89q.worldedit.WorldVector;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.internal.cui.CUIEvent;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World;
@ -33,14 +34,17 @@ class PlayerProxy extends AbstractPlayerActor {
private final Player basePlayer;
private final Actor permActor;
private final Actor cuiActor;
private final World world;
PlayerProxy(Player basePlayer, Actor permActor, World world) {
PlayerProxy(Player basePlayer, Actor permActor, Actor cuiActor, World world) {
checkNotNull(basePlayer);
checkNotNull(permActor);
checkNotNull(cuiActor);
checkNotNull(world);
this.basePlayer = basePlayer;
this.permActor = permActor;
this.cuiActor = cuiActor;
this.world = world;
}
@ -128,4 +132,9 @@ class PlayerProxy extends AbstractPlayerActor {
public boolean hasPermission(String perm) {
return permActor.hasPermission(perm);
}
@Override
public void dispatchCUIEvent(CUIEvent event) {
cuiActor.dispatchCUIEvent(event);
}
}

View File

@ -132,7 +132,10 @@ class DefaultMaskParser extends InputParser<Mask> {
}
default:
return new BlockMask(extent, worldEdit.getBlockRegistry().parseFromListInput(component, context));
ParserContext tempContext = new ParserContext(context);
tempContext.setRestricted(false);
tempContext.setPreferringWildcard(true);
return new BlockMask(extent, worldEdit.getBlockRegistry().parseFromListInput(component, tempContext));
}
}