3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-09 21:10:05 +01:00

Adds Platform support for WorldEdit CUI

Dieser Commit ist enthalten in:
Wyatt Childers 2014-07-06 20:13:27 -04:00
Ursprung ad9b8ce3b1
Commit bc92e43be0
5 geänderte Dateien mit 23 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -168,6 +168,7 @@ public class BukkitServerInterface extends ServerInterface {
public Map<Capability, Preference> getCapabilities() {
Map<Capability, Preference> capabilities = new EnumMap<Capability, Preference>(Capability.class);
capabilities.put(Capability.CONFIGURATION, Preference.NORMAL);
capabilities.put(Capability.WORLDEDIT_CUI, Preference.NORMAL);
capabilities.put(Capability.GAME_HOOKS, Preference.PREFERRED);
capabilities.put(Capability.PERMISSIONS, Preference.PREFERRED);
capabilities.put(Capability.USER_COMMANDS, Preference.PREFERRED);

Datei anzeigen

@ -205,6 +205,7 @@ class ForgePlatform extends ServerInterface {
public Map<Capability, Preference> getCapabilities() {
Map<Capability, Preference> capabilities = new EnumMap<Capability, Preference>(Capability.class);
capabilities.put(Capability.CONFIGURATION, Preference.PREFER_OTHERS);
capabilities.put(Capability.WORLDEDIT_CUI, Preference.NORMAL);
capabilities.put(Capability.GAME_HOOKS, Preference.NORMAL);
capabilities.put(Capability.PERMISSIONS, Preference.PREFER_OTHERS);
capabilities.put(Capability.USER_COMMANDS, Preference.NORMAL);

Datei anzeigen

@ -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.
*/

Datei anzeigen

@ -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;
}

Datei anzeigen

@ -23,6 +23,7 @@ import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldVector;
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;
@ -32,14 +33,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;
}
@ -122,4 +126,9 @@ class PlayerProxy extends AbstractPlayerActor {
public boolean hasPermission(String perm) {
return permActor.hasPermission(perm);
}
@Override
public void dispatchCUIEvent(CUIEvent event) {
cuiActor.dispatchCUIEvent(event);
}
}