From 9381beb417ae62fc3f7da401921003f0469d54ae Mon Sep 17 00:00:00 2001 From: sk89q Date: Fri, 27 Jun 2014 18:34:58 -0700 Subject: [PATCH] Actor should not have getWorld(). --- .../com/sk89q/worldedit/bukkit/BukkitCommandSender.java | 5 ----- .../com/sk89q/worldedit/extension/platform/Actor.java | 7 ------- .../worldedit/extension/platform/PlatformManager.java | 2 +- .../internal/command/CommandLoggingHandler.java | 4 ++-- .../worldedit/internal/command/WorldEditBinding.java | 9 +++++++-- 5 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/bukkit/java/com/sk89q/worldedit/bukkit/BukkitCommandSender.java b/src/bukkit/java/com/sk89q/worldedit/bukkit/BukkitCommandSender.java index 9d4c252b7..a8dc5adc2 100644 --- a/src/bukkit/java/com/sk89q/worldedit/bukkit/BukkitCommandSender.java +++ b/src/bukkit/java/com/sk89q/worldedit/bukkit/BukkitCommandSender.java @@ -117,9 +117,4 @@ class BukkitCommandSender implements Actor { public void dispatchCUIEvent(CUIEvent event) { } - @Override - public LocalWorld getWorld() { - throw new PlayerNeededException(); - } - } diff --git a/src/main/java/com/sk89q/worldedit/extension/platform/Actor.java b/src/main/java/com/sk89q/worldedit/extension/platform/Actor.java index 9dfb769bf..f9912de1a 100644 --- a/src/main/java/com/sk89q/worldedit/extension/platform/Actor.java +++ b/src/main/java/com/sk89q/worldedit/extension/platform/Actor.java @@ -37,13 +37,6 @@ public interface Actor { */ String getName(); - /** - * Get the actor's world. - * - * @return the world - */ - World getWorld(); - /** * Print a message. * diff --git a/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java b/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java index 518bbb9f8..87ec055da 100644 --- a/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java +++ b/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java @@ -240,7 +240,7 @@ public class PlatformManager { permActor = player; } - return (T) new PlayerProxy(player, permActor, getWorldForEditing(base.getWorld())); + return (T) new PlayerProxy(player, permActor, getWorldForEditing(player.getWorld())); } else { return base; } diff --git a/src/main/java/com/sk89q/worldedit/internal/command/CommandLoggingHandler.java b/src/main/java/com/sk89q/worldedit/internal/command/CommandLoggingHandler.java index 2cd72dfaa..b09a26bee 100644 --- a/src/main/java/com/sk89q/worldedit/internal/command/CommandLoggingHandler.java +++ b/src/main/java/com/sk89q/worldedit/internal/command/CommandLoggingHandler.java @@ -89,7 +89,7 @@ public class CommandLoggingHandler extends AbstractInvokeListener implements Inv builder.append("WorldEdit: ").append(sender.getName()); if (sender.isPlayer()) { - builder.append(" (in \"" + sender.getWorld().getName() + "\")"); + builder.append(" (in \"" + player.getWorld().getName() + "\")"); } builder.append(": ").append(context.getCommand()); @@ -126,7 +126,7 @@ public class CommandLoggingHandler extends AbstractInvokeListener implements Inv case REGION: try { builder.append(" - Region: ") - .append(session.getSelection(sender.getWorld())); + .append(session.getSelection(player.getWorld())); } catch (IncompleteRegionException e) { break; } diff --git a/src/main/java/com/sk89q/worldedit/internal/command/WorldEditBinding.java b/src/main/java/com/sk89q/worldedit/internal/command/WorldEditBinding.java index 5cd4f5d81..8d881f5a5 100644 --- a/src/main/java/com/sk89q/worldedit/internal/command/WorldEditBinding.java +++ b/src/main/java/com/sk89q/worldedit/internal/command/WorldEditBinding.java @@ -20,6 +20,7 @@ package com.sk89q.worldedit.internal.command; import com.sk89q.worldedit.*; +import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.extension.platform.Actor; @@ -169,7 +170,9 @@ public class WorldEditBinding extends BindingHelper { Actor actor = context.getContext().getLocals().get(Actor.class); ParserContext parserContext = new ParserContext(); parserContext.setActor(context.getContext().getLocals().get(Actor.class)); - parserContext.setWorld(actor.getWorld()); + if (actor instanceof Entity) { + parserContext.setWorld(((Entity) actor).getWorld()); + } parserContext.setSession(worldEdit.getSessionManager().get(actor)); return worldEdit.getPatternRegistry().parseFromInput(context.next(), parserContext); } @@ -189,7 +192,9 @@ public class WorldEditBinding extends BindingHelper { Actor actor = context.getContext().getLocals().get(Actor.class); ParserContext parserContext = new ParserContext(); parserContext.setActor(context.getContext().getLocals().get(Actor.class)); - parserContext.setWorld(actor.getWorld()); + if (actor instanceof Entity) { + parserContext.setWorld(((Entity) actor).getWorld()); + } parserContext.setSession(worldEdit.getSessionManager().get(actor)); return worldEdit.getMaskRegistry().parseFromInput(context.next(), parserContext); }