diff options
author | md_5 <git@md-5.net> | 2017-06-26 08:27:25 +1000 |
---|---|---|
committer | md_5 <git@md-5.net> | 2017-06-26 08:27:25 +1000 |
commit | de7608559660c92d43e52099325155fa2758561b (patch) | |
tree | 69d53151774e63b092467f6de83793e0a49b8f58 /nms-patches/CommandBlockListenerAbstract.patch | |
parent | 258575110f7c0abc0e3c8b85254b22b28fca27b1 (diff) | |
download | craftbukkit-de7608559660c92d43e52099325155fa2758561b.tar craftbukkit-de7608559660c92d43e52099325155fa2758561b.tar.gz craftbukkit-de7608559660c92d43e52099325155fa2758561b.tar.lz craftbukkit-de7608559660c92d43e52099325155fa2758561b.tar.xz craftbukkit-de7608559660c92d43e52099325155fa2758561b.zip |
SPIGOT-3376: Fix nested functions
Diffstat (limited to 'nms-patches/CommandBlockListenerAbstract.patch')
-rw-r--r-- | nms-patches/CommandBlockListenerAbstract.patch | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/nms-patches/CommandBlockListenerAbstract.patch b/nms-patches/CommandBlockListenerAbstract.patch index da8ee32a..ba41673f 100644 --- a/nms-patches/CommandBlockListenerAbstract.patch +++ b/nms-patches/CommandBlockListenerAbstract.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/CommandBlockListenerAbstract.java +++ b/net/minecraft/server/CommandBlockListenerAbstract.java -@@ -4,6 +4,13 @@ +@@ -4,6 +4,14 @@ import java.util.Date; import javax.annotation.Nullable; @@ -9,12 +9,13 @@ +import org.bukkit.craftbukkit.command.VanillaCommandWrapper; +import com.google.common.base.Joiner; +import java.util.logging.Level; ++import org.bukkit.command.CommandSender; +// CraftBukkit end + public abstract class CommandBlockListenerAbstract implements ICommandListener { private static final SimpleDateFormat a = new SimpleDateFormat("HH:mm:ss"); -@@ -15,6 +22,7 @@ +@@ -15,6 +23,7 @@ private String g = ""; private String h = "@"; private final CommandObjectiveExecutor i = new CommandObjectiveExecutor(); @@ -22,7 +23,7 @@ public CommandBlockListenerAbstract() {} -@@ -107,7 +115,9 @@ +@@ -107,7 +116,9 @@ if (minecraftserver != null && minecraftserver.M() && minecraftserver.getEnableCommandBlock()) { try { this.f = null; @@ -33,7 +34,7 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Executing command block"); CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Command to be executed"); -@@ -149,6 +159,138 @@ +@@ -149,6 +160,163 @@ } } @@ -167,6 +168,31 @@ + + return commands; + } ++ ++ public static CommandSender unwrapSender(ICommandListener listener) { ++ org.bukkit.command.CommandSender sender = null; ++ while (sender == null) { ++ if (listener instanceof DedicatedServer) { ++ sender = ((DedicatedServer) listener).console; ++ } else if (listener instanceof RemoteControlCommandListener) { ++ sender = ((DedicatedServer) listener).remoteConsole; ++ } else if (listener instanceof CommandBlockListenerAbstract) { ++ sender = ((CommandBlockListenerAbstract) listener).sender; ++ } else if (listener instanceof CustomFunctionData.CustomFunctionListener) { ++ sender = ((CustomFunctionData.CustomFunctionListener) listener).sender; ++ } else if (listener instanceof CommandListenerWrapper) { ++ listener = ((CommandListenerWrapper) listener).base; // Search deeper ++ } else if (VanillaCommandWrapper.lastSender != null) { ++ sender = VanillaCommandWrapper.lastSender; ++ } else if (listener.f() != null) { ++ sender = listener.f().getBukkitEntity(); ++ } else { ++ throw new RuntimeException("Unhandled executor " + listener.getClass().getSimpleName()); ++ } ++ } ++ ++ return sender; ++ } + // CraftBukkit end + public String getName() { |