Use TerminalConsoleAppender for console improvements

Rewrite console improvements (console colors, tab completion,
persistent input line, ...) using JLine 3.x and TerminalConsoleAppender.

Also uses the new ANSIComponentSerializer to serialize components when
logging them via the ComponentLogger, or when sending messages to the
console, for hex color support.

New features:
  - Support console colors for Vanilla commands
  - Add console colors for warnings and errors
  - Server can now be turned off safely using CTRL + C. JLine catches
    the signal and the implementation shuts down the server cleanly.
  - Support console colors and persistent input line when running in
    IntelliJ IDEA

Other changes:
  - Server starts 1-2 seconds faster thanks to optimizations in Log4j
    configuration

Co-Authored-By: Emilia Kond <emilia@rymiel.space>
This commit is contained in:
Minecrell
2017-06-09 19:03:43 +02:00
parent 66779f5c86
commit 36723cdd60
19 changed files with 343 additions and 133 deletions

View File

@@ -49,7 +49,7 @@
+import com.mojang.serialization.Lifecycle;
+import java.io.File;
+import java.util.Random;
+import jline.console.ConsoleReader;
+// import jline.console.ConsoleReader; // Paper
+import joptsimple.OptionSet;
+import net.minecraft.nbt.NbtException;
+import net.minecraft.nbt.ReportedNbtException;
@@ -118,17 +118,15 @@
private int playerIdleTimeout;
private final long[] tickTimesNanos;
private long aggregatedTickTimesNanos;
@@ -276,6 +301,26 @@
private static final AtomicReference<RuntimeException> fatalException = new AtomicReference();
@@ -277,6 +302,25 @@
private final SuppressedExceptionCollector suppressedExceptions;
private final DiscontinuousFrame tickFrame;
+
+ // CraftBukkit start
+ public final WorldLoader.DataLoadContext worldLoader;
+ public org.bukkit.craftbukkit.CraftServer server;
+ public OptionSet options;
+ public org.bukkit.command.ConsoleCommandSender console;
+ public ConsoleReader reader;
+ public static int currentTick = (int) (System.currentTimeMillis() / 50);
+ public java.util.Queue<Runnable> processQueue = new java.util.concurrent.ConcurrentLinkedQueue<Runnable>();
+ public int autosavePeriod;
@@ -142,10 +140,11 @@
+ public final double[] recentTps = new double[ 3 ];
+ // Spigot end
+ public final io.papermc.paper.configuration.PaperConfigurations paperConfigurations; // Paper - add paper configuration files
+
public static <S extends MinecraftServer> S spin(Function<Thread, S> serverFactory) {
AtomicReference<S> atomicreference = new AtomicReference();
@@ -290,14 +335,14 @@
Thread thread = new Thread(() -> {
@@ -290,14 +334,14 @@
thread.setPriority(8);
}
@@ -162,7 +161,7 @@
super("Server");
this.metricsRecorder = InactiveMetricsRecorder.INSTANCE;
this.onMetricsRecordingStopped = (methodprofilerresults) -> {
@@ -319,36 +364,64 @@
@@ -319,36 +363,68 @@
this.scoreboard = new ServerScoreboard(this);
this.customBossEvents = new CustomBossEvents();
this.suppressedExceptions = new SuppressedExceptionCollector();
@@ -215,7 +214,9 @@
+ this.options = options;
+ this.worldLoader = worldLoader;
+ this.vanillaCommandDispatcher = worldstem.dataPackResources().commands; // CraftBukkit
+ // Paper start - Handled by TerminalConsoleAppender
+ // Try to see if we're actually running in a terminal, disable jline if not
+ /*
+ if (System.console() == null && System.getProperty("jline.terminal") == null) {
+ System.setProperty("jline.terminal", "jline.UnsupportedTerminal");
+ Main.useJline = false;
@@ -236,13 +237,15 @@
+ MinecraftServer.LOGGER.warn((String) null, ex);
+ }
+ }
+ */
+ // Paper end
+ Runtime.getRuntime().addShutdownHook(new org.bukkit.craftbukkit.util.ServerShutdownThread(this));
+ // CraftBukkit end
+ this.paperConfigurations = services.paperConfigurations(); // Paper - add paper configuration files
}
private void readScoreboard(DimensionDataStorage persistentStateManager) {
@@ -357,7 +430,7 @@
@@ -357,7 +433,7 @@
protected abstract boolean initServer() throws IOException;
@@ -251,7 +254,7 @@
if (!JvmProfiler.INSTANCE.isRunning()) {
;
}
@@ -365,12 +438,8 @@
@@ -365,12 +441,8 @@
boolean flag = false;
ProfiledDuration profiledduration = JvmProfiler.INSTANCE.onWorldLoadedStarted();
@@ -265,7 +268,7 @@
if (profiledduration != null) {
profiledduration.finish(true);
}
@@ -387,23 +456,217 @@
@@ -387,23 +459,217 @@
protected void forceDifficulty() {}
@@ -497,7 +500,7 @@
if (!iworlddataserver.isInitialized()) {
try {
@@ -427,30 +690,8 @@
@@ -427,30 +693,8 @@
iworlddataserver.setInitialized(true);
}
@@ -529,7 +532,7 @@
private static void setInitialSpawn(ServerLevel world, ServerLevelData worldProperties, boolean bonusChest, boolean debugWorld) {
if (debugWorld) {
@@ -458,6 +699,21 @@
@@ -458,6 +702,21 @@
} else {
ServerChunkCache chunkproviderserver = world.getChunkSource();
ChunkPos chunkcoordintpair = new ChunkPos(chunkproviderserver.randomState().sampler().findSpawnPosition());
@@ -551,7 +554,7 @@
int i = chunkproviderserver.getGenerator().getSpawnHeight(world);
if (i < world.getMinY()) {
@@ -516,31 +772,36 @@
@@ -516,31 +775,36 @@
iworlddataserver.setGameType(GameType.SPECTATOR);
}
@@ -599,7 +602,7 @@
ForcedChunksSavedData forcedchunk = (ForcedChunksSavedData) worldserver1.getDataStorage().get(ForcedChunksSavedData.factory(), "chunks");
if (forcedchunk != null) {
@@ -555,10 +816,17 @@
@@ -555,10 +819,17 @@
}
}
@@ -621,7 +624,7 @@
}
public GameType getDefaultGameType() {
@@ -588,12 +856,16 @@
@@ -588,12 +859,16 @@
worldserver.save((ProgressListener) null, flush, worldserver.noSave && !force);
}
@@ -640,7 +643,7 @@
if (flush) {
Iterator iterator1 = this.getAllLevels().iterator();
@@ -628,18 +900,40 @@
@@ -628,18 +903,40 @@
this.stopServer();
}
@@ -681,7 +684,7 @@
}
MinecraftServer.LOGGER.info("Saving worlds");
@@ -693,6 +987,15 @@
@@ -693,6 +990,15 @@
} catch (IOException ioexception1) {
MinecraftServer.LOGGER.error("Failed to unlock level {}", this.storageSource.getLevelId(), ioexception1);
}
@@ -697,21 +700,23 @@
}
@@ -720,6 +1023,13 @@
}
@@ -717,8 +1023,15 @@
MinecraftServer.LOGGER.error("Error while shutting down", interruptedexception);
}
}
+
+ }
+ // Spigot Start
+ private static double calcTps(double avg, double exp, double tps)
+ {
+ return ( avg * exp ) + ( tps * ( 1 - exp ) );
+ }
}
+ // Spigot End
+
protected void runServer() {
try {
if (!this.initServer()) {
@@ -727,9 +1037,12 @@
@@ -727,9 +1040,12 @@
}
this.nextTickTimeNanos = Util.getNanos();
@@ -725,7 +730,7 @@
while (this.running) {
long i;
@@ -744,11 +1057,23 @@
@@ -744,11 +1060,23 @@
if (j > MinecraftServer.OVERLOADED_THRESHOLD_NANOS + 20L * i && this.nextTickTimeNanos - this.lastOverloadWarningNanos >= MinecraftServer.OVERLOADED_WARNING_INTERVAL_NANOS + 100L * i) {
long k = j / i;
@@ -749,7 +754,7 @@
boolean flag = i == 0L;
@@ -757,6 +1082,7 @@
@@ -757,6 +1085,7 @@
this.debugCommandProfiler = new MinecraftServer.TimeProfiler(Util.getNanos(), this.tickCount);
}
@@ -757,21 +762,21 @@
this.nextTickTimeNanos += i;
try {
@@ -830,6 +1156,13 @@
@@ -830,6 +1159,13 @@
this.services.profileCache().clearExecutor();
}
+ org.spigotmc.WatchdogThread.doStop(); // Spigot
+ // CraftBukkit start - Restore terminal to original settings
+ try {
+ this.reader.getTerminal().restore();
+ net.minecrell.terminalconsole.TerminalConsoleAppender.close(); // Paper - Use TerminalConsoleAppender
+ } catch (Exception ignored) {
+ }
+ // CraftBukkit end
this.onServerExit();
}
@@ -889,9 +1222,16 @@
@@ -889,9 +1225,16 @@
}
private boolean haveTime() {
@@ -789,7 +794,7 @@
public static boolean throwIfFatalException() {
RuntimeException runtimeexception = (RuntimeException) MinecraftServer.fatalException.get();
@@ -903,7 +1243,7 @@
@@ -903,7 +1246,7 @@
}
public static void setFatalException(RuntimeException exception) {
@@ -798,7 +803,7 @@
}
@Override
@@ -977,7 +1317,7 @@
@@ -977,7 +1320,7 @@
}
}
@@ -807,7 +812,7 @@
Profiler.get().incrementCounter("runTask");
super.doRunTask(ticktask);
}
@@ -1025,6 +1365,7 @@
@@ -1025,6 +1368,7 @@
}
public void tickServer(BooleanSupplier shouldKeepTicking) {
@@ -815,7 +820,7 @@
long i = Util.getNanos();
int j = this.pauseWhileEmptySeconds() * 20;
@@ -1041,11 +1382,13 @@
@@ -1041,11 +1385,13 @@
this.autoSave();
}
@@ -829,7 +834,7 @@
++this.tickCount;
this.tickRateManager.tick();
this.tickChildren(shouldKeepTicking);
@@ -1055,7 +1398,7 @@
@@ -1055,7 +1401,7 @@
}
--this.ticksUntilAutosave;
@@ -838,7 +843,7 @@
this.autoSave();
}
@@ -1071,10 +1414,13 @@
@@ -1071,10 +1417,13 @@
this.smoothedTickTimeMillis = this.smoothedTickTimeMillis * 0.8F + (float) k / (float) TimeUtil.NANOSECONDS_PER_MILLISECOND * 0.19999999F;
this.logTickMethodTime(i);
gameprofilerfiller.pop();
@@ -853,7 +858,7 @@
MinecraftServer.LOGGER.debug("Autosave started");
ProfilerFiller gameprofilerfiller = Profiler.get();
@@ -1082,6 +1428,7 @@
@@ -1082,6 +1431,7 @@
this.saveEverything(true, false, false);
gameprofilerfiller.pop();
MinecraftServer.LOGGER.debug("Autosave finished");
@@ -861,7 +866,7 @@
}
private void logTickMethodTime(long tickStartTime) {
@@ -1123,7 +1470,7 @@
@@ -1123,7 +1473,7 @@
private ServerStatus buildServerStatus() {
ServerStatus.Players serverping_serverpingplayersample = this.buildPlayerStatus();
@@ -870,7 +875,7 @@
}
private ServerStatus.Players buildPlayerStatus() {
@@ -1154,11 +1501,35 @@
@@ -1154,11 +1504,35 @@
this.getPlayerList().getPlayers().forEach((entityplayer) -> {
entityplayer.connection.suspendFlushing();
});
@@ -906,7 +911,7 @@
while (iterator.hasNext()) {
ServerLevel worldserver = (ServerLevel) iterator.next();
@@ -1167,16 +1538,20 @@
@@ -1167,16 +1541,20 @@
return s + " " + String.valueOf(worldserver.dimension().location());
});
@@ -927,7 +932,7 @@
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Exception ticking world");
@@ -1189,18 +1564,24 @@
@@ -1189,18 +1567,24 @@
}
gameprofilerfiller.popPush("connection");
@@ -952,7 +957,7 @@
gameprofilerfiller.popPush("send chunks");
iterator = this.playerList.getPlayers().iterator();
@@ -1267,6 +1648,22 @@
@@ -1267,6 +1651,22 @@
return (ServerLevel) this.levels.get(key);
}
@@ -975,7 +980,7 @@
public Set<ResourceKey<Level>> levelKeys() {
return this.levels.keySet();
}
@@ -1296,7 +1693,7 @@
@@ -1296,7 +1696,7 @@
@DontObfuscate
public String getServerModName() {
@@ -984,7 +989,16 @@
}
public SystemReport fillSystemReport(SystemReport details) {
@@ -1481,10 +1878,20 @@
@@ -1347,7 +1747,7 @@
@Override
public void sendSystemMessage(Component message) {
- MinecraftServer.LOGGER.info(message.getString());
+ MinecraftServer.LOGGER.info(io.papermc.paper.adventure.PaperAdventure.ANSI_SERIALIZER.serialize(io.papermc.paper.adventure.PaperAdventure.asAdventure(message))); // Paper - Log message with colors
}
public KeyPair getKeyPair() {
@@ -1481,10 +1881,20 @@
@Override
public String getMotd() {
@@ -1006,7 +1020,7 @@
this.motd = motd;
}
@@ -1507,7 +1914,7 @@
@@ -1507,7 +1917,7 @@
}
public ServerConnectionListener getConnection() {
@@ -1015,7 +1029,7 @@
}
public boolean isReady() {
@@ -1634,11 +2041,11 @@
@@ -1634,11 +2044,11 @@
public CompletableFuture<Void> reloadResources(Collection<String> dataPacks) {
CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> {
@@ -1029,7 +1043,7 @@
}, this).thenCompose((immutablelist) -> {
MultiPackResourceManager resourcemanager = new MultiPackResourceManager(PackType.SERVER_DATA, immutablelist);
List<Registry.PendingTags<?>> list = TagLoader.loadTagsForExistingRegistries(resourcemanager, this.registries.compositeAccess());
@@ -1654,6 +2061,7 @@
@@ -1654,6 +2064,7 @@
}).thenAcceptAsync((minecraftserver_reloadableresources) -> {
this.resources.close();
this.resources = minecraftserver_reloadableresources;
@@ -1037,7 +1051,7 @@
this.packRepository.setSelected(dataPacks);
WorldDataConfiguration worlddataconfiguration = new WorldDataConfiguration(MinecraftServer.getSelectedPacks(this.packRepository, true), this.worldData.enabledFeatures());
@@ -1952,7 +2360,7 @@
@@ -1952,7 +2363,7 @@
final List<String> list = Lists.newArrayList();
final GameRules gamerules = this.getGameRules();
@@ -1046,7 +1060,7 @@
@Override
public <T extends GameRules.Value<T>> void visit(GameRules.Key<T> key, GameRules.Type<T> type) {
list.add(String.format(Locale.ROOT, "%s=%s\n", key.getId(), gamerules.getRule(key)));
@@ -2058,7 +2466,7 @@
@@ -2058,7 +2469,7 @@
try {
label51:
{
@@ -1055,7 +1069,7 @@
try {
arraylist = Lists.newArrayList(NativeModuleLister.listModules());
@@ -2105,9 +2513,25 @@
@@ -2105,9 +2516,25 @@
if (bufferedwriter != null) {
bufferedwriter.close();
}
@@ -1081,7 +1095,7 @@
private ProfilerFiller createProfiler() {
if (this.willStartRecordingMetrics) {
this.metricsRecorder = ActiveMetricsRecorder.createStarted(new ServerMetricsSamplersProvider(Util.timeSource, this.isDedicatedServer()), Util.timeSource, Util.ioPool(), new MetricsPersister("server"), this.onMetricsRecordingStopped, (path) -> {
@@ -2225,18 +2649,24 @@
@@ -2225,18 +2652,24 @@
}
public void logChatMessage(Component message, ChatType.Bound params, @Nullable String prefix) {

View File

@@ -34,7 +34,7 @@
@Nullable
private RconThread rconThread;
public DedicatedServerSettings settings;
@@ -81,25 +93,58 @@
@@ -81,33 +93,99 @@
private DebugSampleSubscriptionTracker debugSampleSubscriptionTracker;
public ServerLinks serverLinks;
@@ -63,6 +63,9 @@
+ if (!org.bukkit.craftbukkit.Main.useConsole) {
+ return;
+ }
+ // Paper start - Use TerminalConsoleAppender
+ new com.destroystokyo.paper.console.PaperConsole(DedicatedServer.this).start();
+ /*
+ jline.console.ConsoleReader bufferedreader = DedicatedServer.this.reader;
+ // MC-33041, SPIGOT-5538: if System.in is not valid due to javaw, then return
@@ -96,13 +99,16 @@
+ continue;
+ }
+ if (s.trim().length() > 0) { // Trim to filter lines which are just spaces
+ DedicatedServer.this.handleConsoleInput(s, DedicatedServer.this.createCommandSourceStack());
+ DedicatedServer.this.issueCommand(s, DedicatedServer.this.getServerCommandListener());
+ }
+ // CraftBukkit end
}
} catch (IOException ioexception) {
DedicatedServer.LOGGER.error("Exception handling console input", ioexception);
@@ -108,6 +153,29 @@
}
+ */
+ // Paper end
}
};
@@ -114,6 +120,9 @@
+ }
+ global.addHandler(new org.bukkit.craftbukkit.util.ForwardLogHandler());
+
+ // Paper start - Not needed with TerminalConsoleAppender
+ final org.apache.logging.log4j.Logger logger = LogManager.getRootLogger();
+ /*
+ final org.apache.logging.log4j.core.Logger logger = ((org.apache.logging.log4j.core.Logger) LogManager.getRootLogger());
+ for (org.apache.logging.log4j.core.Appender appender : logger.getAppenders().values()) {
+ if (appender instanceof org.apache.logging.log4j.core.appender.ConsoleAppender) {
@@ -124,6 +133,8 @@
+ TerminalConsoleWriterThread writerThread = new TerminalConsoleWriterThread(System.out, this.reader);
+ this.reader.setCompletionHandler(new TerminalCompletionHandler(writerThread, this.reader.getCompletionHandler()));
+ writerThread.start();
+ */
+ // Paper end - Not needed with TerminalConsoleAppender
+
+ System.setOut(IoBuilder.forLogger(logger).setLevel(Level.INFO).buildPrintStream());
+ System.setErr(IoBuilder.forLogger(logger).setLevel(Level.WARN).buildPrintStream());
@@ -132,7 +143,7 @@
thread.setDaemon(true);
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(DedicatedServer.LOGGER));
thread.start();
@@ -126,13 +194,22 @@
@@ -126,13 +204,22 @@
this.setPreventProxyConnections(dedicatedserverproperties.preventProxyConnections);
this.setLocalIp(dedicatedserverproperties.serverIp);
}
@@ -156,7 +167,7 @@
DedicatedServer.LOGGER.info("Default game type: {}", dedicatedserverproperties.gamemode);
InetAddress inetaddress = null;
@@ -156,10 +233,23 @@
@@ -156,10 +243,23 @@
return false;
}
@@ -181,7 +192,7 @@
DedicatedServer.LOGGER.warn("To change this, set \"online-mode\" to \"true\" in the server.properties file.");
}
@@ -170,7 +260,7 @@
@@ -170,7 +270,7 @@
if (!OldUsersConverter.serverReadyAfterUserconversion(this)) {
return false;
} else {
@@ -190,7 +201,7 @@
this.debugSampleSubscriptionTracker = new DebugSampleSubscriptionTracker(this.getPlayerList());
this.tickTimeLogger = new RemoteSampleLogger(TpsDebugDimensions.values().length, this.debugSampleSubscriptionTracker, RemoteDebugSampleType.TICK_TIME);
long i = Util.getNanos();
@@ -178,13 +268,13 @@
@@ -178,13 +278,13 @@
SkullBlockEntity.setup(this.services, this);
GameProfileCache.setUsesAuthentication(this.usesAuthentication());
DedicatedServer.LOGGER.info("Preparing level \"{}\"", this.getLevelIdName());
@@ -206,7 +217,7 @@
}
if (dedicatedserverproperties.enableQuery) {
@@ -197,7 +287,7 @@
@@ -197,7 +297,7 @@
this.rconThread = RconThread.create(this);
}
@@ -215,7 +226,7 @@
Thread thread1 = new Thread(new ServerWatchdog(this));
thread1.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandlerWithName(DedicatedServer.LOGGER));
@@ -293,6 +383,7 @@
@@ -293,6 +393,7 @@
this.queryThreadGs4.stop();
}
@@ -223,7 +234,7 @@
}
@Override
@@ -302,8 +393,8 @@
@@ -302,8 +403,8 @@
}
@Override
@@ -234,7 +245,7 @@
}
public void handleConsoleInput(String command, CommandSourceStack commandSource) {
@@ -311,12 +402,22 @@
@@ -311,12 +412,22 @@
}
public void handleConsoleInputs() {
@@ -258,7 +269,7 @@
}
@Override
@@ -383,7 +484,7 @@
@@ -383,7 +494,7 @@
@Override
public boolean isUnderSpawnProtection(ServerLevel world, BlockPos pos, Player player) {
@@ -267,7 +278,7 @@
return false;
} else if (this.getPlayerList().getOps().isEmpty()) {
return false;
@@ -541,16 +642,52 @@
@@ -541,16 +652,52 @@
@Override
public String getPluginNames() {
@@ -324,7 +335,7 @@
}
public void storeUsingWhiteList(boolean useWhitelist) {
@@ -660,4 +797,15 @@
@@ -660,4 +807,15 @@
}
}
}

View File

@@ -22,7 +22,7 @@
this.finalizers.forEach(Runnable::run);
}
+ private static final java.util.regex.Pattern ANSI = java.util.regex.Pattern.compile("\\x1B\\[([0-9]{1,2}(;[0-9]{1,2})*)?[m|K]"); // CraftBukkit
+ private static final java.util.regex.Pattern ANSI = java.util.regex.Pattern.compile("\\e\\[[\\d;]*[^\\d;]"); // CraftBukkit // Paper
public void print(JTextArea textArea, JScrollPane scrollPane, String message) {
if (!SwingUtilities.isEventDispatchThread()) {
SwingUtilities.invokeLater(() -> {

View File

@@ -63,7 +63,7 @@
public final PlayerDataStorage playerIo;
private boolean doWhiteList;
private final LayeredRegistryAccess<RegistryLayer> registries;
@@ -134,13 +156,24 @@
@@ -134,13 +156,23 @@
private static final boolean ALLOW_LOGOUTIVATOR = false;
private int sendAllPlayerInfoIn;
@@ -73,8 +73,7 @@
+
public PlayerList(MinecraftServer server, LayeredRegistryAccess<RegistryLayer> registryManager, PlayerDataStorage saveHandler, int maxPlayers) {
+ this.cserver = server.server = new CraftServer((DedicatedServer) server, this);
+ server.console = org.bukkit.craftbukkit.command.ColouredConsoleSender.getInstance();
+ server.reader.addCompleter(new org.bukkit.craftbukkit.command.ConsoleCommandCompleter(server.server));
+ server.console = new com.destroystokyo.paper.console.TerminalConsoleCommandSender(); // Paper
+ // CraftBukkit end
+
this.bans = new UserBanList(PlayerList.USERBANLIST_FILE);
@@ -90,7 +89,7 @@
this.server = server;
this.registries = registryManager;
this.maxPlayers = maxPlayers;
@@ -148,27 +181,37 @@
@@ -148,27 +180,37 @@
}
public void placeNewPlayer(Connection connection, ServerPlayer player, CommonListenerCookie clientData) {
@@ -133,7 +132,7 @@
ServerLevel worldserver = this.server.getLevel(resourcekey);
ServerLevel worldserver1;
@@ -182,10 +225,24 @@
@@ -182,10 +224,24 @@
player.setServerLevel(worldserver1);
String s1 = connection.getLoggableAddress(this.server.logIPs());
@@ -160,7 +159,7 @@
ServerGamePacketListenerImpl playerconnection = new ServerGamePacketListenerImpl(this.server, connection, player, clientData);
connection.setupInboundProtocol(GameProtocols.SERVERBOUND_TEMPLATE.bind(RegistryFriendlyByteBuf.decorator(this.server.registryAccess())), playerconnection);
@@ -194,7 +251,9 @@
@@ -194,7 +250,9 @@
boolean flag1 = gamerules.getBoolean(GameRules.RULE_REDUCEDDEBUGINFO);
boolean flag2 = gamerules.getBoolean(GameRules.RULE_LIMITED_CRAFTING);
@@ -171,7 +170,7 @@
playerconnection.send(new ClientboundChangeDifficultyPacket(worlddata.getDifficulty(), worlddata.isDifficultyLocked()));
playerconnection.send(new ClientboundPlayerAbilitiesPacket(player.getAbilities()));
playerconnection.send(new ClientboundSetHeldSlotPacket(player.getInventory().selected));
@@ -213,8 +272,10 @@
@@ -213,8 +271,10 @@
} else {
ichatmutablecomponent = Component.translatable("multiplayer.player.joined.renamed", player.getDisplayName(), s);
}
@@ -183,7 +182,7 @@
playerconnection.teleport(player.getX(), player.getY(), player.getZ(), player.getYRot(), player.getXRot());
ServerStatus serverping = this.server.getStatus();
@@ -222,17 +283,70 @@
@@ -222,17 +282,70 @@
player.sendServerStatus(serverping);
}
@@ -258,7 +257,7 @@
}
public void updateEntireScoreboard(ServerScoreboard scoreboard, ServerPlayer player) {
@@ -269,30 +383,31 @@
@@ -269,30 +382,31 @@
}
public void addWorldborderListener(ServerLevel world) {
@@ -295,7 +294,7 @@
}
@Override
@@ -319,14 +434,15 @@
@@ -319,14 +433,15 @@
}
protected void save(ServerPlayer player) {
@@ -313,7 +312,7 @@
if (advancementdataplayer != null) {
advancementdataplayer.save();
@@ -334,95 +450,176 @@
@@ -334,95 +449,176 @@
}
@@ -528,7 +527,7 @@
if (entityplayer1 != null) {
set.add(entityplayer1);
@@ -431,30 +628,50 @@
@@ -431,30 +627,50 @@
Iterator iterator1 = set.iterator();
while (iterator1.hasNext()) {
@@ -592,7 +591,7 @@
while (iterator.hasNext()) {
String s = (String) iterator.next();
@@ -462,41 +679,88 @@
@@ -462,41 +678,88 @@
entityplayer1.addTag(s);
}
@@ -689,7 +688,7 @@
return entityplayer1;
}
@@ -524,7 +788,18 @@
@@ -524,7 +787,18 @@
public void tick() {
if (++this.sendAllPlayerInfoIn > 600) {
@@ -709,7 +708,7 @@
this.sendAllPlayerInfoIn = 0;
}
@@ -541,6 +816,25 @@
@@ -541,6 +815,25 @@
}
@@ -735,7 +734,7 @@
public void broadcastAll(Packet<?> packet, ResourceKey<Level> dimension) {
Iterator iterator = this.players.iterator();
@@ -554,7 +848,7 @@
@@ -554,7 +847,7 @@
}
@@ -744,7 +743,7 @@
PlayerTeam scoreboardteam = source.getTeam();
if (scoreboardteam != null) {
@@ -573,7 +867,7 @@
@@ -573,7 +866,7 @@
}
}
@@ -753,7 +752,7 @@
PlayerTeam scoreboardteam = source.getTeam();
if (scoreboardteam == null) {
@@ -619,7 +913,7 @@
@@ -619,7 +912,7 @@
}
public void deop(GameProfile profile) {
@@ -762,7 +761,7 @@
ServerPlayer entityplayer = this.getPlayer(profile.getId());
if (entityplayer != null) {
@@ -643,6 +937,7 @@
@@ -643,6 +936,7 @@
player.connection.send(new ClientboundEntityEventPacket(player, b0));
}
@@ -770,7 +769,7 @@
this.server.getCommands().sendCommands(player);
}
@@ -656,23 +951,19 @@
@@ -656,23 +950,19 @@
@Nullable
public ServerPlayer getPlayerByName(String name) {
@@ -802,7 +801,7 @@
if (entityplayer != player && entityplayer.level().dimension() == worldKey) {
double d4 = x - entityplayer.getX();
double d5 = y - entityplayer.getY();
@@ -712,15 +1003,19 @@
@@ -712,15 +1002,19 @@
public void reloadWhiteList() {}
public void sendLevelInfo(ServerPlayer player, ServerLevel world) {
@@ -826,7 +825,7 @@
}
player.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.LEVEL_CHUNKS_LOAD_START, 0.0F));
@@ -729,8 +1024,16 @@
@@ -729,8 +1023,16 @@
public void sendAllPlayerInfo(ServerPlayer player) {
player.inventoryMenu.sendAllDataToRemote();
@@ -844,7 +843,7 @@
}
public int getPlayerCount() {
@@ -786,12 +1089,22 @@
@@ -786,12 +1088,22 @@
}
public void removeAll() {
@@ -869,7 +868,7 @@
public void broadcastSystemMessage(Component message, boolean overlay) {
this.broadcastSystemMessage(message, (entityplayer) -> {
return message;
@@ -819,24 +1132,43 @@
@@ -819,24 +1131,43 @@
}
public void broadcastChatMessage(PlayerChatMessage message, ServerPlayer sender, ChatType.Bound params) {
@@ -916,7 +915,7 @@
}
if (flag1 && sender != null) {
@@ -845,20 +1177,27 @@
@@ -845,20 +1176,27 @@
}
@@ -949,7 +948,7 @@
Path path = file2.toPath();
if (FileUtil.isPathNormalized(path) && FileUtil.isPathPortable(path) && path.startsWith(file.getPath()) && file2.isFile()) {
@@ -867,7 +1206,7 @@
@@ -867,7 +1205,7 @@
}
serverstatisticmanager = new ServerStatsCounter(this.server, file1);
@@ -958,7 +957,7 @@
}
return serverstatisticmanager;
@@ -875,13 +1214,13 @@
@@ -875,13 +1213,13 @@
public PlayerAdvancements getPlayerAdvancements(ServerPlayer player) {
UUID uuid = player.getUUID();
@@ -974,7 +973,7 @@
}
advancementdataplayer.setPlayer(player);
@@ -932,15 +1271,28 @@
@@ -932,15 +1270,28 @@
}
public void reloadResources() {