Update to Minecraft 1.19

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2022-06-08 02:00:00 +10:00
parent 91d9aa9a89
commit 25f3b50f6b
332 changed files with 3628 additions and 2559 deletions

View File

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

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/CustomFunctionData.java
+++ b/net/minecraft/server/CustomFunctionData.java
@@ -44,7 +44,7 @@
@@ -42,7 +42,7 @@
}
public CommandDispatcher<CommandListenerWrapper> getDispatcher() {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/DispenserRegistry.java
+++ b/net/minecraft/server/DispenserRegistry.java
@@ -33,6 +33,12 @@
@@ -32,6 +32,12 @@
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
import org.slf4j.Logger;
@@ -13,7 +13,7 @@
public class DispenserRegistry {
public static final PrintStream STDOUT = System.out;
@@ -43,6 +49,23 @@
@@ -42,6 +48,23 @@
public static void bootStrap() {
if (!DispenserRegistry.isBootstrapped) {
@@ -37,7 +37,7 @@
DispenserRegistry.isBootstrapped = true;
if (IRegistry.REGISTRY.keySet().isEmpty()) {
throw new IllegalStateException("Unable to load registries");
@@ -60,6 +83,69 @@
@@ -58,6 +81,69 @@
IRegistry.freezeBuiltins();
wrapStreams();
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/Main.java
+++ b/net/minecraft/server/Main.java
@@ -57,6 +57,12 @@
@@ -58,6 +58,12 @@
import net.minecraft.world.level.storage.WorldInfo;
import org.slf4j.Logger;
@@ -13,7 +13,7 @@
public class Main {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -64,8 +70,9 @@
@@ -65,8 +71,9 @@
public Main() {}
@DontObfuscate
@@ -24,7 +24,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");
@@ -90,9 +97,12 @@
@@ -91,9 +98,12 @@
optionparser.printHelpOn(System.err);
return;
}
@@ -38,7 +38,7 @@
JvmProfiler.INSTANCE.start(Environment.SERVER);
}
@@ -100,13 +110,13 @@
@@ -101,13 +111,13 @@
DispenserRegistry.validate();
SystemUtils.startTimerHackThread();
Path path = Paths.get("server.properties");
@@ -54,16 +54,13 @@
Main.LOGGER.info("Initialized '{}' and '{}'", path.toAbsolutePath(), path1.toAbsolutePath());
return;
}
@@ -116,14 +126,15 @@
@@ -117,11 +127,12 @@
return;
}
- File file = new File((String) optionset.valueOf(optionspec9));
+ File file = (File) optionset.valueOf("universe"); // CraftBukkit
YggdrasilAuthenticationService yggdrasilauthenticationservice = new YggdrasilAuthenticationService(Proxy.NO_PROXY);
MinecraftSessionService minecraftsessionservice = yggdrasilauthenticationservice.createMinecraftSessionService();
GameProfileRepository gameprofilerepository = yggdrasilauthenticationservice.createProfileRepository();
UserCache usercache = new UserCache(gameprofilerepository, new File(file, MinecraftServer.USERID_CACHE_FILE.getName()));
Services services = Services.create(new YggdrasilAuthenticationService(Proxy.NO_PROXY), file);
- String s = (String) Optional.ofNullable((String) optionset.valueOf(optionspec10)).orElse(dedicatedserversettings.getProperties().levelName);
+ // CraftBukkit start
+ String s = (String) Optional.ofNullable((String) optionset.valueOf("world")).orElse(dedicatedserversettings.getProperties().levelName);
@@ -73,7 +70,7 @@
WorldInfo worldinfo = convertable_conversionsession.getSummary();
if (worldinfo != null) {
@@ -138,13 +149,32 @@
@@ -136,13 +147,32 @@
}
}
@@ -107,46 +104,46 @@
WorldStem worldstem;
@@ -158,6 +188,12 @@
}, (iresourcemanager, datapackconfiguration) -> {
IRegistryCustom.e iregistrycustom_e = IRegistryCustom.builtinCopy();
DynamicOps<NBTBase> dynamicops = RegistryOps.createAndLoad(DynamicOpsNBT.INSTANCE, iregistrycustom_e, iresourcemanager);
+ // CraftBukkit start
+ config.set(datapackconfiguration);
+ ops.set(dynamicops);
+ return Pair.of(null, iregistrycustom_e.freeze());
+ // CraftBukkit end
+ /*
SaveData savedata = convertable_conversionsession.getDataTag(dynamicops, datapackconfiguration, iregistrycustom_e.allElementsLifecycle());
@@ -155,6 +185,12 @@
return WorldStem.load(worldloader_a, (iresourcemanager, datapackconfiguration1) -> {
IRegistryCustom.e iregistrycustom_e = IRegistryCustom.builtinCopy();
DynamicOps<NBTBase> dynamicops = RegistryOps.createAndLoad(DynamicOpsNBT.INSTANCE, iregistrycustom_e, iresourcemanager);
+ // CraftBukkit start
+ config.set(datapackconfiguration1);
+ ops.set(dynamicops);
+ return Pair.of(null, iregistrycustom_e.freeze());
+ // CraftBukkit end
+ /*
SaveData savedata = convertable_conversionsession.getDataTag(dynamicops, datapackconfiguration1, iregistrycustom_e.allElementsLifecycle());
if (savedata != null) {
@@ -180,6 +216,7 @@
if (savedata != null) {
@@ -177,6 +213,7 @@
return Pair.of(worlddataserver, iregistrycustom_e.freeze());
}
+ */
}, SystemUtils.backgroundExecutor(), Runnable::run).get();
return Pair.of(worlddataserver, iregistrycustom_e.freeze());
}
+ */
}, SystemUtils.backgroundExecutor(), executor);
}).get();
} catch (Exception exception) {
Main.LOGGER.warn("Failed to load datapacks, can't proceed with server load. You can either fix your datapacks or reset to vanilla with --safeMode", exception);
@@ -188,6 +225,7 @@
@@ -184,6 +221,7 @@
return;
}
worldstem.updateGlobals();
+ /*
IRegistryCustom.Dimension iregistrycustom_dimension = worldstem.registryAccess();
dedicatedserversettings.getProperties().getWorldGenSettings(iregistrycustom_dimension);
@@ -200,21 +238,32 @@
@@ -196,21 +234,32 @@
}
convertable_conversionsession.saveDataTag(iregistrycustom_dimension, savedata);
+ */
final DedicatedServer dedicatedserver = (DedicatedServer) MinecraftServer.spin((thread) -> {
- DedicatedServer dedicatedserver1 = new DedicatedServer(thread, convertable_conversionsession, resourcepackrepository, worldstem, dedicatedserversettings, DataConverterRegistry.getDataFixer(), minecraftsessionservice, gameprofilerepository, usercache, WorldLoadListenerLogger::new);
+ DedicatedServer dedicatedserver1 = new DedicatedServer(optionset, config.get(), ops.get(), thread, convertable_conversionsession, resourcepackrepository, worldstem, dedicatedserversettings, DataConverterRegistry.getDataFixer(), minecraftsessionservice, gameprofilerepository, usercache, WorldLoadListenerLogger::new);
- DedicatedServer dedicatedserver1 = new DedicatedServer(thread, convertable_conversionsession, resourcepackrepository, worldstem, dedicatedserversettings, DataConverterRegistry.getDataFixer(), services, WorldLoadListenerLogger::new);
+ DedicatedServer dedicatedserver1 = new DedicatedServer(optionset, config.get(), ops.get(), thread, convertable_conversionsession, resourcepackrepository, worldstem, dedicatedserversettings, DataConverterRegistry.getDataFixer(), services, WorldLoadListenerLogger::new);
+ /*
dedicatedserver1.setSingleplayerName((String) optionset.valueOf(optionspec8));
dedicatedserver1.setSingleplayerProfile(optionset.has(optionspec8) ? new GameProfile((UUID) null, (String) optionset.valueOf(optionspec8)) : null);
dedicatedserver1.setPort((Integer) optionset.valueOf(optionspec11));
dedicatedserver1.setDemo(optionset.has(optionspec2));
dedicatedserver1.setId((String) optionset.valueOf(optionspec12));
@@ -171,7 +168,7 @@
Thread thread = new Thread("Server Shutdown Thread") {
public void run() {
dedicatedserver.halt(true);
@@ -223,6 +272,7 @@
@@ -219,6 +268,7 @@
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(Main.LOGGER));
Runtime.getRuntime().addShutdownHook(thread);
@@ -179,7 +176,7 @@
} catch (Exception exception1) {
Main.LOGGER.error(LogUtils.FATAL_MARKER, "Failed to start the minecraft server", exception1);
}
@@ -230,7 +280,7 @@
@@ -226,7 +276,7 @@
}
public static void forceUpgrade(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, boolean flag, BooleanSupplier booleansupplier, GeneratorSettings generatorsettings) {

View File

@@ -1,12 +1,13 @@
--- a/net/minecraft/server/MinecraftServer.java
+++ b/net/minecraft/server/MinecraftServer.java
@@ -163,6 +163,26 @@
@@ -158,6 +158,28 @@
import org.apache.commons.lang3.Validate;
import org.slf4j.Logger;
+// CraftBukkit start
+import com.mojang.serialization.DynamicOps;
+import com.mojang.serialization.Lifecycle;
+import java.util.Random;
+import jline.console.ConsoleReader;
+import joptsimple.OptionSet;
+import net.minecraft.nbt.DynamicOpsNBT;
@@ -16,6 +17,7 @@
+import net.minecraft.util.datafix.DataConverterRegistry;
+import net.minecraft.world.level.biome.WorldChunkManager;
+import net.minecraft.world.level.levelgen.ChunkGeneratorAbstract;
+import net.minecraft.world.level.levelgen.presets.WorldPresets;
+import net.minecraft.world.level.storage.WorldDataServer;
+import org.bukkit.Bukkit;
+import org.bukkit.craftbukkit.CraftServer;
@@ -27,7 +29,7 @@
public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTask> implements ICommandListener, AutoCloseable {
public static final Logger LOGGER = LogUtils.getLogger();
@@ -255,6 +275,21 @@
@@ -240,6 +262,21 @@
protected SaveData worldData;
private volatile boolean isSaving;
@@ -49,7 +51,7 @@
public static <S extends MinecraftServer> S spin(Function<Thread, S> function) {
AtomicReference<S> atomicreference = new AtomicReference();
Thread thread = new Thread(() -> {
@@ -268,14 +303,14 @@
@@ -253,14 +290,14 @@
thread.setPriority(8);
}
@@ -61,24 +63,33 @@
return s0;
}
- public MinecraftServer(Thread thread, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, WorldStem worldstem, Proxy proxy, DataFixer datafixer, @Nullable MinecraftSessionService minecraftsessionservice, @Nullable GameProfileRepository gameprofilerepository, @Nullable UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) {
+ public MinecraftServer(OptionSet options, DataPackConfiguration datapackconfiguration, DynamicOps<NBTBase> registryreadops, Thread thread, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, WorldStem worldstem, Proxy proxy, DataFixer datafixer, @Nullable MinecraftSessionService minecraftsessionservice, @Nullable GameProfileRepository gameprofilerepository, @Nullable UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) {
- public MinecraftServer(Thread thread, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, WorldStem worldstem, Proxy proxy, DataFixer datafixer, Services services, WorldLoadListenerFactory worldloadlistenerfactory) {
+ public MinecraftServer(OptionSet options, DataPackConfiguration datapackconfiguration, DynamicOps<NBTBase> registryreadops, Thread thread, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, WorldStem worldstem, Proxy proxy, DataFixer datafixer, Services services, WorldLoadListenerFactory worldloadlistenerfactory) {
super("Server");
this.metricsRecorder = InactiveMetricsRecorder.INSTANCE;
this.profiler = this.metricsRecorder.getProfiler();
@@ -287,7 +322,7 @@
@@ -272,7 +309,7 @@
this.status = new ServerPing();
this.random = new Random();
this.random = RandomSource.create();
this.port = -1;
- this.levels = Maps.newLinkedHashMap();
+ this.levels = Maps.newLinkedHashMap(); // CraftBukkit - keep order, k+v already use identity methods
this.running = true;
this.tickTimes = new long[100];
this.resourcePack = "";
@@ -317,13 +352,41 @@
this.structureManager = new DefinedStructureManager(worldstem.resourceManager(), convertable_conversionsession, datafixer);
this.serverThread = thread;
this.executor = SystemUtils.backgroundExecutor();
this.nextTickTime = SystemUtils.getMillis();
@@ -281,7 +318,7 @@
this.frameTimer = new CircularTimer();
this.registryHolder = worldstem.registryAccess();
this.worldData = worldstem.worldData();
- if (!this.worldData.worldGenSettings().dimensions().containsKey(WorldDimension.OVERWORLD)) {
+ if (false && !this.worldData.worldGenSettings().dimensions().containsKey(WorldDimension.OVERWORLD)) { // CraftBukkit - initialised later
throw new IllegalStateException("Missing Overworld dimension data");
} else {
this.proxy = proxy;
@@ -302,13 +339,41 @@
this.serverThread = thread;
this.executor = SystemUtils.backgroundExecutor();
}
+ // CraftBukkit start
+ this.options = options;
+ this.datapackconfiguration = datapackconfiguration;
@@ -118,7 +129,7 @@
ScoreboardServer scoreboardserver1 = this.getScoreboard();
Objects.requireNonNull(scoreboardserver1);
@@ -332,7 +395,7 @@
@@ -317,7 +382,7 @@
protected abstract boolean initServer() throws IOException;
@@ -127,11 +138,10 @@
if (!JvmProfiler.INSTANCE.isRunning()) {
;
}
@@ -340,13 +403,8 @@
@@ -325,12 +390,8 @@
boolean flag = false;
ProfiledDuration profiledduration = JvmProfiler.INSTANCE.onWorldLoadedStarted();
- this.detectBundledResources();
- this.worldData.setModdedInfo(this.getServerModName(), this.getModdedStatus().shouldReportAsModified());
- WorldLoadListener worldloadlistener = this.progressListenerFactory.create(11);
+ loadWorld0(s); // CraftBukkit
@@ -142,7 +152,7 @@
if (profiledduration != null) {
profiledduration.finish();
}
@@ -361,36 +419,206 @@
@@ -345,25 +406,189 @@
}
@@ -158,7 +168,7 @@
+
+ if (this.isDemo()) {
+ worldsettings = MinecraftServer.DEMO_SETTINGS;
+ generatorsettings = GeneratorSettings.demoSettings(iregistrycustom_dimension);
+ generatorsettings = WorldPresets.demoSettings(iregistrycustom_dimension);
+ } else {
+ DedicatedServerProperties dedicatedserverproperties = ((DedicatedServer) this).getProperties();
@@ -171,23 +181,14 @@
- List<MobSpawner> list = ImmutableList.of(new MobSpawnerPhantom(), new MobSpawnerPatrol(), new MobSpawnerCat(), new VillageSiege(), new MobSpawnerTrader(iworlddataserver));
- IRegistry<WorldDimension> iregistry = generatorsettings.dimensions();
- WorldDimension worlddimension = (WorldDimension) iregistry.get(WorldDimension.OVERWORLD);
- Holder holder;
- Object object;
-
- if (worlddimension == null) {
- holder = this.registryAccess().registryOrThrow(IRegistry.DIMENSION_TYPE_REGISTRY).getOrCreateHolder(DimensionManager.OVERWORLD_LOCATION);
- object = GeneratorSettings.makeDefaultOverworld(this.registryAccess(), (new Random()).nextLong());
- } else {
- holder = worlddimension.typeHolder();
- object = worlddimension.generator();
- WorldServer worldserver = new WorldServer(this, this.executor, this.storageSource, iworlddataserver, World.OVERWORLD, worlddimension, worldloadlistener, flag, j, list, true);
+ worldsettings = new WorldSettings(dedicatedserverproperties.levelName, dedicatedserverproperties.gamemode, dedicatedserverproperties.hardcore, dedicatedserverproperties.difficulty, false, new GameRules(), datapackconfiguration);
+ generatorsettings = options.has("bonusChest") ? dedicatedserverproperties.getWorldGenSettings(iregistrycustom_dimension).withBonusChest() : dedicatedserverproperties.getWorldGenSettings(iregistrycustom_dimension);
+ }
+
+ overworldData = new WorldDataServer(worldsettings, generatorsettings, Lifecycle.stable());
}
- WorldServer worldserver = new WorldServer(this, this.executor, this.storageSource, iworlddataserver, World.OVERWORLD, holder, worldloadlistener, (ChunkGenerator) object, flag, j, list, true);
+ }
+
+ GeneratorSettings overworldSettings = overworldData.worldGenSettings();
+ IRegistry<WorldDimension> iregistry = overworldSettings.dimensions();
+ for (WorldDimension worldDimension : iregistry) {
@@ -248,9 +249,7 @@
+ MinecraftServer.LOGGER.info("---- Migration of old " + worldType + " folder failed ----");
+ }
+ }
- this.levels.put(World.OVERWORLD, worldserver);
- WorldPersistentData worldpersistentdata = worldserver.getDataStorage();
+
+ try {
+ worldSession = Convertable.createDefault(server.getWorldContainer().toPath()).createAccess(name, dimensionKey);
+ } catch (IOException ex) {
@@ -268,7 +267,7 @@
+
+ if (this.isDemo()) {
+ worldsettings = MinecraftServer.DEMO_SETTINGS;
+ generatorsettings = GeneratorSettings.demoSettings(iregistrycustom_dimension);
+ generatorsettings = WorldPresets.demoSettings(iregistrycustom_dimension);
+ } else {
+ DedicatedServerProperties dedicatedserverproperties = ((DedicatedServer) this).getProperties();
+
@@ -285,36 +284,19 @@
+ }, worlddata.worldGenSettings());
+ }
+
+ IWorldDataServer iworlddataserver = worlddata;
+ WorldDataServer iworlddataserver = worlddata;
+ GeneratorSettings generatorsettings = worlddata.worldGenSettings();
+ boolean flag = generatorsettings.isDebug();
+ long i = generatorsettings.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(dimensionKey);
+ Holder<DimensionManager> holder;
+ ChunkGenerator chunkgenerator;
+
+ if (worlddimension == null) {
+ holder = this.registryAccess().registryOrThrow(IRegistry.DIMENSION_TYPE_REGISTRY).getOrCreateHolder(DimensionManager.OVERWORLD_LOCATION);
+ chunkgenerator = GeneratorSettings.makeDefaultOverworld(this.registryHolder, (new Random()).nextLong());
+ } else {
+ holder = worlddimension.typeHolder();
+ chunkgenerator = worlddimension.generator();
+ }
+
+ org.bukkit.generator.WorldInfo worldInfo = new org.bukkit.craftbukkit.generator.CraftWorldInfo(iworlddataserver, worldSession, org.bukkit.World.Environment.getEnvironment(dimension), holder.value());
+ org.bukkit.generator.WorldInfo worldInfo = new org.bukkit.craftbukkit.generator.CraftWorldInfo(iworlddataserver, worldSession, org.bukkit.World.Environment.getEnvironment(dimension), worlddimension.typeHolder().value());
+ if (biomeProvider == null && gen != null) {
+ biomeProvider = gen.getDefaultBiomeProvider(worldInfo);
+ }
+
+ if (biomeProvider != null) {
+ WorldChunkManager worldChunkManager = new CustomWorldChunkManager(worldInfo, biomeProvider, registryHolder.ownedRegistryOrThrow(IRegistry.BIOME_REGISTRY));
+ if (chunkgenerator instanceof ChunkGeneratorAbstract cga) {
+ chunkgenerator = new ChunkGeneratorAbstract(cga.structureSets, cga.noises, worldChunkManager, chunkgenerator.ringPlacementSeed, cga.settings);
+ }
+ }
+
+ ResourceKey<World> worldKey = ResourceKey.create(IRegistry.DIMENSION_REGISTRY, dimensionKey.location());
+
+ if (dimensionKey == WorldDimension.OVERWORLD) {
@@ -323,24 +305,26 @@
+
+ WorldLoadListener worldloadlistener = this.progressListenerFactory.create(11);
+
+ world = new WorldServer(this, this.executor, worldSession, iworlddataserver, worldKey, holder, worldloadlistener, chunkgenerator, flag, j, list, true, org.bukkit.World.Environment.getEnvironment(dimension), gen, biomeProvider);
+ world = new WorldServer(this, this.executor, worldSession, iworlddataserver, worldKey, worlddimension, worldloadlistener, flag, j, list, true, org.bukkit.World.Environment.getEnvironment(dimension), gen, biomeProvider);
+ WorldPersistentData worldpersistentdata = world.getDataStorage();
+ this.readScoreboard(worldpersistentdata);
+ this.server.scoreboardManager = new org.bukkit.craftbukkit.scoreboard.CraftScoreboardManager(this, world.getScoreboard());
+ this.commandStorage = new PersistentCommandStorage(worldpersistentdata);
+ } else {
+ WorldLoadListener worldloadlistener = this.progressListenerFactory.create(11);
+ world = new WorldServer(this, this.executor, worldSession, iworlddataserver, worldKey, holder, worldloadlistener, chunkgenerator, flag, j, ImmutableList.of(), true, org.bukkit.World.Environment.getEnvironment(dimension), gen, biomeProvider);
+ world = new WorldServer(this, this.executor, worldSession, iworlddataserver, worldKey, worlddimension, worldloadlistener, flag, j, ImmutableList.of(), true, org.bukkit.World.Environment.getEnvironment(dimension), gen, biomeProvider);
+ }
+
+ worlddata.setModdedInfo(this.getServerModName(), this.getModdedStatus().shouldReportAsModified());
+ this.initWorld(world, worlddata, worldData, worlddata.worldGenSettings());
- this.levels.put(World.OVERWORLD, worldserver);
- WorldPersistentData worldpersistentdata = worldserver.getDataStorage();
+ this.levels.put(world.dimension(), world);
+ this.getPlayerList().addWorldborderListener(world);
- this.readScoreboard(worldpersistentdata);
- this.commandStorage = new PersistentCommandStorage(worldpersistentdata);
+ worlddata.setModdedInfo(this.getServerModName(), this.getModdedStatus().shouldReportAsModified());
+ this.initWorld(world, worlddata, worldData, worlddata.worldGenSettings());
+
+ this.levels.put(world.dimension(), world);
+ this.getPlayerList().addWorldborderListener(world);
+
+ if (worlddata.getCustomBossEvents() != null) {
+ this.getCustomBossEvents().load(worlddata.getCustomBossEvents());
+ }
@@ -373,7 +357,7 @@
if (!iworlddataserver.isInitialized()) {
try {
@@ -414,31 +642,8 @@
@@ -387,29 +612,8 @@
iworlddataserver.setInitialized(true);
}
@@ -390,10 +374,8 @@
-
- if (resourcekey != WorldDimension.OVERWORLD) {
- ResourceKey<World> resourcekey1 = ResourceKey.create(IRegistry.DIMENSION_REGISTRY, resourcekey.location());
- Holder<DimensionManager> holder1 = ((WorldDimension) entry.getValue()).typeHolder();
- ChunkGenerator chunkgenerator = ((WorldDimension) entry.getValue()).generator();
- SecondaryWorldData secondaryworlddata = new SecondaryWorldData(this.worldData, iworlddataserver);
- WorldServer worldserver1 = new WorldServer(this, this.executor, this.storageSource, secondaryworlddata, resourcekey1, holder1, worldloadlistener, chunkgenerator, flag, j, ImmutableList.of(), false);
- WorldServer worldserver1 = new WorldServer(this, this.executor, this.storageSource, secondaryworlddata, resourcekey1, (WorldDimension) entry.getValue(), worldloadlistener, flag, j, ImmutableList.of(), false);
-
- worldborder.addListener(new IWorldBorderListener.a(worldserver1.getWorldBorder()));
- this.levels.put(resourcekey1, worldserver1);
@@ -406,10 +388,10 @@
private static void setInitialSpawn(WorldServer worldserver, IWorldDataServer iworlddataserver, boolean flag, boolean flag1) {
if (flag1) {
@@ -446,6 +651,21 @@
@@ -417,6 +621,21 @@
} else {
ChunkGenerator chunkgenerator = worldserver.getChunkSource().getGenerator();
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(chunkgenerator.climateSampler().findSpawnPosition());
ChunkProviderServer chunkproviderserver = worldserver.getChunkSource();
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(chunkproviderserver.randomState().sampler().findSpawnPosition());
+ // CraftBukkit start
+ if (worldserver.generator != null) {
+ Random rand = new Random(worldserver.getSeed());
@@ -425,10 +407,10 @@
+ }
+ }
+ // CraftBukkit end
int i = chunkgenerator.getSpawnHeight(worldserver);
int i = chunkproviderserver.getGenerator().getSpawnHeight(worldserver);
if (i < worldserver.getMinBuildHeight()) {
@@ -503,8 +723,11 @@
@@ -474,8 +693,11 @@
iworlddataserver.setGameType(EnumGamemode.SPECTATOR);
}
@@ -442,7 +424,7 @@
MinecraftServer.LOGGER.info("Preparing start region for dimension {}", worldserver.dimension().location());
BlockPosition blockposition = worldserver.getSharedSpawnPos();
@@ -514,19 +737,23 @@
@@ -485,19 +707,23 @@
chunkproviderserver.getLightEngine().setTaskPerBatch(500);
this.nextTickTime = SystemUtils.getMillis();
@@ -475,7 +457,7 @@
ForcedChunk forcedchunk = (ForcedChunk) worldserver1.getDataStorage().get(ForcedChunk::load, "chunks");
if (forcedchunk != null) {
@@ -541,11 +768,18 @@
@@ -512,11 +738,18 @@
}
}
@@ -496,8 +478,8 @@
+ // CraftBukkit end
}
protected void detectBundledResources() {
@@ -590,12 +824,16 @@
public EnumGamemode getDefaultGameType() {
@@ -546,12 +779,16 @@
worldserver.save((IProgressUpdate) null, flag1, worldserver.noSave && !flag2);
}
@@ -514,7 +496,7 @@
if (flag1) {
Iterator iterator1 = this.getAllLevels().iterator();
@@ -630,8 +868,29 @@
@@ -586,12 +823,33 @@
this.stopServer();
}
@@ -535,6 +517,10 @@
+ hasStopped = true;
+ }
+ // CraftBukkit end
if (this.metricsRecorder.isRecording()) {
this.cancelRecordingMetrics();
}
MinecraftServer.LOGGER.info("Stopping server");
+ // CraftBukkit start
+ if (this.server != null) {
@@ -544,7 +530,7 @@
if (this.getConnection() != null) {
this.getConnection().stop();
}
@@ -641,6 +900,7 @@
@@ -601,6 +859,7 @@
MinecraftServer.LOGGER.info("Saving players");
this.playerList.saveAll();
this.playerList.removeAll();
@@ -552,28 +538,28 @@
}
MinecraftServer.LOGGER.info("Saving worlds");
@@ -732,9 +992,10 @@
while (this.running) {
long i = SystemUtils.getMillis() - this.nextTickTime;
@@ -696,9 +955,10 @@
while (this.running) {
long i = SystemUtils.getMillis() - this.nextTickTime;
- if (i > 2000L && this.nextTickTime - this.lastOverloadWarning >= 15000L) {
+ if (i > 5000L && this.nextTickTime - this.lastOverloadWarning >= 30000L) { // CraftBukkit
long j = i / 50L;
- if (i > 2000L && this.nextTickTime - this.lastOverloadWarning >= 15000L) {
+ if (i > 5000L && this.nextTickTime - this.lastOverloadWarning >= 30000L) { // CraftBukkit
long j = i / 50L;
+ if (server.getWarnOnOverload()) // CraftBukkit
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;
@@ -745,6 +1006,7 @@
this.debugCommandProfiler = new MinecraftServer.b(SystemUtils.getNanos(), this.tickCount);
}
+ if (server.getWarnOnOverload()) // CraftBukkit
MinecraftServer.LOGGER.warn("Can't keep up! Is the server overloaded? Running {}ms or {} ticks behind", i, j);
this.nextTickTime += j * 50L;
this.lastOverloadWarning = this.nextTickTime;
@@ -709,6 +969,7 @@
this.debugCommandProfiler = new MinecraftServer.TimeProfiler(SystemUtils.getNanos(), this.tickCount);
}
+ MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit
this.nextTickTime += 50L;
this.startMetricsRecordingTick();
this.profiler.push("tick");
@@ -789,6 +1051,12 @@
this.profileCache.clearExecutor();
+ MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit
this.nextTickTime += 50L;
this.startMetricsRecordingTick();
this.profiler.push("tick");
@@ -750,6 +1011,12 @@
this.services.profileCache().clearExecutor();
}
+ // CraftBukkit start - Restore terminal to original settings
@@ -585,7 +571,7 @@
this.onServerExit();
}
@@ -822,8 +1090,15 @@
@@ -783,8 +1050,15 @@
}
private boolean haveTime() {
@@ -602,7 +588,7 @@
protected void waitUntilNextTick() {
this.runAllTasks();
@@ -869,7 +1144,7 @@
@@ -830,7 +1104,7 @@
}
}
@@ -611,7 +597,7 @@
this.getProfiler().incrementCounter("runTask");
super.doRunTask(ticktask);
}
@@ -940,7 +1215,7 @@
@@ -901,7 +1175,7 @@
}
}
@@ -620,7 +606,7 @@
MinecraftServer.LOGGER.debug("Autosave started");
this.profiler.push("save");
this.saveEverything(true, false, false);
@@ -959,22 +1234,39 @@
@@ -920,22 +1194,39 @@
}
public void tickChildren(BooleanSupplier booleansupplier) {
@@ -660,7 +646,7 @@
this.profiler.push("tick");
@@ -1063,7 +1355,7 @@
@@ -1024,7 +1315,7 @@
@DontObfuscate
public String getServerModName() {
@@ -669,7 +655,7 @@
}
public SystemReport fillSystemReport(SystemReport systemreport) {
@@ -1406,11 +1698,11 @@
@@ -1375,11 +1666,11 @@
public CompletableFuture<Void> reloadResources(Collection<String> collection) {
IRegistryCustom.Dimension iregistrycustom_dimension = this.registryAccess();
CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> {
@@ -683,15 +669,15 @@
}, this).thenCompose((immutablelist) -> {
ResourceManager resourcemanager = new ResourceManager(EnumResourcePackType.SERVER_DATA, immutablelist);
@@ -1425,6 +1717,7 @@
}).thenAcceptAsync((minecraftserver_a) -> {
@@ -1394,6 +1685,7 @@
}).thenAcceptAsync((minecraftserver_reloadableresources) -> {
this.resources.close();
this.resources = minecraftserver_a;
this.resources = minecraftserver_reloadableresources;
+ this.server.syncCommands(); // SPIGOT-5884: Lost on reload
this.packRepository.setSelected(collection);
this.worldData.setDataPackConfig(getSelectedPacks(this.packRepository));
this.resources.managers.updateRegistryTags(this.registryAccess());
@@ -1774,7 +2067,7 @@
@@ -1743,7 +2035,7 @@
try {
label51:
{
@@ -700,7 +686,7 @@
try {
arraylist = Lists.newArrayList(NativeModuleLister.listModules());
@@ -1824,6 +2117,22 @@
@@ -1793,6 +2085,22 @@
}
@@ -723,24 +709,3 @@
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) -> {
@@ -1935,8 +2244,10 @@
}
}
- private static record a(IReloadableResourceManager a, DataPackResources b) implements AutoCloseable {
+ // CraftBukkit start - decompile error
+ public static record a(IReloadableResourceManager resourceManager, DataPackResources managers) implements AutoCloseable {
+ /*
final IReloadableResourceManager resourceManager;
final DataPackResources managers;
@@ -1944,6 +2255,8 @@
this.resourceManager = ireloadableresourcemanager;
this.managers = datapackresources;
}
+ */
+ // CraftBukkit end
public void close() {
this.resourceManager.close();

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/bossevents/BossBattleCustom.java
+++ b/net/minecraft/server/bossevents/BossBattleCustom.java
@@ -18,12 +18,27 @@
@@ -17,12 +17,27 @@
import net.minecraft.util.MathHelper;
import net.minecraft.world.BossBattle;

View File

@@ -12,6 +12,6 @@
} else {
- minecraftserver.setDifficulty(enumdifficulty, true);
+ worldServer.serverLevelData.setDifficulty(enumdifficulty); // CraftBukkit
commandlistenerwrapper.sendSuccess(new ChatMessage("commands.difficulty.success", new Object[]{enumdifficulty.getDisplayName()}), true);
commandlistenerwrapper.sendSuccess(IChatBaseComponent.translatable("commands.difficulty.success", enumdifficulty.getDisplayName()), true);
return 0;
}

View File

@@ -8,7 +8,7 @@
+ T t0 = commandlistenerwrapper.getLevel().getGameRules().getRule(gamerules_gamerulekey); // CraftBukkit
t0.setFromArgument(commandcontext, "value");
commandlistenerwrapper.sendSuccess(new ChatMessage("commands.gamerule.set", new Object[]{gamerules_gamerulekey.getId(), t0.toString()}), true);
commandlistenerwrapper.sendSuccess(IChatBaseComponent.translatable("commands.gamerule.set", gamerules_gamerulekey.getId(), t0.toString()), true);
@@ -39,7 +39,7 @@
}
@@ -16,5 +16,5 @@
- T t0 = commandlistenerwrapper.getServer().getGameRules().getRule(gamerules_gamerulekey);
+ T t0 = commandlistenerwrapper.getLevel().getGameRules().getRule(gamerules_gamerulekey); // CraftBukkit
commandlistenerwrapper.sendSuccess(new ChatMessage("commands.gamerule.query", new Object[]{gamerules_gamerulekey.getId(), t0.toString()}), false);
commandlistenerwrapper.sendSuccess(IChatBaseComponent.translatable("commands.gamerule.query", gamerules_gamerulekey.getId(), t0.toString()), false);
return t0.getCommandResult();

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/commands/CommandGive.java
+++ b/net/minecraft/server/commands/CommandGive.java
@@ -59,7 +59,7 @@
@@ -60,7 +60,7 @@
if (flag && itemstack.isEmpty()) {
itemstack.setCount(1);

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/commands/CommandList.java
+++ b/net/minecraft/server/commands/CommandList.java
@@ -37,6 +37,12 @@
@@ -36,6 +36,12 @@
private static int format(CommandListenerWrapper commandlistenerwrapper, Function<EntityPlayer, IChatBaseComponent> function) {
PlayerList playerlist = commandlistenerwrapper.getServer().getPlayerList();
List<EntityPlayer> list = playerlist.getPlayers();
@@ -12,4 +12,4 @@
+ // CraftBukkit end
IChatBaseComponent ichatbasecomponent = ChatComponentUtils.formatList(list, function);
commandlistenerwrapper.sendSuccess(new ChatMessage("commands.list.players", new Object[]{list.size(), playerlist.getMaxPlayers(), ichatbasecomponent}), false);
commandlistenerwrapper.sendSuccess(IChatBaseComponent.translatable("commands.list.players", list.size(), playerlist.getMaxPlayers(), ichatbasecomponent), false);

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/commands/CommandLoot.java
+++ b/net/minecraft/server/commands/CommandLoot.java
@@ -90,7 +90,7 @@
@@ -91,7 +91,7 @@
}
private static <T extends ArgumentBuilder<CommandListenerWrapper, T>> T addTargets(T t0, CommandLoot.c commandloot_c) {
@@ -9,7 +9,7 @@
return entityReplace(ArgumentEntity.getEntities(commandcontext, "entities"), ArgumentInventorySlot.getSlot(commandcontext, "slot"), list.size(), list, commandloot_a);
}).then(commandloot_c.construct(net.minecraft.commands.CommandDispatcher.argument("count", IntegerArgumentType.integer(0)), (commandcontext, list, commandloot_a) -> {
return entityReplace(ArgumentEntity.getEntities(commandcontext, "entities"), ArgumentInventorySlot.getSlot(commandcontext, "slot"), IntegerArgumentType.getInteger(commandcontext, "count"), list, commandloot_a);
@@ -247,6 +247,7 @@
@@ -248,6 +248,7 @@
private static int dropInWorld(CommandListenerWrapper commandlistenerwrapper, Vec3D vec3d, List<ItemStack> list, CommandLoot.a commandloot_a) throws CommandSyntaxException {
WorldServer worldserver = commandlistenerwrapper.getLevel();

View File

@@ -28,8 +28,8 @@
return blockposition.getY() < i && !material.isLiquid() && material != Material.FIRE;
@@ -322,5 +322,12 @@
this.x = MathHelper.nextDouble(random, d0, d2);
this.z = MathHelper.nextDouble(random, d1, d3);
this.x = MathHelper.nextDouble(randomsource, d0, d2);
this.z = MathHelper.nextDouble(randomsource, d1, d3);
}
+
+ // CraftBukkit start - add a version of getBlockState which force loads chunks

View File

@@ -8,4 +8,4 @@
+ if (!worldserver.tryAddFreshEntityWithPassengers(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.COMMAND)) { // CraftBukkit - pass a spawn reason of "COMMAND"
throw CommandSummon.ERROR_DUPLICATE_UUID.create();
} else {
commandlistenerwrapper.sendSuccess(new ChatMessage("commands.summon.success", new Object[]{entity.getDisplayName()}), true);
commandlistenerwrapper.sendSuccess(IChatBaseComponent.translatable("commands.summon.success", entity.getDisplayName()), true);

View File

@@ -12,7 +12,7 @@
+
public class CommandTeleport {
private static final SimpleCommandExceptionType INVALID_POSITION = new SimpleCommandExceptionType(new ChatMessage("commands.teleport.invalidPosition"));
private static final SimpleCommandExceptionType INVALID_POSITION = new SimpleCommandExceptionType(IChatBaseComponent.translatable("commands.teleport.invalidPosition"));
@@ -159,14 +165,29 @@
}

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/server/commands/CommandTime.java
+++ b/net/minecraft/server/commands/CommandTime.java
@@ -9,6 +9,11 @@
import net.minecraft.network.chat.ChatMessage;
import net.minecraft.network.chat.IChatBaseComponent;
import net.minecraft.server.level.WorldServer;
+// CraftBukkit start
@@ -32,7 +32,7 @@
+ // CraftBukkit end
}
commandlistenerwrapper.sendSuccess(new ChatMessage("commands.time.set", new Object[]{i}), true);
commandlistenerwrapper.sendSuccess(IChatBaseComponent.translatable("commands.time.set", i), true);
@@ -60,12 +71,18 @@
}

View File

@@ -43,7 +43,7 @@
- double d0 = commandlistenerwrapper.getServer().overworld().getWorldBorder().getSize();
+ double d0 = commandlistenerwrapper.getLevel().getWorldBorder().getSize(); // CraftBukkit
commandlistenerwrapper.sendSuccess(new ChatMessage("commands.worldborder.get", new Object[]{String.format(Locale.ROOT, "%.0f", d0)}), false);
commandlistenerwrapper.sendSuccess(IChatBaseComponent.translatable("commands.worldborder.get", String.format(Locale.ROOT, "%.0f", d0)), false);
return MathHelper.floor(d0 + 0.5D);
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/net/minecraft/server/dedicated/DedicatedServer.java
@@ -59,6 +59,18 @@
@@ -56,6 +56,18 @@
import net.minecraft.world.level.storage.Convertable;
import org.slf4j.Logger;
@@ -19,20 +19,20 @@
public class DedicatedServer extends MinecraftServer implements IMinecraftServer {
static final Logger LOGGER = LogUtils.getLogger();
@@ -79,8 +91,10 @@
@@ -73,8 +85,10 @@
@Nullable
private final IChatBaseComponent resourcePackPrompt;
private final TextFilter textFilterClient;
- public DedicatedServer(Thread thread, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, WorldStem worldstem, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) {
- super(thread, convertable_conversionsession, resourcepackrepository, worldstem, Proxy.NO_PROXY, datafixer, minecraftsessionservice, gameprofilerepository, usercache, worldloadlistenerfactory);
- public DedicatedServer(Thread thread, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, WorldStem worldstem, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, Services services, WorldLoadListenerFactory worldloadlistenerfactory) {
- super(thread, convertable_conversionsession, resourcepackrepository, worldstem, Proxy.NO_PROXY, datafixer, services, worldloadlistenerfactory);
+ // CraftBukkit start - Signature changed
+ public DedicatedServer(joptsimple.OptionSet options, DataPackConfiguration datapackconfiguration, DynamicOps<NBTBase> registryreadops, Thread thread, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, WorldStem worldstem, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) {
+ super(options, datapackconfiguration, registryreadops, thread, convertable_conversionsession, resourcepackrepository, worldstem, Proxy.NO_PROXY, datafixer, minecraftsessionservice, gameprofilerepository, usercache, worldloadlistenerfactory);
+ public DedicatedServer(joptsimple.OptionSet options, DataPackConfiguration datapackconfiguration, DynamicOps<NBTBase> registryreadops, Thread thread, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, WorldStem worldstem, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, Services services, WorldLoadListenerFactory worldloadlistenerfactory) {
+ super(options, datapackconfiguration, registryreadops, thread, convertable_conversionsession, resourcepackrepository, worldstem, Proxy.NO_PROXY, datafixer, services, worldloadlistenerfactory);
+ // CraftBukkit end
this.settings = dedicatedserversettings;
this.rconConsoleSource = new RemoteControlCommandListener(this);
this.textFilterClient = TextFilter.createFromConfig(dedicatedserversettings.getProperties().textFilteringConfig);
@@ -91,13 +105,44 @@
@@ -84,13 +98,44 @@
public boolean initServer() throws IOException {
Thread thread = new Thread("Server console handler") {
public void run() {
@@ -80,7 +80,7 @@
}
} catch (IOException ioexception) {
DedicatedServer.LOGGER.error("Exception handling console input", ioexception);
@@ -106,6 +151,27 @@
@@ -99,6 +144,27 @@
}
};
@@ -108,7 +108,7 @@
thread.setDaemon(true);
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(DedicatedServer.LOGGER));
thread.start();
@@ -131,7 +197,7 @@
@@ -123,7 +189,7 @@
this.setMotd(dedicatedserverproperties.motd);
super.setPlayerIdleTimeout((Integer) dedicatedserverproperties.playerIdleTimeout.get());
this.setEnforceWhitelist(dedicatedserverproperties.enforceWhitelist);
@@ -117,7 +117,7 @@
DedicatedServer.LOGGER.info("Default game type: {}", dedicatedserverproperties.gamemode);
InetAddress inetaddress = null;
@@ -155,6 +221,12 @@
@@ -147,6 +213,12 @@
return false;
}
@@ -130,7 +130,7 @@
if (!this.usesAuthentication()) {
DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!");
DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware.");
@@ -169,13 +241,13 @@
@@ -161,13 +233,13 @@
if (!NameReferencingFileConverter.serverReadyAfterUserconversion(this)) {
return false;
} else {
@@ -138,7 +138,7 @@
+ // this.setPlayerList(new DedicatedPlayerList(this, this.registryAccess(), this.playerDataStorage)); // CraftBukkit - moved up
long i = SystemUtils.getNanos();
TileEntitySkull.setup(this.getProfileCache(), this.getSessionService(), this);
TileEntitySkull.setup(this.services, this);
UserCache.setUsesAuthentication(this.usesAuthentication());
DedicatedServer.LOGGER.info("Preparing level \"{}\"", this.getLevelIdName());
- this.loadLevel();
@@ -146,7 +146,7 @@
long j = SystemUtils.getNanos() - i;
String s = String.format(Locale.ROOT, "%.3fs", (double) j / 1.0E9D);
@@ -192,6 +264,7 @@
@@ -184,6 +256,7 @@
if (dedicatedserverproperties.enableRcon) {
DedicatedServer.LOGGER.info("Starting remote control listener");
this.rconThread = RemoteControlListener.create(this);
@@ -154,7 +154,7 @@
}
if (this.getMaxTickLength() > 0L) {
@@ -335,6 +408,7 @@
@@ -300,6 +373,7 @@
this.queryThreadGs4.stop();
}
@@ -162,24 +162,24 @@
}
@Override
@@ -356,7 +430,15 @@
@@ -321,7 +395,15 @@
while (!this.consoleInput.isEmpty()) {
ServerCommand servercommand = (ServerCommand) this.consoleInput.remove(0);
- this.getCommands().performCommand(servercommand.source, servercommand.msg);
- this.getCommands().performPrefixedCommand(servercommand.source, servercommand.msg);
+ // CraftBukkit start - ServerCommand for preprocessing
+ ServerCommandEvent event = new ServerCommandEvent(console, servercommand.msg);
+ server.getPluginManager().callEvent(event);
+ if (event.isCancelled()) continue;
+ servercommand = new ServerCommand(event.getCommand(), servercommand.source);
+
+ // this.getCommands().performCommand(servercommand.source, servercommand.msg); // Called in dispatchServerCommand
+ // this.getCommands().performPrefixedCommand(servercommand.source, servercommand.msg); // Called in dispatchServerCommand
+ server.dispatchServerCommand(console, servercommand);
+ // CraftBukkit end
}
}
@@ -566,14 +648,45 @@
@@ -546,14 +628,45 @@
@Override
public String getPluginNames() {
@@ -214,7 +214,7 @@
public String runCommand(String s) {
this.rconConsoleSource.prepareForCommand();
this.executeBlocking(() -> {
- this.getCommands().performCommand(this.rconConsoleSource.createCommandSourceStack(), s);
- this.getCommands().performPrefixedCommand(this.rconConsoleSource.createCommandSourceStack(), s);
+ // CraftBukkit start - fire RemoteServerCommandEvent
+ RemoteServerCommandEvent event = new RemoteServerCommandEvent(remoteConsole, s);
+ server.getPluginManager().callEvent(event);
@@ -227,9 +227,9 @@
});
return this.rconConsoleSource.getCommandResponse();
}
@@ -647,4 +760,15 @@
public IChatBaseComponent getResourcePackPrompt() {
return this.resourcePackPrompt;
@@ -606,4 +719,15 @@
public Optional<MinecraftServer.ServerResourcePackInfo> getServerResourcePack() {
return this.settings.getProperties().serverResourcePackInfo;
}
+
+ // CraftBukkit start

View File

@@ -1,21 +1,22 @@
--- a/net/minecraft/server/dedicated/DedicatedServerProperties.java
+++ b/net/minecraft/server/dedicated/DedicatedServerProperties.java
@@ -13,8 +13,14 @@
import net.minecraft.world.level.EnumGamemode;
import net.minecraft.world.level.levelgen.GeneratorSettings;
@@ -37,10 +37,15 @@
import net.minecraft.world.level.levelgen.structure.StructureSet;
import org.slf4j.Logger;
+// CraftBukkit start
+import joptsimple.OptionSet;
+import net.minecraft.server.dedicated.PropertyManager.EditableProperty;
+// CraftBukkit end
+
public class DedicatedServerProperties extends PropertyManager<DedicatedServerProperties> {
static final Logger LOGGER = LogUtils.getLogger();
private static final Pattern SHA1 = Pattern.compile("^[a-fA-F0-9]{40}$");
+ public final boolean debug = this.get("debug", false); // CraftBukkit
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", "");
@@ -71,8 +77,10 @@
@@ -95,8 +100,10 @@
@Nullable
private GeneratorSettings worldGenSettings;
@@ -28,8 +29,8 @@
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");
@@ -121,13 +129,15 @@
}, "default"));
@@ -147,13 +154,15 @@
this.serverResourcePackInfo = getServerPackInfo(this.get("resource-pack", ""), this.get("resource-pack-sha1", ""), this.getLegacyString("resource-pack-hash"), this.get("require-resource-pack", false), this.get("resource-pack-prompt", ""));
}
- public static DedicatedServerProperties fromFile(Path path) {
@@ -48,24 +49,25 @@
dedicatedserverproperties.getWorldGenSettings(iregistrycustom);
return dedicatedserverproperties;
@@ -141,8 +151,10 @@
return this.worldGenSettings;
}
@@ -222,10 +231,10 @@
}).orElseThrow(() -> {
return new IllegalStateException("Invalid datapack contents: can't find default preset");
});
- Optional optional = Optional.ofNullable(MinecraftKey.tryParse(this.levelType)).map((minecraftkey) -> {
+ Optional<ResourceKey<WorldPreset>> optional = Optional.ofNullable(MinecraftKey.tryParse(this.levelType)).map((minecraftkey) -> { // CraftBukkit - decompile error
return ResourceKey.create(IRegistry.WORLD_PRESET_REGISTRY, minecraftkey);
}).or(() -> {
- return Optional.ofNullable((ResourceKey) DedicatedServerProperties.a.LEGACY_PRESET_NAMES.get(this.levelType));
+ return Optional.ofNullable(DedicatedServerProperties.a.LEGACY_PRESET_NAMES.get(this.levelType)); // CraftBukkit - decompile error
});
- public static record a(String a, JsonObject b, boolean c, String d) {
+ // CraftBukkit start - decompile error
+ public static record a(String levelSeed, JsonObject generatorSettings, boolean generateStructures, String levelType) {
Objects.requireNonNull(iregistry);
@@ -239,7 +248,7 @@
+ /*
private final String levelSeed;
private final JsonObject generatorSettings;
private final boolean generateStructures;
@@ -154,6 +166,8 @@
this.generateStructures = flag;
this.levelType = s1;
}
+ */
+ // CraftBukkit end
if (holder1.is(WorldPresets.FLAT)) {
RegistryOps<JsonElement> registryops = RegistryOps.create(JsonOps.INSTANCE, iregistrycustom);
- DataResult dataresult = GeneratorSettingsFlat.CODEC.parse(new Dynamic(registryops, this.generatorSettings()));
+ DataResult<GeneratorSettingsFlat> dataresult = GeneratorSettingsFlat.CODEC.parse(new Dynamic(registryops, this.generatorSettings())); // CraftBukkit - decompile error
Logger logger = DedicatedServerProperties.LOGGER;
public String levelSeed() {
return this.levelSeed;
Objects.requireNonNull(logger);

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/level/ChunkProviderServer.java
+++ b/net/minecraft/server/level/ChunkProviderServer.java
@@ -83,6 +83,16 @@
@@ -84,6 +84,16 @@
this.clearCache();
}
@@ -17,7 +17,7 @@
@Override
public LightEngineThreaded getLightEngine() {
return this.lightEngine;
@@ -127,7 +137,7 @@
@@ -128,7 +138,7 @@
for (int l = 0; l < 4; ++l) {
if (k == this.lastChunkPos[l] && chunkstatus == this.lastChunkStatus[l]) {
ichunkaccess = this.lastChunk[l];
@@ -26,7 +26,7 @@
return ichunkaccess;
}
}
@@ -175,12 +185,12 @@
@@ -176,12 +186,12 @@
if (playerchunk == null) {
return null;
} else {
@@ -41,7 +41,7 @@
if (ichunkaccess1 != null) {
this.storeInCache(k, ichunkaccess1, ChunkStatus.FULL);
@@ -228,7 +238,15 @@
@@ -229,7 +239,15 @@
int l = 33 + ChunkStatus.getDistance(chunkstatus);
PlayerChunk playerchunk = this.getVisibleChunkIfPresent(k);
@@ -58,7 +58,7 @@
this.distanceManager.addTicket(TicketType.UNKNOWN, chunkcoordintpair, l, chunkcoordintpair);
if (this.chunkAbsent(playerchunk, l)) {
GameProfilerFiller gameprofilerfiller = this.level.getProfiler();
@@ -247,7 +265,7 @@
@@ -248,7 +266,7 @@
}
private boolean chunkAbsent(@Nullable PlayerChunk playerchunk, int i) {
@@ -67,7 +67,7 @@
}
@Override
@@ -314,7 +332,7 @@
@@ -315,7 +333,7 @@
} else if (!this.level.shouldTickBlocksAt(i)) {
return false;
} else {
@@ -76,7 +76,7 @@
return either != null && either.left().isPresent();
}
@@ -327,11 +345,31 @@
@@ -328,11 +346,31 @@
@Override
public void close() throws IOException {
@@ -109,7 +109,7 @@
@Override
public void tick(BooleanSupplier booleansupplier, boolean flag) {
this.level.getProfiler().push("purge");
@@ -363,7 +401,7 @@
@@ -364,7 +402,7 @@
gameprofilerfiller.push("pollingChunks");
int k = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING);
@@ -118,7 +118,7 @@
gameprofilerfiller.push("naturalSpawnCount");
int l = this.distanceManager.getNaturalSpawnChunkCount();
@@ -384,7 +422,7 @@
@@ -385,7 +423,7 @@
}
gameprofilerfiller.popPush("spawnAndTick");
@@ -127,7 +127,7 @@
Collections.shuffle(list);
Iterator iterator1 = list.iterator();
@@ -581,18 +619,26 @@
@@ -586,13 +624,19 @@
}
@Override
@@ -148,19 +148,3 @@
}
}
- private static record a(Chunk a, PlayerChunk b) {
+ // CraftBukkit start - decompile error
+ private static record a(Chunk chunk, PlayerChunk holder) {
+ /*
final Chunk chunk;
final PlayerChunk holder;
@@ -608,5 +654,7 @@
public PlayerChunk holder() {
return this.holder;
}
+ */
+ // CraftBukkit end
}
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/level/EntityPlayer.java
+++ b/net/minecraft/server/level/EntityPlayer.java
@@ -140,6 +140,34 @@
@@ -147,6 +147,34 @@
import net.minecraft.world.scores.criteria.IScoreboardCriteria;
import org.slf4j.Logger;
@@ -35,7 +35,7 @@
public class EntityPlayer extends EntityHuman {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -194,6 +222,21 @@
@@ -201,6 +229,21 @@
public int latency;
public boolean wonGame;
@@ -54,10 +54,10 @@
+ public String kickLeaveMessage = null; // SPIGOT-3034: Forward leave message to PlayerQuitEvent
+ // CraftBukkit end
+
public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile) {
super(worldserver, worldserver.getSharedSpawnPos(), worldserver.getSharedSpawnAngle(), gameprofile);
public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, @Nullable ProfilePublicKey profilepublickey) {
super(worldserver, worldserver.getSharedSpawnPos(), worldserver.getSharedSpawnAngle(), gameprofile, profilepublickey);
this.chatVisibility = EnumChatVisibility.FULL;
@@ -256,12 +299,56 @@
@@ -263,12 +306,56 @@
this.advancements = minecraftserver.getPlayerList().getPlayerAdvancements(this);
this.maxUpStep = 1.0F;
this.fudgeSpawnLocation(worldserver);
@@ -66,8 +66,8 @@
+ this.displayName = this.getScoreboardName();
+ this.bukkitPickUpLoot = true;
+ this.maxHealthCache = this.getMaxHealth();
+ }
+
}
+ // Yes, this doesn't match Vanilla, but it's the best we can do for now.
+ // If this is an issue, PRs are welcome
+ public final BlockPosition getSpawnPoint(WorldServer worldserver) {
@@ -89,7 +89,7 @@
+ long l = k * k;
+ int i1 = l > 2147483647L ? Integer.MAX_VALUE : (int) l;
+ int j1 = this.getCoprime(i1);
+ int k1 = (new Random()).nextInt(i1);
+ int k1 = RandomSource.create().nextInt(i1);
+
+ for (int l1 = 0; l1 < i1; ++l1) {
+ int i2 = (k1 + j1 * l1) % i1;
@@ -104,9 +104,9 @@
+ }
+
+ return blockposition;
}
+ }
+ // CraftBukkit end
+
private void fudgeSpawnLocation(WorldServer worldserver) {
BlockPosition blockposition = worldserver.getSharedSpawnPos();
@@ -115,7 +115,7 @@
int i = Math.max(0, this.server.getSpawnRadius(worldserver));
int j = MathHelper.floor(worldserver.getWorldBorder().getDistanceToBorder((double) blockposition.getX(), (double) blockposition.getZ()));
@@ -319,17 +406,26 @@
@@ -326,17 +413,26 @@
if (nbttagcompound.contains("recipeBook", 10)) {
this.recipeBook.fromNbt(nbttagcompound.getCompound("recipeBook"), this.server.getRecipeManager());
}
@@ -143,7 +143,7 @@
Logger logger = EntityPlayer.LOGGER;
Objects.requireNonNull(logger);
@@ -356,7 +452,20 @@
@@ -363,7 +459,20 @@
Entity entity = this.getRootVehicle();
Entity entity1 = this.getVehicle();
@@ -165,7 +165,7 @@
NBTTagCompound nbttagcompound2 = new NBTTagCompound();
NBTTagCompound nbttagcompound3 = new NBTTagCompound();
@@ -374,7 +483,7 @@
@@ -381,7 +490,7 @@
nbttagcompound.putInt("SpawnZ", this.respawnPosition.getZ());
nbttagcompound.putBoolean("SpawnForced", this.respawnForced);
nbttagcompound.putFloat("SpawnAngle", this.respawnAngle);
@@ -174,13 +174,13 @@
Logger logger = EntityPlayer.LOGGER;
Objects.requireNonNull(logger);
@@ -382,9 +491,33 @@
@@ -389,8 +498,32 @@
nbttagcompound.put("SpawnDimension", nbtbase);
});
}
+ this.getBukkitEntity().setExtraData(nbttagcompound); // CraftBukkit
}
+
+ }
+ // CraftBukkit start - World fallback code, either respawn location or global spawn
+ public void spawnIn(World world) {
@@ -202,13 +202,12 @@
+ this.setPos(position.x(), position.y(), position.z());
+ }
+ this.gameMode.setLevel((WorldServer) world);
+ }
}
+ // CraftBukkit end
+
public void setExperiencePoints(int i) {
float f = (float) this.getXpNeededForNextLevel();
float f1 = (f - 1.0F) / f;
@@ -443,6 +576,11 @@
@@ -450,6 +583,11 @@
@Override
public void tick() {
@@ -220,7 +219,7 @@
this.gameMode.tick();
--this.spawnInvulnerableTime;
if (this.invulnerableTime > 0) {
@@ -498,7 +636,7 @@
@@ -505,7 +643,7 @@
}
if (this.getHealth() != this.lastSentHealth || this.lastSentFood != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) {
@@ -229,7 +228,7 @@
this.lastSentHealth = this.getHealth();
this.lastSentFood = this.foodData.getFoodLevel();
this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F;
@@ -529,6 +667,12 @@
@@ -536,6 +674,12 @@
this.updateScoreForCriteria(IScoreboardCriteria.EXPERIENCE, MathHelper.ceil((float) this.lastRecordedExperience));
}
@@ -242,7 +241,7 @@
if (this.experienceLevel != this.lastRecordedLevel) {
this.lastRecordedLevel = this.experienceLevel;
this.updateScoreForCriteria(IScoreboardCriteria.LEVEL, MathHelper.ceil((float) this.lastRecordedLevel));
@@ -543,6 +687,20 @@
@@ -550,6 +694,20 @@
CriterionTriggers.LOCATION.trigger(this);
}
@@ -263,7 +262,7 @@
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Ticking player");
CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Player being ticked");
@@ -585,7 +743,8 @@
@@ -592,7 +750,8 @@
}
private void updateScoreForCriteria(IScoreboardCriteria iscoreboardcriteria, int i) {
@@ -273,9 +272,9 @@
scoreboardscore.setScore(i);
});
}
@@ -593,9 +752,47 @@
@Override
@@ -601,9 +760,47 @@
public void die(DamageSource damagesource) {
this.gameEvent(GameEvent.ENTITY_DIE);
boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES);
+ // CraftBukkit start - fire PlayerDeathEvent
+ if (this.isRemoved()) {
@@ -323,7 +322,7 @@
this.connection.send(new ClientboundPlayerCombatKillPacket(this.getCombatTracker(), ichatbasecomponent), (future) -> {
if (!future.isSuccess()) {
@@ -629,12 +826,18 @@
@@ -637,12 +834,18 @@
if (this.level.getGameRules().getBoolean(GameRules.RULE_FORGIVE_DEAD_PLAYERS)) {
this.tellNeutralMobsThatIDied();
}
@@ -346,7 +345,7 @@
EntityLiving entityliving = this.getKillCredit();
if (entityliving != null) {
@@ -671,10 +874,12 @@
@@ -680,10 +883,12 @@
String s = this.getScoreboardName();
String s1 = entity.getScoreboardName();
@@ -361,7 +360,7 @@
} else {
this.awardStat(StatisticList.MOB_KILLS);
}
@@ -692,7 +897,8 @@
@@ -701,7 +906,8 @@
int i = scoreboardteam.getColor().getId();
if (i >= 0 && i < aiscoreboardcriteria.length) {
@@ -371,7 +370,7 @@
}
}
@@ -736,18 +942,20 @@
@@ -745,18 +951,20 @@
}
private boolean isPvpAllowed() {
@@ -395,7 +394,7 @@
} else {
return shapedetectorshape;
}
@@ -756,11 +964,20 @@
@@ -765,11 +973,20 @@
@Nullable
@Override
public Entity changeDimension(WorldServer worldserver) {
@@ -419,7 +418,7 @@
this.unRide();
this.getLevel().removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION);
if (!this.wonGame) {
@@ -771,6 +988,8 @@
@@ -780,6 +997,8 @@
return this;
} else {
@@ -427,8 +426,8 @@
+ /*
WorldData worlddata = worldserver.getLevelData();
this.connection.send(new PacketPlayOutRespawn(worldserver.dimensionTypeRegistration(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), true));
@@ -780,22 +999,52 @@
this.connection.send(new PacketPlayOutRespawn(worldserver.dimensionTypeId(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), true, this.getLastDeathLocation()));
@@ -789,22 +1008,52 @@
playerlist.sendPlayerPermissionLevel(this);
worldserver1.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION);
this.unsetRemoved();
@@ -467,7 +466,7 @@
+ if (true) { // CraftBukkit
+ this.isChangingDimension = true; // CraftBukkit - Set teleport invulnerability only if player changing worlds
+
+ this.connection.send(new PacketPlayOutRespawn(worldserver.dimensionTypeRegistration(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), true));
+ this.connection.send(new PacketPlayOutRespawn(worldserver.dimensionTypeId(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), true, this.getLastDeathLocation()));
+ this.connection.send(new PacketPlayOutServerDifficulty(this.level.getDifficulty(), this.level.getLevelData().isDifficultyLocked()));
+ PlayerList playerlist = this.server.getPlayerList();
+
@@ -487,7 +486,7 @@
worldserver1.getProfiler().pop();
this.triggerDimensionChangeTriggers(worldserver1);
this.connection.send(new PacketPlayOutAbilities(this.getAbilities()));
@@ -813,12 +1062,31 @@
@@ -822,12 +1071,31 @@
this.lastSentExp = -1;
this.lastSentHealth = -1.0F;
this.lastSentFood = -1;
@@ -519,7 +518,7 @@
private void createEndPlatform(WorldServer worldserver, BlockPosition blockposition) {
BlockPosition.MutableBlockPosition blockposition_mutableblockposition = blockposition.mutable();
@@ -835,17 +1103,17 @@
@@ -844,17 +1112,17 @@
}
@Override
@@ -542,21 +541,21 @@
}
return optional1;
@@ -855,13 +1123,21 @@
@@ -864,13 +1132,21 @@
public void triggerDimensionChangeTriggers(WorldServer worldserver) {
ResourceKey<World> resourcekey = worldserver.dimension();
ResourceKey<World> resourcekey1 = this.level.dimension();
+ // CraftBukkit start
+ ResourceKey<World> maindimensionkey = CraftDimensionUtil.getMainDimensionKey(worldserver);
+ ResourceKey<World> maindimensionkey1 = CraftDimensionUtil.getMainDimensionKey(this.level);
+
- CriterionTriggers.CHANGED_DIMENSION.trigger(this, resourcekey, resourcekey1);
- if (resourcekey == World.NETHER && resourcekey1 == World.OVERWORLD && this.enteredNetherPosition != null) {
+ CriterionTriggers.CHANGED_DIMENSION.trigger(this, maindimensionkey, maindimensionkey1);
+ if (maindimensionkey != resourcekey || maindimensionkey1 != resourcekey1) {
+ CriterionTriggers.CHANGED_DIMENSION.trigger(this, resourcekey, resourcekey1);
+ }
- CriterionTriggers.CHANGED_DIMENSION.trigger(this, resourcekey, resourcekey1);
- if (resourcekey == World.NETHER && resourcekey1 == World.OVERWORLD && this.enteredNetherPosition != null) {
+
+ if (maindimensionkey == World.NETHER && maindimensionkey1 == World.OVERWORLD && this.enteredNetherPosition != null) {
+ // CraftBukkit end
CriterionTriggers.NETHER_TRAVEL.trigger(this, this.enteredNetherPosition);
@@ -567,7 +566,7 @@
this.enteredNetherPosition = null;
}
@@ -878,12 +1154,10 @@
@@ -887,12 +1163,10 @@
this.containerMenu.broadcastChanges();
}
@@ -583,7 +582,7 @@
return Either.left(EntityHuman.EnumBedResult.NOT_POSSIBLE_HERE);
} else if (!this.bedInRange(blockposition, enumdirection)) {
return Either.left(EntityHuman.EnumBedResult.TOO_FAR_AWAY);
@@ -907,7 +1181,36 @@
@@ -916,7 +1190,36 @@
}
}
@@ -621,7 +620,7 @@
this.awardStat(StatisticList.SLEEP_IN_BED);
CriterionTriggers.SLEPT_IN_BED.trigger(this);
});
@@ -920,9 +1223,8 @@
@@ -929,9 +1232,8 @@
return either;
}
}
@@ -632,7 +631,7 @@
}
@Override
@@ -949,6 +1251,24 @@
@@ -958,6 +1260,24 @@
@Override
public void stopSleepInBed(boolean flag, boolean flag1) {
@@ -657,7 +656,7 @@
if (this.isSleeping()) {
this.getLevel().getChunkSource().broadcastAndSend(this, new PacketPlayOutAnimation(this, 2));
}
@@ -1030,8 +1350,9 @@
@@ -1039,8 +1359,9 @@
this.connection.send(new PacketPlayOutOpenSignEditor(tileentitysign.getBlockPos()));
}
@@ -668,7 +667,7 @@
}
@Override
@@ -1039,13 +1360,35 @@
@@ -1048,13 +1369,35 @@
if (itileinventory == null) {
return OptionalInt.empty();
} else {
@@ -703,8 +702,8 @@
+ // CraftBukkit end
if (container == null) {
if (this.isSpectator()) {
this.displayClientMessage((new ChatMessage("container.spectatorCantOpen")).withStyle(EnumChatFormat.RED), true);
@@ -1053,9 +1396,11 @@
this.displayClientMessage(IChatBaseComponent.translatable("container.spectatorCantOpen").withStyle(EnumChatFormat.RED), true);
@@ -1062,9 +1405,11 @@
return OptionalInt.empty();
} else {
@@ -718,7 +717,7 @@
return OptionalInt.of(this.containerCounter);
}
}
@@ -1068,13 +1413,24 @@
@@ -1077,13 +1422,24 @@
@Override
public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) {
@@ -745,7 +744,7 @@
this.initMenu(this.containerMenu);
}
@@ -1097,6 +1453,7 @@
@@ -1106,6 +1462,7 @@
@Override
public void closeContainer() {
@@ -753,7 +752,7 @@
this.connection.send(new PacketPlayOutCloseWindow(this.containerMenu.containerId));
this.doCloseContainer();
}
@@ -1126,7 +1483,7 @@
@@ -1135,7 +1492,7 @@
@Override
public void awardStat(Statistic<?> statistic, int i) {
this.stats.increment(this, statistic, i);
@@ -762,7 +761,7 @@
scoreboardscore.add(i);
});
}
@@ -1134,7 +1491,7 @@
@@ -1143,7 +1500,7 @@
@Override
public void resetStat(Statistic<?> statistic) {
this.stats.setValue(this, statistic, 0);
@@ -771,7 +770,7 @@
}
@Override
@@ -1150,7 +1507,7 @@
@@ -1159,7 +1516,7 @@
for (int j = 0; j < i; ++j) {
MinecraftKey minecraftkey = aminecraftkey1[j];
@@ -780,24 +779,15 @@
Objects.requireNonNull(list);
optional.ifPresent(list::add);
@@ -1185,7 +1542,16 @@
@@ -1194,6 +1551,7 @@
public void resetSentInfo() {
this.lastSentHealth = -1.0E8F;
+ this.lastSentExp = -1; // CraftBukkit - Added to reset
+ }
+
+ // CraftBukkit start - Support multi-line messages
+ public void sendMessage(UUID uuid, IChatBaseComponent[] ichatbasecomponent) {
+ for (IChatBaseComponent component : ichatbasecomponent) {
+ this.sendMessage(component, (uuid == null) ? SystemUtils.NIL_UUID : uuid);
+ }
}
+ // CraftBukkit end
@Override
public void displayClientMessage(IChatBaseComponent ichatbasecomponent, boolean flag) {
@@ -1240,7 +1606,7 @@
@@ -1249,7 +1607,7 @@
this.lastSentExp = -1;
this.lastSentHealth = -1.0F;
this.lastSentFood = -1;
@@ -806,7 +796,7 @@
this.seenCredits = entityplayer.seenCredits;
this.enteredNetherPosition = entityplayer.enteredNetherPosition;
this.setShoulderEntityLeft(entityplayer.getShoulderEntityLeft());
@@ -1367,7 +1733,20 @@
@@ -1397,7 +1755,20 @@
return s;
}
@@ -827,7 +817,7 @@
this.chatVisibility = packetplayinsettings.chatVisibility();
this.canChatColor = packetplayinsettings.chatColors();
this.textFilteringEnabled = packetplayinsettings.textFilteringEnabled();
@@ -1438,7 +1817,7 @@
@@ -1472,7 +1843,7 @@
this.camera = (Entity) (entity == null ? this : entity);
if (entity1 != this.camera) {
this.connection.send(new PacketPlayOutCamera(this.camera));
@@ -836,7 +826,7 @@
}
}
@@ -1467,7 +1846,7 @@
@@ -1501,7 +1872,7 @@
@Nullable
public IChatBaseComponent getTabListDisplayName() {
@@ -845,7 +835,7 @@
}
@Override
@@ -1488,9 +1867,16 @@
@@ -1522,9 +1893,16 @@
return this.advancements;
}
@@ -862,7 +852,7 @@
if (worldserver == this.level) {
this.connection.teleport(d0, d1, d2, f, f1);
} else {
@@ -1510,6 +1896,9 @@
@@ -1544,6 +1922,9 @@
this.server.getPlayerList().sendLevelInfo(this, worldserver);
this.server.getPlayerList().sendAllPlayerInfo(this);
}
@@ -872,9 +862,9 @@
}
@@ -1668,4 +2057,146 @@
public boolean allowsListing() {
return this.allowsListing;
@@ -1713,4 +2094,146 @@
}
}
+
+ // CraftBukkit start - Add per-player time and weather.

View File

@@ -13,7 +13,7 @@
public class EntityTrackerEntry {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -61,8 +67,12 @@
@@ -59,8 +65,12 @@
private List<Entity> lastPassengers;
private boolean wasRiding;
private boolean wasOnGround;
@@ -27,69 +27,30 @@
this.ap = Vec3D.ZERO;
this.lastPassengers = Collections.emptyList();
this.level = worldserver;
@@ -82,22 +92,22 @@
@@ -88,18 +98,18 @@
if (entity instanceof EntityItemFrame) {
EntityItemFrame entityitemframe = (EntityItemFrame) entity;
if (!list.equals(this.lastPassengers)) {
this.lastPassengers = list;
- this.broadcast.accept(new PacketPlayOutMount(this.entity));
+ this.broadcastAndSend(new PacketPlayOutMount(this.entity)); // CraftBukkit
}
- if (this.tickCount % 10 == 0) {
+ if (true || this.tickCount % 10 == 0) { // CraftBukkit - Moved below, should always enter this block
ItemStack itemstack = entityitemframe.getItem();
- if (this.entity instanceof EntityItemFrame && this.tickCount % 10 == 0) {
+ if (this.entity instanceof EntityItemFrame /*&& this.tickCounter % 10 == 0*/) { // CraftBukkit - Moved below, should always enter this block
EntityItemFrame entityitemframe = (EntityItemFrame) this.entity;
ItemStack itemstack = entityitemframe.getItem();
- if (itemstack.getItem() instanceof ItemWorldMap) {
+ if (this.tickCount % 10 == 0 && itemstack.getItem() instanceof ItemWorldMap) { // CraftBukkit - Moved this.tickCounter % 10 logic here so item frames do not enter the other blocks
Integer integer = ItemWorldMap.getMapId(itemstack);
WorldMap worldmap = ItemWorldMap.getSavedData(integer, this.level);
- if (itemstack.getItem() instanceof ItemWorldMap) {
+ if (this.tickCount % 10 == 0 && itemstack.getItem() instanceof ItemWorldMap) { // CraftBukkit - Moved this.tickCounter % 10 logic here so item frames do not enter the other blocks
Integer integer = ItemWorldMap.getMapId(itemstack);
WorldMap worldmap = ItemWorldMap.getSavedData(integer, this.level);
if (worldmap != null) {
- Iterator iterator = this.level.players().iterator();
+ Iterator<ServerPlayerConnection> iterator = this.trackedPlayers.iterator(); // CraftBukkit
if (worldmap != null) {
- Iterator iterator = this.level.players().iterator();
+ Iterator<ServerPlayerConnection> iterator = this.trackedPlayers.iterator(); // CraftBukkit
while (iterator.hasNext()) {
- EntityPlayer entityplayer = (EntityPlayer) iterator.next();
+ EntityPlayer entityplayer = iterator.next().getPlayer(); // CraftBukkit
while (iterator.hasNext()) {
- EntityPlayer entityplayer = (EntityPlayer) iterator.next();
+ EntityPlayer entityplayer = iterator.next().getPlayer(); // CraftBukkit
worldmap.tickCarriedBy(entityplayer, itemstack);
Packet<?> packet = worldmap.getUpdatePacket(integer, entityplayer);
@@ -140,6 +150,17 @@
boolean flag2 = flag1 || this.tickCount % 60 == 0;
boolean flag3 = Math.abs(i - this.yRotp) >= 1 || Math.abs(j - this.xRotp) >= 1;
+ // CraftBukkit start - Code moved from below
+ if (flag2) {
+ this.updateSentPos();
+ }
+
+ if (flag3) {
+ this.yRotp = i;
+ this.xRotp = j;
+ }
+ // CraftBukkit end
+
if (this.tickCount > 0 || this.entity instanceof EntityArrow) {
long k = PacketPlayOutEntity.entityToPacket(vec3d.x);
long l = PacketPlayOutEntity.entityToPacket(vec3d.y);
@@ -178,6 +199,7 @@
}
this.sendDirtyEntityData();
+ /* CraftBukkit start - Code moved up
if (flag2) {
this.updateSentPos();
}
@@ -186,6 +208,7 @@
this.yRotp = i;
this.xRotp = j;
}
+ // CraftBukkit end */
this.wasRiding = false;
}
@@ -201,7 +224,27 @@
worldmap.tickCarriedBy(entityplayer, itemstack);
Packet<?> packet = worldmap.getUpdatePacket(integer, entityplayer);
@@ -204,7 +214,27 @@
++this.tickCount;
if (this.entity.hurtMarked) {
@@ -118,7 +79,7 @@
this.entity.hurtMarked = false;
}
@@ -216,13 +259,16 @@
@@ -219,13 +249,16 @@
PlayerConnection playerconnection = entityplayer.connection;
Objects.requireNonNull(entityplayer.connection);
@@ -138,7 +99,7 @@
}
Packet<?> packet = this.entity.getAddEntityPacket();
@@ -238,6 +284,12 @@
@@ -241,6 +274,12 @@
if (this.entity instanceof EntityLiving) {
Collection<AttributeModifiable> collection = ((EntityLiving) this.entity).getAttributes().getSyncableAttributes();
@@ -151,7 +112,7 @@
if (!collection.isEmpty()) {
consumer.accept(new PacketPlayOutUpdateAttributes(this.entity.getId(), collection));
}
@@ -269,8 +321,14 @@
@@ -272,8 +311,14 @@
if (!list.isEmpty()) {
consumer.accept(new PacketPlayOutEntityEquipment(this.entity.getId(), list));
}
@@ -166,7 +127,7 @@
if (this.entity instanceof EntityLiving) {
EntityLiving entityliving = (EntityLiving) this.entity;
Iterator iterator = entityliving.getActiveEffects().iterator();
@@ -311,6 +369,11 @@
@@ -314,6 +359,11 @@
Set<AttributeModifiable> set = ((EntityLiving) this.entity).getAttributes().getDirtyAttributes();
if (!set.isEmpty()) {

View File

@@ -76,7 +76,20 @@
if (this.changedBlocksPerSection[i] == null) {
this.hasChangedSections = true;
this.changedBlocksPerSection[i] = new ShortOpenHashSet();
@@ -368,7 +387,7 @@
@@ -182,10 +201,10 @@
}
public void sectionLightChanged(EnumSkyBlock enumskyblock, int i) {
- Either<IChunkAccess, PlayerChunk.Failure> either = (Either) this.getFutureIfPresent(ChunkStatus.FEATURES).getNow((Object) null);
+ Either<IChunkAccess, PlayerChunk.Failure> either = (Either) this.getFutureIfPresent(ChunkStatus.FEATURES).getNow(null); // CraftBukkit - decompile error
if (either != null) {
- IChunkAccess ichunkaccess = (IChunkAccess) either.left().orElse((Object) null);
+ IChunkAccess ichunkaccess = (IChunkAccess) either.left().orElse(null); // CraftBukkit - decompile error
if (ichunkaccess != null) {
ichunkaccess.setUnsaved(true);
@@ -372,7 +391,7 @@
this.pendingFullStateConfirmation = completablefuture1;
completablefuture.thenAccept((either) -> {
either.ifLeft((chunk) -> {
@@ -85,7 +98,7 @@
});
});
}
@@ -385,6 +404,30 @@
@@ -389,6 +408,30 @@
boolean flag1 = this.ticketLevel <= PlayerChunkMap.MAX_CHUNK_DISTANCE;
PlayerChunk.State playerchunk_state = getFullChunkStatus(this.oldTicketLevel);
PlayerChunk.State playerchunk_state1 = getFullChunkStatus(this.ticketLevel);
@@ -116,7 +129,7 @@
if (flag) {
Either<IChunkAccess, PlayerChunk.Failure> either = Either.right(new PlayerChunk.Failure() {
@@ -455,6 +498,26 @@
@@ -459,6 +502,26 @@
this.onLevelChange.onLevelChange(this.pos, this::getQueueLevel, this.ticketLevel, this::setQueueLevel);
this.oldTicketLevel = this.ticketLevel;

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/level/PlayerChunkMap.java
+++ b/net/minecraft/server/level/PlayerChunkMap.java
@@ -98,6 +98,11 @@
@@ -102,6 +102,11 @@
import org.apache.commons.lang3.mutable.MutableObject;
import org.slf4j.Logger;
@@ -12,7 +12,7 @@
public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.e {
private static final byte CHUNK_TYPE_REPLACEABLE = -1;
@@ -139,6 +144,27 @@
@@ -144,6 +149,27 @@
private final Queue<Runnable> unloadQueue;
int viewDistance;
@@ -37,10 +37,10 @@
+ };
+ // CraftBukkit end
+
public PlayerChunkMap(WorldServer worldserver, Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, DefinedStructureManager definedstructuremanager, Executor executor, IAsyncTaskHandler<Runnable> iasynctaskhandler, ILightAccess ilightaccess, ChunkGenerator chunkgenerator, WorldLoadListener worldloadlistener, ChunkStatusUpdateListener chunkstatusupdatelistener, Supplier<WorldPersistentData> supplier, int i, boolean flag) {
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();
@@ -296,9 +322,12 @@
@@ -313,9 +339,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();
@@ -55,7 +55,7 @@
final Either<IChunkAccess, PlayerChunk.Failure> either = (Either) iterator.next();
if (either == null) {
@@ -503,7 +532,7 @@
@@ -520,7 +549,7 @@
private void scheduleUnload(long i, PlayerChunk playerchunk) {
CompletableFuture<IChunkAccess> completablefuture = playerchunk.getChunkToSave();
@@ -64,7 +64,19 @@
CompletableFuture<IChunkAccess> completablefuture1 = playerchunk.getChunkToSave();
if (completablefuture1 != completablefuture) {
@@ -683,7 +712,21 @@
@@ -609,9 +638,9 @@
ProtoChunk protochunk = ChunkRegionLoader.read(this.level, this.poiManager, chunkcoordintpair, (NBTTagCompound) optional.get());
this.markPosition(chunkcoordintpair, protochunk.getStatus().getChunkType());
- return Either.left(protochunk);
+ return Either.<IChunkAccess, PlayerChunk.Failure>left(protochunk); // CraftBukkit - decompile error
} else {
- return Either.left(this.createEmptyChunk(chunkcoordintpair));
+ return Either.<IChunkAccess, PlayerChunk.Failure>left(this.createEmptyChunk(chunkcoordintpair)); // CraftBukkit - decompile error
}
}, this.mainThreadExecutor).exceptionallyAsync((throwable) -> {
return this.handleChunkLoadFailure(throwable, chunkcoordintpair);
@@ -717,7 +746,21 @@
private static void postLoadProtoChunk(WorldServer worldserver, List<NBTTagCompound> list) {
if (!list.isEmpty()) {
@@ -87,7 +99,7 @@
}
}
@@ -782,7 +825,7 @@
@@ -816,7 +859,7 @@
if (!playerchunk.wasAccessibleSinceLastSave()) {
return false;
} else {
@@ -96,7 +108,7 @@
if (!(ichunkaccess instanceof ProtoChunkExtension) && !(ichunkaccess instanceof Chunk)) {
return false;
@@ -944,7 +987,8 @@
@@ -978,7 +1021,8 @@
return ichunkaccess instanceof Chunk ? Optional.of((Chunk) ichunkaccess) : Optional.empty();
});
@@ -106,7 +118,7 @@
return chunk.getBlockEntities().size();
}).orElse(0), tickingtracker.getTicketDebugString(i), tickingtracker.getLevel(i), optional1.map((chunk) -> {
return chunk.getBlockTicks().count();
@@ -957,7 +1001,7 @@
@@ -991,7 +1035,7 @@
private static String printFuture(CompletableFuture<Either<Chunk, PlayerChunk.Failure>> completablefuture) {
try {
@@ -115,16 +127,25 @@
return either != null ? (String) either.map((chunk) -> {
return "done";
@@ -975,7 +1019,7 @@
private NBTTagCompound readChunk(ChunkCoordIntPair chunkcoordintpair) throws IOException {
NBTTagCompound nbttagcompound = this.read(chunkcoordintpair);
@@ -1007,12 +1051,14 @@
- return nbttagcompound == null ? null : this.upgradeChunkTag(this.level.dimension(), this.overworldDataStorage, nbttagcompound, this.generator.getTypeNameForDataFixer());
+ return nbttagcompound == null ? null : this.upgradeChunkTag(this.level.getTypeKey(), this.overworldDataStorage, nbttagcompound, this.generator.getTypeNameForDataFixer(), chunkcoordintpair, level); // CraftBukkit
private CompletableFuture<Optional<NBTTagCompound>> readChunk(ChunkCoordIntPair chunkcoordintpair) {
return this.read(chunkcoordintpair).thenApplyAsync((optional) -> {
- return optional.map(this::upgradeChunkTag);
+ return optional.map((nbttagcompound) -> upgradeChunkTag(nbttagcompound, chunkcoordintpair)); // CraftBukkit
}, SystemUtils.backgroundExecutor());
}
- private NBTTagCompound upgradeChunkTag(NBTTagCompound nbttagcompound) {
- return this.upgradeChunkTag(this.level.dimension(), this.overworldDataStorage, nbttagcompound, this.generator.getTypeNameForDataFixer());
+ // CraftBukkit start
+ private NBTTagCompound upgradeChunkTag(NBTTagCompound nbttagcompound, ChunkCoordIntPair chunkcoordintpair) {
+ return this.upgradeChunkTag(this.level.getTypeKey(), this.overworldDataStorage, nbttagcompound, this.generator.getTypeNameForDataFixer(), chunkcoordintpair, level);
+ // CraftBukkit end
}
boolean anyPlayerCloseEnoughForSpawning(ChunkCoordIntPair chunkcoordintpair) {
@@ -1396,7 +1440,7 @@
@@ -1433,7 +1479,7 @@
public final Set<ServerPlayerConnection> seenBy = Sets.newIdentityHashSet();
public EntityTracker(Entity entity, int i, int j, boolean flag) {
@@ -132,15 +153,8 @@
+ this.serverEntity = new EntityTrackerEntry(PlayerChunkMap.this.level, entity, j, flag, this::broadcast, seenBy); // CraftBukkit
this.entity = entity;
this.range = i;
this.lastSectionPos = SectionPosition.of(entity);
@@ -1449,12 +1493,17 @@
public void updatePlayer(EntityPlayer entityplayer) {
if (entityplayer != this.entity) {
- Vec3D vec3d = entityplayer.position().subtract(this.serverEntity.sentPos());
+ Vec3D vec3d = entityplayer.position().subtract(this.entity.position()); // MC-155077, SPIGOT-5113
double d0 = (double) Math.min(this.getEffectiveRange(), (PlayerChunkMap.this.viewDistance - 1) * 16);
double d1 = vec3d.x * vec3d.x + vec3d.z * vec3d.z;
this.lastSectionPos = SectionPosition.of((EntityAccess) entity);
@@ -1492,6 +1538,11 @@
double d2 = d0 * d0;
boolean flag = d1 <= d2 && this.entity.broadcastToPlayer(entityplayer);

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/server/level/PlayerInteractManager.java
+++ b/net/minecraft/server/level/PlayerInteractManager.java
@@ -26,6 +26,27 @@
import net.minecraft.world.phys.MovingObjectPositionBlock;
import net.minecraft.world.phys.Vec3D;
import org.slf4j.Logger;
+// CraftBukkit start
@@ -60,13 +60,14 @@
IBlockData iblockdata;
if (this.hasDelayedDestroy) {
@@ -152,10 +180,32 @@
@@ -142,11 +170,33 @@
if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.START_DESTROY_BLOCK) {
if (!this.level.mayInteract(this.player, blockposition)) {
+ // CraftBukkit start - fire PlayerInteractEvent
+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, enumdirection, this.player.getInventory().getSelected(), EnumHand.MAIN_HAND);
this.player.connection.send(new PacketPlayOutBlockBreak(blockposition, this.level.getBlockState(blockposition), packetplayinblockdig_enumplayerdigtype, false, "may not interact"));
this.player.connection.send(new PacketPlayOutBlockChange(blockposition, this.level.getBlockState(blockposition)));
this.debugLogging(blockposition, false, j, "may not interact");
+ // Update any tile entity data for this block
+ TileEntity tileentity = level.getBlockEntity(blockposition);
+ if (tileentity != null) {
@@ -91,13 +92,13 @@
+ // CraftBukkit end
+
if (this.isCreative()) {
this.destroyAndAck(blockposition, packetplayinblockdig_enumplayerdigtype, "creative destroy");
this.destroyAndAck(blockposition, j, "creative destroy");
return;
@@ -170,11 +220,43 @@
@@ -162,11 +212,43 @@
float f = 1.0F;
iblockdata1 = this.level.getBlockState(blockposition);
- if (!iblockdata1.isAir()) {
iblockdata = this.level.getBlockState(blockposition);
- if (!iblockdata.isAir()) {
+ // CraftBukkit start - Swings at air do *NOT* exist.
+ if (event.useInteractedBlock() == Event.Result.DENY) {
+ // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door.
@@ -110,9 +111,9 @@
+ } else if (data.getBlock() instanceof BlockTrapdoor) {
+ this.player.connection.send(new PacketPlayOutBlockChange(this.level, blockposition));
+ }
+ } else if (!iblockdata1.isAir()) {
iblockdata1.attack(this.level, blockposition, this.player);
f = iblockdata1.getDestroyProgress(this.player, this.player.level, blockposition);
+ } else if (!iblockdata.isAir()) {
iblockdata.attack(this.level, blockposition, this.player);
f = iblockdata.getDestroyProgress(this.player, this.player.level, blockposition);
}
+ if (event.useItemInHand() == Event.Result.DENY) {
@@ -135,35 +136,27 @@
+ }
+ // CraftBukkit end
+
if (!iblockdata1.isAir() && f >= 1.0F) {
this.destroyAndAck(blockposition, packetplayinblockdig_enumplayerdigtype, "insta mine");
if (!iblockdata.isAir() && f >= 1.0F) {
this.destroyAndAck(blockposition, j, "insta mine");
} else {
@@ -218,13 +300,15 @@
@@ -211,13 +293,15 @@
} else if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.ABORT_DESTROY_BLOCK) {
this.isDestroyingBlock = false;
if (!Objects.equals(this.destroyPos, blockposition)) {
- PlayerInteractManager.LOGGER.warn("Mismatch in destroy block pos: {} {}", this.destroyPos, blockposition);
+ PlayerInteractManager.LOGGER.debug("Mismatch in destroy block pos: {} {}", this.destroyPos, blockposition); // CraftBukkit - SPIGOT-5457 sent by client when interact event cancelled
this.level.destroyBlockProgress(this.player.getId(), this.destroyPos, -1);
this.player.connection.send(new PacketPlayOutBlockBreak(this.destroyPos, this.level.getBlockState(this.destroyPos), packetplayinblockdig_enumplayerdigtype, true, "aborted mismatched destroying"));
this.debugLogging(blockposition, true, j, "aborted mismatched destroying");
}
this.level.destroyBlockProgress(this.player.getId(), blockposition, -1);
this.player.connection.send(new PacketPlayOutBlockBreak(blockposition, this.level.getBlockState(blockposition), packetplayinblockdig_enumplayerdigtype, true, "aborted destroying"));
this.debugLogging(blockposition, true, j, "aborted destroying");
+
+ CraftEventFactory.callBlockDamageAbortEvent(this.player, blockposition, this.player.getInventory().getSelected()); // CraftBukkit
}
}
@@ -234,17 +318,72 @@
if (this.destroyBlock(blockposition)) {
this.player.connection.send(new PacketPlayOutBlockBreak(blockposition, this.level.getBlockState(blockposition), packetplayinblockdig_enumplayerdigtype, true, s));
} else {
- this.player.connection.send(new PacketPlayOutBlockBreak(blockposition, this.level.getBlockState(blockposition), packetplayinblockdig_enumplayerdigtype, false, s));
+ this.player.connection.send(new PacketPlayOutBlockChange(this.level, blockposition)); // CraftBukkit - SPIGOT-5196
}
}
@@ -235,10 +319,65 @@
public boolean destroyBlock(BlockPosition blockposition) {
IBlockData iblockdata = this.level.getBlockState(blockposition);
@@ -195,7 +188,7 @@
+ ItemStack itemstack = this.player.getItemBySlot(EnumItemSlot.MAINHAND);
+
+ if (nmsBlock != null && !event.isCancelled() && !this.isCreative() && this.player.hasCorrectToolForDrops(nmsBlock.defaultBlockState())) {
+ event.setExpToDrop(nmsBlock.getExpDrop(nmsData, this.level, blockposition, itemstack));
+ event.setExpToDrop(nmsBlock.getExpDrop(nmsData, this.level, blockposition, itemstack, true));
+ }
+
+ this.level.getCraftServer().getPluginManager().callEvent(event);
@@ -230,7 +223,7 @@
TileEntity tileentity = this.level.getBlockEntity(blockposition);
Block block = iblockdata.getBlock();
@@ -254,6 +393,10 @@
@@ -248,6 +387,10 @@
} else if (this.player.blockActionRestricted(this.level, blockposition, this.gameModeForPlayer)) {
return false;
} else {
@@ -241,7 +234,7 @@
block.playerWillDestroy(this.level, blockposition, iblockdata, this.player);
boolean flag = this.level.removeBlock(blockposition, false);
@@ -262,19 +405,32 @@
@@ -256,19 +399,32 @@
}
if (this.isCreative()) {
@@ -277,7 +270,7 @@
}
}
}
@@ -316,12 +472,52 @@
@@ -313,12 +469,52 @@
}
}
@@ -330,7 +323,7 @@
if (itileinventory != null) {
entityplayer.openMenu(itileinventory);
@@ -335,7 +531,7 @@
@@ -332,7 +528,7 @@
ItemStack itemstack1 = itemstack.copy();
if (!flag1) {
@@ -339,7 +332,7 @@
if (enuminteractionresult.consumesAction()) {
CriterionTriggers.ITEM_USED_ON_BLOCK.trigger(entityplayer, blockposition, itemstack1);
@@ -343,17 +539,17 @@
@@ -340,17 +536,17 @@
}
}
@@ -360,7 +353,7 @@
}
if (enuminteractionresult1.consumesAction()) {
@@ -361,10 +557,10 @@
@@ -358,10 +554,10 @@
}
return enuminteractionresult1;

View File

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

View File

@@ -1,27 +1,32 @@
--- a/net/minecraft/server/level/WorldServer.java
+++ b/net/minecraft/server/level/WorldServer.java
@@ -150,6 +150,20 @@
@@ -152,6 +152,25 @@
import net.minecraft.world.ticks.TickListServer;
import org.slf4j.Logger;
+// CraftBukkit start
+import net.minecraft.world.entity.monster.EntityDrowned;
+import net.minecraft.world.level.biome.WorldChunkManager;
+import net.minecraft.world.level.dimension.WorldDimension;
+import net.minecraft.world.level.levelgen.ChunkGeneratorAbstract;
+import net.minecraft.world.level.storage.WorldDataServer;
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.WeatherType;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.generator.CustomWorldChunkManager;
+import org.bukkit.craftbukkit.util.CraftNamespacedKey;
+import org.bukkit.craftbukkit.util.WorldUUID;
+import org.bukkit.event.entity.CreatureSpawnEvent;
+import org.bukkit.event.server.MapInitializeEvent;
+import org.bukkit.event.weather.LightningStrikeEvent;
+import org.bukkit.event.world.GenericGameEvent;
+import org.bukkit.event.world.TimeSkipEvent;
+// CraftBukkit end
+
public class WorldServer extends World implements GeneratorAccessSeed {
public static final BlockPosition END_SPAWN_POINT = new BlockPosition(100, 50, 0);
@@ -167,7 +181,7 @@
@@ -169,7 +188,7 @@
final List<EntityPlayer> players;
private final ChunkProviderServer chunkSource;
private final MinecraftServer server;
@@ -30,16 +35,13 @@
final EntityTickList entityTickList;
public final PersistentEntitySectionManager<Entity> entityManager;
public boolean noSave;
@@ -190,9 +204,29 @@
@@ -193,11 +212,28 @@
private final StructureCheck structureCheck;
private final boolean tickTime;
- public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, IWorldDataServer iworlddataserver, ResourceKey<World> resourcekey, Holder<DimensionManager> holder, WorldLoadListener worldloadlistener, ChunkGenerator chunkgenerator, boolean flag, long i, List<MobSpawner> list, boolean flag1) {
- Objects.requireNonNull(minecraftserver);
- super(iworlddataserver, resourcekey, holder, minecraftserver::getProfiler, false, flag, i);
+
- public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, IWorldDataServer iworlddataserver, ResourceKey<World> resourcekey, WorldDimension worlddimension, WorldLoadListener worldloadlistener, boolean flag, long i, List<MobSpawner> list, boolean flag1) {
- Holder holder = worlddimension.typeHolder();
+ // CraftBukkit start
+ private int tickPosition;
+ public final Convertable.ConversionSession convertable;
+ public final UUID uuid;
+
@@ -51,40 +53,49 @@
+ public ResourceKey<WorldDimension> getTypeKey() {
+ return convertable.dimensionType;
+ }
+
+ // Add env and gen to constructor, WorldData -> WorldDataServer
+ public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, IWorldDataServer iworlddataserver, ResourceKey<World> resourcekey, Holder<DimensionManager> holder, WorldLoadListener worldloadlistener, ChunkGenerator chunkgenerator, boolean flag, long i, List<MobSpawner> list, boolean flag1, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) {
- Objects.requireNonNull(minecraftserver);
- super(iworlddataserver, resourcekey, holder, minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates());
+ // Add env and gen to constructor, IWorldDataServer -> WorldDataServer
+ public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, WorldDataServer iworlddataserver, ResourceKey<World> resourcekey, WorldDimension worlddimension, WorldLoadListener worldloadlistener, boolean flag, long i, List<MobSpawner> list, boolean flag1, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) {
+ // Holder holder = worlddimension.typeHolder(); // CraftBukkit - decompile error
+ // Objects.requireNonNull(minecraftserver); // CraftBukkit - decompile error
+ super(iworlddataserver, resourcekey, holder, minecraftserver::getProfiler, false, flag, i, gen, biomeProvider, env);
+ super(iworlddataserver, resourcekey, worlddimension.typeHolder(), minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env);
+ this.pvpMode = minecraftserver.isPvpAllowed();
+ convertable = convertable_conversionsession;
+ uuid = WorldUUID.getUUID(convertable_conversionsession.levelPath.toFile());
+ uuid = WorldUUID.getUUID(convertable_conversionsession.levelDirectory.path().toFile());
+ // CraftBukkit end
this.players = Lists.newArrayList();
this.entityTickList = new EntityTickList();
this.blockTicks = new TickListServer<>(this::isPositionTickingWithEntitiesLoaded, this.getProfilerSupplier());
@@ -204,7 +238,13 @@
this.tickTime = flag1;
this.server = minecraftserver;
@@ -212,6 +248,20 @@
this.customSpawners = list;
- this.serverLevelData = iworlddataserver;
this.serverLevelData = iworlddataserver;
ChunkGenerator chunkgenerator = worlddimension.generator();
+ // CraftBukkit start
+ this.serverLevelData = (WorldDataServer) iworlddataserver;
+ serverLevelData.setWorld(this);
+
+ if (biomeProvider != null) {
+ WorldChunkManager worldChunkManager = new CustomWorldChunkManager(getWorld(), biomeProvider, server.registryHolder.registryOrThrow(IRegistry.BIOME_REGISTRY));
+ if (chunkgenerator instanceof ChunkGeneratorAbstract cga) {
+ chunkgenerator = new ChunkGeneratorAbstract(cga.structureSets, cga.noises, worldChunkManager, cga.settings);
+ }
+ }
+
+ if (gen != null) {
+ chunkgenerator = new org.bukkit.craftbukkit.generator.CustomChunkGenerator(this, chunkgenerator, gen);
+ }
+ // CraftBukkit end
chunkgenerator.ensureStructuresGenerated();
boolean flag2 = minecraftserver.forceSynchronousWrites();
DataFixer datafixer = minecraftserver.getFixerUpper();
@@ -236,14 +276,15 @@
EntityPersistentStorage<Entity> entitypersistentstorage = new EntityStorage(this, convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, minecraftserver);
@@ -243,14 +293,15 @@
long l = minecraftserver.getWorldData().worldGenSettings().seed();
this.structureCheck = new StructureCheck(this.chunkSource.chunkScanner(), this.registryAccess(), minecraftserver.getStructureManager(), resourcekey, chunkgenerator, this, chunkgenerator.getBiomeSource(), l, datafixer);
- this.structureFeatureManager = new StructureManager(this, minecraftserver.getWorldData().worldGenSettings(), this.structureCheck);
+ this.structureFeatureManager = new StructureManager(this, this.serverLevelData.worldGenSettings(), structureCheck); // CraftBukkit
if (this.dimensionType().createDragonFight()) {
this.structureCheck = new StructureCheck(this.chunkSource.chunkScanner(), this.registryAccess(), minecraftserver.getStructureManager(), resourcekey, chunkgenerator, this.chunkSource.randomState(), this, chunkgenerator.getBiomeSource(), l, datafixer);
- this.structureManager = new StructureManager(this, minecraftserver.getWorldData().worldGenSettings(), this.structureCheck);
+ this.structureManager = new StructureManager(this, this.serverLevelData.worldGenSettings(), structureCheck); // CraftBukkit
if (this.dimension() == World.END && this.dimensionTypeRegistration().is(BuiltinDimensionTypes.END)) {
- this.dragonFight = new EnderDragonBattle(this, l, minecraftserver.getWorldData().endDragonFightData());
+ this.dragonFight = new EnderDragonBattle(this, this.serverLevelData.worldGenSettings().seed(), this.serverLevelData.endDragonFightData()); // CraftBukkit
} else {
@@ -96,7 +107,7 @@
}
public void setWeatherParameters(int i, int j, boolean flag, boolean flag1) {
@@ -275,12 +316,20 @@
@@ -282,12 +333,20 @@
long j;
if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) {
@@ -120,7 +131,7 @@
if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE) && this.isRaining()) {
this.resetWeatherCycle();
}
@@ -306,7 +355,7 @@
@@ -313,7 +372,7 @@
this.runBlockEvents();
this.handlingTick = false;
gameprofilerfiller.pop();
@@ -129,7 +140,7 @@
if (flag) {
this.resetEmptyTime();
@@ -322,7 +371,7 @@
@@ -329,7 +388,7 @@
this.entityTickList.forEach((entity) -> {
if (!entity.isRemoved()) {
@@ -138,7 +149,7 @@
entity.discard();
} else {
gameprofilerfiller.push("checkDespawn");
@@ -394,7 +443,7 @@
@@ -403,7 +462,7 @@
private void wakeUpAllPlayers() {
this.sleepStatus.removeAllSleepers();
@@ -147,7 +158,7 @@
entityplayer.stopSleepInBed(false, false);
});
}
@@ -421,14 +470,14 @@
@@ -430,14 +489,14 @@
entityhorseskeleton.setTrap(true);
entityhorseskeleton.setAge(0);
entityhorseskeleton.setPos((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ());
@@ -164,7 +175,7 @@
}
}
@@ -439,12 +488,12 @@
@@ -448,12 +507,12 @@
BiomeBase biomebase = (BiomeBase) this.getBiome(blockposition).value();
if (biomebase.shouldFreeze(this, blockposition1)) {
@@ -179,7 +190,7 @@
}
IBlockData iblockdata = this.getBlockState(blockposition1);
@@ -640,6 +689,7 @@
@@ -649,6 +708,7 @@
this.rainLevel = MathHelper.clamp(this.rainLevel, 0.0F, 1.0F);
}
@@ -187,7 +198,7 @@
if (this.oRainLevel != this.rainLevel) {
this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel), this.dimension());
}
@@ -658,14 +708,47 @@
@@ -667,14 +727,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));
}
@@ -237,7 +248,7 @@
}
public void resetEmptyTime() {
@@ -700,6 +783,7 @@
@@ -709,6 +802,7 @@
});
gameprofilerfiller.incrementCounter("tickNonPassenger");
entity.tick();
@@ -245,7 +256,7 @@
this.getProfiler().pop();
Iterator iterator = entity.getPassengers().iterator();
@@ -723,6 +807,7 @@
@@ -732,6 +826,7 @@
});
gameprofilerfiller.incrementCounter("tickPassenger");
entity1.rideTick();
@@ -253,15 +264,15 @@
gameprofilerfiller.pop();
Iterator iterator = entity1.getPassengers().iterator();
@@ -747,6 +832,7 @@
@@ -756,6 +851,7 @@
ChunkProviderServer chunkproviderserver = this.getChunkSource();
if (!flag1) {
+ org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(getWorld())); // CraftBukkit
if (iprogressupdate != null) {
iprogressupdate.progressStartNoAbort(new ChatMessage("menu.savingLevel"));
iprogressupdate.progressStartNoAbort(IChatBaseComponent.translatable("menu.savingLevel"));
}
@@ -764,11 +850,19 @@
@@ -773,11 +869,19 @@
}
}
@@ -282,7 +293,7 @@
}
this.getChunkSource().getDataStorage().save();
@@ -814,15 +908,37 @@
@@ -823,15 +927,37 @@
@Override
public boolean addFreshEntity(Entity entity) {
@@ -323,7 +334,7 @@
}
public void addDuringCommandTeleport(EntityPlayer entityplayer) {
@@ -853,24 +969,37 @@
@@ -862,24 +988,37 @@
this.entityManager.addNewEntity(entityplayer);
}
@@ -365,7 +376,7 @@
return true;
}
}
@@ -884,10 +1013,32 @@
@@ -893,10 +1032,32 @@
entityplayer.remove(entity_removalreason);
}
@@ -398,7 +409,7 @@
while (iterator.hasNext()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
@@ -896,6 +1047,12 @@
@@ -905,6 +1066,12 @@
double d1 = (double) blockposition.getY() - entityplayer.getY();
double d2 = (double) blockposition.getZ() - entityplayer.getZ();
@@ -411,7 +422,22 @@
if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) {
entityplayer.connection.send(new PacketPlayOutBlockBreakAnimation(i, blockposition, j));
}
@@ -950,7 +1107,18 @@
@@ -941,6 +1108,14 @@
public void gameEvent(GameEvent gameevent, Vec3D vec3d, GameEvent.a gameevent_a) {
int i = gameevent.getNotificationRadius();
BlockPosition blockposition = new BlockPosition(vec3d);
+ // CraftBukkit start
+ GenericGameEvent event = new GenericGameEvent(org.bukkit.GameEvent.getByKey(CraftNamespacedKey.fromMinecraft(IRegistry.GAME_EVENT.getKey(gameevent))), new Location(this.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()), (gameevent_a.sourceEntity() == null) ? null : gameevent_a.sourceEntity().getBukkitEntity(), i, !Bukkit.isPrimaryThread());
+ getCraftServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return;
+ }
+ i = event.getRadius();
+ // CraftBukkit end
int j = SectionPosition.blockToSectionCoord(blockposition.getX() - i);
int k = SectionPosition.blockToSectionCoord(blockposition.getY() - i);
int l = SectionPosition.blockToSectionCoord(blockposition.getZ() - i);
@@ -1013,7 +1188,18 @@
Iterator iterator = this.navigatingMobs.iterator();
while (iterator.hasNext()) {
@@ -431,7 +457,7 @@
NavigationAbstract navigationabstract = entityinsentient.getNavigation();
if (navigationabstract.shouldRecomputePath(blockposition)) {
@@ -986,10 +1154,20 @@
@@ -1069,10 +1255,20 @@
@Override
public Explosion explode(@Nullable Entity entity, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator explosiondamagecalculator, double d0, double d1, double d2, float f, boolean flag, Explosion.Effect explosion_effect) {
@@ -452,7 +478,7 @@
if (explosion_effect == Explosion.Effect.NONE) {
explosion.clearToBlow();
}
@@ -1070,13 +1248,20 @@
@@ -1144,13 +1340,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) {
@@ -475,16 +501,16 @@
++j;
}
}
@@ -1127,7 +1312,7 @@
@@ -1201,7 +1404,7 @@
@Nullable
public BlockPosition findNearestMapFeature(TagKey<StructureFeature<?, ?>> tagkey, BlockPosition blockposition, int i, boolean flag) {
- if (!this.server.getWorldData().worldGenSettings().generateFeatures()) {
+ if (!this.serverLevelData.worldGenSettings().generateFeatures()) { // CraftBukkit
public BlockPosition findNearestMapStructure(TagKey<Structure> tagkey, BlockPosition blockposition, int i, boolean flag) {
- if (!this.server.getWorldData().worldGenSettings().generateStructures()) {
+ if (!this.serverLevelData.worldGenSettings().generateStructures()) { // CraftBukkit
return null;
} else {
Optional<HolderSet.Named<StructureFeature<?, ?>>> optional = this.registryAccess().registryOrThrow(IRegistry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY).getTag(tagkey);
@@ -1169,11 +1354,21 @@
Optional<HolderSet.Named<Structure>> optional = this.registryAccess().registryOrThrow(IRegistry.STRUCTURE_REGISTRY).getTag(tagkey);
@@ -1243,11 +1446,21 @@
@Nullable
@Override
public WorldMap getMapData(String s) {
@@ -507,7 +533,7 @@
this.getServer().overworld().getDataStorage().set(s, worldmap);
}
@@ -1485,6 +1680,11 @@
@@ -1545,6 +1758,11 @@
@Override
public void blockUpdated(BlockPosition blockposition, Block block) {
if (!this.isDebug()) {
@@ -519,7 +545,7 @@
this.updateNeighborsAt(blockposition, block);
}
@@ -1504,12 +1704,12 @@
@@ -1564,12 +1782,12 @@
}
public boolean isFlat() {
@@ -534,7 +560,7 @@
}
@Nullable
@@ -1532,7 +1732,7 @@
@@ -1592,7 +1810,7 @@
private static <T> String getTypeCount(Iterable<T> iterable, Function<T, String> function) {
try {
Object2IntOpenHashMap<String> object2intopenhashmap = new Object2IntOpenHashMap();
@@ -543,7 +569,7 @@
while (iterator.hasNext()) {
T t0 = iterator.next();
@@ -1541,7 +1741,7 @@
@@ -1601,7 +1819,7 @@
object2intopenhashmap.addTo(s, 1);
}
@@ -552,7 +578,7 @@
String s1 = (String) entry.getKey();
return s1 + ":" + entry.getIntValue();
@@ -1552,17 +1752,33 @@
@@ -1612,17 +1830,33 @@
}
public static void makeObsidianPlatform(WorldServer worldserver) {
@@ -588,18 +614,18 @@
}
@Override
@@ -1672,6 +1888,7 @@
}
@@ -1733,6 +1967,7 @@
}
entity.updateDynamicGameEventListener(DynamicGameEventListener::add);
+ entity.valid = true; // CraftBukkit
}
public void onTrackingEnd(Entity entity) {
@@ -1713,6 +1930,14 @@
gameeventlistenerregistrar.onListenerRemoved(entity.level);
@@ -1769,6 +2004,14 @@
}
entity.updateDynamicGameEventListener(DynamicGameEventListener::remove);
+ // CraftBukkit start
+ entity.valid = false;
+ if (!(entity instanceof EntityPlayer)) {
@@ -609,5 +635,5 @@
+ }
+ // CraftBukkit end
}
}
}
public void onSectionChange(Entity entity) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/network/HandshakeListener.java
+++ b/net/minecraft/server/network/HandshakeListener.java
@@ -11,8 +11,17 @@
@@ -10,8 +10,17 @@
import net.minecraft.network.protocol.login.PacketLoginOutDisconnect;
import net.minecraft.server.MinecraftServer;
@@ -15,10 +15,10 @@
+ private static final HashMap<InetAddress, Long> throttleTracker = new HashMap<InetAddress, Long>();
+ private static int throttleCounter = 0;
+ // CraftBukkit end
private static final IChatBaseComponent IGNORE_STATUS_REASON = new ChatComponentText("Ignoring status request");
private static final IChatBaseComponent IGNORE_STATUS_REASON = IChatBaseComponent.literal("Ignoring status request");
private final MinecraftServer server;
private final NetworkManager connection;
@@ -27,6 +36,40 @@
@@ -26,6 +35,40 @@
switch (packethandshakinginsetprotocol.getIntention()) {
case LOGIN:
this.connection.setProtocol(EnumProtocol.LOGIN);
@@ -31,7 +31,7 @@
+ synchronized (throttleTracker) {
+ if (throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - throttleTracker.get(address) < connectionThrottle) {
+ throttleTracker.put(address, currentTime);
+ ChatMessage chatmessage = new ChatMessage("Connection throttled! Please wait before reconnecting.");
+ IChatMutableComponent chatmessage = IChatBaseComponent.literal("Connection throttled! Please wait before reconnecting.");
+ this.connection.send(new PacketLoginOutDisconnect(chatmessage));
+ this.connection.disconnect(chatmessage);
+ return;
@@ -57,10 +57,10 @@
+ }
+ // CraftBukkit end
if (packethandshakinginsetprotocol.getProtocolVersion() != SharedConstants.getCurrentVersion().getProtocolVersion()) {
ChatMessage chatmessage;
IChatMutableComponent ichatmutablecomponent;
@@ -40,6 +83,7 @@
this.connection.disconnect(chatmessage);
@@ -39,6 +82,7 @@
this.connection.disconnect(ichatmutablecomponent);
} else {
this.connection.setListener(new LoginListener(this.server, this.connection));
+ ((LoginListener) this.connection.getPacketListener()).hostname = packethandshakinginsetprotocol.hostName + ":" + packethandshakinginsetprotocol.port; // CraftBukkit - set hostname

View File

@@ -1,11 +1,10 @@
--- a/net/minecraft/server/network/LoginListener.java
+++ b/net/minecraft/server/network/LoginListener.java
@@ -36,6 +36,13 @@
@@ -41,6 +41,12 @@
import org.apache.commons.lang3.Validate;
import org.slf4j.Logger;
+// CraftBukkit start
+import net.minecraft.network.chat.ChatComponentText;
+import org.bukkit.craftbukkit.util.Waitable;
+import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
+import org.bukkit.event.player.PlayerPreLoginEvent;
@@ -14,42 +13,35 @@
public class LoginListener implements PacketLoginInListener {
private static final AtomicInteger UNIQUE_THREAD_ID = new AtomicInteger(0);
@@ -52,6 +59,7 @@
private final String serverId;
@Nullable
@@ -62,6 +68,7 @@
private EntityPlayer delayedAcceptPlayer;
@Nullable
private ProfilePublicKey playerProfilePublicKey;
+ public String hostname = ""; // CraftBukkit - add field
public LoginListener(MinecraftServer minecraftserver, NetworkManager networkmanager) {
this.state = LoginListener.EnumProtocolState.HELLO;
@@ -80,6 +88,20 @@
@@ -90,6 +97,13 @@
}
+ // CraftBukkit start
+ @Deprecated
+ public void disconnect(String s) {
+ try {
+ IChatBaseComponent ichatbasecomponent = new ChatComponentText(s);
+ LoginListener.LOGGER.info("Disconnecting {}: {}", this.getUserName(), s);
+ this.connection.send(new PacketLoginOutDisconnect(ichatbasecomponent));
+ this.connection.disconnect(ichatbasecomponent);
+ } catch (Exception exception) {
+ LoginListener.LOGGER.error("Error whilst disconnecting player", exception);
+ }
+ disconnect(IChatBaseComponent.literal(s));
+ }
+ // CraftBukkit end
+
@Override
public NetworkManager getConnection() {
return this.connection;
@@ -101,10 +123,12 @@
@@ -111,10 +125,12 @@
this.gameProfile = this.createFakeProfile(this.gameProfile);
}
- IChatBaseComponent ichatbasecomponent = this.server.getPlayerList().canPlayerLogin(this.connection.getRemoteAddress(), this.gameProfile);
+ // CraftBukkit start - fire PlayerLoginEvent
+ EntityPlayer s = this.server.getPlayerList().canPlayerLogin(this, this.gameProfile, hostname);
+ EntityPlayer s = this.server.getPlayerList().canPlayerLogin(this, this.gameProfile, this.playerProfilePublicKey, hostname);
- if (ichatbasecomponent != null) {
- this.disconnect(ichatbasecomponent);
@@ -59,16 +51,16 @@
} else {
this.state = LoginListener.EnumProtocolState.ACCEPTED;
if (this.server.getCompressionThreshold() >= 0 && !this.connection.isMemoryConnection()) {
@@ -117,7 +141,7 @@
@@ -127,7 +143,7 @@
EntityPlayer entityplayer = this.server.getPlayerList().getPlayer(this.gameProfile.getId());
try {
- EntityPlayer entityplayer1 = this.server.getPlayerList().getPlayerForLogin(this.gameProfile);
- EntityPlayer entityplayer1 = this.server.getPlayerList().getPlayerForLogin(this.gameProfile, this.playerProfilePublicKey);
+ EntityPlayer entityplayer1 = this.server.getPlayerList().getPlayerForLogin(this.gameProfile, s); // CraftBukkit - add player reference
if (entityplayer != null) {
this.state = LoginListener.EnumProtocolState.DELAY_ACCEPT;
@@ -199,6 +223,43 @@
@@ -259,6 +275,43 @@
try {
LoginListener.this.gameProfile = LoginListener.this.server.getSessionService().hasJoinedServer(new GameProfile((UUID) null, gameprofile.getName()), s, this.getAddress());
if (LoginListener.this.gameProfile != null) {
@@ -112,8 +104,8 @@
LoginListener.LOGGER.info("UUID of player {} is {}", LoginListener.this.gameProfile.getName(), LoginListener.this.gameProfile.getId());
LoginListener.this.state = LoginListener.EnumProtocolState.READY_TO_ACCEPT;
} else if (LoginListener.this.server.isSingleplayer()) {
@@ -218,6 +279,11 @@
LoginListener.this.disconnect(new ChatMessage("multiplayer.disconnect.authservers_down"));
@@ -278,6 +331,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

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/network/PacketStatusListener.java
+++ b/net/minecraft/server/network/PacketStatusListener.java
@@ -10,6 +10,18 @@
@@ -9,6 +9,18 @@
import net.minecraft.network.protocol.status.PacketStatusOutServerInfo;
import net.minecraft.server.MinecraftServer;
@@ -18,8 +18,8 @@
+
public class PacketStatusListener implements PacketStatusInListener {
private static final IChatBaseComponent DISCONNECT_REASON = new ChatMessage("multiplayer.status.request_handled");
@@ -36,7 +48,102 @@
private static final IChatBaseComponent DISCONNECT_REASON = IChatBaseComponent.translatable("multiplayer.status.request_handled");
@@ -35,7 +47,102 @@
this.connection.disconnect(PacketStatusListener.DISCONNECT_REASON);
} else {
this.hasRequestedStatus = true;

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/network/PlayerConnection.java
+++ b/net/minecraft/server/network/PlayerConnection.java
@@ -157,6 +157,62 @@
@@ -173,6 +173,62 @@
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@@ -9,7 +9,7 @@
+import java.util.concurrent.atomic.AtomicInteger;
+import net.minecraft.network.protocol.game.PacketPlayOutAttachEntity;
+import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata;
+import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntityLiving;
+import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity;
+import net.minecraft.network.protocol.game.PacketPlayOutSpawnPosition;
+import net.minecraft.util.MathHelper;
+import net.minecraft.world.entity.EntityInsentient;
@@ -63,7 +63,7 @@
public class PlayerConnection implements ServerPlayerConnection, PacketListenerPlayIn {
static final Logger LOGGER = LogUtils.getLogger();
@@ -168,7 +224,9 @@
@@ -187,7 +243,9 @@
private long keepAliveTime;
private boolean keepAlivePending;
private long keepAliveChallenge;
@@ -74,7 +74,7 @@
private int dropSpamTickCount;
private double firstGoodX;
private double firstGoodY;
@@ -203,7 +261,31 @@
@@ -225,7 +283,31 @@
entityplayer.connection = this;
this.keepAliveTime = SystemUtils.getMillis();
entityplayer.getTextFilter().join();
@@ -105,17 +105,17 @@
+ // CraftBukkit end
public void tick() {
this.resetPosition();
@@ -252,7 +334,7 @@
if (this.ackBlockChangesUpTo > -1) {
@@ -279,7 +361,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(new ChatMessage("disconnect.timeout"));
this.disconnect(IChatBaseComponent.translatable("disconnect.timeout"));
} else {
@@ -264,15 +346,21 @@
@@ -291,15 +373,21 @@
}
this.server.getProfiler().pop();
@@ -134,10 +134,10 @@
if (this.player.getLastActionTime() > 0L && this.server.getPlayerIdleTimeout() > 0 && SystemUtils.getMillis() - this.player.getLastActionTime() > (long) (this.server.getPlayerIdleTimeout() * 1000 * 60)) {
+ this.player.resetLastActionTime(); // CraftBukkit - SPIGOT-854
this.disconnect(new ChatMessage("multiplayer.disconnect.idling"));
this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.idling"));
}
@@ -296,16 +384,47 @@
@@ -324,16 +412,47 @@
return this.server.isSingleplayerOwner(this.player.getGameProfile());
}
@@ -186,7 +186,7 @@
}
private <T, R> void filterTextPacket(T t0, Consumer<R> consumer, BiFunction<ITextFilter, T, CompletableFuture<R>> bifunction) {
@@ -376,7 +495,34 @@
@@ -404,7 +523,34 @@
double d9 = entity.getDeltaMovement().lengthSqr();
double d10 = d6 * d6 + d7 * d7 + d8 * d8;
@@ -222,7 +222,7 @@
PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", new Object[]{entity.getName().getString(), this.player.getName().getString(), d6, d7, d8});
this.connection.send(new PacketPlayOutVehicleMove(entity));
return;
@@ -408,14 +554,72 @@
@@ -436,14 +582,72 @@
}
entity.absMoveTo(d3, d4, d5, f, f1);
@@ -295,16 +295,7 @@
this.player.getLevel().getChunkSource().move(this.player);
this.player.checkMovementStatistics(this.player.getX() - d0, this.player.getY() - d1, this.player.getZ() - d2);
this.clientVehicleIsFloating = d11 >= -0.03125D && !flag1 && !this.server.isFlightAllowed() && !entity.isNoGravity() && this.noBlocksAround(entity);
@@ -434,7 +638,7 @@
@Override
public void handleAcceptTeleportPacket(PacketPlayInTeleportAccept packetplayinteleportaccept) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinteleportaccept, this, this.player.getLevel());
- if (packetplayinteleportaccept.getId() == this.awaitingTeleport) {
+ if (packetplayinteleportaccept.getId() == this.awaitingTeleport && this.awaitingPositionFromClient != null) { // CraftBukkit
this.player.absMoveTo(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot());
this.lastGoodX = this.awaitingPositionFromClient.x;
this.lastGoodY = this.awaitingPositionFromClient.y;
@@ -444,6 +648,7 @@
@@ -477,6 +681,7 @@
}
this.awaitingPositionFromClient = null;
@@ -312,7 +303,7 @@
}
}
@@ -451,7 +656,7 @@
@@ -484,7 +689,7 @@
@Override
public void handleRecipeBookSeenRecipePacket(PacketPlayInRecipeDisplayed packetplayinrecipedisplayed) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinrecipedisplayed, this, this.player.getLevel());
@@ -321,20 +312,20 @@
RecipeBookServer recipebookserver = this.player.getRecipeBook();
Objects.requireNonNull(recipebookserver);
@@ -481,6 +686,12 @@
@@ -514,6 +719,12 @@
@Override
public void handleCustomCommandSuggestions(PacketPlayInTabComplete packetplayintabcomplete) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayintabcomplete, this, this.player.getLevel());
+ // CraftBukkit start
+ if (chatSpamTickCount.addAndGet(1) > 500 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) {
+ this.disconnect(new ChatMessage("disconnect.spam", new Object[0]));
+ this.disconnect(IChatBaseComponent.translatable("disconnect.spam"));
+ return;
+ }
+ // CraftBukkit end
StringReader stringreader = new StringReader(packetplayintabcomplete.getCommand());
if (stringreader.canRead() && stringreader.peek() == '/') {
@@ -490,6 +701,7 @@
@@ -523,6 +734,7 @@
ParseResults<CommandListenerWrapper> parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack());
this.server.getCommands().getDispatcher().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> {
@@ -342,7 +333,7 @@
this.connection.send(new PacketPlayOutTabComplete(packetplayintabcomplete.getId(), suggestions));
});
}
@@ -722,6 +934,13 @@
@@ -755,6 +967,13 @@
if (container instanceof ContainerMerchant) {
ContainerMerchant containermerchant = (ContainerMerchant) container;
@@ -356,7 +347,7 @@
containermerchant.setSelectionHint(i);
containermerchant.tryMoveItems(i);
@@ -731,6 +950,13 @@
@@ -764,6 +983,13 @@
@Override
public void handleEditBook(PacketPlayInBEdit packetplayinbedit) {
@@ -370,7 +361,7 @@
int i = packetplayinbedit.getSlot();
if (PlayerInventory.isHotbarSlot(i) || i == 40) {
@@ -739,7 +965,7 @@
@@ -772,7 +998,7 @@
Objects.requireNonNull(list);
optional.ifPresent(list::add);
@@ -379,7 +370,7 @@
Objects.requireNonNull(list);
stream.forEach(list::add);
@@ -755,7 +981,7 @@
@@ -788,7 +1014,7 @@
ItemStack itemstack = this.player.getInventory().getItem(i);
if (itemstack.is(Items.WRITABLE_BOOK)) {
@@ -388,10 +379,10 @@
}
}
@@ -780,16 +1006,16 @@
@@ -813,16 +1039,16 @@
this.updateBookPages(list, (s) -> {
return IChatBaseComponent.ChatSerializer.toJson(new ChatComponentText(s));
return IChatBaseComponent.ChatSerializer.toJson(IChatBaseComponent.literal(s));
- }, itemstack1);
- this.player.getInventory().setItem(i, itemstack1);
+ }, itemstack1, i, itemstack); // CraftBukkit
@@ -399,17 +390,17 @@
}
}
- private void updateBookPages(List<ITextFilter.a> list, UnaryOperator<String> unaryoperator, ItemStack itemstack) {
+ private void updateBookPages(List<ITextFilter.a> list, UnaryOperator<String> unaryoperator, ItemStack itemstack, int slot, ItemStack handItem) { // CraftBukkit
- private void updateBookPages(List<FilteredText<String>> list, UnaryOperator<String> unaryoperator, ItemStack itemstack) {
+ private void updateBookPages(List<FilteredText<String>> list, UnaryOperator<String> unaryoperator, ItemStack itemstack, int slot, ItemStack handItem) { // CraftBukkit
NBTTagList nbttaglist = new NBTTagList();
if (this.player.isTextFilteringEnabled()) {
- Stream stream = list.stream().map((itextfilter_a) -> {
+ Stream<NBTTagString> stream = list.stream().map((itextfilter_a) -> { // CraftBukkit - decompile error
return NBTTagString.valueOf((String) unaryoperator.apply(itextfilter_a.getFiltered()));
- Stream stream = list.stream().map((filteredtext) -> {
+ Stream<NBTTagString> stream = list.stream().map((filteredtext) -> { // CraftBukkit - decompile error
return NBTTagString.valueOf((String) unaryoperator.apply((String) filteredtext.filteredOrElse("")));
});
@@ -817,6 +1043,7 @@
@@ -848,6 +1074,7 @@
}
itemstack.addTagElement("pages", nbttaglist);
@@ -417,7 +408,7 @@
}
@Override
@@ -853,7 +1080,7 @@
@@ -884,7 +1111,7 @@
} else {
WorldServer worldserver = this.player.getLevel();
@@ -426,7 +417,7 @@
if (this.tickCount == 0) {
this.resetPosition();
}
@@ -863,7 +1090,7 @@
@@ -894,7 +1121,7 @@
this.awaitingTeleportTime = this.tickCount;
this.teleport(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot());
}
@@ -435,7 +426,7 @@
} else {
this.awaitingTeleportTime = this.tickCount;
double d0 = clampHorizontal(packetplayinflying.getX(this.player.getX()));
@@ -875,7 +1102,15 @@
@@ -906,7 +1133,15 @@
if (this.player.isPassenger()) {
this.player.absMoveTo(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1);
this.player.getLevel().getChunkSource().move(this.player);
@@ -451,7 +442,7 @@
double d3 = this.player.getX();
double d4 = this.player.getY();
double d5 = this.player.getZ();
@@ -895,15 +1130,33 @@
@@ -926,15 +1161,33 @@
++this.receivedMovePacketCount;
int i = this.receivedMovePacketCount - this.knownMovePacketCount;
@@ -487,7 +478,7 @@
PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", new Object[]{this.player.getName().getString(), d7, d8, d9});
this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot());
return;
@@ -924,6 +1177,7 @@
@@ -955,6 +1208,7 @@
boolean flag1 = this.player.verticalCollisionBelow;
this.player.move(EnumMoveType.PLAYER, new Vec3D(d7, d8, d9));
@@ -495,7 +486,7 @@
double d12 = d8;
d7 = d0 - this.player.getX();
@@ -943,8 +1197,71 @@
@@ -974,8 +1228,71 @@
this.player.absMoveTo(d0, d1, d2, f, f1);
if (!this.player.noPhysics && !this.player.isSleeping() && (flag2 && worldserver.noCollision(this.player, axisalignedbb) || this.isPlayerCollidingWithAnythingNew(worldserver, axisalignedbb))) {
@@ -568,7 +559,7 @@
this.clientIsFloating = d12 >= -0.03125D && !flag1 && this.player.gameMode.getGameModeForPlayer() != EnumGamemode.SPECTATOR && !this.server.isFlightAllowed() && !this.player.getAbilities().mayfly && !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.isFallFlying() && !this.player.isAutoSpinAttack() && this.noBlocksAround(this.player);
this.player.getLevel().getChunkSource().move(this.player);
this.player.doCheckFallDamage(this.player.getY() - d6, packetplayinflying.isOnGround());
@@ -983,19 +1300,80 @@
@@ -1014,19 +1331,80 @@
return true;
}
@@ -598,8 +589,9 @@
+
+ public void teleport(double d0, double d1, double d2, float f, float f1, Set<PacketPlayOutPosition.EnumPlayerTeleportFlags> set, PlayerTeleportEvent.TeleportCause cause) {
+ this.teleport(d0, d1, d2, f, f1, set, false, cause);
+ }
+
}
- public void teleport(double d0, double d1, double d2, float f, float f1, Set<PacketPlayOutPosition.EnumPlayerTeleportFlags> set, boolean flag) {
+ public boolean teleport(double d0, double d1, double d2, float f, float f1, Set<PacketPlayOutPosition.EnumPlayerTeleportFlags> set, boolean flag, PlayerTeleportEvent.TeleportCause cause) { // CraftBukkit - Return event status
+ Player player = this.getCraftPlayer();
+ Location from = player.getLocation();
@@ -636,9 +628,8 @@
+
+ public void teleport(Location dest) {
+ internalTeleport(dest.getX(), dest.getY(), dest.getZ(), dest.getYaw(), dest.getPitch(), Collections.<PacketPlayOutPosition.EnumPlayerTeleportFlags>emptySet(), true);
}
- public void teleport(double d0, double d1, double d2, float f, float f1, Set<PacketPlayOutPosition.EnumPlayerTeleportFlags> set, boolean flag) {
+ }
+
+ private void internalTeleport(double d0, double d1, double d2, float f, float f1, Set<PacketPlayOutPosition.EnumPlayerTeleportFlags> set, boolean flag) {
+ // CraftBukkit start
+ if (Float.isNaN(f)) {
@@ -653,7 +644,7 @@
double d3 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.X) ? this.player.getX() : 0.0D;
double d4 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Y) ? this.player.getY() : 0.0D;
double d5 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Z) ? this.player.getZ() : 0.0D;
@@ -1007,6 +1385,14 @@
@@ -1038,6 +1416,14 @@
this.awaitingTeleport = 0;
}
@@ -668,7 +659,7 @@
this.awaitingTeleportTime = this.tickCount;
this.player.absMoveTo(d0, d1, d2, f, f1);
this.player.connection.send(new PacketPlayOutPosition(d0 - d3, d1 - d4, d2 - d5, f - f2, f1 - f3, set, this.awaitingTeleport, flag));
@@ -1015,6 +1401,7 @@
@@ -1046,6 +1432,7 @@
@Override
public void handlePlayerAction(PacketPlayInBlockDig packetplayinblockdig) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockdig, this, this.player.getLevel());
@@ -676,7 +667,7 @@
BlockPosition blockposition = packetplayinblockdig.getPos();
this.player.resetLastActionTime();
@@ -1025,14 +1412,46 @@
@@ -1056,14 +1443,46 @@
if (!this.player.isSpectator()) {
ItemStack itemstack = this.player.getItemInHand(EnumHand.OFF_HAND);
@@ -725,15 +716,15 @@
this.player.drop(false);
}
@@ -1069,6 +1488,7 @@
@@ -1101,6 +1520,7 @@
@Override
public void handleUseItemOn(PacketPlayInUseItem packetplayinuseitem) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseitem, this, this.player.getLevel());
+ if (this.player.isImmobile()) return; // CraftBukkit
this.player.connection.ackBlockChangesUpTo(packetplayinuseitem.getSequence());
WorldServer worldserver = this.player.getLevel();
EnumHand enumhand = packetplayinuseitem.getHand();
ItemStack itemstack = this.player.getItemInHand(enumhand);
@@ -1088,6 +1508,7 @@
@@ -1122,6 +1542,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)) {
@@ -741,14 +732,15 @@
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)) {
@@ -1117,12 +1538,51 @@
@@ -1149,6 +1570,7 @@
@Override
public void handleUseItem(PacketPlayInBlockPlace packetplayinblockplace) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockplace, this, this.player.getLevel());
+ if (this.player.isImmobile()) return; // CraftBukkit
this.ackBlockChangesUpTo(packetplayinblockplace.getSequence());
WorldServer worldserver = this.player.getLevel();
EnumHand enumhand = packetplayinblockplace.getHand();
ItemStack itemstack = this.player.getItemInHand(enumhand);
@@ -1156,6 +1578,44 @@
this.player.resetLastActionTime();
if (!itemstack.isEmpty()) {
@@ -793,7 +785,7 @@
EnumInteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand);
if (enuminteractionresult.shouldSwing()) {
@@ -1143,7 +1603,7 @@
@@ -1176,7 +1636,7 @@
Entity entity = packetplayinspectate.getEntity(worldserver);
if (entity != null) {
@@ -802,15 +794,15 @@
return;
}
}
@@ -1158,6 +1618,7 @@
@@ -1191,6 +1651,7 @@
PlayerConnection.LOGGER.info("Disconnecting {} due to resource pack rejection", this.player.getName());
this.disconnect(new ChatMessage("multiplayer.requiredTexturePrompt.disconnect"));
this.disconnect(IChatBaseComponent.translatable("multiplayer.requiredTexturePrompt.disconnect"));
}
+ this.cserver.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(getCraftPlayer(), PlayerResourcePackStatusEvent.Status.values()[packetplayinresourcepackstatus.action.ordinal()])); // CraftBukkit
}
@@ -1177,11 +1638,26 @@
@@ -1210,11 +1671,26 @@
@Override
public void onDisconnect(IChatBaseComponent ichatbasecomponent) {
@@ -825,7 +817,7 @@
+ // CraftBukkit start - Replace vanilla quit message handling with our own.
+ /*
this.server.invalidateStatus();
this.server.getPlayerList().broadcastMessage((new ChatMessage("multiplayer.player.left", new Object[]{this.player.getDisplayName()})).withStyle(EnumChatFormat.YELLOW), ChatMessageType.SYSTEM, SystemUtils.NIL_UUID);
this.server.getPlayerList().broadcastSystemMessage(IChatBaseComponent.translatable("multiplayer.player.left", this.player.getDisplayName()).withStyle(EnumChatFormat.YELLOW), ChatMessageType.SYSTEM);
+ */
+
this.player.disconnect();
@@ -838,7 +830,7 @@
this.player.getTextFilter().leave();
if (this.isSingleplayerOwner()) {
PlayerConnection.LOGGER.info("Stopping singleplayer server as player logged out");
@@ -1196,6 +1672,15 @@
@@ -1237,6 +1713,15 @@
}
public void send(Packet<?> packet, @Nullable GenericFutureListener<? extends Future<? super Void>> genericfuturelistener) {
@@ -854,7 +846,7 @@
try {
this.connection.send(packet, genericfuturelistener);
} catch (Throwable throwable) {
@@ -1212,7 +1697,16 @@
@@ -1253,7 +1738,16 @@
@Override
public void handleSetCarriedItem(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinhelditemslot, this, this.player.getLevel());
@@ -871,7 +863,7 @@
if (this.player.getInventory().selected != packetplayinhelditemslot.getSlot() && this.player.getUsedItemHand() == EnumHand.MAIN_HAND) {
this.player.stopUsingItem();
}
@@ -1221,11 +1715,18 @@
@@ -1262,18 +1756,27 @@
this.player.resetLastActionTime();
} else {
PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString());
@@ -887,39 +879,72 @@
+ return;
+ }
+ // CraftBukkit end
String s = StringUtils.normalizeSpace(packetplayinchat.getMessage());
for (int i = 0; i < s.length(); ++i) {
@@ -1239,20 +1740,42 @@
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinchat, this, this.player.getLevel());
this.handleChat(ITextFilter.a.passThrough(s));
if (isChatMessageIllegal(packetplayinchat.getMessage())) {
this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.illegal_characters"));
} else {
- this.filterTextPacket(s, this::handleChat);
+ this.handleChat(ITextFilter.a.passThrough(s)); // CraftBukkit - filter NYI
if (this.tryHandleChat(packetplayinchat.getMessage(), packetplayinchat.getTimeStamp())) {
- this.filterTextPacket(packetplayinchat.getMessage(), (filteredtext) -> {
- this.handleChat(packetplayinchat, filteredtext);
- });
+ // CraftBukkit start
+ // this.filterTextPacket(packetplayinchat.getMessage(), (filteredtext) -> {
+ this.handleChat(packetplayinchat, FilteredText.passThrough(packetplayinchat.getMessage())); // CraftBukkit - filter NYI
+ // });
+ // CraftBukkit end
}
}
@@ -1286,10 +1789,18 @@
} else {
PlayerConnectionUtils.ensureRunningOnSameThread(serverboundchatcommandpacket, this, this.player.getLevel());
if (this.tryHandleChat(serverboundchatcommandpacket.command(), serverboundchatcommandpacket.timeStamp())) {
- CommandListenerWrapper commandlistenerwrapper = this.player.createCommandSourceStack().withSigningContext(serverboundchatcommandpacket.signingContext(this.player.getUUID()));
+ // CraftBukkit start
+ // CommandListenerWrapper commandlistenerwrapper = this.player.createCommandSourceStack().withSigningContext(serverboundchatcommandpacket.signingContext(this.player.getUUID()));
- this.server.getCommands().performCommand(commandlistenerwrapper, serverboundchatcommandpacket.command());
- this.detectRateSpam();
+ // this.server.getCommands().performCommand(commandlistenerwrapper, serverboundchatcommandpacket.command());
+ try {
+ this.server.server.playerCommandState = true;
+ this.handleCommand("/" + serverboundchatcommandpacket.command());
+ } finally {
+ this.server.server.playerCommandState = false;
+ }
+ this.detectRateSpam(true);
+ // CraftBukkit end
}
}
@@ -1339,7 +1850,7 @@
}
private boolean resetLastActionTime() {
- if (this.player.getChatVisibility() == EnumChatVisibility.HIDDEN) {
+ if (this.player.isRemoved() || this.player.getChatVisibility() == EnumChatVisibility.HIDDEN) { // CraftBukkit - dead men tell no tales
IRegistry<ChatMessageType> iregistry = this.player.level.registryAccess().registryOrThrow(IRegistry.CHAT_TYPE_REGISTRY);
int i = iregistry.getId((ChatMessageType) iregistry.get(ChatMessageType.SYSTEM));
@@ -1357,31 +1868,171 @@
boolean flag = packetplayinchat.signedPreview();
ChatDecorator chatdecorator = this.server.getChatDecorator();
- chatdecorator.decorateChat(this.player, filteredtext.map(IChatBaseComponent::literal), messagesignature, flag).thenAcceptAsync(this::broadcastChatMessage, this.server);
+ chatdecorator.decorateChat(this.player, filteredtext.map(IChatBaseComponent::literal), messagesignature, flag).thenAccept((playerchatmessage) -> broadcastChatMessage(packetplayinchat, playerchatmessage)); // CraftBukkit
}
}
private void handleChat(ITextFilter.a itextfilter_a) {
- if (this.player.getChatVisibility() == EnumChatVisibility.HIDDEN) {
+ if (this.player.isRemoved() || this.player.getChatVisibility() == EnumChatVisibility.HIDDEN) { // CraftBukkit - dead men tell no tales
this.send(new PacketPlayOutChat((new ChatMessage("chat.disabled.options")).withStyle(EnumChatFormat.RED), ChatMessageType.SYSTEM, SystemUtils.NIL_UUID));
- private void broadcastChatMessage(FilteredText<PlayerChatMessage> filteredtext) {
+ private void broadcastChatMessage(PacketPlayInChat packetplayinchat, FilteredText<PlayerChatMessage> filteredtext) {
if (!((PlayerChatMessage) filteredtext.raw()).verify(this.player)) {
PlayerConnection.LOGGER.warn("{} sent message with invalid signature: '{}'", this.player.getName().getString(), ((PlayerChatMessage) filteredtext.raw()).signedContent().getString());
} else {
this.player.resetLastActionTime();
String s = itextfilter_a.getRaw();
- if (s.startsWith("/")) {
- this.handleCommand(s);
- this.server.getPlayerList().broadcastChatMessage(filteredtext, this.player, ChatMessageType.CHAT);
- this.detectRateSpam();
+ // CraftBukkit start
+ boolean isSync = s.startsWith("/");
+ if (isSync) {
+ try {
+ this.server.server.playerCommandState = true;
+ this.handleCommand(s);
+ } finally {
+ this.server.server.playerCommandState = false;
+ }
+ } else if (s.isEmpty()) {
+ String s = packetplayinchat.getMessage();
+ if (s.isEmpty()) {
+ LOGGER.warn(this.player.getScoreboardName() + " tried to send an empty message");
+ } else if (getCraftPlayer().isConversing()) {
+ final String conversationInput = s;
@@ -930,50 +955,23 @@
+ }
+ });
+ } else if (this.player.getChatVisibility() == EnumChatVisibility.SYSTEM) { // Re-add "Command Only" flag check
+ this.send(new PacketPlayOutChat((new ChatMessage("chat.cannotSend")).withStyle(EnumChatFormat.RED), ChatMessageType.SYSTEM, SystemUtils.NIL_UUID));
+ } else if (true) {
+ IRegistry<ChatMessageType> iregistry = this.player.level.registryAccess().registryOrThrow(IRegistry.CHAT_TYPE_REGISTRY);
+ int i = iregistry.getId((ChatMessageType) iregistry.get(ChatMessageType.SYSTEM));
+
+ this.send(new ClientboundSystemChatPacket(IChatBaseComponent.translatable("chat.cannotSend").withStyle(EnumChatFormat.RED), i));
+ } else {
+ this.chat(s, true);
+ // CraftBukkit end - the below is for reference. :)
} else {
String s1 = itextfilter_a.getFiltered();
ChatMessage chatmessage = s1.isEmpty() ? null : new ChatMessage("chat.type.text", new Object[]{this.player.getDisplayName(), s1});
@@ -1263,28 +1786,198 @@
}, ChatMessageType.CHAT, this.player.getUUID());
}
- this.chatSpamTickCount += 20;
- if (this.chatSpamTickCount > 200 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) {
- this.disconnect(new ChatMessage("disconnect.spam"));
+ // CraftBukkit start - replaced with thread safe throttle
+ // this.chatSpamTickCount += 20;
+ if (chatSpamTickCount.addAndGet(20) > 200 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) {
+ if (!isSync) {
+ Waitable waitable = new Waitable() {
+ @Override
+ protected Object evaluate() {
+ PlayerConnection.this.disconnect(new ChatMessage("disconnect.spam"));
+ return null;
+ }
+ };
+
+ this.server.processQueue.add(waitable);
+
+ try {
+ waitable.get();
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ } catch (ExecutionException e) {
+ throw new RuntimeException(e);
+ }
+ } else {
+ this.disconnect(new ChatMessage("disconnect.spam"));
+ }
+ // CraftBukkit end
}
+ }
+ // this.server.getPlayerList().broadcastChatMessage(playerchatmessage, filteredtext, this.player, ChatMessageType.CHAT);
+ this.detectRateSpam(false);
+ // CraftBukkit end
}
}
- private void detectRateSpam() {
- this.chatSpamTickCount += 20;
- if (this.chatSpamTickCount > 200 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) {
- this.disconnect(IChatBaseComponent.translatable("disconnect.spam"));
+ // CraftBukkit start - add method
+ public void chat(String s, boolean async) {
+ if (s.isEmpty() || this.player.getChatVisibility() == EnumChatVisibility.HIDDEN) {
@@ -1046,11 +1044,8 @@
+ }
+ }
+ }
+ // CraftBukkit end
+
private void handleCommand(String s) {
- this.server.getCommands().performCommand(this.player.createCommandSourceStack(), s);
+ // CraftBukkit start - whole method
+ private void handleCommand(String s) {
+ this.LOGGER.info(this.player.getScoreboardName() + " issued server command: " + s);
+
+ CraftPlayer player = this.getCraftPlayer();
@@ -1071,8 +1066,68 @@
+ java.util.logging.Logger.getLogger(PlayerConnection.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ return;
+ }
+ // this.server.getCommands().performCommand(this.player.createCommandSourceStack(), s);
+ // CraftBukkit end
+ }
+ // CraftBukkit end
+
+ // CraftBukkit start - replaced with thread safe throttle
+ private void detectRateSpam(boolean isSync) {
+ // this.chatSpamTickCount += 20;
+ if (this.chatSpamTickCount.addAndGet(20) > 200 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) {
+ if (!isSync) {
+ Waitable waitable = new Waitable() {
+ @Override
+ protected Object evaluate() {
+ PlayerConnection.this.disconnect(IChatBaseComponent.translatable("disconnect.spam"));
+ return null;
+ }
+ };
+
+ this.server.processQueue.add(waitable);
+
+ try {
+ waitable.get();
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ } catch (ExecutionException e) {
+ throw new RuntimeException(e);
+ }
+ } else {
+ this.disconnect(IChatBaseComponent.translatable("disconnect.spam"));
+ }
+ // CraftBukkit end
}
}
@Override
public void handleChatPreview(ServerboundChatPreviewPacket serverboundchatpreviewpacket) {
- if (this.server.previewsChat()) {
+ if (false && this.server.previewsChat()) { // CraftBukkit - preview NYI
this.chatPreviewThrottler.schedule(() -> {
int i = serverboundchatpreviewpacket.queryId();
String s = serverboundchatpreviewpacket.query();
@@ -1428,7 +2079,7 @@
CommandContextBuilder<CommandListenerWrapper> commandcontextbuilder1 = commandcontextbuilder.getLastChild();
if (commandcontextbuilder1.getArguments().isEmpty()) {
- return CompletableFuture.completedFuture((Object) null);
+ return CompletableFuture.completedFuture(null); // CraftBukkit - decompile error
} else {
List<? extends ParsedCommandNode<?>> list = commandcontextbuilder1.getNodes();
@@ -1445,25 +2096,77 @@
return completablefuture;
}
} catch (CommandSyntaxException commandsyntaxexception) {
- return CompletableFuture.completedFuture((Object) null);
+ return CompletableFuture.completedFuture(null); // CraftBukkit - decompile error
}
}
}
- return CompletableFuture.completedFuture((Object) null);
+ return CompletableFuture.completedFuture(null); // CraftBukkit - decompile error
}
}
@Override
@@ -1140,7 +1195,7 @@
this.player.resetLastActionTime();
IJumpable ijumpable;
@@ -1342,6 +2035,7 @@
@@ -1525,6 +2228,7 @@
@Override
public void handleInteract(PacketPlayInUseEntity packetplayinuseentity) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseentity, this, this.player.getLevel());
@@ -1148,9 +1203,9 @@
WorldServer worldserver = this.player.getLevel();
final Entity entity = packetplayinuseentity.getTarget(worldserver);
@@ -1356,10 +2050,44 @@
@@ -1537,10 +2241,44 @@
if (this.player.distanceToSqr(entity) < 36.0D) {
if (entity.distanceToSqr(this.player.getEyePosition()) < PlayerConnection.MAX_INTERACTION_DISTANCE) {
packetplayinuseentity.dispatch(new PacketPlayInUseEntity.c() {
- private void performInteraction(EnumHand enumhand, PlayerConnection.a playerconnection_a) {
+ private void performInteraction(EnumHand enumhand, PlayerConnection.a playerconnection_a, PlayerInteractEntityEvent event) { // CraftBukkit
@@ -1164,7 +1219,7 @@
+
+ // Entity in bucket - SPIGOT-4048 and SPIGOT-6859
+ if ((entity instanceof Bucketable && entity instanceof EntityLiving && origItem != null && origItem.asItem() == Items.WATER_BUCKET) && (event.isCancelled() || player.getInventory().getSelected() == null || player.getInventory().getSelected().getItem() != origItem)) {
+ send(new PacketPlayOutSpawnEntityLiving((EntityLiving) entity));
+ send(new PacketPlayOutSpawnEntity(entity));
+ player.containerMenu.sendAllDataToRemote();
+ }
+
@@ -1194,7 +1249,7 @@
if (enuminteractionresult.consumesAction()) {
CriterionTriggers.PLAYER_INTERACTED_WITH_ENTITY.trigger(PlayerConnection.this.player, itemstack, entity);
if (enuminteractionresult.shouldSwing()) {
@@ -1371,20 +2099,27 @@
@@ -1552,20 +2290,27 @@
@Override
public void onInteraction(EnumHand enumhand) {
@@ -1223,9 +1278,9 @@
+ }
+ // CraftBukkit end
} else {
PlayerConnection.this.disconnect(new ChatMessage("multiplayer.disconnect.invalid_entity_attacked"));
PlayerConnection.this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.invalid_entity_attacked"));
PlayerConnection.LOGGER.warn("Player {} tried to attack an invalid entity", PlayerConnection.this.player.getName().getString());
@@ -1429,15 +2164,21 @@
@@ -1610,15 +2355,21 @@
@Override
public void handleContainerClose(PacketPlayInCloseWindow packetplayinclosewindow) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinclosewindow, this, this.player.getLevel());
@@ -1249,7 +1304,7 @@
this.player.containerMenu.sendAllDataToRemote();
} else {
int i = packetplayinwindowclick.getSlotNum();
@@ -1448,7 +2189,284 @@
@@ -1629,7 +2380,284 @@
boolean flag = packetplayinwindowclick.getStateId() != this.player.containerMenu.getStateId();
this.player.containerMenu.suppressRemoteUpdates();
@@ -1535,7 +1590,7 @@
ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packetplayinwindowclick.getChangedSlots()).iterator();
while (objectiterator.hasNext()) {
@@ -1484,6 +2502,7 @@
@@ -1665,6 +2693,7 @@
@Override
public void handleContainerButtonClick(PacketPlayInEnchantItem packetplayinenchantitem) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinenchantitem, this, this.player.getLevel());
@@ -1543,7 +1598,7 @@
this.player.resetLastActionTime();
if (this.player.containerMenu.containerId == packetplayinenchantitem.getContainerId() && !this.player.isSpectator()) {
boolean flag = this.player.containerMenu.clickMenuButton(this.player, packetplayinenchantitem.getButtonId());
@@ -1514,6 +2533,43 @@
@@ -1695,6 +2724,43 @@
boolean flag1 = packetplayinsetcreativeslot.getSlotNum() >= 1 && packetplayinsetcreativeslot.getSlotNum() <= 45;
boolean flag2 = itemstack.isEmpty() || itemstack.getDamageValue() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty();
@@ -1587,15 +1642,15 @@
if (flag1 && flag2) {
this.player.inventoryMenu.getSlot(packetplayinsetcreativeslot.getSlotNum()).set(itemstack);
@@ -1536,6 +2592,7 @@
@@ -1717,6 +2783,7 @@
}
private void updateSignText(PacketPlayInUpdateSign packetplayinupdatesign, List<ITextFilter.a> list) {
private void updateSignText(PacketPlayInUpdateSign packetplayinupdatesign, List<FilteredText<String>> list) {
+ if (this.player.isImmobile()) return; // CraftBukkit
this.player.resetLastActionTime();
WorldServer worldserver = this.player.getLevel();
BlockPosition blockposition = packetplayinupdatesign.getPos();
@@ -1552,18 +2609,37 @@
@@ -1733,18 +2800,37 @@
if (!tileentitysign.isEditable() || !this.player.getUUID().equals(tileentitysign.getPlayerWhoMayEdit())) {
PlayerConnection.LOGGER.warn("Player {} just tried to change non-editable sign", this.player.getName().getString());
@@ -1611,14 +1666,15 @@
+ String[] lines = new String[4];
+
for (int i = 0; i < list.size(); ++i) {
ITextFilter.a itextfilter_a = (ITextFilter.a) list.get(i);
- FilteredText<IChatBaseComponent> filteredtext = ((FilteredText) list.get(i)).map(IChatBaseComponent::literal);
+ FilteredText<IChatBaseComponent> filteredtext = (list.get(i)).map(IChatBaseComponent::literal); // CraftBukkit - decompile error
if (this.player.isTextFilteringEnabled()) {
- tileentitysign.setMessage(i, new ChatComponentText(itextfilter_a.getFiltered()));
+ lines[i] = EnumChatFormat.stripFormatting(new ChatComponentText(EnumChatFormat.stripFormatting(itextfilter_a.getFiltered())).getString());
- tileentitysign.setMessage(i, (IChatBaseComponent) filteredtext.filteredOrElse(CommonComponents.EMPTY));
+ lines[i] = EnumChatFormat.stripFormatting(filteredtext.filteredOrElse(CommonComponents.EMPTY).getString());
} else {
- tileentitysign.setMessage(i, new ChatComponentText(itextfilter_a.getRaw()), new ChatComponentText(itextfilter_a.getFiltered()));
+ lines[i] = EnumChatFormat.stripFormatting(new ChatComponentText(EnumChatFormat.stripFormatting(itextfilter_a.getRaw())).getString());
- tileentitysign.setMessage(i, (IChatBaseComponent) filteredtext.raw(), (IChatBaseComponent) filteredtext.filteredOrElse(CommonComponents.EMPTY));
+ lines[i] = EnumChatFormat.stripFormatting(filteredtext.raw().getString());
}
}
+ SignChangeEvent event = new SignChangeEvent((org.bukkit.craftbukkit.block.CraftBlock) player.getWorld().getBlockAt(x, y, z), this.player.getBukkitEntity(), lines);
@@ -1635,7 +1691,7 @@
tileentitysign.setChanged();
worldserver.sendBlockUpdated(blockposition, iblockdata, iblockdata, 3);
@@ -1573,6 +2649,7 @@
@@ -1754,6 +2840,7 @@
@Override
public void handleKeepAlive(PacketPlayInKeepAlive packetplayinkeepalive) {
@@ -1643,7 +1699,7 @@
if (this.keepAlivePending && packetplayinkeepalive.getId() == this.keepAliveChallenge) {
int i = (int) (SystemUtils.getMillis() - this.keepAliveTime);
@@ -1587,7 +2664,17 @@
@@ -1768,7 +2855,17 @@
@Override
public void handlePlayerAbilities(PacketPlayInAbilities packetplayinabilities) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinabilities, this, this.player.getLevel());
@@ -1662,7 +1718,7 @@
}
@Override
@@ -1596,8 +2683,50 @@
@@ -1777,8 +2874,50 @@
this.player.updateOptions(packetplayinsettings);
}

View File

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

View File

@@ -1,13 +1,12 @@
--- a/net/minecraft/server/players/PlayerList.java
+++ b/net/minecraft/server/players/PlayerList.java
@@ -95,6 +95,26 @@
@@ -100,6 +100,25 @@
import net.minecraft.world.scores.ScoreboardTeamBase;
import org.slf4j.Logger;
+// CraftBukkit start
+import com.google.common.base.Predicate;
+import java.util.stream.Collectors;
+import net.minecraft.network.protocol.game.PacketPlayOutChat;
+import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata;
+import net.minecraft.server.dedicated.DedicatedServer;
+import net.minecraft.server.network.LoginListener;
@@ -27,7 +26,7 @@
public abstract class PlayerList {
public static final File USERBANLIST_FILE = new File("banned-players.json");
@@ -105,14 +125,16 @@
@@ -110,14 +129,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 +46,7 @@
public final WorldNBTStorage playerIo;
private boolean doWhiteList;
private final IRegistryCustom.Dimension registryHolder;
@@ -123,13 +145,23 @@
@@ -128,13 +149,23 @@
private static final boolean ALLOW_LOGOUTIVATOR = false;
private int sendAllPlayerInfoIn;
@@ -73,7 +72,7 @@
this.server = minecraftserver;
this.registryHolder = iregistrycustom_dimension;
this.maxPlayers = i;
@@ -145,9 +177,15 @@
@@ -150,9 +181,15 @@
usercache.add(gameprofile);
NBTTagCompound nbttagcompound = this.load(entityplayer);
ResourceKey resourcekey;
@@ -90,7 +89,7 @@
Logger logger = PlayerList.LOGGER;
Objects.requireNonNull(logger);
@@ -174,7 +212,8 @@
@@ -179,7 +216,8 @@
s1 = networkmanager.getRemoteAddress().toString();
}
@@ -100,23 +99,23 @@
WorldData worlddata = worldserver1.getLevelData();
entityplayer.loadGameTypes(nbttagcompound);
@@ -184,6 +223,7 @@
@@ -189,6 +227,7 @@
boolean flag1 = gamerules.getBoolean(GameRules.RULE_REDUCEDDEBUGINFO);
playerconnection.send(new PacketPlayOutLogin(entityplayer.getId(), worlddata.isHardcore(), entityplayer.gameMode.getGameModeForPlayer(), entityplayer.gameMode.getPreviousGameModeForPlayer(), this.server.levelKeys(), this.registryHolder, worldserver1.dimensionTypeRegistration(), worldserver1.dimension(), BiomeManager.obfuscateSeed(worldserver1.getSeed()), this.getMaxPlayers(), this.viewDistance, this.simulationDistance, flag1, !flag, worldserver1.isDebug(), worldserver1.isFlat()));
playerconnection.send(new PacketPlayOutLogin(entityplayer.getId(), worlddata.isHardcore(), entityplayer.gameMode.getGameModeForPlayer(), entityplayer.gameMode.getPreviousGameModeForPlayer(), this.server.levelKeys(), this.registryHolder, worldserver1.dimensionTypeId(), worldserver1.dimension(), BiomeManager.obfuscateSeed(worldserver1.getSeed()), this.getMaxPlayers(), this.viewDistance, this.simulationDistance, flag1, !flag, worldserver1.isDebug(), worldserver1.isFlat(), entityplayer.getLastDeathLocation()));
+ entityplayer.getBukkitEntity().sendSupportedChannels(); // CraftBukkit
playerconnection.send(new PacketPlayOutCustomPayload(PacketPlayOutCustomPayload.BRAND, (new PacketDataSerializer(Unpooled.buffer())).writeUtf(this.getServer().getServerModName())));
playerconnection.send(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked()));
playerconnection.send(new PacketPlayOutAbilities(entityplayer.getAbilities()));
@@ -202,19 +242,66 @@
@@ -207,19 +246,66 @@
} else {
chatmessage = new ChatMessage("multiplayer.player.joined.renamed", new Object[]{entityplayer.getDisplayName(), s});
ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.player.joined.renamed", entityplayer.getDisplayName(), s);
}
+ // CraftBukkit start
+ chatmessage.withStyle(EnumChatFormat.YELLOW);
+ String joinMessage = CraftChatMessage.fromComponent(chatmessage);
+ ichatmutablecomponent.withStyle(EnumChatFormat.YELLOW);
+ String joinMessage = CraftChatMessage.fromComponent(ichatmutablecomponent);
- this.broadcastMessage(chatmessage.withStyle(EnumChatFormat.YELLOW), ChatMessageType.SYSTEM, SystemUtils.NIL_UUID);
- this.broadcastSystemMessage(ichatmutablecomponent.withStyle(EnumChatFormat.YELLOW), ChatMessageType.SYSTEM);
playerconnection.teleport(entityplayer.getX(), entityplayer.getY(), entityplayer.getZ(), entityplayer.getYRot(), entityplayer.getXRot());
this.players.add(entityplayer);
this.playersByUUID.put(entityplayer.getUUID(), entityplayer);
@@ -140,7 +139,7 @@
+
+ if (joinMessage != null && joinMessage.length() > 0) {
+ for (IChatBaseComponent line : org.bukkit.craftbukkit.util.CraftChatMessage.fromString(joinMessage)) {
+ server.getPlayerList().broadcastAll(new PacketPlayOutChat(line, ChatMessageType.SYSTEM, SystemUtils.NIL_UUID));
+ server.getPlayerList().broadcastSystemMessage(line, ChatMessageType.SYSTEM);
+ }
+ }
+ // CraftBukkit end
@@ -178,9 +177,9 @@
+ worldserver1 = entityplayer.getLevel(); // CraftBukkit - Update in case join event changed it
+ // CraftBukkit end
this.sendLevelInfo(entityplayer, worldserver1);
if (!this.server.getResourcePack().isEmpty()) {
entityplayer.sendTexturePack(this.server.getResourcePack(), this.server.getResourcePackHash(), this.server.isResourcePackRequired(), this.server.getResourcePackPrompt());
@@ -230,8 +317,11 @@
this.server.getServerResourcePack().ifPresent((minecraftserver_serverresourcepackinfo) -> {
entityplayer.sendTexturePack(minecraftserver_serverresourcepackinfo.url(), minecraftserver_serverresourcepackinfo.hash(), minecraftserver_serverresourcepackinfo.isRequired(), minecraftserver_serverresourcepackinfo.prompt());
@@ -235,8 +321,11 @@
if (nbttagcompound != null && nbttagcompound.contains("RootVehicle", 10)) {
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("RootVehicle");
@@ -194,7 +193,7 @@
});
if (entity != null) {
@@ -274,6 +364,8 @@
@@ -279,6 +368,8 @@
}
entityplayer.initInventoryMenu();
@@ -203,7 +202,7 @@
}
public void updateEntireScoreboard(ScoreboardServer scoreboardserver, EntityPlayer entityplayer) {
@@ -306,30 +398,31 @@
@@ -311,30 +402,31 @@
}
public void addWorldborderListener(WorldServer worldserver) {
@@ -240,7 +239,7 @@
}
@Override
@@ -357,14 +450,15 @@
@@ -362,14 +454,15 @@
}
protected void save(EntityPlayer entityplayer) {
@@ -258,7 +257,7 @@
if (advancementdataplayer != null) {
advancementdataplayer.save();
@@ -372,10 +466,24 @@
@@ -377,10 +470,24 @@
}
@@ -284,7 +283,7 @@
this.save(entityplayer);
if (entityplayer.isPassenger()) {
Entity entity = entityplayer.getRootVehicle();
@@ -399,18 +507,66 @@
@@ -404,18 +511,66 @@
if (entityplayer1 == entityplayer) {
this.playersByUUID.remove(uuid);
@@ -319,12 +318,12 @@
- @Nullable
- public IChatBaseComponent canPlayerLogin(SocketAddress socketaddress, GameProfile gameprofile) {
+ // CraftBukkit start - Whole method, SocketAddress to LoginListener, added hostname to signature, return EntityPlayer
+ public EntityPlayer canPlayerLogin(LoginListener loginlistener, GameProfile gameprofile, String hostname) {
ChatMessage chatmessage;
+ public EntityPlayer canPlayerLogin(LoginListener loginlistener, GameProfile gameprofile, ProfilePublicKey profilepublickey, String hostname) {
IChatMutableComponent ichatmutablecomponent;
- if (this.bans.isBanned(gameprofile)) {
+ // Moved from processLogin
+ UUID uuid = EntityHuman.createPlayerUUID(gameprofile);
+ UUID uuid = UUIDUtil.getOrCreatePlayerUUID(gameprofile);
+ List<EntityPlayer> list = Lists.newArrayList();
+
+ EntityPlayer entityplayer;
@@ -341,7 +340,7 @@
+ while (iterator.hasNext()) {
+ entityplayer = (EntityPlayer) iterator.next();
+ save(entityplayer); // CraftBukkit - Force the player's inventory to be saved
+ entityplayer.connection.disconnect(new ChatMessage("multiplayer.disconnect.duplicate_login", new Object[0]));
+ entityplayer.connection.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.duplicate_login"));
+ }
+
+ // Instead of kicking then returning, we need to store the kick reason
@@ -349,40 +348,40 @@
+ // 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, profilepublickey);
+ Player player = entity.getBukkitEntity();
+ PlayerLoginEvent event = new PlayerLoginEvent(player, hostname, ((java.net.InetSocketAddress) socketaddress).getAddress());
+
+ if (getBans().isBanned(gameprofile) && !getBans().get(gameprofile).hasExpired()) {
GameProfileBanEntry gameprofilebanentry = (GameProfileBanEntry) this.bans.get(gameprofile);
chatmessage = new ChatMessage("multiplayer.disconnect.banned.reason", new Object[]{gameprofilebanentry.getReason()});
@@ -418,10 +574,12 @@
chatmessage.append((IChatBaseComponent) (new ChatMessage("multiplayer.disconnect.banned.expiration", new Object[]{PlayerList.BAN_DATE_FORMAT.format(gameprofilebanentry.getExpires())})));
ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.disconnect.banned.reason", gameprofilebanentry.getReason());
@@ -423,10 +578,12 @@
ichatmutablecomponent.append((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.banned.expiration", PlayerList.BAN_DATE_FORMAT.format(gameprofilebanentry.getExpires())));
}
- return chatmessage;
- return ichatmutablecomponent;
+ // return chatmessage;
+ event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(chatmessage));
+ event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(ichatmutablecomponent));
} else if (!this.isWhiteListed(gameprofile)) {
- return new ChatMessage("multiplayer.disconnect.not_whitelisted");
- return IChatBaseComponent.translatable("multiplayer.disconnect.not_whitelisted");
- } else if (this.ipBans.isBanned(socketaddress)) {
+ chatmessage = new ChatMessage("multiplayer.disconnect.not_whitelisted");
+ event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, CraftChatMessage.fromComponent(chatmessage));
+ ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.disconnect.not_whitelisted");
+ event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, CraftChatMessage.fromComponent(ichatmutablecomponent));
+ } else if (getIpBans().isBanned(socketaddress) && !getIpBans().get(socketaddress).hasExpired()) {
IpBanEntry ipbanentry = this.ipBans.get(socketaddress);
chatmessage = new ChatMessage("multiplayer.disconnect.banned_ip.reason", new Object[]{ipbanentry.getReason()});
@@ -429,13 +587,25 @@
chatmessage.append((IChatBaseComponent) (new ChatMessage("multiplayer.disconnect.banned_ip.expiration", new Object[]{PlayerList.BAN_DATE_FORMAT.format(ipbanentry.getExpires())})));
ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.disconnect.banned_ip.reason", ipbanentry.getReason());
@@ -434,13 +591,25 @@
ichatmutablecomponent.append((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.banned_ip.expiration", PlayerList.BAN_DATE_FORMAT.format(ipbanentry.getExpires())));
}
- return chatmessage;
- return ichatmutablecomponent;
+ // return chatmessage;
+ event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(chatmessage));
+ event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(ichatmutablecomponent));
} else {
- return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile) ? new ChatMessage("multiplayer.disconnect.server_full") : null;
+ // return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile) ? new ChatMessage("multiplayer.disconnect.server_full") : null;
- return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile) ? IChatBaseComponent.translatable("multiplayer.disconnect.server_full") : null;
+ // return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile) ? IChatBaseComponent.translatable("multiplayer.disconnect.server_full") : null;
+ if (this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile)) {
+ event.disallow(PlayerLoginEvent.Result.KICK_FULL, "The server is full");
+ }
@@ -396,16 +395,16 @@
+ return entity;
}
- public EntityPlayer getPlayerForLogin(GameProfile gameprofile) {
- public EntityPlayer getPlayerForLogin(GameProfile gameprofile, @Nullable ProfilePublicKey profilepublickey) {
+ public EntityPlayer getPlayerForLogin(GameProfile gameprofile, EntityPlayer player) { // CraftBukkit - added EntityPlayer
+ /* CraftBukkit startMoved up
UUID uuid = EntityHuman.createPlayerUUID(gameprofile);
UUID uuid = UUIDUtil.getOrCreatePlayerUUID(gameprofile);
List<EntityPlayer> list = Lists.newArrayList();
@@ -462,14 +632,24 @@
@@ -467,14 +636,24 @@
}
return new EntityPlayer(this.server, this.server.overworld(), gameprofile);
return new EntityPlayer(this.server, this.server.overworld(), gameprofile, profilepublickey);
+ */
+ return player;
+ // CraftBukkit end
@@ -427,10 +426,10 @@
WorldServer worldserver = this.server.getLevel(entityplayer.getRespawnDimension());
Optional optional;
@@ -481,6 +661,11 @@
@@ -486,6 +665,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.getProfilePublicKey());
+ // */
+ EntityPlayer entityplayer1 = entityplayer;
+ org.bukkit.World fromWorld = entityplayer.getBukkitEntity().getWorld();
@@ -439,7 +438,7 @@
entityplayer1.connection = entityplayer.connection;
entityplayer1.restoreFrom(entityplayer, flag);
@@ -496,49 +681,110 @@
@@ -501,49 +685,110 @@
boolean flag2 = false;
@@ -520,7 +519,7 @@
}
+ // CraftBukkit start
+ WorldData worlddata = worldserver1.getLevelData();
+ entityplayer1.connection.send(new PacketPlayOutRespawn(worldserver1.dimensionTypeRegistration(), worldserver1.dimension(), BiomeManager.obfuscateSeed(worldserver1.getSeed()), entityplayer1.gameMode.getGameModeForPlayer(), entityplayer1.gameMode.getPreviousGameModeForPlayer(), worldserver1.isDebug(), worldserver1.isFlat(), flag));
+ entityplayer1.connection.send(new PacketPlayOutRespawn(worldserver1.dimensionTypeId(), worldserver1.dimension(), BiomeManager.obfuscateSeed(worldserver1.getSeed()), entityplayer1.gameMode.getGameModeForPlayer(), entityplayer1.gameMode.getPreviousGameModeForPlayer(), worldserver1.isDebug(), worldserver1.isFlat(), flag, entityplayer1.getLastDeathLocation()));
+ entityplayer1.spawnIn(worldserver1);
+ entityplayer1.unsetRemoved();
+ entityplayer1.connection.teleport(new Location(worldserver1.getWorld(), entityplayer1.getX(), entityplayer1.getY(), entityplayer1.getZ(), entityplayer1.getYRot(), entityplayer1.getXRot()));
@@ -528,7 +527,7 @@
- WorldData worlddata = entityplayer1.level.getLevelData();
-
- entityplayer1.connection.send(new PacketPlayOutRespawn(entityplayer1.level.dimensionTypeRegistration(), entityplayer1.level.dimension(), BiomeManager.obfuscateSeed(entityplayer1.getLevel().getSeed()), entityplayer1.gameMode.getGameModeForPlayer(), entityplayer1.gameMode.getPreviousGameModeForPlayer(), entityplayer1.getLevel().isDebug(), entityplayer1.getLevel().isFlat(), flag));
- entityplayer1.connection.send(new PacketPlayOutRespawn(entityplayer1.level.dimensionTypeId(), entityplayer1.level.dimension(), BiomeManager.obfuscateSeed(entityplayer1.getLevel().getSeed()), entityplayer1.gameMode.getGameModeForPlayer(), entityplayer1.gameMode.getPreviousGameModeForPlayer(), entityplayer1.getLevel().isDebug(), entityplayer1.getLevel().isFlat(), flag, entityplayer1.getLastDeathLocation()));
- 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.send(new PacketPlayOutSpawnPosition(worldserver1.getSharedSpawnPos(), worldserver1.getSharedSpawnAngle()));
@@ -548,7 +547,7 @@
+ // entityplayer1.initInventoryMenu();
entityplayer1.setHealth(entityplayer1.getHealth());
if (flag2) {
entityplayer1.connection.send(new PacketPlayOutNamedSoundEffect(SoundEffects.RESPAWN_ANCHOR_DEPLETE, SoundCategory.BLOCKS, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), 1.0F, 1.0F));
entityplayer1.connection.send(new PacketPlayOutNamedSoundEffect(SoundEffects.RESPAWN_ANCHOR_DEPLETE, SoundCategory.BLOCKS, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), 1.0F, 1.0F, worldserver1.getRandom().nextLong()));
}
+ // Added from changeDimension
+ sendAllPlayerInfo(entityplayer); // Update health, etc...
@@ -574,7 +573,7 @@
return entityplayer1;
}
@@ -551,7 +797,18 @@
@@ -556,7 +801,18 @@
public void tick() {
if (++this.sendAllPlayerInfoIn > 600) {
@@ -594,7 +593,7 @@
this.sendAllPlayerInfoIn = 0;
}
@@ -568,6 +825,25 @@
@@ -573,6 +829,25 @@
}
@@ -620,7 +619,7 @@
public void broadcastAll(Packet<?> packet, ResourceKey<World> resourcekey) {
Iterator iterator = this.players.iterator();
@@ -646,7 +922,7 @@
@@ -651,7 +926,7 @@
}
public void deop(GameProfile gameprofile) {
@@ -629,7 +628,7 @@
EntityPlayer entityplayer = this.getPlayer(gameprofile.getId());
if (entityplayer != null) {
@@ -670,6 +946,7 @@
@@ -675,6 +950,7 @@
entityplayer.connection.send(new PacketPlayOutEntityStatus(entityplayer, b0));
}
@@ -637,7 +636,7 @@
this.server.getCommands().sendCommands(entityplayer);
}
@@ -702,6 +979,12 @@
@@ -707,6 +983,12 @@
for (int i = 0; i < this.players.size(); ++i) {
EntityPlayer entityplayer = (EntityPlayer) this.players.get(i);
@@ -650,7 +649,7 @@
if (entityplayer != entityhuman && entityplayer.level.dimension() == resourcekey) {
double d4 = d0 - entityplayer.getX();
double d5 = d1 - entityplayer.getY();
@@ -741,23 +1024,34 @@
@@ -746,23 +1028,34 @@
public void reloadWhiteList() {}
public void sendLevelInfo(EntityPlayer entityplayer, WorldServer worldserver) {
@@ -690,12 +689,12 @@
}
public int getPlayerCount() {
@@ -813,12 +1107,22 @@
@@ -818,12 +1111,22 @@
}
public void removeAll() {
- for (int i = 0; i < this.players.size(); ++i) {
- ((EntityPlayer) this.players.get(i)).connection.disconnect(new ChatMessage("multiplayer.disconnect.server_shutdown"));
- ((EntityPlayer) this.players.get(i)).connection.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.server_shutdown"));
+ // CraftBukkit start - disconnect safely
+ for (EntityPlayer player : this.players) {
+ player.connection.disconnect(this.server.server.getShutdownMessage()); // CraftBukkit - add custom shutdown message
@@ -707,15 +706,15 @@
+ // CraftBukkit start
+ public void broadcastMessage(IChatBaseComponent[] iChatBaseComponents) {
+ for (IChatBaseComponent component : iChatBaseComponents) {
+ broadcastMessage(component, ChatMessageType.SYSTEM, SystemUtils.NIL_UUID);
+ broadcastSystemMessage(component, ChatMessageType.SYSTEM);
+ }
+ }
+ // CraftBukkit end
+
public void broadcastMessage(IChatBaseComponent ichatbasecomponent, ChatMessageType chatmessagetype, UUID uuid) {
this.server.sendMessage(ichatbasecomponent, uuid);
Iterator iterator = this.players.iterator();
@@ -846,16 +1150,23 @@
public void broadcastSystemMessage(IChatBaseComponent ichatbasecomponent, ResourceKey<ChatMessageType> resourcekey) {
this.broadcastSystemMessage(ichatbasecomponent, (entityplayer) -> {
return ichatbasecomponent;
@@ -883,16 +1186,23 @@
}
@@ -743,7 +742,7 @@
Path path = file2.toPath();
if (FileUtils.isPathNormalized(path) && FileUtils.isPathPortable(path) && path.startsWith(file.getPath()) && file2.isFile()) {
@@ -864,7 +1175,7 @@
@@ -901,7 +1211,7 @@
}
serverstatisticmanager = new ServerStatisticManager(this.server, file1);
@@ -752,7 +751,7 @@
}
return serverstatisticmanager;
@@ -872,14 +1183,14 @@
@@ -909,14 +1219,14 @@
public AdvancementDataPlayer getPlayerAdvancements(EntityPlayer entityplayer) {
UUID uuid = entityplayer.getUUID();
@@ -769,7 +768,7 @@
}
advancementdataplayer.setPlayer(entityplayer);
@@ -930,13 +1241,20 @@
@@ -967,13 +1277,20 @@
}
public void reloadResources() {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/rcon/RemoteControlCommandListener.java
+++ b/net/minecraft/server/rcon/RemoteControlCommandListener.java
@@ -36,6 +36,17 @@
@@ -34,6 +34,17 @@
return new CommandListenerWrapper(this, Vec3D.atLowerCornerOf(worldserver.getSharedSpawnPos()), Vec2F.ZERO, worldserver, 4, "Rcon", RemoteControlCommandListener.RCON_COMPONENT, this.server, (Entity) null);
}
@@ -16,5 +16,5 @@
+ // CraftBukkit end
+
@Override
public void sendMessage(IChatBaseComponent ichatbasecomponent, UUID uuid) {
public void sendSystemMessage(IChatBaseComponent ichatbasecomponent) {
this.buffer.append(ichatbasecomponent.getString());