mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-09 08:32:07 -07:00
@@ -1,23 +1,18 @@
|
||||
--- a/net/minecraft/server/AdvancementDataPlayer.java
|
||||
+++ b/net/minecraft/server/AdvancementDataPlayer.java
|
||||
@@ -144,7 +144,11 @@
|
||||
Advancement advancement = advancementdataworld.getAdvancement((MinecraftKey) entry.getKey());
|
||||
@@ -197,6 +197,7 @@
|
||||
AdvancementHolder advancementholder = advancementdataworld.get(minecraftkey);
|
||||
|
||||
if (advancement == null) {
|
||||
- AdvancementDataPlayer.LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", entry.getKey(), this.playerSavePath);
|
||||
+ // CraftBukkit start
|
||||
+ if (entry.getKey().getNamespace().equals("minecraft")) {
|
||||
+ AdvancementDataPlayer.LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", entry.getKey(), this.playerSavePath);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
} else {
|
||||
this.startProgress(advancement, (AdvancementProgress) entry.getValue());
|
||||
this.progressChanged.add(advancement);
|
||||
@@ -227,6 +231,7 @@
|
||||
this.progressChanged.add(advancement);
|
||||
if (advancementholder == null) {
|
||||
+ if (!minecraftkey.getNamespace().equals("minecraft")) return; // CraftBukkit
|
||||
AdvancementDataPlayer.LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", minecraftkey, this.playerSavePath);
|
||||
} else {
|
||||
this.startProgress(advancementholder, advancementprogress);
|
||||
@@ -228,6 +229,7 @@
|
||||
this.progressChanged.add(advancementholder);
|
||||
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()), false);
|
||||
+ this.player.level().getCraftServer().getPluginManager().callEvent(new org.bukkit.event.player.PlayerAdvancementDoneEvent(this.player.getBukkitEntity(), advancementholder.toBukkit())); // CraftBukkit
|
||||
advancementholder.value().rewards().grant(this.player);
|
||||
advancementholder.value().display().ifPresent((advancementdisplay) -> {
|
||||
if (advancementdisplay.shouldAnnounceChat() && this.player.level().getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) {
|
||||
|
@@ -4,4 +4,4 @@
|
||||
+// mc-dev import
|
||||
package net.minecraft.server;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/CustomFunctionData.java
|
||||
+++ b/net/minecraft/server/CustomFunctionData.java
|
||||
@@ -43,7 +43,7 @@
|
||||
@@ -45,7 +45,7 @@
|
||||
}
|
||||
|
||||
public CommandDispatcher<CommandListenerWrapper> getDispatcher() {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/Main.java
|
||||
+++ b/net/minecraft/server/Main.java
|
||||
@@ -64,6 +64,16 @@
|
||||
@@ -61,6 +61,17 @@
|
||||
import net.minecraft.world.level.storage.WorldInfo;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@@ -11,13 +11,14 @@
|
||||
+import net.minecraft.SharedConstants;
|
||||
+import net.minecraft.server.packs.EnumResourcePackType;
|
||||
+import net.minecraft.world.level.dimension.WorldDimension;
|
||||
+import net.minecraft.world.level.storage.SavedFile;
|
||||
+import org.bukkit.configuration.file.YamlConfiguration;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class Main {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -71,8 +81,9 @@
|
||||
@@ -68,8 +79,9 @@
|
||||
public Main() {}
|
||||
|
||||
@DontObfuscate
|
||||
@@ -28,7 +29,7 @@
|
||||
OptionParser optionparser = new OptionParser();
|
||||
OptionSpec<Void> optionspec = optionparser.accepts("nogui");
|
||||
OptionSpec<Void> optionspec1 = optionparser.accepts("initSettings", "Initializes 'server.properties' and 'eula.txt', then quits");
|
||||
@@ -98,15 +109,18 @@
|
||||
@@ -94,15 +106,18 @@
|
||||
optionparser.printHelpOn(System.err);
|
||||
return;
|
||||
}
|
||||
@@ -36,7 +37,7 @@
|
||||
+
|
||||
+ try {
|
||||
|
||||
- Path path = (Path) optionset.valueOf(optionspec14);
|
||||
- Path path = (Path) optionset.valueOf(optionspec13);
|
||||
+ Path path = (Path) optionset.valueOf("pidFile"); // CraftBukkit
|
||||
|
||||
if (path != null) {
|
||||
@@ -44,12 +45,12 @@
|
||||
}
|
||||
|
||||
CrashReport.preload();
|
||||
- if (optionset.has(optionspec13)) {
|
||||
- if (optionset.has(optionspec12)) {
|
||||
+ if (optionset.has("jfrProfile")) { // CraftBukkit
|
||||
JvmProfiler.INSTANCE.start(Environment.SERVER);
|
||||
}
|
||||
|
||||
@@ -114,13 +128,26 @@
|
||||
@@ -110,13 +125,26 @@
|
||||
DispenserRegistry.validate();
|
||||
SystemUtils.startTimerHackThread();
|
||||
Path path1 = Paths.get("server.properties");
|
||||
@@ -78,14 +79,14 @@
|
||||
Main.LOGGER.info("Initialized '{}' and '{}'", path1.toAbsolutePath(), path2.toAbsolutePath());
|
||||
return;
|
||||
}
|
||||
@@ -130,11 +157,12 @@
|
||||
@@ -126,11 +154,12 @@
|
||||
return;
|
||||
}
|
||||
|
||||
- File file = new File((String) optionset.valueOf(optionspec9));
|
||||
- File file = new File((String) optionset.valueOf(optionspec8));
|
||||
+ File file = (File) optionset.valueOf("universe"); // CraftBukkit
|
||||
Services services = Services.create(new YggdrasilAuthenticationService(Proxy.NO_PROXY), file);
|
||||
- String s = (String) Optional.ofNullable((String) optionset.valueOf(optionspec10)).orElse(dedicatedserversettings.getProperties().levelName);
|
||||
- String s = (String) Optional.ofNullable((String) optionset.valueOf(optionspec9)).orElse(dedicatedserversettings.getProperties().levelName);
|
||||
+ // CraftBukkit start
|
||||
+ String s = (String) Optional.ofNullable((String) optionset.valueOf("world")).orElse(dedicatedserversettings.getProperties().levelName);
|
||||
Convertable convertable = Convertable.createDefault(file.toPath());
|
||||
@@ -94,7 +95,7 @@
|
||||
WorldInfo worldinfo = convertable_conversionsession.getSummary();
|
||||
|
||||
if (worldinfo != null) {
|
||||
@@ -149,13 +177,31 @@
|
||||
@@ -145,13 +174,31 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +106,7 @@
|
||||
Main.LOGGER.warn("Safe mode active, only vanilla datapack will be loaded");
|
||||
}
|
||||
|
||||
ResourcePackRepository resourcepackrepository = ResourcePackSourceVanilla.createPackRepository(convertable_conversionsession.getLevelPath(SavedFile.DATAPACK_DIR));
|
||||
ResourcePackRepository resourcepackrepository = ResourcePackSourceVanilla.createPackRepository(convertable_conversionsession);
|
||||
+ // CraftBukkit start
|
||||
+ File bukkitDataPackFolder = new File(convertable_conversionsession.getLevelPath(SavedFile.DATAPACK_DIR).toFile(), "bukkit");
|
||||
+ if (!bukkitDataPackFolder.exists()) {
|
||||
@@ -127,7 +128,7 @@
|
||||
|
||||
WorldStem worldstem;
|
||||
|
||||
@@ -164,6 +210,7 @@
|
||||
@@ -160,6 +207,7 @@
|
||||
|
||||
worldstem = (WorldStem) SystemUtils.blockUntilDone((executor) -> {
|
||||
return WorldLoader.load(worldloader_c, (worldloader_a) -> {
|
||||
@@ -135,7 +136,7 @@
|
||||
IRegistry<WorldDimension> iregistry = worldloader_a.datapackDimensions().registryOrThrow(Registries.LEVEL_STEM);
|
||||
DynamicOps<NBTBase> dynamicops = RegistryOps.create(DynamicOpsNBT.INSTANCE, (HolderLookup.b) worldloader_a.datapackWorldgen());
|
||||
Pair<SaveData, WorldDimensions.b> pair = convertable_conversionsession.getDataTag(dynamicops, worldloader_a.dataConfiguration(), iregistry, worldloader_a.datapackWorldgen().allRegistriesLifecycle());
|
||||
@@ -175,7 +222,7 @@
|
||||
@@ -171,7 +219,7 @@
|
||||
WorldOptions worldoptions;
|
||||
WorldDimensions worlddimensions;
|
||||
|
||||
@@ -144,7 +145,7 @@
|
||||
worldsettings = MinecraftServer.DEMO_SETTINGS;
|
||||
worldoptions = WorldOptions.DEMO_OPTIONS;
|
||||
worlddimensions = WorldPresets.createNormalWorldDimensions(worldloader_a.datapackWorldgen());
|
||||
@@ -183,7 +230,7 @@
|
||||
@@ -179,7 +227,7 @@
|
||||
DedicatedServerProperties dedicatedserverproperties = dedicatedserversettings.getProperties();
|
||||
|
||||
worldsettings = new WorldSettings(dedicatedserverproperties.levelName, dedicatedserverproperties.gamemode, dedicatedserverproperties.hardcore, dedicatedserverproperties.difficulty, false, new GameRules(), worldloader_a.dataConfiguration());
|
||||
@@ -153,7 +154,7 @@
|
||||
worlddimensions = dedicatedserverproperties.createDimensions(worldloader_a.datapackWorldgen());
|
||||
}
|
||||
|
||||
@@ -199,6 +246,7 @@
|
||||
@@ -195,6 +243,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -161,7 +162,7 @@
|
||||
IRegistryCustom.Dimension iregistrycustom_dimension = worldstem.registries().compositeAccess();
|
||||
|
||||
if (optionset.has(optionspec4)) {
|
||||
@@ -210,21 +258,32 @@
|
||||
@@ -206,20 +255,31 @@
|
||||
SaveData savedata = worldstem.worldData();
|
||||
|
||||
convertable_conversionsession.saveDataTag(iregistrycustom_dimension, savedata);
|
||||
@@ -171,10 +172,9 @@
|
||||
+ DedicatedServer dedicatedserver1 = new DedicatedServer(optionset, worldLoader.get(), thread, convertable_conversionsession, resourcepackrepository, worldstem, dedicatedserversettings, DataConverterRegistry.getDataFixer(), services, WorldLoadListenerLogger::new);
|
||||
|
||||
+ /*
|
||||
dedicatedserver1.setSingleplayerProfile(optionset.has(optionspec8) ? new GameProfile((UUID) null, (String) optionset.valueOf(optionspec8)) : null);
|
||||
dedicatedserver1.setPort((Integer) optionset.valueOf(optionspec11));
|
||||
dedicatedserver1.setPort((Integer) optionset.valueOf(optionspec10));
|
||||
dedicatedserver1.setDemo(optionset.has(optionspec2));
|
||||
dedicatedserver1.setId((String) optionset.valueOf(optionspec12));
|
||||
dedicatedserver1.setId((String) optionset.valueOf(optionspec11));
|
||||
- boolean flag1 = !optionset.has(optionspec) && !optionset.valuesOf(nonoptionargumentspec).contains("nogui");
|
||||
+ */
|
||||
+ boolean flag1 = !optionset.has("nogui") && !optionset.nonOptionArguments().contains("nogui");
|
||||
@@ -196,7 +196,7 @@
|
||||
Thread thread = new Thread("Server Shutdown Thread") {
|
||||
public void run() {
|
||||
dedicatedserver.halt(true);
|
||||
@@ -233,6 +292,7 @@
|
||||
@@ -228,6 +288,7 @@
|
||||
|
||||
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(Main.LOGGER));
|
||||
Runtime.getRuntime().addShutdownHook(thread);
|
||||
@@ -204,7 +204,7 @@
|
||||
} catch (Exception exception1) {
|
||||
Main.LOGGER.error(LogUtils.FATAL_MARKER, "Failed to start the minecraft server", exception1);
|
||||
}
|
||||
@@ -268,7 +328,7 @@
|
||||
@@ -263,7 +324,7 @@
|
||||
}
|
||||
|
||||
public static void forceUpgrade(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, boolean flag, BooleanSupplier booleansupplier, IRegistry<WorldDimension> iregistry) {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -164,6 +164,33 @@
|
||||
@@ -163,6 +163,30 @@
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@@ -25,16 +25,13 @@
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.craftbukkit.CraftServer;
|
||||
+import org.bukkit.craftbukkit.Main;
|
||||
+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 abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTask> implements ServerInfo, ICommandListener, AutoCloseable {
|
||||
|
||||
public static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -249,6 +276,19 @@
|
||||
@@ -247,6 +271,19 @@
|
||||
protected SaveData worldData;
|
||||
private volatile boolean isSaving;
|
||||
|
||||
@@ -54,7 +51,7 @@
|
||||
public static <S extends MinecraftServer> S spin(Function<Thread, S> function) {
|
||||
AtomicReference<S> atomicreference = new AtomicReference();
|
||||
Thread thread = new Thread(() -> {
|
||||
@@ -262,14 +302,14 @@
|
||||
@@ -260,14 +297,14 @@
|
||||
thread.setPriority(8);
|
||||
}
|
||||
|
||||
@@ -71,8 +68,8 @@
|
||||
super("Server");
|
||||
this.metricsRecorder = InactiveMetricsRecorder.INSTANCE;
|
||||
this.profiler = this.metricsRecorder.getProfiler();
|
||||
@@ -289,7 +329,7 @@
|
||||
this.frameTimer = new CircularTimer();
|
||||
@@ -286,7 +323,7 @@
|
||||
this.customBossEvents = new BossBattleCustomData();
|
||||
this.registries = worldstem.registries();
|
||||
this.worldData = worldstem.worldData();
|
||||
- if (!this.registries.compositeAccess().registryOrThrow(Registries.LEVEL_STEM).containsKey(WorldDimension.OVERWORLD)) {
|
||||
@@ -80,7 +77,7 @@
|
||||
throw new IllegalStateException("Missing Overworld dimension data");
|
||||
} else {
|
||||
this.proxy = proxy;
|
||||
@@ -312,13 +352,40 @@
|
||||
@@ -309,6 +346,33 @@
|
||||
this.serverThread = thread;
|
||||
this.executor = SystemUtils.backgroundExecutor();
|
||||
}
|
||||
@@ -110,19 +107,11 @@
|
||||
+ }
|
||||
+ }
|
||||
+ Runtime.getRuntime().addShutdownHook(new org.bukkit.craftbukkit.util.ServerShutdownThread(this));
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
|
||||
private void readScoreboard(WorldPersistentData worldpersistentdata) {
|
||||
ScoreboardServer scoreboardserver = this.getScoreboard();
|
||||
|
||||
Objects.requireNonNull(scoreboardserver);
|
||||
- Function function = scoreboardserver::createData;
|
||||
+ Function<net.minecraft.nbt.NBTTagCompound, net.minecraft.world.scores.PersistentScoreboard> function = scoreboardserver::createData; // CraftBukkit - decompile error
|
||||
ScoreboardServer scoreboardserver1 = this.getScoreboard();
|
||||
|
||||
Objects.requireNonNull(scoreboardserver1);
|
||||
@@ -327,7 +394,7 @@
|
||||
@@ -317,7 +381,7 @@
|
||||
|
||||
protected abstract boolean initServer() throws IOException;
|
||||
|
||||
@@ -131,7 +120,7 @@
|
||||
if (!JvmProfiler.INSTANCE.isRunning()) {
|
||||
;
|
||||
}
|
||||
@@ -335,12 +402,8 @@
|
||||
@@ -325,12 +389,8 @@
|
||||
boolean flag = false;
|
||||
ProfiledDuration profiledduration = JvmProfiler.INSTANCE.onWorldLoadedStarted();
|
||||
|
||||
@@ -145,11 +134,20 @@
|
||||
if (profiledduration != null) {
|
||||
profiledduration.finish();
|
||||
}
|
||||
@@ -355,25 +418,183 @@
|
||||
@@ -347,23 +407,179 @@
|
||||
|
||||
}
|
||||
protected void forceDifficulty() {}
|
||||
|
||||
- protected void forceDifficulty() {}
|
||||
- protected void createLevels(WorldLoadListener worldloadlistener) {
|
||||
- IWorldDataServer iworlddataserver = this.worldData.overworldData();
|
||||
- boolean flag = this.worldData.isDebugWorld();
|
||||
- IRegistry<WorldDimension> iregistry = this.registries.compositeAccess().registryOrThrow(Registries.LEVEL_STEM);
|
||||
- WorldOptions worldoptions = this.worldData.worldGenOptions();
|
||||
- long i = worldoptions.seed();
|
||||
- long j = BiomeManager.obfuscateSeed(i);
|
||||
- List<MobSpawner> list = ImmutableList.of(new MobSpawnerPhantom(), new MobSpawnerPatrol(), new MobSpawnerCat(), new VillageSiege(), new MobSpawnerTrader(iworlddataserver));
|
||||
- WorldDimension worlddimension = (WorldDimension) iregistry.get(WorldDimension.OVERWORLD);
|
||||
- WorldServer worldserver = new WorldServer(this, this.executor, this.storageSource, iworlddataserver, World.OVERWORLD, worlddimension, worldloadlistener, flag, j, list, true, (RandomSequences) null);
|
||||
+ // CraftBukkit start
|
||||
+ private void loadWorld0(String s) {
|
||||
+ Convertable.ConversionSession worldSession = this.storageSource;
|
||||
@@ -176,17 +174,7 @@
|
||||
+ } else if (dimensionKey != WorldDimension.OVERWORLD) {
|
||||
+ dimension = -999;
|
||||
+ }
|
||||
|
||||
- protected void createLevels(WorldLoadListener worldloadlistener) {
|
||||
- IWorldDataServer iworlddataserver = this.worldData.overworldData();
|
||||
- boolean flag = this.worldData.isDebugWorld();
|
||||
- IRegistry<WorldDimension> iregistry = this.registries.compositeAccess().registryOrThrow(Registries.LEVEL_STEM);
|
||||
- WorldOptions worldoptions = this.worldData.worldGenOptions();
|
||||
- long i = worldoptions.seed();
|
||||
- long j = BiomeManager.obfuscateSeed(i);
|
||||
- List<MobSpawner> list = ImmutableList.of(new MobSpawnerPhantom(), new MobSpawnerPatrol(), new MobSpawnerCat(), new VillageSiege(), new MobSpawnerTrader(iworlddataserver));
|
||||
- WorldDimension worlddimension = (WorldDimension) iregistry.get(WorldDimension.OVERWORLD);
|
||||
- WorldServer worldserver = new WorldServer(this, this.executor, this.storageSource, iworlddataserver, World.OVERWORLD, worlddimension, worldloadlistener, flag, j, list, true, (RandomSequences) null);
|
||||
+
|
||||
+ String worldType = (dimension == -999) ? dimensionKey.location().getNamespace() + "_" + dimensionKey.location().getPath() : org.bukkit.World.Environment.getEnvironment(dimension).toString().toLowerCase();
|
||||
+ String name = (dimensionKey == WorldDimension.OVERWORLD) ? s : s + "_" + worldType;
|
||||
+ if (dimension != 0) {
|
||||
@@ -230,10 +218,14 @@
|
||||
+ throw new RuntimeException(ex);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
|
||||
- this.levels.put(World.OVERWORLD, worldserver);
|
||||
- WorldPersistentData worldpersistentdata = worldserver.getDataStorage();
|
||||
+ org.bukkit.generator.ChunkGenerator gen = this.server.getGenerator(name);
|
||||
+ org.bukkit.generator.BiomeProvider biomeProvider = this.server.getBiomeProvider(name);
|
||||
+
|
||||
|
||||
- this.readScoreboard(worldpersistentdata);
|
||||
- this.commandStorage = new PersistentCommandStorage(worldpersistentdata);
|
||||
+ WorldDataServer worlddata;
|
||||
+ WorldLoader.a worldloader_a = this.worldLoader;
|
||||
+ IRegistry<WorldDimension> iregistry = worldloader_a.datapackDimensions().registryOrThrow(Registries.LEVEL_STEM);
|
||||
@@ -289,13 +281,9 @@
|
||||
+ if (dimensionKey == WorldDimension.OVERWORLD) {
|
||||
+ this.worldData = worlddata;
|
||||
+ this.worldData.setGameType(((DedicatedServer) this).getProperties().gamemode); // From DedicatedServer.init
|
||||
|
||||
- this.levels.put(World.OVERWORLD, worldserver);
|
||||
- WorldPersistentData worldpersistentdata = worldserver.getDataStorage();
|
||||
+
|
||||
+ WorldLoadListener worldloadlistener = this.progressListenerFactory.create(11);
|
||||
|
||||
- this.readScoreboard(worldpersistentdata);
|
||||
- this.commandStorage = new PersistentCommandStorage(worldpersistentdata);
|
||||
+
|
||||
+ world = new WorldServer(this, this.executor, worldSession, iworlddataserver, worldKey, worlddimension, worldloadlistener, flag, j, list, true, (RandomSequences) null, org.bukkit.World.Environment.getEnvironment(dimension), gen, biomeProvider);
|
||||
+ WorldPersistentData worldpersistentdata = world.getDataStorage();
|
||||
+ this.readScoreboard(worldpersistentdata);
|
||||
@@ -327,11 +315,7 @@
|
||||
+ this.server.getPluginManager().callEvent(new ServerLoadEvent(ServerLoadEvent.LoadType.STARTUP));
|
||||
+ this.connection.acceptConnections();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
+ protected void forceDifficulty() {}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ public void initWorld(WorldServer worldserver, IWorldDataServer iworlddataserver, SaveData saveData, WorldOptions worldoptions) {
|
||||
+ boolean flag = saveData.isDebugWorld();
|
||||
+ // CraftBukkit start
|
||||
@@ -344,7 +328,7 @@
|
||||
|
||||
if (!iworlddataserver.isInitialized()) {
|
||||
try {
|
||||
@@ -397,30 +618,8 @@
|
||||
@@ -387,30 +603,8 @@
|
||||
iworlddataserver.setInitialized(true);
|
||||
}
|
||||
|
||||
@@ -376,7 +360,7 @@
|
||||
|
||||
private static void setInitialSpawn(WorldServer worldserver, IWorldDataServer iworlddataserver, boolean flag, boolean flag1) {
|
||||
if (flag1) {
|
||||
@@ -428,6 +627,21 @@
|
||||
@@ -418,6 +612,21 @@
|
||||
} else {
|
||||
ChunkProviderServer chunkproviderserver = worldserver.getChunkSource();
|
||||
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(chunkproviderserver.randomState().sampler().findSpawnPosition());
|
||||
@@ -398,7 +382,7 @@
|
||||
int i = chunkproviderserver.getGenerator().getSpawnHeight(worldserver);
|
||||
|
||||
if (i < worldserver.getMinBuildHeight()) {
|
||||
@@ -487,8 +701,11 @@
|
||||
@@ -477,8 +686,11 @@
|
||||
iworlddataserver.setGameType(EnumGamemode.SPECTATOR);
|
||||
}
|
||||
|
||||
@@ -412,7 +396,7 @@
|
||||
|
||||
MinecraftServer.LOGGER.info("Preparing start region for dimension {}", worldserver.dimension().location());
|
||||
BlockPosition blockposition = worldserver.getSharedSpawnPos();
|
||||
@@ -497,19 +714,23 @@
|
||||
@@ -487,19 +699,23 @@
|
||||
ChunkProviderServer chunkproviderserver = worldserver.getChunkSource();
|
||||
|
||||
this.nextTickTime = SystemUtils.getMillis();
|
||||
@@ -442,10 +426,10 @@
|
||||
+ if (true) {
|
||||
+ WorldServer worldserver1 = worldserver;
|
||||
+ // CraftBukkit end
|
||||
ForcedChunk forcedchunk = (ForcedChunk) worldserver1.getDataStorage().get(ForcedChunk::load, "chunks");
|
||||
ForcedChunk forcedchunk = (ForcedChunk) worldserver1.getDataStorage().get(ForcedChunk.factory(), "chunks");
|
||||
|
||||
if (forcedchunk != null) {
|
||||
@@ -524,10 +745,17 @@
|
||||
@@ -514,10 +730,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -466,7 +450,7 @@
|
||||
}
|
||||
|
||||
public EnumGamemode getDefaultGameType() {
|
||||
@@ -557,12 +785,16 @@
|
||||
@@ -547,12 +770,16 @@
|
||||
worldserver.save((IProgressUpdate) null, flag1, worldserver.noSave && !flag2);
|
||||
}
|
||||
|
||||
@@ -483,7 +467,7 @@
|
||||
if (flag1) {
|
||||
Iterator iterator1 = this.getAllLevels().iterator();
|
||||
|
||||
@@ -597,12 +829,33 @@
|
||||
@@ -587,18 +814,40 @@
|
||||
this.stopServer();
|
||||
}
|
||||
|
||||
@@ -514,10 +498,9 @@
|
||||
+ this.server.disablePlugins();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (this.getConnection() != null) {
|
||||
this.getConnection().stop();
|
||||
}
|
||||
@@ -612,6 +865,7 @@
|
||||
this.getConnection().stop();
|
||||
this.isSaving = true;
|
||||
if (this.playerList != null) {
|
||||
MinecraftServer.LOGGER.info("Saving players");
|
||||
this.playerList.saveAll();
|
||||
this.playerList.removeAll();
|
||||
@@ -525,7 +508,7 @@
|
||||
}
|
||||
|
||||
MinecraftServer.LOGGER.info("Saving worlds");
|
||||
@@ -699,15 +953,16 @@
|
||||
@@ -686,15 +935,16 @@
|
||||
}
|
||||
|
||||
this.nextTickTime = SystemUtils.getMillis();
|
||||
@@ -544,7 +527,7 @@
|
||||
MinecraftServer.LOGGER.warn("Can't keep up! Is the server overloaded? Running {}ms or {} ticks behind", i, j);
|
||||
this.nextTickTime += j * 50L;
|
||||
this.lastOverloadWarning = this.nextTickTime;
|
||||
@@ -718,6 +973,7 @@
|
||||
@@ -705,6 +955,7 @@
|
||||
this.debugCommandProfiler = new MinecraftServer.TimeProfiler(SystemUtils.getNanos(), this.tickCount);
|
||||
}
|
||||
|
||||
@@ -552,7 +535,7 @@
|
||||
this.nextTickTime += 50L;
|
||||
this.startMetricsRecordingTick();
|
||||
this.profiler.push("tick");
|
||||
@@ -756,6 +1012,12 @@
|
||||
@@ -743,6 +994,12 @@
|
||||
this.services.profileCache().clearExecutor();
|
||||
}
|
||||
|
||||
@@ -565,25 +548,23 @@
|
||||
this.onServerExit();
|
||||
}
|
||||
|
||||
@@ -789,9 +1051,16 @@
|
||||
@@ -776,7 +1033,14 @@
|
||||
}
|
||||
|
||||
private boolean haveTime() {
|
||||
- return this.runningTask() || SystemUtils.getMillis() < (this.mayHaveDelayedTasks ? this.delayedTasksMaxNextTickTime : this.nextTickTime);
|
||||
+ // CraftBukkit start
|
||||
+ return this.forceTicks || this.runningTask() || SystemUtils.getMillis() < (this.mayHaveDelayedTasks ? this.delayedTasksMaxNextTickTime : this.nextTickTime);
|
||||
}
|
||||
|
||||
+ }
|
||||
+
|
||||
+ private void executeModerately() {
|
||||
+ this.runAllTasks();
|
||||
+ java.util.concurrent.locks.LockSupport.parkNanos("executing tasks", 1000L);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
protected void waitUntilNextTick() {
|
||||
this.runAllTasks();
|
||||
this.managedBlock(() -> {
|
||||
@@ -836,7 +1105,7 @@
|
||||
@@ -823,7 +1087,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -592,7 +573,7 @@
|
||||
this.getProfiler().incrementCounter("runTask");
|
||||
super.doRunTask(ticktask);
|
||||
}
|
||||
@@ -889,7 +1158,7 @@
|
||||
@@ -876,7 +1140,7 @@
|
||||
this.status = this.buildServerStatus();
|
||||
}
|
||||
|
||||
@@ -601,10 +582,10 @@
|
||||
MinecraftServer.LOGGER.debug("Autosave started");
|
||||
this.profiler.push("save");
|
||||
this.saveEverything(true, false, false);
|
||||
@@ -936,22 +1205,39 @@
|
||||
}
|
||||
|
||||
public void tickChildren(BooleanSupplier booleansupplier) {
|
||||
@@ -928,22 +1192,39 @@
|
||||
this.getPlayerList().getPlayers().forEach((entityplayer) -> {
|
||||
entityplayer.connection.suspendFlushing();
|
||||
});
|
||||
+ this.server.getScheduler().mainThreadHeartbeat(this.tickCount); // CraftBukkit
|
||||
this.profiler.push("commandFunctions");
|
||||
this.getFunctions().tick();
|
||||
@@ -641,7 +622,7 @@
|
||||
|
||||
this.profiler.push("tick");
|
||||
|
||||
@@ -1031,6 +1317,22 @@
|
||||
@@ -1033,6 +1314,22 @@
|
||||
return (WorldServer) this.levels.get(resourcekey);
|
||||
}
|
||||
|
||||
@@ -664,7 +645,7 @@
|
||||
public Set<ResourceKey<World>> levelKeys() {
|
||||
return this.levels.keySet();
|
||||
}
|
||||
@@ -1057,7 +1359,7 @@
|
||||
@@ -1062,7 +1359,7 @@
|
||||
|
||||
@DontObfuscate
|
||||
public String getServerModName() {
|
||||
@@ -673,7 +654,7 @@
|
||||
}
|
||||
|
||||
public SystemReport fillSystemReport(SystemReport systemreport) {
|
||||
@@ -1398,11 +1700,11 @@
|
||||
@@ -1403,11 +1700,11 @@
|
||||
public CompletableFuture<Void> reloadResources(Collection<String> collection) {
|
||||
IRegistryCustom.Dimension iregistrycustom_dimension = this.registries.getAccessForLoading(RegistryLayer.RELOADABLE);
|
||||
CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> {
|
||||
@@ -687,7 +668,7 @@
|
||||
}, this).thenCompose((immutablelist) -> {
|
||||
ResourceManager resourcemanager = new ResourceManager(EnumResourcePackType.SERVER_DATA, immutablelist);
|
||||
|
||||
@@ -1417,6 +1719,7 @@
|
||||
@@ -1422,6 +1719,7 @@
|
||||
}).thenAcceptAsync((minecraftserver_reloadableresources) -> {
|
||||
this.resources.close();
|
||||
this.resources = minecraftserver_reloadableresources;
|
||||
@@ -695,7 +676,7 @@
|
||||
this.packRepository.setSelected(collection);
|
||||
WorldDataConfiguration worlddataconfiguration = new WorldDataConfiguration(getSelectedPacks(this.packRepository), this.worldData.enabledFeatures());
|
||||
|
||||
@@ -1777,7 +2080,7 @@
|
||||
@@ -1778,7 +2076,7 @@
|
||||
try {
|
||||
label51:
|
||||
{
|
||||
@@ -704,7 +685,7 @@
|
||||
|
||||
try {
|
||||
arraylist = Lists.newArrayList(NativeModuleLister.listModules());
|
||||
@@ -1827,6 +2130,22 @@
|
||||
@@ -1828,6 +2126,22 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -727,35 +708,15 @@
|
||||
private void startMetricsRecordingTick() {
|
||||
if (this.willStartRecordingMetrics) {
|
||||
this.metricsRecorder = ActiveMetricsRecorder.createStarted(new ServerMetricsSamplersProvider(SystemUtils.timeSource, this.isDedicatedServer()), SystemUtils.timeSource, SystemUtils.ioPool(), new MetricsPersister("server"), this.onMetricsRecordingStopped, (path) -> {
|
||||
@@ -1953,8 +2272,30 @@
|
||||
@@ -1954,6 +2268,11 @@
|
||||
|
||||
}
|
||||
|
||||
+ // 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());
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public ChatDecorator getChatDecorator() {
|
||||
- return ChatDecorator.PLAIN;
|
||||
+ return (entityplayer, ichatbasecomponent) -> {
|
||||
+ // SPIGOT-7127: Console /say and similar
|
||||
+ if (entityplayer == null) {
|
||||
+ return CompletableFuture.completedFuture(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
|
||||
return ChatDecorator.PLAIN;
|
||||
}
|
||||
|
||||
public static record ReloadableResources(IReloadableResourceManager resourceManager, DataPackResources managers) implements AutoCloseable {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/ScoreboardServer.java
|
||||
+++ b/net/minecraft/server/ScoreboardServer.java
|
||||
@@ -34,7 +34,7 @@
|
||||
@@ -37,7 +37,7 @@
|
||||
public void onScoreChanged(ScoreboardScore scoreboardscore) {
|
||||
super.onScoreChanged(scoreboardscore);
|
||||
if (this.trackedObjectives.contains(scoreboardscore.getObjective())) {
|
||||
@@ -9,7 +9,7 @@
|
||||
}
|
||||
|
||||
this.setDirty();
|
||||
@@ -43,7 +43,7 @@
|
||||
@@ -46,7 +46,7 @@
|
||||
@Override
|
||||
public void onPlayerRemoved(String s) {
|
||||
super.onPlayerRemoved(s);
|
||||
@@ -18,7 +18,7 @@
|
||||
this.setDirty();
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
@@ -54,7 +54,7 @@
|
||||
public void onPlayerScoreRemoved(String s, ScoreboardObjective scoreboardobjective) {
|
||||
super.onPlayerScoreRemoved(s, scoreboardobjective);
|
||||
if (this.trackedObjectives.contains(scoreboardobjective)) {
|
||||
@@ -27,25 +27,25 @@
|
||||
}
|
||||
|
||||
this.setDirty();
|
||||
@@ -64,7 +64,7 @@
|
||||
super.setDisplayObjective(i, scoreboardobjective);
|
||||
@@ -67,7 +67,7 @@
|
||||
super.setDisplayObjective(displayslot, scoreboardobjective);
|
||||
if (scoreboardobjective1 != scoreboardobjective && scoreboardobjective1 != null) {
|
||||
if (this.getObjectiveDisplaySlotCount(scoreboardobjective1) > 0) {
|
||||
- this.server.getPlayerList().broadcastAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective));
|
||||
+ this.broadcastAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective));
|
||||
- this.server.getPlayerList().broadcastAll(new PacketPlayOutScoreboardDisplayObjective(displayslot, scoreboardobjective));
|
||||
+ this.broadcastAll(new PacketPlayOutScoreboardDisplayObjective(displayslot, scoreboardobjective));
|
||||
} else {
|
||||
this.stopTrackingObjective(scoreboardobjective1);
|
||||
}
|
||||
@@ -72,7 +72,7 @@
|
||||
@@ -75,7 +75,7 @@
|
||||
|
||||
if (scoreboardobjective != null) {
|
||||
if (this.trackedObjectives.contains(scoreboardobjective)) {
|
||||
- this.server.getPlayerList().broadcastAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective));
|
||||
+ this.broadcastAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective));
|
||||
- this.server.getPlayerList().broadcastAll(new PacketPlayOutScoreboardDisplayObjective(displayslot, scoreboardobjective));
|
||||
+ this.broadcastAll(new PacketPlayOutScoreboardDisplayObjective(displayslot, scoreboardobjective));
|
||||
} else {
|
||||
this.startTrackingObjective(scoreboardobjective);
|
||||
}
|
||||
@@ -84,7 +84,7 @@
|
||||
@@ -87,7 +87,7 @@
|
||||
@Override
|
||||
public boolean addPlayerToTeam(String s, ScoreboardTeam scoreboardteam) {
|
||||
if (super.addPlayerToTeam(s, scoreboardteam)) {
|
||||
@@ -54,7 +54,7 @@
|
||||
this.setDirty();
|
||||
return true;
|
||||
} else {
|
||||
@@ -95,7 +95,7 @@
|
||||
@@ -98,7 +98,7 @@
|
||||
@Override
|
||||
public void removePlayerFromTeam(String s, ScoreboardTeam scoreboardteam) {
|
||||
super.removePlayerFromTeam(s, scoreboardteam);
|
||||
@@ -63,7 +63,7 @@
|
||||
this.setDirty();
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@
|
||||
@@ -112,7 +112,7 @@
|
||||
public void onObjectiveChanged(ScoreboardObjective scoreboardobjective) {
|
||||
super.onObjectiveChanged(scoreboardobjective);
|
||||
if (this.trackedObjectives.contains(scoreboardobjective)) {
|
||||
@@ -72,7 +72,7 @@
|
||||
}
|
||||
|
||||
this.setDirty();
|
||||
@@ -128,21 +128,21 @@
|
||||
@@ -131,21 +131,21 @@
|
||||
@Override
|
||||
public void onTeamAdded(ScoreboardTeam scoreboardteam) {
|
||||
super.onTeamAdded(scoreboardteam);
|
||||
@@ -97,7 +97,7 @@
|
||||
this.setDirty();
|
||||
}
|
||||
|
||||
@@ -189,6 +189,7 @@
|
||||
@@ -196,6 +196,7 @@
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
|
||||
@@ -105,7 +105,7 @@
|
||||
Iterator iterator1 = list.iterator();
|
||||
|
||||
while (iterator1.hasNext()) {
|
||||
@@ -221,6 +222,7 @@
|
||||
@@ -232,6 +233,7 @@
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
|
||||
@@ -113,7 +113,7 @@
|
||||
Iterator iterator1 = list.iterator();
|
||||
|
||||
while (iterator1.hasNext()) {
|
||||
@@ -257,6 +259,16 @@
|
||||
@@ -276,6 +278,16 @@
|
||||
return this.createData().load(nbttagcompound);
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/bossevents/BossBattleCustom.java
|
||||
+++ b/net/minecraft/server/bossevents/BossBattleCustom.java
|
||||
@@ -17,12 +17,27 @@
|
||||
@@ -18,12 +18,27 @@
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.BossBattle;
|
||||
|
||||
|
@@ -21,8 +21,8 @@
|
||||
private final List<ServerCommand> consoleInput = Collections.synchronizedList(Lists.newArrayList());
|
||||
@Nullable
|
||||
private RemoteStatusListener queryThreadGs4;
|
||||
- public final RemoteControlCommandListener rconConsoleSource;
|
||||
+ // public final RemoteControlCommandListener rconConsoleSource; // CraftBukkit - remove field
|
||||
- private final RemoteControlCommandListener rconConsoleSource;
|
||||
+ // private final RemoteControlCommandListener rconConsoleSource; // CraftBukkit - remove field
|
||||
@Nullable
|
||||
private RemoteControlListener rconThread;
|
||||
public DedicatedServerSettings settings;
|
||||
@@ -181,7 +181,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -539,16 +618,52 @@
|
||||
@@ -544,16 +623,52 @@
|
||||
|
||||
@Override
|
||||
public String getPluginNames() {
|
||||
@@ -238,7 +238,7 @@
|
||||
}
|
||||
|
||||
public void storeUsingWhiteList(boolean flag) {
|
||||
@@ -599,4 +714,15 @@
|
||||
@@ -604,4 +719,15 @@
|
||||
public Optional<MinecraftServer.ServerResourcePackInfo> getServerResourcePack() {
|
||||
return this.settings.getProperties().serverResourcePackInfo;
|
||||
}
|
||||
|
@@ -17,7 +17,7 @@
|
||||
public final boolean onlineMode = this.get("online-mode", true);
|
||||
public final boolean preventProxyConnections = this.get("prevent-proxy-connections", false);
|
||||
public final String serverIp = this.get("server-ip", "");
|
||||
@@ -103,8 +108,10 @@
|
||||
@@ -104,8 +109,10 @@
|
||||
private final DedicatedServerProperties.WorldDimensionData worldDimensionData;
|
||||
public final WorldOptions worldOptions;
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
this.difficulty = (EnumDifficulty) this.get("difficulty", dispatchNumberOrString(EnumDifficulty::byId, EnumDifficulty::byName), EnumDifficulty::getKey, EnumDifficulty.EASY);
|
||||
this.gamemode = (EnumGamemode) this.get("gamemode", dispatchNumberOrString(EnumGamemode::byId, EnumGamemode::byName), EnumGamemode::getName, EnumGamemode.SURVIVAL);
|
||||
this.levelName = this.get("level-name", "world");
|
||||
@@ -160,13 +167,15 @@
|
||||
@@ -162,13 +169,15 @@
|
||||
this.initialDataPackConfiguration = getDatapackConfig(this.get("initial-enabled-packs", String.join(",", WorldDataConfiguration.DEFAULT.dataPacks().getEnabled())), this.get("initial-disabled-packs", String.join(",", WorldDataConfiguration.DEFAULT.dataPacks().getDisabled())));
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -247,10 +256,10 @@
|
||||
@@ -249,10 +258,10 @@
|
||||
}).orElseThrow(() -> {
|
||||
return new IllegalStateException("Invalid datapack contents: can't find default preset");
|
||||
});
|
||||
@@ -63,7 +63,7 @@
|
||||
});
|
||||
|
||||
Objects.requireNonNull(iregistry);
|
||||
@@ -262,7 +271,7 @@
|
||||
@@ -264,7 +273,7 @@
|
||||
|
||||
if (holder.is(WorldPresets.FLAT)) {
|
||||
RegistryOps<JsonElement> registryops = RegistryOps.create(JsonOps.INSTANCE, (HolderLookup.b) iregistrycustom);
|
||||
|
@@ -1,11 +1,10 @@
|
||||
--- a/net/minecraft/server/level/EntityPlayer.java
|
||||
+++ b/net/minecraft/server/level/EntityPlayer.java
|
||||
@@ -155,6 +155,38 @@
|
||||
@@ -151,6 +151,37 @@
|
||||
import net.minecraft.world.scores.criteria.IScoreboardCriteria;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import net.minecraft.core.Position;
|
||||
+import net.minecraft.nbt.NBTBase;
|
||||
+import net.minecraft.world.damagesource.CombatTracker;
|
||||
+import net.minecraft.world.food.FoodMetaData;
|
||||
@@ -39,8 +38,17 @@
|
||||
public class EntityPlayer extends EntityHuman {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -212,6 +244,21 @@
|
||||
public int latency;
|
||||
@@ -185,7 +216,7 @@
|
||||
private int levitationStartTime;
|
||||
private boolean disconnected;
|
||||
private int requestedViewDistance;
|
||||
- public String language;
|
||||
+ public String language = "en_us"; // CraftBukkit - default
|
||||
@Nullable
|
||||
private Vec3D startingToFallPosition;
|
||||
@Nullable
|
||||
@@ -210,6 +241,20 @@
|
||||
private int containerCounter;
|
||||
public boolean wonGame;
|
||||
|
||||
+ // CraftBukkit start
|
||||
@@ -54,17 +62,16 @@
|
||||
+ public double maxHealthCache;
|
||||
+ public boolean joining = true;
|
||||
+ public boolean sentListPacket = false;
|
||||
+ public Integer clientViewDistance;
|
||||
+ public String kickLeaveMessage = null; // SPIGOT-3034: Forward leave message to PlayerQuitEvent
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile) {
|
||||
public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, ClientInformation clientinformation) {
|
||||
super(worldserver, worldserver.getSharedSpawnPos(), worldserver.getSharedSpawnAngle(), gameprofile);
|
||||
this.chatVisibility = EnumChatVisibility.FULL;
|
||||
@@ -274,12 +321,56 @@
|
||||
this.advancements = minecraftserver.getPlayerList().getPlayerAdvancements(this);
|
||||
@@ -276,12 +321,56 @@
|
||||
this.setMaxUpStep(1.0F);
|
||||
this.fudgeSpawnLocation(worldserver);
|
||||
this.updateOptions(clientinformation);
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ this.displayName = this.getScoreboardName();
|
||||
@@ -119,7 +126,7 @@
|
||||
int i = Math.max(0, this.server.getSpawnRadius(worldserver));
|
||||
int j = MathHelper.floor(worldserver.getWorldBorder().getDistanceToBorder((double) blockposition.getX(), (double) blockposition.getZ()));
|
||||
|
||||
@@ -328,7 +419,7 @@
|
||||
@@ -330,7 +419,7 @@
|
||||
public void readAdditionalSaveData(NBTTagCompound nbttagcompound) {
|
||||
super.readAdditionalSaveData(nbttagcompound);
|
||||
if (nbttagcompound.contains("warden_spawn_tracker", 10)) {
|
||||
@@ -128,7 +135,7 @@
|
||||
Logger logger = EntityPlayer.LOGGER;
|
||||
|
||||
Objects.requireNonNull(logger);
|
||||
@@ -347,17 +438,26 @@
|
||||
@@ -349,17 +438,26 @@
|
||||
if (nbttagcompound.contains("recipeBook", 10)) {
|
||||
this.recipeBook.fromNbt(nbttagcompound.getCompound("recipeBook"), this.server.getRecipeManager());
|
||||
}
|
||||
@@ -156,7 +163,7 @@
|
||||
Logger logger1 = EntityPlayer.LOGGER;
|
||||
|
||||
Objects.requireNonNull(logger1);
|
||||
@@ -370,7 +470,7 @@
|
||||
@@ -372,7 +470,7 @@
|
||||
@Override
|
||||
public void addAdditionalSaveData(NBTTagCompound nbttagcompound) {
|
||||
super.addAdditionalSaveData(nbttagcompound);
|
||||
@@ -165,7 +172,7 @@
|
||||
Logger logger = EntityPlayer.LOGGER;
|
||||
|
||||
Objects.requireNonNull(logger);
|
||||
@@ -391,7 +491,20 @@
|
||||
@@ -393,7 +491,20 @@
|
||||
Entity entity = this.getRootVehicle();
|
||||
Entity entity1 = this.getVehicle();
|
||||
|
||||
@@ -187,7 +194,7 @@
|
||||
NBTTagCompound nbttagcompound2 = new NBTTagCompound();
|
||||
NBTTagCompound nbttagcompound3 = new NBTTagCompound();
|
||||
|
||||
@@ -416,8 +529,32 @@
|
||||
@@ -418,8 +529,32 @@
|
||||
nbttagcompound.put("SpawnDimension", nbtbase);
|
||||
});
|
||||
}
|
||||
@@ -220,7 +227,7 @@
|
||||
|
||||
public void setExperiencePoints(int i) {
|
||||
float f = (float) this.getXpNeededForNextLevel();
|
||||
@@ -477,6 +614,11 @@
|
||||
@@ -479,6 +614,11 @@
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
@@ -232,7 +239,7 @@
|
||||
this.gameMode.tick();
|
||||
this.wardenSpawnTracker.tick();
|
||||
--this.spawnInvulnerableTime;
|
||||
@@ -533,7 +675,7 @@
|
||||
@@ -535,7 +675,7 @@
|
||||
}
|
||||
|
||||
if (this.getHealth() != this.lastSentHealth || this.lastSentFood != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) {
|
||||
@@ -241,7 +248,7 @@
|
||||
this.lastSentHealth = this.getHealth();
|
||||
this.lastSentFood = this.foodData.getFoodLevel();
|
||||
this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F;
|
||||
@@ -564,6 +706,12 @@
|
||||
@@ -566,6 +706,12 @@
|
||||
this.updateScoreForCriteria(IScoreboardCriteria.EXPERIENCE, MathHelper.ceil((float) this.lastRecordedExperience));
|
||||
}
|
||||
|
||||
@@ -254,7 +261,7 @@
|
||||
if (this.experienceLevel != this.lastRecordedLevel) {
|
||||
this.lastRecordedLevel = this.experienceLevel;
|
||||
this.updateScoreForCriteria(IScoreboardCriteria.LEVEL, MathHelper.ceil((float) this.lastRecordedLevel));
|
||||
@@ -578,6 +726,20 @@
|
||||
@@ -580,6 +726,20 @@
|
||||
CriterionTriggers.LOCATION.trigger(this);
|
||||
}
|
||||
|
||||
@@ -275,7 +282,7 @@
|
||||
} catch (Throwable throwable) {
|
||||
CrashReport crashreport = CrashReport.forThrowable(throwable, "Ticking player");
|
||||
CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Player being ticked");
|
||||
@@ -620,7 +782,8 @@
|
||||
@@ -622,7 +782,8 @@
|
||||
}
|
||||
|
||||
private void updateScoreForCriteria(IScoreboardCriteria iscoreboardcriteria, int i) {
|
||||
@@ -285,7 +292,7 @@
|
||||
scoreboardscore.setScore(i);
|
||||
});
|
||||
}
|
||||
@@ -629,9 +792,47 @@
|
||||
@@ -631,9 +792,47 @@
|
||||
public void die(DamageSource damagesource) {
|
||||
this.gameEvent(GameEvent.ENTITY_DIE);
|
||||
boolean flag = this.level().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES);
|
||||
@@ -335,7 +342,7 @@
|
||||
|
||||
this.connection.send(new ClientboundPlayerCombatKillPacket(this.getId(), ichatbasecomponent), PacketSendListener.exceptionallySend(() -> {
|
||||
boolean flag1 = true;
|
||||
@@ -662,12 +863,18 @@
|
||||
@@ -664,12 +863,18 @@
|
||||
if (this.level().getGameRules().getBoolean(GameRules.RULE_FORGIVE_DEAD_PLAYERS)) {
|
||||
this.tellNeutralMobsThatIDied();
|
||||
}
|
||||
@@ -358,7 +365,7 @@
|
||||
EntityLiving entityliving = this.getKillCredit();
|
||||
|
||||
if (entityliving != null) {
|
||||
@@ -705,10 +912,12 @@
|
||||
@@ -707,10 +912,12 @@
|
||||
String s = this.getScoreboardName();
|
||||
String s1 = entity.getScoreboardName();
|
||||
|
||||
@@ -373,7 +380,7 @@
|
||||
} else {
|
||||
this.awardStat(StatisticList.MOB_KILLS);
|
||||
}
|
||||
@@ -726,7 +935,8 @@
|
||||
@@ -728,7 +935,8 @@
|
||||
int i = scoreboardteam.getColor().getId();
|
||||
|
||||
if (i >= 0 && i < aiscoreboardcriteria.length) {
|
||||
@@ -383,7 +390,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -776,18 +986,20 @@
|
||||
@@ -778,18 +986,20 @@
|
||||
}
|
||||
|
||||
private boolean isPvpAllowed() {
|
||||
@@ -407,7 +414,7 @@
|
||||
} else {
|
||||
return shapedetectorshape;
|
||||
}
|
||||
@@ -796,11 +1008,20 @@
|
||||
@@ -798,11 +1008,20 @@
|
||||
@Nullable
|
||||
@Override
|
||||
public Entity changeDimension(WorldServer worldserver) {
|
||||
@@ -431,7 +438,7 @@
|
||||
this.unRide();
|
||||
this.serverLevel().removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION);
|
||||
if (!this.wonGame) {
|
||||
@@ -811,6 +1032,8 @@
|
||||
@@ -813,6 +1032,8 @@
|
||||
|
||||
return this;
|
||||
} else {
|
||||
@@ -439,8 +446,8 @@
|
||||
+ /*
|
||||
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(), (byte) 3, this.getLastDeathLocation(), this.getPortalCooldown()));
|
||||
@@ -820,20 +1043,50 @@
|
||||
this.connection.send(new PacketPlayOutRespawn(this.createCommonSpawnInfo(worldserver), (byte) 3));
|
||||
@@ -822,20 +1043,50 @@
|
||||
playerlist.sendPlayerPermissionLevel(this);
|
||||
worldserver1.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION);
|
||||
this.unsetRemoved();
|
||||
@@ -479,7 +486,7 @@
|
||||
+ if (true) { // CraftBukkit
|
||||
+ this.isChangingDimension = true; // CraftBukkit - Set teleport invulnerability only if player changing worlds
|
||||
+
|
||||
+ this.connection.send(new PacketPlayOutRespawn(worldserver.dimensionTypeId(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), (byte) 3, this.getLastDeathLocation(), this.getPortalCooldown()));
|
||||
+ this.connection.send(new PacketPlayOutRespawn(this.createCommonSpawnInfo(worldserver), (byte) 3));
|
||||
+ this.connection.send(new PacketPlayOutServerDifficulty(this.level().getDifficulty(), this.level().getLevelData().isDifficultyLocked()));
|
||||
+ PlayerList playerlist = this.server.getPlayerList();
|
||||
+
|
||||
@@ -496,7 +503,7 @@
|
||||
this.connection.resetPosition();
|
||||
worldserver.addDuringPortalTeleport(this);
|
||||
worldserver1.getProfiler().pop();
|
||||
@@ -853,39 +1106,66 @@
|
||||
@@ -855,39 +1106,66 @@
|
||||
this.lastSentExp = -1;
|
||||
this.lastSentHealth = -1.0F;
|
||||
this.lastSentFood = -1;
|
||||
@@ -513,7 +520,7 @@
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ protected CraftPortalEvent callPortalEvent(Entity entity, WorldServer exitWorldServer, Position exitPosition, TeleportCause cause, int searchRadius, int creationRadius) {
|
||||
+ protected CraftPortalEvent callPortalEvent(Entity entity, WorldServer exitWorldServer, Vec3D exitPosition, TeleportCause cause, int searchRadius, int creationRadius) {
|
||||
+ Location enter = this.getBukkitEntity().getLocation();
|
||||
+ Location exit = CraftLocation.toBukkit(exitPosition, exitWorldServer.getWorld(), getYRot(), getXRot());
|
||||
+ PlayerPortalEvent event = new PlayerPortalEvent(this.getBukkitEntity(), enter, exit, cause, searchRadius, true, creationRadius);
|
||||
@@ -563,13 +570,13 @@
|
||||
- Optional<BlockUtil.Rectangle> optional1 = worldserver.getPortalForcer().createPortal(blockposition, enumdirection_enumaxis);
|
||||
+ Optional<BlockUtil.Rectangle> optional1 = worldserver.getPortalForcer().createPortal(blockposition, enumdirection_enumaxis, this, createRadius); // CraftBukkit
|
||||
|
||||
if (!optional1.isPresent()) {
|
||||
if (optional1.isEmpty()) {
|
||||
- EntityPlayer.LOGGER.error("Unable to create a portal, likely target out of worldborder");
|
||||
+ // EntityPlayer.LOGGER.error("Unable to create a portal, likely target out of worldborder"); // CraftBukkit
|
||||
}
|
||||
|
||||
return optional1;
|
||||
@@ -895,13 +1175,21 @@
|
||||
@@ -897,13 +1175,21 @@
|
||||
public void triggerDimensionChangeTriggers(WorldServer worldserver) {
|
||||
ResourceKey<World> resourcekey = worldserver.dimension();
|
||||
ResourceKey<World> resourcekey1 = this.level().dimension();
|
||||
@@ -594,7 +601,7 @@
|
||||
this.enteredNetherPosition = null;
|
||||
}
|
||||
|
||||
@@ -918,19 +1206,17 @@
|
||||
@@ -920,19 +1206,17 @@
|
||||
this.containerMenu.broadcastChanges();
|
||||
}
|
||||
|
||||
@@ -618,7 +625,7 @@
|
||||
if (this.level().isDay()) {
|
||||
return Either.left(EntityHuman.EnumBedResult.NOT_POSSIBLE_NOW);
|
||||
} else {
|
||||
@@ -947,7 +1233,36 @@
|
||||
@@ -949,7 +1233,36 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -656,7 +663,7 @@
|
||||
this.awardStat(StatisticList.SLEEP_IN_BED);
|
||||
CriterionTriggers.SLEPT_IN_BED.trigger(this);
|
||||
});
|
||||
@@ -960,9 +1275,8 @@
|
||||
@@ -962,9 +1275,8 @@
|
||||
return either;
|
||||
}
|
||||
}
|
||||
@@ -667,7 +674,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -989,13 +1303,31 @@
|
||||
@@ -991,13 +1303,31 @@
|
||||
|
||||
@Override
|
||||
public void stopSleepInBed(boolean flag, boolean flag1) {
|
||||
@@ -700,7 +707,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1037,8 +1369,9 @@
|
||||
@@ -1039,8 +1369,9 @@
|
||||
this.connection.send(new PacketPlayOutOpenSignEditor(tileentitysign.getBlockPos(), flag));
|
||||
}
|
||||
|
||||
@@ -711,7 +718,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1046,13 +1379,35 @@
|
||||
@@ -1048,13 +1379,35 @@
|
||||
if (itileinventory == null) {
|
||||
return OptionalInt.empty();
|
||||
} else {
|
||||
@@ -747,7 +754,7 @@
|
||||
if (container == null) {
|
||||
if (this.isSpectator()) {
|
||||
this.displayClientMessage(IChatBaseComponent.translatable("container.spectatorCantOpen").withStyle(EnumChatFormat.RED), true);
|
||||
@@ -1060,9 +1415,11 @@
|
||||
@@ -1062,9 +1415,11 @@
|
||||
|
||||
return OptionalInt.empty();
|
||||
} else {
|
||||
@@ -761,7 +768,7 @@
|
||||
return OptionalInt.of(this.containerCounter);
|
||||
}
|
||||
}
|
||||
@@ -1075,13 +1432,24 @@
|
||||
@@ -1077,13 +1432,24 @@
|
||||
|
||||
@Override
|
||||
public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) {
|
||||
@@ -788,7 +795,7 @@
|
||||
this.initMenu(this.containerMenu);
|
||||
}
|
||||
|
||||
@@ -1104,6 +1472,7 @@
|
||||
@@ -1106,6 +1472,7 @@
|
||||
|
||||
@Override
|
||||
public void closeContainer() {
|
||||
@@ -796,7 +803,7 @@
|
||||
this.connection.send(new PacketPlayOutCloseWindow(this.containerMenu.containerId));
|
||||
this.doCloseContainer();
|
||||
}
|
||||
@@ -1126,6 +1495,16 @@
|
||||
@@ -1128,6 +1495,16 @@
|
||||
}
|
||||
|
||||
this.jumping = flag;
|
||||
@@ -813,7 +820,7 @@
|
||||
this.setShiftKeyDown(flag1);
|
||||
}
|
||||
|
||||
@@ -1134,7 +1513,7 @@
|
||||
@@ -1136,7 +1513,7 @@
|
||||
@Override
|
||||
public void awardStat(Statistic<?> statistic, int i) {
|
||||
this.stats.increment(this, statistic, i);
|
||||
@@ -822,7 +829,7 @@
|
||||
scoreboardscore.add(i);
|
||||
});
|
||||
}
|
||||
@@ -1142,7 +1521,7 @@
|
||||
@@ -1144,7 +1521,7 @@
|
||||
@Override
|
||||
public void resetStat(Statistic<?> statistic) {
|
||||
this.stats.setValue(this, statistic, 0);
|
||||
@@ -831,16 +838,16 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1163,7 +1542,7 @@
|
||||
@@ -1165,7 +1542,7 @@
|
||||
|
||||
for (int j = 0; j < i; ++j) {
|
||||
MinecraftKey minecraftkey = aminecraftkey1[j];
|
||||
- Optional optional = this.server.getRecipeManager().byKey(minecraftkey);
|
||||
+ Optional<? extends IRecipe<?>> optional = this.server.getRecipeManager().byKey(minecraftkey); // CraftBukkit - decompile error
|
||||
+ Optional<? extends RecipeHolder<?>> optional = this.server.getRecipeManager().byKey(minecraftkey); // CraftBukkit - decompile error
|
||||
|
||||
Objects.requireNonNull(list);
|
||||
optional.ifPresent(list::add);
|
||||
@@ -1198,6 +1577,7 @@
|
||||
@@ -1200,6 +1577,7 @@
|
||||
|
||||
public void resetSentInfo() {
|
||||
this.lastSentHealth = -1.0E8F;
|
||||
@@ -848,7 +855,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1256,7 +1636,7 @@
|
||||
@@ -1257,7 +1635,7 @@
|
||||
this.lastSentExp = -1;
|
||||
this.lastSentHealth = -1.0F;
|
||||
this.lastSentFood = -1;
|
||||
@@ -856,8 +863,8 @@
|
||||
+ // this.recipeBook.copyOverData(entityplayer.recipeBook); // CraftBukkit
|
||||
this.seenCredits = entityplayer.seenCredits;
|
||||
this.enteredNetherPosition = entityplayer.enteredNetherPosition;
|
||||
this.setShoulderEntityLeft(entityplayer.getShoulderEntityLeft());
|
||||
@@ -1306,6 +1686,12 @@
|
||||
this.chunkTrackingView = entityplayer.chunkTrackingView;
|
||||
@@ -1308,6 +1686,12 @@
|
||||
|
||||
@Override
|
||||
public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set<RelativeMovement> set, float f, float f1) {
|
||||
@@ -870,7 +877,7 @@
|
||||
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(BlockPosition.containing(d0, d1, d2));
|
||||
|
||||
worldserver.getChunkSource().addRegionTicket(TicketType.POST_TELEPORT, chunkcoordintpair, 1, this.getId());
|
||||
@@ -1315,9 +1701,9 @@
|
||||
@@ -1317,9 +1701,9 @@
|
||||
}
|
||||
|
||||
if (worldserver == this.level()) {
|
||||
@@ -882,28 +889,24 @@
|
||||
}
|
||||
|
||||
this.setYHeadRot(f);
|
||||
@@ -1420,7 +1806,20 @@
|
||||
}
|
||||
@@ -1423,6 +1807,16 @@
|
||||
}
|
||||
|
||||
+ public String locale = "en_us"; // CraftBukkit - add, lowercase
|
||||
public void updateOptions(PacketPlayInSettings packetplayinsettings) {
|
||||
public void updateOptions(ClientInformation clientinformation) {
|
||||
+ // CraftBukkit start
|
||||
+ if (getMainArm() != packetplayinsettings.mainHand()) {
|
||||
+ if (getMainArm() != clientinformation.mainHand()) {
|
||||
+ PlayerChangedMainHandEvent event = new PlayerChangedMainHandEvent(getBukkitEntity(), getMainArm() == EnumMainHand.LEFT ? MainHand.LEFT : MainHand.RIGHT);
|
||||
+ this.server.server.getPluginManager().callEvent(event);
|
||||
+ }
|
||||
+ if (!this.locale.equals(packetplayinsettings.language)) {
|
||||
+ PlayerLocaleChangeEvent event = new PlayerLocaleChangeEvent(getBukkitEntity(), packetplayinsettings.language);
|
||||
+ if (!this.language.equals(clientinformation.language())) {
|
||||
+ PlayerLocaleChangeEvent event = new PlayerLocaleChangeEvent(getBukkitEntity(), clientinformation.language());
|
||||
+ this.server.server.getPluginManager().callEvent(event);
|
||||
+ }
|
||||
+ this.locale = packetplayinsettings.language;
|
||||
+ this.clientViewDistance = packetplayinsettings.viewDistance;
|
||||
+ // CraftBukkit end
|
||||
this.chatVisibility = packetplayinsettings.chatVisibility();
|
||||
this.canChatColor = packetplayinsettings.chatColors();
|
||||
this.textFilteringEnabled = packetplayinsettings.textFilteringEnabled();
|
||||
@@ -1495,7 +1894,7 @@
|
||||
this.language = clientinformation.language();
|
||||
this.requestedViewDistance = clientinformation.viewDistance();
|
||||
this.chatVisibility = clientinformation.chatVisibility();
|
||||
@@ -1506,7 +1900,7 @@
|
||||
if (world instanceof WorldServer) {
|
||||
WorldServer worldserver = (WorldServer) world;
|
||||
|
||||
@@ -912,7 +915,7 @@
|
||||
}
|
||||
|
||||
if (entity != null) {
|
||||
@@ -1532,7 +1931,7 @@
|
||||
@@ -1543,7 +1937,7 @@
|
||||
|
||||
@Nullable
|
||||
public IChatBaseComponent getTabListDisplayName() {
|
||||
@@ -921,7 +924,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1553,9 +1952,16 @@
|
||||
@@ -1564,9 +1958,16 @@
|
||||
return this.advancements;
|
||||
}
|
||||
|
||||
@@ -938,7 +941,7 @@
|
||||
if (worldserver == this.level()) {
|
||||
this.connection.teleport(d0, d1, d2, f, f1);
|
||||
} else {
|
||||
@@ -1575,6 +1981,9 @@
|
||||
@@ -1586,6 +1987,9 @@
|
||||
this.server.getPlayerList().sendLevelInfo(this, worldserver);
|
||||
this.server.getPlayerList().sendAllPlayerInfo(this);
|
||||
}
|
||||
@@ -948,7 +951,7 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -1596,6 +2005,32 @@
|
||||
@@ -1607,6 +2011,32 @@
|
||||
}
|
||||
|
||||
public void setRespawnPosition(ResourceKey<World> resourcekey, @Nullable BlockPosition blockposition, float f, boolean flag, boolean flag1) {
|
||||
@@ -981,9 +984,9 @@
|
||||
if (blockposition != null) {
|
||||
boolean flag2 = blockposition.equals(this.respawnPosition) && resourcekey.equals(this.respawnDimension);
|
||||
|
||||
@@ -1805,4 +2240,146 @@
|
||||
}
|
||||
|
||||
@@ -1812,4 +2242,146 @@
|
||||
public CommonPlayerSpawnInfo createCommonSpawnInfo(WorldServer worldserver) {
|
||||
return new CommonPlayerSpawnInfo(worldserver.dimensionTypeId(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), this.getLastDeathLocation(), this.getPortalCooldown());
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start - Add per-player time and weather.
|
||||
|
@@ -13,7 +13,7 @@
|
||||
public class EntityTrackerEntry {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -63,8 +69,12 @@
|
||||
@@ -66,8 +72,12 @@
|
||||
private boolean wasOnGround;
|
||||
@Nullable
|
||||
private List<DataWatcher.b<?>> trackedDataValues;
|
||||
@@ -27,7 +27,7 @@
|
||||
this.ap = Vec3D.ZERO;
|
||||
this.lastPassengers = Collections.emptyList();
|
||||
this.level = worldserver;
|
||||
@@ -84,7 +94,7 @@
|
||||
@@ -87,7 +97,7 @@
|
||||
List<Entity> list = this.entity.getPassengers();
|
||||
|
||||
if (!list.equals(this.lastPassengers)) {
|
||||
@@ -36,7 +36,7 @@
|
||||
removedPassengers(list, this.lastPassengers).forEach((entity) -> {
|
||||
if (entity instanceof EntityPlayer) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) entity;
|
||||
@@ -101,18 +111,18 @@
|
||||
@@ -104,18 +114,18 @@
|
||||
if (entity instanceof EntityItemFrame) {
|
||||
EntityItemFrame entityitemframe = (EntityItemFrame) entity;
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
|
||||
worldmap.tickCarriedBy(entityplayer, itemstack);
|
||||
Packet<?> packet = worldmap.getUpdatePacket(integer, entityplayer);
|
||||
@@ -225,7 +235,27 @@
|
||||
@@ -228,7 +238,27 @@
|
||||
|
||||
++this.tickCount;
|
||||
if (this.entity.hurtMarked) {
|
||||
@@ -88,7 +88,7 @@
|
||||
this.entity.hurtMarked = false;
|
||||
}
|
||||
|
||||
@@ -253,7 +283,10 @@
|
||||
@@ -256,7 +286,10 @@
|
||||
|
||||
public void sendPairingData(EntityPlayer entityplayer, Consumer<Packet<PacketListenerPlayOut>> consumer) {
|
||||
if (this.entity.isRemoved()) {
|
||||
@@ -100,7 +100,7 @@
|
||||
}
|
||||
|
||||
Packet<PacketListenerPlayOut> packet = this.entity.getAddEntityPacket();
|
||||
@@ -269,6 +302,12 @@
|
||||
@@ -272,6 +305,12 @@
|
||||
if (this.entity instanceof EntityLiving) {
|
||||
Collection<AttributeModifiable> collection = ((EntityLiving) this.entity).getAttributes().getSyncableAttributes();
|
||||
|
||||
@@ -113,7 +113,7 @@
|
||||
if (!collection.isEmpty()) {
|
||||
consumer.accept(new PacketPlayOutUpdateAttributes(this.entity.getId(), collection));
|
||||
}
|
||||
@@ -300,8 +339,15 @@
|
||||
@@ -303,8 +342,15 @@
|
||||
if (!list.isEmpty()) {
|
||||
consumer.accept(new PacketPlayOutEntityEquipment(this.entity.getId(), list));
|
||||
}
|
||||
@@ -129,7 +129,7 @@
|
||||
if (!this.entity.getPassengers().isEmpty()) {
|
||||
consumer.accept(new PacketPlayOutMount(this.entity));
|
||||
}
|
||||
@@ -333,6 +379,11 @@
|
||||
@@ -338,6 +384,11 @@
|
||||
Set<AttributeModifiable> set = ((EntityLiving) this.entity).getAttributes().getDirtyAttributes();
|
||||
|
||||
if (!set.isEmpty()) {
|
||||
|
@@ -11,7 +11,7 @@
|
||||
public class PlayerChunk {
|
||||
|
||||
public static final Either<IChunkAccess, PlayerChunk.Failure> UNLOADED_CHUNK = Either.right(PlayerChunk.Failure.UNLOADED);
|
||||
@@ -71,11 +75,11 @@
|
||||
@@ -72,12 +76,12 @@
|
||||
this.fullChunkFuture = PlayerChunk.UNLOADED_LEVEL_CHUNK_FUTURE;
|
||||
this.tickingChunkFuture = PlayerChunk.UNLOADED_LEVEL_CHUNK_FUTURE;
|
||||
this.entityTickingChunkFuture = PlayerChunk.UNLOADED_LEVEL_CHUNK_FUTURE;
|
||||
@@ -21,11 +21,13 @@
|
||||
this.blockChangedLightSectionFilter = new BitSet();
|
||||
this.skyChangedLightSectionFilter = new BitSet();
|
||||
- this.pendingFullStateConfirmation = CompletableFuture.completedFuture((Object) null);
|
||||
- this.sendSync = CompletableFuture.completedFuture((Object) null);
|
||||
+ this.pendingFullStateConfirmation = CompletableFuture.completedFuture(null); // CraftBukkit - decompile error
|
||||
+ this.sendSync = CompletableFuture.completedFuture(null); // CraftBukkit - decompile error
|
||||
this.pos = chunkcoordintpair;
|
||||
this.levelHeightAccessor = levelheightaccessor;
|
||||
this.lightEngine = levellightengine;
|
||||
@@ -88,6 +92,20 @@
|
||||
@@ -90,6 +94,20 @@
|
||||
this.changedBlocksPerSection = new ShortSet[levelheightaccessor.getSectionsCount()];
|
||||
}
|
||||
|
||||
@@ -46,7 +48,7 @@
|
||||
public CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> getFutureIfPresentUnchecked(ChunkStatus chunkstatus) {
|
||||
CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> completablefuture = (CompletableFuture) this.futures.get(chunkstatus.getIndex());
|
||||
|
||||
@@ -113,17 +131,17 @@
|
||||
@@ -115,9 +133,9 @@
|
||||
@Nullable
|
||||
public Chunk getTickingChunk() {
|
||||
CompletableFuture<Either<Chunk, PlayerChunk.Failure>> completablefuture = this.getTickingChunkFuture();
|
||||
@@ -57,6 +59,8 @@
|
||||
+ return either == null ? null : (Chunk) either.left().orElse(null); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
public CompletableFuture<?> getChunkSendSyncFuture() {
|
||||
@@ -132,9 +150,9 @@
|
||||
@Nullable
|
||||
public Chunk getFullChunk() {
|
||||
CompletableFuture<Either<Chunk, PlayerChunk.Failure>> completablefuture = this.getFullChunkFuture();
|
||||
@@ -68,7 +72,7 @@
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -168,6 +186,7 @@
|
||||
@@ -179,6 +197,7 @@
|
||||
if (chunk != null) {
|
||||
int i = this.levelHeightAccessor.getSectionIndex(blockposition.getY());
|
||||
|
||||
@@ -76,7 +80,7 @@
|
||||
if (this.changedBlocksPerSection[i] == null) {
|
||||
this.hasChangedSections = true;
|
||||
this.changedBlocksPerSection[i] = new ShortOpenHashSet();
|
||||
@@ -178,10 +197,10 @@
|
||||
@@ -189,10 +208,10 @@
|
||||
}
|
||||
|
||||
public void sectionLightChanged(EnumSkyBlock enumskyblock, int i) {
|
||||
@@ -89,7 +93,7 @@
|
||||
|
||||
if (ichunkaccess != null) {
|
||||
ichunkaccess.setUnsaved(true);
|
||||
@@ -246,8 +265,11 @@
|
||||
@@ -257,8 +276,11 @@
|
||||
PacketPlayOutMultiBlockChange packetplayoutmultiblockchange = new PacketPlayOutMultiBlockChange(sectionposition, shortset, chunksection);
|
||||
|
||||
this.broadcast(list, packetplayoutmultiblockchange);
|
||||
@@ -102,7 +106,7 @@
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -372,7 +394,7 @@
|
||||
@@ -394,7 +416,7 @@
|
||||
this.pendingFullStateConfirmation = completablefuture1;
|
||||
completablefuture.thenAccept((either) -> {
|
||||
either.ifLeft((chunk) -> {
|
||||
@@ -111,7 +115,7 @@
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -389,6 +411,30 @@
|
||||
@@ -411,6 +433,30 @@
|
||||
boolean flag1 = ChunkLevel.isLoaded(this.ticketLevel);
|
||||
FullChunkStatus fullchunkstatus = ChunkLevel.fullStatus(this.oldTicketLevel);
|
||||
FullChunkStatus fullchunkstatus1 = ChunkLevel.fullStatus(this.ticketLevel);
|
||||
@@ -142,7 +146,7 @@
|
||||
|
||||
if (flag) {
|
||||
Either<IChunkAccess, PlayerChunk.Failure> either = Either.right(new PlayerChunk.Failure() {
|
||||
@@ -459,6 +505,26 @@
|
||||
@@ -481,6 +527,26 @@
|
||||
|
||||
this.onLevelChange.onLevelChange(this.pos, this::getQueueLevel, this.ticketLevel, this::setQueueLevel);
|
||||
this.oldTicketLevel = this.ticketLevel;
|
||||
|
@@ -1,7 +1,7 @@
|
||||
--- a/net/minecraft/server/level/PlayerChunkMap.java
|
||||
+++ b/net/minecraft/server/level/PlayerChunkMap.java
|
||||
@@ -109,6 +109,12 @@
|
||||
import org.apache.commons.lang3.mutable.MutableObject;
|
||||
@@ -101,6 +101,12 @@
|
||||
import org.apache.commons.lang3.mutable.MutableBoolean;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
@@ -13,9 +13,9 @@
|
||||
public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
|
||||
|
||||
private static final byte CHUNK_TYPE_REPLACEABLE = -1;
|
||||
@@ -151,6 +157,27 @@
|
||||
@@ -143,6 +149,27 @@
|
||||
private final Queue<Runnable> unloadQueue;
|
||||
int viewDistance;
|
||||
private int serverViewDistance;
|
||||
|
||||
+ // CraftBukkit start - recursion-safe executor for Chunk loadCallback() and unloadCallback()
|
||||
+ public final CallbackExecutor callbackExecutor = new CallbackExecutor();
|
||||
@@ -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();
|
||||
@@ -169,6 +196,11 @@
|
||||
@@ -161,6 +188,11 @@
|
||||
this.storageName = path.getFileName().toString();
|
||||
this.level = worldserver;
|
||||
this.generator = chunkgenerator;
|
||||
@@ -53,7 +53,7 @@
|
||||
IRegistryCustom iregistrycustom = worldserver.registryAccess();
|
||||
long j = worldserver.getSeed();
|
||||
|
||||
@@ -335,9 +367,12 @@
|
||||
@@ -332,9 +364,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) {
|
||||
@@ -543,7 +578,7 @@
|
||||
@@ -540,7 +575,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) {
|
||||
@@ -634,9 +669,9 @@
|
||||
@@ -631,9 +666,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);
|
||||
@@ -751,7 +786,21 @@
|
||||
@@ -748,7 +783,21 @@
|
||||
|
||||
private static void postLoadProtoChunk(WorldServer worldserver, List<NBTTagCompound> list) {
|
||||
if (!list.isEmpty()) {
|
||||
@@ -112,7 +112,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -852,7 +901,7 @@
|
||||
@@ -860,7 +909,7 @@
|
||||
if (!playerchunk.wasAccessibleSinceLastSave()) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -121,7 +121,7 @@
|
||||
|
||||
if (!(ichunkaccess instanceof ProtoChunkExtension) && !(ichunkaccess instanceof Chunk)) {
|
||||
return false;
|
||||
@@ -1014,7 +1063,8 @@
|
||||
@@ -1017,7 +1066,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();
|
||||
@@ -1027,7 +1077,7 @@
|
||||
@@ -1030,7 +1080,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";
|
||||
@@ -1043,12 +1093,14 @@
|
||||
@@ -1046,12 +1096,14 @@
|
||||
|
||||
private CompletableFuture<Optional<NBTTagCompound>> readChunk(ChunkCoordIntPair chunkcoordintpair) {
|
||||
return this.read(chunkcoordintpair).thenApplyAsync((optional) -> {
|
||||
@@ -158,7 +158,7 @@
|
||||
}
|
||||
|
||||
boolean anyPlayerCloseEnoughForSpawning(ChunkCoordIntPair chunkcoordintpair) {
|
||||
@@ -1503,7 +1555,7 @@
|
||||
@@ -1460,7 +1512,7 @@
|
||||
public final Set<ServerPlayerConnection> seenBy = Sets.newIdentityHashSet();
|
||||
|
||||
public EntityTracker(Entity entity, int i, int j, boolean flag) {
|
||||
@@ -167,9 +167,9 @@
|
||||
this.entity = entity;
|
||||
this.range = i;
|
||||
this.lastSectionPos = SectionPosition.of((EntityAccess) entity);
|
||||
@@ -1562,6 +1614,11 @@
|
||||
@@ -1520,6 +1572,11 @@
|
||||
double d2 = d0 * d0;
|
||||
boolean flag = d1 <= d2 && this.entity.broadcastToPlayer(entityplayer);
|
||||
boolean flag = d1 <= d2 && this.entity.broadcastToPlayer(entityplayer) && PlayerChunkMap.this.isChunkTracked(entityplayer, this.entity.chunkPosition().x, this.entity.chunkPosition().z);
|
||||
|
||||
+ // CraftBukkit start - respect vanish API
|
||||
+ if (!entityplayer.getBukkitEntity().canSee(this.entity.getBukkitEntity())) {
|
||||
|
@@ -95,7 +95,7 @@
|
||||
boolean flag2 = minecraftserver.forceSynchronousWrites();
|
||||
DataFixer datafixer = minecraftserver.getFixerUpper();
|
||||
EntityPersistentStorage<Entity> entitypersistentstorage = new EntityStorage(this, convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, minecraftserver);
|
||||
@@ -250,9 +304,9 @@
|
||||
@@ -246,9 +300,9 @@
|
||||
long l = minecraftserver.getWorldData().worldGenOptions().seed();
|
||||
|
||||
this.structureCheck = new StructureCheck(this.chunkSource.chunkScanner(), this.registryAccess(), minecraftserver.getStructureManager(), resourcekey, chunkgenerator, this.chunkSource.randomState(), this, chunkgenerator.getBiomeSource(), l, datafixer);
|
||||
@@ -108,15 +108,15 @@
|
||||
} else {
|
||||
this.dragonFight = null;
|
||||
}
|
||||
@@ -266,6 +320,7 @@
|
||||
return new RandomSequences(l);
|
||||
}, "random_sequences");
|
||||
@@ -258,6 +312,7 @@
|
||||
this.randomSequences = (RandomSequences) Objects.requireNonNullElseGet(randomsequences, () -> {
|
||||
return (RandomSequences) this.getDataStorage().computeIfAbsent(RandomSequences.factory(l), "random_sequences");
|
||||
});
|
||||
+ this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
@@ -304,12 +359,20 @@
|
||||
@@ -296,12 +351,20 @@
|
||||
long j;
|
||||
|
||||
if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) {
|
||||
@@ -140,7 +140,7 @@
|
||||
if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE) && this.isRaining()) {
|
||||
this.resetWeatherCycle();
|
||||
}
|
||||
@@ -335,7 +398,7 @@
|
||||
@@ -327,7 +390,7 @@
|
||||
this.runBlockEvents();
|
||||
this.handlingTick = false;
|
||||
gameprofilerfiller.pop();
|
||||
@@ -149,7 +149,7 @@
|
||||
|
||||
if (flag) {
|
||||
this.resetEmptyTime();
|
||||
@@ -351,7 +414,7 @@
|
||||
@@ -343,7 +406,7 @@
|
||||
|
||||
this.entityTickList.forEach((entity) -> {
|
||||
if (!entity.isRemoved()) {
|
||||
@@ -158,7 +158,7 @@
|
||||
entity.discard();
|
||||
} else {
|
||||
gameprofilerfiller.push("checkDespawn");
|
||||
@@ -423,7 +486,7 @@
|
||||
@@ -415,7 +478,7 @@
|
||||
|
||||
private void wakeUpAllPlayers() {
|
||||
this.sleepStatus.removeAllSleepers();
|
||||
@@ -167,7 +167,7 @@
|
||||
entityplayer.stopSleepInBed(false, false);
|
||||
});
|
||||
}
|
||||
@@ -451,7 +514,7 @@
|
||||
@@ -442,7 +505,7 @@
|
||||
entityhorseskeleton.setTrap(true);
|
||||
entityhorseskeleton.setAge(0);
|
||||
entityhorseskeleton.setPos((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ());
|
||||
@@ -176,7 +176,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -460,7 +523,7 @@
|
||||
@@ -451,7 +514,7 @@
|
||||
if (entitylightning != null) {
|
||||
entitylightning.moveTo(Vec3D.atBottomCenterOf(blockposition));
|
||||
entitylightning.setVisualOnly(flag1);
|
||||
@@ -185,29 +185,29 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -475,7 +538,7 @@
|
||||
BiomeBase biomebase = (BiomeBase) this.getBiome(blockposition).value();
|
||||
@@ -506,7 +569,7 @@
|
||||
BiomeBase biomebase = (BiomeBase) this.getBiome(blockposition1).value();
|
||||
|
||||
if (biomebase.shouldFreeze(this, blockposition1)) {
|
||||
- this.setBlockAndUpdate(blockposition1, Blocks.ICE.defaultBlockState());
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition1, Blocks.ICE.defaultBlockState(), null); // CraftBukkit
|
||||
if (biomebase.shouldFreeze(this, blockposition2)) {
|
||||
- this.setBlockAndUpdate(blockposition2, Blocks.ICE.defaultBlockState());
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition2, Blocks.ICE.defaultBlockState(), null); // CraftBukkit
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
@@ -522,10 +585,10 @@
|
||||
IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockSnow.LAYERS, j + 1);
|
||||
|
||||
Block.pushEntitiesUp(iblockdata, iblockdata1, this, blockposition1);
|
||||
- this.setBlockAndUpdate(blockposition1, iblockdata1);
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition1, iblockdata1, null); // CraftBukkit
|
||||
}
|
||||
} else {
|
||||
- this.setBlockAndUpdate(blockposition1, Blocks.SNOW.defaultBlockState());
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition1, Blocks.SNOW.defaultBlockState(), null); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
@@ -489,10 +552,10 @@
|
||||
IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockSnow.LAYERS, i1 + 1);
|
||||
|
||||
Block.pushEntitiesUp(iblockdata, iblockdata1, this, blockposition);
|
||||
- this.setBlockAndUpdate(blockposition, iblockdata1);
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition, iblockdata1, null); // CraftBukkit
|
||||
}
|
||||
} else {
|
||||
- this.setBlockAndUpdate(blockposition, Blocks.SNOW.defaultBlockState());
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition, Blocks.SNOW.defaultBlockState(), null); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -688,6 +751,7 @@
|
||||
@@ -686,6 +749,7 @@
|
||||
this.rainLevel = MathHelper.clamp(this.rainLevel, 0.0F, 1.0F);
|
||||
}
|
||||
|
||||
@@ -215,7 +215,7 @@
|
||||
if (this.oRainLevel != this.rainLevel) {
|
||||
this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel), this.dimension());
|
||||
}
|
||||
@@ -706,14 +770,47 @@
|
||||
@@ -704,14 +768,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));
|
||||
}
|
||||
@@ -265,7 +265,7 @@
|
||||
}
|
||||
|
||||
public void resetEmptyTime() {
|
||||
@@ -748,6 +845,7 @@
|
||||
@@ -746,6 +843,7 @@
|
||||
});
|
||||
gameprofilerfiller.incrementCounter("tickNonPassenger");
|
||||
entity.tick();
|
||||
@@ -273,7 +273,7 @@
|
||||
this.getProfiler().pop();
|
||||
Iterator iterator = entity.getPassengers().iterator();
|
||||
|
||||
@@ -771,6 +869,7 @@
|
||||
@@ -769,6 +867,7 @@
|
||||
});
|
||||
gameprofilerfiller.incrementCounter("tickPassenger");
|
||||
entity1.rideTick();
|
||||
@@ -281,7 +281,7 @@
|
||||
gameprofilerfiller.pop();
|
||||
Iterator iterator = entity1.getPassengers().iterator();
|
||||
|
||||
@@ -795,6 +894,7 @@
|
||||
@@ -793,6 +892,7 @@
|
||||
ChunkProviderServer chunkproviderserver = this.getChunkSource();
|
||||
|
||||
if (!flag1) {
|
||||
@@ -289,7 +289,7 @@
|
||||
if (iprogressupdate != null) {
|
||||
iprogressupdate.progressStartNoAbort(IChatBaseComponent.translatable("menu.savingLevel"));
|
||||
}
|
||||
@@ -812,11 +912,19 @@
|
||||
@@ -810,11 +910,19 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -310,7 +310,7 @@
|
||||
}
|
||||
|
||||
this.getChunkSource().getDataStorage().save();
|
||||
@@ -881,15 +989,37 @@
|
||||
@@ -879,15 +987,37 @@
|
||||
|
||||
@Override
|
||||
public boolean addFreshEntity(Entity entity) {
|
||||
@@ -351,7 +351,7 @@
|
||||
}
|
||||
|
||||
public void addDuringCommandTeleport(EntityPlayer entityplayer) {
|
||||
@@ -920,24 +1050,37 @@
|
||||
@@ -918,24 +1048,37 @@
|
||||
this.entityManager.addNewEntity(entityplayer);
|
||||
}
|
||||
|
||||
@@ -393,7 +393,7 @@
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -951,10 +1094,32 @@
|
||||
@@ -949,10 +1092,32 @@
|
||||
entityplayer.remove(entity_removalreason);
|
||||
}
|
||||
|
||||
@@ -426,7 +426,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
|
||||
|
||||
@@ -963,6 +1128,12 @@
|
||||
@@ -961,6 +1126,12 @@
|
||||
double d1 = (double) blockposition.getY() - entityplayer.getY();
|
||||
double d2 = (double) blockposition.getZ() - entityplayer.getZ();
|
||||
|
||||
@@ -439,7 +439,7 @@
|
||||
if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) {
|
||||
entityplayer.connection.send(new PacketPlayOutBlockBreakAnimation(i, blockposition, j));
|
||||
}
|
||||
@@ -1022,7 +1193,18 @@
|
||||
@@ -1020,7 +1191,18 @@
|
||||
Iterator iterator = this.navigatingMobs.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
@@ -459,7 +459,7 @@
|
||||
NavigationAbstract navigationabstract = entityinsentient.getNavigation();
|
||||
|
||||
if (navigationabstract.shouldRecomputePath(blockposition)) {
|
||||
@@ -1084,6 +1266,11 @@
|
||||
@@ -1082,6 +1264,11 @@
|
||||
@Override
|
||||
public Explosion explode(@Nullable Entity entity, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator explosiondamagecalculator, double d0, double d1, double d2, float f, boolean flag, World.a world_a) {
|
||||
Explosion explosion = this.explode(entity, damagesource, explosiondamagecalculator, d0, d1, d2, f, flag, world_a, false);
|
||||
@@ -471,7 +471,7 @@
|
||||
|
||||
if (!explosion.interactsWithBlocks()) {
|
||||
explosion.clearToBlow();
|
||||
@@ -1156,13 +1343,20 @@
|
||||
@@ -1154,13 +1341,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) {
|
||||
@@ -494,7 +494,7 @@
|
||||
++j;
|
||||
}
|
||||
}
|
||||
@@ -1213,7 +1407,7 @@
|
||||
@@ -1211,7 +1405,7 @@
|
||||
|
||||
@Nullable
|
||||
public BlockPosition findNearestMapStructure(TagKey<Structure> tagkey, BlockPosition blockposition, int i, boolean flag) {
|
||||
@@ -503,22 +503,7 @@
|
||||
return null;
|
||||
} else {
|
||||
Optional<HolderSet.Named<Structure>> optional = this.registryAccess().registryOrThrow(Registries.STRUCTURE).getTag(tagkey);
|
||||
@@ -1250,11 +1444,21 @@
|
||||
@Nullable
|
||||
@Override
|
||||
public WorldMap getMapData(String s) {
|
||||
- return (WorldMap) this.getServer().overworld().getDataStorage().get(WorldMap::load, s);
|
||||
+ // CraftBukkit start
|
||||
+ return (WorldMap) this.getServer().overworld().getDataStorage().get((nbttagcompound) -> {
|
||||
+ // We only get here when the data file exists, but is not a valid map
|
||||
+ WorldMap newMap = WorldMap.load(nbttagcompound);
|
||||
+ newMap.id = s;
|
||||
+ MapInitializeEvent event = new MapInitializeEvent(newMap.mapView);
|
||||
+ Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
+ return newMap;
|
||||
+ }, s);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -1253,6 +1447,7 @@
|
||||
|
||||
@Override
|
||||
public void setMapData(String s, WorldMap worldmap) {
|
||||
@@ -526,7 +511,7 @@
|
||||
this.getServer().overworld().getDataStorage().set(s, worldmap);
|
||||
}
|
||||
|
||||
@@ -1552,6 +1756,11 @@
|
||||
@@ -1550,6 +1745,11 @@
|
||||
@Override
|
||||
public void blockUpdated(BlockPosition blockposition, Block block) {
|
||||
if (!this.isDebug()) {
|
||||
@@ -538,7 +523,7 @@
|
||||
this.updateNeighborsAt(blockposition, block);
|
||||
}
|
||||
|
||||
@@ -1571,12 +1780,12 @@
|
||||
@@ -1569,12 +1769,12 @@
|
||||
}
|
||||
|
||||
public boolean isFlat() {
|
||||
@@ -553,7 +538,7 @@
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -1599,7 +1808,7 @@
|
||||
@@ -1597,7 +1797,7 @@
|
||||
private static <T> String getTypeCount(Iterable<T> iterable, Function<T, String> function) {
|
||||
try {
|
||||
Object2IntOpenHashMap<String> object2intopenhashmap = new Object2IntOpenHashMap();
|
||||
@@ -562,7 +547,7 @@
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
T t0 = iterator.next();
|
||||
@@ -1608,7 +1817,7 @@
|
||||
@@ -1606,7 +1806,7 @@
|
||||
object2intopenhashmap.addTo(s, 1);
|
||||
}
|
||||
|
||||
@@ -571,7 +556,7 @@
|
||||
String s1 = (String) entry.getKey();
|
||||
|
||||
return s1 + ":" + entry.getIntValue();
|
||||
@@ -1619,17 +1828,33 @@
|
||||
@@ -1617,17 +1817,33 @@
|
||||
}
|
||||
|
||||
public static void makeObsidianPlatform(WorldServer worldserver) {
|
||||
@@ -607,7 +592,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1753,6 +1978,7 @@
|
||||
@@ -1751,6 +1967,7 @@
|
||||
}
|
||||
|
||||
entity.updateDynamicGameEventListener(DynamicGameEventListener::add);
|
||||
@@ -615,7 +600,7 @@
|
||||
}
|
||||
|
||||
public void onTrackingEnd(Entity entity) {
|
||||
@@ -1789,6 +2015,14 @@
|
||||
@@ -1787,6 +2004,14 @@
|
||||
}
|
||||
|
||||
entity.updateDynamicGameEventListener(DynamicGameEventListener::remove);
|
||||
|
@@ -22,10 +22,10 @@
|
||||
|
||||
@Override
|
||||
public void handleIntention(PacketHandshakingInSetProtocol packethandshakinginsetprotocol) {
|
||||
+ this.connection.hostname = packethandshakinginsetprotocol.hostName + ":" + packethandshakinginsetprotocol.port; // CraftBukkit - set hostname
|
||||
switch (packethandshakinginsetprotocol.getIntention()) {
|
||||
+ this.connection.hostname = packethandshakinginsetprotocol.hostName() + ":" + packethandshakinginsetprotocol.port(); // CraftBukkit - set hostname
|
||||
switch (packethandshakinginsetprotocol.intention()) {
|
||||
case LOGIN:
|
||||
this.connection.setProtocol(EnumProtocol.LOGIN);
|
||||
this.connection.setClientboundProtocolAfterHandshake(ClientIntent.LOGIN);
|
||||
+ // CraftBukkit start - Connection throttle
|
||||
+ try {
|
||||
+ long currentTime = System.currentTimeMillis();
|
||||
@@ -60,6 +60,6 @@
|
||||
+ org.apache.logging.log4j.LogManager.getLogger().debug("Failed to check connection throttle", t);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (packethandshakinginsetprotocol.getProtocolVersion() != SharedConstants.getCurrentVersion().getProtocolVersion()) {
|
||||
if (packethandshakinginsetprotocol.protocolVersion() != SharedConstants.getCurrentVersion().getProtocolVersion()) {
|
||||
IChatMutableComponent ichatmutablecomponent;
|
||||
|
||||
|
@@ -1,34 +1,45 @@
|
||||
--- a/net/minecraft/server/network/LegacyPingHandler.java
|
||||
+++ b/net/minecraft/server/network/LegacyPingHandler.java
|
||||
@@ -37,11 +37,12 @@
|
||||
MinecraftServer minecraftserver = this.serverConnectionListener.getServer();
|
||||
int i = bytebuf.readableBytes();
|
||||
String s;
|
||||
+ org.bukkit.event.server.ServerListPingEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callServerListPingEvent(minecraftserver.server, inetsocketaddress.getAddress(), minecraftserver.getMotd(), minecraftserver.getPlayerCount(), minecraftserver.getMaxPlayers()); // CraftBukkit
|
||||
@@ -35,10 +35,11 @@
|
||||
SocketAddress socketaddress = channelhandlercontext.channel().remoteAddress();
|
||||
int i = bytebuf.readableBytes();
|
||||
String s;
|
||||
+ org.bukkit.event.server.ServerListPingEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callServerListPingEvent(socketaddress, server.getMotd(), server.getPlayerCount(), server.getMaxPlayers()); // CraftBukkit
|
||||
|
||||
switch (i) {
|
||||
case 0:
|
||||
LegacyPingHandler.LOGGER.debug("Ping: (<1.3.x) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort());
|
||||
- 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:
|
||||
@@ -50,7 +51,7 @@
|
||||
if (i == 0) {
|
||||
LegacyPingHandler.LOGGER.debug("Ping: (<1.3.x) from {}", socketaddress);
|
||||
- s = createVersion0Response(this.server);
|
||||
+ s = createVersion0Response(this.server, event); // CraftBukkit
|
||||
sendFlushAndClose(channelhandlercontext, createLegacyDisconnectPacket(channelhandlercontext.alloc(), s));
|
||||
} else {
|
||||
if (bytebuf.readUnsignedByte() != 1) {
|
||||
@@ -55,7 +56,7 @@
|
||||
LegacyPingHandler.LOGGER.debug("Ping: (1.4-1.5.x) from {}", socketaddress);
|
||||
}
|
||||
|
||||
LegacyPingHandler.LOGGER.debug("Ping: (1.4-1.5.x) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort());
|
||||
- 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:
|
||||
@@ -69,7 +70,7 @@
|
||||
}
|
||||
- s = createVersion1Response(this.server);
|
||||
+ s = createVersion1Response(this.server, event); // CraftBukkit
|
||||
sendFlushAndClose(channelhandlercontext, createLegacyDisconnectPacket(channelhandlercontext.alloc(), s));
|
||||
}
|
||||
|
||||
LegacyPingHandler.LOGGER.debug("Ping: (1.6) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort());
|
||||
- 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);
|
||||
@@ -106,12 +107,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
- private static String createVersion0Response(ServerInfo serverinfo) {
|
||||
- return String.format(Locale.ROOT, "%s\u00a7%d\u00a7%d", serverinfo.getMotd(), serverinfo.getPlayerCount(), serverinfo.getMaxPlayers());
|
||||
+ // CraftBukkit start
|
||||
+ private static String createVersion0Response(ServerInfo serverinfo, org.bukkit.event.server.ServerListPingEvent event) {
|
||||
+ return String.format(Locale.ROOT, "%s\u00a7%d\u00a7%d", event.getMotd(), event.getNumPlayers(), event.getMaxPlayers());
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
- private static String createVersion1Response(ServerInfo serverinfo) {
|
||||
- return String.format(Locale.ROOT, "\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, serverinfo.getServerVersion(), serverinfo.getMotd(), serverinfo.getPlayerCount(), serverinfo.getMaxPlayers());
|
||||
+ // CraftBukkit start
|
||||
+ private static String createVersion1Response(ServerInfo serverinfo, org.bukkit.event.server.ServerListPingEvent event) {
|
||||
+ return String.format(Locale.ROOT, "\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, serverinfo.getServerVersion(), event.getMotd(), event.getNumPlayers(), event.getMaxPlayers());
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
private static void sendFlushAndClose(ChannelHandlerContext channelhandlercontext, ByteBuf bytebuf) {
|
||||
|
@@ -1,10 +1,11 @@
|
||||
--- a/net/minecraft/server/network/LoginListener.java
|
||||
+++ b/net/minecraft/server/network/LoginListener.java
|
||||
@@ -38,6 +38,12 @@
|
||||
@@ -39,6 +39,13 @@
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import net.minecraft.server.level.EntityPlayer;
|
||||
+import org.bukkit.craftbukkit.util.Waitable;
|
||||
+import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
||||
+import org.bukkit.event.player.PlayerPreLoginEvent;
|
||||
@@ -13,7 +14,15 @@
|
||||
public class LoginListener implements PacketLoginInListener, TickablePacketListener {
|
||||
|
||||
private static final AtomicInteger UNIQUE_THREAD_ID = new AtomicInteger(0);
|
||||
@@ -83,6 +89,13 @@
|
||||
@@ -55,6 +62,7 @@
|
||||
@Nullable
|
||||
private GameProfile authenticatedProfile;
|
||||
private final String serverId;
|
||||
+ private EntityPlayer player; // CraftBukkit
|
||||
|
||||
public LoginListener(MinecraftServer minecraftserver, NetworkManager networkmanager) {
|
||||
this.state = LoginListener.EnumProtocolState.HELLO;
|
||||
@@ -80,6 +88,13 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -27,43 +36,43 @@
|
||||
@Override
|
||||
public boolean isAcceptingMessages() {
|
||||
return this.connection.isConnected();
|
||||
@@ -104,10 +117,12 @@
|
||||
this.gameProfile = this.createFakeProfile(this.gameProfile);
|
||||
}
|
||||
@@ -138,10 +153,12 @@
|
||||
|
||||
- IChatBaseComponent ichatbasecomponent = this.server.getPlayerList().canPlayerLogin(this.connection.getRemoteAddress(), this.gameProfile);
|
||||
private void verifyLoginAndFinishConnectionSetup(GameProfile gameprofile) {
|
||||
PlayerList playerlist = this.server.getPlayerList();
|
||||
- IChatBaseComponent ichatbasecomponent = playerlist.canPlayerLogin(this.connection.getRemoteAddress(), gameprofile);
|
||||
+ // CraftBukkit start - fire PlayerLoginEvent
|
||||
+ EntityPlayer s = this.server.getPlayerList().canPlayerLogin(this, this.gameProfile);
|
||||
+ this.player = playerlist.canPlayerLogin(this, gameprofile); // CraftBukkit
|
||||
|
||||
- if (ichatbasecomponent != null) {
|
||||
- this.disconnect(ichatbasecomponent);
|
||||
+ if (s == null) {
|
||||
+ if (this.player == null) {
|
||||
+ // this.disconnect(ichatbasecomponent);
|
||||
+ // CraftBukkit end
|
||||
} else {
|
||||
this.state = LoginListener.EnumProtocolState.ACCEPTED;
|
||||
if (this.server.getCompressionThreshold() >= 0 && !this.connection.isMemoryConnection()) {
|
||||
@@ -120,7 +135,7 @@
|
||||
EntityPlayer entityplayer = this.server.getPlayerList().getPlayer(this.gameProfile.getId());
|
||||
this.connection.send(new PacketLoginOutSetCompression(this.server.getCompressionThreshold()), PacketSendListener.thenRun(() -> {
|
||||
@@ -149,7 +166,7 @@
|
||||
}));
|
||||
}
|
||||
|
||||
try {
|
||||
- EntityPlayer entityplayer1 = this.server.getPlayerList().getPlayerForLogin(this.gameProfile);
|
||||
+ EntityPlayer entityplayer1 = this.server.getPlayerList().getPlayerForLogin(this.gameProfile, s); // CraftBukkit - add player reference
|
||||
- boolean flag = playerlist.disconnectAllPlayersWithProfile(gameprofile);
|
||||
+ boolean flag = playerlist.disconnectAllPlayersWithProfile(gameprofile, this.player); // CraftBukkit - add player reference
|
||||
|
||||
if (flag) {
|
||||
this.state = LoginListener.EnumProtocolState.WAITING_FOR_DUPE_DISCONNECT;
|
||||
@@ -205,6 +222,43 @@
|
||||
if (profileresult != null) {
|
||||
GameProfile gameprofile = profileresult.profile();
|
||||
|
||||
if (entityplayer != null) {
|
||||
this.state = LoginListener.EnumProtocolState.DELAY_ACCEPT;
|
||||
@@ -210,6 +225,43 @@
|
||||
try {
|
||||
LoginListener.this.gameProfile = LoginListener.this.server.getSessionService().hasJoinedServer(new GameProfile((UUID) null, gameprofile.getName()), s, this.getAddress());
|
||||
if (LoginListener.this.gameProfile != null) {
|
||||
+ // CraftBukkit start - fire PlayerPreLoginEvent
|
||||
+ if (!connection.isConnected()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ String playerName = gameProfile.getName();
|
||||
+ String playerName = gameprofile.getName();
|
||||
+ java.net.InetAddress address = ((java.net.InetSocketAddress) connection.getRemoteAddress()).getAddress();
|
||||
+ java.util.UUID uniqueId = gameProfile.getId();
|
||||
+ java.util.UUID uniqueId = gameprofile.getId();
|
||||
+ final org.bukkit.craftbukkit.CraftServer server = LoginListener.this.server.server;
|
||||
+
|
||||
+ AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, uniqueId);
|
||||
@@ -93,18 +102,27 @@
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
LoginListener.LOGGER.info("UUID of player {} is {}", LoginListener.this.gameProfile.getName(), LoginListener.this.gameProfile.getId());
|
||||
LoginListener.this.state = LoginListener.EnumProtocolState.READY_TO_ACCEPT;
|
||||
LoginListener.LOGGER.info("UUID of player {} is {}", gameprofile.getName(), gameprofile.getId());
|
||||
LoginListener.this.startClientVerification(gameprofile);
|
||||
} else if (LoginListener.this.server.isSingleplayer()) {
|
||||
@@ -229,6 +281,11 @@
|
||||
@@ -222,6 +276,11 @@
|
||||
LoginListener.this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.authservers_down"));
|
||||
LoginListener.LOGGER.error("Couldn't verify username because servers are unavailable");
|
||||
}
|
||||
+ // CraftBukkit start - catch all exceptions
|
||||
+ } catch (Exception exception) {
|
||||
+ disconnect("Failed to verify username!");
|
||||
+ server.server.getLogger().log(java.util.logging.Level.WARNING, "Exception verifying " + gameprofile.getName(), exception);
|
||||
+ server.server.getLogger().log(java.util.logging.Level.WARNING, "Exception verifying " + s1, exception);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
}
|
||||
@@ -247,7 +306,7 @@
|
||||
public void handleLoginAcknowledgement(ServerboundLoginAcknowledgedPacket serverboundloginacknowledgedpacket) {
|
||||
Validate.validState(this.state == LoginListener.EnumProtocolState.PROTOCOL_SWITCHING, "Unexpected login acknowledgement packet", new Object[0]);
|
||||
CommonListenerCookie commonlistenercookie = CommonListenerCookie.createInitial((GameProfile) Objects.requireNonNull(this.authenticatedProfile));
|
||||
- ServerConfigurationPacketListenerImpl serverconfigurationpacketlistenerimpl = new ServerConfigurationPacketListenerImpl(this.server, this.connection, commonlistenercookie);
|
||||
+ ServerConfigurationPacketListenerImpl serverconfigurationpacketlistenerimpl = new ServerConfigurationPacketListenerImpl(this.server, this.connection, commonlistenercookie, this.player); // CraftBukkit
|
||||
|
||||
this.connection.setListener(serverconfigurationpacketlistenerimpl);
|
||||
serverconfigurationpacketlistenerimpl.startConfiguration();
|
||||
|
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/network/PlayerConnection.java
|
||||
+++ b/net/minecraft/server/network/PlayerConnection.java
|
||||
@@ -185,6 +185,71 @@
|
||||
@@ -180,6 +180,66 @@
|
||||
import net.minecraft.world.phys.shapes.VoxelShapes;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
+import net.minecraft.network.protocol.game.PacketPlayOutAttachEntity;
|
||||
+import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment;
|
||||
+import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity;
|
||||
+import net.minecraft.network.protocol.game.PacketPlayOutSpawnPosition;
|
||||
+import net.minecraft.world.entity.EntityInsentient;
|
||||
+import net.minecraft.world.entity.animal.Bucketable;
|
||||
+import net.minecraft.world.entity.EntityLiving;
|
||||
@@ -21,7 +20,7 @@
|
||||
+import net.minecraft.world.entity.animal.allay.Allay;
|
||||
+import net.minecraft.world.inventory.InventoryClickType;
|
||||
+import net.minecraft.world.inventory.Slot;
|
||||
+import net.minecraft.world.item.crafting.IRecipe;
|
||||
+import net.minecraft.world.item.crafting.RecipeHolder;
|
||||
+import net.minecraft.world.level.RayTrace;
|
||||
+import net.minecraft.world.phys.MovingObjectPosition;
|
||||
+import org.bukkit.Location;
|
||||
@@ -30,7 +29,6 @@
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.craftbukkit.util.CraftChatMessage;
|
||||
+import org.bukkit.craftbukkit.util.CraftLocation;
|
||||
+import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
+import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
+import org.bukkit.craftbukkit.util.LazyPlayerSet;
|
||||
@@ -38,7 +36,6 @@
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.Event;
|
||||
+import org.bukkit.event.block.Action;
|
||||
+import org.bukkit.event.block.SignChangeEvent;
|
||||
+import org.bukkit.event.inventory.ClickType;
|
||||
+import org.bukkit.event.inventory.CraftItemEvent;
|
||||
+import org.bukkit.event.inventory.InventoryAction;
|
||||
@@ -54,9 +51,7 @@
|
||||
+import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||
+import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
+import org.bukkit.event.player.PlayerItemHeldEvent;
|
||||
+import org.bukkit.event.player.PlayerKickEvent;
|
||||
+import org.bukkit.event.player.PlayerMoveEvent;
|
||||
+import org.bukkit.event.player.PlayerResourcePackStatusEvent;
|
||||
+import org.bukkit.event.player.PlayerRespawnEvent.RespawnReason;
|
||||
+import org.bukkit.event.player.PlayerSwapHandItemsEvent;
|
||||
+import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
@@ -69,13 +64,13 @@
|
||||
+import org.bukkit.inventory.SmithingInventory;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class PlayerConnection implements ServerPlayerConnection, TickablePacketListener, PacketListenerPlayIn {
|
||||
public class PlayerConnection extends ServerCommonPacketListenerImpl implements PacketListenerPlayIn, ServerPlayerConnection, TickablePacketListener {
|
||||
|
||||
static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -201,7 +266,9 @@
|
||||
private long keepAliveTime;
|
||||
private boolean keepAlivePending;
|
||||
private long keepAliveChallenge;
|
||||
@@ -191,7 +251,9 @@
|
||||
public final PlayerChunkSender chunkSender;
|
||||
private int tickCount;
|
||||
private int ackBlockChangesUpTo = -1;
|
||||
- private int chatSpamTickCount;
|
||||
+ // CraftBukkit start - multithreaded fields
|
||||
+ private final AtomicInteger chatSpamTickCount = new AtomicInteger();
|
||||
@@ -83,18 +78,24 @@
|
||||
private int dropSpamTickCount;
|
||||
private double firstGoodX;
|
||||
private double firstGoodY;
|
||||
@@ -247,8 +314,31 @@
|
||||
this.keepAliveTime = SystemUtils.getMillis();
|
||||
@@ -227,7 +289,7 @@
|
||||
private boolean waitingForSwitchToConfig;
|
||||
|
||||
public PlayerConnection(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayer entityplayer, CommonListenerCookie commonlistenercookie) {
|
||||
- super(minecraftserver, networkmanager, commonlistenercookie);
|
||||
+ super(minecraftserver, networkmanager, commonlistenercookie, entityplayer); // CraftBukkit
|
||||
this.lastChatTimeStamp = new AtomicReference(Instant.EPOCH);
|
||||
this.lastSeenMessages = new LastSeenMessagesValidator(20);
|
||||
this.messageSignatureCache = MessageSignatureCache.createDefault();
|
||||
@@ -237,9 +299,25 @@
|
||||
entityplayer.connection = this;
|
||||
entityplayer.getTextFilter().join();
|
||||
this.signedMessageDecoder = minecraftserver.enforceSecureProfile() ? SignedMessageChain.b.REJECT_ALL : SignedMessageChain.b.unsigned(entityplayer.getUUID());
|
||||
- this.chatMessageChain = new FutureChain(minecraftserver);
|
||||
+ this.chatMessageChain = new FutureChain(minecraftserver.chatExecutor); // CraftBukkit - async chat
|
||||
+ // CraftBukkit start - add fields and methods
|
||||
+ this.cserver = minecraftserver.server;
|
||||
+ }
|
||||
+
|
||||
+ private final org.bukkit.craftbukkit.CraftServer cserver;
|
||||
+ public boolean processedDisconnect;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - add fields
|
||||
+ private int lastTick = MinecraftServer.currentTick;
|
||||
+ private int allowedPlayerTicks = 1;
|
||||
+ private int lastDropTick = MinecraftServer.currentTick;
|
||||
@@ -108,27 +109,15 @@
|
||||
+ private float lastPitch = Float.MAX_VALUE;
|
||||
+ private float lastYaw = Float.MAX_VALUE;
|
||||
+ private boolean justTeleported = false;
|
||||
+
|
||||
+ public CraftPlayer getCraftPlayer() {
|
||||
+ return (this.player == null) ? null : (CraftPlayer) this.player.getBukkitEntity();
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
|
||||
+
|
||||
@Override
|
||||
public void tick() {
|
||||
@@ -303,7 +393,7 @@
|
||||
this.server.getProfiler().push("keepAlive");
|
||||
long i = SystemUtils.getMillis();
|
||||
|
||||
- if (i - this.keepAliveTime >= 15000L) {
|
||||
+ if (i - this.keepAliveTime >= 25000L) { // CraftBukkit
|
||||
if (this.keepAlivePending) {
|
||||
this.disconnect(IChatBaseComponent.translatable("disconnect.timeout"));
|
||||
} else {
|
||||
@@ -315,15 +405,21 @@
|
||||
if (this.ackBlockChangesUpTo > -1) {
|
||||
@@ -291,15 +369,21 @@
|
||||
}
|
||||
|
||||
this.server.getProfiler().pop();
|
||||
this.keepConnectionAlive();
|
||||
+ // CraftBukkit start
|
||||
+ for (int spam; (spam = this.chatSpamTickCount.get()) > 0 && !chatSpamTickCount.compareAndSet(spam, spam - 1); ) ;
|
||||
+ /* Use thread-safe field access instead
|
||||
@@ -147,76 +136,7 @@
|
||||
this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.idling"));
|
||||
}
|
||||
|
||||
@@ -347,16 +443,67 @@
|
||||
return this.server.isSingleplayerOwner(this.player.getGameProfile());
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ @Deprecated
|
||||
public void disconnect(IChatBaseComponent ichatbasecomponent) {
|
||||
+ disconnect(CraftChatMessage.fromComponent(ichatbasecomponent));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
+ public void disconnect(String s) {
|
||||
+ // CraftBukkit start - fire PlayerKickEvent
|
||||
+ 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);
|
||||
+
|
||||
+ if (this.cserver.getServer().isRunning()) {
|
||||
+ this.cserver.getPluginManager().callEvent(event);
|
||||
+ }
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ // Do not kick the player
|
||||
+ return;
|
||||
+ }
|
||||
+ this.player.kickLeaveMessage = event.getLeaveMessage(); // CraftBukkit - SPIGOT-3034: Forward leave message to PlayerQuitEvent
|
||||
+ // Send the possibly modified leave message
|
||||
+ final IChatBaseComponent ichatbasecomponent = CraftChatMessage.fromString(event.getReason(), true)[0];
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
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;
|
||||
NetworkManager networkmanager = this.connection;
|
||||
|
||||
Objects.requireNonNull(this.connection);
|
||||
- minecraftserver.executeBlocking(networkmanager::handleDisconnection);
|
||||
+ // CraftBukkit - Don't wait
|
||||
+ minecraftserver.wrapRunnable(networkmanager::handleDisconnection);
|
||||
}
|
||||
|
||||
private <T, R> CompletableFuture<R> filterTextPacket(T t0, BiFunction<ITextFilter, T, CompletableFuture<R>> bifunction) {
|
||||
@@ -420,7 +567,34 @@
|
||||
@@ -390,7 +474,34 @@
|
||||
double d9 = entity.getDeltaMovement().lengthSqr();
|
||||
double d10 = d6 * d6 + d7 * d7 + d8 * d8;
|
||||
|
||||
@@ -250,9 +170,9 @@
|
||||
+ if (d10 - d9 > Math.max(100.0D, Math.pow((double) (10.0F * (float) i * speed), 2)) && !this.isSingleplayerOwner()) {
|
||||
+ // CraftBukkit end
|
||||
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));
|
||||
this.send(new PacketPlayOutVehicleMove(entity));
|
||||
return;
|
||||
@@ -460,14 +634,72 @@
|
||||
@@ -430,14 +541,72 @@
|
||||
}
|
||||
|
||||
entity.absMoveTo(d3, d4, d5, f, f1);
|
||||
@@ -262,7 +182,7 @@
|
||||
if (flag && (flag2 || !flag3)) {
|
||||
entity.absMoveTo(d0, d1, d2, f, f1);
|
||||
+ player.absMoveTo(d0, d1, d2, this.player.getYRot(), this.player.getXRot()); // CraftBukkit
|
||||
this.connection.send(new PacketPlayOutVehicleMove(entity));
|
||||
this.send(new PacketPlayOutVehicleMove(entity));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -325,7 +245,7 @@
|
||||
this.player.serverLevel().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);
|
||||
@@ -501,6 +733,7 @@
|
||||
@@ -471,6 +640,7 @@
|
||||
}
|
||||
|
||||
this.awaitingPositionFromClient = null;
|
||||
@@ -333,16 +253,16 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -508,7 +741,7 @@
|
||||
@@ -478,7 +648,7 @@
|
||||
@Override
|
||||
public void handleRecipeBookSeenRecipePacket(PacketPlayInRecipeDisplayed packetplayinrecipedisplayed) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinrecipedisplayed, this, this.player.serverLevel());
|
||||
- Optional optional = this.server.getRecipeManager().byKey(packetplayinrecipedisplayed.getRecipe());
|
||||
+ Optional<? extends IRecipe<?>> optional = this.server.getRecipeManager().byKey(packetplayinrecipedisplayed.getRecipe()); // CraftBukkit - decompile error
|
||||
+ Optional<? extends RecipeHolder<?>> optional = this.server.getRecipeManager().byKey(packetplayinrecipedisplayed.getRecipe()); // CraftBukkit - decompile error
|
||||
RecipeBookServer recipebookserver = this.player.getRecipeBook();
|
||||
|
||||
Objects.requireNonNull(recipebookserver);
|
||||
@@ -538,6 +771,12 @@
|
||||
@@ -508,6 +678,12 @@
|
||||
@Override
|
||||
public void handleCustomCommandSuggestions(PacketPlayInTabComplete packetplayintabcomplete) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayintabcomplete, this, this.player.serverLevel());
|
||||
@@ -355,15 +275,15 @@
|
||||
StringReader stringreader = new StringReader(packetplayintabcomplete.getCommand());
|
||||
|
||||
if (stringreader.canRead() && stringreader.peek() == '/') {
|
||||
@@ -547,6 +786,7 @@
|
||||
@@ -517,6 +693,7 @@
|
||||
ParseResults<CommandListenerWrapper> parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack());
|
||||
|
||||
this.server.getCommands().getDispatcher().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> {
|
||||
+ if (suggestions.isEmpty()) return; // CraftBukkit - don't send through empty suggestions - prevents [<args>] from showing for plugins with nothing more to offer
|
||||
this.connection.send(new PacketPlayOutTabComplete(packetplayintabcomplete.getId(), suggestions));
|
||||
this.send(new PacketPlayOutTabComplete(packetplayintabcomplete.getId(), suggestions));
|
||||
});
|
||||
}
|
||||
@@ -792,6 +1032,13 @@
|
||||
@@ -762,6 +939,13 @@
|
||||
|
||||
if (container instanceof ContainerMerchant) {
|
||||
ContainerMerchant containermerchant = (ContainerMerchant) container;
|
||||
@@ -377,7 +297,7 @@
|
||||
|
||||
if (!containermerchant.stillValid(this.player)) {
|
||||
PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, containermerchant);
|
||||
@@ -806,6 +1053,13 @@
|
||||
@@ -776,6 +960,13 @@
|
||||
|
||||
@Override
|
||||
public void handleEditBook(PacketPlayInBEdit packetplayinbedit) {
|
||||
@@ -391,7 +311,7 @@
|
||||
int i = packetplayinbedit.getSlot();
|
||||
|
||||
if (PlayerInventory.isHotbarSlot(i) || i == 40) {
|
||||
@@ -814,7 +1068,7 @@
|
||||
@@ -784,7 +975,7 @@
|
||||
|
||||
Objects.requireNonNull(list);
|
||||
optional.ifPresent(list::add);
|
||||
@@ -400,7 +320,7 @@
|
||||
|
||||
Objects.requireNonNull(list);
|
||||
stream.forEach(list::add);
|
||||
@@ -832,7 +1086,7 @@
|
||||
@@ -802,7 +993,7 @@
|
||||
ItemStack itemstack = this.player.getInventory().getItem(i);
|
||||
|
||||
if (itemstack.is(Items.WRITABLE_BOOK)) {
|
||||
@@ -409,7 +329,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -857,16 +1111,16 @@
|
||||
@@ -827,16 +1018,16 @@
|
||||
|
||||
this.updateBookPages(list, (s) -> {
|
||||
return IChatBaseComponent.ChatSerializer.toJson(IChatBaseComponent.literal(s));
|
||||
@@ -430,7 +350,7 @@
|
||||
return NBTTagString.valueOf((String) unaryoperator.apply(filteredtext.filteredOrEmpty()));
|
||||
});
|
||||
|
||||
@@ -892,6 +1146,7 @@
|
||||
@@ -862,6 +1053,7 @@
|
||||
}
|
||||
|
||||
itemstack.addTagElement("pages", nbttaglist);
|
||||
@@ -438,7 +358,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -928,7 +1183,7 @@
|
||||
@@ -898,7 +1090,7 @@
|
||||
} else {
|
||||
WorldServer worldserver = this.player.serverLevel();
|
||||
|
||||
@@ -447,7 +367,7 @@
|
||||
if (this.tickCount == 0) {
|
||||
this.resetPosition();
|
||||
}
|
||||
@@ -938,7 +1193,7 @@
|
||||
@@ -908,7 +1100,7 @@
|
||||
this.awaitingTeleportTime = this.tickCount;
|
||||
this.teleport(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot());
|
||||
}
|
||||
@@ -456,7 +376,7 @@
|
||||
} else {
|
||||
this.awaitingTeleportTime = this.tickCount;
|
||||
double d0 = clampHorizontal(packetplayinflying.getX(this.player.getX()));
|
||||
@@ -950,7 +1205,15 @@
|
||||
@@ -920,7 +1112,15 @@
|
||||
if (this.player.isPassenger()) {
|
||||
this.player.absMoveTo(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1);
|
||||
this.player.serverLevel().getChunkSource().move(this.player);
|
||||
@@ -472,7 +392,7 @@
|
||||
double d3 = this.player.getX();
|
||||
double d4 = this.player.getY();
|
||||
double d5 = this.player.getZ();
|
||||
@@ -969,15 +1232,33 @@
|
||||
@@ -939,15 +1139,33 @@
|
||||
++this.receivedMovePacketCount;
|
||||
int i = this.receivedMovePacketCount - this.knownMovePacketCount;
|
||||
|
||||
@@ -508,7 +428,7 @@
|
||||
PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", new Object[]{this.player.getName().getString(), d6, d7, d8});
|
||||
this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot());
|
||||
return;
|
||||
@@ -998,6 +1279,7 @@
|
||||
@@ -968,6 +1186,7 @@
|
||||
boolean flag1 = this.player.verticalCollisionBelow;
|
||||
|
||||
this.player.move(EnumMoveType.PLAYER, new Vec3D(d6, d7, d8));
|
||||
@@ -516,7 +436,7 @@
|
||||
double d11 = d7;
|
||||
|
||||
d6 = d0 - this.player.getX();
|
||||
@@ -1016,9 +1298,70 @@
|
||||
@@ -986,9 +1205,70 @@
|
||||
}
|
||||
|
||||
if (!this.player.noPhysics && !this.player.isSleeping() && (flag2 && worldserver.noCollision(this.player, axisalignedbb) || this.isPlayerCollidingWithAnythingNew(worldserver, axisalignedbb, d0, d1, d2))) {
|
||||
@@ -588,7 +508,7 @@
|
||||
this.player.absMoveTo(d0, d1, d2, f, f1);
|
||||
this.clientIsFloating = d11 >= -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.serverLevel().getChunkSource().move(this.player);
|
||||
@@ -1059,11 +1402,68 @@
|
||||
@@ -1029,11 +1309,68 @@
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -658,7 +578,7 @@
|
||||
double d3 = set.contains(RelativeMovement.X) ? this.player.getX() : 0.0D;
|
||||
double d4 = set.contains(RelativeMovement.Y) ? this.player.getY() : 0.0D;
|
||||
double d5 = set.contains(RelativeMovement.Z) ? this.player.getZ() : 0.0D;
|
||||
@@ -1075,6 +1475,14 @@
|
||||
@@ -1045,6 +1382,14 @@
|
||||
this.awaitingTeleport = 0;
|
||||
}
|
||||
|
||||
@@ -673,7 +593,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));
|
||||
@@ -1083,6 +1491,7 @@
|
||||
@@ -1053,6 +1398,7 @@
|
||||
@Override
|
||||
public void handlePlayerAction(PacketPlayInBlockDig packetplayinblockdig) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockdig, this, this.player.serverLevel());
|
||||
@@ -681,7 +601,7 @@
|
||||
BlockPosition blockposition = packetplayinblockdig.getPos();
|
||||
|
||||
this.player.resetLastActionTime();
|
||||
@@ -1093,14 +1502,46 @@
|
||||
@@ -1063,14 +1409,46 @@
|
||||
if (!this.player.isSpectator()) {
|
||||
ItemStack itemstack = this.player.getItemInHand(EnumHand.OFF_HAND);
|
||||
|
||||
@@ -730,7 +650,7 @@
|
||||
this.player.drop(false);
|
||||
}
|
||||
|
||||
@@ -1138,6 +1579,7 @@
|
||||
@@ -1108,6 +1486,7 @@
|
||||
@Override
|
||||
public void handleUseItemOn(PacketPlayInUseItem packetplayinuseitem) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseitem, this, this.player.serverLevel());
|
||||
@@ -738,7 +658,7 @@
|
||||
this.player.connection.ackBlockChangesUpTo(packetplayinuseitem.getSequence());
|
||||
WorldServer worldserver = this.player.serverLevel();
|
||||
EnumHand enumhand = packetplayinuseitem.getHand();
|
||||
@@ -1161,6 +1603,7 @@
|
||||
@@ -1131,6 +1510,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)) {
|
||||
@@ -746,7 +666,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)) {
|
||||
@@ -1189,6 +1632,7 @@
|
||||
@@ -1159,6 +1539,7 @@
|
||||
@Override
|
||||
public void handleUseItem(PacketPlayInBlockPlace packetplayinblockplace) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockplace, this, this.player.serverLevel());
|
||||
@@ -754,7 +674,7 @@
|
||||
this.ackBlockChangesUpTo(packetplayinblockplace.getSequence());
|
||||
WorldServer worldserver = this.player.serverLevel();
|
||||
EnumHand enumhand = packetplayinblockplace.getHand();
|
||||
@@ -1196,6 +1640,49 @@
|
||||
@@ -1166,6 +1547,49 @@
|
||||
|
||||
this.player.resetLastActionTime();
|
||||
if (!itemstack.isEmpty() && itemstack.isItemEnabled(worldserver.enabledFeatures())) {
|
||||
@@ -804,7 +724,7 @@
|
||||
EnumInteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand);
|
||||
|
||||
if (enuminteractionresult.shouldSwing()) {
|
||||
@@ -1216,7 +1703,7 @@
|
||||
@@ -1186,7 +1610,7 @@
|
||||
Entity entity = packetplayinspectate.getEntity(worldserver);
|
||||
|
||||
if (entity != null) {
|
||||
@@ -813,15 +733,7 @@
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1231,6 +1718,7 @@
|
||||
PlayerConnection.LOGGER.info("Disconnecting {} due to resource pack rejection", this.player.getName());
|
||||
this.disconnect(IChatBaseComponent.translatable("multiplayer.requiredTexturePrompt.disconnect"));
|
||||
}
|
||||
+ this.cserver.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(getCraftPlayer(), PlayerResourcePackStatusEvent.Status.values()[packetplayinresourcepackstatus.action.ordinal()])); // CraftBukkit
|
||||
|
||||
}
|
||||
|
||||
@@ -1252,12 +1740,27 @@
|
||||
@@ -1209,6 +1633,13 @@
|
||||
|
||||
@Override
|
||||
public void onDisconnect(IChatBaseComponent ichatbasecomponent) {
|
||||
@@ -832,8 +744,13 @@
|
||||
+ this.processedDisconnect = true;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.chatMessageChain.close();
|
||||
PlayerConnection.LOGGER.info("{} lost connection: {}", this.player.getName().getString(), ichatbasecomponent.getString());
|
||||
this.removePlayerFromWorld();
|
||||
super.onDisconnect(ichatbasecomponent);
|
||||
@@ -1216,10 +1647,18 @@
|
||||
|
||||
private void removePlayerFromWorld() {
|
||||
this.chatMessageChain.close();
|
||||
+ // CraftBukkit start - Replace vanilla quit message handling with our own.
|
||||
+ /*
|
||||
this.server.invalidateStatus();
|
||||
@@ -848,25 +765,9 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.player.getTextFilter().leave();
|
||||
if (this.isSingleplayerOwner()) {
|
||||
PlayerConnection.LOGGER.info("Stopping singleplayer server as player logged out");
|
||||
@@ -1280,6 +1783,15 @@
|
||||
}
|
||||
|
||||
public void send(Packet<?> packet, @Nullable PacketSendListener packetsendlistener) {
|
||||
+ // CraftBukkit start
|
||||
+ if (packet == null) {
|
||||
+ return;
|
||||
+ } else if (packet instanceof PacketPlayOutSpawnPosition) {
|
||||
+ PacketPlayOutSpawnPosition packet6 = (PacketPlayOutSpawnPosition) packet;
|
||||
+ this.player.compassTarget = CraftLocation.toBukkit(packet6.pos, this.getCraftPlayer().getWorld());
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
try {
|
||||
this.connection.send(packet, packetsendlistener);
|
||||
} catch (Throwable throwable) {
|
||||
@@ -1296,7 +1808,16 @@
|
||||
@@ -1234,7 +1673,16 @@
|
||||
@Override
|
||||
public void handleSetCarriedItem(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinhelditemslot, this, this.player.serverLevel());
|
||||
@@ -883,7 +784,7 @@
|
||||
if (this.player.getInventory().selected != packetplayinhelditemslot.getSlot() && this.player.getUsedItemHand() == EnumHand.MAIN_HAND) {
|
||||
this.player.stopUsingItem();
|
||||
}
|
||||
@@ -1305,18 +1826,25 @@
|
||||
@@ -1243,18 +1691,25 @@
|
||||
this.player.resetLastActionTime();
|
||||
} else {
|
||||
PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString());
|
||||
@@ -910,8 +811,8 @@
|
||||
PlayerChatMessage playerchatmessage;
|
||||
|
||||
try {
|
||||
@@ -1334,9 +1862,9 @@
|
||||
PlayerChatMessage playerchatmessage1 = playerchatmessage.withUnsignedContent((IChatBaseComponent) completablefuture1.join()).filter(((FilteredText) completablefuture.join()).mask());
|
||||
@@ -1272,9 +1727,9 @@
|
||||
PlayerChatMessage playerchatmessage1 = playerchatmessage.withUnsignedContent(ichatbasecomponent).filter(filteredtext.mask());
|
||||
|
||||
this.broadcastChatMessage(playerchatmessage1);
|
||||
- }, executor);
|
||||
@@ -922,7 +823,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1351,6 +1879,12 @@
|
||||
@@ -1289,6 +1744,12 @@
|
||||
|
||||
if (optional.isPresent()) {
|
||||
this.server.submit(() -> {
|
||||
@@ -935,7 +836,7 @@
|
||||
this.performChatCommand(serverboundchatcommandpacket, (LastSeenMessages) optional.get());
|
||||
this.detectRateSpam();
|
||||
});
|
||||
@@ -1360,12 +1894,25 @@
|
||||
@@ -1298,12 +1759,25 @@
|
||||
}
|
||||
|
||||
private void performChatCommand(ServerboundChatCommandPacket serverboundchatcommandpacket, LastSeenMessages lastseenmessages) {
|
||||
@@ -963,20 +864,20 @@
|
||||
} catch (SignedMessageChain.a signedmessagechain_a) {
|
||||
this.handleMessageDecodeFailure(signedmessagechain_a);
|
||||
return;
|
||||
@@ -1373,10 +1920,10 @@
|
||||
@@ -1311,10 +1785,10 @@
|
||||
|
||||
CommandSigningContext.a commandsigningcontext_a = new CommandSigningContext.a(map);
|
||||
|
||||
- parseresults = CommandDispatcher.mapSource(parseresults, (commandlistenerwrapper) -> {
|
||||
+ parseresults = CommandDispatcher.<CommandListenerWrapper>mapSource(parseresults, (commandlistenerwrapper) -> { // CraftBukkit - decompile error
|
||||
return commandlistenerwrapper.withSigningContext(commandsigningcontext_a);
|
||||
return commandlistenerwrapper.withSigningContext(commandsigningcontext_a, this.chatMessageChain);
|
||||
});
|
||||
- this.server.getCommands().performCommand(parseresults, serverboundchatcommandpacket.command());
|
||||
+ this.server.getCommands().performCommand(parseresults, command); // CraftBukkit
|
||||
}
|
||||
|
||||
private void handleMessageDecodeFailure(SignedMessageChain.a signedmessagechain_a) {
|
||||
@@ -1417,7 +1964,7 @@
|
||||
@@ -1355,7 +1829,7 @@
|
||||
} else {
|
||||
Optional<LastSeenMessages> optional = this.unpackAndApplyLastSeen(lastseenmessages_b);
|
||||
|
||||
@@ -985,7 +886,7 @@
|
||||
this.send(new ClientboundSystemChatPacket(IChatBaseComponent.translatable("chat.disabled.options").withStyle(EnumChatFormat.RED), false));
|
||||
return Optional.empty();
|
||||
} else {
|
||||
@@ -1465,6 +2012,116 @@
|
||||
@@ -1403,6 +1877,116 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1102,7 +1003,7 @@
|
||||
private PlayerChatMessage getSignedMessage(PacketPlayInChat packetplayinchat, LastSeenMessages lastseenmessages) throws SignedMessageChain.a {
|
||||
SignedMessageBody signedmessagebody = new SignedMessageBody(packetplayinchat.message(), packetplayinchat.timeStamp(), packetplayinchat.salt(), lastseenmessages);
|
||||
|
||||
@@ -1472,13 +2129,33 @@
|
||||
@@ -1410,13 +1994,33 @@
|
||||
}
|
||||
|
||||
private void broadcastChatMessage(PlayerChatMessage playerchatmessage) {
|
||||
@@ -1139,7 +1040,7 @@
|
||||
this.disconnect(IChatBaseComponent.translatable("disconnect.spam"));
|
||||
}
|
||||
|
||||
@@ -1500,13 +2177,62 @@
|
||||
@@ -1438,13 +2042,62 @@
|
||||
@Override
|
||||
public void handleAnimate(PacketPlayInArmAnimation packetplayinarmanimation) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinarmanimation, this, this.player.serverLevel());
|
||||
@@ -1202,7 +1103,7 @@
|
||||
this.player.resetLastActionTime();
|
||||
Entity entity;
|
||||
IJumpable ijumpable;
|
||||
@@ -1588,6 +2314,12 @@
|
||||
@@ -1526,6 +2179,12 @@
|
||||
}
|
||||
|
||||
public void sendPlayerChatMessage(PlayerChatMessage playerchatmessage, ChatMessageType.a chatmessagetype_a) {
|
||||
@@ -1215,7 +1116,7 @@
|
||||
this.send(new ClientboundPlayerChatPacket(playerchatmessage.link().sender(), playerchatmessage.link().index(), playerchatmessage.signature(), playerchatmessage.signedBody().pack(this.messageSignatureCache), playerchatmessage.unsignedContent(), playerchatmessage.filterMask(), chatmessagetype_a.toNetwork(this.player.level().registryAccess())));
|
||||
this.addPendingMessage(playerchatmessage);
|
||||
}
|
||||
@@ -1603,6 +2335,7 @@
|
||||
@@ -1552,6 +2211,7 @@
|
||||
@Override
|
||||
public void handleInteract(PacketPlayInUseEntity packetplayinuseentity) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseentity, this, this.player.serverLevel());
|
||||
@@ -1223,7 +1124,7 @@
|
||||
final WorldServer worldserver = this.player.serverLevel();
|
||||
final Entity entity = packetplayinuseentity.getTarget(worldserver);
|
||||
|
||||
@@ -1617,13 +2350,51 @@
|
||||
@@ -1566,13 +2226,51 @@
|
||||
|
||||
if (axisalignedbb.distanceToSqr(this.player.getEyePosition()) < PlayerConnection.MAX_INTERACTION_DISTANCE) {
|
||||
packetplayinuseentity.dispatch(new PacketPlayInUseEntity.c() {
|
||||
@@ -1276,7 +1177,7 @@
|
||||
if (enuminteractionresult.consumesAction()) {
|
||||
CriterionTriggers.PLAYER_INTERACTED_WITH_ENTITY.trigger(PlayerConnection.this.player, itemstack1, entity);
|
||||
if (enuminteractionresult.shouldSwing()) {
|
||||
@@ -1636,23 +2407,29 @@
|
||||
@@ -1585,23 +2283,29 @@
|
||||
|
||||
@Override
|
||||
public void onInteraction(EnumHand enumhand) {
|
||||
@@ -1309,7 +1210,7 @@
|
||||
}
|
||||
} else {
|
||||
PlayerConnection.this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.invalid_entity_attacked"));
|
||||
@@ -1675,14 +2452,14 @@
|
||||
@@ -1624,14 +2328,14 @@
|
||||
case PERFORM_RESPAWN:
|
||||
if (this.player.wonGame) {
|
||||
this.player.wonGame = false;
|
||||
@@ -1326,7 +1227,7 @@
|
||||
if (this.server.isHardcore()) {
|
||||
this.player.setGameMode(EnumGamemode.SPECTATOR);
|
||||
((GameRules.GameRuleBoolean) this.player.level().getGameRules().getRule(GameRules.RULE_SPECTATORSGENERATECHUNKS)).set(false, this.server);
|
||||
@@ -1698,15 +2475,21 @@
|
||||
@@ -1647,15 +2351,21 @@
|
||||
@Override
|
||||
public void handleContainerClose(PacketPlayInCloseWindow packetplayinclosewindow) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinclosewindow, this, this.player.serverLevel());
|
||||
@@ -1350,7 +1251,7 @@
|
||||
this.player.containerMenu.sendAllDataToRemote();
|
||||
} else if (!this.player.containerMenu.stillValid(this.player)) {
|
||||
PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu);
|
||||
@@ -1719,7 +2502,284 @@
|
||||
@@ -1668,7 +2378,284 @@
|
||||
boolean flag = packetplayinwindowclick.getStateId() != this.player.containerMenu.getStateId();
|
||||
|
||||
this.player.containerMenu.suppressRemoteUpdates();
|
||||
@@ -1636,12 +1537,12 @@
|
||||
ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packetplayinwindowclick.getChangedSlots()).iterator();
|
||||
|
||||
while (objectiterator.hasNext()) {
|
||||
@@ -1749,9 +2809,18 @@
|
||||
@@ -1698,9 +2685,18 @@
|
||||
if (!this.player.containerMenu.stillValid(this.player)) {
|
||||
PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu);
|
||||
} else {
|
||||
- this.server.getRecipeManager().byKey(packetplayinautorecipe.getRecipe()).ifPresent((irecipe) -> {
|
||||
- ((ContainerRecipeBook) this.player.containerMenu).handlePlacement(packetplayinautorecipe.isShiftDown(), irecipe, this.player);
|
||||
- this.server.getRecipeManager().byKey(packetplayinautorecipe.getRecipe()).ifPresent((recipeholder) -> {
|
||||
- ((ContainerRecipeBook) this.player.containerMenu).handlePlacement(packetplayinautorecipe.isShiftDown(), recipeholder, this.player);
|
||||
+ // CraftBukkit start - implement PlayerRecipeBookClickEvent
|
||||
+ org.bukkit.inventory.Recipe recipe = this.cserver.getRecipe(CraftNamespacedKey.fromMinecraft(packetplayinautorecipe.getRecipe()));
|
||||
+ if (recipe == null) {
|
||||
@@ -1650,14 +1551,14 @@
|
||||
+ org.bukkit.event.player.PlayerRecipeBookClickEvent event = CraftEventFactory.callRecipeBookClickEvent(this.player, recipe, packetplayinautorecipe.isShiftDown());
|
||||
+
|
||||
+ // Cast to keyed should be safe as the recipe will never be a MerchantRecipe.
|
||||
+ this.server.getRecipeManager().byKey(CraftNamespacedKey.toMinecraft(((org.bukkit.Keyed) event.getRecipe()).getKey())).ifPresent((irecipe) -> {
|
||||
+ ((ContainerRecipeBook) this.player.containerMenu).handlePlacement(event.isShiftClick(), irecipe, this.player);
|
||||
+ this.server.getRecipeManager().byKey(CraftNamespacedKey.toMinecraft(((org.bukkit.Keyed) event.getRecipe()).getKey())).ifPresent((recipeholder) -> {
|
||||
+ ((ContainerRecipeBook) this.player.containerMenu).handlePlacement(event.isShiftClick(), recipeholder, this.player);
|
||||
});
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1759,6 +2828,7 @@
|
||||
@@ -1708,6 +2704,7 @@
|
||||
@Override
|
||||
public void handleContainerButtonClick(PacketPlayInEnchantItem packetplayinenchantitem) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinenchantitem, this, this.player.serverLevel());
|
||||
@@ -1665,7 +1566,7 @@
|
||||
this.player.resetLastActionTime();
|
||||
if (this.player.containerMenu.containerId == packetplayinenchantitem.getContainerId() && !this.player.isSpectator()) {
|
||||
if (!this.player.containerMenu.stillValid(this.player)) {
|
||||
@@ -1801,6 +2871,43 @@
|
||||
@@ -1750,6 +2747,43 @@
|
||||
|
||||
boolean flag1 = packetplayinsetcreativeslot.getSlotNum() >= 1 && packetplayinsetcreativeslot.getSlotNum() <= 45;
|
||||
boolean flag2 = itemstack.isEmpty() || itemstack.getDamageValue() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty();
|
||||
@@ -1709,7 +1610,7 @@
|
||||
|
||||
if (flag1 && flag2) {
|
||||
this.player.inventoryMenu.getSlot(packetplayinsetcreativeslot.getSlotNum()).setByPlayer(itemstack);
|
||||
@@ -1823,6 +2930,7 @@
|
||||
@@ -1772,6 +2806,7 @@
|
||||
}
|
||||
|
||||
private void updateSignText(PacketPlayInUpdateSign packetplayinupdatesign, List<FilteredText> list) {
|
||||
@@ -1717,15 +1618,7 @@
|
||||
this.player.resetLastActionTime();
|
||||
WorldServer worldserver = this.player.serverLevel();
|
||||
BlockPosition blockposition = packetplayinupdatesign.getPos();
|
||||
@@ -1843,6 +2951,7 @@
|
||||
|
||||
@Override
|
||||
public void handleKeepAlive(PacketPlayInKeepAlive packetplayinkeepalive) {
|
||||
+ PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinkeepalive, this, this.player.serverLevel()); // CraftBukkit
|
||||
if (this.keepAlivePending && packetplayinkeepalive.getId() == this.keepAliveChallenge) {
|
||||
int i = (int) (SystemUtils.getMillis() - this.keepAliveTime);
|
||||
|
||||
@@ -1857,7 +2966,17 @@
|
||||
@@ -1793,7 +2828,17 @@
|
||||
@Override
|
||||
public void handlePlayerAbilities(PacketPlayInAbilities packetplayinabilities) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinabilities, this, this.player.serverLevel());
|
||||
@@ -1744,56 +1637,12 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1866,8 +2985,50 @@
|
||||
this.player.updateOptions(packetplayinsettings);
|
||||
@@ -1852,7 +2897,7 @@
|
||||
if (!this.waitingForSwitchToConfig) {
|
||||
throw new IllegalStateException("Client acknowledged config, but none was requested");
|
||||
} else {
|
||||
- this.connection.setListener(new ServerConfigurationPacketListenerImpl(this.server, this.connection, this.createCookie(this.player.clientInformation())));
|
||||
+ this.connection.setListener(new ServerConfigurationPacketListenerImpl(this.server, this.connection, this.createCookie(this.player.clientInformation()), this.player)); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
- @Override
|
||||
- public void handleCustomPayload(PacketPlayInCustomPayload packetplayincustompayload) {}
|
||||
+ // CraftBukkit start
|
||||
+ private static final MinecraftKey CUSTOM_REGISTER = new MinecraftKey("register");
|
||||
+ private static final MinecraftKey CUSTOM_UNREGISTER = new MinecraftKey("unregister");
|
||||
+
|
||||
+ @Override
|
||||
+ public void handleCustomPayload(PacketPlayInCustomPayload packetplayincustompayload) {
|
||||
+ PlayerConnectionUtils.ensureRunningOnSameThread(packetplayincustompayload, this, this.player.serverLevel());
|
||||
+ if (packetplayincustompayload.identifier.equals(CUSTOM_REGISTER)) {
|
||||
+ try {
|
||||
+ String channels = packetplayincustompayload.data.toString(com.google.common.base.Charsets.UTF_8);
|
||||
+ for (String channel : channels.split("\0")) {
|
||||
+ getCraftPlayer().addChannel(channel);
|
||||
+ }
|
||||
+ } catch (Exception ex) {
|
||||
+ PlayerConnection.LOGGER.error("Couldn\'t register custom payload", ex);
|
||||
+ this.disconnect("Invalid payload REGISTER!");
|
||||
+ }
|
||||
+ } else if (packetplayincustompayload.identifier.equals(CUSTOM_UNREGISTER)) {
|
||||
+ try {
|
||||
+ String channels = packetplayincustompayload.data.toString(com.google.common.base.Charsets.UTF_8);
|
||||
+ for (String channel : channels.split("\0")) {
|
||||
+ getCraftPlayer().removeChannel(channel);
|
||||
+ }
|
||||
+ } catch (Exception ex) {
|
||||
+ PlayerConnection.LOGGER.error("Couldn\'t unregister custom payload", ex);
|
||||
+ this.disconnect("Invalid payload UNREGISTER!");
|
||||
+ }
|
||||
+ } else {
|
||||
+ try {
|
||||
+ byte[] data = new byte[packetplayincustompayload.data.readableBytes()];
|
||||
+ packetplayincustompayload.data.readBytes(data);
|
||||
+ cserver.getMessenger().dispatchIncomingMessage(player.getBukkitEntity(), packetplayincustompayload.identifier.toString(), data);
|
||||
+ } catch (Exception ex) {
|
||||
+ PlayerConnection.LOGGER.error("Couldn\'t dispatch custom payload", ex);
|
||||
+ this.disconnect("Invalid custom payload!");
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ public final boolean isDisconnected() {
|
||||
+ return !this.player.joining && !this.connection.isConnected();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
@Override
|
||||
public void handleChangeDifficulty(PacketPlayInDifficultyChange packetplayindifficultychange) {
|
||||
|
@@ -0,0 +1,215 @@
|
||||
--- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
+++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
@@ -26,6 +26,21 @@
|
||||
import net.minecraft.util.thread.IAsyncTaskHandler;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import io.netty.buffer.ByteBuf;
|
||||
+import java.util.concurrent.ExecutionException;
|
||||
+import net.minecraft.EnumChatFormat;
|
||||
+import net.minecraft.network.protocol.game.PacketPlayOutSpawnPosition;
|
||||
+import net.minecraft.resources.MinecraftKey;
|
||||
+import net.minecraft.server.level.EntityPlayer;
|
||||
+import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
+import org.bukkit.craftbukkit.util.CraftChatMessage;
|
||||
+import org.bukkit.craftbukkit.util.CraftLocation;
|
||||
+import org.bukkit.craftbukkit.util.Waitable;
|
||||
+import org.bukkit.event.player.PlayerKickEvent;
|
||||
+import org.bukkit.event.player.PlayerResourcePackStatusEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public abstract class ServerCommonPacketListenerImpl implements ServerCommonPacketListener {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -39,11 +54,22 @@
|
||||
private int latency;
|
||||
private volatile boolean suspendFlushingOnServerThread = false;
|
||||
|
||||
- public ServerCommonPacketListenerImpl(MinecraftServer minecraftserver, NetworkManager networkmanager, CommonListenerCookie commonlistenercookie) {
|
||||
+ public ServerCommonPacketListenerImpl(MinecraftServer minecraftserver, NetworkManager networkmanager, CommonListenerCookie commonlistenercookie, EntityPlayer player) { // CraftBukkit
|
||||
this.server = minecraftserver;
|
||||
this.connection = networkmanager;
|
||||
this.keepAliveTime = SystemUtils.getMillis();
|
||||
this.latency = commonlistenercookie.latency();
|
||||
+ // CraftBukkit start - add fields and methods
|
||||
+ this.player = player;
|
||||
+ this.cserver = minecraftserver.server;
|
||||
+ }
|
||||
+ protected final EntityPlayer player;
|
||||
+ protected final org.bukkit.craftbukkit.CraftServer cserver;
|
||||
+ public boolean processedDisconnect;
|
||||
+
|
||||
+ public CraftPlayer getCraftPlayer() {
|
||||
+ return (this.player == null) ? null : (CraftPlayer) this.player.getBukkitEntity();
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -57,6 +83,7 @@
|
||||
|
||||
@Override
|
||||
public void handleKeepAlive(ServerboundKeepAlivePacket serverboundkeepalivepacket) {
|
||||
+ PlayerConnectionUtils.ensureRunningOnSameThread(serverboundkeepalivepacket, this, this.player.serverLevel()); // CraftBukkit
|
||||
if (this.keepAlivePending && serverboundkeepalivepacket.getId() == this.keepAliveChallenge) {
|
||||
int i = (int) (SystemUtils.getMillis() - this.keepAliveTime);
|
||||
|
||||
@@ -71,8 +98,56 @@
|
||||
@Override
|
||||
public void handlePong(ServerboundPongPacket serverboundpongpacket) {}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ private static final MinecraftKey CUSTOM_REGISTER = new MinecraftKey("register");
|
||||
+ private static final MinecraftKey CUSTOM_UNREGISTER = new MinecraftKey("unregister");
|
||||
+
|
||||
@Override
|
||||
- public void handleCustomPayload(ServerboundCustomPayloadPacket serverboundcustompayloadpacket) {}
|
||||
+ public void handleCustomPayload(ServerboundCustomPayloadPacket serverboundcustompayloadpacket) {
|
||||
+ if (!(serverboundcustompayloadpacket.payload() instanceof ServerboundCustomPayloadPacket.UnknownPayload)) {
|
||||
+ return;
|
||||
+ }
|
||||
+ PlayerConnectionUtils.ensureRunningOnSameThread(serverboundcustompayloadpacket, this, this.player.serverLevel());
|
||||
+ MinecraftKey identifier = serverboundcustompayloadpacket.payload().id();
|
||||
+ ByteBuf payload = ((ServerboundCustomPayloadPacket.UnknownPayload)serverboundcustompayloadpacket.payload()).data();
|
||||
+
|
||||
+ if (identifier.equals(CUSTOM_REGISTER)) {
|
||||
+ try {
|
||||
+ String channels = payload.toString(com.google.common.base.Charsets.UTF_8);
|
||||
+ for (String channel : channels.split("\0")) {
|
||||
+ getCraftPlayer().addChannel(channel);
|
||||
+ }
|
||||
+ } catch (Exception ex) {
|
||||
+ PlayerConnection.LOGGER.error("Couldn\'t register custom payload", ex);
|
||||
+ this.disconnect("Invalid payload REGISTER!");
|
||||
+ }
|
||||
+ } else if (identifier.equals(CUSTOM_UNREGISTER)) {
|
||||
+ try {
|
||||
+ String channels = payload.toString(com.google.common.base.Charsets.UTF_8);
|
||||
+ for (String channel : channels.split("\0")) {
|
||||
+ getCraftPlayer().removeChannel(channel);
|
||||
+ }
|
||||
+ } catch (Exception ex) {
|
||||
+ PlayerConnection.LOGGER.error("Couldn\'t unregister custom payload", ex);
|
||||
+ this.disconnect("Invalid payload UNREGISTER!");
|
||||
+ }
|
||||
+ } else {
|
||||
+ try {
|
||||
+ byte[] data = new byte[payload.readableBytes()];
|
||||
+ payload.readBytes(data);
|
||||
+ cserver.getMessenger().dispatchIncomingMessage(player.getBukkitEntity(), identifier.toString(), data);
|
||||
+ } catch (Exception ex) {
|
||||
+ PlayerConnection.LOGGER.error("Couldn\'t dispatch custom payload", ex);
|
||||
+ this.disconnect("Invalid custom payload!");
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ public final boolean isDisconnected() {
|
||||
+ return !this.player.joining && !this.connection.isConnected();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
@Override
|
||||
public void handleResourcePackResponse(ServerboundResourcePackPacket serverboundresourcepackpacket) {
|
||||
@@ -81,6 +156,7 @@
|
||||
ServerCommonPacketListenerImpl.LOGGER.info("Disconnecting {} due to resource pack rejection", this.playerProfile().getName());
|
||||
this.disconnect(IChatBaseComponent.translatable("multiplayer.requiredTexturePrompt.disconnect"));
|
||||
}
|
||||
+ this.cserver.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(getCraftPlayer(), PlayerResourcePackStatusEvent.Status.values()[serverboundresourcepackpacket.getAction().ordinal()])); // CraftBukkit
|
||||
|
||||
}
|
||||
|
||||
@@ -88,7 +164,7 @@
|
||||
this.server.getProfiler().push("keepAlive");
|
||||
long i = SystemUtils.getMillis();
|
||||
|
||||
- if (i - this.keepAliveTime >= 15000L) {
|
||||
+ if (i - this.keepAliveTime >= 25000L) { // CraftBukkit
|
||||
if (this.keepAlivePending) {
|
||||
this.disconnect(ServerCommonPacketListenerImpl.TIMEOUT_DISCONNECTION_MESSAGE);
|
||||
} else {
|
||||
@@ -116,6 +192,14 @@
|
||||
}
|
||||
|
||||
public void send(Packet<?> packet, @Nullable PacketSendListener packetsendlistener) {
|
||||
+ // CraftBukkit start
|
||||
+ if (packet == null) {
|
||||
+ return;
|
||||
+ } else if (packet instanceof PacketPlayOutSpawnPosition) {
|
||||
+ PacketPlayOutSpawnPosition packet6 = (PacketPlayOutSpawnPosition) packet;
|
||||
+ this.player.compassTarget = CraftLocation.toBukkit(packet6.pos, this.getCraftPlayer().getWorld());
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
boolean flag = !this.suspendFlushingOnServerThread || !this.server.isSameThread();
|
||||
|
||||
try {
|
||||
@@ -131,16 +215,67 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ @Deprecated
|
||||
public void disconnect(IChatBaseComponent ichatbasecomponent) {
|
||||
+ disconnect(CraftChatMessage.fromComponent(ichatbasecomponent));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
+ public void disconnect(String s) {
|
||||
+ // CraftBukkit start - fire PlayerKickEvent
|
||||
+ if (this.processedDisconnect) {
|
||||
+ return;
|
||||
+ }
|
||||
+ if (!this.cserver.isPrimaryThread()) {
|
||||
+ Waitable waitable = new Waitable() {
|
||||
+ @Override
|
||||
+ protected Object evaluate() {
|
||||
+ ServerCommonPacketListenerImpl.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);
|
||||
+
|
||||
+ if (this.cserver.getServer().isRunning()) {
|
||||
+ this.cserver.getPluginManager().callEvent(event);
|
||||
+ }
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ // Do not kick the player
|
||||
+ return;
|
||||
+ }
|
||||
+ this.player.kickLeaveMessage = event.getLeaveMessage(); // CraftBukkit - SPIGOT-3034: Forward leave message to PlayerQuitEvent
|
||||
+ // Send the possibly modified leave message
|
||||
+ final IChatBaseComponent ichatbasecomponent = CraftChatMessage.fromString(event.getReason(), true)[0];
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
this.connection.send(new ClientboundDisconnectPacket(ichatbasecomponent), PacketSendListener.thenRun(() -> {
|
||||
this.connection.disconnect(ichatbasecomponent);
|
||||
}));
|
||||
+ this.onDisconnect(ichatbasecomponent); // CraftBukkit - fire quit instantly
|
||||
this.connection.setReadOnly();
|
||||
MinecraftServer minecraftserver = this.server;
|
||||
NetworkManager networkmanager = this.connection;
|
||||
|
||||
Objects.requireNonNull(this.connection);
|
||||
- minecraftserver.executeBlocking(networkmanager::handleDisconnection);
|
||||
+ // CraftBukkit - Don't wait
|
||||
+ minecraftserver.wrapRunnable(networkmanager::handleDisconnection);
|
||||
}
|
||||
|
||||
protected boolean isSingleplayerOwner() {
|
@@ -0,0 +1,30 @@
|
||||
--- a/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java
|
||||
+++ b/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java
|
||||
@@ -44,8 +44,8 @@
|
||||
private ConfigurationTask currentTask;
|
||||
private ClientInformation clientInformation;
|
||||
|
||||
- public ServerConfigurationPacketListenerImpl(MinecraftServer minecraftserver, NetworkManager networkmanager, CommonListenerCookie commonlistenercookie) {
|
||||
- super(minecraftserver, networkmanager, commonlistenercookie);
|
||||
+ public ServerConfigurationPacketListenerImpl(MinecraftServer minecraftserver, NetworkManager networkmanager, CommonListenerCookie commonlistenercookie, EntityPlayer player) { // CraftBukkit
|
||||
+ super(minecraftserver, networkmanager, commonlistenercookie, player); // CraftBukkit
|
||||
this.gameProfile = commonlistenercookie.gameProfile();
|
||||
this.clientInformation = commonlistenercookie.clientInformation();
|
||||
}
|
||||
@@ -117,14 +117,14 @@
|
||||
return;
|
||||
}
|
||||
|
||||
- IChatBaseComponent ichatbasecomponent = playerlist.canPlayerLogin(this.connection.getRemoteAddress(), this.gameProfile);
|
||||
+ IChatBaseComponent ichatbasecomponent = null; // CraftBukkit - login checks already completed
|
||||
|
||||
if (ichatbasecomponent != null) {
|
||||
this.disconnect(ichatbasecomponent);
|
||||
return;
|
||||
}
|
||||
|
||||
- EntityPlayer entityplayer = playerlist.getPlayerForLogin(this.gameProfile, this.clientInformation);
|
||||
+ EntityPlayer entityplayer = playerlist.getPlayerForLogin(this.gameProfile, this.clientInformation, this.player); // CraftBukkit
|
||||
|
||||
playerlist.placeNewPlayer(this.connection, entityplayer, this.createCookie(this.clientInformation));
|
||||
this.connection.resumeInboundAfterProtocolChange();
|
@@ -1,18 +1,18 @@
|
||||
--- a/net/minecraft/server/network/ServerConnection.java
|
||||
+++ b/net/minecraft/server/network/ServerConnection.java
|
||||
@@ -95,16 +95,26 @@
|
||||
@@ -98,16 +98,26 @@
|
||||
|
||||
NetworkManager.configureSerialization(channelpipeline, EnumProtocolDirection.SERVERBOUND);
|
||||
NetworkManager.configureSerialization(channelpipeline, EnumProtocolDirection.SERVERBOUND, (BandwidthDebugMonitor) null);
|
||||
int j = ServerConnection.this.server.getRateLimitPacketsPerSecond();
|
||||
- Object object = j > 0 ? new NetworkManagerServer(j) : new NetworkManager(EnumProtocolDirection.SERVERBOUND);
|
||||
+ NetworkManager object = j > 0 ? new NetworkManagerServer(j) : new NetworkManager(EnumProtocolDirection.SERVERBOUND); // CraftBukkit - decompile error
|
||||
|
||||
ServerConnection.this.connections.add(object);
|
||||
channelpipeline.addLast("packet_handler", (ChannelHandler) object);
|
||||
((NetworkManager) object).setListener(new HandshakeListener(ServerConnection.this.server, (NetworkManager) object));
|
||||
((NetworkManager) object).configurePacketHandler(channelpipeline);
|
||||
((NetworkManager) object).setListenerForServerboundHandshake(new HandshakeListener(ServerConnection.this.server, (NetworkManager) object));
|
||||
}
|
||||
- }).group((EventLoopGroup) lazyinitvar.get()).localAddress(inetaddress, i)).bind().syncUninterruptibly());
|
||||
+ }).group((EventLoopGroup) lazyinitvar.get()).localAddress(inetaddress, i)).option(ChannelOption.AUTO_READ, false).bind().syncUninterruptibly()); // CraftBukkit
|
||||
- }).group(eventloopgroup).localAddress(inetaddress, i)).bind().syncUninterruptibly());
|
||||
+ }).group(eventloopgroup).localAddress(inetaddress, i)).option(ChannelOption.AUTO_READ, false).bind().syncUninterruptibly()); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -3,7 +3,7 @@
|
||||
@@ -27,7 +27,7 @@
|
||||
}
|
||||
|
||||
protected ExpirableListEntry(T t0, JsonObject jsonobject) {
|
||||
protected ExpirableListEntry(@Nullable T t0, JsonObject jsonobject) {
|
||||
- super(t0);
|
||||
+ super(checkExpiry(t0, jsonobject)); // CraftBukkit
|
||||
|
||||
|
@@ -41,12 +41,12 @@
|
||||
JsonObject jsonobject = new JsonObject();
|
||||
|
||||
Objects.requireNonNull(jsonlistentry);
|
||||
@@ -165,7 +166,7 @@
|
||||
JsonListEntry<K> jsonlistentry = this.createEntry(jsonobject);
|
||||
@@ -171,7 +172,7 @@
|
||||
JsonListEntry<K> jsonlistentry = this.createEntry(jsonobject);
|
||||
|
||||
if (jsonlistentry.getUser() != null) {
|
||||
- this.map.put(this.getKeyForUser(jsonlistentry.getUser()), jsonlistentry);
|
||||
+ this.map.put(this.getKeyForUser(jsonlistentry.getUser()), (V) jsonlistentry); // CraftBukkit - decompile error
|
||||
if (jsonlistentry.getUser() != null) {
|
||||
- this.map.put(this.getKeyForUser(jsonlistentry.getUser()), jsonlistentry);
|
||||
+ this.map.put(this.getKeyForUser(jsonlistentry.getUser()), (V) jsonlistentry); // CraftBukkit - decompile error
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Throwable throwable) {
|
||||
} catch (Throwable throwable) {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/players/NameReferencingFileConverter.java
|
||||
+++ b/net/minecraft/server/players/NameReferencingFileConverter.java
|
||||
@@ -28,6 +28,11 @@
|
||||
@@ -27,6 +27,11 @@
|
||||
import net.minecraft.world.level.storage.SavedFile;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
public class NameReferencingFileConverter {
|
||||
|
||||
static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -88,7 +93,7 @@
|
||||
@@ -87,7 +92,7 @@
|
||||
try {
|
||||
gameprofilebanlist.load();
|
||||
} catch (IOException ioexception) {
|
||||
@@ -21,7 +21,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,7 +151,7 @@
|
||||
@@ -145,7 +150,7 @@
|
||||
try {
|
||||
ipbanlist.load();
|
||||
} catch (IOException ioexception) {
|
||||
@@ -30,7 +30,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,7 +192,7 @@
|
||||
@@ -186,7 +191,7 @@
|
||||
try {
|
||||
oplist.load();
|
||||
} catch (IOException ioexception) {
|
||||
@@ -39,7 +39,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,7 +236,7 @@
|
||||
@@ -230,7 +235,7 @@
|
||||
try {
|
||||
whitelist.load();
|
||||
} catch (IOException ioexception) {
|
||||
@@ -48,7 +48,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,6 +359,30 @@
|
||||
@@ -349,6 +354,30 @@
|
||||
File file5 = new File(file, s2 + ".dat");
|
||||
File file6 = new File(file4, s3 + ".dat");
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/net/minecraft/server/players/PlayerList.java
|
||||
@@ -108,6 +108,26 @@
|
||||
@@ -102,6 +102,26 @@
|
||||
import net.minecraft.world.scores.ScoreboardTeamBase;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
public abstract class PlayerList {
|
||||
|
||||
public static final File USERBANLIST_FILE = new File("banned-players.json");
|
||||
@@ -119,14 +139,16 @@
|
||||
@@ -114,14 +134,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;
|
||||
@@ -47,7 +47,7 @@
|
||||
public final WorldNBTStorage playerIo;
|
||||
private boolean doWhiteList;
|
||||
private final LayeredRegistryAccess<RegistryLayer> registries;
|
||||
@@ -138,13 +160,23 @@
|
||||
@@ -132,13 +154,23 @@
|
||||
private static final boolean ALLOW_LOGOUTIVATOR = false;
|
||||
private int sendAllPlayerInfoIn;
|
||||
|
||||
@@ -72,8 +72,8 @@
|
||||
+ // CraftBukkit end
|
||||
this.server = minecraftserver;
|
||||
this.registries = layeredregistryaccess;
|
||||
this.synchronizedRegistries = (new IRegistryCustom.c(RegistrySynchronization.networkedRegistries(layeredregistryaccess))).freeze();
|
||||
@@ -168,9 +200,15 @@
|
||||
this.maxPlayers = i;
|
||||
@@ -161,9 +193,15 @@
|
||||
|
||||
NBTTagCompound nbttagcompound = this.load(entityplayer);
|
||||
ResourceKey resourcekey;
|
||||
@@ -90,9 +90,9 @@
|
||||
Logger logger = PlayerList.LOGGER;
|
||||
|
||||
Objects.requireNonNull(logger);
|
||||
@@ -197,7 +235,8 @@
|
||||
s1 = networkmanager.getRemoteAddress().toString();
|
||||
}
|
||||
@@ -186,7 +224,8 @@
|
||||
entityplayer.setServerLevel(worldserver1);
|
||||
String s1 = networkmanager.getLoggableAddress(this.server.logIPs());
|
||||
|
||||
- PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ({}, {}, {})", new Object[]{entityplayer.getName().getString(), s1, entityplayer.getId(), entityplayer.getX(), entityplayer.getY(), entityplayer.getZ()});
|
||||
+ // CraftBukkit - Moved message to after join
|
||||
@@ -100,15 +100,15 @@
|
||||
WorldData worlddata = worldserver1.getLevelData();
|
||||
|
||||
entityplayer.loadGameTypes(nbttagcompound);
|
||||
@@ -207,6 +246,7 @@
|
||||
boolean flag1 = gamerules.getBoolean(GameRules.RULE_REDUCEDDEBUGINFO);
|
||||
@@ -197,6 +236,7 @@
|
||||
boolean flag2 = gamerules.getBoolean(GameRules.RULE_LIMITED_CRAFTING);
|
||||
|
||||
playerconnection.send(new PacketPlayOutLogin(entityplayer.getId(), worlddata.isHardcore(), entityplayer.gameMode.getGameModeForPlayer(), entityplayer.gameMode.getPreviousGameModeForPlayer(), this.server.levelKeys(), this.synchronizedRegistries, worldserver1.dimensionTypeId(), worldserver1.dimension(), BiomeManager.obfuscateSeed(worldserver1.getSeed()), this.getMaxPlayers(), this.viewDistance, this.simulationDistance, flag1, !flag, worldserver1.isDebug(), worldserver1.isFlat(), entityplayer.getLastDeathLocation(), entityplayer.getPortalCooldown()));
|
||||
playerconnection.send(new PacketPlayOutLogin(entityplayer.getId(), worlddata.isHardcore(), this.server.levelKeys(), this.getMaxPlayers(), this.viewDistance, this.simulationDistance, flag1, !flag, flag2, entityplayer.createCommonSpawnInfo(worldserver1)));
|
||||
+ entityplayer.getBukkitEntity().sendSupportedChannels(); // CraftBukkit
|
||||
playerconnection.send(new ClientboundUpdateEnabledFeaturesPacket(FeatureFlags.REGISTRY.toNames(worldserver1.enabledFeatures())));
|
||||
playerconnection.send(new PacketPlayOutCustomPayload(PacketPlayOutCustomPayload.BRAND, (new PacketDataSerializer(Unpooled.buffer())).writeUtf(this.getServer().getServerModName())));
|
||||
playerconnection.send(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked()));
|
||||
@@ -226,8 +266,10 @@
|
||||
playerconnection.send(new PacketPlayOutAbilities(entityplayer.getAbilities()));
|
||||
playerconnection.send(new PacketPlayOutHeldItemSlot(entityplayer.getInventory().selected));
|
||||
@@ -213,8 +253,10 @@
|
||||
} else {
|
||||
ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.player.joined.renamed", entityplayer.getDisplayName(), s);
|
||||
}
|
||||
@@ -120,7 +120,7 @@
|
||||
playerconnection.teleport(entityplayer.getX(), entityplayer.getY(), entityplayer.getZ(), entityplayer.getYRot(), entityplayer.getXRot());
|
||||
ServerPing serverping = this.server.getStatus();
|
||||
|
||||
@@ -235,13 +277,64 @@
|
||||
@@ -222,13 +264,64 @@
|
||||
entityplayer.sendServerStatus(serverping);
|
||||
}
|
||||
|
||||
@@ -186,10 +186,10 @@
|
||||
+
|
||||
+ worldserver1 = entityplayer.serverLevel(); // CraftBukkit - Update in case join event changed it
|
||||
+ // CraftBukkit end
|
||||
this.server.getServerResourcePack().ifPresent((minecraftserver_serverresourcepackinfo) -> {
|
||||
entityplayer.sendTexturePack(minecraftserver_serverresourcepackinfo.url(), minecraftserver_serverresourcepackinfo.hash(), minecraftserver_serverresourcepackinfo.isRequired(), minecraftserver_serverresourcepackinfo.prompt());
|
||||
});
|
||||
@@ -255,8 +348,11 @@
|
||||
Iterator iterator = entityplayer.getActiveEffects().iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
@@ -239,8 +332,11 @@
|
||||
|
||||
if (nbttagcompound != null && nbttagcompound.contains("RootVehicle", 10)) {
|
||||
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("RootVehicle");
|
||||
@@ -203,7 +203,7 @@
|
||||
});
|
||||
|
||||
if (entity != null) {
|
||||
@@ -299,6 +395,8 @@
|
||||
@@ -283,6 +379,8 @@
|
||||
}
|
||||
|
||||
entityplayer.initInventoryMenu();
|
||||
@@ -212,7 +212,7 @@
|
||||
}
|
||||
|
||||
public void updateEntireScoreboard(ScoreboardServer scoreboardserver, EntityPlayer entityplayer) {
|
||||
@@ -331,30 +429,31 @@
|
||||
@@ -319,30 +417,31 @@
|
||||
}
|
||||
|
||||
public void addWorldborderListener(WorldServer worldserver) {
|
||||
@@ -249,7 +249,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -382,14 +481,15 @@
|
||||
@@ -370,14 +469,15 @@
|
||||
}
|
||||
|
||||
protected void save(EntityPlayer entityplayer) {
|
||||
@@ -267,7 +267,7 @@
|
||||
|
||||
if (advancementdataplayer != null) {
|
||||
advancementdataplayer.save();
|
||||
@@ -397,10 +497,24 @@
|
||||
@@ -385,10 +485,24 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -293,7 +293,7 @@
|
||||
this.save(entityplayer);
|
||||
if (entityplayer.isPassenger()) {
|
||||
Entity entity = entityplayer.getRootVehicle();
|
||||
@@ -424,18 +538,66 @@
|
||||
@@ -412,18 +526,66 @@
|
||||
|
||||
if (entityplayer1 == entityplayer) {
|
||||
this.playersByUUID.remove(uuid);
|
||||
@@ -333,7 +333,7 @@
|
||||
|
||||
- if (this.bans.isBanned(gameprofile)) {
|
||||
+ // Moved from processLogin
|
||||
+ UUID uuid = UUIDUtil.getOrCreatePlayerUUID(gameprofile);
|
||||
+ UUID uuid = gameprofile.getId();
|
||||
+ List<EntityPlayer> list = Lists.newArrayList();
|
||||
+
|
||||
+ EntityPlayer entityplayer;
|
||||
@@ -358,7 +358,7 @@
|
||||
+ // depending on the outcome.
|
||||
+ SocketAddress socketaddress = loginlistener.connection.getRemoteAddress();
|
||||
+
|
||||
+ EntityPlayer entity = new EntityPlayer(this.server, this.server.getLevel(World.OVERWORLD), gameprofile);
|
||||
+ EntityPlayer entity = new EntityPlayer(this.server, this.server.getLevel(World.OVERWORLD), gameprofile, ClientInformation.createDefault());
|
||||
+ Player player = entity.getBukkitEntity();
|
||||
+ PlayerLoginEvent event = new PlayerLoginEvent(player, loginlistener.connection.hostname, ((java.net.InetSocketAddress) socketaddress).getAddress());
|
||||
+
|
||||
@@ -366,7 +366,7 @@
|
||||
GameProfileBanEntry gameprofilebanentry = (GameProfileBanEntry) this.bans.get(gameprofile);
|
||||
|
||||
ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.disconnect.banned.reason", gameprofilebanentry.getReason());
|
||||
@@ -443,10 +605,12 @@
|
||||
@@ -431,10 +593,12 @@
|
||||
ichatmutablecomponent.append((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.banned.expiration", PlayerList.BAN_DATE_FORMAT.format(gameprofilebanentry.getExpires())));
|
||||
}
|
||||
|
||||
@@ -382,7 +382,7 @@
|
||||
IpBanEntry ipbanentry = this.ipBans.get(socketaddress);
|
||||
|
||||
ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.disconnect.banned_ip.reason", ipbanentry.getReason());
|
||||
@@ -454,13 +618,25 @@
|
||||
@@ -442,17 +606,32 @@
|
||||
ichatmutablecomponent.append((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.banned_ip.expiration", PlayerList.BAN_DATE_FORMAT.format(ipbanentry.getExpires())));
|
||||
}
|
||||
|
||||
@@ -405,18 +405,27 @@
|
||||
+ return entity;
|
||||
}
|
||||
|
||||
- public EntityPlayer getPlayerForLogin(GameProfile gameprofile) {
|
||||
+ public EntityPlayer getPlayerForLogin(GameProfile gameprofile, EntityPlayer player) { // CraftBukkit - added EntityPlayer
|
||||
+ /* CraftBukkit startMoved up
|
||||
UUID uuid = UUIDUtil.getOrCreatePlayerUUID(gameprofile);
|
||||
List<EntityPlayer> list = Lists.newArrayList();
|
||||
- public EntityPlayer getPlayerForLogin(GameProfile gameprofile, ClientInformation clientinformation) {
|
||||
- return new EntityPlayer(this.server, this.server.overworld(), gameprofile, clientinformation);
|
||||
+ // CraftBukkit start - added EntityPlayer
|
||||
+ public EntityPlayer getPlayerForLogin(GameProfile gameprofile, ClientInformation clientinformation, EntityPlayer player) {
|
||||
+ player.updateOptions(clientinformation);
|
||||
+ return player;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
@@ -487,14 +663,24 @@
|
||||
- public boolean disconnectAllPlayersWithProfile(GameProfile gameprofile) {
|
||||
+ public boolean disconnectAllPlayersWithProfile(GameProfile gameprofile, EntityPlayer player) { // CraftBukkit - added EntityPlayer
|
||||
+ /* CraftBukkit startMoved up
|
||||
UUID uuid = gameprofile.getId();
|
||||
Set<EntityPlayer> set = Sets.newIdentityHashSet();
|
||||
Iterator iterator = this.players.iterator();
|
||||
@@ -480,14 +659,24 @@
|
||||
}
|
||||
|
||||
return new EntityPlayer(this.server, this.server.overworld(), gameprofile);
|
||||
return !set.isEmpty();
|
||||
+ */
|
||||
+ return player;
|
||||
+ return player == null;
|
||||
+ // CraftBukkit end
|
||||
+ }
|
||||
+
|
||||
@@ -437,10 +446,10 @@
|
||||
WorldServer worldserver = this.server.getLevel(entityplayer.getRespawnDimension());
|
||||
Optional optional;
|
||||
|
||||
@@ -506,6 +692,11 @@
|
||||
@@ -499,6 +688,11 @@
|
||||
|
||||
WorldServer worldserver1 = worldserver != null && optional.isPresent() ? worldserver : this.server.overworld();
|
||||
EntityPlayer entityplayer1 = new EntityPlayer(this.server, worldserver1, entityplayer.getGameProfile());
|
||||
EntityPlayer entityplayer1 = new EntityPlayer(this.server, worldserver1, entityplayer.getGameProfile(), entityplayer.clientInformation());
|
||||
+ // */
|
||||
+ EntityPlayer entityplayer1 = entityplayer;
|
||||
+ org.bukkit.World fromWorld = entityplayer.getBukkitEntity().getWorld();
|
||||
@@ -449,7 +458,7 @@
|
||||
|
||||
entityplayer1.connection = entityplayer.connection;
|
||||
entityplayer1.restoreFrom(entityplayer, flag);
|
||||
@@ -521,50 +712,112 @@
|
||||
@@ -514,28 +708,66 @@
|
||||
|
||||
boolean flag2 = false;
|
||||
|
||||
@@ -521,27 +530,23 @@
|
||||
+ location.setWorld(worldserver.getWorld());
|
||||
}
|
||||
+ WorldServer worldserver1 = ((CraftWorld) location.getWorld()).getHandle();
|
||||
+ entityplayer1.spawnIn(worldserver1);
|
||||
+ entityplayer1.unsetRemoved();
|
||||
+ entityplayer1.setShiftKeyDown(false);
|
||||
+ entityplayer1.forceSetPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
||||
+ // CraftBukkit end
|
||||
|
||||
- while (!worldserver1.noCollision((Entity) entityplayer1) && entityplayer1.getY() < (double) worldserver1.getMaxBuildHeight()) {
|
||||
+ while (avoidSuffocation && !worldserver1.noCollision((Entity) entityplayer1) && entityplayer1.getY() < (double) worldserver1.getMaxBuildHeight()) {
|
||||
+ // CraftBukkit end
|
||||
entityplayer1.setPos(entityplayer1.getX(), entityplayer1.getY() + 1.0D, entityplayer1.getZ());
|
||||
}
|
||||
|
||||
int i = flag ? 1 : 0;
|
||||
- WorldData worlddata = entityplayer1.level().getLevelData();
|
||||
+ // CraftBukkit start
|
||||
+ WorldData worlddata = worldserver1.getLevelData();
|
||||
+ entityplayer1.connection.send(new PacketPlayOutRespawn(worldserver1.dimensionTypeId(), worldserver1.dimension(), BiomeManager.obfuscateSeed(worldserver1.getSeed()), entityplayer1.gameMode.getGameModeForPlayer(), entityplayer1.gameMode.getPreviousGameModeForPlayer(), worldserver1.isDebug(), worldserver1.isFlat(), (byte) i, entityplayer1.getLastDeathLocation(), entityplayer1.getPortalCooldown()));
|
||||
+ entityplayer1.spawnIn(worldserver1);
|
||||
+ entityplayer1.unsetRemoved();
|
||||
+ entityplayer1.connection.teleport(CraftLocation.toBukkit(entityplayer1.position(), worldserver1.getWorld(), entityplayer1.getYRot(), entityplayer1.getXRot()));
|
||||
+ entityplayer1.setShiftKeyDown(false);
|
||||
@@ -544,21 +776,43 @@
|
||||
WorldData worlddata = worldserver2.getLevelData();
|
||||
|
||||
- entityplayer1.connection.send(new PacketPlayOutRespawn(entityplayer1.level().dimensionTypeId(), entityplayer1.level().dimension(), BiomeManager.obfuscateSeed(entityplayer1.serverLevel().getSeed()), entityplayer1.gameMode.getGameModeForPlayer(), entityplayer1.gameMode.getPreviousGameModeForPlayer(), entityplayer1.level().isDebug(), entityplayer1.serverLevel().isFlat(), (byte) i, entityplayer1.getLastDeathLocation(), entityplayer1.getPortalCooldown()));
|
||||
entityplayer1.connection.send(new PacketPlayOutRespawn(entityplayer1.createCommonSpawnInfo(worldserver2), (byte) i));
|
||||
- entityplayer1.connection.teleport(entityplayer1.getX(), entityplayer1.getY(), entityplayer1.getZ(), entityplayer1.getYRot(), entityplayer1.getXRot());
|
||||
+ // entityplayer1.connection.teleport(entityplayer1.getX(), entityplayer1.getY(), entityplayer1.getZ(), entityplayer1.getYRot(), entityplayer1.getXRot());
|
||||
+ entityplayer1.connection.teleport(CraftLocation.toBukkit(entityplayer1.position(), worldserver2.getWorld(), entityplayer1.getYRot(), entityplayer1.getXRot())); // CraftBukkit
|
||||
entityplayer1.connection.send(new PacketPlayOutSpawnPosition(worldserver1.getSharedSpawnPos(), worldserver1.getSharedSpawnAngle()));
|
||||
entityplayer1.connection.send(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked()));
|
||||
entityplayer1.connection.send(new PacketPlayOutExperience(entityplayer1.experienceProgress, entityplayer1.totalExperience, entityplayer1.experienceLevel));
|
||||
@@ -570,13 +575,13 @@
|
||||
+
|
||||
+ // Fire advancement trigger
|
||||
+ entityplayer.triggerDimensionChangeTriggers(((CraftWorld) fromWorld).getHandle());
|
||||
|
||||
+
|
||||
+ // Don't fire on respawn
|
||||
+ if (fromWorld != location.getWorld()) {
|
||||
+ PlayerChangedWorldEvent event = new PlayerChangedWorldEvent(entityplayer.getBukkitEntity(), fromWorld);
|
||||
+ server.server.getPluginManager().callEvent(event);
|
||||
+ }
|
||||
+
|
||||
|
||||
+ // Save player file again if they were disconnected
|
||||
+ if (entityplayer.connection.isDisconnected()) {
|
||||
+ this.save(entityplayer);
|
||||
@@ -585,7 +590,7 @@
|
||||
return entityplayer1;
|
||||
}
|
||||
|
||||
@@ -577,7 +830,18 @@
|
||||
@@ -571,7 +825,18 @@
|
||||
|
||||
public void tick() {
|
||||
if (++this.sendAllPlayerInfoIn > 600) {
|
||||
@@ -605,7 +610,7 @@
|
||||
this.sendAllPlayerInfoIn = 0;
|
||||
}
|
||||
|
||||
@@ -594,6 +858,25 @@
|
||||
@@ -588,6 +853,25 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -631,7 +636,7 @@
|
||||
public void broadcastAll(Packet<?> packet, ResourceKey<World> resourcekey) {
|
||||
Iterator iterator = this.players.iterator();
|
||||
|
||||
@@ -672,7 +955,7 @@
|
||||
@@ -666,7 +950,7 @@
|
||||
}
|
||||
|
||||
public void deop(GameProfile gameprofile) {
|
||||
@@ -640,7 +645,7 @@
|
||||
EntityPlayer entityplayer = this.getPlayer(gameprofile.getId());
|
||||
|
||||
if (entityplayer != null) {
|
||||
@@ -696,6 +979,7 @@
|
||||
@@ -690,6 +974,7 @@
|
||||
entityplayer.connection.send(new PacketPlayOutEntityStatus(entityplayer, b0));
|
||||
}
|
||||
|
||||
@@ -648,7 +653,7 @@
|
||||
this.server.getCommands().sendCommands(entityplayer);
|
||||
}
|
||||
|
||||
@@ -728,6 +1012,12 @@
|
||||
@@ -722,6 +1007,12 @@
|
||||
for (int i = 0; i < this.players.size(); ++i) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) this.players.get(i);
|
||||
|
||||
@@ -661,7 +666,7 @@
|
||||
if (entityplayer != entityhuman && entityplayer.level().dimension() == resourcekey) {
|
||||
double d4 = d0 - entityplayer.getX();
|
||||
double d5 = d1 - entityplayer.getY();
|
||||
@@ -767,23 +1057,35 @@
|
||||
@@ -761,23 +1052,35 @@
|
||||
public void reloadWhiteList() {}
|
||||
|
||||
public void sendLevelInfo(EntityPlayer entityplayer, WorldServer worldserver) {
|
||||
@@ -702,7 +707,7 @@
|
||||
}
|
||||
|
||||
public int getPlayerCount() {
|
||||
@@ -839,12 +1141,22 @@
|
||||
@@ -833,12 +1136,22 @@
|
||||
}
|
||||
|
||||
public void removeAll() {
|
||||
@@ -727,7 +732,7 @@
|
||||
public void broadcastSystemMessage(IChatBaseComponent ichatbasecomponent, boolean flag) {
|
||||
this.broadcastSystemMessage(ichatbasecomponent, (entityplayer) -> {
|
||||
return ichatbasecomponent;
|
||||
@@ -902,16 +1214,23 @@
|
||||
@@ -896,16 +1209,23 @@
|
||||
return playerchatmessage.hasSignature() && !playerchatmessage.hasExpiredServer(Instant.now());
|
||||
}
|
||||
|
||||
@@ -755,7 +760,7 @@
|
||||
Path path = file2.toPath();
|
||||
|
||||
if (FileUtils.isPathNormalized(path) && FileUtils.isPathPortable(path) && path.startsWith(file.getPath()) && file2.isFile()) {
|
||||
@@ -920,7 +1239,7 @@
|
||||
@@ -914,7 +1234,7 @@
|
||||
}
|
||||
|
||||
serverstatisticmanager = new ServerStatisticManager(this.server, file1);
|
||||
@@ -764,7 +769,7 @@
|
||||
}
|
||||
|
||||
return serverstatisticmanager;
|
||||
@@ -928,13 +1247,13 @@
|
||||
@@ -922,13 +1242,13 @@
|
||||
|
||||
public AdvancementDataPlayer getPlayerAdvancements(EntityPlayer entityplayer) {
|
||||
UUID uuid = entityplayer.getUUID();
|
||||
@@ -780,7 +785,7 @@
|
||||
}
|
||||
|
||||
advancementdataplayer.setPlayer(entityplayer);
|
||||
@@ -985,13 +1304,20 @@
|
||||
@@ -979,13 +1299,20 @@
|
||||
}
|
||||
|
||||
public void reloadResources() {
|
||||
@@ -800,5 +805,5 @@
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
|
||||
this.broadcastAll(new PacketPlayOutTags(TagNetworkSerialization.serializeTagsToNetwork(this.registries)));
|
||||
this.broadcastAll(new ClientboundUpdateTagsPacket(TagNetworkSerialization.serializeTagsToNetwork(this.registries)));
|
||||
PacketPlayOutRecipeUpdate packetplayoutrecipeupdate = new PacketPlayOutRecipeUpdate(this.server.getRecipeManager().getRecipes());
|
||||
|
@@ -5,10 +5,10 @@
|
||||
package net.minecraft.server.players;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -93,7 +94,7 @@
|
||||
@@ -81,7 +82,7 @@
|
||||
}
|
||||
|
||||
public void onProfileLookupFailed(GameProfile gameprofile, Exception exception) {
|
||||
public void onProfileLookupFailed(String s1, Exception exception) {
|
||||
- atomicreference.set((Object) null);
|
||||
+ atomicreference.set(null); // CraftBukkit - decompile error
|
||||
}
|
||||
|
Reference in New Issue
Block a user