mirror of
https://github.com/PaperMC/Paper.git
synced 2025-02-03 14:11:27 +01:00
SPIGOT-7467: Add getAddress to RemoteConsoleCommandSender
By: md_5 <git@md-5.net>
This commit is contained in:
parent
6fdc83ddd9
commit
a16df1b04c
@ -34,7 +34,7 @@
|
||||
public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTask> implements ICommandListener, AutoCloseable {
|
||||
|
||||
public static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -249,6 +276,20 @@
|
||||
@@ -249,6 +276,19 @@
|
||||
protected SaveData worldData;
|
||||
private volatile boolean isSaving;
|
||||
|
||||
@ -43,7 +43,6 @@
|
||||
+ public org.bukkit.craftbukkit.CraftServer server;
|
||||
+ public OptionSet options;
|
||||
+ public org.bukkit.command.ConsoleCommandSender console;
|
||||
+ public org.bukkit.command.RemoteConsoleCommandSender remoteConsole;
|
||||
+ public ConsoleReader reader;
|
||||
+ public static int currentTick = (int) (System.currentTimeMillis() / 50);
|
||||
+ public java.util.Queue<Runnable> processQueue = new java.util.concurrent.ConcurrentLinkedQueue<Runnable>();
|
||||
@ -55,7 +54,7 @@
|
||||
public static <S extends MinecraftServer> S spin(Function<Thread, S> function) {
|
||||
AtomicReference<S> atomicreference = new AtomicReference();
|
||||
Thread thread = new Thread(() -> {
|
||||
@@ -262,14 +303,14 @@
|
||||
@@ -262,14 +302,14 @@
|
||||
thread.setPriority(8);
|
||||
}
|
||||
|
||||
@ -72,7 +71,7 @@
|
||||
super("Server");
|
||||
this.metricsRecorder = InactiveMetricsRecorder.INSTANCE;
|
||||
this.profiler = this.metricsRecorder.getProfiler();
|
||||
@@ -289,7 +330,7 @@
|
||||
@@ -289,7 +329,7 @@
|
||||
this.frameTimer = new CircularTimer();
|
||||
this.registries = worldstem.registries();
|
||||
this.worldData = worldstem.worldData();
|
||||
@ -81,7 +80,7 @@
|
||||
throw new IllegalStateException("Missing Overworld dimension data");
|
||||
} else {
|
||||
this.proxy = proxy;
|
||||
@@ -312,13 +353,40 @@
|
||||
@@ -312,13 +352,40 @@
|
||||
this.serverThread = thread;
|
||||
this.executor = SystemUtils.backgroundExecutor();
|
||||
}
|
||||
@ -123,7 +122,7 @@
|
||||
ScoreboardServer scoreboardserver1 = this.getScoreboard();
|
||||
|
||||
Objects.requireNonNull(scoreboardserver1);
|
||||
@@ -327,7 +395,7 @@
|
||||
@@ -327,7 +394,7 @@
|
||||
|
||||
protected abstract boolean initServer() throws IOException;
|
||||
|
||||
@ -132,7 +131,7 @@
|
||||
if (!JvmProfiler.INSTANCE.isRunning()) {
|
||||
;
|
||||
}
|
||||
@@ -335,12 +403,8 @@
|
||||
@@ -335,12 +402,8 @@
|
||||
boolean flag = false;
|
||||
ProfiledDuration profiledduration = JvmProfiler.INSTANCE.onWorldLoadedStarted();
|
||||
|
||||
@ -146,7 +145,7 @@
|
||||
if (profiledduration != null) {
|
||||
profiledduration.finish();
|
||||
}
|
||||
@@ -355,25 +419,183 @@
|
||||
@@ -355,25 +418,183 @@
|
||||
|
||||
}
|
||||
|
||||
@ -345,7 +344,7 @@
|
||||
|
||||
if (!iworlddataserver.isInitialized()) {
|
||||
try {
|
||||
@@ -397,30 +619,8 @@
|
||||
@@ -397,30 +618,8 @@
|
||||
iworlddataserver.setInitialized(true);
|
||||
}
|
||||
|
||||
@ -377,7 +376,7 @@
|
||||
|
||||
private static void setInitialSpawn(WorldServer worldserver, IWorldDataServer iworlddataserver, boolean flag, boolean flag1) {
|
||||
if (flag1) {
|
||||
@@ -428,6 +628,21 @@
|
||||
@@ -428,6 +627,21 @@
|
||||
} else {
|
||||
ChunkProviderServer chunkproviderserver = worldserver.getChunkSource();
|
||||
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(chunkproviderserver.randomState().sampler().findSpawnPosition());
|
||||
@ -399,7 +398,7 @@
|
||||
int i = chunkproviderserver.getGenerator().getSpawnHeight(worldserver);
|
||||
|
||||
if (i < worldserver.getMinBuildHeight()) {
|
||||
@@ -487,8 +702,11 @@
|
||||
@@ -487,8 +701,11 @@
|
||||
iworlddataserver.setGameType(EnumGamemode.SPECTATOR);
|
||||
}
|
||||
|
||||
@ -413,7 +412,7 @@
|
||||
|
||||
MinecraftServer.LOGGER.info("Preparing start region for dimension {}", worldserver.dimension().location());
|
||||
BlockPosition blockposition = worldserver.getSharedSpawnPos();
|
||||
@@ -497,19 +715,23 @@
|
||||
@@ -497,19 +714,23 @@
|
||||
ChunkProviderServer chunkproviderserver = worldserver.getChunkSource();
|
||||
|
||||
this.nextTickTime = SystemUtils.getMillis();
|
||||
@ -446,7 +445,7 @@
|
||||
ForcedChunk forcedchunk = (ForcedChunk) worldserver1.getDataStorage().get(ForcedChunk::load, "chunks");
|
||||
|
||||
if (forcedchunk != null) {
|
||||
@@ -524,10 +746,17 @@
|
||||
@@ -524,10 +745,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -467,7 +466,7 @@
|
||||
}
|
||||
|
||||
public EnumGamemode getDefaultGameType() {
|
||||
@@ -557,12 +786,16 @@
|
||||
@@ -557,12 +785,16 @@
|
||||
worldserver.save((IProgressUpdate) null, flag1, worldserver.noSave && !flag2);
|
||||
}
|
||||
|
||||
@ -484,7 +483,7 @@
|
||||
if (flag1) {
|
||||
Iterator iterator1 = this.getAllLevels().iterator();
|
||||
|
||||
@@ -597,12 +830,33 @@
|
||||
@@ -597,12 +829,33 @@
|
||||
this.stopServer();
|
||||
}
|
||||
|
||||
@ -518,7 +517,7 @@
|
||||
if (this.getConnection() != null) {
|
||||
this.getConnection().stop();
|
||||
}
|
||||
@@ -612,6 +866,7 @@
|
||||
@@ -612,6 +865,7 @@
|
||||
MinecraftServer.LOGGER.info("Saving players");
|
||||
this.playerList.saveAll();
|
||||
this.playerList.removeAll();
|
||||
@ -526,7 +525,7 @@
|
||||
}
|
||||
|
||||
MinecraftServer.LOGGER.info("Saving worlds");
|
||||
@@ -699,15 +954,16 @@
|
||||
@@ -699,15 +953,16 @@
|
||||
}
|
||||
|
||||
this.nextTickTime = SystemUtils.getMillis();
|
||||
@ -545,7 +544,7 @@
|
||||
MinecraftServer.LOGGER.warn("Can't keep up! Is the server overloaded? Running {}ms or {} ticks behind", i, j);
|
||||
this.nextTickTime += j * 50L;
|
||||
this.lastOverloadWarning = this.nextTickTime;
|
||||
@@ -718,6 +974,7 @@
|
||||
@@ -718,6 +973,7 @@
|
||||
this.debugCommandProfiler = new MinecraftServer.TimeProfiler(SystemUtils.getNanos(), this.tickCount);
|
||||
}
|
||||
|
||||
@ -553,7 +552,7 @@
|
||||
this.nextTickTime += 50L;
|
||||
this.startMetricsRecordingTick();
|
||||
this.profiler.push("tick");
|
||||
@@ -756,6 +1013,12 @@
|
||||
@@ -756,6 +1012,12 @@
|
||||
this.services.profileCache().clearExecutor();
|
||||
}
|
||||
|
||||
@ -566,7 +565,7 @@
|
||||
this.onServerExit();
|
||||
}
|
||||
|
||||
@@ -789,9 +1052,16 @@
|
||||
@@ -789,9 +1051,16 @@
|
||||
}
|
||||
|
||||
private boolean haveTime() {
|
||||
@ -584,7 +583,7 @@
|
||||
protected void waitUntilNextTick() {
|
||||
this.runAllTasks();
|
||||
this.managedBlock(() -> {
|
||||
@@ -836,7 +1106,7 @@
|
||||
@@ -836,7 +1105,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -593,7 +592,7 @@
|
||||
this.getProfiler().incrementCounter("runTask");
|
||||
super.doRunTask(ticktask);
|
||||
}
|
||||
@@ -889,7 +1159,7 @@
|
||||
@@ -889,7 +1158,7 @@
|
||||
this.status = this.buildServerStatus();
|
||||
}
|
||||
|
||||
@ -602,7 +601,7 @@
|
||||
MinecraftServer.LOGGER.debug("Autosave started");
|
||||
this.profiler.push("save");
|
||||
this.saveEverything(true, false, false);
|
||||
@@ -936,22 +1206,39 @@
|
||||
@@ -936,22 +1205,39 @@
|
||||
}
|
||||
|
||||
public void tickChildren(BooleanSupplier booleansupplier) {
|
||||
@ -642,7 +641,7 @@
|
||||
|
||||
this.profiler.push("tick");
|
||||
|
||||
@@ -1031,6 +1318,22 @@
|
||||
@@ -1031,6 +1317,22 @@
|
||||
return (WorldServer) this.levels.get(resourcekey);
|
||||
}
|
||||
|
||||
@ -665,7 +664,7 @@
|
||||
public Set<ResourceKey<World>> levelKeys() {
|
||||
return this.levels.keySet();
|
||||
}
|
||||
@@ -1057,7 +1360,7 @@
|
||||
@@ -1057,7 +1359,7 @@
|
||||
|
||||
@DontObfuscate
|
||||
public String getServerModName() {
|
||||
@ -674,7 +673,7 @@
|
||||
}
|
||||
|
||||
public SystemReport fillSystemReport(SystemReport systemreport) {
|
||||
@@ -1398,11 +1701,11 @@
|
||||
@@ -1398,11 +1700,11 @@
|
||||
public CompletableFuture<Void> reloadResources(Collection<String> collection) {
|
||||
IRegistryCustom.Dimension iregistrycustom_dimension = this.registries.getAccessForLoading(RegistryLayer.RELOADABLE);
|
||||
CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> {
|
||||
@ -688,7 +687,7 @@
|
||||
}, this).thenCompose((immutablelist) -> {
|
||||
ResourceManager resourcemanager = new ResourceManager(EnumResourcePackType.SERVER_DATA, immutablelist);
|
||||
|
||||
@@ -1417,6 +1720,7 @@
|
||||
@@ -1417,6 +1719,7 @@
|
||||
}).thenAcceptAsync((minecraftserver_reloadableresources) -> {
|
||||
this.resources.close();
|
||||
this.resources = minecraftserver_reloadableresources;
|
||||
@ -696,7 +695,7 @@
|
||||
this.packRepository.setSelected(collection);
|
||||
WorldDataConfiguration worlddataconfiguration = new WorldDataConfiguration(getSelectedPacks(this.packRepository), this.worldData.enabledFeatures());
|
||||
|
||||
@@ -1777,7 +2081,7 @@
|
||||
@@ -1777,7 +2080,7 @@
|
||||
try {
|
||||
label51:
|
||||
{
|
||||
@ -705,7 +704,7 @@
|
||||
|
||||
try {
|
||||
arraylist = Lists.newArrayList(NativeModuleLister.listModules());
|
||||
@@ -1827,6 +2131,22 @@
|
||||
@@ -1827,6 +2130,22 @@
|
||||
|
||||
}
|
||||
|
||||
@ -728,7 +727,7 @@
|
||||
private void startMetricsRecordingTick() {
|
||||
if (this.willStartRecordingMetrics) {
|
||||
this.metricsRecorder = ActiveMetricsRecorder.createStarted(new ServerMetricsSamplersProvider(SystemUtils.timeSource, this.isDedicatedServer()), SystemUtils.timeSource, SystemUtils.ioPool(), new MetricsPersister("server"), this.onMetricsRecordingStopped, (path) -> {
|
||||
@@ -1953,8 +2273,30 @@
|
||||
@@ -1953,8 +2272,30 @@
|
||||
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,16 @@
|
||||
public class DedicatedServer extends MinecraftServer implements IMinecraftServer {
|
||||
|
||||
static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -70,8 +80,10 @@
|
||||
@@ -61,7 +71,7 @@
|
||||
private final List<ServerCommand> consoleInput = Collections.synchronizedList(Lists.newArrayList());
|
||||
@Nullable
|
||||
private RemoteStatusListener queryThreadGs4;
|
||||
- public final RemoteControlCommandListener rconConsoleSource;
|
||||
+ // public final RemoteControlCommandListener rconConsoleSource; // CraftBukkit - remove field
|
||||
@Nullable
|
||||
private RemoteControlListener rconThread;
|
||||
public DedicatedServerSettings settings;
|
||||
@@ -70,10 +80,12 @@
|
||||
@Nullable
|
||||
private final TextFilter textFilterClient;
|
||||
|
||||
@ -28,8 +37,11 @@
|
||||
+ super(options, worldLoader, thread, convertable_conversionsession, resourcepackrepository, worldstem, Proxy.NO_PROXY, datafixer, services, worldloadlistenerfactory);
|
||||
+ // CraftBukkit end
|
||||
this.settings = dedicatedserversettings;
|
||||
this.rconConsoleSource = new RemoteControlCommandListener(this);
|
||||
- this.rconConsoleSource = new RemoteControlCommandListener(this);
|
||||
+ // this.rconConsoleSource = new RemoteControlCommandListener(this); // CraftBukkit - remove field
|
||||
this.textFilterClient = TextFilter.createFromConfig(dedicatedserversettings.getProperties().textFilteringConfig);
|
||||
}
|
||||
|
||||
@@ -81,13 +93,44 @@
|
||||
public boolean initServer() throws IOException {
|
||||
Thread thread = new Thread("Server console handler") {
|
||||
@ -144,15 +156,7 @@
|
||||
long j = SystemUtils.getNanos() - i;
|
||||
String s = String.format(Locale.ROOT, "%.3fs", (double) j / 1.0E9D);
|
||||
|
||||
@@ -181,6 +251,7 @@
|
||||
if (dedicatedserverproperties.enableRcon) {
|
||||
DedicatedServer.LOGGER.info("Starting remote control listener");
|
||||
this.rconThread = RemoteControlListener.create(this);
|
||||
+ this.remoteConsole = new org.bukkit.craftbukkit.command.CraftRemoteConsoleCommandSender(this.rconConsoleSource); // CraftBukkit
|
||||
}
|
||||
|
||||
if (this.getMaxTickLength() > 0L) {
|
||||
@@ -296,6 +367,7 @@
|
||||
@@ -296,6 +366,7 @@
|
||||
this.queryThreadGs4.stop();
|
||||
}
|
||||
|
||||
@ -160,7 +164,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -317,7 +389,15 @@
|
||||
@@ -317,7 +388,15 @@
|
||||
while (!this.consoleInput.isEmpty()) {
|
||||
ServerCommand servercommand = (ServerCommand) this.consoleInput.remove(0);
|
||||
|
||||
@ -177,7 +181,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -539,14 +619,45 @@
|
||||
@@ -539,16 +618,52 @@
|
||||
|
||||
@Override
|
||||
public String getPluginNames() {
|
||||
@ -210,22 +214,31 @@
|
||||
|
||||
@Override
|
||||
public String runCommand(String s) {
|
||||
this.rconConsoleSource.prepareForCommand();
|
||||
- this.rconConsoleSource.prepareForCommand();
|
||||
+ // CraftBukkit start - fire RemoteServerCommandEvent
|
||||
+ throw new UnsupportedOperationException("Not supported - remote source required.");
|
||||
+ }
|
||||
+
|
||||
+ public String runCommand(RemoteControlCommandListener rconConsoleSource, String s) {
|
||||
+ rconConsoleSource.prepareForCommand();
|
||||
this.executeBlocking(() -> {
|
||||
- this.getCommands().performPrefixedCommand(this.rconConsoleSource.createCommandSourceStack(), s);
|
||||
+ // CraftBukkit start - fire RemoteServerCommandEvent
|
||||
+ RemoteServerCommandEvent event = new RemoteServerCommandEvent(remoteConsole, s);
|
||||
+ CommandListenerWrapper wrapper = rconConsoleSource.createCommandSourceStack();
|
||||
+ RemoteServerCommandEvent event = new RemoteServerCommandEvent(rconConsoleSource.getBukkitSender(wrapper), s);
|
||||
+ server.getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ ServerCommand serverCommand = new ServerCommand(event.getCommand(), rconConsoleSource.createCommandSourceStack());
|
||||
+ server.dispatchServerCommand(remoteConsole, serverCommand);
|
||||
+ // CraftBukkit end
|
||||
+ ServerCommand serverCommand = new ServerCommand(event.getCommand(), wrapper);
|
||||
+ server.dispatchServerCommand(event.getSender(), serverCommand);
|
||||
});
|
||||
return this.rconConsoleSource.getCommandResponse();
|
||||
- return this.rconConsoleSource.getCommandResponse();
|
||||
+ return rconConsoleSource.getCommandResponse();
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -599,4 +710,15 @@
|
||||
|
||||
public void storeUsingWhiteList(boolean flag) {
|
||||
@@ -599,4 +714,15 @@
|
||||
public Optional<MinecraftServer.ServerResourcePackInfo> getServerResourcePack() {
|
||||
return this.settings.getProperties().serverResourcePackInfo;
|
||||
}
|
||||
|
@ -1,6 +1,32 @@
|
||||
--- a/net/minecraft/server/rcon/RemoteControlCommandListener.java
|
||||
+++ b/net/minecraft/server/rcon/RemoteControlCommandListener.java
|
||||
@@ -34,6 +34,17 @@
|
||||
@@ -9,14 +9,23 @@
|
||||
import net.minecraft.world.phys.Vec2F;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import java.net.SocketAddress;
|
||||
+import org.bukkit.craftbukkit.command.CraftRemoteConsoleCommandSender;
|
||||
+// CraftBukkit end
|
||||
public class RemoteControlCommandListener implements ICommandListener {
|
||||
|
||||
private static final String RCON = "Rcon";
|
||||
private static final IChatBaseComponent RCON_COMPONENT = IChatBaseComponent.literal("Rcon");
|
||||
private final StringBuffer buffer = new StringBuffer();
|
||||
private final MinecraftServer server;
|
||||
-
|
||||
- public RemoteControlCommandListener(MinecraftServer minecraftserver) {
|
||||
+ // CraftBukkit start
|
||||
+ public final SocketAddress socketAddress;
|
||||
+ private final CraftRemoteConsoleCommandSender remoteConsole = new CraftRemoteConsoleCommandSender(this);
|
||||
+
|
||||
+ public RemoteControlCommandListener(MinecraftServer minecraftserver, SocketAddress socketAddress) {
|
||||
+ this.socketAddress = socketAddress;
|
||||
+ // CraftBukkit end
|
||||
this.server = minecraftserver;
|
||||
}
|
||||
|
||||
@@ -34,6 +43,17 @@
|
||||
return new CommandListenerWrapper(this, Vec3D.atLowerCornerOf(worldserver.getSharedSpawnPos()), Vec2F.ZERO, worldserver, 4, "Rcon", RemoteControlCommandListener.RCON_COMPONENT, this.server, (Entity) null);
|
||||
}
|
||||
|
||||
@ -11,7 +37,7 @@
|
||||
+
|
||||
+ @Override
|
||||
+ public org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper) {
|
||||
+ return server.remoteConsole;
|
||||
+ return this.remoteConsole;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
|
@ -0,0 +1,77 @@
|
||||
--- a/net/minecraft/server/rcon/thread/RemoteControlSession.java
|
||||
+++ b/net/minecraft/server/rcon/thread/RemoteControlSession.java
|
||||
@@ -11,6 +11,10 @@
|
||||
import net.minecraft.server.IMinecraftServer;
|
||||
import net.minecraft.server.rcon.StatusChallengeUtils;
|
||||
import org.slf4j.Logger;
|
||||
+// CraftBukkit start
|
||||
+import net.minecraft.server.dedicated.DedicatedServer;
|
||||
+import net.minecraft.server.rcon.RemoteControlCommandListener;
|
||||
+// CraftBukkit end
|
||||
|
||||
public class RemoteControlSession extends RemoteConnectionThread {
|
||||
|
||||
@@ -24,11 +28,14 @@
|
||||
private final Socket client;
|
||||
private final byte[] buf = new byte[1460];
|
||||
private final String rconPassword;
|
||||
- private final IMinecraftServer serverInterface;
|
||||
+ // CraftBukkit start
|
||||
+ private final DedicatedServer serverInterface;
|
||||
+ private final RemoteControlCommandListener rconConsoleSource;
|
||||
+ // CraftBukkit end
|
||||
|
||||
RemoteControlSession(IMinecraftServer iminecraftserver, String s, Socket socket) {
|
||||
super("RCON Client " + socket.getInetAddress());
|
||||
- this.serverInterface = iminecraftserver;
|
||||
+ this.serverInterface = (DedicatedServer) iminecraftserver; // CraftBukkit
|
||||
this.client = socket;
|
||||
|
||||
try {
|
||||
@@ -38,11 +45,14 @@
|
||||
}
|
||||
|
||||
this.rconPassword = s;
|
||||
+ this.rconConsoleSource = new net.minecraft.server.rcon.RemoteControlCommandListener(this.serverInterface, socket.getRemoteSocketAddress()); // CraftBukkit
|
||||
}
|
||||
|
||||
public void run() {
|
||||
- while (true) {
|
||||
- try {
|
||||
+ // CraftBukkit start - decompile error: switch try / while statement
|
||||
+ try {
|
||||
+ while (true) {
|
||||
+ // CraftBukkit end
|
||||
if (!this.running) {
|
||||
return;
|
||||
}
|
||||
@@ -71,7 +81,7 @@
|
||||
String s = StatusChallengeUtils.stringFromByteArray(this.buf, k, i);
|
||||
|
||||
try {
|
||||
- this.sendCmdResponse(l, this.serverInterface.runCommand(s));
|
||||
+ this.sendCmdResponse(l, this.serverInterface.runCommand(this.rconConsoleSource, s)); // CraftBukkit
|
||||
} catch (Exception exception) {
|
||||
this.sendCmdResponse(l, "Error executing: " + s + " (" + exception.getMessage() + ")");
|
||||
}
|
||||
@@ -98,6 +108,7 @@
|
||||
continue;
|
||||
}
|
||||
}
|
||||
+ } // CraftBukkit - decompile error: switch try / while statement
|
||||
} catch (IOException ioexception) {
|
||||
return;
|
||||
} catch (Exception exception1) {
|
||||
@@ -109,8 +120,10 @@
|
||||
this.running = false;
|
||||
}
|
||||
|
||||
- return;
|
||||
- }
|
||||
+ // CraftBukkit start - decompile error: switch try / while statement
|
||||
+ // return;
|
||||
+ // }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
private void send(int i, int j, String s) throws IOException {
|
@ -1,5 +1,6 @@
|
||||
package org.bukkit.craftbukkit.command;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
import net.minecraft.network.chat.IChatBaseComponent;
|
||||
import net.minecraft.server.rcon.RemoteControlCommandListener;
|
||||
import org.bukkit.command.RemoteConsoleCommandSender;
|
||||
@ -12,6 +13,15 @@ public class CraftRemoteConsoleCommandSender extends ServerCommandSender impleme
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public RemoteControlCommandListener getListener() {
|
||||
return listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SocketAddress getAddress() {
|
||||
return listener.socketAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
listener.sendSystemMessage(IChatBaseComponent.literal(message + "\n")); // Send a newline after each message, to preserve formatting.
|
||||
|
@ -75,7 +75,7 @@ public final class VanillaCommandWrapper extends BukkitCommand {
|
||||
return ((CraftBlockCommandSender) sender).getWrapper();
|
||||
}
|
||||
if (sender instanceof RemoteConsoleCommandSender) {
|
||||
return ((DedicatedServer) MinecraftServer.getServer()).rconConsoleSource.createCommandSourceStack();
|
||||
return ((CraftRemoteConsoleCommandSender) sender).getListener().createCommandSourceStack();
|
||||
}
|
||||
if (sender instanceof ConsoleCommandSender) {
|
||||
return ((CraftServer) sender.getServer()).getServer().createCommandSourceStack();
|
||||
|
Loading…
Reference in New Issue
Block a user