Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 12:30:06 +01:00
Re-enable selectors for players and the console using vanilla commands
Dieser Commit ist enthalten in:
Ursprung
84699b36a8
Commit
b13fd35165
@ -1,5 +1,5 @@
|
|||||||
--- ../work/decompile-8eb82bde//net/minecraft/server/CommandBlockListenerAbstract.java 2014-12-05 23:10:24.921614234 +0000
|
--- ../work/decompile-8eb82bde/net/minecraft/server/CommandBlockListenerAbstract.java 2014-12-11 20:04:50.493619968 +0000
|
||||||
+++ src/main/java/net/minecraft/server/CommandBlockListenerAbstract.java 2014-12-05 23:04:53.325621594 +0000
|
+++ src/main/java/net/minecraft/server/CommandBlockListenerAbstract.java 2014-12-11 20:02:45.005621331 +0000
|
||||||
@@ -4,6 +4,13 @@
|
@@ -4,6 +4,13 @@
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
@ -34,7 +34,7 @@
|
|||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
CrashReport crashreport = CrashReport.a(throwable, "Executing command block");
|
CrashReport crashreport = CrashReport.a(throwable, "Executing command block");
|
||||||
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Command to be executed");
|
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Command to be executed");
|
||||||
@@ -91,8 +102,123 @@
|
@@ -91,8 +102,129 @@
|
||||||
} else {
|
} else {
|
||||||
this.b = 0;
|
this.b = 0;
|
||||||
}
|
}
|
||||||
@ -69,7 +69,13 @@
|
|||||||
+ commandBlockCommand = commandMap.getCommand("minecraft:" + args[0]);
|
+ commandBlockCommand = commandMap.getCommand("minecraft:" + args[0]);
|
||||||
+ }
|
+ }
|
||||||
+ if (commandBlockCommand instanceof VanillaCommandWrapper) {
|
+ if (commandBlockCommand instanceof VanillaCommandWrapper) {
|
||||||
+ return ((VanillaCommandWrapper) commandBlockCommand).dispatchVanillaCommandBlock(sender, command);
|
+ command = command.trim();
|
||||||
|
+ if (command.startsWith("/")) {
|
||||||
|
+ command = command.substring(1);
|
||||||
|
+ }
|
||||||
|
+ String as[] = command.split(" ");
|
||||||
|
+ as = VanillaCommandWrapper.dropFirstArgument(as);
|
||||||
|
+ return ((VanillaCommandWrapper) commandBlockCommand).dispatchVanillaCommand(sender, as);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ // Make sure this is a valid command
|
+ // Make sure this is a valid command
|
||||||
|
@ -1,18 +1,6 @@
|
|||||||
--- ../work/decompile-8eb82bde//net/minecraft/server/PlayerSelector.java 2014-12-02 20:23:52.649621319 +0000
|
--- ../work/decompile-8eb82bde/net/minecraft/server/PlayerSelector.java 2014-12-11 20:04:51.273619960 +0000
|
||||||
+++ src/main/java/net/minecraft/server/PlayerSelector.java 2014-12-02 20:22:46.409622789 +0000
|
+++ src/main/java/net/minecraft/server/PlayerSelector.java 2014-12-11 20:03:19.893620952 +0000
|
||||||
@@ -52,6 +52,11 @@
|
@@ -97,7 +97,7 @@
|
||||||
}
|
|
||||||
|
|
||||||
public static List getPlayers(ICommandListener icommandlistener, String s, Class oclass) {
|
|
||||||
+ // CraftBukkit start - disable playerselections for ICommandListeners other than command blocks
|
|
||||||
+ if (!(icommandlistener instanceof CommandBlockListenerAbstract)) {
|
|
||||||
+ return com.google.common.collect.ImmutableList.of();
|
|
||||||
+ }
|
|
||||||
+ // CraftBukkit end
|
|
||||||
Matcher matcher = PlayerSelector.a.matcher(s);
|
|
||||||
|
|
||||||
if (matcher.matches() && icommandlistener.a(1, "@")) {
|
|
||||||
@@ -97,7 +102,7 @@
|
|
||||||
if (h(map)) {
|
if (h(map)) {
|
||||||
arraylist.add(icommandlistener.getWorld());
|
arraylist.add(icommandlistener.getWorld());
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.bukkit.craftbukkit.command;
|
package org.bukkit.craftbukkit.command;
|
||||||
|
|
||||||
|
import com.google.common.base.Joiner;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -39,23 +40,7 @@ public final class VanillaCommandWrapper extends VanillaCommand {
|
|||||||
if (!testPermission(sender)) return true;
|
if (!testPermission(sender)) return true;
|
||||||
|
|
||||||
ICommandListener icommandlistener = getListener(sender);
|
ICommandListener icommandlistener = getListener(sender);
|
||||||
// Some commands use the worldserver variable but we leave it full of null values,
|
dispatchVanillaCommand(icommandlistener, args);
|
||||||
// so we must temporarily populate it with the world of the commandsender
|
|
||||||
WorldServer[] prev = MinecraftServer.getServer().worldServer;
|
|
||||||
MinecraftServer.getServer().worldServer = new WorldServer[]{(WorldServer) icommandlistener.getWorld()};
|
|
||||||
try {
|
|
||||||
vanillaCommand.execute(icommandlistener, args);
|
|
||||||
} catch (ExceptionUsage exceptionusage) {
|
|
||||||
ChatMessage chatmessage = new ChatMessage("commands.generic.usage", new Object[] {new ChatMessage(exceptionusage.getMessage(), exceptionusage.getArgs())});
|
|
||||||
chatmessage.getChatModifier().setColor(EnumChatFormat.RED);
|
|
||||||
icommandlistener.sendMessage(chatmessage);
|
|
||||||
} catch (CommandException commandexception) {
|
|
||||||
ChatMessage chatmessage = new ChatMessage(commandexception.getMessage(), commandexception.getArgs());
|
|
||||||
chatmessage.getChatModifier().setColor(EnumChatFormat.RED);
|
|
||||||
icommandlistener.sendMessage(chatmessage);
|
|
||||||
} finally {
|
|
||||||
MinecraftServer.getServer().worldServer = prev;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,14 +52,8 @@ public final class VanillaCommandWrapper extends VanillaCommand {
|
|||||||
return (List<String>) vanillaCommand.tabComplete(getListener(sender), args, new BlockPosition(0, 0, 0));
|
return (List<String>) vanillaCommand.tabComplete(getListener(sender), args, new BlockPosition(0, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int dispatchVanillaCommandBlock(ICommandListener icommandlistener, String s) {
|
public final int dispatchVanillaCommand(ICommandListener icommandlistener, String[] as) {
|
||||||
// Copied from net.minecraft.server.CommandHandler
|
// Copied from net.minecraft.server.CommandHandler
|
||||||
s = s.trim();
|
|
||||||
if (s.startsWith("/")) {
|
|
||||||
s = s.substring(1);
|
|
||||||
}
|
|
||||||
String as[] = s.split(" ");
|
|
||||||
as = dropFirstArgument(as);
|
|
||||||
int i = getPlayerListSize(as);
|
int i = getPlayerListSize(as);
|
||||||
int j = 0;
|
int j = 0;
|
||||||
// Some commands use the worldserver variable but we leave it full of null values,
|
// Some commands use the worldserver variable but we leave it full of null values,
|
||||||
@ -174,7 +153,7 @@ public final class VanillaCommandWrapper extends VanillaCommand {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String[] dropFirstArgument(String as[]) {
|
public static String[] dropFirstArgument(String as[]) {
|
||||||
String as1[] = new String[as.length - 1];
|
String as1[] = new String[as.length - 1];
|
||||||
for (int i = 1; i < as.length; i++) {
|
for (int i = 1; i < as.length; i++) {
|
||||||
as1[i - 1] = as[i];
|
as1[i - 1] = as[i];
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren