Update to Minecraft 1.19.1

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2022-07-28 04:00:00 +10:00
parent 7c33b52741
commit f8db65033c
41 changed files with 654 additions and 579 deletions

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/CrashReport.java
+++ b/net/minecraft/CrashReport.java
@@ -32,6 +32,7 @@
@@ -34,6 +34,7 @@
public CrashReport(String s, Throwable throwable) {
this.title = s;
this.exception = throwable;

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/commands/CommandDispatcher.java
+++ b/net/minecraft/commands/CommandDispatcher.java
@@ -106,6 +106,14 @@
@@ -109,6 +109,14 @@
import net.minecraft.util.profiling.jfr.JvmProfiler;
import org.slf4j.Logger;
@ -15,7 +15,7 @@
public class CommandDispatcher {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -117,6 +125,7 @@
@@ -120,6 +128,7 @@
private final com.mojang.brigadier.CommandDispatcher<CommandListenerWrapper> dispatcher = new com.mojang.brigadier.CommandDispatcher();
public CommandDispatcher(CommandDispatcher.ServerType commanddispatcher_servertype, CommandBuildContext commandbuildcontext) {
@ -23,7 +23,7 @@
CommandAdvancement.register(this.dispatcher);
CommandAttribute.register(this.dispatcher);
CommandExecute.register(this.dispatcher, commandbuildcontext);
@@ -201,16 +210,68 @@
@@ -204,6 +213,11 @@
CommandPublish.register(this.dispatcher);
}
@ -35,6 +35,8 @@
this.dispatcher.setConsumer((commandcontext, flag, i) -> {
((CommandListenerWrapper) commandcontext.getSource()).onCommandComplete(commandcontext, flag, i);
});
@@ -216,12 +230,59 @@
return new ParseResults(commandcontextbuilder1, parseresults.getReader(), parseresults.getExceptions());
}
+ // CraftBukkit start
@ -70,30 +72,31 @@
+ }
+
+ String newCommand = joiner.join(args);
+ return this.performCommand(sender, newCommand, newCommand);
+ return this.performPrefixedCommand(sender, newCommand, newCommand);
+ }
+ // CraftBukkit end
+
public int performPrefixedCommand(CommandListenerWrapper commandlistenerwrapper, String s) {
- return this.performCommand(commandlistenerwrapper, s.startsWith("/") ? s.substring(1) : s);
+ // CraftBukkit start
+ return this.performPrefixedCommand(commandlistenerwrapper, s, s);
+ }
+
+ public int performPrefixedCommand(CommandListenerWrapper commandlistenerwrapper, String s, String label) {
+ return this.performCommand(commandlistenerwrapper, s.startsWith("/") ? s.substring(1) : s, label);
s = s.startsWith("/") ? s.substring(1) : s;
- return this.performCommand(this.dispatcher.parse(s, commandlistenerwrapper), s);
+ return this.performCommand(this.dispatcher.parse(s, commandlistenerwrapper), s, label);
+ // CraftBukkit end
}
public int performCommand(CommandListenerWrapper commandlistenerwrapper, String s) {
+ return this.performCommand(commandlistenerwrapper, s, s);
public int performCommand(ParseResults<CommandListenerWrapper> parseresults, String s) {
+ return this.performCommand(parseresults, s, s);
+ }
+
+ public int performCommand(CommandListenerWrapper commandlistenerwrapper, String s, String label) { // CraftBukkit
StringReader stringreader = new StringReader(s);
+ public int performCommand(ParseResults<CommandListenerWrapper> parseresults, String s, String label) { // CraftBukkit
CommandListenerWrapper commandlistenerwrapper = (CommandListenerWrapper) parseresults.getContext().getSource();
commandlistenerwrapper.getServer().getProfiler().push(() -> {
@@ -235,7 +296,7 @@
@@ -246,7 +307,7 @@
if (commandsyntaxexception.getInput() != null && commandsyntaxexception.getCursor() >= 0) {
int j = Math.min(commandsyntaxexception.getInput().length(), commandsyntaxexception.getCursor());
IChatMutableComponent ichatmutablecomponent = IChatBaseComponent.empty().withStyle(EnumChatFormat.GRAY).withStyle((chatmodifier) -> {
@ -102,7 +105,7 @@
});
if (j > 10) {
@@ -285,11 +346,36 @@
@@ -296,11 +357,36 @@
}
public void sendCommands(EntityPlayer entityplayer) {
@ -140,7 +143,7 @@
entityplayer.connection.send(new PacketPlayOutCommands(rootcommandnode));
}
@@ -300,7 +386,7 @@
@@ -311,7 +397,7 @@
CommandNode<CommandListenerWrapper> commandnode2 = (CommandNode) iterator.next();
if (commandnode2.canUse(commandlistenerwrapper)) {
@ -149,7 +152,7 @@
argumentbuilder.requires((icompletionprovider) -> {
return true;
@@ -323,7 +409,7 @@
@@ -334,7 +420,7 @@
argumentbuilder.redirect((CommandNode) map.get(argumentbuilder.getRedirect()));
}

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/commands/CommandListenerWrapper.java
+++ b/net/minecraft/commands/CommandListenerWrapper.java
@@ -35,6 +35,8 @@
@@ -38,6 +38,8 @@
import net.minecraft.world.phys.Vec2F;
import net.minecraft.world.phys.Vec3D;
@ -9,15 +9,15 @@
public class CommandListenerWrapper implements ICompletionProvider {
public static final SimpleCommandExceptionType ERROR_NOT_PLAYER = new SimpleCommandExceptionType(IChatBaseComponent.translatable("permissions.requires.player"));
@@ -54,6 +56,7 @@
private final ArgumentAnchor.Anchor anchor;
@@ -58,6 +60,7 @@
private final Vec2F rotation;
private final CommandSigningContext signingContext;
private final TaskChainer chatMessageChainer;
+ public volatile CommandNode currentCommand; // CraftBukkit
public CommandListenerWrapper(ICommandListener icommandlistener, Vec3D vec3d, Vec2F vec2f, WorldServer worldserver, int i, String s, IChatBaseComponent ichatbasecomponent, MinecraftServer minecraftserver, @Nullable Entity entity) {
this(icommandlistener, vec3d, vec2f, worldserver, i, s, ichatbasecomponent, minecraftserver, entity, false, (commandcontext, flag, j) -> {
@@ -163,9 +166,23 @@
@@ -172,9 +175,23 @@
@Override
public boolean hasPermission(int i) {
@ -41,7 +41,7 @@
public Vec3D getPosition() {
return this.worldPosition;
}
@@ -255,7 +272,7 @@
@@ -300,7 +317,7 @@
while (iterator.hasNext()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
@ -50,7 +50,7 @@
entityplayer.sendSystemMessage(ichatmutablecomponent);
}
}
@@ -323,4 +340,10 @@
@@ -368,4 +385,10 @@
public IRegistryCustom registryAccess() {
return this.server.registryAccess();
}

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/network/NetworkManager.java
+++ b/net/minecraft/network/NetworkManager.java
@@ -168,7 +168,7 @@
@@ -164,7 +164,7 @@
}
private static <T extends PacketListener> void genericsFtw(Packet<T> packet, PacketListener packetlistener) {
@ -9,7 +9,7 @@
}
public void setListener(PacketListener packetlistener) {
@@ -280,7 +280,7 @@
@@ -289,7 +289,7 @@
public void disconnect(IChatBaseComponent ichatbasecomponent) {
if (this.channel.isOpen()) {

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/network/chat/ChatHexColor.java
+++ b/net/minecraft/network/chat/ChatHexColor.java
@@ -19,7 +19,7 @@
@@ -20,7 +20,7 @@
return chathexcolor != null ? DataResult.success(chathexcolor) : DataResult.error("String is not a valid color name or hex color code");
}, ChatHexColor::serialize);
private static final Map<EnumChatFormat, ChatHexColor> LEGACY_FORMAT_TO_COLOR = (Map) Stream.of(EnumChatFormat.values()).filter(EnumChatFormat::isColor).collect(ImmutableMap.toImmutableMap(Function.identity(), (enumchatformat) -> {
@ -9,7 +9,7 @@
}));
private static final Map<String, ChatHexColor> NAMED_COLORS = (Map) ChatHexColor.LEGACY_FORMAT_TO_COLOR.values().stream().collect(ImmutableMap.toImmutableMap((chathexcolor) -> {
return chathexcolor.name;
@@ -27,16 +27,22 @@
@@ -28,16 +28,22 @@
private final int value;
@Nullable
public final String name;

View file

@ -0,0 +1,30 @@
--- a/net/minecraft/network/chat/ChatMessageType.java
+++ b/net/minecraft/network/chat/ChatMessageType.java
@@ -2,6 +2,7 @@
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
+import java.util.List;
import java.util.Optional;
import javax.annotation.Nullable;
import net.minecraft.commands.CommandListenerWrapper;
@@ -27,6 +28,7 @@
public static final ResourceKey<ChatMessageType> TEAM_MSG_COMMAND_INCOMING = create("team_msg_command_incoming");
public static final ResourceKey<ChatMessageType> TEAM_MSG_COMMAND_OUTGOING = create("team_msg_command_outgoing");
public static final ResourceKey<ChatMessageType> EMOTE_COMMAND = create("emote_command");
+ public static final ResourceKey<ChatMessageType> RAW = create("raw"); // CraftBukkit
private static ResourceKey<ChatMessageType> create(String s) {
return ResourceKey.create(IRegistry.CHAT_TYPE_REGISTRY, new MinecraftKey(s));
@@ -39,7 +41,10 @@
RegistryGeneration.register(iregistry, ChatMessageType.MSG_COMMAND_OUTGOING, new ChatMessageType(ChatDecoration.outgoingDirectMessage("commands.message.display.outgoing"), ChatDecoration.withSender("chat.type.text.narrate")));
RegistryGeneration.register(iregistry, ChatMessageType.TEAM_MSG_COMMAND_INCOMING, new ChatMessageType(ChatDecoration.teamMessage("chat.type.team.text"), ChatDecoration.withSender("chat.type.text.narrate")));
RegistryGeneration.register(iregistry, ChatMessageType.TEAM_MSG_COMMAND_OUTGOING, new ChatMessageType(ChatDecoration.teamMessage("chat.type.team.sent"), ChatDecoration.withSender("chat.type.text.narrate")));
- return RegistryGeneration.register(iregistry, ChatMessageType.EMOTE_COMMAND, new ChatMessageType(ChatDecoration.withSender("chat.type.emote"), ChatDecoration.withSender("chat.type.emote")));
+ // CraftBukkit start
+ RegistryGeneration.register(iregistry, ChatMessageType.EMOTE_COMMAND, new ChatMessageType(ChatDecoration.withSender("chat.type.emote"), ChatDecoration.withSender("chat.type.emote")));
+ return RegistryGeneration.register(iregistry, ChatMessageType.RAW, new ChatMessageType(new ChatDecoration("%s", List.of(ChatDecoration.a.CONTENT), ChatModifier.EMPTY), new ChatDecoration("%s", List.of(ChatDecoration.a.CONTENT), ChatModifier.EMPTY)));
+ // CraftBukkit end
}
public static ChatMessageType.a bind(ResourceKey<ChatMessageType> resourcekey, Entity entity) {

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/network/chat/IChatBaseComponent.java
+++ b/net/minecraft/network/chat/IChatBaseComponent.java
@@ -40,7 +40,23 @@
@@ -41,7 +41,23 @@
import net.minecraft.util.ChatTypeAdapterFactory;
import net.minecraft.util.FormattedString;

View file

@ -4,4 +4,4 @@
+// mc-dev import
package net.minecraft.network.protocol.game;
import java.util.Objects;
import net.minecraft.network.PacketDataSerializer;

View file

@ -1,11 +0,0 @@
--- a/net/minecraft/network/protocol/game/PacketPlayInChat.java
+++ b/net/minecraft/network/protocol/game/PacketPlayInChat.java
@@ -25,7 +25,7 @@
}
public PacketPlayInChat(PacketDataSerializer packetdataserializer) {
- this.message = packetdataserializer.readUtf(256);
+ this.message = org.apache.commons.lang3.StringUtils.normalizeSpace(packetdataserializer.readUtf(256)); // CraftBukkit - see PlayerConnection
this.timeStamp = packetdataserializer.readInstant();
this.saltSignature = new MinecraftEncryption.b(packetdataserializer);
this.signedPreview = packetdataserializer.readBoolean();

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/network/syncher/DataWatcher.java
+++ b/net/minecraft/network/syncher/DataWatcher.java
@@ -141,6 +141,13 @@
@@ -142,6 +142,13 @@
}
@ -14,9 +14,9 @@
public boolean isDirty() {
return this.isDirty;
}
@@ -273,7 +280,7 @@
@@ -274,7 +281,7 @@
if (!Objects.equals(datawatcher_item1.accessor.getSerializer(), datawatcher_item.accessor.getSerializer())) {
throw new IllegalStateException(String.format("Invalid entity data item type for field %d on entity %s: old=%s(%s), new=%s(%s)", datawatcher_item.accessor.getId(), this.entity, datawatcher_item.value, datawatcher_item.value.getClass(), datawatcher_item1.value, datawatcher_item1.value.getClass()));
throw new IllegalStateException(String.format(Locale.ROOT, "Invalid entity data item type for field %d on entity %s: old=%s(%s), new=%s(%s)", datawatcher_item.accessor.getId(), this.entity, datawatcher_item.value, datawatcher_item.value.getClass(), datawatcher_item1.value, datawatcher_item1.value.getClass()));
} else {
- datawatcher_item.setValue(datawatcher_item1.getValue());
+ datawatcher_item.setValue((T) datawatcher_item1.getValue()); // CraftBukkit - decompile error

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/server/AdvancementDataPlayer.java
+++ b/net/minecraft/server/AdvancementDataPlayer.java
@@ -180,7 +180,11 @@
@@ -179,7 +179,11 @@
Advancement advancement = advancementdataworld.getAdvancement((MinecraftKey) entry.getKey());
if (advancement == null) {
@ -13,11 +13,11 @@
} else {
this.startProgress(advancement, (AdvancementProgress) entry.getValue());
}
@@ -275,6 +279,7 @@
@@ -274,6 +278,7 @@
this.progressChanged.add(advancement);
flag = true;
if (!flag1 && advancementprogress.isDone()) {
+ this.player.level.getCraftServer().getPluginManager().callEvent(new org.bukkit.event.player.PlayerAdvancementDoneEvent(this.player.getBukkitEntity(), advancement.bukkit)); // CraftBukkit
advancement.getRewards().grant(this.player);
if (advancement.getDisplay() != null && advancement.getDisplay().shouldAnnounceChat() && this.player.level.getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) {
this.playerList.broadcastSystemMessage(IChatBaseComponent.translatable("chat.type.advancement." + advancement.getDisplay().getFrame().getName(), this.player.getDisplayName(), advancement.getChatComponent()), ChatMessageType.SYSTEM);
this.playerList.broadcastSystemMessage(IChatBaseComponent.translatable("chat.type.advancement." + advancement.getDisplay().getFrame().getName(), this.player.getDisplayName(), advancement.getChatComponent()), false);

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/server/MinecraftServer.java
+++ b/net/minecraft/server/MinecraftServer.java
@@ -158,6 +158,28 @@
@@ -157,6 +157,31 @@
import org.apache.commons.lang3.Validate;
import org.slf4j.Logger;
@ -23,13 +23,16 @@
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.craftbukkit.Main;
+import org.bukkit.craftbukkit.generator.CustomWorldChunkManager;
+import org.bukkit.craftbukkit.util.CraftChatMessage;
+import org.bukkit.craftbukkit.util.LazyPlayerSet;
+import org.bukkit.event.player.AsyncPlayerChatPreviewEvent;
+import org.bukkit.event.server.ServerLoadEvent;
+// CraftBukkit end
+
public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTask> implements ICommandListener, AutoCloseable {
public static final Logger LOGGER = LogUtils.getLogger();
@@ -240,6 +262,21 @@
@@ -239,6 +264,21 @@
protected SaveData worldData;
private volatile boolean isSaving;
@ -51,7 +54,7 @@
public static <S extends MinecraftServer> S spin(Function<Thread, S> function) {
AtomicReference<S> atomicreference = new AtomicReference();
Thread thread = new Thread(() -> {
@@ -253,14 +290,14 @@
@@ -252,14 +292,14 @@
thread.setPriority(8);
}
@ -68,7 +71,7 @@
super("Server");
this.metricsRecorder = InactiveMetricsRecorder.INSTANCE;
this.profiler = this.metricsRecorder.getProfiler();
@@ -272,7 +309,7 @@
@@ -271,7 +311,7 @@
this.status = new ServerPing();
this.random = RandomSource.create();
this.port = -1;
@ -77,7 +80,7 @@
this.running = true;
this.tickTimes = new long[100];
this.nextTickTime = SystemUtils.getMillis();
@@ -281,7 +318,7 @@
@@ -280,7 +320,7 @@
this.frameTimer = new CircularTimer();
this.registryHolder = worldstem.registryAccess();
this.worldData = worldstem.worldData();
@ -86,7 +89,7 @@
throw new IllegalStateException("Missing Overworld dimension data");
} else {
this.proxy = proxy;
@@ -302,13 +339,41 @@
@@ -301,13 +341,41 @@
this.serverThread = thread;
this.executor = SystemUtils.backgroundExecutor();
}
@ -129,7 +132,7 @@
ScoreboardServer scoreboardserver1 = this.getScoreboard();
Objects.requireNonNull(scoreboardserver1);
@@ -317,7 +382,7 @@
@@ -316,7 +384,7 @@
protected abstract boolean initServer() throws IOException;
@ -138,7 +141,7 @@
if (!JvmProfiler.INSTANCE.isRunning()) {
;
}
@@ -325,12 +390,8 @@
@@ -324,12 +392,8 @@
boolean flag = false;
ProfiledDuration profiledduration = JvmProfiler.INSTANCE.onWorldLoadedStarted();
@ -152,7 +155,7 @@
if (profiledduration != null) {
profiledduration.finish();
}
@@ -345,25 +406,189 @@
@@ -344,25 +408,189 @@
}
@ -317,14 +320,10 @@
+
+ worlddata.setModdedInfo(this.getServerModName(), this.getModdedStatus().shouldReportAsModified());
+ this.initWorld(world, worlddata, worldData, worlddata.worldGenSettings());
- this.levels.put(World.OVERWORLD, worldserver);
- WorldPersistentData worldpersistentdata = worldserver.getDataStorage();
+
+ this.levels.put(world.dimension(), world);
+ this.getPlayerList().addWorldborderListener(world);
- this.readScoreboard(worldpersistentdata);
- this.commandStorage = new PersistentCommandStorage(worldpersistentdata);
+
+ if (worlddata.getCustomBossEvents() != null) {
+ this.getCustomBossEvents().load(worlddata.getCustomBossEvents());
+ }
@ -335,7 +334,9 @@
+ worldserver.entityManager.tick(); // SPIGOT-6526: Load pending entities so they are available to the API
+ this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldLoadEvent(worldserver.getWorld()));
+ }
+
- this.levels.put(World.OVERWORLD, worldserver);
- WorldPersistentData worldpersistentdata = worldserver.getDataStorage();
+ this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.POSTWORLD);
+ this.server.getPluginManager().callEvent(new ServerLoadEvent(ServerLoadEvent.LoadType.STARTUP));
+ this.connection.acceptConnections();
@ -343,7 +344,9 @@
+ // CraftBukkit end
+
+ protected void forceDifficulty() {}
+
- this.readScoreboard(worldpersistentdata);
- this.commandStorage = new PersistentCommandStorage(worldpersistentdata);
+ // CraftBukkit start
+ public void initWorld(WorldServer worldserver, IWorldDataServer iworlddataserver, SaveData saveData, GeneratorSettings generatorsettings) {
+ boolean flag = generatorsettings.isDebug();
@ -357,7 +360,7 @@
if (!iworlddataserver.isInitialized()) {
try {
@@ -387,29 +612,8 @@
@@ -386,29 +614,8 @@
iworlddataserver.setInitialized(true);
}
@ -388,7 +391,7 @@
private static void setInitialSpawn(WorldServer worldserver, IWorldDataServer iworlddataserver, boolean flag, boolean flag1) {
if (flag1) {
@@ -417,6 +621,21 @@
@@ -416,6 +623,21 @@
} else {
ChunkProviderServer chunkproviderserver = worldserver.getChunkSource();
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(chunkproviderserver.randomState().sampler().findSpawnPosition());
@ -410,7 +413,7 @@
int i = chunkproviderserver.getGenerator().getSpawnHeight(worldserver);
if (i < worldserver.getMinBuildHeight()) {
@@ -474,8 +693,11 @@
@@ -473,8 +695,11 @@
iworlddataserver.setGameType(EnumGamemode.SPECTATOR);
}
@ -424,7 +427,7 @@
MinecraftServer.LOGGER.info("Preparing start region for dimension {}", worldserver.dimension().location());
BlockPosition blockposition = worldserver.getSharedSpawnPos();
@@ -485,19 +707,23 @@
@@ -484,19 +709,23 @@
chunkproviderserver.getLightEngine().setTaskPerBatch(500);
this.nextTickTime = SystemUtils.getMillis();
@ -457,7 +460,7 @@
ForcedChunk forcedchunk = (ForcedChunk) worldserver1.getDataStorage().get(ForcedChunk::load, "chunks");
if (forcedchunk != null) {
@@ -512,11 +738,18 @@
@@ -511,11 +740,18 @@
}
}
@ -479,7 +482,7 @@
}
public EnumGamemode getDefaultGameType() {
@@ -546,12 +779,16 @@
@@ -545,12 +781,16 @@
worldserver.save((IProgressUpdate) null, flag1, worldserver.noSave && !flag2);
}
@ -496,7 +499,7 @@
if (flag1) {
Iterator iterator1 = this.getAllLevels().iterator();
@@ -586,12 +823,33 @@
@@ -585,12 +825,33 @@
this.stopServer();
}
@ -530,7 +533,7 @@
if (this.getConnection() != null) {
this.getConnection().stop();
}
@@ -601,6 +859,7 @@
@@ -600,6 +861,7 @@
MinecraftServer.LOGGER.info("Saving players");
this.playerList.saveAll();
this.playerList.removeAll();
@ -538,7 +541,7 @@
}
MinecraftServer.LOGGER.info("Saving worlds");
@@ -696,9 +955,10 @@
@@ -696,9 +958,10 @@
while (this.running) {
long i = SystemUtils.getMillis() - this.nextTickTime;
@ -550,7 +553,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;
@@ -709,6 +969,7 @@
@@ -709,6 +972,7 @@
this.debugCommandProfiler = new MinecraftServer.TimeProfiler(SystemUtils.getNanos(), this.tickCount);
}
@ -558,7 +561,7 @@
this.nextTickTime += 50L;
this.startMetricsRecordingTick();
this.profiler.push("tick");
@@ -750,6 +1011,12 @@
@@ -747,6 +1011,12 @@
this.services.profileCache().clearExecutor();
}
@ -571,7 +574,7 @@
this.onServerExit();
}
@@ -783,8 +1050,15 @@
@@ -780,8 +1050,15 @@
}
private boolean haveTime() {
@ -588,7 +591,7 @@
protected void waitUntilNextTick() {
this.runAllTasks();
@@ -830,7 +1104,7 @@
@@ -827,7 +1104,7 @@
}
}
@ -597,7 +600,7 @@
this.getProfiler().incrementCounter("runTask");
super.doRunTask(ticktask);
}
@@ -901,7 +1175,7 @@
@@ -898,7 +1175,7 @@
}
}
@ -606,7 +609,7 @@
MinecraftServer.LOGGER.debug("Autosave started");
this.profiler.push("save");
this.saveEverything(true, false, false);
@@ -920,22 +1194,39 @@
@@ -917,22 +1194,39 @@
}
public void tickChildren(BooleanSupplier booleansupplier) {
@ -646,7 +649,7 @@
this.profiler.push("tick");
@@ -1024,7 +1315,7 @@
@@ -1021,7 +1315,7 @@
@DontObfuscate
public String getServerModName() {
@ -655,7 +658,7 @@
}
public SystemReport fillSystemReport(SystemReport systemreport) {
@@ -1375,11 +1666,11 @@
@@ -1372,11 +1666,11 @@
public CompletableFuture<Void> reloadResources(Collection<String> collection) {
IRegistryCustom.Dimension iregistrycustom_dimension = this.registryAccess();
CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> {
@ -669,7 +672,7 @@
}, this).thenCompose((immutablelist) -> {
ResourceManager resourcemanager = new ResourceManager(EnumResourcePackType.SERVER_DATA, immutablelist);
@@ -1394,6 +1685,7 @@
@@ -1391,6 +1685,7 @@
}).thenAcceptAsync((minecraftserver_reloadableresources) -> {
this.resources.close();
this.resources = minecraftserver_reloadableresources;
@ -677,7 +680,7 @@
this.packRepository.setSelected(collection);
this.worldData.setDataPackConfig(getSelectedPacks(this.packRepository));
this.resources.managers.updateRegistryTags(this.registryAccess());
@@ -1743,7 +2035,7 @@
@@ -1740,7 +2035,7 @@
try {
label51:
{
@ -686,7 +689,7 @@
try {
arraylist = Lists.newArrayList(NativeModuleLister.listModules());
@@ -1793,6 +2085,22 @@
@@ -1790,6 +2085,22 @@
}
@ -709,3 +712,30 @@
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) -> {
@@ -1912,8 +2223,25 @@
}
+ // CraftBukkit start
+ public final java.util.concurrent.ExecutorService chatExecutor = java.util.concurrent.Executors.newCachedThreadPool(
+ new com.google.common.util.concurrent.ThreadFactoryBuilder().setDaemon(true).setNameFormat("Async Chat Thread - #%d").build());
+
public ChatDecorator getChatDecorator() {
- return ChatDecorator.PLAIN;
+ return (entityplayer, ichatbasecomponent) -> {
+ return CompletableFuture.supplyAsync(() -> {
+ AsyncPlayerChatPreviewEvent event = new AsyncPlayerChatPreviewEvent(true, entityplayer.getBukkitEntity(), CraftChatMessage.fromComponent(ichatbasecomponent), new LazyPlayerSet(this));
+ String originalFormat = event.getFormat(), originalMessage = event.getMessage();
+ this.server.getPluginManager().callEvent(event);
+
+ if (originalFormat.equals(event.getFormat()) && originalMessage.equals(event.getMessage()) && event.getPlayer().getName().equalsIgnoreCase(event.getPlayer().getDisplayName())) {
+ return ichatbasecomponent;
+ }
+
+ return CraftChatMessage.fromStringOrNull(String.format(event.getFormat(), event.getPlayer().getDisplayName(), event.getMessage()));
+ }, chatExecutor);
+ };
+ // CraftBukkit end
}
public static record ReloadableResources(IReloadableResourceManager resourceManager, DataPackResources managers) implements AutoCloseable {

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/server/level/EntityPlayer.java
+++ b/net/minecraft/server/level/EntityPlayer.java
@@ -147,6 +147,35 @@
@@ -148,6 +148,35 @@
import net.minecraft.world.scores.criteria.IScoreboardCriteria;
import org.slf4j.Logger;
@ -36,7 +36,7 @@
public class EntityPlayer extends EntityHuman {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -201,6 +230,21 @@
@@ -202,6 +231,21 @@
public int latency;
public boolean wonGame;
@ -58,7 +58,7 @@
public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, @Nullable ProfilePublicKey profilepublickey) {
super(worldserver, worldserver.getSharedSpawnPos(), worldserver.getSharedSpawnAngle(), gameprofile, profilepublickey);
this.chatVisibility = EnumChatVisibility.FULL;
@@ -263,12 +307,56 @@
@@ -264,12 +308,56 @@
this.advancements = minecraftserver.getPlayerList().getPlayerAdvancements(this);
this.maxUpStep = 1.0F;
this.fudgeSpawnLocation(worldserver);
@ -116,7 +116,7 @@
int i = Math.max(0, this.server.getSpawnRadius(worldserver));
int j = MathHelper.floor(worldserver.getWorldBorder().getDistanceToBorder((double) blockposition.getX(), (double) blockposition.getZ()));
@@ -326,17 +414,26 @@
@@ -327,17 +415,26 @@
if (nbttagcompound.contains("recipeBook", 10)) {
this.recipeBook.fromNbt(nbttagcompound.getCompound("recipeBook"), this.server.getRecipeManager());
}
@ -144,7 +144,7 @@
Logger logger = EntityPlayer.LOGGER;
Objects.requireNonNull(logger);
@@ -363,7 +460,20 @@
@@ -364,7 +461,20 @@
Entity entity = this.getRootVehicle();
Entity entity1 = this.getVehicle();
@ -166,7 +166,7 @@
NBTTagCompound nbttagcompound2 = new NBTTagCompound();
NBTTagCompound nbttagcompound3 = new NBTTagCompound();
@@ -381,7 +491,7 @@
@@ -382,7 +492,7 @@
nbttagcompound.putInt("SpawnZ", this.respawnPosition.getZ());
nbttagcompound.putBoolean("SpawnForced", this.respawnForced);
nbttagcompound.putFloat("SpawnAngle", this.respawnAngle);
@ -175,7 +175,7 @@
Logger logger = EntityPlayer.LOGGER;
Objects.requireNonNull(logger);
@@ -389,8 +499,32 @@
@@ -390,8 +500,32 @@
nbttagcompound.put("SpawnDimension", nbtbase);
});
}
@ -208,7 +208,7 @@
public void setExperiencePoints(int i) {
float f = (float) this.getXpNeededForNextLevel();
@@ -450,6 +584,11 @@
@@ -451,6 +585,11 @@
@Override
public void tick() {
@ -220,7 +220,7 @@
this.gameMode.tick();
--this.spawnInvulnerableTime;
if (this.invulnerableTime > 0) {
@@ -505,7 +644,7 @@
@@ -506,7 +645,7 @@
}
if (this.getHealth() != this.lastSentHealth || this.lastSentFood != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) {
@ -229,7 +229,7 @@
this.lastSentHealth = this.getHealth();
this.lastSentFood = this.foodData.getFoodLevel();
this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F;
@@ -536,6 +675,12 @@
@@ -537,6 +676,12 @@
this.updateScoreForCriteria(IScoreboardCriteria.EXPERIENCE, MathHelper.ceil((float) this.lastRecordedExperience));
}
@ -242,7 +242,7 @@
if (this.experienceLevel != this.lastRecordedLevel) {
this.lastRecordedLevel = this.experienceLevel;
this.updateScoreForCriteria(IScoreboardCriteria.LEVEL, MathHelper.ceil((float) this.lastRecordedLevel));
@@ -550,6 +695,20 @@
@@ -551,6 +696,20 @@
CriterionTriggers.LOCATION.trigger(this);
}
@ -263,7 +263,7 @@
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Ticking player");
CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Player being ticked");
@@ -592,7 +751,8 @@
@@ -593,7 +752,8 @@
}
private void updateScoreForCriteria(IScoreboardCriteria iscoreboardcriteria, int i) {
@ -273,7 +273,7 @@
scoreboardscore.setScore(i);
});
}
@@ -601,9 +761,47 @@
@@ -602,9 +762,47 @@
public void die(DamageSource damagesource) {
this.gameEvent(GameEvent.ENTITY_DIE);
boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES);
@ -321,9 +321,9 @@
+ ichatbasecomponent = org.bukkit.craftbukkit.util.CraftChatMessage.fromStringOrNull(deathMessage);
+ }
this.connection.send(new ClientboundPlayerCombatKillPacket(this.getCombatTracker(), ichatbasecomponent), (future) -> {
if (!future.isSuccess()) {
@@ -637,12 +835,18 @@
this.connection.send(new ClientboundPlayerCombatKillPacket(this.getCombatTracker(), ichatbasecomponent), PacketSendListener.exceptionallySend(() -> {
boolean flag1 = true;
@@ -635,12 +833,18 @@
if (this.level.getGameRules().getBoolean(GameRules.RULE_FORGIVE_DEAD_PLAYERS)) {
this.tellNeutralMobsThatIDied();
}
@ -346,7 +346,7 @@
EntityLiving entityliving = this.getKillCredit();
if (entityliving != null) {
@@ -680,10 +884,12 @@
@@ -678,10 +882,12 @@
String s = this.getScoreboardName();
String s1 = entity.getScoreboardName();
@ -361,7 +361,7 @@
} else {
this.awardStat(StatisticList.MOB_KILLS);
}
@@ -701,7 +907,8 @@
@@ -699,7 +905,8 @@
int i = scoreboardteam.getColor().getId();
if (i >= 0 && i < aiscoreboardcriteria.length) {
@ -371,7 +371,7 @@
}
}
@@ -745,18 +952,20 @@
@@ -743,18 +950,20 @@
}
private boolean isPvpAllowed() {
@ -395,7 +395,7 @@
} else {
return shapedetectorshape;
}
@@ -765,11 +974,20 @@
@@ -763,11 +972,20 @@
@Nullable
@Override
public Entity changeDimension(WorldServer worldserver) {
@ -419,7 +419,7 @@
this.unRide();
this.getLevel().removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION);
if (!this.wonGame) {
@@ -780,6 +998,8 @@
@@ -778,6 +996,8 @@
return this;
} else {
@ -428,7 +428,7 @@
WorldData worlddata = worldserver.getLevelData();
this.connection.send(new PacketPlayOutRespawn(worldserver.dimensionTypeId(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), true, this.getLastDeathLocation()));
@@ -789,22 +1009,52 @@
@@ -787,22 +1007,52 @@
playerlist.sendPlayerPermissionLevel(this);
worldserver1.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION);
this.unsetRemoved();
@ -487,7 +487,7 @@
worldserver1.getProfiler().pop();
this.triggerDimensionChangeTriggers(worldserver1);
this.connection.send(new PacketPlayOutAbilities(this.getAbilities()));
@@ -822,12 +1072,31 @@
@@ -820,12 +1070,31 @@
this.lastSentExp = -1;
this.lastSentHealth = -1.0F;
this.lastSentFood = -1;
@ -519,7 +519,7 @@
private void createEndPlatform(WorldServer worldserver, BlockPosition blockposition) {
BlockPosition.MutableBlockPosition blockposition_mutableblockposition = blockposition.mutable();
@@ -844,17 +1113,17 @@
@@ -842,17 +1111,17 @@
}
@Override
@ -542,7 +542,7 @@
}
return optional1;
@@ -864,13 +1133,21 @@
@@ -862,13 +1131,21 @@
public void triggerDimensionChangeTriggers(WorldServer worldserver) {
ResourceKey<World> resourcekey = worldserver.dimension();
ResourceKey<World> resourcekey1 = this.level.dimension();
@ -567,7 +567,7 @@
this.enteredNetherPosition = null;
}
@@ -887,12 +1164,10 @@
@@ -885,12 +1162,10 @@
this.containerMenu.broadcastChanges();
}
@ -583,7 +583,7 @@
return Either.left(EntityHuman.EnumBedResult.NOT_POSSIBLE_HERE);
} else if (!this.bedInRange(blockposition, enumdirection)) {
return Either.left(EntityHuman.EnumBedResult.TOO_FAR_AWAY);
@@ -916,7 +1191,36 @@
@@ -914,7 +1189,36 @@
}
}
@ -621,7 +621,7 @@
this.awardStat(StatisticList.SLEEP_IN_BED);
CriterionTriggers.SLEPT_IN_BED.trigger(this);
});
@@ -929,9 +1233,8 @@
@@ -927,9 +1231,8 @@
return either;
}
}
@ -632,7 +632,7 @@
}
@Override
@@ -958,6 +1261,24 @@
@@ -956,6 +1259,24 @@
@Override
public void stopSleepInBed(boolean flag, boolean flag1) {
@ -657,7 +657,7 @@
if (this.isSleeping()) {
this.getLevel().getChunkSource().broadcastAndSend(this, new PacketPlayOutAnimation(this, 2));
}
@@ -1039,8 +1360,9 @@
@@ -1037,8 +1358,9 @@
this.connection.send(new PacketPlayOutOpenSignEditor(tileentitysign.getBlockPos()));
}
@ -668,7 +668,7 @@
}
@Override
@@ -1048,13 +1370,35 @@
@@ -1046,13 +1368,35 @@
if (itileinventory == null) {
return OptionalInt.empty();
} else {
@ -704,7 +704,7 @@
if (container == null) {
if (this.isSpectator()) {
this.displayClientMessage(IChatBaseComponent.translatable("container.spectatorCantOpen").withStyle(EnumChatFormat.RED), true);
@@ -1062,9 +1406,11 @@
@@ -1060,9 +1404,11 @@
return OptionalInt.empty();
} else {
@ -718,7 +718,7 @@
return OptionalInt.of(this.containerCounter);
}
}
@@ -1077,13 +1423,24 @@
@@ -1075,13 +1421,24 @@
@Override
public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) {
@ -745,7 +745,7 @@
this.initMenu(this.containerMenu);
}
@@ -1106,6 +1463,7 @@
@@ -1104,6 +1461,7 @@
@Override
public void closeContainer() {
@ -753,7 +753,7 @@
this.connection.send(new PacketPlayOutCloseWindow(this.containerMenu.containerId));
this.doCloseContainer();
}
@@ -1135,7 +1493,7 @@
@@ -1133,7 +1491,7 @@
@Override
public void awardStat(Statistic<?> statistic, int i) {
this.stats.increment(this, statistic, i);
@ -762,7 +762,7 @@
scoreboardscore.add(i);
});
}
@@ -1143,7 +1501,7 @@
@@ -1141,7 +1499,7 @@
@Override
public void resetStat(Statistic<?> statistic) {
this.stats.setValue(this, statistic, 0);
@ -771,7 +771,7 @@
}
@Override
@@ -1159,7 +1517,7 @@
@@ -1157,7 +1515,7 @@
for (int j = 0; j < i; ++j) {
MinecraftKey minecraftkey = aminecraftkey1[j];
@ -780,7 +780,7 @@
Objects.requireNonNull(list);
optional.ifPresent(list::add);
@@ -1194,6 +1552,7 @@
@@ -1192,6 +1550,7 @@
public void resetSentInfo() {
this.lastSentHealth = -1.0E8F;
@ -788,7 +788,7 @@
}
@Override
@@ -1249,7 +1608,7 @@
@@ -1247,7 +1606,7 @@
this.lastSentExp = -1;
this.lastSentHealth = -1.0F;
this.lastSentFood = -1;
@ -797,7 +797,7 @@
this.seenCredits = entityplayer.seenCredits;
this.enteredNetherPosition = entityplayer.enteredNetherPosition;
this.setShoulderEntityLeft(entityplayer.getShoulderEntityLeft());
@@ -1397,7 +1756,20 @@
@@ -1390,7 +1749,20 @@
return s;
}
@ -818,7 +818,7 @@
this.chatVisibility = packetplayinsettings.chatVisibility();
this.canChatColor = packetplayinsettings.chatColors();
this.textFilteringEnabled = packetplayinsettings.textFilteringEnabled();
@@ -1472,7 +1844,7 @@
@@ -1461,7 +1833,7 @@
this.camera = (Entity) (entity == null ? this : entity);
if (entity1 != this.camera) {
this.connection.send(new PacketPlayOutCamera(this.camera));
@ -827,7 +827,7 @@
}
}
@@ -1501,7 +1873,7 @@
@@ -1490,7 +1862,7 @@
@Nullable
public IChatBaseComponent getTabListDisplayName() {
@ -836,7 +836,7 @@
}
@Override
@@ -1522,9 +1894,16 @@
@@ -1511,9 +1883,16 @@
return this.advancements;
}
@ -853,7 +853,7 @@
if (worldserver == this.level) {
this.connection.teleport(d0, d1, d2, f, f1);
} else {
@@ -1544,6 +1923,9 @@
@@ -1533,6 +1912,9 @@
this.server.getPlayerList().sendLevelInfo(this, worldserver);
this.server.getPlayerList().sendAllPlayerInfo(this);
}
@ -863,7 +863,7 @@
}
@@ -1713,4 +2095,146 @@
@@ -1702,4 +2084,146 @@
}
}

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/server/level/PlayerChunkMap.java
+++ b/net/minecraft/server/level/PlayerChunkMap.java
@@ -102,6 +102,12 @@
@@ -103,6 +103,12 @@
import org.apache.commons.lang3.mutable.MutableObject;
import org.slf4j.Logger;
@ -13,7 +13,7 @@
public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.e {
private static final byte CHUNK_TYPE_REPLACEABLE = -1;
@@ -144,6 +150,27 @@
@@ -145,6 +151,27 @@
private final Queue<Runnable> unloadQueue;
int viewDistance;
@ -41,7 +41,7 @@
public PlayerChunkMap(WorldServer worldserver, Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, StructureTemplateManager structuretemplatemanager, Executor executor, IAsyncTaskHandler<Runnable> iasynctaskhandler, ILightAccess ilightaccess, ChunkGenerator chunkgenerator, WorldLoadListener worldloadlistener, ChunkStatusUpdateListener chunkstatusupdatelistener, Supplier<WorldPersistentData> supplier, int i, boolean flag) {
super(convertable_conversionsession.getDimensionPath(worldserver.dimension()).resolve("region"), datafixer, flag);
this.visibleChunkMap = this.updatingChunkMap.clone();
@@ -162,6 +189,11 @@
@@ -163,6 +190,11 @@
this.storageName = path.getFileName().toString();
this.level = worldserver;
this.generator = chunkgenerator;
@ -53,7 +53,7 @@
if (chunkgenerator instanceof ChunkGeneratorAbstract) {
ChunkGeneratorAbstract chunkgeneratorabstract = (ChunkGeneratorAbstract) chunkgenerator;
@@ -313,9 +345,12 @@
@@ -314,9 +346,12 @@
CompletableFuture<List<Either<IChunkAccess, PlayerChunk.Failure>>> completablefuture1 = SystemUtils.sequence(list);
CompletableFuture<Either<List<IChunkAccess>, PlayerChunk.Failure>> completablefuture2 = completablefuture1.thenApply((list2) -> {
List<IChunkAccess> list3 = Lists.newArrayList();
@ -68,7 +68,7 @@
final Either<IChunkAccess, PlayerChunk.Failure> either = (Either) iterator.next();
if (either == null) {
@@ -520,7 +555,7 @@
@@ -521,7 +556,7 @@
private void scheduleUnload(long i, PlayerChunk playerchunk) {
CompletableFuture<IChunkAccess> completablefuture = playerchunk.getChunkToSave();
@ -77,7 +77,7 @@
CompletableFuture<IChunkAccess> completablefuture1 = playerchunk.getChunkToSave();
if (completablefuture1 != completablefuture) {
@@ -609,9 +644,9 @@
@@ -610,9 +645,9 @@
ProtoChunk protochunk = ChunkRegionLoader.read(this.level, this.poiManager, chunkcoordintpair, (NBTTagCompound) optional.get());
this.markPosition(chunkcoordintpair, protochunk.getStatus().getChunkType());
@ -89,7 +89,7 @@
}
}, this.mainThreadExecutor).exceptionallyAsync((throwable) -> {
return this.handleChunkLoadFailure(throwable, chunkcoordintpair);
@@ -717,7 +752,21 @@
@@ -718,7 +753,21 @@
private static void postLoadProtoChunk(WorldServer worldserver, List<NBTTagCompound> list) {
if (!list.isEmpty()) {
@ -112,7 +112,7 @@
}
}
@@ -816,7 +865,7 @@
@@ -817,7 +866,7 @@
if (!playerchunk.wasAccessibleSinceLastSave()) {
return false;
} else {
@ -121,7 +121,7 @@
if (!(ichunkaccess instanceof ProtoChunkExtension) && !(ichunkaccess instanceof Chunk)) {
return false;
@@ -978,7 +1027,8 @@
@@ -979,7 +1028,8 @@
return ichunkaccess instanceof Chunk ? Optional.of((Chunk) ichunkaccess) : Optional.empty();
});
@ -131,7 +131,7 @@
return chunk.getBlockEntities().size();
}).orElse(0), tickingtracker.getTicketDebugString(i), tickingtracker.getLevel(i), optional1.map((chunk) -> {
return chunk.getBlockTicks().count();
@@ -991,7 +1041,7 @@
@@ -992,7 +1042,7 @@
private static String printFuture(CompletableFuture<Either<Chunk, PlayerChunk.Failure>> completablefuture) {
try {
@ -140,7 +140,7 @@
return either != null ? (String) either.map((chunk) -> {
return "done";
@@ -1007,12 +1057,14 @@
@@ -1008,12 +1058,14 @@
private CompletableFuture<Optional<NBTTagCompound>> readChunk(ChunkCoordIntPair chunkcoordintpair) {
return this.read(chunkcoordintpair).thenApplyAsync((optional) -> {
@ -158,7 +158,7 @@
}
boolean anyPlayerCloseEnoughForSpawning(ChunkCoordIntPair chunkcoordintpair) {
@@ -1433,7 +1485,7 @@
@@ -1434,7 +1486,7 @@
public final Set<ServerPlayerConnection> seenBy = Sets.newIdentityHashSet();
public EntityTracker(Entity entity, int i, int j, boolean flag) {
@ -167,7 +167,7 @@
this.entity = entity;
this.range = i;
this.lastSectionPos = SectionPosition.of((EntityAccess) entity);
@@ -1492,6 +1544,11 @@
@@ -1493,6 +1545,11 @@
double d2 = d0 * d0;
boolean flag = d1 <= d2 && this.entity.broadcastToPlayer(entityplayer);

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/server/level/RegionLimitedWorldAccess.java
+++ b/net/minecraft/server/level/RegionLimitedWorldAccess.java
@@ -206,7 +206,7 @@
@@ -207,7 +207,7 @@
if (iblockdata.isAir()) {
return false;
} else {
@ -9,7 +9,7 @@
TileEntity tileentity = iblockdata.hasBlockEntity() ? this.getBlockEntity(blockposition) : null;
Block.dropResources(iblockdata, this.level, blockposition, tileentity, entity, ItemStack.EMPTY);
@@ -325,6 +325,13 @@
@@ -326,6 +326,13 @@
@Override
public boolean addFreshEntity(Entity entity) {

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/server/level/WorldServer.java
+++ b/net/minecraft/server/level/WorldServer.java
@@ -152,6 +152,26 @@
@@ -153,6 +153,26 @@
import net.minecraft.world.ticks.TickListServer;
import org.slf4j.Logger;
@ -27,7 +27,7 @@
public class WorldServer extends World implements GeneratorAccessSeed {
public static final BlockPosition END_SPAWN_POINT = new BlockPosition(100, 50, 0);
@@ -169,7 +189,7 @@
@@ -170,7 +190,7 @@
final List<EntityPlayer> players;
private final ChunkProviderServer chunkSource;
private final MinecraftServer server;
@ -36,7 +36,7 @@
final EntityTickList entityTickList;
public final PersistentEntitySectionManager<Entity> entityManager;
public boolean noSave;
@@ -193,11 +213,28 @@
@@ -194,11 +214,28 @@
private final StructureCheck structureCheck;
private final boolean tickTime;
@ -69,7 +69,7 @@
this.players = Lists.newArrayList();
this.entityTickList = new EntityTickList();
this.blockTicks = new TickListServer<>(this::isPositionTickingWithEntitiesLoaded, this.getProfilerSupplier());
@@ -212,6 +249,22 @@
@@ -213,6 +250,22 @@
this.customSpawners = list;
this.serverLevelData = iworlddataserver;
ChunkGenerator chunkgenerator = worlddimension.generator();
@ -92,7 +92,7 @@
boolean flag2 = minecraftserver.forceSynchronousWrites();
DataFixer datafixer = minecraftserver.getFixerUpper();
EntityPersistentStorage<Entity> entitypersistentstorage = new EntityStorage(this, convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, minecraftserver);
@@ -243,14 +296,15 @@
@@ -244,14 +297,15 @@
long l = minecraftserver.getWorldData().worldGenSettings().seed();
this.structureCheck = new StructureCheck(this.chunkSource.chunkScanner(), this.registryAccess(), minecraftserver.getStructureManager(), resourcekey, chunkgenerator, this.chunkSource.randomState(), this, chunkgenerator.getBiomeSource(), l, datafixer);
@ -111,7 +111,7 @@
}
public void setWeatherParameters(int i, int j, boolean flag, boolean flag1) {
@@ -282,12 +336,20 @@
@@ -283,12 +337,20 @@
long j;
if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) {
@ -135,7 +135,7 @@
if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE) && this.isRaining()) {
this.resetWeatherCycle();
}
@@ -313,7 +375,7 @@
@@ -314,7 +376,7 @@
this.runBlockEvents();
this.handlingTick = false;
gameprofilerfiller.pop();
@ -144,7 +144,7 @@
if (flag) {
this.resetEmptyTime();
@@ -329,7 +391,7 @@
@@ -330,7 +392,7 @@
this.entityTickList.forEach((entity) -> {
if (!entity.isRemoved()) {
@ -153,7 +153,7 @@
entity.discard();
} else {
gameprofilerfiller.push("checkDespawn");
@@ -403,7 +465,7 @@
@@ -404,7 +466,7 @@
private void wakeUpAllPlayers() {
this.sleepStatus.removeAllSleepers();
@ -162,7 +162,7 @@
entityplayer.stopSleepInBed(false, false);
});
}
@@ -430,14 +492,14 @@
@@ -431,14 +493,14 @@
entityhorseskeleton.setTrap(true);
entityhorseskeleton.setAge(0);
entityhorseskeleton.setPos((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ());
@ -179,7 +179,7 @@
}
}
@@ -448,12 +510,12 @@
@@ -449,12 +511,12 @@
BiomeBase biomebase = (BiomeBase) this.getBiome(blockposition).value();
if (biomebase.shouldFreeze(this, blockposition1)) {
@ -194,7 +194,7 @@
}
IBlockData iblockdata = this.getBlockState(blockposition1);
@@ -649,6 +711,7 @@
@@ -650,6 +712,7 @@
this.rainLevel = MathHelper.clamp(this.rainLevel, 0.0F, 1.0F);
}
@ -202,7 +202,7 @@
if (this.oRainLevel != this.rainLevel) {
this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel), this.dimension());
}
@@ -667,14 +730,47 @@
@@ -668,14 +731,47 @@
this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel));
this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, this.thunderLevel));
}
@ -252,7 +252,7 @@
}
public void resetEmptyTime() {
@@ -709,6 +805,7 @@
@@ -710,6 +806,7 @@
});
gameprofilerfiller.incrementCounter("tickNonPassenger");
entity.tick();
@ -260,7 +260,7 @@
this.getProfiler().pop();
Iterator iterator = entity.getPassengers().iterator();
@@ -732,6 +829,7 @@
@@ -733,6 +830,7 @@
});
gameprofilerfiller.incrementCounter("tickPassenger");
entity1.rideTick();
@ -268,7 +268,7 @@
gameprofilerfiller.pop();
Iterator iterator = entity1.getPassengers().iterator();
@@ -756,6 +854,7 @@
@@ -757,6 +855,7 @@
ChunkProviderServer chunkproviderserver = this.getChunkSource();
if (!flag1) {
@ -276,7 +276,7 @@
if (iprogressupdate != null) {
iprogressupdate.progressStartNoAbort(IChatBaseComponent.translatable("menu.savingLevel"));
}
@@ -773,11 +872,19 @@
@@ -774,11 +873,19 @@
}
}
@ -297,7 +297,7 @@
}
this.getChunkSource().getDataStorage().save();
@@ -823,15 +930,37 @@
@@ -824,15 +931,37 @@
@Override
public boolean addFreshEntity(Entity entity) {
@ -338,7 +338,7 @@
}
public void addDuringCommandTeleport(EntityPlayer entityplayer) {
@@ -862,24 +991,37 @@
@@ -863,24 +992,37 @@
this.entityManager.addNewEntity(entityplayer);
}
@ -380,7 +380,7 @@
return true;
}
}
@@ -893,10 +1035,32 @@
@@ -894,10 +1036,32 @@
entityplayer.remove(entity_removalreason);
}
@ -413,7 +413,7 @@
while (iterator.hasNext()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
@@ -905,6 +1069,12 @@
@@ -906,6 +1070,12 @@
double d1 = (double) blockposition.getY() - entityplayer.getY();
double d2 = (double) blockposition.getZ() - entityplayer.getZ();
@ -426,7 +426,7 @@
if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) {
entityplayer.connection.send(new PacketPlayOutBlockBreakAnimation(i, blockposition, j));
}
@@ -941,6 +1111,14 @@
@@ -942,6 +1112,14 @@
public void gameEvent(GameEvent gameevent, Vec3D vec3d, GameEvent.a gameevent_a) {
int i = gameevent.getNotificationRadius();
BlockPosition blockposition = new BlockPosition(vec3d);
@ -441,7 +441,7 @@
int j = SectionPosition.blockToSectionCoord(blockposition.getX() - i);
int k = SectionPosition.blockToSectionCoord(blockposition.getY() - i);
int l = SectionPosition.blockToSectionCoord(blockposition.getZ() - i);
@@ -1013,7 +1191,18 @@
@@ -1014,7 +1192,18 @@
Iterator iterator = this.navigatingMobs.iterator();
while (iterator.hasNext()) {
@ -461,7 +461,7 @@
NavigationAbstract navigationabstract = entityinsentient.getNavigation();
if (navigationabstract.shouldRecomputePath(blockposition)) {
@@ -1069,10 +1258,20 @@
@@ -1070,10 +1259,20 @@
@Override
public Explosion explode(@Nullable Entity entity, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator explosiondamagecalculator, double d0, double d1, double d2, float f, boolean flag, Explosion.Effect explosion_effect) {
@ -482,7 +482,7 @@
if (explosion_effect == Explosion.Effect.NONE) {
explosion.clearToBlow();
}
@@ -1144,13 +1343,20 @@
@@ -1145,13 +1344,20 @@
}
public <T extends ParticleParam> int sendParticles(T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) {
@ -505,7 +505,7 @@
++j;
}
}
@@ -1201,7 +1407,7 @@
@@ -1202,7 +1408,7 @@
@Nullable
public BlockPosition findNearestMapStructure(TagKey<Structure> tagkey, BlockPosition blockposition, int i, boolean flag) {
@ -514,7 +514,7 @@
return null;
} else {
Optional<HolderSet.Named<Structure>> optional = this.registryAccess().registryOrThrow(IRegistry.STRUCTURE_REGISTRY).getTag(tagkey);
@@ -1243,11 +1449,21 @@
@@ -1244,11 +1450,21 @@
@Nullable
@Override
public WorldMap getMapData(String s) {
@ -537,7 +537,7 @@
this.getServer().overworld().getDataStorage().set(s, worldmap);
}
@@ -1545,6 +1761,11 @@
@@ -1546,6 +1762,11 @@
@Override
public void blockUpdated(BlockPosition blockposition, Block block) {
if (!this.isDebug()) {
@ -549,7 +549,7 @@
this.updateNeighborsAt(blockposition, block);
}
@@ -1564,12 +1785,12 @@
@@ -1565,12 +1786,12 @@
}
public boolean isFlat() {
@ -564,7 +564,7 @@
}
@Nullable
@@ -1592,7 +1813,7 @@
@@ -1593,7 +1814,7 @@
private static <T> String getTypeCount(Iterable<T> iterable, Function<T, String> function) {
try {
Object2IntOpenHashMap<String> object2intopenhashmap = new Object2IntOpenHashMap();
@ -573,7 +573,7 @@
while (iterator.hasNext()) {
T t0 = iterator.next();
@@ -1601,7 +1822,7 @@
@@ -1602,7 +1823,7 @@
object2intopenhashmap.addTo(s, 1);
}
@ -582,7 +582,7 @@
String s1 = (String) entry.getKey();
return s1 + ":" + entry.getIntValue();
@@ -1612,17 +1833,33 @@
@@ -1613,17 +1834,33 @@
}
public static void makeObsidianPlatform(WorldServer worldserver) {
@ -618,7 +618,7 @@
}
@Override
@@ -1733,6 +1970,7 @@
@@ -1734,6 +1971,7 @@
}
entity.updateDynamicGameEventListener(DynamicGameEventListener::add);
@ -626,7 +626,7 @@
}
public void onTrackingEnd(Entity entity) {
@@ -1769,6 +2007,14 @@
@@ -1770,6 +2008,14 @@
}
entity.updateDynamicGameEventListener(DynamicGameEventListener::remove);

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/server/network/LegacyPingHandler.java
+++ b/net/minecraft/server/network/LegacyPingHandler.java
@@ -36,11 +36,12 @@
@@ -37,11 +37,12 @@
MinecraftServer minecraftserver = this.serverConnectionListener.getServer();
int i = bytebuf.readableBytes();
String s;
@ -9,26 +9,26 @@
switch (i) {
case 0:
LegacyPingHandler.LOGGER.debug("Ping: (<1.3.x) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort());
- s = String.format("%s\u00a7%d\u00a7%d", minecraftserver.getMotd(), minecraftserver.getPlayerCount(), minecraftserver.getMaxPlayers());
+ s = String.format("%s\u00a7%d\u00a7%d", event.getMotd(), event.getNumPlayers(), event.getMaxPlayers()); // CraftBukkit
- s = String.format(Locale.ROOT, "%s\u00a7%d\u00a7%d", minecraftserver.getMotd(), minecraftserver.getPlayerCount(), minecraftserver.getMaxPlayers());
+ s = String.format(Locale.ROOT, "%s\u00a7%d\u00a7%d", event.getMotd(), event.getNumPlayers(), event.getMaxPlayers()); // CraftBukkit
this.sendFlushAndClose(channelhandlercontext, this.createReply(s));
break;
case 1:
@@ -49,7 +50,7 @@
@@ -50,7 +51,7 @@
}
LegacyPingHandler.LOGGER.debug("Ping: (1.4-1.5.x) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort());
- s = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getServerVersion(), minecraftserver.getMotd(), minecraftserver.getPlayerCount(), minecraftserver.getMaxPlayers());
+ s = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getServerVersion(), event.getMotd(), event.getNumPlayers(), event.getMaxPlayers()); // CraftBukkit
- s = String.format(Locale.ROOT, "\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getServerVersion(), minecraftserver.getMotd(), minecraftserver.getPlayerCount(), minecraftserver.getMaxPlayers());
+ s = String.format(Locale.ROOT, "\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getServerVersion(), event.getMotd(), event.getNumPlayers(), event.getMaxPlayers()); // CraftBukkit
this.sendFlushAndClose(channelhandlercontext, this.createReply(s));
break;
default:
@@ -68,7 +69,7 @@
@@ -69,7 +70,7 @@
}
LegacyPingHandler.LOGGER.debug("Ping: (1.6) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort());
- String s1 = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getServerVersion(), minecraftserver.getMotd(), minecraftserver.getPlayerCount(), minecraftserver.getMaxPlayers());
+ String s1 = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getServerVersion(), event.getMotd(), event.getNumPlayers(), event.getMaxPlayers()); // CraftBukkit
- String s1 = String.format(Locale.ROOT, "\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getServerVersion(), minecraftserver.getMotd(), minecraftserver.getPlayerCount(), minecraftserver.getMaxPlayers());
+ String s1 = String.format(Locale.ROOT, "\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getServerVersion(), event.getMotd(), event.getNumPlayers(), event.getMaxPlayers()); // CraftBukkit
ByteBuf bytebuf1 = this.createReply(s1);
try {

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/server/network/LoginListener.java
+++ b/net/minecraft/server/network/LoginListener.java
@@ -41,6 +41,12 @@
@@ -42,6 +42,12 @@
import org.apache.commons.lang3.Validate;
import org.slf4j.Logger;
@ -10,18 +10,18 @@
+import org.bukkit.event.player.PlayerPreLoginEvent;
+// CraftBukkit end
+
public class LoginListener implements PacketLoginInListener {
public class LoginListener implements TickablePacketListener, PacketLoginInListener {
private static final AtomicInteger UNIQUE_THREAD_ID = new AtomicInteger(0);
@@ -62,6 +68,7 @@
@@ -63,6 +69,7 @@
private EntityPlayer delayedAcceptPlayer;
@Nullable
private ProfilePublicKey playerProfilePublicKey;
private ProfilePublicKey.a profilePublicKeyData;
+ public String hostname = ""; // CraftBukkit - add field
public LoginListener(MinecraftServer minecraftserver, NetworkManager networkmanager) {
this.state = LoginListener.EnumProtocolState.HELLO;
@@ -90,6 +97,13 @@
@@ -92,6 +99,13 @@
}
@ -35,13 +35,13 @@
@Override
public NetworkManager getConnection() {
return this.connection;
@@ -111,10 +125,12 @@
this.gameProfile = this.createFakeProfile(this.gameProfile);
@@ -127,10 +141,12 @@
}
}
- IChatBaseComponent ichatbasecomponent = this.server.getPlayerList().canPlayerLogin(this.connection.getRemoteAddress(), this.gameProfile);
+ // CraftBukkit start - fire PlayerLoginEvent
+ EntityPlayer s = this.server.getPlayerList().canPlayerLogin(this, this.gameProfile, this.playerProfilePublicKey, hostname);
+ EntityPlayer s = this.server.getPlayerList().canPlayerLogin(this, this.gameProfile, profilepublickey, hostname);
- if (ichatbasecomponent != null) {
- this.disconnect(ichatbasecomponent);
@ -51,16 +51,25 @@
} else {
this.state = LoginListener.EnumProtocolState.ACCEPTED;
if (this.server.getCompressionThreshold() >= 0 && !this.connection.isMemoryConnection()) {
@@ -127,7 +143,7 @@
@@ -143,7 +159,7 @@
EntityPlayer entityplayer = this.server.getPlayerList().getPlayer(this.gameProfile.getId());
try {
- EntityPlayer entityplayer1 = this.server.getPlayerList().getPlayerForLogin(this.gameProfile, this.playerProfilePublicKey);
- EntityPlayer entityplayer1 = this.server.getPlayerList().getPlayerForLogin(this.gameProfile, profilepublickey);
+ EntityPlayer entityplayer1 = this.server.getPlayerList().getPlayerForLogin(this.gameProfile, s); // CraftBukkit - add player reference
if (entityplayer != null) {
this.state = LoginListener.EnumProtocolState.DELAY_ACCEPT;
@@ -259,6 +275,43 @@
@@ -204,7 +220,7 @@
public void handleHello(PacketLoginInStart packetlogininstart) {
Validate.validState(this.state == LoginListener.EnumProtocolState.HELLO, "Unexpected hello packet", new Object[0]);
Validate.validState(isValidUsername(packetlogininstart.name()), "Invalid characters in username", new Object[0]);
- this.profilePublicKeyData = (ProfilePublicKey.a) packetlogininstart.publicKey().orElse((Object) null);
+ this.profilePublicKeyData = (ProfilePublicKey.a) packetlogininstart.publicKey().orElse(null); // CraftBukkit - decompile error
GameProfile gameprofile = this.server.getSingleplayerProfile();
if (gameprofile != null && packetlogininstart.name().equalsIgnoreCase(gameprofile.getName())) {
@@ -265,6 +281,43 @@
try {
LoginListener.this.gameProfile = LoginListener.this.server.getSessionService().hasJoinedServer(new GameProfile((UUID) null, gameprofile.getName()), s, this.getAddress());
if (LoginListener.this.gameProfile != null) {
@ -104,7 +113,7 @@
LoginListener.LOGGER.info("UUID of player {} is {}", LoginListener.this.gameProfile.getName(), LoginListener.this.gameProfile.getId());
LoginListener.this.state = LoginListener.EnumProtocolState.READY_TO_ACCEPT;
} else if (LoginListener.this.server.isSingleplayer()) {
@@ -278,6 +331,11 @@
@@ -284,6 +337,11 @@
LoginListener.this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.authservers_down"));
LoginListener.LOGGER.error("Couldn't verify username because servers are unavailable");
}

View file

@ -1,12 +1,13 @@
--- a/net/minecraft/server/network/PlayerConnection.java
+++ b/net/minecraft/server/network/PlayerConnection.java
@@ -173,6 +173,62 @@
@@ -184,6 +184,63 @@
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
+// CraftBukkit start
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.atomic.AtomicInteger;
+import net.minecraft.network.chat.OutgoingPlayerChatMessage;
+import net.minecraft.network.protocol.game.PacketPlayOutAttachEntity;
+import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata;
+import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity;
@ -60,10 +61,10 @@
+import org.bukkit.inventory.SmithingInventory;
+// CraftBukkit end
+
public class PlayerConnection implements ServerPlayerConnection, PacketListenerPlayIn {
public class PlayerConnection implements ServerPlayerConnection, TickablePacketListener, PacketListenerPlayIn {
static final Logger LOGGER = LogUtils.getLogger();
@@ -187,7 +243,9 @@
@@ -199,7 +256,9 @@
private long keepAliveTime;
private boolean keepAlivePending;
private long keepAliveChallenge;
@ -74,10 +75,12 @@
private int dropSpamTickCount;
private double firstGoodX;
private double firstGoodY;
@@ -225,7 +283,31 @@
entityplayer.connection = this;
this.keepAliveTime = SystemUtils.getMillis();
entityplayer.getTextFilter().join();
@@ -250,8 +309,32 @@
this.signedMessageDecoder = SignedMessageChain.a.UNSIGNED;
}
- this.chatMessageChain = new FutureChain(minecraftserver);
+ this.chatMessageChain = new FutureChain(minecraftserver.chatExecutor); // CraftBukkit - async chat
+
+ // CraftBukkit start - add fields and methods
+ this.cserver = minecraftserver.server;
@ -104,9 +107,9 @@
}
+ // CraftBukkit end
@Override
public void tick() {
if (this.ackBlockChangesUpTo > -1) {
@@ -279,7 +361,7 @@
@@ -306,7 +389,7 @@
this.server.getProfiler().push("keepAlive");
long i = SystemUtils.getMillis();
@ -115,7 +118,7 @@
if (this.keepAlivePending) {
this.disconnect(IChatBaseComponent.translatable("disconnect.timeout"));
} else {
@@ -291,15 +373,21 @@
@@ -318,15 +401,21 @@
}
this.server.getProfiler().pop();
@ -137,7 +140,7 @@
this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.idling"));
}
@@ -324,16 +412,47 @@
@@ -351,16 +440,67 @@
return this.server.isSingleplayerOwner(this.player.getGameProfile());
}
@ -153,6 +156,27 @@
+ if (this.processedDisconnect) {
+ return;
+ }
+ if (!this.cserver.isPrimaryThread()) {
+ Waitable waitable = new Waitable() {
+ @Override
+ protected Object evaluate() {
+ PlayerConnection.this.disconnect(s);
+ return null;
+ }
+ };
+
+ this.server.processQueue.add(waitable);
+
+ try {
+ waitable.get();
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ } catch (ExecutionException e) {
+ throw new RuntimeException(e);
+ }
+ return;
+ }
+
+ String leaveMessage = EnumChatFormat.YELLOW + this.player.getScoreboardName() + " left the game.";
+
+ PlayerKickEvent event = new PlayerKickEvent(this.player.getBukkitEntity(), s, leaveMessage);
@ -167,13 +191,12 @@
+ }
+ this.player.kickLeaveMessage = event.getLeaveMessage(); // CraftBukkit - SPIGOT-3034: Forward leave message to PlayerQuitEvent
+ // Send the possibly modified leave message
+ s = event.getReason();
+ final IChatBaseComponent ichatbasecomponent = CraftChatMessage.fromString(s, true)[0];
+ final IChatBaseComponent ichatbasecomponent = CraftChatMessage.fromString(event.getReason(), true)[0];
+ // CraftBukkit end
+
this.connection.send(new PacketPlayOutKickDisconnect(ichatbasecomponent), (future) -> {
this.connection.send(new PacketPlayOutKickDisconnect(ichatbasecomponent), PacketSendListener.thenRun(() -> {
this.connection.disconnect(ichatbasecomponent);
});
}));
+ this.onDisconnect(ichatbasecomponent); // CraftBukkit - fire quit instantly
this.connection.setReadOnly();
MinecraftServer minecraftserver = this.server;
@ -185,8 +208,8 @@
+ minecraftserver.wrapRunnable(networkmanager::handleDisconnection);
}
private <T, R> void filterTextPacket(T t0, Consumer<R> consumer, BiFunction<ITextFilter, T, CompletableFuture<R>> bifunction) {
@@ -404,7 +523,34 @@
private <T, R> CompletableFuture<R> filterTextPacket(T t0, BiFunction<ITextFilter, T, CompletableFuture<R>> bifunction) {
@@ -424,7 +564,34 @@
double d9 = entity.getDeltaMovement().lengthSqr();
double d10 = d6 * d6 + d7 * d7 + d8 * d8;
@ -222,7 +245,7 @@
PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", new Object[]{entity.getName().getString(), this.player.getName().getString(), d6, d7, d8});
this.connection.send(new PacketPlayOutVehicleMove(entity));
return;
@@ -436,14 +582,72 @@
@@ -456,14 +623,72 @@
}
entity.absMoveTo(d3, d4, d5, f, f1);
@ -295,7 +318,7 @@
this.player.getLevel().getChunkSource().move(this.player);
this.player.checkMovementStatistics(this.player.getX() - d0, this.player.getY() - d1, this.player.getZ() - d2);
this.clientVehicleIsFloating = d11 >= -0.03125D && !flag1 && !this.server.isFlightAllowed() && !entity.isNoGravity() && this.noBlocksAround(entity);
@@ -477,6 +681,7 @@
@@ -497,6 +722,7 @@
}
this.awaitingPositionFromClient = null;
@ -303,7 +326,7 @@
}
}
@@ -484,7 +689,7 @@
@@ -504,7 +730,7 @@
@Override
public void handleRecipeBookSeenRecipePacket(PacketPlayInRecipeDisplayed packetplayinrecipedisplayed) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinrecipedisplayed, this, this.player.getLevel());
@ -312,7 +335,7 @@
RecipeBookServer recipebookserver = this.player.getRecipeBook();
Objects.requireNonNull(recipebookserver);
@@ -514,6 +719,12 @@
@@ -534,6 +760,12 @@
@Override
public void handleCustomCommandSuggestions(PacketPlayInTabComplete packetplayintabcomplete) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayintabcomplete, this, this.player.getLevel());
@ -325,7 +348,7 @@
StringReader stringreader = new StringReader(packetplayintabcomplete.getCommand());
if (stringreader.canRead() && stringreader.peek() == '/') {
@@ -523,6 +734,7 @@
@@ -543,6 +775,7 @@
ParseResults<CommandListenerWrapper> parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack());
this.server.getCommands().getDispatcher().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> {
@ -333,7 +356,7 @@
this.connection.send(new PacketPlayOutTabComplete(packetplayintabcomplete.getId(), suggestions));
});
}
@@ -755,6 +967,13 @@
@@ -792,6 +1025,13 @@
if (container instanceof ContainerMerchant) {
ContainerMerchant containermerchant = (ContainerMerchant) container;
@ -345,9 +368,9 @@
+ }
+ // CraftBukkit end
containermerchant.setSelectionHint(i);
containermerchant.tryMoveItems(i);
@@ -764,6 +983,13 @@
if (!containermerchant.stillValid(this.player)) {
PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, containermerchant);
@@ -806,6 +1046,13 @@
@Override
public void handleEditBook(PacketPlayInBEdit packetplayinbedit) {
@ -361,7 +384,7 @@
int i = packetplayinbedit.getSlot();
if (PlayerInventory.isHotbarSlot(i) || i == 40) {
@@ -772,7 +998,7 @@
@@ -814,7 +1061,7 @@
Objects.requireNonNull(list);
optional.ifPresent(list::add);
@ -370,7 +393,7 @@
Objects.requireNonNull(list);
stream.forEach(list::add);
@@ -788,7 +1014,7 @@
@@ -832,7 +1079,7 @@
ItemStack itemstack = this.player.getInventory().getItem(i);
if (itemstack.is(Items.WRITABLE_BOOK)) {
@ -379,7 +402,7 @@
}
}
@@ -813,16 +1039,16 @@
@@ -857,16 +1104,16 @@
this.updateBookPages(list, (s) -> {
return IChatBaseComponent.ChatSerializer.toJson(IChatBaseComponent.literal(s));
@ -390,17 +413,17 @@
}
}
- private void updateBookPages(List<FilteredText<String>> list, UnaryOperator<String> unaryoperator, ItemStack itemstack) {
+ private void updateBookPages(List<FilteredText<String>> list, UnaryOperator<String> unaryoperator, ItemStack itemstack, int slot, ItemStack handItem) { // CraftBukkit
- private void updateBookPages(List<FilteredText> list, UnaryOperator<String> unaryoperator, ItemStack itemstack) {
+ private void updateBookPages(List<FilteredText> list, UnaryOperator<String> unaryoperator, ItemStack itemstack, int slot, ItemStack handItem) { // CraftBukkit
NBTTagList nbttaglist = new NBTTagList();
if (this.player.isTextFilteringEnabled()) {
- Stream stream = list.stream().map((filteredtext) -> {
+ Stream<NBTTagString> stream = list.stream().map((filteredtext) -> { // CraftBukkit - decompile error
return NBTTagString.valueOf((String) unaryoperator.apply((String) filteredtext.filteredOrElse("")));
return NBTTagString.valueOf((String) unaryoperator.apply(filteredtext.filteredOrEmpty()));
});
@@ -848,6 +1074,7 @@
@@ -892,6 +1139,7 @@
}
itemstack.addTagElement("pages", nbttaglist);
@ -408,7 +431,7 @@
}
@Override
@@ -884,7 +1111,7 @@
@@ -928,7 +1176,7 @@
} else {
WorldServer worldserver = this.player.getLevel();
@ -417,7 +440,7 @@
if (this.tickCount == 0) {
this.resetPosition();
}
@@ -894,7 +1121,7 @@
@@ -938,7 +1186,7 @@
this.awaitingTeleportTime = this.tickCount;
this.teleport(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot());
}
@ -426,7 +449,7 @@
} else {
this.awaitingTeleportTime = this.tickCount;
double d0 = clampHorizontal(packetplayinflying.getX(this.player.getX()));
@@ -906,7 +1133,15 @@
@@ -950,7 +1198,15 @@
if (this.player.isPassenger()) {
this.player.absMoveTo(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1);
this.player.getLevel().getChunkSource().move(this.player);
@ -442,7 +465,7 @@
double d3 = this.player.getX();
double d4 = this.player.getY();
double d5 = this.player.getZ();
@@ -926,15 +1161,33 @@
@@ -970,15 +1226,33 @@
++this.receivedMovePacketCount;
int i = this.receivedMovePacketCount - this.knownMovePacketCount;
@ -478,7 +501,7 @@
PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", new Object[]{this.player.getName().getString(), d7, d8, d9});
this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot());
return;
@@ -955,6 +1208,7 @@
@@ -999,6 +1273,7 @@
boolean flag1 = this.player.verticalCollisionBelow;
this.player.move(EnumMoveType.PLAYER, new Vec3D(d7, d8, d9));
@ -486,7 +509,7 @@
double d12 = d8;
d7 = d0 - this.player.getX();
@@ -974,8 +1228,71 @@
@@ -1018,8 +1293,71 @@
this.player.absMoveTo(d0, d1, d2, f, f1);
if (!this.player.noPhysics && !this.player.isSleeping() && (flag2 && worldserver.noCollision(this.player, axisalignedbb) || this.isPlayerCollidingWithAnythingNew(worldserver, axisalignedbb))) {
@ -559,7 +582,7 @@
this.clientIsFloating = d12 >= -0.03125D && !flag1 && this.player.gameMode.getGameModeForPlayer() != EnumGamemode.SPECTATOR && !this.server.isFlightAllowed() && !this.player.getAbilities().mayfly && !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.isFallFlying() && !this.player.isAutoSpinAttack() && this.noBlocksAround(this.player);
this.player.getLevel().getChunkSource().move(this.player);
this.player.doCheckFallDamage(this.player.getY() - d6, packetplayinflying.isOnGround());
@@ -1014,19 +1331,80 @@
@@ -1058,19 +1396,80 @@
return true;
}
@ -644,7 +667,7 @@
double d3 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.X) ? this.player.getX() : 0.0D;
double d4 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Y) ? this.player.getY() : 0.0D;
double d5 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Z) ? this.player.getZ() : 0.0D;
@@ -1038,6 +1416,14 @@
@@ -1082,6 +1481,14 @@
this.awaitingTeleport = 0;
}
@ -659,7 +682,7 @@
this.awaitingTeleportTime = this.tickCount;
this.player.absMoveTo(d0, d1, d2, f, f1);
this.player.connection.send(new PacketPlayOutPosition(d0 - d3, d1 - d4, d2 - d5, f - f2, f1 - f3, set, this.awaitingTeleport, flag));
@@ -1046,6 +1432,7 @@
@@ -1090,6 +1497,7 @@
@Override
public void handlePlayerAction(PacketPlayInBlockDig packetplayinblockdig) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockdig, this, this.player.getLevel());
@ -667,7 +690,7 @@
BlockPosition blockposition = packetplayinblockdig.getPos();
this.player.resetLastActionTime();
@@ -1056,14 +1443,46 @@
@@ -1100,14 +1508,46 @@
if (!this.player.isSpectator()) {
ItemStack itemstack = this.player.getItemInHand(EnumHand.OFF_HAND);
@ -716,7 +739,7 @@
this.player.drop(false);
}
@@ -1101,6 +1520,7 @@
@@ -1145,6 +1585,7 @@
@Override
public void handleUseItemOn(PacketPlayInUseItem packetplayinuseitem) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseitem, this, this.player.getLevel());
@ -724,7 +747,7 @@
this.player.connection.ackBlockChangesUpTo(packetplayinuseitem.getSequence());
WorldServer worldserver = this.player.getLevel();
EnumHand enumhand = packetplayinuseitem.getHand();
@@ -1122,6 +1542,7 @@
@@ -1166,6 +1607,7 @@
if (blockposition.getY() < i) {
if (this.awaitingPositionFromClient == null && this.player.distanceToSqr((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && worldserver.mayInteract(this.player, blockposition)) {
@ -732,7 +755,7 @@
EnumInteractionResult enuminteractionresult = this.player.gameMode.useItemOn(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock);
if (enumdirection == EnumDirection.UP && !enuminteractionresult.consumesAction() && blockposition.getY() >= i - 1 && wasBlockPlacementAttempt(this.player, itemstack)) {
@@ -1149,6 +1570,7 @@
@@ -1193,6 +1635,7 @@
@Override
public void handleUseItem(PacketPlayInBlockPlace packetplayinblockplace) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockplace, this, this.player.getLevel());
@ -740,7 +763,7 @@
this.ackBlockChangesUpTo(packetplayinblockplace.getSequence());
WorldServer worldserver = this.player.getLevel();
EnumHand enumhand = packetplayinblockplace.getHand();
@@ -1156,6 +1578,44 @@
@@ -1200,6 +1643,44 @@
this.player.resetLastActionTime();
if (!itemstack.isEmpty()) {
@ -785,7 +808,7 @@
EnumInteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand);
if (enuminteractionresult.shouldSwing()) {
@@ -1176,7 +1636,7 @@
@@ -1220,7 +1701,7 @@
Entity entity = packetplayinspectate.getEntity(worldserver);
if (entity != null) {
@ -794,7 +817,7 @@
return;
}
}
@@ -1191,6 +1651,7 @@
@@ -1235,6 +1716,7 @@
PlayerConnection.LOGGER.info("Disconnecting {} due to resource pack rejection", this.player.getName());
this.disconnect(IChatBaseComponent.translatable("multiplayer.requiredTexturePrompt.disconnect"));
}
@ -802,7 +825,7 @@
}
@@ -1210,11 +1671,26 @@
@@ -1254,11 +1736,26 @@
@Override
public void onDisconnect(IChatBaseComponent ichatbasecomponent) {
@ -817,7 +840,7 @@
+ // CraftBukkit start - Replace vanilla quit message handling with our own.
+ /*
this.server.invalidateStatus();
this.server.getPlayerList().broadcastSystemMessage(IChatBaseComponent.translatable("multiplayer.player.left", this.player.getDisplayName()).withStyle(EnumChatFormat.YELLOW), ChatMessageType.SYSTEM);
this.server.getPlayerList().broadcastSystemMessage(IChatBaseComponent.translatable("multiplayer.player.left", this.player.getDisplayName()).withStyle(EnumChatFormat.YELLOW), false);
+ */
+
this.player.disconnect();
@ -830,10 +853,10 @@
this.player.getTextFilter().leave();
if (this.isSingleplayerOwner()) {
PlayerConnection.LOGGER.info("Stopping singleplayer server as player logged out");
@@ -1237,6 +1713,15 @@
@@ -1281,6 +1778,15 @@
}
public void send(Packet<?> packet, @Nullable GenericFutureListener<? extends Future<? super Void>> genericfuturelistener) {
public void send(Packet<?> packet, @Nullable PacketSendListener packetsendlistener) {
+ // CraftBukkit start
+ if (packet == null) {
+ return;
@ -844,9 +867,9 @@
+ // CraftBukkit end
+
try {
this.connection.send(packet, genericfuturelistener);
this.connection.send(packet, packetsendlistener);
} catch (Throwable throwable) {
@@ -1253,7 +1738,16 @@
@@ -1297,7 +1803,16 @@
@Override
public void handleSetCarriedItem(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinhelditemslot, this, this.player.getLevel());
@ -863,7 +886,7 @@
if (this.player.getInventory().selected != packetplayinhelditemslot.getSlot() && this.player.getUsedItemHand() == EnumHand.MAIN_HAND) {
this.player.stopUsingItem();
}
@@ -1262,18 +1756,27 @@
@@ -1306,16 +1821,23 @@
this.player.resetLastActionTime();
} else {
PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString());
@ -879,104 +902,80 @@
+ return;
+ }
+ // CraftBukkit end
if (isChatMessageIllegal(packetplayinchat.getMessage())) {
if (isChatMessageIllegal(packetplayinchat.message())) {
this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.illegal_characters"));
} else {
if (this.tryHandleChat(packetplayinchat.getMessage(), packetplayinchat.getTimeStamp())) {
- this.filterTextPacket(packetplayinchat.getMessage(), (filteredtext) -> {
- this.handleChat(packetplayinchat, filteredtext);
if (this.tryHandleChat(packetplayinchat.message(), packetplayinchat.timeStamp(), packetplayinchat.lastSeenMessages())) {
- this.server.submit(() -> {
+ // this.server.submit(() -> { // CraftBukkit - async chat
PlayerChatMessage playerchatmessage = this.getSignedMessage(packetplayinchat);
if (this.verifyChatMessage(playerchatmessage)) {
@@ -1328,10 +1850,10 @@
PlayerChatMessage playerchatmessage1 = ((PlayerChatMessage) completablefuture1.join()).filter(filtermask);
this.broadcastChatMessage(playerchatmessage1);
- }, this.server);
+ }, this.server.chatExecutor); // CraftBukkit - async chat
});
}
- });
+ // CraftBukkit start
+ // this.filterTextPacket(packetplayinchat.getMessage(), (filteredtext) -> {
+ this.handleChat(packetplayinchat, FilteredText.passThrough(packetplayinchat.getMessage())); // CraftBukkit - filter NYI
+ // });
+ // CraftBukkit end
+ // }); // CraftBukkit - async chat
}
}
@@ -1286,10 +1789,18 @@
} else {
PlayerConnectionUtils.ensureRunningOnSameThread(serverboundchatcommandpacket, this, this.player.getLevel());
if (this.tryHandleChat(serverboundchatcommandpacket.command(), serverboundchatcommandpacket.timeStamp())) {
- CommandListenerWrapper commandlistenerwrapper = this.player.createCommandSourceStack().withSigningContext(serverboundchatcommandpacket.signingContext(this.player.getUUID()));
+ // CraftBukkit start
+ // CommandListenerWrapper commandlistenerwrapper = this.player.createCommandSourceStack().withSigningContext(serverboundchatcommandpacket.signingContext(this.player.getUUID()));
- this.server.getCommands().performCommand(commandlistenerwrapper, serverboundchatcommandpacket.command());
- this.detectRateSpam();
+ // this.server.getCommands().performCommand(commandlistenerwrapper, serverboundchatcommandpacket.command());
+ try {
+ this.server.server.playerCommandState = true;
+ this.handleCommand("/" + serverboundchatcommandpacket.command());
+ } finally {
+ this.server.server.playerCommandState = false;
+ }
+ this.detectRateSpam(true);
+ // CraftBukkit end
}
}
@@ -1339,7 +1850,7 @@
@@ -1353,8 +1875,21 @@
}
private boolean resetLastActionTime() {
- if (this.player.getChatVisibility() == EnumChatVisibility.HIDDEN) {
+ if (this.player.isRemoved() || this.player.getChatVisibility() == EnumChatVisibility.HIDDEN) { // CraftBukkit - dead men tell no tales
IRegistry<ChatMessageType> iregistry = this.player.level.registryAccess().registryOrThrow(IRegistry.CHAT_TYPE_REGISTRY);
int i = iregistry.getId((ChatMessageType) iregistry.get(ChatMessageType.SYSTEM));
@@ -1357,31 +1868,171 @@
boolean flag = packetplayinchat.signedPreview();
ChatDecorator chatdecorator = this.server.getChatDecorator();
- chatdecorator.decorateChat(this.player, filteredtext.map(IChatBaseComponent::literal), messagesignature, flag).thenAcceptAsync(this::broadcastChatMessage, this.server);
+ chatdecorator.decorateChat(this.player, filteredtext.map(IChatBaseComponent::literal), messagesignature, flag).thenAccept((playerchatmessage) -> broadcastChatMessage(packetplayinchat, playerchatmessage)); // CraftBukkit
}
}
- private void broadcastChatMessage(FilteredText<PlayerChatMessage> filteredtext) {
+ private void broadcastChatMessage(PacketPlayInChat packetplayinchat, FilteredText<PlayerChatMessage> filteredtext) {
if (!((PlayerChatMessage) filteredtext.raw()).verify(this.player)) {
PlayerConnection.LOGGER.warn("{} sent message with invalid signature: '{}'", this.player.getName().getString(), ((PlayerChatMessage) filteredtext.raw()).signedContent().getString());
} else {
- this.server.getPlayerList().broadcastChatMessage(filteredtext, this.player, ChatMessageType.CHAT);
- this.detectRateSpam();
+ // CraftBukkit start
+ String s = packetplayinchat.getMessage();
+ if (s.isEmpty()) {
+ LOGGER.warn(this.player.getScoreboardName() + " tried to send an empty message");
+ } else if (getCraftPlayer().isConversing()) {
+ final String conversationInput = s;
+ this.server.processQueue.add(new Runnable() {
+ @Override
+ public void run() {
+ getCraftPlayer().acceptConversationInput(conversationInput);
+ }
+ });
+ } else if (this.player.getChatVisibility() == EnumChatVisibility.SYSTEM) { // Re-add "Command Only" flag check
+ IRegistry<ChatMessageType> iregistry = this.player.level.registryAccess().registryOrThrow(IRegistry.CHAT_TYPE_REGISTRY);
+ int i = iregistry.getId((ChatMessageType) iregistry.get(ChatMessageType.SYSTEM));
private void performChatCommand(ServerboundChatCommandPacket serverboundchatcommandpacket) {
- ParseResults<CommandListenerWrapper> parseresults = this.parseCommand(serverboundchatcommandpacket.command());
- Map<String, PlayerChatMessage> map = this.collectSignedArguments(serverboundchatcommandpacket, PreviewableCommand.of(parseresults));
+ // CraftBukkit start
+ String command = "/" + serverboundchatcommandpacket.command();
+ PlayerConnection.LOGGER.info(this.player.getScoreboardName() + " issued server command: " + command);
+
+ this.send(new ClientboundSystemChatPacket(IChatBaseComponent.translatable("chat.cannotSend").withStyle(EnumChatFormat.RED), i));
+ } else {
+ this.chat(s, true);
+ }
+ // this.server.getPlayerList().broadcastChatMessage(playerchatmessage, filteredtext, this.player, ChatMessageType.CHAT);
+ this.detectRateSpam(false);
+ // CraftBukkit end
}
+ PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(getCraftPlayer(), command, new LazyPlayerSet(server));
+ this.cserver.getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return;
+ }
+ command = event.getMessage().substring(1);
+
+ ParseResults<CommandListenerWrapper> parseresults = this.parseCommand(command);
+ Map<String, PlayerChatMessage> map = (serverboundchatcommandpacket.command().equals(command)) ? this.collectSignedArguments(serverboundchatcommandpacket, PreviewableCommand.of(parseresults)) : Collections.emptyMap();
+ // CraftBukkit end
Iterator iterator = map.values().iterator();
PlayerChatMessage playerchatmessage;
@@ -1366,7 +1901,7 @@
parseresults = CommandDispatcher.mapSource(parseresults, (commandlistenerwrapper) -> {
return commandlistenerwrapper.withSigningContext(commandsigningcontext_a);
});
- this.server.getCommands().performCommand(parseresults, serverboundchatcommandpacket.command());
+ this.server.getCommands().performCommand(parseresults, command); // CraftBukkit
return;
}
@@ -1415,7 +1950,7 @@
PlayerConnection.LOGGER.warn("{} sent out-of-order chat: '{}'", this.player.getName().getString(), s);
this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.out_of_order_chat"));
return false;
- } else if (this.player.getChatVisibility() == EnumChatVisibility.HIDDEN) {
+ } else if (this.player.isRemoved() || this.player.getChatVisibility() == EnumChatVisibility.HIDDEN) { // CraftBukkit - dead men tell no tales
this.send(new ClientboundSystemChatPacket(IChatBaseComponent.translatable("chat.disabled.options").withStyle(EnumChatFormat.RED), false));
return false;
} else {
@@ -1459,6 +1994,135 @@
return false;
}
- private void detectRateSpam() {
- this.chatSpamTickCount += 20;
- if (this.chatSpamTickCount > 200 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) {
- this.disconnect(IChatBaseComponent.translatable("disconnect.spam"));
+ // CraftBukkit start - add method
+ public void chat(String s, boolean async) {
+ public void chat(String s, PlayerChatMessage original, boolean async) {
+ if (s.isEmpty() || this.player.getChatVisibility() == EnumChatVisibility.HIDDEN) {
+ return;
+ }
+ OutgoingPlayerChatMessage outgoing = OutgoingPlayerChatMessage.create(original);
+
+ if (!async && s.startsWith("/")) {
+ this.handleCommand(s);
@ -985,6 +984,7 @@
+ } else {
+ Player player = this.getCraftPlayer();
+ AsyncPlayerChatEvent event = new AsyncPlayerChatEvent(async, player, s, new LazyPlayerSet(server));
+ String originalFormat = event.getFormat(), originalMessage = event.getMessage();
+ this.cserver.getPluginManager().callEvent(event);
+
+ if (PlayerChatEvent.getHandlerList().getRegisteredListeners().length != 0) {
@ -997,12 +997,22 @@
+ org.bukkit.Bukkit.getPluginManager().callEvent(queueEvent);
+
+ if (queueEvent.isCancelled()) {
+ if (outgoing != null) {
+ outgoing.sendHeadersToRemainingPlayers(PlayerConnection.this.server.getPlayerList());
+ }
+ return null;
+ }
+
+ String message = String.format(queueEvent.getFormat(), queueEvent.getPlayer().getDisplayName(), queueEvent.getMessage());
+ PlayerConnection.this.server.console.sendMessage(message);
+ if (((LazyPlayerSet) queueEvent.getRecipients()).isLazy()) {
+ if (originalFormat.equals(queueEvent.getFormat()) && originalMessage.equals(queueEvent.getMessage()) && queueEvent.getPlayer().getName().equalsIgnoreCase(queueEvent.getPlayer().getDisplayName())) {
+ PlayerConnection.this.server.getPlayerList().broadcastChatMessage(original, PlayerConnection.this.player, ChatMessageType.bind(ChatMessageType.CHAT, (Entity) PlayerConnection.this.player));
+ return null;
+ } else if (CraftChatMessage.fromComponent(original.serverContent()).equals(message)) {
+ PlayerConnection.this.server.getPlayerList().broadcastChatMessage(original, PlayerConnection.this.player, ChatMessageType.bind(ChatMessageType.RAW, (Entity) PlayerConnection.this.player));
+ return null;
+ }
+
+ for (EntityPlayer recipient : server.getPlayerList().players) {
+ recipient.getBukkitEntity().sendMessage(PlayerConnection.this.player.getUUID(), message);
+ }
@ -1011,6 +1021,11 @@
+ player.sendMessage(PlayerConnection.this.player.getUUID(), message);
+ }
+ }
+ PlayerConnection.this.server.console.sendMessage(message);
+
+ if (outgoing != null) {
+ outgoing.sendHeadersToRemainingPlayers(PlayerConnection.this.server.getPlayerList());
+ }
+ return null;
+ }};
+ if (async) {
@ -1027,12 +1042,22 @@
+ }
+ } else {
+ if (event.isCancelled()) {
+ if (outgoing != null) {
+ outgoing.sendHeadersToRemainingPlayers(PlayerConnection.this.server.getPlayerList());
+ }
+ return;
+ }
+
+ s = String.format(event.getFormat(), event.getPlayer().getDisplayName(), event.getMessage());
+ server.console.sendMessage(s);
+ if (((LazyPlayerSet) event.getRecipients()).isLazy()) {
+ if (originalFormat.equals(event.getFormat()) && originalMessage.equals(event.getMessage()) && event.getPlayer().getName().equalsIgnoreCase(event.getPlayer().getDisplayName())) {
+ PlayerConnection.this.server.getPlayerList().broadcastChatMessage(original, PlayerConnection.this.player, ChatMessageType.bind(ChatMessageType.CHAT, (Entity) PlayerConnection.this.player));
+ return;
+ } else if (CraftChatMessage.fromComponent(original.serverContent()).equals(s)) {
+ PlayerConnection.this.server.getPlayerList().broadcastChatMessage(original, PlayerConnection.this.player, ChatMessageType.bind(ChatMessageType.RAW, (Entity) PlayerConnection.this.player));
+ return;
+ }
+
+ for (EntityPlayer recipient : server.getPlayerList().players) {
+ recipient.getBukkitEntity().sendMessage(PlayerConnection.this.player.getUUID(), s);
+ }
@ -1041,6 +1066,11 @@
+ recipient.sendMessage(PlayerConnection.this.player.getUUID(), s);
+ }
+ }
+ server.console.sendMessage(s);
+
+ if (outgoing != null) {
+ outgoing.sendHeadersToRemainingPlayers(PlayerConnection.this.server.getPlayerList());
+ }
+ }
+ }
+ }
@ -1069,59 +1099,64 @@
+ }
+ // CraftBukkit end
+
+ // CraftBukkit start - replaced with thread safe throttle
+ private void detectRateSpam(boolean isSync) {
+ // this.chatSpamTickCount += 20;
+ if (this.chatSpamTickCount.addAndGet(20) > 200 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) {
+ if (!isSync) {
+ Waitable waitable = new Waitable() {
+ @Override
+ protected Object evaluate() {
+ PlayerConnection.this.disconnect(IChatBaseComponent.translatable("disconnect.spam"));
+ return null;
+ }
+ };
+
+ this.server.processQueue.add(waitable);
+
+ try {
+ waitable.get();
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ } catch (ExecutionException e) {
+ throw new RuntimeException(e);
+ }
+ } else {
+ this.disconnect(IChatBaseComponent.translatable("disconnect.spam"));
+ }
+ // CraftBukkit end
}
private PlayerChatMessage getSignedMessage(PacketPlayInChat packetplayinchat) {
MessageSigner messagesigner = packetplayinchat.getSigner(this.player);
SignedMessageChain.c signedmessagechain_c = new SignedMessageChain.c(packetplayinchat.signature());
@@ -1475,7 +2139,25 @@
}
@Override
public void handleChatPreview(ServerboundChatPreviewPacket serverboundchatpreviewpacket) {
- if (this.server.previewsChat()) {
+ if (false && this.server.previewsChat()) { // CraftBukkit - preview NYI
this.chatPreviewThrottler.schedule(() -> {
int i = serverboundchatpreviewpacket.queryId();
String s = serverboundchatpreviewpacket.query();
@@ -1428,7 +2079,7 @@
CommandContextBuilder<CommandListenerWrapper> commandcontextbuilder1 = commandcontextbuilder.getLastChild();
private void broadcastChatMessage(PlayerChatMessage playerchatmessage) {
- this.server.getPlayerList().broadcastChatMessage(playerchatmessage, this.player, ChatMessageType.bind(ChatMessageType.CHAT, (Entity) this.player));
+ // CraftBukkit start
+ String s = playerchatmessage.signedContent().plain();
+ if (s.isEmpty()) {
+ LOGGER.warn(this.player.getScoreboardName() + " tried to send an empty message");
+ } else if (getCraftPlayer().isConversing()) {
+ final String conversationInput = s;
+ this.server.processQueue.add(new Runnable() {
+ @Override
+ public void run() {
+ getCraftPlayer().acceptConversationInput(conversationInput);
+ }
+ });
+ } else if (this.player.getChatVisibility() == EnumChatVisibility.SYSTEM) { // Re-add "Command Only" flag check
+ this.send(new ClientboundSystemChatPacket(IChatBaseComponent.translatable("chat.cannotSend").withStyle(EnumChatFormat.RED), false));
+ } else {
+ this.chat(s, playerchatmessage, true);
+ }
+ // this.server.getPlayerList().broadcastChatMessage(playerchatmessage, this.player, ChatMessageType.bind(ChatMessageType.CHAT, (Entity) this.player));
+ // CraftBukkit end
this.detectRateSpam();
}
if (commandcontextbuilder1.getArguments().isEmpty()) {
@@ -1495,8 +2177,10 @@
}
private void detectRateSpam() {
- this.chatSpamTickCount += 20;
- if (this.chatSpamTickCount > 200 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) {
+ // CraftBukkit start - replaced with thread safe throttle
+ // this.chatSpamTickCount += 20;
+ if (this.chatSpamTickCount.addAndGet(20) > 200 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) {
+ // CraftBukkit end
this.disconnect(IChatBaseComponent.translatable("disconnect.spam"));
}
@@ -1560,7 +2244,7 @@
List<PreviewableCommand.a<CommandListenerWrapper>> list = previewablecommand.arguments();
if (list.isEmpty()) {
- return CompletableFuture.completedFuture((Object) null);
+ return CompletableFuture.completedFuture(null); // CraftBukkit - decompile error
} else {
List<? extends ParsedCommandNode<?>> list = commandcontextbuilder1.getNodes();
@@ -1445,25 +2096,77 @@
return completablefuture;
}
} catch (CommandSyntaxException commandsyntaxexception) {
- return CompletableFuture.completedFuture((Object) null);
+ return CompletableFuture.completedFuture(null); // CraftBukkit - decompile error
for (int i = list.size() - 1; i >= 0; --i) {
PreviewableCommand.a previewablecommand_a = (PreviewableCommand.a) list.get(i);
@@ -1572,11 +2256,11 @@
return completablefuture;
}
} catch (CommandSyntaxException commandsyntaxexception) {
- return CompletableFuture.completedFuture((Object) null);
+ return CompletableFuture.completedFuture(null); // CraftBukkit - decompile error
}
}
@ -1130,6 +1165,7 @@
}
}
@@ -1603,13 +2287,65 @@
@Override
public void handleAnimate(PacketPlayInArmAnimation packetplayinarmanimation) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinarmanimation, this, this.player.getLevel());
@ -1195,7 +1231,7 @@
this.player.resetLastActionTime();
IJumpable ijumpable;
@@ -1525,6 +2228,7 @@
@@ -1694,6 +2430,7 @@
@Override
public void handleInteract(PacketPlayInUseEntity packetplayinuseentity) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseentity, this, this.player.getLevel());
@ -1203,7 +1239,7 @@
WorldServer worldserver = this.player.getLevel();
final Entity entity = packetplayinuseentity.getTarget(worldserver);
@@ -1537,10 +2241,44 @@
@@ -1706,10 +2443,44 @@
if (entity.distanceToSqr(this.player.getEyePosition()) < PlayerConnection.MAX_INTERACTION_DISTANCE) {
packetplayinuseentity.dispatch(new PacketPlayInUseEntity.c() {
@ -1249,7 +1285,7 @@
if (enuminteractionresult.consumesAction()) {
CriterionTriggers.PLAYER_INTERACTED_WITH_ENTITY.trigger(PlayerConnection.this.player, itemstack, entity);
if (enuminteractionresult.shouldSwing()) {
@@ -1552,20 +2290,27 @@
@@ -1721,20 +2492,27 @@
@Override
public void onInteraction(EnumHand enumhand) {
@ -1280,7 +1316,7 @@
} else {
PlayerConnection.this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.invalid_entity_attacked"));
PlayerConnection.LOGGER.warn("Player {} tried to attack an invalid entity", PlayerConnection.this.player.getName().getString());
@@ -1610,15 +2355,21 @@
@@ -1779,15 +2557,21 @@
@Override
public void handleContainerClose(PacketPlayInCloseWindow packetplayinclosewindow) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinclosewindow, this, this.player.getLevel());
@ -1302,9 +1338,9 @@
+ boolean cancelled = this.player.isSpectator(); // CraftBukkit - see below if
+ if (false/*this.player.isSpectator()*/) { // CraftBukkit
this.player.containerMenu.sendAllDataToRemote();
} else {
int i = packetplayinwindowclick.getSlotNum();
@@ -1629,7 +2380,284 @@
} else if (!this.player.containerMenu.stillValid(this.player)) {
PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu);
@@ -1800,7 +2584,284 @@
boolean flag = packetplayinwindowclick.getStateId() != this.player.containerMenu.getStateId();
this.player.containerMenu.suppressRemoteUpdates();
@ -1590,15 +1626,15 @@
ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packetplayinwindowclick.getChangedSlots()).iterator();
while (objectiterator.hasNext()) {
@@ -1665,6 +2693,7 @@
@@ -1840,6 +2901,7 @@
@Override
public void handleContainerButtonClick(PacketPlayInEnchantItem packetplayinenchantitem) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinenchantitem, this, this.player.getLevel());
+ if (this.player.isImmobile()) return; // CraftBukkit
this.player.resetLastActionTime();
if (this.player.containerMenu.containerId == packetplayinenchantitem.getContainerId() && !this.player.isSpectator()) {
boolean flag = this.player.containerMenu.clickMenuButton(this.player, packetplayinenchantitem.getButtonId());
@@ -1695,6 +2724,43 @@
if (!this.player.containerMenu.stillValid(this.player)) {
@@ -1877,6 +2939,43 @@
boolean flag1 = packetplayinsetcreativeslot.getSlotNum() >= 1 && packetplayinsetcreativeslot.getSlotNum() <= 45;
boolean flag2 = itemstack.isEmpty() || itemstack.getDamageValue() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty();
@ -1642,15 +1678,15 @@
if (flag1 && flag2) {
this.player.inventoryMenu.getSlot(packetplayinsetcreativeslot.getSlotNum()).set(itemstack);
@@ -1717,6 +2783,7 @@
@@ -1899,6 +2998,7 @@
}
private void updateSignText(PacketPlayInUpdateSign packetplayinupdatesign, List<FilteredText<String>> list) {
private void updateSignText(PacketPlayInUpdateSign packetplayinupdatesign, List<FilteredText> list) {
+ if (this.player.isImmobile()) return; // CraftBukkit
this.player.resetLastActionTime();
WorldServer worldserver = this.player.getLevel();
BlockPosition blockposition = packetplayinupdatesign.getPos();
@@ -1733,18 +2800,37 @@
@@ -1915,18 +3015,37 @@
if (!tileentitysign.isEditable() || !this.player.getUUID().equals(tileentitysign.getPlayerWhoMayEdit())) {
PlayerConnection.LOGGER.warn("Player {} just tried to change non-editable sign", this.player.getName().getString());
@ -1666,17 +1702,16 @@
+ String[] lines = new String[4];
+
for (int i = 0; i < list.size(); ++i) {
- FilteredText<IChatBaseComponent> filteredtext = ((FilteredText) list.get(i)).map(IChatBaseComponent::literal);
+ FilteredText<IChatBaseComponent> filteredtext = (list.get(i)).map(IChatBaseComponent::literal); // CraftBukkit - decompile error
FilteredText filteredtext = (FilteredText) list.get(i);
if (this.player.isTextFilteringEnabled()) {
- tileentitysign.setMessage(i, (IChatBaseComponent) filteredtext.filteredOrElse(CommonComponents.EMPTY));
+ lines[i] = EnumChatFormat.stripFormatting(filteredtext.filteredOrElse(CommonComponents.EMPTY).getString());
- tileentitysign.setMessage(i, IChatBaseComponent.literal(filteredtext.filteredOrEmpty()));
+ lines[i] = EnumChatFormat.stripFormatting(filteredtext.filteredOrEmpty());
} else {
- tileentitysign.setMessage(i, (IChatBaseComponent) filteredtext.raw(), (IChatBaseComponent) filteredtext.filteredOrElse(CommonComponents.EMPTY));
+ lines[i] = EnumChatFormat.stripFormatting(filteredtext.raw().getString());
}
}
- tileentitysign.setMessage(i, IChatBaseComponent.literal(filteredtext.raw()), IChatBaseComponent.literal(filteredtext.filteredOrEmpty()));
+ lines[i] = EnumChatFormat.stripFormatting(filteredtext.raw());
+ }
+ }
+ SignChangeEvent event = new SignChangeEvent((org.bukkit.craftbukkit.block.CraftBlock) player.getWorld().getBlockAt(x, y, z), this.player.getBukkitEntity(), lines);
+ this.cserver.getPluginManager().callEvent(event);
+
@ -1684,14 +1719,14 @@
+ IChatBaseComponent[] components = org.bukkit.craftbukkit.block.CraftSign.sanitizeLines(event.getLines());
+ for (int i = 0; i < components.length; i++) {
+ tileentitysign.setMessage(i, components[i]);
+ }
}
+ tileentitysign.isEditable = false;
+ }
}
+ // CraftBukkit end
tileentitysign.setChanged();
worldserver.sendBlockUpdated(blockposition, iblockdata, iblockdata, 3);
@@ -1754,6 +2840,7 @@
@@ -1936,6 +3055,7 @@
@Override
public void handleKeepAlive(PacketPlayInKeepAlive packetplayinkeepalive) {
@ -1699,7 +1734,7 @@
if (this.keepAlivePending && packetplayinkeepalive.getId() == this.keepAliveChallenge) {
int i = (int) (SystemUtils.getMillis() - this.keepAliveTime);
@@ -1768,7 +2855,17 @@
@@ -1950,7 +3070,17 @@
@Override
public void handlePlayerAbilities(PacketPlayInAbilities packetplayinabilities) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinabilities, this, this.player.getLevel());
@ -1718,7 +1753,7 @@
}
@Override
@@ -1777,8 +2874,50 @@
@@ -1959,8 +3089,50 @@
this.player.updateOptions(packetplayinsettings);
}

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/server/network/ServerConnection.java
+++ b/net/minecraft/server/network/ServerConnection.java
@@ -97,14 +97,24 @@
@@ -98,14 +98,24 @@
int j = ServerConnection.this.server.getRateLimitPacketsPerSecond();
Object object = j > 0 ? new NetworkManagerServer(j) : new NetworkManager(EnumProtocolDirection.SERVERBOUND);

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/server/players/ExpirableListEntry.java
+++ b/net/minecraft/server/players/ExpirableListEntry.java
@@ -26,7 +26,7 @@
@@ -27,7 +27,7 @@
}
protected ExpirableListEntry(T t0, JsonObject jsonobject) {
@ -9,7 +9,7 @@
Date date;
@@ -82,4 +82,22 @@
@@ -83,4 +83,22 @@
jsonobject.addProperty("expires", this.expires == null ? "forever" : ExpirableListEntry.DATE_FORMAT.format(this.expires));
jsonobject.addProperty("reason", this.reason);
}

View file

@ -1,11 +1,10 @@
--- a/net/minecraft/server/players/PlayerList.java
+++ b/net/minecraft/server/players/PlayerList.java
@@ -100,6 +100,25 @@
@@ -102,6 +102,24 @@
import net.minecraft.world.scores.ScoreboardTeamBase;
import org.slf4j.Logger;
+// CraftBukkit start
+import com.google.common.base.Predicate;
+import java.util.stream.Collectors;
+import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata;
+import net.minecraft.server.dedicated.DedicatedServer;
@ -26,7 +25,7 @@
public abstract class PlayerList {
public static final File USERBANLIST_FILE = new File("banned-players.json");
@@ -110,14 +129,16 @@
@@ -113,14 +131,16 @@
private static final int SEND_PLAYER_INFO_INTERVAL = 600;
private static final SimpleDateFormat BAN_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
private final MinecraftServer server;
@ -46,7 +45,7 @@
public final WorldNBTStorage playerIo;
private boolean doWhiteList;
private final IRegistryCustom.Dimension registryHolder;
@@ -128,13 +149,23 @@
@@ -131,13 +151,23 @@
private static final boolean ALLOW_LOGOUTIVATOR = false;
private int sendAllPlayerInfoIn;
@ -72,7 +71,7 @@
this.server = minecraftserver;
this.registryHolder = iregistrycustom_dimension;
this.maxPlayers = i;
@@ -150,9 +181,15 @@
@@ -153,9 +183,15 @@
usercache.add(gameprofile);
NBTTagCompound nbttagcompound = this.load(entityplayer);
ResourceKey resourcekey;
@ -89,7 +88,7 @@
Logger logger = PlayerList.LOGGER;
Objects.requireNonNull(logger);
@@ -179,7 +216,8 @@
@@ -182,7 +218,8 @@
s1 = networkmanager.getRemoteAddress().toString();
}
@ -99,7 +98,7 @@
WorldData worlddata = worldserver1.getLevelData();
entityplayer.loadGameTypes(nbttagcompound);
@@ -189,6 +227,7 @@
@@ -192,6 +229,7 @@
boolean flag1 = gamerules.getBoolean(GameRules.RULE_REDUCEDDEBUGINFO);
playerconnection.send(new PacketPlayOutLogin(entityplayer.getId(), worlddata.isHardcore(), entityplayer.gameMode.getGameModeForPlayer(), entityplayer.gameMode.getPreviousGameModeForPlayer(), this.server.levelKeys(), this.registryHolder, worldserver1.dimensionTypeId(), worldserver1.dimension(), BiomeManager.obfuscateSeed(worldserver1.getSeed()), this.getMaxPlayers(), this.viewDistance, this.simulationDistance, flag1, !flag, worldserver1.isDebug(), worldserver1.isFlat(), entityplayer.getLastDeathLocation()));
@ -107,7 +106,7 @@
playerconnection.send(new PacketPlayOutCustomPayload(PacketPlayOutCustomPayload.BRAND, (new PacketDataSerializer(Unpooled.buffer())).writeUtf(this.getServer().getServerModName())));
playerconnection.send(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked()));
playerconnection.send(new PacketPlayOutAbilities(entityplayer.getAbilities()));
@@ -207,19 +246,66 @@
@@ -210,19 +248,66 @@
} else {
ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.player.joined.renamed", entityplayer.getDisplayName(), s);
}
@ -115,7 +114,7 @@
+ ichatmutablecomponent.withStyle(EnumChatFormat.YELLOW);
+ String joinMessage = CraftChatMessage.fromComponent(ichatmutablecomponent);
- this.broadcastSystemMessage(ichatmutablecomponent.withStyle(EnumChatFormat.YELLOW), ChatMessageType.SYSTEM);
- this.broadcastSystemMessage(ichatmutablecomponent.withStyle(EnumChatFormat.YELLOW), false);
playerconnection.teleport(entityplayer.getX(), entityplayer.getY(), entityplayer.getZ(), entityplayer.getYRot(), entityplayer.getXRot());
this.players.add(entityplayer);
this.playersByUUID.put(entityplayer.getUUID(), entityplayer);
@ -139,7 +138,7 @@
+
+ if (joinMessage != null && joinMessage.length() > 0) {
+ for (IChatBaseComponent line : org.bukkit.craftbukkit.util.CraftChatMessage.fromString(joinMessage)) {
+ server.getPlayerList().broadcastSystemMessage(line, ChatMessageType.SYSTEM);
+ server.getPlayerList().broadcastSystemMessage(line, false);
+ }
+ }
+ // CraftBukkit end
@ -179,7 +178,7 @@
this.sendLevelInfo(entityplayer, worldserver1);
this.server.getServerResourcePack().ifPresent((minecraftserver_serverresourcepackinfo) -> {
entityplayer.sendTexturePack(minecraftserver_serverresourcepackinfo.url(), minecraftserver_serverresourcepackinfo.hash(), minecraftserver_serverresourcepackinfo.isRequired(), minecraftserver_serverresourcepackinfo.prompt());
@@ -235,8 +321,11 @@
@@ -238,8 +323,11 @@
if (nbttagcompound != null && nbttagcompound.contains("RootVehicle", 10)) {
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("RootVehicle");
@ -193,7 +192,7 @@
});
if (entity != null) {
@@ -279,6 +368,8 @@
@@ -282,6 +370,8 @@
}
entityplayer.initInventoryMenu();
@ -202,7 +201,7 @@
}
public void updateEntireScoreboard(ScoreboardServer scoreboardserver, EntityPlayer entityplayer) {
@@ -311,30 +402,31 @@
@@ -314,30 +404,31 @@
}
public void addWorldborderListener(WorldServer worldserver) {
@ -239,7 +238,7 @@
}
@Override
@@ -362,14 +454,15 @@
@@ -365,14 +456,15 @@
}
protected void save(EntityPlayer entityplayer) {
@ -257,7 +256,7 @@
if (advancementdataplayer != null) {
advancementdataplayer.save();
@@ -377,10 +470,24 @@
@@ -380,10 +472,24 @@
}
@ -283,7 +282,7 @@
this.save(entityplayer);
if (entityplayer.isPassenger()) {
Entity entity = entityplayer.getRootVehicle();
@@ -404,18 +511,66 @@
@@ -407,18 +513,66 @@
if (entityplayer1 == entityplayer) {
this.playersByUUID.remove(uuid);
@ -356,7 +355,7 @@
GameProfileBanEntry gameprofilebanentry = (GameProfileBanEntry) this.bans.get(gameprofile);
ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.disconnect.banned.reason", gameprofilebanentry.getReason());
@@ -423,10 +578,12 @@
@@ -426,10 +580,12 @@
ichatmutablecomponent.append((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.banned.expiration", PlayerList.BAN_DATE_FORMAT.format(gameprofilebanentry.getExpires())));
}
@ -372,7 +371,7 @@
IpBanEntry ipbanentry = this.ipBans.get(socketaddress);
ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.disconnect.banned_ip.reason", ipbanentry.getReason());
@@ -434,13 +591,25 @@
@@ -437,13 +593,25 @@
ichatmutablecomponent.append((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.banned_ip.expiration", PlayerList.BAN_DATE_FORMAT.format(ipbanentry.getExpires())));
}
@ -401,7 +400,7 @@
UUID uuid = UUIDUtil.getOrCreatePlayerUUID(gameprofile);
List<EntityPlayer> list = Lists.newArrayList();
@@ -467,14 +636,24 @@
@@ -470,14 +638,24 @@
}
return new EntityPlayer(this.server, this.server.overworld(), gameprofile, profilepublickey);
@ -426,7 +425,7 @@
WorldServer worldserver = this.server.getLevel(entityplayer.getRespawnDimension());
Optional optional;
@@ -486,6 +665,11 @@
@@ -489,6 +667,11 @@
WorldServer worldserver1 = worldserver != null && optional.isPresent() ? worldserver : this.server.overworld();
EntityPlayer entityplayer1 = new EntityPlayer(this.server, worldserver1, entityplayer.getGameProfile(), entityplayer.getProfilePublicKey());
@ -438,7 +437,7 @@
entityplayer1.connection = entityplayer.connection;
entityplayer1.restoreFrom(entityplayer, flag);
@@ -501,49 +685,110 @@
@@ -504,49 +687,110 @@
boolean flag2 = false;
@ -573,7 +572,7 @@
return entityplayer1;
}
@@ -556,7 +801,18 @@
@@ -559,7 +803,18 @@
public void tick() {
if (++this.sendAllPlayerInfoIn > 600) {
@ -584,7 +583,7 @@
+
+ target.connection.send(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_LATENCY, this.players.stream().filter(new Predicate<EntityPlayer>() {
+ @Override
+ public boolean apply(EntityPlayer input) {
+ public boolean test(EntityPlayer input) {
+ return target.getBukkitEntity().canSee(input.getBukkitEntity());
+ }
+ }).collect(Collectors.toList())));
@ -593,7 +592,7 @@
this.sendAllPlayerInfoIn = 0;
}
@@ -573,6 +829,25 @@
@@ -576,6 +831,25 @@
}
@ -619,7 +618,7 @@
public void broadcastAll(Packet<?> packet, ResourceKey<World> resourcekey) {
Iterator iterator = this.players.iterator();
@@ -651,7 +926,7 @@
@@ -654,7 +928,7 @@
}
public void deop(GameProfile gameprofile) {
@ -628,7 +627,7 @@
EntityPlayer entityplayer = this.getPlayer(gameprofile.getId());
if (entityplayer != null) {
@@ -675,6 +950,7 @@
@@ -678,6 +952,7 @@
entityplayer.connection.send(new PacketPlayOutEntityStatus(entityplayer, b0));
}
@ -636,7 +635,7 @@
this.server.getCommands().sendCommands(entityplayer);
}
@@ -707,6 +983,12 @@
@@ -710,6 +985,12 @@
for (int i = 0; i < this.players.size(); ++i) {
EntityPlayer entityplayer = (EntityPlayer) this.players.get(i);
@ -649,7 +648,7 @@
if (entityplayer != entityhuman && entityplayer.level.dimension() == resourcekey) {
double d4 = d0 - entityplayer.getX();
double d5 = d1 - entityplayer.getY();
@@ -746,23 +1028,34 @@
@@ -749,23 +1030,34 @@
public void reloadWhiteList() {}
public void sendLevelInfo(EntityPlayer entityplayer, WorldServer worldserver) {
@ -689,7 +688,7 @@
}
public int getPlayerCount() {
@@ -818,12 +1111,22 @@
@@ -821,12 +1113,22 @@
}
public void removeAll() {
@ -706,16 +705,16 @@
+ // CraftBukkit start
+ public void broadcastMessage(IChatBaseComponent[] iChatBaseComponents) {
+ for (IChatBaseComponent component : iChatBaseComponents) {
+ broadcastSystemMessage(component, ChatMessageType.SYSTEM);
+ broadcastSystemMessage(component, false);
+ }
+ }
+ // CraftBukkit end
+
public void broadcastSystemMessage(IChatBaseComponent ichatbasecomponent, ResourceKey<ChatMessageType> resourcekey) {
public void broadcastSystemMessage(IChatBaseComponent ichatbasecomponent, boolean flag) {
this.broadcastSystemMessage(ichatbasecomponent, (entityplayer) -> {
return ichatbasecomponent;
@@ -883,16 +1186,23 @@
@@ -902,16 +1204,23 @@
return !playerchatmessage.hasExpiredServer(Instant.now()) && playerchatmessage.verify(chatsender);
}
- public ServerStatisticManager getPlayerStats(EntityHuman entityhuman) {
@ -742,7 +741,7 @@
Path path = file2.toPath();
if (FileUtils.isPathNormalized(path) && FileUtils.isPathPortable(path) && path.startsWith(file.getPath()) && file2.isFile()) {
@@ -901,7 +1211,7 @@
@@ -920,7 +1229,7 @@
}
serverstatisticmanager = new ServerStatisticManager(this.server, file1);
@ -751,7 +750,7 @@
}
return serverstatisticmanager;
@@ -909,14 +1219,14 @@
@@ -928,14 +1237,14 @@
public AdvancementDataPlayer getPlayerAdvancements(EntityPlayer entityplayer) {
UUID uuid = entityplayer.getUUID();
@ -768,7 +767,7 @@
}
advancementdataplayer.setPlayer(entityplayer);
@@ -967,13 +1277,20 @@
@@ -986,13 +1295,20 @@
}
public void reloadResources() {

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/util/datafix/DataConverterRegistry.java
+++ b/net/minecraft/util/datafix/DataConverterRegistry.java
@@ -436,6 +436,18 @@
@@ -439,6 +439,18 @@
datafixerbuilder.addFixer(new DataConverterItemFrame(schema46, false));
Schema schema47 = datafixerbuilder.addSchema(1458, DataConverterRegistry.SAME_NAMESPACED);
@ -19,7 +19,7 @@
datafixerbuilder.addFixer(new DataConverterCustomNameEntity(schema47, false));
datafixerbuilder.addFixer(new DataConverterCustomNameItem(schema47, false));
datafixerbuilder.addFixer(new DataConverterCustomNameTile(schema47, false));
@@ -753,12 +765,14 @@
@@ -756,12 +768,14 @@
datafixerbuilder.addFixer(new DataConverterAddChoices(schema131, "Added Glow Squid", DataConverterTypes.ENTITY));
datafixerbuilder.addFixer(new DataConverterAddChoices(schema131, "Added Glow Item Frame", DataConverterTypes.ENTITY));
Schema schema132 = datafixerbuilder.addSchema(2690, DataConverterRegistry.SAME_NAMESPACED);
@ -36,7 +36,7 @@
datafixerbuilder.addFixer(DataConverterItemName.create(schema133, "Rename copper item suffixes", createRenamer(immutablemap1)));
datafixerbuilder.addFixer(BlockRenameFixWithJigsaw.create(schema133, "Rename copper blocks suffixes", createRenamer(immutablemap1)));
@@ -766,7 +780,8 @@
@@ -769,7 +783,8 @@
datafixerbuilder.addFixer(new AddFlagIfNotPresentFix(schema134, DataConverterTypes.WORLD_GEN_SETTINGS, "has_increased_height_already", false));
Schema schema135 = datafixerbuilder.addSchema(2696, DataConverterRegistry.SAME_NAMESPACED);
@ -46,7 +46,7 @@
datafixerbuilder.addFixer(DataConverterItemName.create(schema135, "Renamed grimstone block items to deepslate", createRenamer(immutablemap2)));
datafixerbuilder.addFixer(BlockRenameFixWithJigsaw.create(schema135, "Renamed grimstone blocks to deepslate", createRenamer(immutablemap2)));
@@ -853,10 +868,11 @@
@@ -856,10 +871,11 @@
datafixerbuilder.addFixer(new DataConverterAddChoices(schema160, "Added Allay", DataConverterTypes.ENTITY));
Schema schema161 = datafixerbuilder.addSchema(3084, DataConverterRegistry.SAME_NAMESPACED);
@ -60,7 +60,7 @@
int2objectopenhashmap1.defaultReturnValue("minecraft:tabby");
int2objectopenhashmap1.put(0, "minecraft:tabby");
int2objectopenhashmap1.put(1, "minecraft:black");
@@ -873,7 +889,8 @@
@@ -876,7 +892,8 @@
Objects.requireNonNull(int2objectopenhashmap);
datafixerbuilder.addFixer(new EntityVariantFix(schema162, "Change cat variant type", typereference, "minecraft:cat", "CatType", int2objectopenhashmap::get));

View file

@ -253,7 +253,7 @@
if (this.onGround) {
block.stepOn(this.level, blockposition, iblockdata, this);
}
@@ -1295,6 +1471,7 @@
@@ -1290,6 +1466,7 @@
this.yo = d1;
this.zo = d4;
this.setPos(d3, d1, d4);
@ -261,7 +261,7 @@
}
public void moveTo(Vec3D vec3d) {
@@ -1485,6 +1662,12 @@
@@ -1480,6 +1657,12 @@
return false;
}
@ -274,7 +274,7 @@
public void awardKillScore(Entity entity, int i, DamageSource damagesource) {
if (entity instanceof EntityPlayer) {
CriterionTriggers.ENTITY_KILLED_PLAYER.trigger((EntityPlayer) entity, this, damagesource);
@@ -1518,7 +1701,7 @@
@@ -1513,7 +1696,7 @@
} else {
String s = this.getEncodeId();
@ -283,7 +283,7 @@
return false;
} else {
nbttagcompound.putString("id", s);
@@ -1543,6 +1726,18 @@
@@ -1538,6 +1721,18 @@
Vec3D vec3d = this.getDeltaMovement();
nbttagcompound.put("Motion", this.newDoubleList(vec3d.x, vec3d.y, vec3d.z));
@ -302,7 +302,7 @@
nbttagcompound.put("Rotation", this.newFloatList(this.getYRot(), this.getXRot()));
nbttagcompound.putFloat("FallDistance", this.fallDistance);
nbttagcompound.putShort("Fire", (short) this.remainingFireTicks);
@@ -1551,6 +1746,22 @@
@@ -1546,6 +1741,22 @@
nbttagcompound.putBoolean("Invulnerable", this.invulnerable);
nbttagcompound.putInt("PortalCooldown", this.portalCooldown);
nbttagcompound.putUUID("UUID", this.getUUID());
@ -325,7 +325,7 @@
IChatBaseComponent ichatbasecomponent = this.getCustomName();
if (ichatbasecomponent != null) {
@@ -1618,6 +1829,11 @@
@@ -1613,6 +1824,11 @@
}
}
@ -337,7 +337,7 @@
return nbttagcompound;
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT");
@@ -1699,6 +1915,44 @@
@@ -1696,6 +1912,44 @@
} else {
throw new IllegalStateException("Entity has invalid position");
}
@ -382,7 +382,7 @@
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT");
CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Entity being loaded");
@@ -1774,9 +2028,22 @@
@@ -1771,9 +2025,22 @@
} else if (this.level.isClientSide) {
return null;
} else {
@ -405,7 +405,7 @@
this.level.addFreshEntity(entityitem);
return entityitem;
}
@@ -1870,7 +2137,7 @@
@@ -1867,7 +2134,7 @@
this.setPose(EntityPose.STANDING);
this.vehicle = entity;
@ -414,7 +414,7 @@
entity.getIndirectPassengersStream().filter((entity2) -> {
return entity2 instanceof EntityPlayer;
}).forEach((entity2) -> {
@@ -1901,7 +2168,7 @@
@@ -1898,7 +2165,7 @@
Entity entity = this.vehicle;
this.vehicle = null;
@ -423,7 +423,7 @@
}
}
@@ -1910,10 +2177,31 @@
@@ -1907,10 +2174,31 @@
this.removeVehicle();
}
@ -456,7 +456,7 @@
if (this.passengers.isEmpty()) {
this.passengers = ImmutableList.of(entity);
} else {
@@ -1929,12 +2217,32 @@
@@ -1926,12 +2214,32 @@
}
}
@ -490,7 +490,7 @@
if (this.passengers.size() == 1 && this.passengers.get(0) == entity) {
this.passengers = ImmutableList.of();
} else {
@@ -1945,6 +2253,7 @@
@@ -1942,6 +2250,7 @@
entity.boardingCooldown = 60;
}
@ -498,7 +498,7 @@
}
protected boolean canAddPassenger(Entity entity) {
@@ -2007,14 +2316,20 @@
@@ -2004,14 +2313,20 @@
if (this.isInsidePortal) {
MinecraftServer minecraftserver = worldserver.getServer();
@ -522,7 +522,7 @@
this.level.getProfiler().pop();
}
@@ -2132,6 +2447,13 @@
@@ -2129,6 +2444,13 @@
}
public void setSwimming(boolean flag) {
@ -536,7 +536,7 @@
this.setSharedFlag(4, flag);
}
@@ -2177,8 +2499,12 @@
@@ -2174,8 +2496,12 @@
return this.getTeam() != null ? this.getTeam().isAlliedTo(scoreboardteambase) : false;
}
@ -550,7 +550,7 @@
}
public boolean getSharedFlag(int i) {
@@ -2197,7 +2523,7 @@
@@ -2194,7 +2520,7 @@
}
public int getMaxAirSupply() {
@ -559,7 +559,7 @@
}
public int getAirSupply() {
@@ -2205,7 +2531,18 @@
@@ -2202,7 +2528,18 @@
}
public void setAirSupply(int i) {
@ -579,7 +579,7 @@
}
public int getTicksFrozen() {
@@ -2232,11 +2569,41 @@
@@ -2229,11 +2566,41 @@
public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) {
this.setRemainingFireTicks(this.remainingFireTicks + 1);
@ -623,7 +623,7 @@
}
public void onAboveBubbleCol(boolean flag) {
@@ -2394,15 +2761,38 @@
@@ -2391,15 +2758,38 @@
@Nullable
public Entity changeDimension(WorldServer worldserver) {
@ -664,7 +664,7 @@
this.level.getProfiler().popPush("reloading");
Entity entity = this.getType().create(worldserver);
@@ -2411,9 +2801,17 @@
@@ -2408,9 +2798,17 @@
entity.moveTo(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, entity.getXRot());
entity.setDeltaMovement(shapedetectorshape.speed);
worldserver.addDuringTeleport(entity);
@ -684,7 +684,7 @@
}
this.removeAfterChangingDimensions();
@@ -2434,20 +2832,34 @@
@@ -2431,20 +2829,34 @@
@Nullable
protected ShapeDetectorShape findDimensionEntryPoint(WorldServer worldserver) {
@ -724,7 +724,7 @@
IBlockData iblockdata = this.level.getBlockState(this.portalEntrancePos);
EnumDirection.EnumAxis enumdirection_enumaxis;
Vec3D vec3d;
@@ -2464,8 +2876,8 @@
@@ -2461,8 +2873,8 @@
vec3d = new Vec3D(0.5D, 0.0D, 0.0D);
}
@ -735,7 +735,7 @@
}
} else {
BlockPosition blockposition1;
@@ -2475,8 +2887,14 @@
@@ -2472,8 +2884,14 @@
} else {
blockposition1 = worldserver.getHeightmapPos(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver.getSharedSpawnPos());
}
@ -751,7 +751,7 @@
}
}
@@ -2484,8 +2902,23 @@
@@ -2481,8 +2899,23 @@
return BlockPortalShape.getRelativePosition(blockutil_rectangle, enumdirection_enumaxis, this.position(), this.getDimensions(this.getPose()));
}
@ -777,7 +777,7 @@
}
public boolean canChangeDimensions() {
@@ -2694,7 +3127,26 @@
@@ -2691,7 +3124,26 @@
}
public final void setBoundingBox(AxisAlignedBB axisalignedbb) {
@ -805,7 +805,7 @@
}
protected float getEyeHeight(EntityPose entitypose, EntitySize entitysize) {
@@ -2982,6 +3434,11 @@
@@ -2979,6 +3431,11 @@
vec3d = vec3d.add(vec3d1);
++k1;
}

View file

@ -90,7 +90,7 @@
+ // CraftBukkit end
boolean flag = itemstack1.isEmpty() && itemstack.isEmpty();
if (!flag && !ItemStack.isSameIgnoreDurability(itemstack, itemstack1)) {
if (!flag && !ItemStack.isSameIgnoreDurability(itemstack, itemstack1) && !this.firstTick) {
- if (enumitemslot.getType() == EnumItemSlot.Function.ARMOR) {
+ if (enumitemslot.getType() == EnumItemSlot.Function.ARMOR && !silent) { // CraftBukkit
this.playEquipSound(itemstack1);
@ -815,7 +815,7 @@
this.setSharedFlag(7, false);
}
} else {
@@ -2769,6 +3201,7 @@
@@ -2772,6 +3204,7 @@
}
if (!this.level.isClientSide) {
@ -823,7 +823,7 @@
this.setSharedFlag(7, flag);
}
@@ -2928,14 +3361,21 @@
@@ -2931,14 +3364,21 @@
@Override
public boolean isPickable() {
@ -847,7 +847,7 @@
@Override
public float getYHeadRot() {
return this.yHeadRot;
@@ -3130,7 +3570,25 @@
@@ -3133,7 +3573,25 @@
} else {
if (!this.useItem.isEmpty() && this.isUsingItem()) {
this.triggerItemUseEffects(this.useItem, 16);
@ -874,7 +874,7 @@
if (itemstack != this.useItem) {
this.setItemInHand(enumhand, itemstack);
@@ -3208,6 +3666,12 @@
@@ -3211,6 +3669,12 @@
}
public boolean randomTeleport(double d0, double d1, double d2, boolean flag) {
@ -887,7 +887,7 @@
double d3 = this.getX();
double d4 = this.getY();
double d5 = this.getZ();
@@ -3232,16 +3696,41 @@
@@ -3235,16 +3699,41 @@
}
if (flag2) {
@ -932,7 +932,7 @@
} else {
if (flag) {
world.broadcastEntityEvent(this, (byte) 46);
@@ -3251,7 +3740,7 @@
@@ -3254,7 +3743,7 @@
((EntityCreature) this).getNavigation().stop();
}
@ -941,7 +941,7 @@
}
}
@@ -3334,7 +3823,7 @@
@@ -3337,7 +3826,7 @@
}
public void stopSleeping() {
@ -950,7 +950,7 @@
World world = this.level;
java.util.Objects.requireNonNull(this.level);
@@ -3366,7 +3855,7 @@
@@ -3369,7 +3858,7 @@
@Nullable
public EnumDirection getBedOrientation() {
@ -959,7 +959,7 @@
return blockposition != null ? BlockBed.getBedOrientation(this.level, blockposition) : null;
}
@@ -3414,7 +3903,7 @@
@@ -3417,7 +3906,7 @@
Pair<MobEffect, Float> pair = (Pair) iterator.next();
if (!world.isClientSide && pair.getFirst() != null && world.random.nextFloat() < (Float) pair.getSecond()) {

View file

@ -21,7 +21,7 @@
public EntityItem(EntityTypes<? extends EntityItem> entitytypes, World world) {
super(entitytypes, world);
@@ -105,9 +112,12 @@
@@ -103,9 +110,12 @@
this.discard();
} else {
super.tick();
@ -37,7 +37,7 @@
this.xo = this.getX();
this.yo = this.getY();
@@ -157,9 +167,11 @@
@@ -155,9 +165,11 @@
this.mergeWithNeighbours();
}
@ -49,7 +49,7 @@
this.hasImpulse |= this.updateInWaterStateAndDoFluidPushing();
if (!this.level.isClientSide) {
@@ -171,6 +183,12 @@
@@ -169,6 +181,12 @@
}
if (!this.level.isClientSide && this.age >= 6000) {
@ -62,7 +62,7 @@
this.discard();
}
@@ -246,10 +264,11 @@
@@ -244,10 +262,11 @@
private static void merge(EntityItem entityitem, ItemStack itemstack, ItemStack itemstack1) {
ItemStack itemstack2 = merge(itemstack, itemstack1, 64);
@ -75,7 +75,7 @@
merge(entityitem, itemstack, itemstack1);
entityitem.pickupDelay = Math.max(entityitem.pickupDelay, entityitem1.pickupDelay);
entityitem.age = Math.min(entityitem.age, entityitem1.age);
@@ -275,6 +294,11 @@
@@ -273,6 +292,11 @@
} else if (this.level.isClientSide) {
return true;
} else {
@ -87,7 +87,7 @@
this.markHurt();
this.health = (int) ((float) this.health - f);
this.gameEvent(GameEvent.ENTITY_DAMAGE, damagesource.getEntity());
@@ -338,6 +362,46 @@
@@ -336,6 +360,46 @@
Item item = itemstack.getItem();
int i = itemstack.getCount();
@ -134,7 +134,7 @@
if (this.pickupDelay == 0 && (this.owner == null || this.owner.equals(entityhuman.getUUID())) && entityhuman.getInventory().add(itemstack)) {
entityhuman.take(this, i);
if (itemstack.isEmpty()) {
@@ -381,7 +445,9 @@
@@ -379,7 +443,9 @@
}
public void setItem(ItemStack itemstack) {

View file

@ -88,7 +88,7 @@
}
}
}
@@ -248,7 +271,7 @@
@@ -249,7 +272,7 @@
}
}

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/player/EntityHuman.java
+++ b/net/minecraft/world/entity/player/EntityHuman.java
@@ -116,6 +116,20 @@
@@ -117,6 +117,20 @@
import net.minecraft.world.scores.ScoreboardTeamBase;
import org.slf4j.Logger;
@ -21,7 +21,7 @@
public abstract class EntityHuman extends EntityLiving {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -129,7 +143,8 @@
@@ -130,7 +144,8 @@
public static final float SWIMMING_BB_HEIGHT = 0.6F;
public static final float DEFAULT_EYE_HEIGHT = 1.62F;
public static final EntitySize STANDING_DIMENSIONS = EntitySize.scalable(0.6F, 1.8F);
@ -31,7 +31,7 @@
private static final int FLY_ACHIEVEMENT_SPEED = 25;
private static final DataWatcherObject<Float> DATA_PLAYER_ABSORPTION_ID = DataWatcher.defineId(EntityHuman.class, DataWatcherRegistry.FLOAT);
private static final DataWatcherObject<Integer> DATA_SCORE_ID = DataWatcher.defineId(EntityHuman.class, DataWatcherRegistry.INT);
@@ -139,10 +154,10 @@
@@ -140,10 +155,10 @@
protected static final DataWatcherObject<NBTTagCompound> DATA_SHOULDER_RIGHT = DataWatcher.defineId(EntityHuman.class, DataWatcherRegistry.COMPOUND_TAG);
private long timeEntitySatOnShoulder;
private final PlayerInventory inventory = new PlayerInventory(this);
@ -44,7 +44,7 @@
protected WardenSpawnTracker wardenSpawnTracker = new WardenSpawnTracker(0, 0, 0);
protected int jumpTriggerTime;
public float oBob;
@@ -173,6 +188,16 @@
@@ -174,6 +189,16 @@
@Nullable
public EntityFishingHook fishing;
@ -61,7 +61,7 @@
public EntityHuman(World world, BlockPosition blockposition, float f, GameProfile gameprofile, @Nullable ProfilePublicKey profilepublickey) {
super(EntityTypes.PLAYER, world);
this.lastItemInMainHand = ItemStack.EMPTY;
@@ -314,7 +339,7 @@
@@ -315,7 +340,7 @@
ItemStack itemstack = this.getItemBySlot(EnumItemSlot.HEAD);
if (itemstack.is(Items.TURTLE_HELMET) && !this.isEyeInFluid(TagsFluid.WATER)) {
@ -70,7 +70,7 @@
}
}
@@ -506,7 +531,8 @@
@@ -507,7 +532,8 @@
if (this.level.getDifficulty() == EnumDifficulty.PEACEFUL && this.level.getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION)) {
if (this.getHealth() < this.getMaxHealth() && this.tickCount % 20 == 0) {
@ -80,7 +80,7 @@
}
if (this.foodData.needsFood() && this.tickCount % 10 == 0) {
@@ -670,6 +696,13 @@
@@ -671,6 +697,13 @@
@Nullable
public EntityItem drop(ItemStack itemstack, boolean flag, boolean flag1) {
@ -94,7 +94,7 @@
if (itemstack.isEmpty()) {
return null;
} else {
@@ -704,6 +737,33 @@
@@ -705,6 +738,33 @@
entityitem.setDeltaMovement((double) (-f3 * f2 * 0.3F) + Math.cos((double) f5) * (double) f6, (double) (-f1 * 0.3F + 0.1F + (this.random.nextFloat() - this.random.nextFloat()) * 0.1F), (double) (f4 * f2 * 0.3F) + Math.sin((double) f5) * (double) f6);
}
@ -128,7 +128,7 @@
return entityitem;
}
}
@@ -780,7 +840,7 @@
@@ -781,7 +841,7 @@
this.setScore(nbttagcompound.getInt("Score"));
this.foodData.readAdditionalSaveData(nbttagcompound);
if (nbttagcompound.contains("warden_spawn_tracker", 10)) {
@ -137,7 +137,7 @@
Logger logger = EntityHuman.LOGGER;
Objects.requireNonNull(logger);
@@ -804,7 +864,7 @@
@@ -805,7 +865,7 @@
}
if (nbttagcompound.contains("LastDeathLocation", 10)) {
@ -146,7 +146,7 @@
Logger logger1 = EntityHuman.LOGGER;
Objects.requireNonNull(logger1);
@@ -826,7 +886,7 @@
@@ -827,7 +887,7 @@
nbttagcompound.putInt("XpSeed", this.enchantmentSeed);
nbttagcompound.putInt("Score", this.getScore());
this.foodData.addAdditionalSaveData(nbttagcompound);
@ -155,7 +155,7 @@
Logger logger = EntityHuman.LOGGER;
Objects.requireNonNull(logger);
@@ -844,7 +904,7 @@
@@ -845,7 +905,7 @@
}
this.getLastDeathLocation().flatMap((globalpos) -> {
@ -164,7 +164,7 @@
Logger logger1 = EntityHuman.LOGGER;
Objects.requireNonNull(logger1);
@@ -871,12 +931,12 @@
@@ -872,12 +932,12 @@
return false;
} else {
if (!this.level.isClientSide) {
@ -179,7 +179,7 @@
}
if (this.level.getDifficulty() == EnumDifficulty.EASY) {
@@ -888,7 +948,13 @@
@@ -889,7 +949,13 @@
}
}
@ -194,7 +194,7 @@
}
}
}
@@ -908,10 +974,29 @@
@@ -909,10 +975,29 @@
}
public boolean canHarmPlayer(EntityHuman entityhuman) {
@ -227,7 +227,7 @@
}
@Override
@@ -953,8 +1038,13 @@
@@ -954,8 +1039,13 @@
}
}
@ -242,7 +242,7 @@
if (!this.isInvulnerableTo(damagesource)) {
f = this.getDamageAfterArmorAbsorb(damagesource, f);
f = this.getDamageAfterMagicAbsorb(damagesource, f);
@@ -969,7 +1059,7 @@
@@ -970,7 +1060,7 @@
}
if (f != 0.0F) {
@ -251,7 +251,7 @@
float f3 = this.getHealth();
this.setHealth(this.getHealth() - f);
@@ -980,6 +1070,7 @@
@@ -981,6 +1071,7 @@
}
}
@ -259,7 +259,7 @@
}
@Override
@@ -1139,7 +1230,7 @@
@@ -1140,7 +1231,7 @@
f *= 0.2F + f2 * f2 * 0.8F;
f1 *= f2;
@ -268,7 +268,7 @@
if (f > 0.0F || f1 > 0.0F) {
boolean flag = f2 > 0.9F;
boolean flag1 = false;
@@ -1178,8 +1269,15 @@
@@ -1179,8 +1270,15 @@
if (entity instanceof EntityLiving) {
f3 = ((EntityLiving) entity).getHealth();
if (j > 0 && !entity.isOnFire()) {
@ -286,7 +286,7 @@
}
}
@@ -1207,8 +1305,11 @@
@@ -1208,8 +1306,11 @@
EntityLiving entityliving = (EntityLiving) iterator.next();
if (entityliving != this && entityliving != entity && !this.isAlliedTo((Entity) entityliving) && (!(entityliving instanceof EntityArmorStand) || !((EntityArmorStand) entityliving).isMarker()) && this.distanceToSqr((Entity) entityliving) < 9.0D) {
@ -299,7 +299,7 @@
}
}
@@ -1217,9 +1318,26 @@
@@ -1218,9 +1319,26 @@
}
if (entity instanceof EntityPlayer && entity.hurtMarked) {
@ -326,7 +326,7 @@
}
if (flag2) {
@@ -1264,7 +1382,14 @@
@@ -1265,7 +1383,14 @@
this.awardStat(StatisticList.DAMAGE_DEALT, Math.round(f5 * 10.0F));
if (j > 0) {
@ -342,7 +342,7 @@
}
if (this.level instanceof WorldServer && f5 > 2.0F) {
@@ -1274,12 +1399,17 @@
@@ -1275,12 +1400,17 @@
}
}
@ -361,8 +361,8 @@
}
}
@@ -1357,6 +1487,12 @@
public void updateTutorialInventoryAction(ItemStack itemstack, ItemStack itemstack1, ClickAction clickaction) {}
@@ -1362,6 +1492,12 @@
}
public Either<EntityHuman.EnumBedResult, Unit> startSleepInBed(BlockPosition blockposition) {
+ // CraftBukkit start
@ -374,7 +374,7 @@
this.startSleeping(blockposition);
this.sleepCounter = 0;
return Either.right(Unit.INSTANCE);
@@ -1441,9 +1577,9 @@
@@ -1446,9 +1582,9 @@
super.jumpFromGround();
this.awardStat(StatisticList.JUMP);
if (this.isSprinting()) {
@ -386,7 +386,7 @@
}
}
@@ -1477,7 +1613,11 @@
@@ -1482,7 +1618,11 @@
this.setDeltaMovement(vec3d2.x, d3 * 0.6D, vec3d2.z);
this.flyingSpeed = f;
this.resetFallDistance();
@ -399,7 +399,7 @@
} else {
super.travel(vec3d);
}
@@ -1512,19 +1652,19 @@
@@ -1517,19 +1657,19 @@
i = Math.round((float) Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F);
if (i > 0) {
this.awardStat(StatisticList.SWIM_ONE_CM, i);
@ -422,7 +422,7 @@
}
} else if (this.onClimbable()) {
if (d1 > 0.0D) {
@@ -1535,13 +1675,13 @@
@@ -1540,13 +1680,13 @@
if (i > 0) {
if (this.isSprinting()) {
this.awardStat(StatisticList.SPRINT_ONE_CM, i);
@ -439,7 +439,7 @@
}
}
} else if (this.isFallFlying()) {
@@ -1607,12 +1747,24 @@
@@ -1617,12 +1757,24 @@
}
public void startFallFlying() {
@ -465,7 +465,7 @@
}
@Override
@@ -1703,10 +1855,21 @@
@@ -1713,10 +1865,21 @@
return this.experienceLevel >= 30 ? 112 + (this.experienceLevel - 30) * 9 : (this.experienceLevel >= 15 ? 37 + (this.experienceLevel - 15) * 5 : 7 + this.experienceLevel * 2);
}
@ -488,7 +488,7 @@
}
}
@@ -1792,13 +1955,20 @@
@@ -1802,13 +1965,20 @@
@Override
public void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack) {
@ -512,7 +512,7 @@
}
}
@@ -1837,26 +2007,31 @@
@@ -1847,26 +2017,31 @@
protected void removeEntitiesOnShoulder() {
if (this.timeEntitySatOnShoulder + 20L < this.level.getGameTime()) {

View file

@ -16,15 +16,6 @@
public class EntityBoat extends Entity {
private static final DataWatcherObject<Integer> DATA_ID_HURT = DataWatcher.defineId(EntityBoat.class, DataWatcherRegistry.INT);
@@ -82,7 +91,7 @@
private boolean inputDown;
private double waterLevel;
private float landFriction;
- private EntityBoat.EnumStatus status;
+ public EntityBoat.EnumStatus status;
private EntityBoat.EnumStatus oldStatus;
private double lastYd;
private boolean isAboveBubbleColumn;
@@ -91,6 +100,14 @@
private float bubbleAngle;
private float bubbleAngleO;

View file

@ -20,7 +20,7 @@
+
public abstract class Container {
private static Logger LOGGER = LogUtils.getLogger();
private static final Logger LOGGER = LogUtils.getLogger();
@@ -62,6 +76,27 @@
private ContainerSynchronizer synchronizer;
private boolean suppressRemoteUpdates;

View file

@ -72,7 +72,7 @@
return stillValid(this.access, entityhuman, Blocks.LOOM);
}
@@ -304,6 +342,11 @@
@@ -309,6 +347,11 @@
if (nbttagcompound != null && nbttagcompound.contains("Patterns", 9)) {
nbttaglist = nbttagcompound.getList("Patterns", 10);

View file

@ -5,7 +5,7 @@
package net.minecraft.world.item;
import java.util.Collection;
@@ -96,7 +97,7 @@
@@ -95,7 +96,7 @@
}
private static <T extends Comparable<T>> IBlockData cycleState(IBlockData iblockdata, IBlockState<T> iblockstate, boolean flag) {

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/world/item/ItemRecord.java
+++ b/net/minecraft/world/item/ItemRecord.java
@@ -41,6 +41,7 @@
@@ -43,6 +43,7 @@
ItemStack itemstack = itemactioncontext.getItemInHand();
if (!world.isClientSide) {

View file

@ -1,17 +1,17 @@
--- a/net/minecraft/world/level/block/BlockJukeBox.java
+++ b/net/minecraft/world/level/block/BlockJukeBox.java
@@ -62,7 +62,13 @@
TileEntity tileentity = generatoraccess.getBlockEntity(blockposition);
@@ -67,7 +67,13 @@
if (tileentity instanceof TileEntityJukeBox) {
- ((TileEntityJukeBox) tileentity).setRecord(itemstack.copy());
TileEntityJukeBox tileentityjukebox = (TileEntityJukeBox) tileentity;
- tileentityjukebox.setRecord(itemstack.copy());
+ // CraftBukkit start - There can only be one
+ itemstack = itemstack.copy();
+ if (!itemstack.isEmpty()) {
+ itemstack.setCount(1);
+ }
+ ((TileEntityJukeBox) tileentity).setRecord(itemstack);
+ tileentityjukebox.setRecord(itemstack);
+ // CraftBukkit end
tileentityjukebox.playRecord();
generatoraccess.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockJukeBox.HAS_RECORD, true), 2);
generatoraccess.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(entity, iblockdata));
}

View file

@ -1,11 +0,0 @@
--- a/net/minecraft/world/level/block/entity/TileEntityEnderChest.java
+++ b/net/minecraft/world/level/block/entity/TileEntityEnderChest.java
@@ -11,7 +11,7 @@
public class TileEntityEnderChest extends TileEntity implements LidBlockEntity {
private final ChestLidController chestLidController = new ChestLidController();
- private final ContainerOpenersCounter openersCounter = new ContainerOpenersCounter() {
+ public final ContainerOpenersCounter openersCounter = new ContainerOpenersCounter() {
@Override
protected void onOpen(World world, BlockPosition blockposition, IBlockData iblockdata) {
world.playSound((EntityHuman) null, (double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D, SoundEffects.ENDER_CHEST_OPEN, SoundCategory.BLOCKS, 0.5F, world.random.nextFloat() * 0.1F + 0.9F);

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/chunk/ChunkGenerator.java
+++ b/net/minecraft/world/level/chunk/ChunkGenerator.java
@@ -414,7 +414,7 @@
@@ -417,7 +417,7 @@
}
}
@ -9,7 +9,7 @@
ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos();
if (!SharedConstants.debugVoidTerrain(chunkcoordintpair)) {
@@ -436,7 +436,7 @@
@@ -439,7 +439,7 @@
for (int k = 0; k < j; ++k) {
ChunkSection chunksection = achunksection[k];
@ -18,7 +18,7 @@
Objects.requireNonNull(set);
palettedcontainerro.getAll(set::add);
@@ -462,7 +462,7 @@
@@ -465,7 +465,7 @@
Structure structure = (Structure) iterator.next();
seededrandom.setFeatureSeed(i, i1, l);
@ -27,7 +27,7 @@
Optional optional = iregistry.getResourceKey(structure).map(Object::toString);
Objects.requireNonNull(structure);
@@ -547,6 +547,33 @@
@@ -550,6 +550,33 @@
}
}

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.java
+++ b/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.java
@@ -50,6 +50,12 @@
@@ -51,6 +51,12 @@
import net.minecraft.world.phys.shapes.VoxelShapeBitSet;
import net.minecraft.world.phys.shapes.VoxelShapeDiscrete;
@ -13,7 +13,7 @@
public class DefinedStructure {
public static final String PALETTE_TAG = "palette";
@@ -69,6 +75,11 @@
@@ -70,6 +76,11 @@
private BaseBlockPosition size;
private String author;
@ -25,7 +25,7 @@
public DefinedStructure() {
this.size = BaseBlockPosition.ZERO;
this.author = "?";
@@ -142,7 +153,7 @@
@@ -143,7 +154,7 @@
}
private static List<DefinedStructure.BlockInfo> buildInfoList(List<DefinedStructure.BlockInfo> list, List<DefinedStructure.BlockInfo> list1, List<DefinedStructure.BlockInfo> list2) {
@ -34,7 +34,7 @@
return definedstructure_blockinfo.pos.getY();
}).thenComparingInt((definedstructure_blockinfo) -> {
return definedstructure_blockinfo.pos.getX();
@@ -463,11 +474,13 @@
@@ -464,11 +475,13 @@
}
private static Optional<Entity> createEntityIgnoreException(WorldAccess worldaccess, NBTTagCompound nbttagcompound) {
@ -52,7 +52,7 @@
}
public BaseBlockPosition getSize(EnumBlockRotation enumblockrotation) {
@@ -682,6 +695,13 @@
@@ -683,6 +696,13 @@
nbttagcompound.put("entities", nbttaglist3);
nbttagcompound.put("size", this.newIntegerList(this.size.getX(), this.size.getY(), this.size.getZ()));
nbttagcompound.putInt("DataVersion", SharedConstants.getCurrentVersion().getWorldVersion());
@ -66,7 +66,7 @@
return nbttagcompound;
}
@@ -721,6 +741,12 @@
@@ -722,6 +742,12 @@
}
}
@ -79,7 +79,7 @@
}
private void loadPalette(NBTTagList nbttaglist, NBTTagList nbttaglist1) {
@@ -860,7 +886,7 @@
@@ -861,7 +887,7 @@
public IBlockData stateFor(int i) {
IBlockData iblockdata = (IBlockData) this.ids.byId(i);

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/redstone/NeighborUpdater.java
+++ b/net/minecraft/world/level/redstone/NeighborUpdater.java
@@ -11,6 +11,13 @@
@@ -12,6 +12,13 @@
import net.minecraft.world.level.World;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.IBlockData;
@ -14,7 +14,7 @@
public interface NeighborUpdater {
@@ -45,6 +52,17 @@
@@ -46,6 +53,17 @@
static void executeUpdate(World world, IBlockData iblockdata, BlockPosition blockposition, Block block, BlockPosition blockposition1, boolean flag) {
try {

View file

@ -4,7 +4,7 @@
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<packaging>jar</packaging>
<version>1.19-R0.1-SNAPSHOT</version>
<version>1.19.1-R0.1-SNAPSHOT</version>
<name>CraftBukkit</name>
<url>https://www.spigotmc.org/</url>
@ -67,7 +67,7 @@
<dependency>
<groupId>com.mojang</groupId>
<artifactId>authlib</artifactId>
<version>3.5.41</version>
<version>3.11.49</version>
<scope>compile</scope>
</dependency>
<dependency>

View file

@ -381,7 +381,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
public void chat(String msg) {
if (getHandle().connection == null) return;
getHandle().connection.chat(msg, false);
getHandle().connection.chat(msg, null, false);
}
@Override

View file

@ -237,7 +237,7 @@ public final class CraftMagicNumbers implements UnsafeValues {
* @return string
*/
public String getMappingsVersion() {
return "7b9de0da1357e5b251eddde9aa762916";
return "4cc0cc97cac491651bff3af8b124a214";
}
@Override