@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/AdvancementDataWorld.java
|
||||
+++ b/net/minecraft/server/AdvancementDataWorld.java
|
||||
@@ -28,11 +28,15 @@
|
||||
@@ -27,11 +27,15 @@
|
||||
import net.minecraft.util.profiling.GameProfilerFiller;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
private AdvancementTree tree = new AdvancementTree();
|
||||
private final HolderLookup.a registries;
|
||||
|
||||
@@ -56,7 +60,7 @@
|
||||
@@ -55,7 +59,7 @@
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/DispenserRegistry.java
|
||||
+++ b/net/minecraft/server/DispenserRegistry.java
|
||||
@@ -29,6 +29,12 @@
|
||||
@@ -28,6 +28,12 @@
|
||||
import net.minecraft.world.level.block.BlockFire;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
public class DispenserRegistry {
|
||||
|
||||
public static final PrintStream STDOUT = System.out;
|
||||
@@ -40,6 +46,23 @@
|
||||
@@ -39,6 +45,23 @@
|
||||
|
||||
public static void bootStrap() {
|
||||
if (!DispenserRegistry.isBootstrapped) {
|
||||
@@ -37,7 +37,7 @@
|
||||
DispenserRegistry.isBootstrapped = true;
|
||||
Instant instant = Instant.now();
|
||||
|
||||
@@ -59,6 +82,69 @@
|
||||
@@ -58,6 +81,69 @@
|
||||
wrapStreams();
|
||||
DispenserRegistry.bootstrapDuration.set(Duration.between(instant, Instant.now()).toMillis());
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -168,13 +168,37 @@
|
||||
@@ -173,13 +173,38 @@
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import com.mojang.serialization.Dynamic;
|
||||
+import com.mojang.serialization.Lifecycle;
|
||||
+import java.io.File;
|
||||
+import java.util.Random;
|
||||
+import jline.console.ConsoleReader;
|
||||
+import joptsimple.OptionSet;
|
||||
@@ -28,7 +29,7 @@
|
||||
+import org.bukkit.event.server.ServerLoadEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTask> implements ServerInfo, ICommandListener, AutoCloseable {
|
||||
public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTask> implements ServerInfo, ChunkIOErrorReporter, ICommandListener, AutoCloseable {
|
||||
|
||||
public static final Logger LOGGER = LogUtils.getLogger();
|
||||
public static final String VANILLA_BRAND = "vanilla";
|
||||
@@ -39,9 +40,9 @@
|
||||
private static final int OVERLOADED_TICKS_THRESHOLD = 20;
|
||||
private static final long OVERLOADED_WARNING_INTERVAL_NANOS = 10L * TimeRange.NANOSECONDS_PER_SECOND;
|
||||
private static final int OVERLOADED_TICKS_WARNING_INTERVAL = 100;
|
||||
@@ -260,6 +284,19 @@
|
||||
private final PotionBrewer potionBrewing;
|
||||
@@ -266,6 +291,19 @@
|
||||
private volatile boolean isSaving;
|
||||
private static final AtomicReference<RuntimeException> fatalException = new AtomicReference();
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public final WorldLoader.a worldLoader;
|
||||
@@ -59,7 +60,7 @@
|
||||
public static <S extends MinecraftServer> S spin(Function<Thread, S> function) {
|
||||
AtomicReference<S> atomicreference = new AtomicReference();
|
||||
Thread thread = new Thread(() -> {
|
||||
@@ -273,14 +310,14 @@
|
||||
@@ -279,14 +317,14 @@
|
||||
thread.setPriority(8);
|
||||
}
|
||||
|
||||
@@ -76,7 +77,7 @@
|
||||
super("Server");
|
||||
this.metricsRecorder = InactiveMetricsRecorder.INSTANCE;
|
||||
this.profiler = this.metricsRecorder.getProfiler();
|
||||
@@ -303,7 +340,7 @@
|
||||
@@ -309,7 +347,7 @@
|
||||
this.customBossEvents = new BossBattleCustomData();
|
||||
this.registries = worldstem.registries();
|
||||
this.worldData = worldstem.worldData();
|
||||
@@ -85,7 +86,7 @@
|
||||
throw new IllegalStateException("Missing Overworld dimension data");
|
||||
} else {
|
||||
this.proxy = proxy;
|
||||
@@ -328,6 +365,33 @@
|
||||
@@ -334,6 +372,33 @@
|
||||
this.executor = SystemUtils.backgroundExecutor();
|
||||
this.potionBrewing = PotionBrewer.bootstrap(this.worldData.enabledFeatures());
|
||||
}
|
||||
@@ -119,7 +120,7 @@
|
||||
}
|
||||
|
||||
private void readScoreboard(WorldPersistentData worldpersistentdata) {
|
||||
@@ -336,7 +400,7 @@
|
||||
@@ -342,7 +407,7 @@
|
||||
|
||||
protected abstract boolean initServer() throws IOException;
|
||||
|
||||
@@ -128,7 +129,7 @@
|
||||
if (!JvmProfiler.INSTANCE.isRunning()) {
|
||||
;
|
||||
}
|
||||
@@ -344,12 +408,8 @@
|
||||
@@ -350,12 +415,8 @@
|
||||
boolean flag = false;
|
||||
ProfiledDuration profiledduration = JvmProfiler.INSTANCE.onWorldLoadedStarted();
|
||||
|
||||
@@ -142,7 +143,7 @@
|
||||
if (profiledduration != null) {
|
||||
profiledduration.finish();
|
||||
}
|
||||
@@ -366,23 +426,217 @@
|
||||
@@ -372,23 +433,217 @@
|
||||
|
||||
protected void forceDifficulty() {}
|
||||
|
||||
@@ -173,7 +174,7 @@
|
||||
+ int dimension = 0;
|
||||
+
|
||||
+ if (dimensionKey == WorldDimension.NETHER) {
|
||||
+ if (isNetherEnabled()) {
|
||||
+ if (server.getAllowNether()) {
|
||||
+ dimension = -1;
|
||||
+ } else {
|
||||
+ continue;
|
||||
@@ -374,7 +375,7 @@
|
||||
|
||||
if (!iworlddataserver.isInitialized()) {
|
||||
try {
|
||||
@@ -406,30 +660,8 @@
|
||||
@@ -412,30 +667,8 @@
|
||||
iworlddataserver.setInitialized(true);
|
||||
}
|
||||
|
||||
@@ -406,7 +407,7 @@
|
||||
|
||||
private static void setInitialSpawn(WorldServer worldserver, IWorldDataServer iworlddataserver, boolean flag, boolean flag1) {
|
||||
if (flag1) {
|
||||
@@ -437,6 +669,21 @@
|
||||
@@ -443,6 +676,21 @@
|
||||
} else {
|
||||
ChunkProviderServer chunkproviderserver = worldserver.getChunkSource();
|
||||
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(chunkproviderserver.randomState().sampler().findSpawnPosition());
|
||||
@@ -428,7 +429,7 @@
|
||||
int i = chunkproviderserver.getGenerator().getSpawnHeight(worldserver);
|
||||
|
||||
if (i < worldserver.getMinBuildHeight()) {
|
||||
@@ -495,8 +742,11 @@
|
||||
@@ -501,8 +749,11 @@
|
||||
iworlddataserver.setGameType(EnumGamemode.SPECTATOR);
|
||||
}
|
||||
|
||||
@@ -442,7 +443,7 @@
|
||||
|
||||
MinecraftServer.LOGGER.info("Preparing start region for dimension {}", worldserver.dimension().location());
|
||||
BlockPosition blockposition = worldserver.getSharedSpawnPos();
|
||||
@@ -506,20 +756,22 @@
|
||||
@@ -512,20 +763,22 @@
|
||||
|
||||
this.nextTickTimeNanos = SystemUtils.getNanos();
|
||||
worldserver.setDefaultSpawnPos(blockposition, worldserver.getSharedSpawnAngle());
|
||||
@@ -473,7 +474,7 @@
|
||||
ForcedChunk forcedchunk = (ForcedChunk) worldserver1.getDataStorage().get(ForcedChunk.factory(), "chunks");
|
||||
|
||||
if (forcedchunk != null) {
|
||||
@@ -534,10 +786,17 @@
|
||||
@@ -540,10 +793,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -494,7 +495,7 @@
|
||||
}
|
||||
|
||||
public EnumGamemode getDefaultGameType() {
|
||||
@@ -567,12 +826,16 @@
|
||||
@@ -573,12 +833,16 @@
|
||||
worldserver.save((IProgressUpdate) null, flag1, worldserver.noSave && !flag2);
|
||||
}
|
||||
|
||||
@@ -511,7 +512,7 @@
|
||||
if (flag1) {
|
||||
Iterator iterator1 = this.getAllLevels().iterator();
|
||||
|
||||
@@ -607,18 +870,40 @@
|
||||
@@ -613,18 +877,40 @@
|
||||
this.stopServer();
|
||||
}
|
||||
|
||||
@@ -552,7 +553,7 @@
|
||||
}
|
||||
|
||||
MinecraftServer.LOGGER.info("Saving worlds");
|
||||
@@ -706,7 +991,7 @@
|
||||
@@ -712,7 +998,7 @@
|
||||
}
|
||||
|
||||
this.nextTickTimeNanos = SystemUtils.getNanos();
|
||||
@@ -561,7 +562,7 @@
|
||||
this.status = this.buildServerStatus();
|
||||
|
||||
while (this.running) {
|
||||
@@ -723,6 +1008,7 @@
|
||||
@@ -729,6 +1015,7 @@
|
||||
if (j > MinecraftServer.OVERLOADED_THRESHOLD_NANOS + 20L * i && this.nextTickTimeNanos - this.lastOverloadWarningNanos >= MinecraftServer.OVERLOADED_WARNING_INTERVAL_NANOS + 100L * i) {
|
||||
long k = j / i;
|
||||
|
||||
@@ -569,7 +570,7 @@
|
||||
MinecraftServer.LOGGER.warn("Can't keep up! Is the server overloaded? Running {}ms or {} ticks behind", j / TimeRange.NANOSECONDS_PER_MILLISECOND, k);
|
||||
this.nextTickTimeNanos += k * i;
|
||||
this.lastOverloadWarningNanos = this.nextTickTimeNanos;
|
||||
@@ -736,6 +1022,7 @@
|
||||
@@ -742,6 +1029,7 @@
|
||||
this.debugCommandProfiler = new MinecraftServer.TimeProfiler(SystemUtils.getNanos(), this.tickCount);
|
||||
}
|
||||
|
||||
@@ -577,7 +578,7 @@
|
||||
this.nextTickTimeNanos += i;
|
||||
this.startMetricsRecordingTick();
|
||||
this.profiler.push("tick");
|
||||
@@ -783,6 +1070,12 @@
|
||||
@@ -789,6 +1077,12 @@
|
||||
this.services.profileCache().clearExecutor();
|
||||
}
|
||||
|
||||
@@ -590,7 +591,7 @@
|
||||
this.onServerExit();
|
||||
}
|
||||
|
||||
@@ -842,7 +1135,14 @@
|
||||
@@ -848,7 +1142,14 @@
|
||||
}
|
||||
|
||||
private boolean haveTime() {
|
||||
@@ -605,8 +606,17 @@
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
protected void waitUntilNextTick() {
|
||||
@@ -901,7 +1201,7 @@
|
||||
public static boolean throwIfFatalException() {
|
||||
@@ -862,7 +1163,7 @@
|
||||
}
|
||||
|
||||
public static void setFatalException(RuntimeException runtimeexception) {
|
||||
- MinecraftServer.fatalException.compareAndSet((Object) null, runtimeexception);
|
||||
+ MinecraftServer.fatalException.compareAndSet(null, runtimeexception); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -928,7 +1229,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -615,7 +625,7 @@
|
||||
this.getProfiler().incrementCounter("runTask");
|
||||
super.doRunTask(ticktask);
|
||||
}
|
||||
@@ -960,8 +1260,10 @@
|
||||
@@ -987,8 +1288,10 @@
|
||||
}
|
||||
|
||||
--this.ticksUntilAutosave;
|
||||
@@ -628,7 +638,7 @@
|
||||
MinecraftServer.LOGGER.debug("Autosave started");
|
||||
this.profiler.push("save");
|
||||
this.saveEverything(true, false, false);
|
||||
@@ -1049,11 +1351,26 @@
|
||||
@@ -1076,11 +1379,26 @@
|
||||
this.getPlayerList().getPlayers().forEach((entityplayer) -> {
|
||||
entityplayer.connection.suspendFlushing();
|
||||
});
|
||||
@@ -655,7 +665,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
WorldServer worldserver = (WorldServer) iterator.next();
|
||||
|
||||
@@ -1062,11 +1379,13 @@
|
||||
@@ -1089,11 +1407,13 @@
|
||||
|
||||
return s + " " + String.valueOf(worldserver.dimension().location());
|
||||
});
|
||||
@@ -669,7 +679,7 @@
|
||||
|
||||
this.profiler.push("tick");
|
||||
|
||||
@@ -1156,6 +1475,22 @@
|
||||
@@ -1183,6 +1503,22 @@
|
||||
return (WorldServer) this.levels.get(resourcekey);
|
||||
}
|
||||
|
||||
@@ -692,7 +702,7 @@
|
||||
public Set<ResourceKey<World>> levelKeys() {
|
||||
return this.levels.keySet();
|
||||
}
|
||||
@@ -1185,7 +1520,7 @@
|
||||
@@ -1212,7 +1548,7 @@
|
||||
|
||||
@DontObfuscate
|
||||
public String getServerModName() {
|
||||
@@ -701,7 +711,7 @@
|
||||
}
|
||||
|
||||
public SystemReport fillSystemReport(SystemReport systemreport) {
|
||||
@@ -1527,11 +1862,11 @@
|
||||
@@ -1554,11 +1890,11 @@
|
||||
|
||||
public CompletableFuture<Void> reloadResources(Collection<String> collection) {
|
||||
CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> {
|
||||
@@ -715,7 +725,7 @@
|
||||
}, this).thenCompose((immutablelist) -> {
|
||||
ResourceManager resourcemanager = new ResourceManager(EnumResourcePackType.SERVER_DATA, immutablelist);
|
||||
|
||||
@@ -1546,6 +1881,7 @@
|
||||
@@ -1573,6 +1909,7 @@
|
||||
}).thenAcceptAsync((minecraftserver_reloadableresources) -> {
|
||||
this.resources.close();
|
||||
this.resources = minecraftserver_reloadableresources;
|
||||
@@ -723,7 +733,7 @@
|
||||
this.packRepository.setSelected(collection);
|
||||
WorldDataConfiguration worlddataconfiguration = new WorldDataConfiguration(getSelectedPacks(this.packRepository, true), this.worldData.enabledFeatures());
|
||||
|
||||
@@ -1846,7 +2182,7 @@
|
||||
@@ -1873,7 +2210,7 @@
|
||||
final List<String> list = Lists.newArrayList();
|
||||
final GameRules gamerules = this.getGameRules();
|
||||
|
||||
@@ -732,7 +742,7 @@
|
||||
@Override
|
||||
public <T extends GameRules.GameRuleValue<T>> void visit(GameRules.GameRuleKey<T> gamerules_gamerulekey, GameRules.GameRuleDefinition<T> gamerules_gameruledefinition) {
|
||||
list.add(String.format(Locale.ROOT, "%s=%s\n", gamerules_gamerulekey.getId(), gamerules.getRule(gamerules_gamerulekey)));
|
||||
@@ -1952,7 +2288,7 @@
|
||||
@@ -1979,7 +2316,7 @@
|
||||
try {
|
||||
label51:
|
||||
{
|
||||
@@ -741,7 +751,7 @@
|
||||
|
||||
try {
|
||||
arraylist = Lists.newArrayList(NativeModuleLister.listModules());
|
||||
@@ -2002,6 +2338,22 @@
|
||||
@@ -2029,6 +2366,22 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -764,7 +774,7 @@
|
||||
private void startMetricsRecordingTick() {
|
||||
if (this.willStartRecordingMetrics) {
|
||||
this.metricsRecorder = ActiveMetricsRecorder.createStarted(new ServerMetricsSamplersProvider(SystemUtils.timeSource, this.isDedicatedServer()), SystemUtils.timeSource, SystemUtils.ioPool(), new MetricsPersister("server"), this.onMetricsRecordingStopped, (path) -> {
|
||||
@@ -2132,6 +2484,11 @@
|
||||
@@ -2159,6 +2512,11 @@
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -58,6 +58,18 @@
|
||||
@@ -60,6 +60,18 @@
|
||||
import net.minecraft.world.level.storage.Convertable;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
public class DedicatedServer extends MinecraftServer implements IMinecraftServer {
|
||||
|
||||
static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -66,7 +78,7 @@
|
||||
@@ -68,7 +80,7 @@
|
||||
private final List<ServerCommand> consoleInput = Collections.synchronizedList(Lists.newArrayList());
|
||||
@Nullable
|
||||
private RemoteStatusListener queryThreadGs4;
|
||||
@@ -28,9 +28,9 @@
|
||||
@Nullable
|
||||
private RemoteControlListener rconThread;
|
||||
public DedicatedServerSettings settings;
|
||||
@@ -79,10 +91,12 @@
|
||||
@Nullable
|
||||
@@ -82,10 +94,12 @@
|
||||
private DebugSampleSubscriptionTracker debugSampleSubscriptionTracker;
|
||||
public ServerLinks serverLinks;
|
||||
|
||||
- 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);
|
||||
@@ -42,9 +42,9 @@
|
||||
- this.rconConsoleSource = new RemoteControlCommandListener(this);
|
||||
+ // this.rconConsoleSource = new RemoteControlCommandListener(this); // CraftBukkit - remove field
|
||||
this.textFilterClient = TextFilter.createFromConfig(dedicatedserversettings.getProperties().textFilteringConfig);
|
||||
this.serverLinks = createServerLinks(dedicatedserversettings);
|
||||
}
|
||||
|
||||
@@ -90,13 +104,44 @@
|
||||
@@ -94,13 +108,44 @@
|
||||
public boolean initServer() throws IOException {
|
||||
Thread thread = new Thread("Server console handler") {
|
||||
public void run() {
|
||||
@@ -92,7 +92,7 @@
|
||||
}
|
||||
} catch (IOException ioexception) {
|
||||
DedicatedServer.LOGGER.error("Exception handling console input", ioexception);
|
||||
@@ -105,6 +150,29 @@
|
||||
@@ -109,6 +154,29 @@
|
||||
}
|
||||
};
|
||||
|
||||
@@ -122,7 +122,7 @@
|
||||
thread.setDaemon(true);
|
||||
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(DedicatedServer.LOGGER));
|
||||
thread.start();
|
||||
@@ -129,7 +197,7 @@
|
||||
@@ -133,7 +201,7 @@
|
||||
this.setMotd(dedicatedserverproperties.motd);
|
||||
super.setPlayerIdleTimeout((Integer) dedicatedserverproperties.playerIdleTimeout.get());
|
||||
this.setEnforceWhitelist(dedicatedserverproperties.enforceWhitelist);
|
||||
@@ -131,7 +131,7 @@
|
||||
DedicatedServer.LOGGER.info("Default game type: {}", dedicatedserverproperties.gamemode);
|
||||
InetAddress inetaddress = null;
|
||||
|
||||
@@ -153,6 +221,12 @@
|
||||
@@ -157,6 +225,12 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -144,7 +144,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.");
|
||||
@@ -167,7 +241,7 @@
|
||||
@@ -171,7 +245,7 @@
|
||||
if (!NameReferencingFileConverter.serverReadyAfterUserconversion(this)) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -153,7 +153,7 @@
|
||||
this.debugSampleSubscriptionTracker = new DebugSampleSubscriptionTracker(this.getPlayerList());
|
||||
this.tickTimeLogger = new RemoteSampleLogger(TpsDebugDimensions.values().length, this.debugSampleSubscriptionTracker, RemoteDebugSampleType.TICK_TIME);
|
||||
long i = SystemUtils.getNanos();
|
||||
@@ -175,13 +249,13 @@
|
||||
@@ -179,13 +253,13 @@
|
||||
TileEntitySkull.setup(this.services, this);
|
||||
UserCache.setUsesAuthentication(this.usesAuthentication());
|
||||
DedicatedServer.LOGGER.info("Preparing level \"{}\"", this.getLevelIdName());
|
||||
@@ -169,7 +169,7 @@
|
||||
}
|
||||
|
||||
if (dedicatedserverproperties.enableQuery) {
|
||||
@@ -307,6 +381,7 @@
|
||||
@@ -311,6 +385,7 @@
|
||||
this.queryThreadGs4.stop();
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -328,7 +403,15 @@
|
||||
@@ -332,7 +407,15 @@
|
||||
while (!this.consoleInput.isEmpty()) {
|
||||
ServerCommand servercommand = (ServerCommand) this.consoleInput.remove(0);
|
||||
|
||||
@@ -194,7 +194,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -555,16 +638,52 @@
|
||||
@@ -559,16 +642,52 @@
|
||||
|
||||
@Override
|
||||
public String getPluginNames() {
|
||||
@@ -251,9 +251,9 @@
|
||||
}
|
||||
|
||||
public void storeUsingWhiteList(boolean flag) {
|
||||
@@ -641,4 +760,15 @@
|
||||
public boolean acceptsTransfers() {
|
||||
return this.settings.getProperties().acceptsTransfers;
|
||||
@@ -673,4 +792,15 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
public final boolean onlineMode = this.get("online-mode", true);
|
||||
public final boolean preventProxyConnections = this.get("prevent-proxy-connections", false);
|
||||
public final String serverIp = this.get("server-ip", "");
|
||||
@@ -104,8 +109,10 @@
|
||||
@@ -105,8 +110,10 @@
|
||||
public final WorldOptions worldOptions;
|
||||
public boolean acceptsTransfers;
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
this.difficulty = (EnumDifficulty) this.get("difficulty", dispatchNumberOrString(EnumDifficulty::byId, EnumDifficulty::byName), EnumDifficulty::getKey, EnumDifficulty.EASY);
|
||||
this.gamemode = (EnumGamemode) this.get("gamemode", dispatchNumberOrString(EnumGamemode::byId, EnumGamemode::byName), EnumGamemode::getName, EnumGamemode.SURVIVAL);
|
||||
this.levelName = this.get("level-name", "world");
|
||||
@@ -164,13 +171,15 @@
|
||||
@@ -165,13 +172,15 @@
|
||||
this.initialDataPackConfiguration = getDatapackConfig(this.get("initial-enabled-packs", String.join(",", WorldDataConfiguration.DEFAULT.dataPacks().getEnabled())), this.get("initial-disabled-packs", String.join(",", WorldDataConfiguration.DEFAULT.dataPacks().getDisabled())));
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -251,10 +260,10 @@
|
||||
@@ -252,10 +261,10 @@
|
||||
}).orElseThrow(() -> {
|
||||
return new IllegalStateException("Invalid datapack contents: can't find default preset");
|
||||
});
|
||||
@@ -63,7 +63,7 @@
|
||||
});
|
||||
|
||||
Objects.requireNonNull(iregistry);
|
||||
@@ -266,7 +275,7 @@
|
||||
@@ -267,7 +276,7 @@
|
||||
|
||||
if (holder.is(WorldPresets.FLAT)) {
|
||||
RegistryOps<JsonElement> registryops = iregistrycustom.createSerializationContext(JsonOps.INSTANCE);
|
||||
|
||||
@@ -1,35 +1,6 @@
|
||||
--- a/net/minecraft/server/level/ChunkMapDistance.java
|
||||
+++ b/net/minecraft/server/level/ChunkMapDistance.java
|
||||
@@ -121,10 +121,25 @@
|
||||
}
|
||||
|
||||
if (!this.chunksToUpdateFutures.isEmpty()) {
|
||||
- this.chunksToUpdateFutures.forEach((playerchunk) -> {
|
||||
+ // CraftBukkit start
|
||||
+ // Iterate pending chunk updates with protection against concurrent modification exceptions
|
||||
+ java.util.Iterator<PlayerChunk> iter = this.chunksToUpdateFutures.iterator();
|
||||
+ int expectedSize = this.chunksToUpdateFutures.size();
|
||||
+ do {
|
||||
+ PlayerChunk playerchunk = iter.next();
|
||||
+ iter.remove();
|
||||
+ expectedSize--;
|
||||
+
|
||||
playerchunk.updateFutures(playerchunkmap, this.mainThreadExecutor);
|
||||
- });
|
||||
- this.chunksToUpdateFutures.clear();
|
||||
+
|
||||
+ // Reset iterator if set was modified using add()
|
||||
+ if (this.chunksToUpdateFutures.size() != expectedSize) {
|
||||
+ expectedSize = this.chunksToUpdateFutures.size();
|
||||
+ iter = this.chunksToUpdateFutures.iterator();
|
||||
+ }
|
||||
+ } while (iter.hasNext());
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
return true;
|
||||
} else {
|
||||
if (!this.ticketsToRelease.isEmpty()) {
|
||||
@@ -160,7 +175,7 @@
|
||||
@@ -163,7 +163,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +9,7 @@
|
||||
ArraySetSorted<Ticket<?>> arraysetsorted = this.getTickets(i);
|
||||
int j = getTicketLevelAt(arraysetsorted);
|
||||
Ticket<?> ticket1 = (Ticket) arraysetsorted.addOrGet(ticket);
|
||||
@@ -170,13 +185,15 @@
|
||||
@@ -173,13 +173,15 @@
|
||||
this.ticketTracker.update(i, ticket.getTicketLevel(), true);
|
||||
}
|
||||
|
||||
@@ -56,7 +27,7 @@
|
||||
}
|
||||
|
||||
if (arraysetsorted.isEmpty()) {
|
||||
@@ -184,6 +201,7 @@
|
||||
@@ -187,6 +189,7 @@
|
||||
}
|
||||
|
||||
this.ticketTracker.update(i, getTicketLevelAt(arraysetsorted), false);
|
||||
@@ -64,7 +35,7 @@
|
||||
}
|
||||
|
||||
public <T> void addTicket(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) {
|
||||
@@ -197,19 +215,33 @@
|
||||
@@ -200,19 +203,33 @@
|
||||
}
|
||||
|
||||
public <T> void addRegionTicket(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) {
|
||||
@@ -100,7 +71,7 @@
|
||||
}
|
||||
|
||||
private ArraySetSorted<Ticket<?>> getTickets(long i) {
|
||||
@@ -248,6 +280,7 @@
|
||||
@@ -251,6 +268,7 @@
|
||||
ChunkCoordIntPair chunkcoordintpair = sectionposition.chunk();
|
||||
long i = chunkcoordintpair.toLong();
|
||||
ObjectSet<EntityPlayer> objectset = (ObjectSet) this.playersPerChunk.get(i);
|
||||
@@ -108,7 +79,7 @@
|
||||
|
||||
objectset.remove(entityplayer);
|
||||
if (objectset.isEmpty()) {
|
||||
@@ -377,6 +410,26 @@
|
||||
@@ -380,6 +398,26 @@
|
||||
return !this.tickets.isEmpty();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/level/ChunkProviderServer.java
|
||||
+++ b/net/minecraft/server/level/ChunkProviderServer.java
|
||||
@@ -81,6 +81,16 @@
|
||||
@@ -82,6 +82,16 @@
|
||||
this.clearCache();
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
@Override
|
||||
public LightEngineThreaded getLightEngine() {
|
||||
return this.lightEngine;
|
||||
@@ -124,7 +134,7 @@
|
||||
@@ -125,7 +135,7 @@
|
||||
if (k == this.lastChunkPos[l] && chunkstatus == this.lastChunkStatus[l]) {
|
||||
IChunkAccess ichunkaccess = this.lastChunk[l];
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
return ichunkaccess;
|
||||
}
|
||||
}
|
||||
@@ -137,7 +147,7 @@
|
||||
@@ -138,7 +148,7 @@
|
||||
Objects.requireNonNull(completablefuture);
|
||||
chunkproviderserver_b.managedBlock(completablefuture::isDone);
|
||||
ChunkResult<IChunkAccess> chunkresult = (ChunkResult) completablefuture.join();
|
||||
@@ -35,22 +35,7 @@
|
||||
|
||||
if (ichunkaccess1 == null && flag) {
|
||||
throw (IllegalStateException) SystemUtils.pauseInIde(new IllegalStateException("Chunk not there when requested: " + chunkresult.getError()));
|
||||
@@ -170,12 +180,12 @@
|
||||
if (playerchunk == null) {
|
||||
return null;
|
||||
} else {
|
||||
- ChunkResult<IChunkAccess> chunkresult = (ChunkResult) playerchunk.getFutureIfPresent(ChunkStatus.FULL).getNow((Object) null);
|
||||
+ ChunkResult<IChunkAccess> chunkresult = (ChunkResult) playerchunk.getFutureIfPresent(ChunkStatus.FULL).getNow(null); // CraftBukkit - decompile error
|
||||
|
||||
if (chunkresult == null) {
|
||||
return null;
|
||||
} else {
|
||||
- IChunkAccess ichunkaccess1 = (IChunkAccess) chunkresult.orElse((Object) null);
|
||||
+ IChunkAccess ichunkaccess1 = (IChunkAccess) chunkresult.orElse(null); // CraftBukkit - decompile error
|
||||
|
||||
if (ichunkaccess1 != null) {
|
||||
this.storeInCache(k, ichunkaccess1, ChunkStatus.FULL);
|
||||
@@ -223,7 +233,15 @@
|
||||
@@ -218,7 +228,15 @@
|
||||
int l = ChunkLevel.byStatus(chunkstatus);
|
||||
PlayerChunk playerchunk = this.getVisibleChunkIfPresent(k);
|
||||
|
||||
@@ -67,16 +52,7 @@
|
||||
this.distanceManager.addTicket(TicketType.UNKNOWN, chunkcoordintpair, l, chunkcoordintpair);
|
||||
if (this.chunkAbsent(playerchunk, l)) {
|
||||
GameProfilerFiller gameprofilerfiller = this.level.getProfiler();
|
||||
@@ -242,7 +260,7 @@
|
||||
}
|
||||
|
||||
private boolean chunkAbsent(@Nullable PlayerChunk playerchunk, int i) {
|
||||
- return playerchunk == null || playerchunk.getTicketLevel() > i;
|
||||
+ return playerchunk == null || playerchunk.oldTicketLevel > i; // CraftBukkit using oldTicketLevel for isLoaded checks
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -315,11 +333,31 @@
|
||||
@@ -292,11 +310,31 @@
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
@@ -109,7 +85,7 @@
|
||||
@Override
|
||||
public void tick(BooleanSupplier booleansupplier, boolean flag) {
|
||||
this.level.getProfiler().push("purge");
|
||||
@@ -369,11 +407,11 @@
|
||||
@@ -346,11 +384,11 @@
|
||||
|
||||
this.lastSpawnState = spawnercreature_d;
|
||||
gameprofilerfiller.popPush("spawnAndTick");
|
||||
@@ -123,7 +99,7 @@
|
||||
Iterator iterator1 = list.iterator();
|
||||
|
||||
while (iterator1.hasNext()) {
|
||||
@@ -576,13 +614,19 @@
|
||||
@@ -560,13 +598,19 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/level/EntityPlayer.java
|
||||
+++ b/net/minecraft/server/level/EntityPlayer.java
|
||||
@@ -165,6 +165,39 @@
|
||||
@@ -166,6 +166,42 @@
|
||||
import net.minecraft.world.scores.criteria.IScoreboardCriteria;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
+import net.minecraft.world.damagesource.CombatTracker;
|
||||
+import net.minecraft.world.food.FoodMetaData;
|
||||
+import net.minecraft.world.inventory.ContainerPlayer;
|
||||
+import net.minecraft.world.item.enchantment.EnchantmentEffectComponents;
|
||||
+import net.minecraft.world.item.enchantment.EnchantmentManager;
|
||||
+import net.minecraft.world.level.block.BlockChest;
|
||||
+import net.minecraft.world.level.dimension.WorldDimension;
|
||||
@@ -24,12 +25,14 @@
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.craftbukkit.util.CraftDimensionUtil;
|
||||
+import org.bukkit.craftbukkit.util.CraftLocation;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.entity.EntityExhaustionEvent;
|
||||
+import org.bukkit.event.player.PlayerBedLeaveEvent;
|
||||
+import org.bukkit.event.player.PlayerChangedMainHandEvent;
|
||||
+import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
+import org.bukkit.event.player.PlayerLocaleChangeEvent;
|
||||
+import org.bukkit.event.player.PlayerPortalEvent;
|
||||
+import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
+import org.bukkit.event.player.PlayerSpawnChangeEvent;
|
||||
+import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
+import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
@@ -40,7 +43,7 @@
|
||||
public class EntityPlayer extends EntityHuman {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -203,7 +236,7 @@
|
||||
@@ -204,7 +240,7 @@
|
||||
private int levitationStartTime;
|
||||
private boolean disconnected;
|
||||
private int requestedViewDistance;
|
||||
@@ -49,7 +52,7 @@
|
||||
@Nullable
|
||||
private Vec3D startingToFallPosition;
|
||||
@Nullable
|
||||
@@ -233,6 +266,21 @@
|
||||
@@ -235,6 +271,21 @@
|
||||
private int containerCounter;
|
||||
public boolean wonGame;
|
||||
|
||||
@@ -71,8 +74,8 @@
|
||||
public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, ClientInformation clientinformation) {
|
||||
super(worldserver, worldserver.getSharedSpawnPos(), worldserver.getSharedSpawnAngle(), gameprofile);
|
||||
this.chatVisibility = EnumChatVisibility.FULL;
|
||||
@@ -299,12 +347,65 @@
|
||||
this.fudgeSpawnLocation(worldserver);
|
||||
@@ -302,14 +353,67 @@
|
||||
this.moveTo(this.adjustSpawnLocation(worldserver, worldserver.getSharedSpawnPos()).getBottomCenter(), 0.0F, 0.0F);
|
||||
this.updateOptions(clientinformation);
|
||||
this.object = null;
|
||||
+
|
||||
@@ -130,15 +133,17 @@
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
|
||||
private void fudgeSpawnLocation(WorldServer worldserver) {
|
||||
BlockPosition blockposition = worldserver.getSharedSpawnPos();
|
||||
@Override
|
||||
public BlockPosition adjustSpawnLocation(WorldServer worldserver, BlockPosition blockposition) {
|
||||
AxisAlignedBB axisalignedbb = this.getDimensions(EntityPose.STANDING).makeBoundingBox(Vec3D.ZERO);
|
||||
BlockPosition blockposition1 = blockposition;
|
||||
|
||||
- if (worldserver.dimensionType().hasSkyLight() && worldserver.getServer().getWorldData().getGameType() != EnumGamemode.ADVENTURE) {
|
||||
+ if (worldserver.dimensionType().hasSkyLight() && worldserver.serverLevelData.getGameType() != EnumGamemode.ADVENTURE) { // CraftBukkit
|
||||
int i = Math.max(0, this.server.getSpawnRadius(worldserver));
|
||||
int j = MathHelper.floor(worldserver.getWorldBorder().getDistanceToBorder((double) blockposition.getX(), (double) blockposition.getZ()));
|
||||
|
||||
@@ -359,7 +460,7 @@
|
||||
@@ -366,7 +470,7 @@
|
||||
dataresult = WardenSpawnTracker.CODEC.parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.get("warden_spawn_tracker")));
|
||||
logger = EntityPlayer.LOGGER;
|
||||
Objects.requireNonNull(logger);
|
||||
@@ -147,7 +152,7 @@
|
||||
this.wardenSpawnTracker = wardenspawntracker;
|
||||
});
|
||||
}
|
||||
@@ -374,17 +475,26 @@
|
||||
@@ -381,17 +485,26 @@
|
||||
if (nbttagcompound.contains("recipeBook", 10)) {
|
||||
this.recipeBook.fromNbt(nbttagcompound.getCompound("recipeBook"), this.server.getRecipeManager());
|
||||
}
|
||||
@@ -175,7 +180,7 @@
|
||||
Logger logger1 = EntityPlayer.LOGGER;
|
||||
|
||||
Objects.requireNonNull(logger1);
|
||||
@@ -399,7 +509,7 @@
|
||||
@@ -406,7 +519,7 @@
|
||||
dataresult = BlockPosition.CODEC.parse(DynamicOpsNBT.INSTANCE, nbtbase);
|
||||
logger = EntityPlayer.LOGGER;
|
||||
Objects.requireNonNull(logger);
|
||||
@@ -184,7 +189,7 @@
|
||||
this.raidOmenPosition = blockposition;
|
||||
});
|
||||
}
|
||||
@@ -409,7 +519,7 @@
|
||||
@@ -416,7 +529,7 @@
|
||||
@Override
|
||||
public void addAdditionalSaveData(NBTTagCompound nbttagcompound) {
|
||||
super.addAdditionalSaveData(nbttagcompound);
|
||||
@@ -193,7 +198,7 @@
|
||||
Logger logger = EntityPlayer.LOGGER;
|
||||
|
||||
Objects.requireNonNull(logger);
|
||||
@@ -430,7 +540,20 @@
|
||||
@@ -437,7 +550,20 @@
|
||||
Entity entity = this.getRootVehicle();
|
||||
Entity entity1 = this.getVehicle();
|
||||
|
||||
@@ -215,7 +220,7 @@
|
||||
NBTTagCompound nbttagcompound2 = new NBTTagCompound();
|
||||
NBTTagCompound nbttagcompound3 = new NBTTagCompound();
|
||||
|
||||
@@ -455,6 +578,7 @@
|
||||
@@ -462,6 +588,7 @@
|
||||
nbttagcompound.put("SpawnDimension", nbtbase);
|
||||
});
|
||||
}
|
||||
@@ -223,7 +228,7 @@
|
||||
|
||||
nbttagcompound.putBoolean("spawn_extra_particles_on_fall", this.spawnExtraParticlesOnFall);
|
||||
if (this.raidOmenPosition != null) {
|
||||
@@ -468,6 +592,29 @@
|
||||
@@ -475,6 +602,29 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -236,7 +241,7 @@
|
||||
+ if (this.respawnDimension != null) {
|
||||
+ world = this.server.getLevel(this.respawnDimension);
|
||||
+ if (world != null && this.getRespawnPosition() != null) {
|
||||
+ position = EntityHuman.findRespawnPositionAndUseSpawnBlock((WorldServer) world, this.getRespawnPosition(), this.getRespawnAngle(), false, false).orElse(null);
|
||||
+ position = EntityPlayer.findRespawnAndUseSpawnBlock((WorldServer) world, this.getRespawnPosition(), this.getRespawnAngle(), false, false).map(EntityPlayer.RespawnPosAngle::position).orElse(null);
|
||||
+ }
|
||||
+ }
|
||||
+ if (world == null || position == null) {
|
||||
@@ -253,7 +258,7 @@
|
||||
public void setExperiencePoints(int i) {
|
||||
float f = (float) this.getXpNeededForNextLevel();
|
||||
float f1 = (f - 1.0F) / f;
|
||||
@@ -526,6 +673,11 @@
|
||||
@@ -533,6 +683,11 @@
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
@@ -265,7 +270,7 @@
|
||||
this.gameMode.tick();
|
||||
this.wardenSpawnTracker.tick();
|
||||
--this.spawnInvulnerableTime;
|
||||
@@ -606,7 +758,7 @@
|
||||
@@ -613,7 +768,7 @@
|
||||
}
|
||||
|
||||
if (this.getHealth() != this.lastSentHealth || this.lastSentFood != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) {
|
||||
@@ -274,7 +279,7 @@
|
||||
this.lastSentHealth = this.getHealth();
|
||||
this.lastSentFood = this.foodData.getFoodLevel();
|
||||
this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F;
|
||||
@@ -637,6 +789,12 @@
|
||||
@@ -644,6 +799,12 @@
|
||||
this.updateScoreForCriteria(IScoreboardCriteria.EXPERIENCE, MathHelper.ceil((float) this.lastRecordedExperience));
|
||||
}
|
||||
|
||||
@@ -287,7 +292,7 @@
|
||||
if (this.experienceLevel != this.lastRecordedLevel) {
|
||||
this.lastRecordedLevel = this.experienceLevel;
|
||||
this.updateScoreForCriteria(IScoreboardCriteria.LEVEL, MathHelper.ceil((float) this.lastRecordedLevel));
|
||||
@@ -651,6 +809,20 @@
|
||||
@@ -658,6 +819,20 @@
|
||||
CriterionTriggers.LOCATION.trigger(this);
|
||||
}
|
||||
|
||||
@@ -308,7 +313,7 @@
|
||||
} catch (Throwable throwable) {
|
||||
CrashReport crashreport = CrashReport.forThrowable(throwable, "Ticking player");
|
||||
CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Player being ticked");
|
||||
@@ -696,7 +868,8 @@
|
||||
@@ -703,7 +878,8 @@
|
||||
}
|
||||
|
||||
private void updateScoreForCriteria(IScoreboardCriteria iscoreboardcriteria, int i) {
|
||||
@@ -318,7 +323,7 @@
|
||||
scoreaccess.set(i);
|
||||
});
|
||||
}
|
||||
@@ -705,9 +878,47 @@
|
||||
@@ -712,9 +888,47 @@
|
||||
public void die(DamageSource damagesource) {
|
||||
this.gameEvent(GameEvent.ENTITY_DIE);
|
||||
boolean flag = this.level().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES);
|
||||
@@ -333,7 +338,7 @@
|
||||
- IChatBaseComponent ichatbasecomponent = this.getCombatTracker().getDeathMessage();
|
||||
+ if (!keepInventory) {
|
||||
+ for (ItemStack item : this.getInventory().getContents()) {
|
||||
+ if (!item.isEmpty() && !EnchantmentManager.hasVanishingCurse(item)) {
|
||||
+ if (!item.isEmpty() && EnchantmentManager.has(item, EnchantmentEffectComponents.PREVENT_EQUIPMENT_DROP)) {
|
||||
+ loot.add(CraftItemStack.asCraftMirror(item));
|
||||
+ }
|
||||
+ }
|
||||
@@ -368,15 +373,15 @@
|
||||
|
||||
this.connection.send(new ClientboundPlayerCombatKillPacket(this.getId(), ichatbasecomponent), PacketSendListener.exceptionallySend(() -> {
|
||||
boolean flag1 = true;
|
||||
@@ -738,12 +949,18 @@
|
||||
@@ -745,12 +959,18 @@
|
||||
if (this.level().getGameRules().getBoolean(GameRules.RULE_FORGIVE_DEAD_PLAYERS)) {
|
||||
this.tellNeutralMobsThatIDied();
|
||||
}
|
||||
-
|
||||
- if (!this.isSpectator()) {
|
||||
- this.dropAllDeathLoot(damagesource);
|
||||
- this.dropAllDeathLoot(this.serverLevel(), damagesource);
|
||||
+ // SPIGOT-5478 must be called manually now
|
||||
+ this.dropExperience();
|
||||
+ this.dropExperience(damagesource.getEntity());
|
||||
+ // we clean the player's inventory after the EntityDeathEvent is called so plugins can get the exact state of the inventory.
|
||||
+ if (!event.getKeepInventory()) {
|
||||
+ this.getInventory().clearContent();
|
||||
@@ -391,7 +396,7 @@
|
||||
EntityLiving entityliving = this.getKillCredit();
|
||||
|
||||
if (entityliving != null) {
|
||||
@@ -778,10 +995,12 @@
|
||||
@@ -785,10 +1005,12 @@
|
||||
if (entity != this) {
|
||||
super.awardKillScore(entity, i, damagesource);
|
||||
this.increaseScore(i);
|
||||
@@ -406,7 +411,7 @@
|
||||
} else {
|
||||
this.awardStat(StatisticList.MOB_KILLS);
|
||||
}
|
||||
@@ -799,7 +1018,8 @@
|
||||
@@ -806,7 +1028,8 @@
|
||||
int i = scoreboardteam.getColor().getId();
|
||||
|
||||
if (i >= 0 && i < aiscoreboardcriteria.length) {
|
||||
@@ -416,7 +421,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -849,18 +1069,20 @@
|
||||
@@ -856,10 +1079,16 @@
|
||||
}
|
||||
|
||||
private boolean isPvpAllowed() {
|
||||
@@ -425,111 +430,152 @@
|
||||
+ return this.level().pvpMode;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected ShapeDetectorShape findDimensionEntryPoint(WorldServer worldserver) {
|
||||
ShapeDetectorShape shapedetectorshape = super.findDimensionEntryPoint(worldserver);
|
||||
+ worldserver = (shapedetectorshape == null) ? worldserver : shapedetectorshape.world; // CraftBukkit
|
||||
|
||||
- if (shapedetectorshape != null && this.level().dimension() == World.OVERWORLD && worldserver.dimension() == World.END) {
|
||||
+ if (shapedetectorshape != null && this.level().getTypeKey() == WorldDimension.OVERWORLD && worldserver != null && worldserver.getTypeKey() == WorldDimension.END) { // CraftBukkit
|
||||
Vec3D vec3d = shapedetectorshape.pos.add(0.0D, -1.0D, 0.0D);
|
||||
|
||||
- return new ShapeDetectorShape(vec3d, Vec3D.ZERO, 90.0F, 0.0F);
|
||||
+ return new ShapeDetectorShape(vec3d, Vec3D.ZERO, 90.0F, 0.0F, worldserver, shapedetectorshape.portalEventInfo); // CraftBukkit
|
||||
} else {
|
||||
return shapedetectorshape;
|
||||
}
|
||||
@@ -869,11 +1091,20 @@
|
||||
@Nullable
|
||||
@Override
|
||||
public Entity changeDimension(WorldServer worldserver) {
|
||||
- this.isChangingDimension = true;
|
||||
+ // CraftBukkit start
|
||||
+ return changeDimension(worldserver, TeleportCause.UNKNOWN);
|
||||
+ }
|
||||
+
|
||||
+ @Nullable
|
||||
+ public Entity changeDimension(WorldServer worldserver, PlayerTeleportEvent.TeleportCause cause) {
|
||||
- public DimensionTransition findRespawnPositionAndUseSpawnBlock(boolean flag, DimensionTransition.a dimensiontransition_a) {
|
||||
+ // CraftBukkit start
|
||||
+ public DimensionTransition findRespawnPositionAndUseSpawnBlock(boolean flag, DimensionTransition.a dimensiontransition_a, PlayerRespawnEvent.RespawnReason reason) {
|
||||
+ DimensionTransition dimensionTransition;
|
||||
+ boolean isBedSpawn = false;
|
||||
+ boolean isAnchorSpawn = false;
|
||||
+ // CraftBukkit end
|
||||
+ if (this.isSleeping()) return this; // CraftBukkit - SPIGOT-3154
|
||||
+ // this.isChangingDimension = true; // CraftBukkit - Moved down and into PlayerList#changeDimension
|
||||
WorldServer worldserver1 = this.serverLevel();
|
||||
- ResourceKey<World> resourcekey = worldserver1.dimension();
|
||||
+ ResourceKey<WorldDimension> resourcekey = worldserver1.getTypeKey(); // CraftBukkit
|
||||
BlockPosition blockposition = this.getRespawnPosition();
|
||||
float f = this.getRespawnAngle();
|
||||
boolean flag1 = this.isRespawnForced();
|
||||
@@ -871,13 +1100,32 @@
|
||||
if (optional.isPresent()) {
|
||||
EntityPlayer.RespawnPosAngle entityplayer_respawnposangle = (EntityPlayer.RespawnPosAngle) optional.get();
|
||||
|
||||
- if (resourcekey == World.END && worldserver.dimension() == World.OVERWORLD) {
|
||||
+ if (resourcekey == WorldDimension.END && worldserver != null && worldserver.getTypeKey() == WorldDimension.OVERWORLD) { // CraftBukkit
|
||||
+ this.isChangingDimension = true; // CraftBukkit - Moved down from above
|
||||
this.unRide();
|
||||
this.serverLevel().removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION);
|
||||
if (!this.wonGame) {
|
||||
@@ -884,6 +1115,8 @@
|
||||
|
||||
return this;
|
||||
- return new DimensionTransition(worldserver, entityplayer_respawnposangle.position(), Vec3D.ZERO, entityplayer_respawnposangle.yaw(), 0.0F, dimensiontransition_a);
|
||||
+ // CraftBukkit start
|
||||
+ isBedSpawn = entityplayer_respawnposangle.isBedSpawn();
|
||||
+ isAnchorSpawn = entityplayer_respawnposangle.isAnchorSpawn();
|
||||
+ dimensionTransition = new DimensionTransition(worldserver, entityplayer_respawnposangle.position(), Vec3D.ZERO, entityplayer_respawnposangle.yaw(), 0.0F, dimensiontransition_a);
|
||||
+ // CraftBukkit end
|
||||
} else {
|
||||
- return DimensionTransition.missingRespawnBlock(this.server.overworld(), this, dimensiontransition_a);
|
||||
+ dimensionTransition = DimensionTransition.missingRespawnBlock(this.server.overworld(), this, dimensiontransition_a); // CraftBukkit
|
||||
}
|
||||
} else {
|
||||
- return new DimensionTransition(this.server.overworld(), this, dimensiontransition_a);
|
||||
+ dimensionTransition = new DimensionTransition(this.server.overworld(), this, dimensiontransition_a); // CraftBukkit
|
||||
}
|
||||
+ // CraftBukkit start
|
||||
+ if (reason == null) {
|
||||
+ return dimensionTransition;
|
||||
+ }
|
||||
+
|
||||
+ Player respawnPlayer = this.getBukkitEntity();
|
||||
+ Location location = CraftLocation.toBukkit(dimensionTransition.pos(), dimensionTransition.newLevel().getWorld(), dimensionTransition.yRot(), dimensionTransition.xRot());
|
||||
+
|
||||
+ PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn, isAnchorSpawn, reason);
|
||||
+ this.level().getCraftServer().getPluginManager().callEvent(respawnEvent);
|
||||
+
|
||||
+ location = respawnEvent.getRespawnLocation();
|
||||
+
|
||||
+ return new DimensionTransition(((CraftWorld) location.getWorld()).getHandle(), CraftLocation.toVec3D(location), dimensionTransition.speed(), location.getYaw(), location.getPitch(), dimensionTransition.missingRespawnBlock(), dimensionTransition.postDimensionTransition(), dimensionTransition.cause());
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public static Optional<EntityPlayer.RespawnPosAngle> findRespawnAndUseSpawnBlock(WorldServer worldserver, BlockPosition blockposition, float f, boolean flag, boolean flag1) {
|
||||
@@ -892,11 +1140,11 @@
|
||||
}
|
||||
|
||||
return optional.map((vec3d) -> {
|
||||
- return EntityPlayer.RespawnPosAngle.of(vec3d, blockposition);
|
||||
+ return EntityPlayer.RespawnPosAngle.of(vec3d, blockposition, false, true); // CraftBukkit
|
||||
});
|
||||
} else if (block instanceof BlockBed && BlockBed.canSetSpawn(worldserver)) {
|
||||
return BlockBed.findStandUpPosition(EntityTypes.PLAYER, worldserver, blockposition, (EnumDirection) iblockdata.getValue(BlockBed.FACING), f).map((vec3d) -> {
|
||||
- return EntityPlayer.RespawnPosAngle.of(vec3d, blockposition);
|
||||
+ return EntityPlayer.RespawnPosAngle.of(vec3d, blockposition, true, false); // CraftBukkit
|
||||
});
|
||||
} else if (!flag) {
|
||||
return Optional.empty();
|
||||
@@ -905,7 +1153,7 @@
|
||||
IBlockData iblockdata1 = worldserver.getBlockState(blockposition.above());
|
||||
boolean flag3 = iblockdata1.getBlock().isPossibleToRespawnInThis(iblockdata1);
|
||||
|
||||
- return flag2 && flag3 ? Optional.of(new EntityPlayer.RespawnPosAngle(new Vec3D((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.1D, (double) blockposition.getZ() + 0.5D), f)) : Optional.empty();
|
||||
+ return flag2 && flag3 ? Optional.of(new EntityPlayer.RespawnPosAngle(new Vec3D((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.1D, (double) blockposition.getZ() + 0.5D), f, false, false)) : Optional.empty(); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -923,6 +1171,7 @@
|
||||
@Nullable
|
||||
@Override
|
||||
public Entity changeDimension(DimensionTransition dimensiontransition) {
|
||||
+ if (this.isSleeping()) return null; // CraftBukkit - SPIGOT-3154
|
||||
if (this.isRemoved()) {
|
||||
return null;
|
||||
} else {
|
||||
@@ -932,14 +1181,21 @@
|
||||
|
||||
WorldServer worldserver = dimensiontransition.newLevel();
|
||||
WorldServer worldserver1 = this.serverLevel();
|
||||
- ResourceKey<World> resourcekey = worldserver1.dimension();
|
||||
+ // CraftBukkit start
|
||||
+ /*
|
||||
WorldData worlddata = worldserver.getLevelData();
|
||||
+ ResourceKey<WorldDimension> resourcekey = worldserver1.getTypeKey();
|
||||
|
||||
this.connection.send(new PacketPlayOutRespawn(this.createCommonSpawnInfo(worldserver), (byte) 3));
|
||||
@@ -893,20 +1126,50 @@
|
||||
playerlist.sendPlayerPermissionLevel(this);
|
||||
worldserver1.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION);
|
||||
this.unsetRemoved();
|
||||
+ */
|
||||
+ // CraftBukkit end
|
||||
ShapeDetectorShape shapedetectorshape = this.findDimensionEntryPoint(worldserver);
|
||||
- if (worldserver.dimension() == resourcekey) {
|
||||
- this.connection.teleport(dimensiontransition.pos().x, dimensiontransition.pos().y, dimensiontransition.pos().z, dimensiontransition.yRot(), dimensiontransition.xRot());
|
||||
+ if (worldserver != null && worldserver.dimension() == worldserver1.dimension()) { // CraftBukkit
|
||||
+ boolean result = this.connection.teleport(dimensiontransition.pos().x, dimensiontransition.pos().y, dimensiontransition.pos().z, dimensiontransition.yRot(), dimensiontransition.xRot(), dimensiontransition.cause());
|
||||
+ if (!result) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.connection.resetPosition();
|
||||
dimensiontransition.postDimensionTransition().onTransition(this);
|
||||
return this;
|
||||
} else {
|
||||
+ // CraftBukkit start
|
||||
+ /*
|
||||
this.isChangingDimension = true;
|
||||
WorldData worlddata = worldserver.getLevelData();
|
||||
|
||||
if (shapedetectorshape != null) {
|
||||
@@ -950,15 +1206,40 @@
|
||||
playerlist.sendPlayerPermissionLevel(this);
|
||||
worldserver1.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION);
|
||||
this.unsetRemoved();
|
||||
+ */
|
||||
+ // CraftBukkit end
|
||||
worldserver1.getProfiler().push("moving");
|
||||
- if (resourcekey == World.OVERWORLD && worldserver.dimension() == World.NETHER) {
|
||||
+ worldserver = shapedetectorshape.world; // CraftBukkit
|
||||
+ if (worldserver == null) { } else // CraftBukkit - empty to fall through to null to event
|
||||
+ if (resourcekey == WorldDimension.OVERWORLD && worldserver.getTypeKey() == WorldDimension.NETHER) { // CraftBukkit
|
||||
+ if (worldserver != null && resourcekey == WorldDimension.OVERWORLD && worldserver.getTypeKey() == WorldDimension.NETHER) { // CraftBukkit - empty to fall through to null to event
|
||||
this.enteredNetherPosition = this.position();
|
||||
- } else if (worldserver.dimension() == World.END) {
|
||||
+ } else if (worldserver.getTypeKey() == WorldDimension.END && shapedetectorshape.portalEventInfo != null && shapedetectorshape.portalEventInfo.getCanCreatePortal()) { // CraftBukkit
|
||||
this.createEndPlatform(worldserver, BlockPosition.containing(shapedetectorshape.pos));
|
||||
}
|
||||
+ // CraftBukkit start
|
||||
+ } else {
|
||||
+ return null;
|
||||
+ }
|
||||
+ Location enter = this.getBukkitEntity().getLocation();
|
||||
+ Location exit = (worldserver == null) ? null : CraftLocation.toBukkit(shapedetectorshape.pos, worldserver.getWorld(), shapedetectorshape.yRot, shapedetectorshape.xRot);
|
||||
+ PlayerTeleportEvent tpEvent = new PlayerTeleportEvent(this.getBukkitEntity(), enter, exit, cause);
|
||||
+ Bukkit.getServer().getPluginManager().callEvent(tpEvent);
|
||||
+ if (tpEvent.isCancelled() || tpEvent.getTo() == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ exit = tpEvent.getTo();
|
||||
+ worldserver = ((CraftWorld) exit.getWorld()).getHandle();
|
||||
+ // CraftBukkit end
|
||||
+ Location enter = this.getBukkitEntity().getLocation();
|
||||
+ Location exit = (worldserver == null) ? null : CraftLocation.toBukkit(dimensiontransition.pos(), worldserver.getWorld(), dimensiontransition.yRot(), dimensiontransition.xRot());
|
||||
+ PlayerTeleportEvent tpEvent = new PlayerTeleportEvent(this.getBukkitEntity(), enter, exit, dimensiontransition.cause());
|
||||
+ Bukkit.getServer().getPluginManager().callEvent(tpEvent);
|
||||
+ if (tpEvent.isCancelled() || tpEvent.getTo() == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ exit = tpEvent.getTo();
|
||||
+ worldserver = ((CraftWorld) exit.getWorld()).getHandle();
|
||||
+ // CraftBukkit end
|
||||
|
||||
- worldserver1.getProfiler().pop();
|
||||
- worldserver1.getProfiler().push("placing");
|
||||
+ worldserver1.getProfiler().pop();
|
||||
+ worldserver1.getProfiler().push("placing");
|
||||
+ if (true) { // CraftBukkit
|
||||
worldserver1.getProfiler().pop();
|
||||
worldserver1.getProfiler().push("placing");
|
||||
+ // CraftBukkit start
|
||||
+ this.isChangingDimension = true; // CraftBukkit - Set teleport invulnerability only if player changing worlds
|
||||
+ WorldData worlddata = worldserver.getLevelData();
|
||||
+
|
||||
+ this.connection.send(new PacketPlayOutRespawn(this.createCommonSpawnInfo(worldserver), (byte) 3));
|
||||
+ this.connection.send(new PacketPlayOutServerDifficulty(this.level().getDifficulty(), this.level().getLevelData().isDifficultyLocked()));
|
||||
+ this.connection.send(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked()));
|
||||
+ PlayerList playerlist = this.server.getPlayerList();
|
||||
+
|
||||
+ playerlist.sendPlayerPermissionLevel(this);
|
||||
+ worldserver1.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION);
|
||||
+ this.unsetRemoved();
|
||||
+
|
||||
+ // CraftBukkit end
|
||||
this.setServerLevel(worldserver);
|
||||
- this.connection.teleport(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, shapedetectorshape.xRot);
|
||||
- this.connection.teleport(dimensiontransition.pos().x, dimensiontransition.pos().y, dimensiontransition.pos().z, dimensiontransition.yRot(), dimensiontransition.xRot());
|
||||
+ this.connection.teleport(exit); // CraftBukkit - use internal teleport without event
|
||||
this.connection.resetPosition();
|
||||
worldserver.addDuringPortalTeleport(this);
|
||||
worldserver.addDuringTeleport(this);
|
||||
worldserver1.getProfiler().pop();
|
||||
@@ -926,39 +1189,66 @@
|
||||
@@ -971,21 +1252,47 @@
|
||||
this.lastSentExp = -1;
|
||||
this.lastSentHealth = -1.0F;
|
||||
this.lastSentFood = -1;
|
||||
@@ -538,17 +584,15 @@
|
||||
+ PlayerChangedWorldEvent changeEvent = new PlayerChangedWorldEvent(this.getBukkitEntity(), worldserver1.getWorld());
|
||||
+ this.level().getCraftServer().getPluginManager().callEvent(changeEvent);
|
||||
+ // CraftBukkit end
|
||||
return this;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ protected CraftPortalEvent callPortalEvent(Entity entity, WorldServer exitWorldServer, Vec3D exitPosition, TeleportCause cause, int searchRadius, int creationRadius) {
|
||||
+ public CraftPortalEvent callPortalEvent(Entity entity, Location exit, TeleportCause cause, int searchRadius, int creationRadius) {
|
||||
+ Location enter = this.getBukkitEntity().getLocation();
|
||||
+ Location exit = CraftLocation.toBukkit(exitPosition, exitWorldServer.getWorld(), getYRot(), getXRot());
|
||||
+ PlayerPortalEvent event = new PlayerPortalEvent(this.getBukkitEntity(), enter, exit, cause, searchRadius, true, creationRadius);
|
||||
+ Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled() || event.getTo() == null || event.getTo().getWorld() == null) {
|
||||
@@ -558,51 +602,6 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
private void createEndPlatform(WorldServer worldserver, BlockPosition blockposition) {
|
||||
BlockPosition.MutableBlockPosition blockposition_mutableblockposition = blockposition.mutable();
|
||||
+ org.bukkit.craftbukkit.util.BlockStateListPopulator blockList = new org.bukkit.craftbukkit.util.BlockStateListPopulator(worldserver); // CraftBukkit
|
||||
|
||||
for (int i = -2; i <= 2; ++i) {
|
||||
for (int j = -2; j <= 2; ++j) {
|
||||
for (int k = -1; k < 3; ++k) {
|
||||
IBlockData iblockdata = k == -1 ? Blocks.OBSIDIAN.defaultBlockState() : Blocks.AIR.defaultBlockState();
|
||||
|
||||
- worldserver.setBlockAndUpdate(blockposition_mutableblockposition.set(blockposition).move(j, k, i), iblockdata);
|
||||
+ blockList.setBlock(blockposition_mutableblockposition.set(blockposition).move(j, k, i), iblockdata, 3); // CraftBukkit
|
||||
}
|
||||
}
|
||||
}
|
||||
+ // CraftBukkit start - call portal event
|
||||
+ org.bukkit.event.world.PortalCreateEvent portalEvent = new org.bukkit.event.world.PortalCreateEvent((List<org.bukkit.block.BlockState>) (List) blockList.getList(), worldserver.getWorld(), this.getBukkitEntity(), org.bukkit.event.world.PortalCreateEvent.CreateReason.END_PLATFORM);
|
||||
+ worldserver.getCraftServer().getPluginManager().callEvent(portalEvent);
|
||||
+ if (!portalEvent.isCancelled()) {
|
||||
+ blockList.updateList();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
- protected Optional<BlockUtil.Rectangle> getExitPortal(WorldServer worldserver, BlockPosition blockposition, boolean flag, WorldBorder worldborder) {
|
||||
- Optional<BlockUtil.Rectangle> optional = super.getExitPortal(worldserver, blockposition, flag, worldborder);
|
||||
+ protected Optional<BlockUtil.Rectangle> getExitPortal(WorldServer worldserver, BlockPosition blockposition, boolean flag, WorldBorder worldborder, int searchRadius, boolean canCreatePortal, int createRadius) { // CraftBukkit
|
||||
+ Optional<BlockUtil.Rectangle> optional = super.getExitPortal(worldserver, blockposition, flag, worldborder, searchRadius, canCreatePortal, createRadius); // CraftBukkit
|
||||
|
||||
- if (optional.isPresent()) {
|
||||
+ if (optional.isPresent() || !canCreatePortal) { // CraftBukkit
|
||||
return optional;
|
||||
} else {
|
||||
EnumDirection.EnumAxis enumdirection_enumaxis = (EnumDirection.EnumAxis) this.level().getBlockState(this.portalEntrancePos).getOptionalValue(BlockPortal.AXIS).orElse(EnumDirection.EnumAxis.X);
|
||||
- Optional<BlockUtil.Rectangle> optional1 = worldserver.getPortalForcer().createPortal(blockposition, enumdirection_enumaxis);
|
||||
+ Optional<BlockUtil.Rectangle> optional1 = worldserver.getPortalForcer().createPortal(blockposition, enumdirection_enumaxis, this, createRadius); // CraftBukkit
|
||||
|
||||
if (optional1.isEmpty()) {
|
||||
- EntityPlayer.LOGGER.error("Unable to create a portal, likely target out of worldborder");
|
||||
+ // EntityPlayer.LOGGER.error("Unable to create a portal, likely target out of worldborder"); // CraftBukkit
|
||||
}
|
||||
|
||||
return optional1;
|
||||
@@ -968,13 +1258,21 @@
|
||||
public void triggerDimensionChangeTriggers(WorldServer worldserver) {
|
||||
ResourceKey<World> resourcekey = worldserver.dimension();
|
||||
ResourceKey<World> resourcekey1 = this.level().dimension();
|
||||
@@ -627,7 +626,7 @@
|
||||
this.enteredNetherPosition = null;
|
||||
}
|
||||
|
||||
@@ -991,19 +1289,17 @@
|
||||
@@ -1002,19 +1309,17 @@
|
||||
this.containerMenu.broadcastChanges();
|
||||
}
|
||||
|
||||
@@ -651,7 +650,7 @@
|
||||
if (this.level().isDay()) {
|
||||
return Either.left(EntityHuman.EnumBedResult.NOT_POSSIBLE_NOW);
|
||||
} else {
|
||||
@@ -1020,7 +1316,36 @@
|
||||
@@ -1031,7 +1336,36 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -689,7 +688,7 @@
|
||||
this.awardStat(StatisticList.SLEEP_IN_BED);
|
||||
CriterionTriggers.SLEPT_IN_BED.trigger(this);
|
||||
});
|
||||
@@ -1033,9 +1358,8 @@
|
||||
@@ -1044,9 +1378,8 @@
|
||||
return either;
|
||||
}
|
||||
}
|
||||
@@ -700,7 +699,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1062,13 +1386,31 @@
|
||||
@@ -1073,13 +1406,31 @@
|
||||
|
||||
@Override
|
||||
public void stopSleepInBed(boolean flag, boolean flag1) {
|
||||
@@ -733,7 +732,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1135,8 +1477,9 @@
|
||||
@@ -1146,8 +1497,9 @@
|
||||
this.connection.send(new PacketPlayOutOpenSignEditor(tileentitysign.getBlockPos(), flag));
|
||||
}
|
||||
|
||||
@@ -744,7 +743,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1144,13 +1487,35 @@
|
||||
@@ -1155,13 +1507,35 @@
|
||||
if (itileinventory == null) {
|
||||
return OptionalInt.empty();
|
||||
} else {
|
||||
@@ -780,7 +779,7 @@
|
||||
if (container == null) {
|
||||
if (this.isSpectator()) {
|
||||
this.displayClientMessage(IChatBaseComponent.translatable("container.spectatorCantOpen").withStyle(EnumChatFormat.RED), true);
|
||||
@@ -1158,9 +1523,11 @@
|
||||
@@ -1169,9 +1543,11 @@
|
||||
|
||||
return OptionalInt.empty();
|
||||
} else {
|
||||
@@ -794,13 +793,13 @@
|
||||
return OptionalInt.of(this.containerCounter);
|
||||
}
|
||||
}
|
||||
@@ -1173,13 +1540,24 @@
|
||||
@@ -1184,15 +1560,26 @@
|
||||
|
||||
@Override
|
||||
public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) {
|
||||
+ // CraftBukkit start - Inventory open hook
|
||||
+ this.nextContainerCounter();
|
||||
+ Container container = new ContainerHorse(this.containerCounter, this.getInventory(), iinventory, entityhorseabstract);
|
||||
+ Container container = new ContainerHorse(this.containerCounter, this.getInventory(), iinventory, entityhorseabstract, entityhorseabstract.getInventoryColumns());
|
||||
+ container.setTitle(entityhorseabstract.getDisplayName());
|
||||
+ container = CraftEventFactory.callInventoryOpenEvent(this, container);
|
||||
+
|
||||
@@ -815,13 +814,15 @@
|
||||
|
||||
- this.nextContainerCounter();
|
||||
+ // this.nextContainerCounter(); // CraftBukkit - moved up
|
||||
this.connection.send(new PacketPlayOutOpenWindowHorse(this.containerCounter, iinventory.getContainerSize(), entityhorseabstract.getId()));
|
||||
- this.containerMenu = new ContainerHorse(this.containerCounter, this.getInventory(), iinventory, entityhorseabstract);
|
||||
int i = entityhorseabstract.getInventoryColumns();
|
||||
|
||||
this.connection.send(new PacketPlayOutOpenWindowHorse(this.containerCounter, i, entityhorseabstract.getId()));
|
||||
- this.containerMenu = new ContainerHorse(this.containerCounter, this.getInventory(), iinventory, entityhorseabstract, i);
|
||||
+ this.containerMenu = container; // CraftBukkit
|
||||
this.initMenu(this.containerMenu);
|
||||
}
|
||||
|
||||
@@ -1202,6 +1580,7 @@
|
||||
@@ -1215,6 +1602,7 @@
|
||||
|
||||
@Override
|
||||
public void closeContainer() {
|
||||
@@ -829,7 +830,7 @@
|
||||
this.connection.send(new PacketPlayOutCloseWindow(this.containerMenu.containerId));
|
||||
this.doCloseContainer();
|
||||
}
|
||||
@@ -1224,6 +1603,16 @@
|
||||
@@ -1237,6 +1625,16 @@
|
||||
}
|
||||
|
||||
this.jumping = flag;
|
||||
@@ -846,7 +847,7 @@
|
||||
this.setShiftKeyDown(flag1);
|
||||
}
|
||||
|
||||
@@ -1257,19 +1646,19 @@
|
||||
@@ -1270,19 +1668,19 @@
|
||||
i = Math.round((float) Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F);
|
||||
if (i > 0) {
|
||||
this.awardStat(StatisticList.SWIM_ONE_CM, i);
|
||||
@@ -869,7 +870,7 @@
|
||||
}
|
||||
} else if (this.onClimbable()) {
|
||||
if (d1 > 0.0D) {
|
||||
@@ -1280,13 +1669,13 @@
|
||||
@@ -1293,13 +1691,13 @@
|
||||
if (i > 0) {
|
||||
if (this.isSprinting()) {
|
||||
this.awardStat(StatisticList.SPRINT_ONE_CM, i);
|
||||
@@ -886,7 +887,7 @@
|
||||
}
|
||||
}
|
||||
} else if (this.isFallFlying()) {
|
||||
@@ -1329,7 +1718,7 @@
|
||||
@@ -1342,7 +1740,7 @@
|
||||
@Override
|
||||
public void awardStat(Statistic<?> statistic, int i) {
|
||||
this.stats.increment(this, statistic, i);
|
||||
@@ -895,7 +896,7 @@
|
||||
scoreaccess.add(i);
|
||||
});
|
||||
}
|
||||
@@ -1337,7 +1726,7 @@
|
||||
@@ -1350,7 +1748,7 @@
|
||||
@Override
|
||||
public void resetStat(Statistic<?> statistic) {
|
||||
this.stats.setValue(this, statistic, 0);
|
||||
@@ -904,7 +905,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1385,6 +1774,7 @@
|
||||
@@ -1398,6 +1796,7 @@
|
||||
|
||||
public void resetSentInfo() {
|
||||
this.lastSentHealth = -1.0E8F;
|
||||
@@ -912,7 +913,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1442,7 +1832,7 @@
|
||||
@@ -1465,7 +1864,7 @@
|
||||
this.lastSentExp = -1;
|
||||
this.lastSentHealth = -1.0F;
|
||||
this.lastSentFood = -1;
|
||||
@@ -921,7 +922,7 @@
|
||||
this.seenCredits = entityplayer.seenCredits;
|
||||
this.enteredNetherPosition = entityplayer.enteredNetherPosition;
|
||||
this.chunkTrackingView = entityplayer.chunkTrackingView;
|
||||
@@ -1493,6 +1883,12 @@
|
||||
@@ -1516,6 +1915,12 @@
|
||||
|
||||
@Override
|
||||
public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set<RelativeMovement> set, float f, float f1) {
|
||||
@@ -934,7 +935,7 @@
|
||||
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(BlockPosition.containing(d0, d1, d2));
|
||||
|
||||
worldserver.getChunkSource().addRegionTicket(TicketType.POST_TELEPORT, chunkcoordintpair, 1, this.getId());
|
||||
@@ -1502,9 +1898,9 @@
|
||||
@@ -1525,9 +1930,9 @@
|
||||
}
|
||||
|
||||
if (worldserver == this.level()) {
|
||||
@@ -946,7 +947,7 @@
|
||||
}
|
||||
|
||||
this.setYHeadRot(f);
|
||||
@@ -1606,6 +2002,16 @@
|
||||
@@ -1635,6 +2040,16 @@
|
||||
}
|
||||
|
||||
public void updateOptions(ClientInformation clientinformation) {
|
||||
@@ -963,7 +964,7 @@
|
||||
this.language = clientinformation.language();
|
||||
this.requestedViewDistance = clientinformation.viewDistance();
|
||||
this.chatVisibility = clientinformation.chatVisibility();
|
||||
@@ -1689,7 +2095,7 @@
|
||||
@@ -1718,7 +2133,7 @@
|
||||
if (world instanceof WorldServer) {
|
||||
WorldServer worldserver = (WorldServer) world;
|
||||
|
||||
@@ -972,7 +973,7 @@
|
||||
}
|
||||
|
||||
if (entity != null) {
|
||||
@@ -1726,7 +2132,7 @@
|
||||
@@ -1755,7 +2170,7 @@
|
||||
|
||||
@Nullable
|
||||
public IChatBaseComponent getTabListDisplayName() {
|
||||
@@ -981,7 +982,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1747,9 +2153,16 @@
|
||||
@@ -1776,14 +2191,24 @@
|
||||
return this.advancements;
|
||||
}
|
||||
|
||||
@@ -998,9 +999,7 @@
|
||||
if (worldserver == this.level()) {
|
||||
this.connection.teleport(d0, d1, d2, f, f1);
|
||||
} else {
|
||||
@@ -1769,6 +2182,9 @@
|
||||
this.server.getPlayerList().sendLevelInfo(this, worldserver);
|
||||
this.server.getPlayerList().sendAllPlayerInfo(this);
|
||||
this.changeDimension(new DimensionTransition(worldserver, new Vec3D(d0, d1, d2), Vec3D.ZERO, f, f1, DimensionTransition.DO_NOTHING));
|
||||
}
|
||||
+ */
|
||||
+ this.getBukkitEntity().teleport(new Location(worldserver.getWorld(), d0, d1, d2, f, f1), cause);
|
||||
@@ -1008,7 +1007,7 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -1790,6 +2206,32 @@
|
||||
@@ -1809,6 +2234,32 @@
|
||||
}
|
||||
|
||||
public void setRespawnPosition(ResourceKey<World> resourcekey, @Nullable BlockPosition blockposition, float f, boolean flag, boolean flag1) {
|
||||
@@ -1041,9 +1040,25 @@
|
||||
if (blockposition != null) {
|
||||
boolean flag2 = blockposition.equals(this.respawnPosition) && resourcekey.equals(this.respawnDimension);
|
||||
|
||||
@@ -2011,4 +2453,147 @@
|
||||
public BlockPosition getRaidOmenPosition() {
|
||||
return this.raidOmenPosition;
|
||||
@@ -2049,10 +2500,12 @@
|
||||
this.awardStat(StatisticList.ITEM_BROKEN.get(item));
|
||||
}
|
||||
|
||||
- public static record RespawnPosAngle(Vec3D position, float yaw) {
|
||||
+ // CraftBukkit start
|
||||
+ public static record RespawnPosAngle(Vec3D position, float yaw, boolean isBedSpawn, boolean isAnchorSpawn) {
|
||||
|
||||
- public static EntityPlayer.RespawnPosAngle of(Vec3D vec3d, BlockPosition blockposition) {
|
||||
- return new EntityPlayer.RespawnPosAngle(vec3d, calculateLookAtYaw(vec3d, blockposition));
|
||||
+ public static EntityPlayer.RespawnPosAngle of(Vec3D vec3d, BlockPosition blockposition, boolean isBedSpawn, boolean isAnchorSpawn) {
|
||||
+ return new EntityPlayer.RespawnPosAngle(vec3d, calculateLookAtYaw(vec3d, blockposition), isBedSpawn, isAnchorSpawn);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
private static float calculateLookAtYaw(Vec3D vec3d, BlockPosition blockposition) {
|
||||
@@ -2061,4 +2514,147 @@
|
||||
return (float) MathHelper.wrapDegrees(MathHelper.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D);
|
||||
}
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start - Add per-player time and weather.
|
||||
|
||||
@@ -24,10 +24,10 @@
|
||||
+ public EntityTrackerEntry(WorldServer worldserver, Entity entity, int i, boolean flag, Consumer<Packet<?>> consumer, Set<ServerPlayerConnection> trackedPlayers) {
|
||||
+ this.trackedPlayers = trackedPlayers;
|
||||
+ // CraftBukkit end
|
||||
this.ap = Vec3D.ZERO;
|
||||
this.lastPassengers = Collections.emptyList();
|
||||
this.level = worldserver;
|
||||
@@ -91,7 +101,7 @@
|
||||
this.broadcast = consumer;
|
||||
this.entity = entity;
|
||||
@@ -90,7 +100,7 @@
|
||||
List<Entity> list = this.entity.getPassengers();
|
||||
|
||||
if (!list.equals(this.lastPassengers)) {
|
||||
@@ -36,7 +36,7 @@
|
||||
removedPassengers(list, this.lastPassengers).forEach((entity) -> {
|
||||
if (entity instanceof EntityPlayer entityplayer) {
|
||||
entityplayer.connection.teleport(entityplayer.getX(), entityplayer.getY(), entityplayer.getZ(), entityplayer.getYRot(), entityplayer.getXRot());
|
||||
@@ -104,18 +114,18 @@
|
||||
@@ -103,18 +113,18 @@
|
||||
Entity entity = this.entity;
|
||||
|
||||
if (entity instanceof EntityItemFrame entityitemframe) {
|
||||
@@ -59,11 +59,10 @@
|
||||
|
||||
worldmap.tickCarriedBy(entityplayer, itemstack);
|
||||
Packet<?> packet = worldmap.getUpdatePacket(mapid, entityplayer);
|
||||
@@ -228,7 +238,27 @@
|
||||
@@ -232,6 +242,27 @@
|
||||
|
||||
++this.tickCount;
|
||||
if (this.entity.hurtMarked) {
|
||||
- this.broadcastAndSend(new PacketPlayOutEntityVelocity(this.entity));
|
||||
+ // CraftBukkit start - Create PlayerVelocity event
|
||||
+ boolean cancelled = false;
|
||||
+
|
||||
@@ -81,14 +80,14 @@
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (!cancelled) {
|
||||
+ this.broadcastAndSend(new PacketPlayOutEntityVelocity(this.entity));
|
||||
+ if (cancelled) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
entity = this.entity;
|
||||
if (entity instanceof EntityFireball) {
|
||||
EntityFireball entityfireball = (EntityFireball) entity;
|
||||
@@ -263,7 +293,10 @@
|
||||
this.entity.hurtMarked = false;
|
||||
this.broadcastAndSend(new PacketPlayOutEntityVelocity(this.entity));
|
||||
}
|
||||
@@ -260,7 +291,10 @@
|
||||
|
||||
public void sendPairingData(EntityPlayer entityplayer, Consumer<Packet<PacketListenerPlayOut>> consumer) {
|
||||
if (this.entity.isRemoved()) {
|
||||
@@ -99,8 +98,8 @@
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
Packet<PacketListenerPlayOut> packet = this.entity.getAddEntityPacket();
|
||||
@@ -279,6 +312,12 @@
|
||||
Packet<PacketListenerPlayOut> packet = this.entity.getAddEntityPacket(this);
|
||||
@@ -275,6 +309,12 @@
|
||||
if (this.entity instanceof EntityLiving) {
|
||||
Collection<AttributeModifiable> collection = ((EntityLiving) this.entity).getAttributes().getSyncableAttributes();
|
||||
|
||||
@@ -113,7 +112,7 @@
|
||||
if (!collection.isEmpty()) {
|
||||
consumer.accept(new PacketPlayOutUpdateAttributes(this.entity.getId(), collection));
|
||||
}
|
||||
@@ -310,6 +349,7 @@
|
||||
@@ -305,6 +345,7 @@
|
||||
if (!list.isEmpty()) {
|
||||
consumer.accept(new PacketPlayOutEntityEquipment(this.entity.getId(), list));
|
||||
}
|
||||
@@ -121,8 +120,8 @@
|
||||
}
|
||||
|
||||
if (!this.entity.getPassengers().isEmpty()) {
|
||||
@@ -343,6 +383,11 @@
|
||||
Set<AttributeModifiable> set = ((EntityLiving) this.entity).getAttributes().getDirtyAttributes();
|
||||
@@ -358,6 +399,11 @@
|
||||
Set<AttributeModifiable> set = ((EntityLiving) this.entity).getAttributes().getAttributesToSync();
|
||||
|
||||
if (!set.isEmpty()) {
|
||||
+ // CraftBukkit start - Send scaled max health
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/level/PlayerChunk.java
|
||||
+++ b/net/minecraft/server/level/PlayerChunk.java
|
||||
@@ -34,6 +34,10 @@
|
||||
@@ -28,6 +28,10 @@
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
import net.minecraft.world.level.lighting.LevelLightEngine;
|
||||
|
||||
@@ -8,47 +8,40 @@
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class PlayerChunk {
|
||||
public class PlayerChunk extends GenerationChunkHolder {
|
||||
|
||||
public static final ChunkResult<IChunkAccess> UNLOADED_CHUNK = ChunkResult.error("Unloaded chunk");
|
||||
@@ -70,12 +74,12 @@
|
||||
this.fullChunkFuture = PlayerChunk.UNLOADED_LEVEL_CHUNK_FUTURE;
|
||||
this.tickingChunkFuture = PlayerChunk.UNLOADED_LEVEL_CHUNK_FUTURE;
|
||||
public static final ChunkResult<Chunk> UNLOADED_LEVEL_CHUNK = ChunkResult.error("Unloaded level chunk");
|
||||
@@ -58,9 +62,9 @@
|
||||
this.entityTickingChunkFuture = PlayerChunk.UNLOADED_LEVEL_CHUNK_FUTURE;
|
||||
- this.chunkToSave = CompletableFuture.completedFuture((Object) null);
|
||||
+ this.chunkToSave = CompletableFuture.completedFuture(null); // CraftBukkit - decompile error
|
||||
this.chunkToSaveHistory = null;
|
||||
this.blockChangedLightSectionFilter = new BitSet();
|
||||
this.skyChangedLightSectionFilter = new BitSet();
|
||||
- this.pendingFullStateConfirmation = CompletableFuture.completedFuture((Object) null);
|
||||
- this.sendSync = CompletableFuture.completedFuture((Object) null);
|
||||
- this.saveSync = CompletableFuture.completedFuture((Object) null);
|
||||
+ this.pendingFullStateConfirmation = CompletableFuture.completedFuture(null); // CraftBukkit - decompile error
|
||||
+ this.sendSync = CompletableFuture.completedFuture(null); // CraftBukkit - decompile error
|
||||
this.pos = chunkcoordintpair;
|
||||
+ this.saveSync = CompletableFuture.completedFuture(null); // CraftBukkit - decompile error
|
||||
this.levelHeightAccessor = levelheightaccessor;
|
||||
this.lightEngine = levellightengine;
|
||||
@@ -88,6 +92,20 @@
|
||||
this.onLevelChange = playerchunk_a;
|
||||
@@ -72,6 +76,16 @@
|
||||
this.changedBlocksPerSection = new ShortSet[levelheightaccessor.getSectionsCount()];
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public Chunk getFullChunkNow() {
|
||||
+ // Note: We use the oldTicketLevel for isLoaded checks.
|
||||
+ if (!ChunkLevel.fullStatus(this.oldTicketLevel).isOrAfter(FullChunkStatus.FULL)) return null;
|
||||
+ return this.getFullChunkNowUnchecked();
|
||||
+ return (Chunk) this.getChunkIfPresent(ChunkStatus.FULL);
|
||||
+ }
|
||||
+
|
||||
+ public Chunk getFullChunkNowUnchecked() {
|
||||
+ CompletableFuture<ChunkResult<IChunkAccess>> statusFuture = this.getFutureIfPresentUnchecked(ChunkStatus.FULL);
|
||||
+ ChunkResult<IChunkAccess> either = statusFuture.getNow(null);
|
||||
+ return (either == null) ? null : (Chunk) either.orElse(null);
|
||||
+ return (Chunk) this.getChunkIfPresentUnchecked(ChunkStatus.FULL);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public CompletableFuture<ChunkResult<IChunkAccess>> getFutureIfPresentUnchecked(ChunkStatus chunkstatus) {
|
||||
CompletableFuture<ChunkResult<IChunkAccess>> completablefuture = (CompletableFuture) this.futures.get(chunkstatus.getIndex());
|
||||
|
||||
@@ -112,7 +130,7 @@
|
||||
public CompletableFuture<ChunkResult<Chunk>> getTickingChunkFuture() {
|
||||
return this.tickingChunkFuture;
|
||||
}
|
||||
@@ -86,7 +100,7 @@
|
||||
|
||||
@Nullable
|
||||
public Chunk getTickingChunk() {
|
||||
@@ -56,8 +49,8 @@
|
||||
+ return (Chunk) ((ChunkResult) this.getTickingChunkFuture().getNow(PlayerChunk.UNLOADED_LEVEL_CHUNK)).orElse(null); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
public CompletableFuture<?> getChunkSendSyncFuture() {
|
||||
@@ -166,6 +184,7 @@
|
||||
@Nullable
|
||||
@@ -134,6 +148,7 @@
|
||||
if (chunk != null) {
|
||||
int i = this.levelHeightAccessor.getSectionIndex(blockposition.getY());
|
||||
|
||||
@@ -65,16 +58,7 @@
|
||||
if (this.changedBlocksPerSection[i] == null) {
|
||||
this.hasChangedSections = true;
|
||||
this.changedBlocksPerSection[i] = new ShortOpenHashSet();
|
||||
@@ -176,7 +195,7 @@
|
||||
}
|
||||
|
||||
public void sectionLightChanged(EnumSkyBlock enumskyblock, int i) {
|
||||
- IChunkAccess ichunkaccess = (IChunkAccess) ((ChunkResult) this.getFutureIfPresent(ChunkStatus.INITIALIZE_LIGHT).getNow(PlayerChunk.UNLOADED_CHUNK)).orElse((Object) null);
|
||||
+ IChunkAccess ichunkaccess = (IChunkAccess) ((ChunkResult) this.getFutureIfPresent(ChunkStatus.INITIALIZE_LIGHT).getNow(PlayerChunk.UNLOADED_CHUNK)).orElse(null); // CraftBukkit - decompile error
|
||||
|
||||
if (ichunkaccess != null) {
|
||||
ichunkaccess.setUnsaved(true);
|
||||
@@ -240,8 +259,11 @@
|
||||
@@ -208,8 +223,11 @@
|
||||
PacketPlayOutMultiBlockChange packetplayoutmultiblockchange = new PacketPlayOutMultiBlockChange(sectionposition, shortset, chunksection);
|
||||
|
||||
this.broadcast(list, packetplayoutmultiblockchange);
|
||||
@@ -87,7 +71,7 @@
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -374,7 +396,7 @@
|
||||
@@ -275,7 +293,7 @@
|
||||
this.pendingFullStateConfirmation = completablefuture1;
|
||||
completablefuture.thenAccept((chunkresult) -> {
|
||||
chunkresult.ifSuccess((chunk) -> {
|
||||
@@ -96,14 +80,14 @@
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -391,6 +413,30 @@
|
||||
boolean flag1 = ChunkLevel.isLoaded(this.ticketLevel);
|
||||
FullChunkStatus fullchunkstatus = ChunkLevel.fullStatus(this.oldTicketLevel);
|
||||
@@ -290,6 +308,30 @@
|
||||
FullChunkStatus fullchunkstatus1 = ChunkLevel.fullStatus(this.ticketLevel);
|
||||
boolean flag = fullchunkstatus.isOrAfter(FullChunkStatus.FULL);
|
||||
boolean flag1 = fullchunkstatus1.isOrAfter(FullChunkStatus.FULL);
|
||||
+ // CraftBukkit start
|
||||
+ // ChunkUnloadEvent: Called before the chunk is unloaded: isChunkLoaded is still true and chunk can still be modified by plugins.
|
||||
+ if (fullchunkstatus.isOrAfter(FullChunkStatus.FULL) && !fullchunkstatus1.isOrAfter(FullChunkStatus.FULL)) {
|
||||
+ this.getFutureIfPresentUnchecked(ChunkStatus.FULL).thenAccept((either) -> {
|
||||
+ if (flag && !flag1) {
|
||||
+ this.getFullChunkFuture().thenAccept((either) -> {
|
||||
+ Chunk chunk = (Chunk) either.orElse(null);
|
||||
+ if (chunk != null) {
|
||||
+ playerchunkmap.callbackExecutor.execute(() -> {
|
||||
@@ -125,16 +109,16 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (flag) {
|
||||
ChunkResult<IChunkAccess> chunkresult = ChunkResult.error(() -> {
|
||||
@@ -459,6 +505,26 @@
|
||||
this.wasAccessibleSinceLastSave |= flag1;
|
||||
if (!flag && flag1) {
|
||||
@@ -341,6 +383,26 @@
|
||||
|
||||
this.onLevelChange.onLevelChange(this.pos, this::getQueueLevel, this.ticketLevel, this::setQueueLevel);
|
||||
this.oldTicketLevel = this.ticketLevel;
|
||||
+ // CraftBukkit start
|
||||
+ // ChunkLoadEvent: Called after the chunk is loaded: isChunkLoaded returns true and chunk is ready to be modified by plugins.
|
||||
+ if (!fullchunkstatus.isOrAfter(FullChunkStatus.FULL) && fullchunkstatus1.isOrAfter(FullChunkStatus.FULL)) {
|
||||
+ this.getFutureIfPresentUnchecked(ChunkStatus.FULL).thenAccept((either) -> {
|
||||
+ this.getFullChunkFuture().thenAccept((either) -> {
|
||||
+ Chunk chunk = (Chunk) either.orElse(null);
|
||||
+ if (chunk != null) {
|
||||
+ playerchunkmap.callbackExecutor.execute(() -> {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/level/PlayerChunkMap.java
|
||||
+++ b/net/minecraft/server/level/PlayerChunkMap.java
|
||||
@@ -104,6 +104,10 @@
|
||||
@@ -102,6 +102,10 @@
|
||||
import org.apache.commons.lang3.mutable.MutableBoolean;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
+import org.bukkit.craftbukkit.generator.CustomChunkGenerator;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.c {
|
||||
public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.b, GeneratingChunkMap {
|
||||
|
||||
private static final byte CHUNK_TYPE_REPLACEABLE = -1;
|
||||
@@ -146,6 +150,27 @@
|
||||
private static final ChunkResult<List<IChunkAccess>> UNLOADED_CHUNK_LIST_RESULT = ChunkResult.error("Unloaded chunks found in range");
|
||||
@@ -145,6 +149,27 @@
|
||||
public int serverViewDistance;
|
||||
private WorldGenContext worldGenContext;
|
||||
private final WorldGenContext worldGenContext;
|
||||
|
||||
+ // CraftBukkit start - recursion-safe executor for Chunk loadCallback() and unloadCallback()
|
||||
+ public final CallbackExecutor callbackExecutor = new CallbackExecutor();
|
||||
@@ -39,7 +39,7 @@
|
||||
public PlayerChunkMap(WorldServer worldserver, Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, StructureTemplateManager structuretemplatemanager, Executor executor, IAsyncTaskHandler<Runnable> iasynctaskhandler, ILightAccess ilightaccess, ChunkGenerator chunkgenerator, WorldLoadListener worldloadlistener, ChunkStatusUpdateListener chunkstatusupdatelistener, Supplier<WorldPersistentData> supplier, int i, boolean flag) {
|
||||
super(new RegionStorageInfo(convertable_conversionsession.getLevelId(), worldserver.dimension(), "chunk"), convertable_conversionsession.getDimensionPath(worldserver.dimension()).resolve("region"), datafixer, flag);
|
||||
this.visibleChunkMap = this.updatingChunkMap.clone();
|
||||
@@ -166,7 +191,13 @@
|
||||
@@ -164,7 +189,13 @@
|
||||
IRegistryCustom iregistrycustom = worldserver.registryAccess();
|
||||
long j = worldserver.getSeed();
|
||||
|
||||
@@ -54,21 +54,7 @@
|
||||
this.randomState = RandomState.create((GeneratorSettingBase) chunkgeneratorabstract.generatorSettings().value(), (HolderGetter) iregistrycustom.lookupOrThrow(Registries.NOISE), j);
|
||||
} else {
|
||||
this.randomState = RandomState.create(GeneratorSettingBase.dummy(), (HolderGetter) iregistrycustom.lookupOrThrow(Registries.NOISE), j);
|
||||
@@ -332,16 +363,19 @@
|
||||
CompletableFuture<List<ChunkResult<IChunkAccess>>> completablefuture1 = SystemUtils.sequence(list);
|
||||
CompletableFuture<ChunkResult<List<IChunkAccess>>> completablefuture2 = completablefuture1.thenApply((list2) -> {
|
||||
List<IChunkAccess> list3 = Lists.newArrayList();
|
||||
- int l1 = 0;
|
||||
+ // CraftBukkit start - decompile error
|
||||
+ int cnt = 0;
|
||||
|
||||
- for (Iterator iterator = list2.iterator(); iterator.hasNext(); ++l1) {
|
||||
+ for (Iterator iterator = list2.iterator(); iterator.hasNext(); ++cnt) {
|
||||
+ final int l1 = cnt;
|
||||
+ // CraftBukkit end
|
||||
ChunkResult<IChunkAccess> chunkresult = (ChunkResult) iterator.next();
|
||||
|
||||
if (chunkresult == null) {
|
||||
@@ -318,7 +349,7 @@
|
||||
throw this.debugFuturesAndCreateReportedException(new IllegalStateException("At least one of the chunk futures were null"), "n/a");
|
||||
}
|
||||
|
||||
@@ -76,68 +62,18 @@
|
||||
+ IChunkAccess ichunkaccess = (IChunkAccess) chunkresult.orElse(null); // CraftBukkit - decompile error
|
||||
|
||||
if (ichunkaccess == null) {
|
||||
return ChunkResult.error(() -> {
|
||||
@@ -538,7 +572,7 @@
|
||||
|
||||
private void scheduleUnload(long i, PlayerChunk playerchunk) {
|
||||
CompletableFuture<IChunkAccess> completablefuture = playerchunk.getChunkToSave();
|
||||
- Consumer consumer = (ichunkaccess) -> {
|
||||
+ Consumer<IChunkAccess> consumer = (ichunkaccess) -> { // CraftBukkit - decompile error
|
||||
CompletableFuture<IChunkAccess> completablefuture1 = playerchunk.getChunkToSave();
|
||||
|
||||
if (completablefuture1 != completablefuture) {
|
||||
@@ -708,7 +742,7 @@
|
||||
};
|
||||
|
||||
return completablefuture.thenComposeAsync((chunkresult) -> {
|
||||
- List<IChunkAccess> list = (List) chunkresult.orElse((Object) null);
|
||||
+ List<IChunkAccess> list = (List) chunkresult.orElse(null); // CraftBukkit - decompile error
|
||||
|
||||
if (list == null) {
|
||||
this.releaseLightTicket(chunkcoordintpair);
|
||||
@@ -773,7 +807,21 @@
|
||||
|
||||
private static void postLoadProtoChunk(WorldServer worldserver, List<NBTTagCompound> list) {
|
||||
if (!list.isEmpty()) {
|
||||
- worldserver.addWorldGenChunkEntities(EntityTypes.loadEntitiesRecursive(list, worldserver));
|
||||
+ // CraftBukkit start - these are spawned serialized (DefinedStructure) and we don't call an add event below at the moment due to ordering complexities
|
||||
+ worldserver.addWorldGenChunkEntities(EntityTypes.loadEntitiesRecursive(list, worldserver).filter((entity) -> {
|
||||
+ boolean needsRemoval = false;
|
||||
+ net.minecraft.server.dedicated.DedicatedServer server = worldserver.getCraftServer().getServer();
|
||||
+ if (!server.areNpcsEnabled() && entity instanceof net.minecraft.world.entity.npc.NPC) {
|
||||
+ entity.discard(null); // CraftBukkit - add Bukkit remove cause
|
||||
+ needsRemoval = true;
|
||||
+ }
|
||||
+ if (!server.isSpawningAnimals() && (entity instanceof net.minecraft.world.entity.animal.EntityAnimal || entity instanceof net.minecraft.world.entity.animal.EntityWaterAnimal)) {
|
||||
+ entity.discard(null); // CraftBukkit - add Bukkit remove cause
|
||||
+ needsRemoval = true;
|
||||
+ }
|
||||
+ return !needsRemoval;
|
||||
+ }));
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
}
|
||||
@@ -879,7 +927,7 @@
|
||||
if (!playerchunk.wasAccessibleSinceLastSave()) {
|
||||
return false;
|
||||
} else {
|
||||
- IChunkAccess ichunkaccess = (IChunkAccess) playerchunk.getChunkToSave().getNow((Object) null);
|
||||
+ IChunkAccess ichunkaccess = (IChunkAccess) playerchunk.getChunkToSave().getNow(null); // CraftBukkit - decompile error
|
||||
|
||||
if (!(ichunkaccess instanceof ProtoChunkExtension) && !(ichunkaccess instanceof Chunk)) {
|
||||
return false;
|
||||
@@ -1040,7 +1088,8 @@
|
||||
return PlayerChunkMap.UNLOADED_CHUNK_LIST_RESULT;
|
||||
@@ -937,7 +968,8 @@
|
||||
return ichunkaccess instanceof Chunk ? Optional.of((Chunk) ichunkaccess) : Optional.empty();
|
||||
});
|
||||
|
||||
- csvwriter.writeRow(chunkcoordintpair.x, chunkcoordintpair.z, playerchunk.getTicketLevel(), optional.isPresent(), optional.map(IChunkAccess::getStatus).orElse((Object) null), optional1.map(Chunk::getFullStatus).orElse((Object) null), printFuture(playerchunk.getFullChunkFuture()), printFuture(playerchunk.getTickingChunkFuture()), printFuture(playerchunk.getEntityTickingChunkFuture()), this.distanceManager.getTicketDebugString(i), this.anyPlayerCloseEnoughForSpawning(chunkcoordintpair), optional1.map((chunk) -> {
|
||||
- csvwriter.writeRow(chunkcoordintpair.x, chunkcoordintpair.z, playerchunk.getTicketLevel(), optional.isPresent(), optional.map(IChunkAccess::getPersistedStatus).orElse((Object) null), optional1.map(Chunk::getFullStatus).orElse((Object) null), printFuture(playerchunk.getFullChunkFuture()), printFuture(playerchunk.getTickingChunkFuture()), printFuture(playerchunk.getEntityTickingChunkFuture()), this.distanceManager.getTicketDebugString(i), this.anyPlayerCloseEnoughForSpawning(chunkcoordintpair), optional1.map((chunk) -> {
|
||||
+ // CraftBukkit - decompile error
|
||||
+ csvwriter.writeRow(chunkcoordintpair.x, chunkcoordintpair.z, playerchunk.getTicketLevel(), optional.isPresent(), optional.map(IChunkAccess::getStatus).orElse(null), optional1.map(Chunk::getFullStatus).orElse(null), printFuture(playerchunk.getFullChunkFuture()), printFuture(playerchunk.getTickingChunkFuture()), printFuture(playerchunk.getEntityTickingChunkFuture()), this.distanceManager.getTicketDebugString(i), this.anyPlayerCloseEnoughForSpawning(chunkcoordintpair), optional1.map((chunk) -> {
|
||||
+ csvwriter.writeRow(chunkcoordintpair.x, chunkcoordintpair.z, playerchunk.getTicketLevel(), optional.isPresent(), optional.map(IChunkAccess::getPersistedStatus).orElse(null), optional1.map(Chunk::getFullStatus).orElse(null), printFuture(playerchunk.getFullChunkFuture()), printFuture(playerchunk.getTickingChunkFuture()), printFuture(playerchunk.getEntityTickingChunkFuture()), this.distanceManager.getTicketDebugString(i), this.anyPlayerCloseEnoughForSpawning(chunkcoordintpair), optional1.map((chunk) -> {
|
||||
return chunk.getBlockEntities().size();
|
||||
}).orElse(0), tickingtracker.getTicketDebugString(i), tickingtracker.getLevel(i), optional1.map((chunk) -> {
|
||||
return chunk.getBlockTicks().count();
|
||||
@@ -1053,7 +1102,7 @@
|
||||
@@ -950,7 +982,7 @@
|
||||
|
||||
private static String printFuture(CompletableFuture<ChunkResult<Chunk>> completablefuture) {
|
||||
try {
|
||||
@@ -146,7 +82,7 @@
|
||||
|
||||
return chunkresult != null ? (chunkresult.isSuccess() ? "done" : "unloaded") : "not completed";
|
||||
} catch (CompletionException completionexception) {
|
||||
@@ -1065,12 +1114,14 @@
|
||||
@@ -962,12 +994,14 @@
|
||||
|
||||
private CompletableFuture<Optional<NBTTagCompound>> readChunk(ChunkCoordIntPair chunkcoordintpair) {
|
||||
return this.read(chunkcoordintpair).thenApplyAsync((optional) -> {
|
||||
@@ -156,15 +92,15 @@
|
||||
}
|
||||
|
||||
- private NBTTagCompound upgradeChunkTag(NBTTagCompound nbttagcompound) {
|
||||
- return this.upgradeChunkTag(this.level.dimension(), this.overworldDataStorage, nbttagcompound, this.generator.getTypeNameForDataFixer());
|
||||
- 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);
|
||||
+ return this.upgradeChunkTag(this.level.getTypeKey(), this.overworldDataStorage, nbttagcompound, this.generator().getTypeNameForDataFixer(), chunkcoordintpair, level);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
boolean anyPlayerCloseEnoughForSpawning(ChunkCoordIntPair chunkcoordintpair) {
|
||||
@@ -1473,7 +1524,7 @@
|
||||
@@ -1370,7 +1404,7 @@
|
||||
public final Set<ServerPlayerConnection> seenBy = Sets.newIdentityHashSet();
|
||||
|
||||
public EntityTracker(final Entity entity, final int i, final int j, final boolean flag) {
|
||||
@@ -173,7 +109,7 @@
|
||||
this.entity = entity;
|
||||
this.range = i;
|
||||
this.lastSectionPos = SectionPosition.of((EntityAccess) entity);
|
||||
@@ -1533,6 +1584,11 @@
|
||||
@@ -1430,6 +1464,11 @@
|
||||
double d2 = d0 * d0;
|
||||
boolean flag = d1 <= d2 && this.entity.broadcastToPlayer(entityplayer) && PlayerChunkMap.this.isChunkTracked(entityplayer, this.entity.chunkPosition().x, this.entity.chunkPosition().z);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
--- a/net/minecraft/server/level/PlayerInteractManager.java
|
||||
+++ b/net/minecraft/server/level/PlayerInteractManager.java
|
||||
@@ -25,6 +25,27 @@
|
||||
import net.minecraft.world.phys.MovingObjectPositionBlock;
|
||||
@@ -28,6 +28,27 @@
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
@@ -28,7 +28,7 @@
|
||||
public class PlayerInteractManager {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -55,9 +76,16 @@
|
||||
@@ -58,9 +79,16 @@
|
||||
if (enumgamemode == this.gameModeForPlayer) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -46,7 +46,7 @@
|
||||
this.level.updateSleepingPlayerList();
|
||||
if (enumgamemode == EnumGamemode.CREATIVE) {
|
||||
this.player.resetCurrentImpulseContext();
|
||||
@@ -91,7 +119,7 @@
|
||||
@@ -94,7 +122,7 @@
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
@@ -55,7 +55,7 @@
|
||||
IBlockData iblockdata;
|
||||
|
||||
if (this.hasDelayedDestroy) {
|
||||
@@ -145,11 +173,33 @@
|
||||
@@ -148,11 +176,33 @@
|
||||
|
||||
if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.START_DESTROY_BLOCK) {
|
||||
if (!this.level.mayInteract(this.player, blockposition)) {
|
||||
@@ -89,7 +89,7 @@
|
||||
if (this.isCreative()) {
|
||||
this.destroyAndAck(blockposition, j, "creative destroy");
|
||||
return;
|
||||
@@ -165,11 +215,43 @@
|
||||
@@ -168,7 +218,19 @@
|
||||
float f = 1.0F;
|
||||
|
||||
iblockdata = this.level.getBlockState(blockposition);
|
||||
@@ -107,7 +107,10 @@
|
||||
+ this.player.connection.send(new PacketPlayOutBlockChange(this.level, blockposition));
|
||||
+ }
|
||||
+ } else if (!iblockdata.isAir()) {
|
||||
iblockdata.attack(this.level, blockposition, this.player);
|
||||
EnchantmentManager.onHitBlock(this.level, this.player.getMainHandItem(), this.player, this.player, EnumItemSlot.MAINHAND, Vec3D.atCenterOf(blockposition), iblockdata, (item) -> {
|
||||
this.player.onEquippedItemBroken(item, EnumItemSlot.MAINHAND);
|
||||
});
|
||||
@@ -176,6 +238,26 @@
|
||||
f = iblockdata.getDestroyProgress(this.player, this.player.level(), blockposition);
|
||||
}
|
||||
|
||||
@@ -134,7 +137,7 @@
|
||||
if (!iblockdata.isAir() && f >= 1.0F) {
|
||||
this.destroyAndAck(blockposition, j, "insta mine");
|
||||
} else {
|
||||
@@ -214,13 +296,15 @@
|
||||
@@ -220,13 +302,15 @@
|
||||
} else if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.ABORT_DESTROY_BLOCK) {
|
||||
this.isDestroyingBlock = false;
|
||||
if (!Objects.equals(this.destroyPos, blockposition)) {
|
||||
@@ -151,7 +154,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -238,10 +322,65 @@
|
||||
@@ -244,10 +328,65 @@
|
||||
|
||||
public boolean destroyBlock(BlockPosition blockposition) {
|
||||
IBlockData iblockdata = this.level.getBlockState(blockposition);
|
||||
@@ -218,7 +221,7 @@
|
||||
TileEntity tileentity = this.level.getBlockEntity(blockposition);
|
||||
Block block = iblockdata.getBlock();
|
||||
|
||||
@@ -251,6 +390,10 @@
|
||||
@@ -257,6 +396,10 @@
|
||||
} else if (this.player.blockActionRestricted(this.level, blockposition, this.gameModeForPlayer)) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -229,7 +232,7 @@
|
||||
IBlockData iblockdata1 = block.playerWillDestroy(this.level, blockposition, iblockdata, this.player);
|
||||
boolean flag = this.level.removeBlock(blockposition, false);
|
||||
|
||||
@@ -259,19 +402,32 @@
|
||||
@@ -265,19 +408,32 @@
|
||||
}
|
||||
|
||||
if (this.isCreative()) {
|
||||
@@ -265,7 +268,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -309,14 +465,53 @@
|
||||
@@ -315,14 +471,53 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,7 +322,7 @@
|
||||
|
||||
if (itileinventory != null) {
|
||||
entityplayer.openMenu(itileinventory);
|
||||
@@ -347,7 +542,7 @@
|
||||
@@ -353,7 +548,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/level/RegionLimitedWorldAccess.java
|
||||
+++ b/net/minecraft/server/level/RegionLimitedWorldAccess.java
|
||||
@@ -216,7 +216,7 @@
|
||||
@@ -217,7 +217,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);
|
||||
@@ -335,6 +335,13 @@
|
||||
@@ -336,6 +336,13 @@
|
||||
|
||||
@Override
|
||||
public boolean addFreshEntity(Entity entity) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/level/TicketType.java
|
||||
+++ b/net/minecraft/server/level/TicketType.java
|
||||
@@ -23,6 +23,8 @@
|
||||
@@ -22,6 +22,8 @@
|
||||
public static final TicketType<BlockPosition> PORTAL = create("portal", BaseBlockPosition::compareTo, 300);
|
||||
public static final TicketType<Integer> POST_TELEPORT = create("post_teleport", Integer::compareTo, 5);
|
||||
public static final TicketType<ChunkCoordIntPair> UNKNOWN = create("unknown", Comparator.comparingLong(ChunkCoordIntPair::toLong), 1);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/level/WorldServer.java
|
||||
+++ b/net/minecraft/server/level/WorldServer.java
|
||||
@@ -170,6 +170,23 @@
|
||||
@@ -171,6 +171,23 @@
|
||||
import net.minecraft.world.ticks.TickListServer;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
public class WorldServer extends World implements GeneratorAccessSeed {
|
||||
|
||||
public static final BlockPosition END_SPAWN_POINT = new BlockPosition(100, 50, 0);
|
||||
@@ -183,7 +200,7 @@
|
||||
@@ -184,7 +201,7 @@
|
||||
final List<EntityPlayer> players;
|
||||
private final ChunkProviderServer chunkSource;
|
||||
private final MinecraftServer server;
|
||||
@@ -33,7 +33,7 @@
|
||||
private int lastSpawnChunkRadius;
|
||||
final EntityTickList entityTickList;
|
||||
public final PersistentEntitySectionManager<Entity> entityManager;
|
||||
@@ -210,12 +227,30 @@
|
||||
@@ -211,12 +228,30 @@
|
||||
private final boolean tickTime;
|
||||
private final RandomSequences randomSequences;
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
this.players = Lists.newArrayList();
|
||||
this.entityTickList = new EntityTickList();
|
||||
this.blockTicks = new TickListServer<>(this::isPositionTickingWithEntitiesLoaded, this.getProfilerSupplier());
|
||||
@@ -230,6 +265,22 @@
|
||||
@@ -231,6 +266,22 @@
|
||||
this.customSpawners = list;
|
||||
this.serverLevelData = iworlddataserver;
|
||||
ChunkGenerator chunkgenerator = worlddimension.generator();
|
||||
@@ -92,7 +92,7 @@
|
||||
boolean flag2 = minecraftserver.forceSynchronousWrites();
|
||||
DataFixer datafixer = minecraftserver.getFixerUpper();
|
||||
EntityPersistentStorage<Entity> entitypersistentstorage = new EntityStorage(new SimpleRegionStorage(new RegionStorageInfo(convertable_conversionsession.getLevelId(), resourcekey, "entities"), convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, DataFixTypes.ENTITY_CHUNK), this, minecraftserver);
|
||||
@@ -257,9 +308,9 @@
|
||||
@@ -258,9 +309,9 @@
|
||||
long l = minecraftserver.getWorldData().worldGenOptions().seed();
|
||||
|
||||
this.structureCheck = new StructureCheck(this.chunkSource.chunkScanner(), this.registryAccess(), minecraftserver.getStructureManager(), resourcekey, chunkgenerator, this.chunkSource.randomState(), this, chunkgenerator.getBiomeSource(), l, datafixer);
|
||||
@@ -105,7 +105,7 @@
|
||||
} else {
|
||||
this.dragonFight = null;
|
||||
}
|
||||
@@ -269,6 +320,7 @@
|
||||
@@ -270,6 +321,7 @@
|
||||
this.randomSequences = (RandomSequences) Objects.requireNonNullElseGet(randomsequences, () -> {
|
||||
return (RandomSequences) this.getDataStorage().computeIfAbsent(RandomSequences.factory(l), "random_sequences");
|
||||
});
|
||||
@@ -113,7 +113,7 @@
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
@@ -313,12 +365,20 @@
|
||||
@@ -314,12 +366,20 @@
|
||||
long j;
|
||||
|
||||
if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) {
|
||||
@@ -137,7 +137,7 @@
|
||||
if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE) && this.isRaining()) {
|
||||
this.resetWeatherCycle();
|
||||
}
|
||||
@@ -353,7 +413,7 @@
|
||||
@@ -354,7 +414,7 @@
|
||||
|
||||
this.handlingTick = false;
|
||||
gameprofilerfiller.pop();
|
||||
@@ -146,7 +146,7 @@
|
||||
|
||||
if (flag1) {
|
||||
this.resetEmptyTime();
|
||||
@@ -369,7 +429,7 @@
|
||||
@@ -370,7 +430,7 @@
|
||||
|
||||
this.entityTickList.forEach((entity) -> {
|
||||
if (!entity.isRemoved()) {
|
||||
@@ -155,7 +155,7 @@
|
||||
entity.discard();
|
||||
} else if (!tickratemanager.isEntityFrozen(entity)) {
|
||||
gameprofilerfiller.push("checkDespawn");
|
||||
@@ -441,7 +501,7 @@
|
||||
@@ -442,7 +502,7 @@
|
||||
|
||||
private void wakeUpAllPlayers() {
|
||||
this.sleepStatus.removeAllSleepers();
|
||||
@@ -164,7 +164,7 @@
|
||||
entityplayer.stopSleepInBed(false, false);
|
||||
});
|
||||
}
|
||||
@@ -468,7 +528,7 @@
|
||||
@@ -469,7 +529,7 @@
|
||||
entityhorseskeleton.setTrap(true);
|
||||
entityhorseskeleton.setAge(0);
|
||||
entityhorseskeleton.setPos((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ());
|
||||
@@ -173,7 +173,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -477,7 +537,7 @@
|
||||
@@ -478,7 +538,7 @@
|
||||
if (entitylightning != null) {
|
||||
entitylightning.moveTo(Vec3D.atBottomCenterOf(blockposition));
|
||||
entitylightning.setVisualOnly(flag1);
|
||||
@@ -182,7 +182,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -533,7 +593,7 @@
|
||||
@@ -534,7 +594,7 @@
|
||||
BiomeBase biomebase = (BiomeBase) this.getBiome(blockposition1).value();
|
||||
|
||||
if (biomebase.shouldFreeze(this, blockposition2)) {
|
||||
@@ -191,7 +191,7 @@
|
||||
}
|
||||
|
||||
if (this.isRaining()) {
|
||||
@@ -549,10 +609,10 @@
|
||||
@@ -550,10 +610,10 @@
|
||||
IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockSnow.LAYERS, j + 1);
|
||||
|
||||
Block.pushEntitiesUp(iblockdata, iblockdata1, this, blockposition1);
|
||||
@@ -204,7 +204,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -713,6 +773,7 @@
|
||||
@@ -714,6 +774,7 @@
|
||||
this.rainLevel = MathHelper.clamp(this.rainLevel, 0.0F, 1.0F);
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@
|
||||
if (this.oRainLevel != this.rainLevel) {
|
||||
this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel), this.dimension());
|
||||
}
|
||||
@@ -731,15 +792,48 @@
|
||||
@@ -732,15 +793,48 @@
|
||||
this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel));
|
||||
this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, this.thunderLevel));
|
||||
}
|
||||
@@ -263,7 +263,7 @@
|
||||
}
|
||||
|
||||
public void resetEmptyTime() {
|
||||
@@ -774,6 +868,7 @@
|
||||
@@ -775,6 +869,7 @@
|
||||
});
|
||||
gameprofilerfiller.incrementCounter("tickNonPassenger");
|
||||
entity.tick();
|
||||
@@ -271,7 +271,7 @@
|
||||
this.getProfiler().pop();
|
||||
Iterator iterator = entity.getPassengers().iterator();
|
||||
|
||||
@@ -797,6 +892,7 @@
|
||||
@@ -798,6 +893,7 @@
|
||||
});
|
||||
gameprofilerfiller.incrementCounter("tickPassenger");
|
||||
entity1.rideTick();
|
||||
@@ -279,7 +279,7 @@
|
||||
gameprofilerfiller.pop();
|
||||
Iterator iterator = entity1.getPassengers().iterator();
|
||||
|
||||
@@ -821,6 +917,7 @@
|
||||
@@ -822,6 +918,7 @@
|
||||
ChunkProviderServer chunkproviderserver = this.getChunkSource();
|
||||
|
||||
if (!flag1) {
|
||||
@@ -287,7 +287,7 @@
|
||||
if (iprogressupdate != null) {
|
||||
iprogressupdate.progressStartNoAbort(IChatBaseComponent.translatable("menu.savingLevel"));
|
||||
}
|
||||
@@ -838,11 +935,19 @@
|
||||
@@ -839,11 +936,19 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -308,7 +308,7 @@
|
||||
}
|
||||
|
||||
this.getChunkSource().getDataStorage().save();
|
||||
@@ -907,15 +1012,37 @@
|
||||
@@ -908,18 +1013,40 @@
|
||||
|
||||
@Override
|
||||
public boolean addFreshEntity(Entity entity) {
|
||||
@@ -335,7 +335,6 @@
|
||||
}
|
||||
|
||||
public void addDuringTeleport(Entity entity) {
|
||||
- this.addEntity(entity);
|
||||
+ // CraftBukkit start
|
||||
+ // SPIGOT-6415: Don't call spawn event for entities which travel trough worlds,
|
||||
+ // since it is only an implementation detail, that a new entity is created when
|
||||
@@ -344,12 +343,16 @@
|
||||
+ }
|
||||
+
|
||||
+ public void addDuringTeleport(Entity entity, CreatureSpawnEvent.SpawnReason reason) {
|
||||
+ this.addEntity(entity, reason);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
if (entity instanceof EntityPlayer entityplayer) {
|
||||
this.addPlayer(entityplayer);
|
||||
} else {
|
||||
- this.addEntity(entity);
|
||||
+ this.addEntity(entity, reason); // CraftBukkit
|
||||
}
|
||||
|
||||
public void addDuringCommandTeleport(EntityPlayer entityplayer) {
|
||||
@@ -946,24 +1073,37 @@
|
||||
}
|
||||
@@ -944,24 +1071,37 @@
|
||||
this.entityManager.addNewEntity(entityplayer);
|
||||
}
|
||||
|
||||
@@ -391,14 +394,14 @@
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -974,13 +1114,35 @@
|
||||
@@ -972,13 +1112,35 @@
|
||||
}
|
||||
|
||||
public void removePlayerImmediately(EntityPlayer entityplayer, Entity.RemovalReason entity_removalreason) {
|
||||
- entityplayer.remove(entity_removalreason);
|
||||
+ entityplayer.remove(entity_removalreason, null); // CraftBukkit - add Bukkit remove cause
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public boolean strikeLightning(Entity entitylightning) {
|
||||
+ return this.strikeLightning(entitylightning, LightningStrikeEvent.Cause.UNKNOWN);
|
||||
@@ -412,9 +415,9 @@
|
||||
+ }
|
||||
+
|
||||
+ return this.addFreshEntity(entitylightning);
|
||||
}
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
+
|
||||
@Override
|
||||
public void destroyBlockProgress(int i, BlockPosition blockposition, int j) {
|
||||
Iterator iterator = this.server.getPlayerList().getPlayers().iterator();
|
||||
@@ -428,7 +431,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
|
||||
|
||||
@@ -989,6 +1151,12 @@
|
||||
@@ -987,6 +1149,12 @@
|
||||
double d1 = (double) blockposition.getY() - entityplayer.getY();
|
||||
double d2 = (double) blockposition.getZ() - entityplayer.getZ();
|
||||
|
||||
@@ -441,7 +444,7 @@
|
||||
if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) {
|
||||
entityplayer.connection.send(new PacketPlayOutBlockBreakAnimation(i, blockposition, j));
|
||||
}
|
||||
@@ -1049,7 +1217,18 @@
|
||||
@@ -1047,7 +1215,18 @@
|
||||
Iterator iterator = this.navigatingMobs.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
@@ -461,7 +464,7 @@
|
||||
NavigationAbstract navigationabstract = entityinsentient.getNavigation();
|
||||
|
||||
if (navigationabstract.shouldRecomputePath(blockposition)) {
|
||||
@@ -1111,6 +1290,11 @@
|
||||
@@ -1109,6 +1288,11 @@
|
||||
@Override
|
||||
public Explosion explode(@Nullable Entity entity, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator explosiondamagecalculator, double d0, double d1, double d2, float f, boolean flag, World.a world_a, ParticleParam particleparam, ParticleParam particleparam1, Holder<SoundEffect> holder) {
|
||||
Explosion explosion = this.explode(entity, damagesource, explosiondamagecalculator, d0, d1, d2, f, flag, world_a, false, particleparam, particleparam1, holder);
|
||||
@@ -473,7 +476,7 @@
|
||||
|
||||
if (!explosion.interactsWithBlocks()) {
|
||||
explosion.clearToBlow();
|
||||
@@ -1183,13 +1367,20 @@
|
||||
@@ -1181,13 +1365,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) {
|
||||
@@ -496,7 +499,7 @@
|
||||
++j;
|
||||
}
|
||||
}
|
||||
@@ -1240,7 +1431,7 @@
|
||||
@@ -1238,7 +1429,7 @@
|
||||
|
||||
@Nullable
|
||||
public BlockPosition findNearestMapStructure(TagKey<Structure> tagkey, BlockPosition blockposition, int i, boolean flag) {
|
||||
@@ -505,7 +508,7 @@
|
||||
return null;
|
||||
} else {
|
||||
Optional<HolderSet.Named<Structure>> optional = this.registryAccess().registryOrThrow(Registries.STRUCTURE).getTag(tagkey);
|
||||
@@ -1282,11 +1473,22 @@
|
||||
@@ -1280,11 +1471,22 @@
|
||||
@Nullable
|
||||
@Override
|
||||
public WorldMap getMapData(MapId mapid) {
|
||||
@@ -529,7 +532,7 @@
|
||||
this.getServer().overworld().getDataStorage().set(mapid.key(), worldmap);
|
||||
}
|
||||
|
||||
@@ -1597,6 +1799,11 @@
|
||||
@@ -1595,6 +1797,11 @@
|
||||
@Override
|
||||
public void blockUpdated(BlockPosition blockposition, Block block) {
|
||||
if (!this.isDebug()) {
|
||||
@@ -541,7 +544,7 @@
|
||||
this.updateNeighborsAt(blockposition, block);
|
||||
}
|
||||
|
||||
@@ -1616,12 +1823,12 @@
|
||||
@@ -1614,12 +1821,12 @@
|
||||
}
|
||||
|
||||
public boolean isFlat() {
|
||||
@@ -556,7 +559,7 @@
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -1644,7 +1851,7 @@
|
||||
@@ -1642,7 +1849,7 @@
|
||||
private static <T> String getTypeCount(Iterable<T> iterable, Function<T, String> function) {
|
||||
try {
|
||||
Object2IntOpenHashMap<String> object2intopenhashmap = new Object2IntOpenHashMap();
|
||||
@@ -565,7 +568,7 @@
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
T t0 = iterator.next();
|
||||
@@ -1653,7 +1860,7 @@
|
||||
@@ -1651,7 +1858,7 @@
|
||||
object2intopenhashmap.addTo(s, 1);
|
||||
}
|
||||
|
||||
@@ -574,43 +577,7 @@
|
||||
String s1 = (String) entry.getKey();
|
||||
|
||||
return s1 + ":" + entry.getIntValue();
|
||||
@@ -1664,17 +1871,33 @@
|
||||
}
|
||||
|
||||
public static void makeObsidianPlatform(WorldServer worldserver) {
|
||||
+ // CraftBukkit start
|
||||
+ WorldServer.makeObsidianPlatform(worldserver, null);
|
||||
+ }
|
||||
+
|
||||
+ public static void makeObsidianPlatform(WorldServer worldserver, Entity entity) {
|
||||
+ // CraftBukkit end
|
||||
BlockPosition blockposition = WorldServer.END_SPAWN_POINT;
|
||||
int i = blockposition.getX();
|
||||
int j = blockposition.getY() - 2;
|
||||
int k = blockposition.getZ();
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.craftbukkit.util.BlockStateListPopulator blockList = new org.bukkit.craftbukkit.util.BlockStateListPopulator(worldserver);
|
||||
BlockPosition.betweenClosed(i - 2, j + 1, k - 2, i + 2, j + 3, k + 2).forEach((blockposition1) -> {
|
||||
- worldserver.setBlockAndUpdate(blockposition1, Blocks.AIR.defaultBlockState());
|
||||
+ blockList.setBlock(blockposition1, Blocks.AIR.defaultBlockState(), 3);
|
||||
});
|
||||
BlockPosition.betweenClosed(i - 2, j, k - 2, i + 2, j, k + 2).forEach((blockposition1) -> {
|
||||
- worldserver.setBlockAndUpdate(blockposition1, Blocks.OBSIDIAN.defaultBlockState());
|
||||
+ blockList.setBlock(blockposition1, Blocks.OBSIDIAN.defaultBlockState(), 3);
|
||||
});
|
||||
+ org.bukkit.World bworld = worldserver.getWorld();
|
||||
+ org.bukkit.event.world.PortalCreateEvent portalEvent = new org.bukkit.event.world.PortalCreateEvent((List<org.bukkit.block.BlockState>) (List) blockList.getList(), bworld, (entity == null) ? null : entity.getBukkitEntity(), org.bukkit.event.world.PortalCreateEvent.CreateReason.END_PLATFORM);
|
||||
+
|
||||
+ worldserver.getCraftServer().getPluginManager().callEvent(portalEvent);
|
||||
+ if (!portalEvent.isCancelled()) {
|
||||
+ blockList.updateList();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1812,6 +2035,8 @@
|
||||
@@ -1796,6 +2003,8 @@
|
||||
}
|
||||
|
||||
entity.updateDynamicGameEventListener(DynamicGameEventListener::add);
|
||||
@@ -619,7 +586,7 @@
|
||||
}
|
||||
|
||||
public void onTrackingEnd(Entity entity) {
|
||||
@@ -1843,6 +2068,14 @@
|
||||
@@ -1827,6 +2036,14 @@
|
||||
}
|
||||
|
||||
entity.updateDynamicGameEventListener(DynamicGameEventListener::remove);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/network/HandshakeListener.java
|
||||
+++ b/net/minecraft/server/network/HandshakeListener.java
|
||||
@@ -12,8 +12,17 @@
|
||||
@@ -13,8 +13,17 @@
|
||||
import net.minecraft.network.protocol.status.StatusProtocols;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
private static final IChatBaseComponent IGNORE_STATUS_REASON = IChatBaseComponent.translatable("disconnect.ignoring_status_request");
|
||||
private final MinecraftServer server;
|
||||
private final NetworkManager connection;
|
||||
@@ -25,6 +34,7 @@
|
||||
@@ -26,6 +35,7 @@
|
||||
|
||||
@Override
|
||||
public void handleIntention(PacketHandshakingInSetProtocol packethandshakinginsetprotocol) {
|
||||
@@ -26,7 +26,7 @@
|
||||
switch (packethandshakinginsetprotocol.intention()) {
|
||||
case LOGIN:
|
||||
this.beginLogin(packethandshakinginsetprotocol, false);
|
||||
@@ -58,6 +68,40 @@
|
||||
@@ -59,6 +69,40 @@
|
||||
|
||||
private void beginLogin(PacketHandshakingInSetProtocol packethandshakinginsetprotocol, boolean flag) {
|
||||
this.connection.setupOutboundProtocol(LoginProtocols.CLIENTBOUND);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/network/LoginListener.java
|
||||
+++ b/net/minecraft/server/network/LoginListener.java
|
||||
@@ -42,8 +42,33 @@
|
||||
@@ -44,8 +44,33 @@
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
private static final AtomicInteger UNIQUE_THREAD_ID = new AtomicInteger(0);
|
||||
static final Logger LOGGER = LogUtils.getLogger();
|
||||
private static final int MAX_TICKS_BEFORE_LOGIN = 600;
|
||||
@@ -58,6 +83,7 @@
|
||||
@@ -60,6 +85,7 @@
|
||||
private GameProfile authenticatedProfile;
|
||||
private final String serverId;
|
||||
private final boolean transferred;
|
||||
@@ -43,7 +43,7 @@
|
||||
|
||||
public LoginListener(MinecraftServer minecraftserver, NetworkManager networkmanager, boolean flag) {
|
||||
this.state = LoginListener.EnumProtocolState.HELLO;
|
||||
@@ -74,6 +100,12 @@
|
||||
@@ -76,6 +102,12 @@
|
||||
this.verifyLoginAndFinishConnectionSetup((GameProfile) Objects.requireNonNull(this.authenticatedProfile));
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
if (this.state == LoginListener.EnumProtocolState.WAITING_FOR_DUPE_DISCONNECT && !this.isPlayerAlreadyInWorld((GameProfile) Objects.requireNonNull(this.authenticatedProfile))) {
|
||||
this.finishLoginAndWaitForClient(this.authenticatedProfile);
|
||||
}
|
||||
@@ -84,6 +116,13 @@
|
||||
@@ -86,6 +118,13 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
@Override
|
||||
public boolean isAcceptingMessages() {
|
||||
return this.connection.isConnected();
|
||||
@@ -129,7 +168,27 @@
|
||||
@@ -131,7 +170,27 @@
|
||||
this.state = LoginListener.EnumProtocolState.KEY;
|
||||
this.connection.send(new PacketLoginOutEncryptionBegin("", this.server.getKeyPair().getPublic().getEncoded(), this.challenge, true));
|
||||
} else {
|
||||
@@ -99,7 +99,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -142,10 +201,24 @@
|
||||
@@ -144,10 +203,24 @@
|
||||
|
||||
private void verifyLoginAndFinishConnectionSetup(GameProfile gameprofile) {
|
||||
PlayerList playerlist = this.server.getPlayerList();
|
||||
@@ -127,7 +127,7 @@
|
||||
} else {
|
||||
if (this.server.getCompressionThreshold() >= 0 && !this.connection.isMemoryConnection()) {
|
||||
this.connection.send(new PacketLoginOutSetCompression(this.server.getCompressionThreshold()), PacketSendListener.thenRun(() -> {
|
||||
@@ -153,7 +226,7 @@
|
||||
@@ -155,7 +228,7 @@
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@
|
||||
|
||||
if (flag) {
|
||||
this.state = LoginListener.EnumProtocolState.WAITING_FOR_DUPE_DISCONNECT;
|
||||
@@ -203,6 +276,12 @@
|
||||
@@ -205,6 +278,12 @@
|
||||
if (profileresult != null) {
|
||||
GameProfile gameprofile = profileresult.profile();
|
||||
|
||||
@@ -149,7 +149,7 @@
|
||||
LoginListener.LOGGER.info("UUID of player {} is {}", gameprofile.getName(), gameprofile.getId());
|
||||
LoginListener.this.startClientVerification(gameprofile);
|
||||
} else if (LoginListener.this.server.isSingleplayer()) {
|
||||
@@ -220,6 +299,11 @@
|
||||
@@ -222,6 +301,11 @@
|
||||
LoginListener.this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.authservers_down"));
|
||||
LoginListener.LOGGER.error("Couldn't verify username because servers are unavailable");
|
||||
}
|
||||
@@ -161,7 +161,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -236,6 +320,43 @@
|
||||
@@ -238,6 +322,43 @@
|
||||
thread.start();
|
||||
}
|
||||
|
||||
@@ -205,7 +205,11 @@
|
||||
@Override
|
||||
public void handleCustomQueryPacket(ServerboundCustomQueryAnswerPacket serverboundcustomqueryanswerpacket) {
|
||||
this.disconnect(ServerCommonPacketListenerImpl.DISCONNECT_UNEXPECTED_QUERY);
|
||||
@@ -246,7 +367,7 @@
|
||||
@@ -245,10 +366,11 @@
|
||||
|
||||
@Override
|
||||
public void handleLoginAcknowledgement(ServerboundLoginAcknowledgedPacket serverboundloginacknowledgedpacket) {
|
||||
+ PlayerConnectionUtils.ensureRunningOnSameThread(serverboundloginacknowledgedpacket, this, this.server); // CraftBukkit
|
||||
Validate.validState(this.state == LoginListener.EnumProtocolState.PROTOCOL_SWITCHING, "Unexpected login acknowledgement packet", new Object[0]);
|
||||
this.connection.setupOutboundProtocol(ConfigurationProtocols.CLIENTBOUND);
|
||||
CommonListenerCookie commonlistenercookie = CommonListenerCookie.createInitial((GameProfile) Objects.requireNonNull(this.authenticatedProfile), this.transferred);
|
||||
@@ -214,7 +218,7 @@
|
||||
|
||||
this.connection.setupInboundProtocol(ConfigurationProtocols.SERVERBOUND, serverconfigurationpacketlistenerimpl);
|
||||
serverconfigurationpacketlistenerimpl.startConfiguration();
|
||||
@@ -262,12 +383,18 @@
|
||||
@@ -264,12 +386,18 @@
|
||||
|
||||
@Override
|
||||
public void handleCookieResponse(ServerboundCookieResponsePacket serverboundcookieresponsepacket) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/network/PacketStatusListener.java
|
||||
+++ b/net/minecraft/server/network/PacketStatusListener.java
|
||||
@@ -9,6 +9,21 @@
|
||||
@@ -10,6 +10,21 @@
|
||||
import net.minecraft.network.protocol.status.PacketStatusOutServerInfo;
|
||||
import net.minecraft.network.protocol.status.ServerPing;
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
public class PacketStatusListener implements PacketStatusInListener {
|
||||
|
||||
private static final IChatBaseComponent DISCONNECT_REASON = IChatBaseComponent.translatable("multiplayer.status.request_handled");
|
||||
@@ -35,7 +50,101 @@
|
||||
@@ -36,7 +51,101 @@
|
||||
this.connection.disconnect(PacketStatusListener.DISCONNECT_REASON);
|
||||
} else {
|
||||
this.hasRequestedStatus = true;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/network/PlayerConnection.java
|
||||
+++ b/net/minecraft/server/network/PlayerConnection.java
|
||||
@@ -190,6 +190,67 @@
|
||||
@@ -191,6 +191,67 @@
|
||||
import net.minecraft.world.phys.shapes.VoxelShapes;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
public class PlayerConnection extends ServerCommonPacketListenerImpl implements PacketListenerPlayIn, ServerPlayerConnection, TickablePacketListener {
|
||||
|
||||
static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -203,7 +264,9 @@
|
||||
@@ -204,7 +265,9 @@
|
||||
public final PlayerChunkSender chunkSender;
|
||||
private int tickCount;
|
||||
private int ackBlockChangesUpTo = -1;
|
||||
@@ -79,7 +79,7 @@
|
||||
private int dropSpamTickCount;
|
||||
private double firstGoodX;
|
||||
private double firstGoodY;
|
||||
@@ -238,7 +301,7 @@
|
||||
@@ -239,7 +302,7 @@
|
||||
private boolean waitingForSwitchToConfig;
|
||||
|
||||
public PlayerConnection(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayer entityplayer, CommonListenerCookie commonlistenercookie) {
|
||||
@@ -88,7 +88,7 @@
|
||||
this.chunkSender = new PlayerChunkSender(networkmanager.isMemoryConnection());
|
||||
this.player = entityplayer;
|
||||
entityplayer.connection = this;
|
||||
@@ -247,9 +310,25 @@
|
||||
@@ -248,9 +311,25 @@
|
||||
|
||||
Objects.requireNonNull(minecraftserver);
|
||||
this.signedMessageDecoder = SignedMessageChain.b.unsigned(uuid, minecraftserver::enforceSecureProfile);
|
||||
@@ -115,7 +115,7 @@
|
||||
@Override
|
||||
public void tick() {
|
||||
if (this.ackBlockChangesUpTo > -1) {
|
||||
@@ -301,15 +380,21 @@
|
||||
@@ -302,15 +381,21 @@
|
||||
}
|
||||
|
||||
this.keepConnectionAlive();
|
||||
@@ -134,10 +134,10 @@
|
||||
|
||||
if (this.player.getLastActionTime() > 0L && this.server.getPlayerIdleTimeout() > 0 && SystemUtils.getMillis() - this.player.getLastActionTime() > (long) this.server.getPlayerIdleTimeout() * 1000L * 60L) {
|
||||
+ this.player.resetLastActionTime(); // CraftBukkit - SPIGOT-854
|
||||
this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.idling"));
|
||||
this.disconnect((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.idling"));
|
||||
}
|
||||
|
||||
@@ -398,6 +483,13 @@
|
||||
@@ -399,6 +484,13 @@
|
||||
|
||||
if (entity != this.player && entity.getControllingPassenger() == this.player && entity == this.lastVehicle) {
|
||||
WorldServer worldserver = this.player.serverLevel();
|
||||
@@ -151,7 +151,7 @@
|
||||
double d0 = entity.getX();
|
||||
double d1 = entity.getY();
|
||||
double d2 = entity.getZ();
|
||||
@@ -412,7 +504,33 @@
|
||||
@@ -413,7 +505,33 @@
|
||||
double d9 = entity.getDeltaMovement().lengthSqr();
|
||||
double d10 = d6 * d6 + d7 * d7 + d8 * d8;
|
||||
|
||||
@@ -186,7 +186,7 @@
|
||||
PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", new Object[]{entity.getName().getString(), this.player.getName().getString(), d6, d7, d8});
|
||||
this.send(new PacketPlayOutVehicleMove(entity));
|
||||
return;
|
||||
@@ -452,14 +570,76 @@
|
||||
@@ -453,14 +571,76 @@
|
||||
}
|
||||
|
||||
entity.absMoveTo(d3, d4, d5, f, f1);
|
||||
@@ -261,9 +261,9 @@
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
this.player.serverLevel().getChunkSource().move(this.player);
|
||||
this.player.checkMovementStatistics(this.player.getX() - d0, this.player.getY() - d1, this.player.getZ() - d2);
|
||||
this.clientVehicleIsFloating = d11 >= -0.03125D && !flag1 && !this.server.isFlightAllowed() && !entity.isNoGravity() && this.noBlocksAround(entity);
|
||||
@@ -493,6 +673,7 @@
|
||||
Vec3D vec3d = new Vec3D(entity.getX() - d0, entity.getY() - d1, entity.getZ() - d2);
|
||||
|
||||
@@ -497,6 +677,7 @@
|
||||
}
|
||||
|
||||
this.awaitingPositionFromClient = null;
|
||||
@@ -271,7 +271,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -500,7 +681,7 @@
|
||||
@@ -504,7 +685,7 @@
|
||||
@Override
|
||||
public void handleRecipeBookSeenRecipePacket(PacketPlayInRecipeDisplayed packetplayinrecipedisplayed) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinrecipedisplayed, this, this.player.serverLevel());
|
||||
@@ -280,7 +280,7 @@
|
||||
RecipeBookServer recipebookserver = this.player.getRecipeBook();
|
||||
|
||||
Objects.requireNonNull(recipebookserver);
|
||||
@@ -510,6 +691,7 @@
|
||||
@@ -514,6 +695,7 @@
|
||||
@Override
|
||||
public void handleRecipeBookChangeSettingsPacket(PacketPlayInRecipeSettings packetplayinrecipesettings) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinrecipesettings, this, this.player.serverLevel());
|
||||
@@ -288,7 +288,7 @@
|
||||
this.player.getRecipeBook().setBookSetting(packetplayinrecipesettings.getBookType(), packetplayinrecipesettings.isOpen(), packetplayinrecipesettings.isFiltering());
|
||||
}
|
||||
|
||||
@@ -530,6 +712,12 @@
|
||||
@@ -534,6 +716,12 @@
|
||||
@Override
|
||||
public void handleCustomCommandSuggestions(PacketPlayInTabComplete packetplayintabcomplete) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayintabcomplete, this, this.player.serverLevel());
|
||||
@@ -301,7 +301,7 @@
|
||||
StringReader stringreader = new StringReader(packetplayintabcomplete.getCommand());
|
||||
|
||||
if (stringreader.canRead() && stringreader.peek() == '/') {
|
||||
@@ -539,6 +727,7 @@
|
||||
@@ -543,6 +731,7 @@
|
||||
ParseResults<CommandListenerWrapper> parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack());
|
||||
|
||||
this.server.getCommands().getDispatcher().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> {
|
||||
@@ -309,7 +309,7 @@
|
||||
Suggestions suggestions1 = suggestions.getList().size() <= 1000 ? suggestions : new Suggestions(suggestions.getRange(), suggestions.getList().subList(0, 1000));
|
||||
|
||||
this.send(new PacketPlayOutTabComplete(packetplayintabcomplete.getId(), suggestions1));
|
||||
@@ -783,6 +972,13 @@
|
||||
@@ -787,6 +976,13 @@
|
||||
Container container = this.player.containerMenu;
|
||||
|
||||
if (container instanceof ContainerMerchant containermerchant) {
|
||||
@@ -323,13 +323,13 @@
|
||||
if (!containermerchant.stillValid(this.player)) {
|
||||
PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, containermerchant);
|
||||
return;
|
||||
@@ -796,6 +992,13 @@
|
||||
@@ -800,6 +996,13 @@
|
||||
|
||||
@Override
|
||||
public void handleEditBook(PacketPlayInBEdit packetplayinbedit) {
|
||||
+ // CraftBukkit start
|
||||
+ if (this.lastBookTick + 20 > MinecraftServer.currentTick) {
|
||||
+ this.disconnect("Book edited too quickly!");
|
||||
+ this.disconnect(IChatBaseComponent.literal("Book edited too quickly!"));
|
||||
+ return;
|
||||
+ }
|
||||
+ this.lastBookTick = MinecraftServer.currentTick;
|
||||
@@ -337,7 +337,7 @@
|
||||
int i = packetplayinbedit.slot();
|
||||
|
||||
if (PlayerInventory.isHotbarSlot(i) || i == 40) {
|
||||
@@ -804,7 +1007,7 @@
|
||||
@@ -808,7 +1011,7 @@
|
||||
|
||||
Objects.requireNonNull(list);
|
||||
optional.ifPresent(list::add);
|
||||
@@ -346,7 +346,7 @@
|
||||
|
||||
Objects.requireNonNull(list);
|
||||
stream.forEach(list::add);
|
||||
@@ -819,12 +1022,16 @@
|
||||
@@ -823,12 +1026,16 @@
|
||||
}
|
||||
|
||||
private void updateBookContents(List<FilteredText> list, int i) {
|
||||
@@ -364,8 +364,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -835,12 +1042,13 @@
|
||||
ItemStack itemstack1 = itemstack.transmuteCopy(Items.WRITTEN_BOOK, 1);
|
||||
@@ -839,12 +1046,13 @@
|
||||
ItemStack itemstack1 = itemstack.transmuteCopy(Items.WRITTEN_BOOK);
|
||||
|
||||
itemstack1.remove(DataComponents.WRITABLE_BOOK_CONTENT);
|
||||
- List<Filterable<IChatBaseComponent>> list1 = list.stream().map((filteredtext1) -> {
|
||||
@@ -380,7 +380,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -902,7 +1110,7 @@
|
||||
@@ -906,7 +1114,7 @@
|
||||
} else {
|
||||
WorldServer worldserver = this.player.serverLevel();
|
||||
|
||||
@@ -389,15 +389,7 @@
|
||||
if (this.tickCount == 0) {
|
||||
this.resetPosition();
|
||||
}
|
||||
@@ -912,6 +1120,7 @@
|
||||
this.awaitingTeleportTime = this.tickCount;
|
||||
this.teleport(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot());
|
||||
}
|
||||
+ this.allowedPlayerTicks = 20; // CraftBukkit
|
||||
|
||||
} else {
|
||||
this.awaitingTeleportTime = this.tickCount;
|
||||
@@ -924,7 +1133,15 @@
|
||||
@@ -921,7 +1129,15 @@
|
||||
if (this.player.isPassenger()) {
|
||||
this.player.absMoveTo(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1);
|
||||
this.player.serverLevel().getChunkSource().move(this.player);
|
||||
@@ -413,7 +405,7 @@
|
||||
double d3 = this.player.getX();
|
||||
double d4 = this.player.getY();
|
||||
double d5 = this.player.getZ();
|
||||
@@ -946,15 +1163,33 @@
|
||||
@@ -943,15 +1159,33 @@
|
||||
++this.receivedMovePacketCount;
|
||||
int i = this.receivedMovePacketCount - this.knownMovePacketCount;
|
||||
|
||||
@@ -449,7 +441,7 @@
|
||||
PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", new Object[]{this.player.getName().getString(), d6, d7, d8});
|
||||
this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot());
|
||||
return;
|
||||
@@ -976,6 +1211,7 @@
|
||||
@@ -973,6 +1207,7 @@
|
||||
boolean flag2 = this.player.verticalCollisionBelow;
|
||||
|
||||
this.player.move(EnumMoveType.PLAYER, new Vec3D(d6, d7, d8));
|
||||
@@ -457,7 +449,7 @@
|
||||
double d11 = d7;
|
||||
|
||||
d6 = d0 - this.player.getX();
|
||||
@@ -994,9 +1230,75 @@
|
||||
@@ -991,9 +1226,75 @@
|
||||
}
|
||||
|
||||
if (!this.player.noPhysics && !this.player.isSleeping() && (flag3 && worldserver.noCollision(this.player, axisalignedbb) || this.isPlayerCollidingWithAnythingNew(worldserver, axisalignedbb, d0, d1, d2))) {
|
||||
@@ -534,7 +526,15 @@
|
||||
this.player.absMoveTo(d0, d1, d2, f, f1);
|
||||
boolean flag4 = this.player.isAutoSpinAttack();
|
||||
|
||||
@@ -1043,11 +1345,68 @@
|
||||
@@ -1030,6 +1331,7 @@
|
||||
this.awaitingTeleportTime = this.tickCount;
|
||||
this.teleport(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot());
|
||||
}
|
||||
+ this.allowedPlayerTicks = 20; // CraftBukkit
|
||||
|
||||
return true;
|
||||
} else {
|
||||
@@ -1057,11 +1359,68 @@
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -544,8 +544,8 @@
|
||||
+ this.teleport(d0, d1, d2, f, f1, PlayerTeleportEvent.TeleportCause.UNKNOWN);
|
||||
+ }
|
||||
+
|
||||
+ public void teleport(double d0, double d1, double d2, float f, float f1, PlayerTeleportEvent.TeleportCause cause) {
|
||||
+ this.teleport(d0, d1, d2, f, f1, Collections.emptySet(), cause);
|
||||
+ public boolean teleport(double d0, double d1, double d2, float f, float f1, PlayerTeleportEvent.TeleportCause cause) {
|
||||
+ return this.teleport(d0, d1, d2, f, f1, Collections.emptySet(), cause);
|
||||
}
|
||||
|
||||
public void teleport(double d0, double d1, double d2, float f, float f1, Set<RelativeMovement> set) {
|
||||
@@ -604,7 +604,7 @@
|
||||
double d3 = set.contains(RelativeMovement.X) ? this.player.getX() : 0.0D;
|
||||
double d4 = set.contains(RelativeMovement.Y) ? this.player.getY() : 0.0D;
|
||||
double d5 = set.contains(RelativeMovement.Z) ? this.player.getZ() : 0.0D;
|
||||
@@ -1059,6 +1418,14 @@
|
||||
@@ -1073,6 +1432,14 @@
|
||||
this.awaitingTeleport = 0;
|
||||
}
|
||||
|
||||
@@ -617,9 +617,9 @@
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
this.awaitingTeleportTime = this.tickCount;
|
||||
this.player.resetCurrentImpulseContext();
|
||||
this.player.absMoveTo(d0, d1, d2, f, f1);
|
||||
@@ -1068,6 +1435,7 @@
|
||||
this.player.connection.send(new PacketPlayOutPosition(d0 - d3, d1 - d4, d2 - d5, f - f2, f1 - f3, set, this.awaitingTeleport));
|
||||
@@ -1081,6 +1448,7 @@
|
||||
@Override
|
||||
public void handlePlayerAction(PacketPlayInBlockDig packetplayinblockdig) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockdig, this, this.player.serverLevel());
|
||||
@@ -627,7 +627,7 @@
|
||||
BlockPosition blockposition = packetplayinblockdig.getPos();
|
||||
|
||||
this.player.resetLastActionTime();
|
||||
@@ -1078,14 +1446,46 @@
|
||||
@@ -1091,14 +1459,46 @@
|
||||
if (!this.player.isSpectator()) {
|
||||
ItemStack itemstack = this.player.getItemInHand(EnumHand.OFF_HAND);
|
||||
|
||||
@@ -668,7 +668,7 @@
|
||||
+ this.dropCount++;
|
||||
+ if (this.dropCount >= 20) {
|
||||
+ LOGGER.warn(this.player.getScoreboardName() + " dropped their items too quickly!");
|
||||
+ this.disconnect("You dropped your items too quickly (Hacking?)");
|
||||
+ this.disconnect(IChatBaseComponent.literal("You dropped your items too quickly (Hacking?)"));
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
@@ -676,7 +676,7 @@
|
||||
this.player.drop(false);
|
||||
}
|
||||
|
||||
@@ -1123,6 +1523,7 @@
|
||||
@@ -1136,6 +1536,7 @@
|
||||
@Override
|
||||
public void handleUseItemOn(PacketPlayInUseItem packetplayinuseitem) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseitem, this, this.player.serverLevel());
|
||||
@@ -684,7 +684,7 @@
|
||||
this.player.connection.ackBlockChangesUpTo(packetplayinuseitem.getSequence());
|
||||
WorldServer worldserver = this.player.serverLevel();
|
||||
EnumHand enumhand = packetplayinuseitem.getHand();
|
||||
@@ -1145,6 +1546,7 @@
|
||||
@@ -1158,6 +1559,7 @@
|
||||
|
||||
if (blockposition.getY() < i) {
|
||||
if (this.awaitingPositionFromClient == null && worldserver.mayInteract(this.player, blockposition)) {
|
||||
@@ -692,7 +692,7 @@
|
||||
EnumInteractionResult enuminteractionresult = this.player.gameMode.useItemOn(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock);
|
||||
|
||||
if (enuminteractionresult.consumesAction()) {
|
||||
@@ -1177,6 +1579,7 @@
|
||||
@@ -1190,6 +1592,7 @@
|
||||
@Override
|
||||
public void handleUseItem(PacketPlayInBlockPlace packetplayinblockplace) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockplace, this, this.player.serverLevel());
|
||||
@@ -700,21 +700,19 @@
|
||||
this.ackBlockChangesUpTo(packetplayinblockplace.getSequence());
|
||||
WorldServer worldserver = this.player.serverLevel();
|
||||
EnumHand enumhand = packetplayinblockplace.getHand();
|
||||
@@ -1184,6 +1587,49 @@
|
||||
@@ -1204,6 +1607,47 @@
|
||||
this.player.absRotateTo(f, f1);
|
||||
}
|
||||
|
||||
this.player.resetLastActionTime();
|
||||
if (!itemstack.isEmpty() && itemstack.isItemEnabled(worldserver.enabledFeatures())) {
|
||||
+ // CraftBukkit start
|
||||
+ // Raytrace to look for 'rogue armswings'
|
||||
+ float f1 = this.player.getXRot();
|
||||
+ float f2 = this.player.getYRot();
|
||||
+ double d0 = this.player.getX();
|
||||
+ double d1 = this.player.getY() + (double) this.player.getEyeHeight();
|
||||
+ double d2 = this.player.getZ();
|
||||
+ Vec3D vec3d = new Vec3D(d0, d1, d2);
|
||||
+
|
||||
+ float f3 = MathHelper.cos(-f2 * 0.017453292F - 3.1415927F);
|
||||
+ float f4 = MathHelper.sin(-f2 * 0.017453292F - 3.1415927F);
|
||||
+ float f3 = MathHelper.cos(-f * 0.017453292F - 3.1415927F);
|
||||
+ float f4 = MathHelper.sin(-f * 0.017453292F - 3.1415927F);
|
||||
+ float f5 = -MathHelper.cos(-f1 * 0.017453292F);
|
||||
+ float f6 = MathHelper.sin(-f1 * 0.017453292F);
|
||||
+ float f7 = f4 * f5;
|
||||
@@ -750,7 +748,7 @@
|
||||
EnumInteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand);
|
||||
|
||||
if (enuminteractionresult.shouldSwing()) {
|
||||
@@ -1204,7 +1650,7 @@
|
||||
@@ -1224,7 +1668,7 @@
|
||||
Entity entity = packetplayinspectate.getEntity(worldserver);
|
||||
|
||||
if (entity != null) {
|
||||
@@ -759,10 +757,10 @@
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1225,6 +1671,13 @@
|
||||
@@ -1245,6 +1689,13 @@
|
||||
|
||||
@Override
|
||||
public void onDisconnect(IChatBaseComponent ichatbasecomponent) {
|
||||
public void onDisconnect(DisconnectionDetails disconnectiondetails) {
|
||||
+ // CraftBukkit start - Rarely it would send a disconnect line twice
|
||||
+ if (this.processedDisconnect) {
|
||||
+ return;
|
||||
@@ -770,10 +768,10 @@
|
||||
+ this.processedDisconnect = true;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
PlayerConnection.LOGGER.info("{} lost connection: {}", this.player.getName().getString(), ichatbasecomponent.getString());
|
||||
PlayerConnection.LOGGER.info("{} lost connection: {}", this.player.getName().getString(), disconnectiondetails.reason().getString());
|
||||
this.removePlayerFromWorld();
|
||||
super.onDisconnect(ichatbasecomponent);
|
||||
@@ -1232,10 +1685,18 @@
|
||||
super.onDisconnect(disconnectiondetails);
|
||||
@@ -1252,10 +1703,18 @@
|
||||
|
||||
private void removePlayerFromWorld() {
|
||||
this.chatMessageChain.close();
|
||||
@@ -793,7 +791,7 @@
|
||||
this.player.getTextFilter().leave();
|
||||
}
|
||||
|
||||
@@ -1250,7 +1711,16 @@
|
||||
@@ -1270,7 +1729,16 @@
|
||||
@Override
|
||||
public void handleSetCarriedItem(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinhelditemslot, this, this.player.serverLevel());
|
||||
@@ -810,11 +808,11 @@
|
||||
if (this.player.getInventory().selected != packetplayinhelditemslot.getSlot() && this.player.getUsedItemHand() == EnumHand.MAIN_HAND) {
|
||||
this.player.stopUsingItem();
|
||||
}
|
||||
@@ -1259,11 +1729,18 @@
|
||||
@@ -1279,11 +1747,18 @@
|
||||
this.player.resetLastActionTime();
|
||||
} else {
|
||||
PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString());
|
||||
+ this.disconnect("Invalid hotbar selection (Hacking?)"); // CraftBukkit
|
||||
+ this.disconnect(IChatBaseComponent.literal("Invalid hotbar selection (Hacking?)")); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -829,7 +827,7 @@
|
||||
Optional<LastSeenMessages> optional = this.unpackAndApplyLastSeen(packetplayinchat.lastSeenMessages());
|
||||
|
||||
if (!optional.isEmpty()) {
|
||||
@@ -1277,7 +1754,7 @@
|
||||
@@ -1297,7 +1772,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -838,7 +836,7 @@
|
||||
IChatBaseComponent ichatbasecomponent = this.server.getChatDecorator().decorate(this.player, playerchatmessage.decoratedContent());
|
||||
|
||||
this.chatMessageChain.append(completablefuture, (filteredtext) -> {
|
||||
@@ -1285,19 +1762,36 @@
|
||||
@@ -1305,19 +1780,36 @@
|
||||
|
||||
this.broadcastChatMessage(playerchatmessage1);
|
||||
});
|
||||
@@ -877,7 +875,7 @@
|
||||
ParseResults<CommandListenerWrapper> parseresults = this.parseCommand(s);
|
||||
|
||||
if (this.server.enforceSecureProfile() && SignableCommand.hasSignableArguments(parseresults)) {
|
||||
@@ -1314,19 +1808,37 @@
|
||||
@@ -1334,19 +1826,37 @@
|
||||
|
||||
if (!optional.isEmpty()) {
|
||||
this.tryHandleChat(serverboundchatcommandsignedpacket.command(), () -> {
|
||||
@@ -918,7 +916,7 @@
|
||||
} catch (SignedMessageChain.a signedmessagechain_a) {
|
||||
this.handleMessageDecodeFailure(signedmessagechain_a);
|
||||
return;
|
||||
@@ -1334,10 +1846,10 @@
|
||||
@@ -1354,10 +1864,10 @@
|
||||
|
||||
CommandSigningContext.a commandsigningcontext_a = new CommandSigningContext.a(map);
|
||||
|
||||
@@ -931,14 +929,14 @@
|
||||
}
|
||||
|
||||
private void handleMessageDecodeFailure(SignedMessageChain.a signedmessagechain_a) {
|
||||
@@ -1413,14 +1925,20 @@
|
||||
@@ -1433,14 +1943,20 @@
|
||||
return com_mojang_brigadier_commanddispatcher.parse(s, this.player.createCommandSourceStack());
|
||||
}
|
||||
|
||||
- private void tryHandleChat(String s, Runnable runnable) {
|
||||
+ private void tryHandleChat(String s, Runnable runnable, boolean sync) { // CraftBukkit
|
||||
if (isChatMessageIllegal(s)) {
|
||||
this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.illegal_characters"));
|
||||
this.disconnect((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.illegal_characters"));
|
||||
- } else if (this.player.getChatVisibility() == EnumChatVisibility.HIDDEN) {
|
||||
+ } else if (this.player.isRemoved() || this.player.getChatVisibility() == EnumChatVisibility.HIDDEN) { // CraftBukkit - dead men tell no tales
|
||||
this.send(new ClientboundSystemChatPacket(IChatBaseComponent.translatable("chat.disabled.options").withStyle(EnumChatFormat.RED), false));
|
||||
@@ -955,7 +953,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1449,6 +1967,116 @@
|
||||
@@ -1469,6 +1985,116 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1072,7 +1070,7 @@
|
||||
private PlayerChatMessage getSignedMessage(PacketPlayInChat packetplayinchat, LastSeenMessages lastseenmessages) throws SignedMessageChain.a {
|
||||
SignedMessageBody signedmessagebody = new SignedMessageBody(packetplayinchat.message(), packetplayinchat.timeStamp(), packetplayinchat.salt(), lastseenmessages);
|
||||
|
||||
@@ -1456,13 +2084,33 @@
|
||||
@@ -1476,13 +2102,33 @@
|
||||
}
|
||||
|
||||
private void broadcastChatMessage(PlayerChatMessage playerchatmessage) {
|
||||
@@ -1101,15 +1099,15 @@
|
||||
|
||||
private void detectRateSpam() {
|
||||
- this.chatSpamTickCount += 20;
|
||||
- if (this.chatSpamTickCount > 200 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) {
|
||||
- if (this.chatSpamTickCount > 200 && !this.server.getPlayerList().isOp(this.player.getGameProfile()) && !this.server.isSingleplayerOwner(this.player.getGameProfile())) {
|
||||
+ // CraftBukkit start - replaced with thread safe throttle
|
||||
+ // this.chatSpamTickCount += 20;
|
||||
+ if (this.chatSpamTickCount.addAndGet(20) > 200 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) {
|
||||
+ if (this.chatSpamTickCount.addAndGet(20) > 200 && !this.server.getPlayerList().isOp(this.player.getGameProfile()) && !this.server.isSingleplayerOwner(this.player.getGameProfile())) {
|
||||
+ // CraftBukkit end
|
||||
this.disconnect(IChatBaseComponent.translatable("disconnect.spam"));
|
||||
this.disconnect((IChatBaseComponent) IChatBaseComponent.translatable("disconnect.spam"));
|
||||
}
|
||||
|
||||
@@ -1484,13 +2132,62 @@
|
||||
@@ -1504,13 +2150,62 @@
|
||||
@Override
|
||||
public void handleAnimate(PacketPlayInArmAnimation packetplayinarmanimation) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinarmanimation, this, this.player.serverLevel());
|
||||
@@ -1172,7 +1170,7 @@
|
||||
this.player.resetLastActionTime();
|
||||
Entity entity;
|
||||
|
||||
@@ -1567,6 +2264,12 @@
|
||||
@@ -1587,6 +2282,12 @@
|
||||
}
|
||||
|
||||
public void sendPlayerChatMessage(PlayerChatMessage playerchatmessage, ChatMessageType.a chatmessagetype_a) {
|
||||
@@ -1185,7 +1183,7 @@
|
||||
this.send(new ClientboundPlayerChatPacket(playerchatmessage.link().sender(), playerchatmessage.link().index(), playerchatmessage.signature(), playerchatmessage.signedBody().pack(this.messageSignatureCache), playerchatmessage.unsignedContent(), playerchatmessage.filterMask(), chatmessagetype_a));
|
||||
this.addPendingMessage(playerchatmessage);
|
||||
}
|
||||
@@ -1594,6 +2297,7 @@
|
||||
@@ -1614,6 +2315,7 @@
|
||||
@Override
|
||||
public void handleInteract(PacketPlayInUseEntity packetplayinuseentity) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseentity, this, this.player.serverLevel());
|
||||
@@ -1193,7 +1191,7 @@
|
||||
final WorldServer worldserver = this.player.serverLevel();
|
||||
final Entity entity = packetplayinuseentity.getTarget(worldserver);
|
||||
|
||||
@@ -1608,13 +2312,51 @@
|
||||
@@ -1628,13 +2330,51 @@
|
||||
|
||||
if (this.player.canInteractWithEntity(axisalignedbb, 1.0D)) {
|
||||
packetplayinuseentity.dispatch(new PacketPlayInUseEntity.c() {
|
||||
@@ -1212,7 +1210,7 @@
|
||||
+
|
||||
+ // Entity in bucket - SPIGOT-4048 and SPIGOT-6859a
|
||||
+ 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 PacketPlayOutSpawnEntity(entity));
|
||||
+ entity.getBukkitEntity().update(player);
|
||||
+ player.containerMenu.sendAllDataToRemote();
|
||||
+ }
|
||||
+
|
||||
@@ -1246,7 +1244,7 @@
|
||||
if (enuminteractionresult.consumesAction()) {
|
||||
CriterionTriggers.PLAYER_INTERACTED_WITH_ENTITY.trigger(PlayerConnection.this.player, enuminteractionresult.indicateItemUse() ? itemstack1 : ItemStack.EMPTY, entity);
|
||||
if (enuminteractionresult.shouldSwing()) {
|
||||
@@ -1627,19 +2369,20 @@
|
||||
@@ -1647,19 +2387,20 @@
|
||||
|
||||
@Override
|
||||
public void onInteraction(EnumHand enumhand) {
|
||||
@@ -1270,7 +1268,7 @@
|
||||
label23:
|
||||
{
|
||||
if (entity instanceof EntityArrow) {
|
||||
@@ -1657,6 +2400,11 @@
|
||||
@@ -1677,6 +2418,11 @@
|
||||
}
|
||||
|
||||
PlayerConnection.this.player.attack(entity);
|
||||
@@ -1282,20 +1280,20 @@
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1680,17 +2428,17 @@
|
||||
@@ -1700,17 +2446,17 @@
|
||||
case PERFORM_RESPAWN:
|
||||
if (this.player.wonGame) {
|
||||
this.player.wonGame = false;
|
||||
- this.player = this.server.getPlayerList().respawn(this.player, true);
|
||||
+ this.player = this.server.getPlayerList().respawn(this.player, true, RespawnReason.END_PORTAL);
|
||||
- this.player = this.server.getPlayerList().respawn(this.player, true, Entity.RemovalReason.CHANGED_DIMENSION);
|
||||
+ this.player = this.server.getPlayerList().respawn(this.player, true, Entity.RemovalReason.CHANGED_DIMENSION, RespawnReason.END_PORTAL); // CraftBukkit
|
||||
CriterionTriggers.CHANGED_DIMENSION.trigger(this.player, World.END, World.OVERWORLD);
|
||||
} else {
|
||||
if (this.player.getHealth() > 0.0F) {
|
||||
return;
|
||||
}
|
||||
|
||||
- this.player = this.server.getPlayerList().respawn(this.player, false);
|
||||
+ this.player = this.server.getPlayerList().respawn(this.player, false, RespawnReason.DEATH);
|
||||
- this.player = this.server.getPlayerList().respawn(this.player, false, Entity.RemovalReason.KILLED);
|
||||
+ this.player = this.server.getPlayerList().respawn(this.player, false, Entity.RemovalReason.KILLED, RespawnReason.DEATH); // CraftBukkit
|
||||
if (this.server.isHardcore()) {
|
||||
this.player.setGameMode(EnumGamemode.SPECTATOR);
|
||||
- ((GameRules.GameRuleBoolean) this.player.level().getGameRules().getRule(GameRules.RULE_SPECTATORSGENERATECHUNKS)).set(false, this.server);
|
||||
@@ -1303,7 +1301,7 @@
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1703,15 +2451,21 @@
|
||||
@@ -1723,15 +2469,21 @@
|
||||
@Override
|
||||
public void handleContainerClose(PacketPlayInCloseWindow packetplayinclosewindow) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinclosewindow, this, this.player.serverLevel());
|
||||
@@ -1327,7 +1325,7 @@
|
||||
this.player.containerMenu.sendAllDataToRemote();
|
||||
} else if (!this.player.containerMenu.stillValid(this.player)) {
|
||||
PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu);
|
||||
@@ -1724,7 +2478,284 @@
|
||||
@@ -1744,7 +2496,284 @@
|
||||
boolean flag = packetplayinwindowclick.getStateId() != this.player.containerMenu.getStateId();
|
||||
|
||||
this.player.containerMenu.suppressRemoteUpdates();
|
||||
@@ -1613,7 +1611,7 @@
|
||||
ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packetplayinwindowclick.getChangedSlots()).iterator();
|
||||
|
||||
while (objectiterator.hasNext()) {
|
||||
@@ -1754,9 +2785,18 @@
|
||||
@@ -1774,9 +2803,18 @@
|
||||
if (!this.player.containerMenu.stillValid(this.player)) {
|
||||
PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu);
|
||||
} else {
|
||||
@@ -1634,7 +1632,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1764,6 +2804,7 @@
|
||||
@@ -1784,6 +2822,7 @@
|
||||
@Override
|
||||
public void handleContainerButtonClick(PacketPlayInEnchantItem packetplayinenchantitem) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinenchantitem, this, this.player.serverLevel());
|
||||
@@ -1642,7 +1640,7 @@
|
||||
this.player.resetLastActionTime();
|
||||
if (this.player.containerMenu.containerId == packetplayinenchantitem.containerId() && !this.player.isSpectator()) {
|
||||
if (!this.player.containerMenu.stillValid(this.player)) {
|
||||
@@ -1806,6 +2847,43 @@
|
||||
@@ -1826,6 +2865,43 @@
|
||||
|
||||
boolean flag1 = packetplayinsetcreativeslot.slotNum() >= 1 && packetplayinsetcreativeslot.slotNum() <= 45;
|
||||
boolean flag2 = itemstack.isEmpty() || itemstack.getCount() <= itemstack.getMaxStackSize();
|
||||
@@ -1686,7 +1684,7 @@
|
||||
|
||||
if (flag1 && flag2) {
|
||||
this.player.inventoryMenu.getSlot(packetplayinsetcreativeslot.slotNum()).setByPlayer(itemstack);
|
||||
@@ -1828,6 +2906,7 @@
|
||||
@@ -1848,6 +2924,7 @@
|
||||
}
|
||||
|
||||
private void updateSignText(PacketPlayInUpdateSign packetplayinupdatesign, List<FilteredText> list) {
|
||||
@@ -1694,7 +1692,7 @@
|
||||
this.player.resetLastActionTime();
|
||||
WorldServer worldserver = this.player.serverLevel();
|
||||
BlockPosition blockposition = packetplayinupdatesign.getPos();
|
||||
@@ -1849,7 +2928,17 @@
|
||||
@@ -1869,7 +2946,17 @@
|
||||
@Override
|
||||
public void handlePlayerAbilities(PacketPlayInAbilities packetplayinabilities) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinabilities, this, this.player.serverLevel());
|
||||
@@ -1713,7 +1711,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1908,7 +2997,7 @@
|
||||
@@ -1928,7 +3015,7 @@
|
||||
if (!this.waitingForSwitchToConfig) {
|
||||
throw new IllegalStateException("Client acknowledged config, but none was requested");
|
||||
} else {
|
||||
@@ -1722,7 +1720,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1933,8 +3022,10 @@
|
||||
@@ -1953,8 +3040,10 @@
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
+++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
@@ -27,8 +27,39 @@
|
||||
@@ -28,8 +28,39 @@
|
||||
import net.minecraft.util.thread.IAsyncTaskHandler;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@@ -20,14 +20,14 @@
|
||||
+import org.bukkit.craftbukkit.util.Waitable;
|
||||
+import org.bukkit.event.player.PlayerKickEvent;
|
||||
+import org.bukkit.event.player.PlayerResourcePackStatusEvent;
|
||||
+
|
||||
|
||||
+public abstract class ServerCommonPacketListenerImpl implements ServerCommonPacketListener, CraftPlayer.TransferCookieConnection {
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isTransferred() {
|
||||
+ return this.transferred;
|
||||
+ }
|
||||
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumProtocol getProtocol() {
|
||||
+ return protocol();
|
||||
@@ -41,7 +41,7 @@
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
public static final int LATENCY_CHECK_INTERVAL = 15000;
|
||||
private static final int CLOSED_LISTENER_TIMEOUT = 15000;
|
||||
@@ -45,12 +76,24 @@
|
||||
@@ -46,12 +77,24 @@
|
||||
private int latency;
|
||||
private volatile boolean suspendFlushingOnServerThread = false;
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
}
|
||||
|
||||
private void close() {
|
||||
@@ -72,6 +115,7 @@
|
||||
@@ -73,6 +116,7 @@
|
||||
|
||||
@Override
|
||||
public void handleKeepAlive(ServerboundKeepAlivePacket serverboundkeepalivepacket) {
|
||||
@@ -75,13 +75,13 @@
|
||||
if (this.keepAlivePending && serverboundkeepalivepacket.getId() == this.keepAliveChallenge) {
|
||||
int i = (int) (SystemUtils.getMillis() - this.keepAliveTime);
|
||||
|
||||
@@ -86,8 +130,56 @@
|
||||
@@ -87,8 +131,56 @@
|
||||
@Override
|
||||
public void handlePong(ServerboundPongPacket serverboundpongpacket) {}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ private static final MinecraftKey CUSTOM_REGISTER = new MinecraftKey("register");
|
||||
+ private static final MinecraftKey CUSTOM_UNREGISTER = new MinecraftKey("unregister");
|
||||
+ private static final MinecraftKey CUSTOM_REGISTER = MinecraftKey.withDefaultNamespace("register");
|
||||
+ private static final MinecraftKey CUSTOM_UNREGISTER = MinecraftKey.withDefaultNamespace("unregister");
|
||||
+
|
||||
@Override
|
||||
- public void handleCustomPayload(ServerboundCustomPayloadPacket serverboundcustompayloadpacket) {}
|
||||
@@ -101,7 +101,7 @@
|
||||
+ }
|
||||
+ } catch (Exception ex) {
|
||||
+ PlayerConnection.LOGGER.error("Couldn\'t register custom payload", ex);
|
||||
+ this.disconnect("Invalid payload REGISTER!");
|
||||
+ this.disconnect(IChatBaseComponent.literal("Invalid payload REGISTER!"));
|
||||
+ }
|
||||
+ } else if (identifier.equals(CUSTOM_UNREGISTER)) {
|
||||
+ try {
|
||||
@@ -111,7 +111,7 @@
|
||||
+ }
|
||||
+ } catch (Exception ex) {
|
||||
+ PlayerConnection.LOGGER.error("Couldn\'t unregister custom payload", ex);
|
||||
+ this.disconnect("Invalid payload UNREGISTER!");
|
||||
+ this.disconnect(IChatBaseComponent.literal("Invalid payload UNREGISTER!"));
|
||||
+ }
|
||||
+ } else {
|
||||
+ try {
|
||||
@@ -120,7 +120,7 @@
|
||||
+ cserver.getMessenger().dispatchIncomingMessage(player.getBukkitEntity(), identifier.toString(), data);
|
||||
+ } catch (Exception ex) {
|
||||
+ PlayerConnection.LOGGER.error("Couldn\'t dispatch custom payload", ex);
|
||||
+ this.disconnect("Invalid custom payload!");
|
||||
+ this.disconnect(IChatBaseComponent.literal("Invalid custom payload!"));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
@@ -133,9 +133,9 @@
|
||||
|
||||
@Override
|
||||
public void handleResourcePackResponse(ServerboundResourcePackPacket serverboundresourcepackpacket) {
|
||||
@@ -96,11 +188,18 @@
|
||||
@@ -97,11 +189,18 @@
|
||||
ServerCommonPacketListenerImpl.LOGGER.info("Disconnecting {} due to resource pack {} rejection", this.playerProfile().getName(), serverboundresourcepackpacket.id());
|
||||
this.disconnect(IChatBaseComponent.translatable("multiplayer.requiredTexturePrompt.disconnect"));
|
||||
this.disconnect((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.requiredTexturePrompt.disconnect"));
|
||||
}
|
||||
+ this.cserver.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(getCraftPlayer(), serverboundresourcepackpacket.id(), PlayerResourcePackStatusEvent.Status.values()[serverboundresourcepackpacket.action().ordinal()])); // CraftBukkit
|
||||
|
||||
@@ -152,7 +152,7 @@
|
||||
this.disconnect(ServerCommonPacketListenerImpl.DISCONNECT_UNEXPECTED_QUERY);
|
||||
}
|
||||
|
||||
@@ -108,7 +207,7 @@
|
||||
@@ -109,7 +208,7 @@
|
||||
this.server.getProfiler().push("keepAlive");
|
||||
long i = SystemUtils.getMillis();
|
||||
|
||||
@@ -161,7 +161,7 @@
|
||||
if (this.keepAlivePending) {
|
||||
this.disconnect(ServerCommonPacketListenerImpl.TIMEOUT_DISCONNECTION_MESSAGE);
|
||||
} else if (this.checkIfClosed(i)) {
|
||||
@@ -148,6 +247,14 @@
|
||||
@@ -149,6 +248,14 @@
|
||||
}
|
||||
|
||||
public void send(Packet<?> packet, @Nullable PacketSendListener packetsendlistener) {
|
||||
@@ -176,18 +176,10 @@
|
||||
if (packet.isTerminal()) {
|
||||
this.close();
|
||||
}
|
||||
@@ -167,16 +274,67 @@
|
||||
}
|
||||
@@ -173,15 +280,61 @@
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ @Deprecated
|
||||
public void disconnect(IChatBaseComponent ichatbasecomponent) {
|
||||
+ disconnect(CraftChatMessage.fromComponent(ichatbasecomponent));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
+ public void disconnect(String s) {
|
||||
public void disconnect(DisconnectionDetails disconnectiondetails) {
|
||||
+ // CraftBukkit start - fire PlayerKickEvent
|
||||
+ if (this.processedDisconnect) {
|
||||
+ return;
|
||||
@@ -196,7 +188,7 @@
|
||||
+ Waitable waitable = new Waitable() {
|
||||
+ @Override
|
||||
+ protected Object evaluate() {
|
||||
+ ServerCommonPacketListenerImpl.this.disconnect(s);
|
||||
+ ServerCommonPacketListenerImpl.this.disconnect(disconnectiondetails);
|
||||
+ return null;
|
||||
+ }
|
||||
+ };
|
||||
@@ -215,7 +207,7 @@
|
||||
+
|
||||
+ String leaveMessage = EnumChatFormat.YELLOW + this.player.getScoreboardName() + " left the game.";
|
||||
+
|
||||
+ PlayerKickEvent event = new PlayerKickEvent(this.player.getBukkitEntity(), s, leaveMessage);
|
||||
+ PlayerKickEvent event = new PlayerKickEvent(this.player.getBukkitEntity(), CraftChatMessage.fromComponent(disconnectiondetails.reason()), leaveMessage);
|
||||
+
|
||||
+ if (this.cserver.getServer().isRunning()) {
|
||||
+ this.cserver.getPluginManager().callEvent(event);
|
||||
@@ -227,13 +219,15 @@
|
||||
+ }
|
||||
+ this.player.kickLeaveMessage = event.getLeaveMessage(); // CraftBukkit - SPIGOT-3034: Forward leave message to PlayerQuitEvent
|
||||
+ // Send the possibly modified leave message
|
||||
+ final IChatBaseComponent ichatbasecomponent = CraftChatMessage.fromString(event.getReason(), true)[0];
|
||||
+ // CraftBukkit end
|
||||
+ disconnect0(new DisconnectionDetails(CraftChatMessage.fromString(event.getReason(), true)[0], disconnectiondetails.report(), disconnectiondetails.bugReportLink()));
|
||||
+ }
|
||||
+
|
||||
this.connection.send(new ClientboundDisconnectPacket(ichatbasecomponent), PacketSendListener.thenRun(() -> {
|
||||
this.connection.disconnect(ichatbasecomponent);
|
||||
+ private void disconnect0(DisconnectionDetails disconnectiondetails) {
|
||||
+ // CraftBukkit end
|
||||
this.connection.send(new ClientboundDisconnectPacket(disconnectiondetails.reason()), PacketSendListener.thenRun(() -> {
|
||||
this.connection.disconnect(disconnectiondetails);
|
||||
}));
|
||||
+ this.onDisconnect(ichatbasecomponent); // CraftBukkit - fire quit instantly
|
||||
+ this.onDisconnect(disconnectiondetails); // CraftBukkit - fire quit instantly
|
||||
this.connection.setReadOnly();
|
||||
MinecraftServer minecraftserver = this.server;
|
||||
NetworkManager networkmanager = this.connection;
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
--- a/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java
|
||||
+++ b/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java
|
||||
@@ -47,8 +47,10 @@
|
||||
@@ -38,6 +38,11 @@
|
||||
import net.minecraft.world.flag.FeatureFlags;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.CraftServerLinks;
|
||||
+import org.bukkit.event.player.PlayerLinksSendEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class ServerConfigurationPacketListenerImpl extends ServerCommonPacketListenerImpl implements ServerConfigurationPacketListener, TickablePacketListener {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -50,8 +55,10 @@
|
||||
@Nullable
|
||||
private SynchronizeRegistriesTask synchronizeRegistriesTask;
|
||||
|
||||
@@ -13,7 +25,20 @@
|
||||
this.gameProfile = commonlistenercookie.gameProfile();
|
||||
this.clientInformation = commonlistenercookie.clientInformation();
|
||||
}
|
||||
@@ -134,14 +136,14 @@
|
||||
@@ -75,6 +82,12 @@
|
||||
public void startConfiguration() {
|
||||
this.send(new ClientboundCustomPayloadPacket(new BrandPayload(this.server.getServerModName())));
|
||||
ServerLinks serverlinks = this.server.serverLinks();
|
||||
+ // CraftBukkit start
|
||||
+ CraftServerLinks wrapper = new CraftServerLinks(serverlinks);
|
||||
+ PlayerLinksSendEvent event = new PlayerLinksSendEvent(player.getBukkitEntity(), wrapper);
|
||||
+ player.getBukkitEntity().getServer().getPluginManager().callEvent(event);
|
||||
+ serverlinks = wrapper.getServerLinks();
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (!serverlinks.isEmpty()) {
|
||||
this.send(new ClientboundServerLinksPacket(serverlinks.untrust()));
|
||||
@@ -143,14 +156,14 @@
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@
|
||||
+ entityplayer.loadGameTypes((NBTTagCompound) optional.orElse(null)); // CraftBukkit - decompile error
|
||||
PlayerConnection playerconnection = new PlayerConnection(this.server, networkmanager, entityplayer, commonlistenercookie);
|
||||
|
||||
networkmanager.setupInboundProtocol(GameProtocols.SERVERBOUND.bind(RegistryFriendlyByteBuf.decorator(this.server.registryAccess())), playerconnection);
|
||||
networkmanager.setupInboundProtocol(GameProtocols.SERVERBOUND_TEMPLATE.bind(RegistryFriendlyByteBuf.decorator(this.server.registryAccess())), playerconnection);
|
||||
@@ -194,6 +237,7 @@
|
||||
boolean flag2 = gamerules.getBoolean(GameRules.RULE_LIMITED_CRAFTING);
|
||||
|
||||
@@ -148,7 +148,7 @@
|
||||
playerconnection.teleport(entityplayer.getX(), entityplayer.getY(), entityplayer.getZ(), entityplayer.getYRot(), entityplayer.getXRot());
|
||||
ServerPing serverping = this.server.getStatus();
|
||||
|
||||
@@ -219,13 +265,64 @@
|
||||
@@ -219,18 +265,70 @@
|
||||
entityplayer.sendServerStatus(serverping);
|
||||
}
|
||||
|
||||
@@ -214,11 +214,7 @@
|
||||
+
|
||||
+ worldserver1 = entityplayer.serverLevel(); // CraftBukkit - Update in case join event changed it
|
||||
+ // CraftBukkit end
|
||||
Iterator iterator = entityplayer.getActiveEffects().iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
@@ -236,8 +333,9 @@
|
||||
|
||||
this.sendActivePlayerEffects(entityplayer);
|
||||
if (optional.isPresent() && ((NBTTagCompound) optional.get()).contains("RootVehicle", 10)) {
|
||||
NBTTagCompound nbttagcompound = ((NBTTagCompound) optional.get()).getCompound("RootVehicle");
|
||||
+ WorldServer finalWorldServer = worldserver1; // CraftBukkit - decompile error
|
||||
@@ -228,16 +224,16 @@
|
||||
});
|
||||
|
||||
if (entity != null) {
|
||||
@@ -268,18 +366,20 @@
|
||||
@@ -261,18 +359,20 @@
|
||||
|
||||
if (!entityplayer.isPassenger()) {
|
||||
PlayerList.LOGGER.warn("Couldn't reattach entity to player");
|
||||
- entity.discard();
|
||||
+ entity.discard(null); // CraftBukkit - add Bukkit remove cause
|
||||
iterator1 = entity.getIndirectPassengers().iterator();
|
||||
iterator = entity.getIndirectPassengers().iterator();
|
||||
|
||||
while (iterator1.hasNext()) {
|
||||
entity1 = (Entity) iterator1.next();
|
||||
while (iterator.hasNext()) {
|
||||
entity1 = (Entity) iterator.next();
|
||||
- entity1.discard();
|
||||
+ entity1.discard(null); // CraftBukkit - add Bukkit remove cause
|
||||
}
|
||||
@@ -251,7 +247,7 @@
|
||||
}
|
||||
|
||||
public void updateEntireScoreboard(ScoreboardServer scoreboardserver, EntityPlayer entityplayer) {
|
||||
@@ -316,30 +416,31 @@
|
||||
@@ -309,30 +409,31 @@
|
||||
}
|
||||
|
||||
public void addWorldborderListener(WorldServer worldserver) {
|
||||
@@ -288,7 +284,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -366,14 +467,15 @@
|
||||
@@ -359,14 +460,15 @@
|
||||
}
|
||||
|
||||
protected void save(EntityPlayer entityplayer) {
|
||||
@@ -306,7 +302,7 @@
|
||||
|
||||
if (advancementdataplayer != null) {
|
||||
advancementdataplayer.save();
|
||||
@@ -381,10 +483,24 @@
|
||||
@@ -374,10 +476,24 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -332,7 +328,7 @@
|
||||
this.save(entityplayer);
|
||||
if (entityplayer.isPassenger()) {
|
||||
Entity entity = entityplayer.getRootVehicle();
|
||||
@@ -393,7 +509,7 @@
|
||||
@@ -386,7 +502,7 @@
|
||||
PlayerList.LOGGER.debug("Removing player mount");
|
||||
entityplayer.stopRiding();
|
||||
entity.getPassengersAndSelf().forEach((entity1) -> {
|
||||
@@ -341,7 +337,7 @@
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -408,17 +524,66 @@
|
||||
@@ -401,17 +517,66 @@
|
||||
|
||||
if (entityplayer1 == entityplayer) {
|
||||
this.playersByUUID.remove(uuid);
|
||||
@@ -413,7 +409,7 @@
|
||||
if (this.bans.isBanned(gameprofile)) {
|
||||
GameProfileBanEntry gameprofilebanentry = (GameProfileBanEntry) this.bans.get(gameprofile);
|
||||
|
||||
@@ -427,9 +592,11 @@
|
||||
@@ -420,9 +585,11 @@
|
||||
ichatmutablecomponent.append((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.banned.expiration", PlayerList.BAN_DATE_FORMAT.format(gameprofilebanentry.getExpires())));
|
||||
}
|
||||
|
||||
@@ -427,7 +423,7 @@
|
||||
} else if (this.ipBans.isBanned(socketaddress)) {
|
||||
IpBanEntry ipbanentry = this.ipBans.get(socketaddress);
|
||||
|
||||
@@ -438,17 +605,32 @@
|
||||
@@ -431,17 +598,32 @@
|
||||
ichatmutablecomponent.append((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.banned_ip.expiration", PlayerList.BAN_DATE_FORMAT.format(ipbanentry.getExpires())));
|
||||
}
|
||||
|
||||
@@ -465,7 +461,7 @@
|
||||
UUID uuid = gameprofile.getId();
|
||||
Set<EntityPlayer> set = Sets.newIdentityHashSet();
|
||||
Iterator iterator = this.players.iterator();
|
||||
@@ -476,14 +658,24 @@
|
||||
@@ -469,22 +651,41 @@
|
||||
}
|
||||
|
||||
return !set.isEmpty();
|
||||
@@ -474,142 +470,96 @@
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
- public EntityPlayer respawn(EntityPlayer entityplayer, boolean flag) {
|
||||
- public EntityPlayer respawn(EntityPlayer entityplayer, boolean flag, Entity.RemovalReason entity_removalreason) {
|
||||
+ // CraftBukkit start
|
||||
+ public EntityPlayer respawn(EntityPlayer entityplayer, boolean flag, RespawnReason reason) {
|
||||
+ return this.respawn(entityplayer, this.server.getLevel(entityplayer.getRespawnDimension()), flag, null, true, reason);
|
||||
+ public EntityPlayer respawn(EntityPlayer entityplayer, boolean flag, Entity.RemovalReason entity_removalreason, RespawnReason reason) {
|
||||
+ return this.respawn(entityplayer, flag, entity_removalreason, reason, null);
|
||||
+ }
|
||||
+
|
||||
+ public EntityPlayer respawn(EntityPlayer entityplayer, WorldServer worldserver, boolean flag, Location location, boolean avoidSuffocation, RespawnReason reason) {
|
||||
+ public EntityPlayer respawn(EntityPlayer entityplayer, boolean flag, Entity.RemovalReason entity_removalreason, RespawnReason reason, Location location) {
|
||||
+ entityplayer.stopRiding(); // CraftBukkit
|
||||
this.players.remove(entityplayer);
|
||||
entityplayer.serverLevel().removePlayerImmediately(entityplayer, Entity.RemovalReason.DISCARDED);
|
||||
BlockPosition blockposition = entityplayer.getRespawnPosition();
|
||||
float f = entityplayer.getRespawnAngle();
|
||||
boolean flag1 = entityplayer.isRespawnForced();
|
||||
entityplayer.serverLevel().removePlayerImmediately(entityplayer, entity_removalreason);
|
||||
+ /* CraftBukkit start
|
||||
WorldServer worldserver = this.server.getLevel(entityplayer.getRespawnDimension());
|
||||
Optional optional;
|
||||
|
||||
@@ -495,6 +687,11 @@
|
||||
|
||||
WorldServer worldserver1 = worldserver != null && optional.isPresent() ? worldserver : this.server.overworld();
|
||||
EntityPlayer entityplayer1 = new EntityPlayer(this.server, worldserver1, entityplayer.getGameProfile(), entityplayer.clientInformation());
|
||||
DimensionTransition dimensiontransition = entityplayer.findRespawnPositionAndUseSpawnBlock(flag, DimensionTransition.DO_NOTHING);
|
||||
WorldServer worldserver = dimensiontransition.newLevel();
|
||||
EntityPlayer entityplayer1 = new EntityPlayer(this.server, worldserver, entityplayer.getGameProfile(), entityplayer.clientInformation());
|
||||
+ // */
|
||||
+ EntityPlayer entityplayer1 = entityplayer;
|
||||
+ org.bukkit.World fromWorld = entityplayer.getBukkitEntity().getWorld();
|
||||
+ World fromWorld = entityplayer.level();
|
||||
+ entityplayer.wonGame = false;
|
||||
+ // CraftBukkit end
|
||||
|
||||
entityplayer1.connection = entityplayer.connection;
|
||||
entityplayer1.restoreFrom(entityplayer, flag);
|
||||
@@ -510,28 +707,66 @@
|
||||
entityplayer1.setId(entityplayer.getId());
|
||||
entityplayer1.setMainArm(entityplayer.getMainArm());
|
||||
+ // CraftBukkit - not required, just copies old location into reused entity
|
||||
+ /*
|
||||
if (!dimensiontransition.missingRespawnBlock()) {
|
||||
entityplayer1.copyRespawnPosition(entityplayer);
|
||||
}
|
||||
+ */
|
||||
+ // CraftBukkit end
|
||||
|
||||
boolean flag2 = false;
|
||||
Iterator iterator = entityplayer.getTags().iterator();
|
||||
|
||||
@@ -494,11 +695,26 @@
|
||||
entityplayer1.addTag(s);
|
||||
}
|
||||
|
||||
- if (optional.isPresent()) {
|
||||
- IBlockData iblockdata = worldserver1.getBlockState(blockposition);
|
||||
- boolean flag3 = iblockdata.is(Blocks.RESPAWN_ANCHOR);
|
||||
- Vec3D vec3d = (Vec3D) optional.get();
|
||||
- float f1;
|
||||
+ // CraftBukkit start - fire PlayerRespawnEvent
|
||||
+ DimensionTransition dimensiontransition;
|
||||
+ if (location == null) {
|
||||
+ boolean isBedSpawn = false;
|
||||
+ WorldServer worldserver1 = this.server.getLevel(entityplayer.getRespawnDimension());
|
||||
+ if (worldserver1 != null) {
|
||||
+ Optional optional;
|
||||
|
||||
- if (!iblockdata.is(TagsBlock.BEDS) && !flag3) {
|
||||
- f1 = f;
|
||||
- } else {
|
||||
- Vec3D vec3d1 = Vec3D.atBottomCenterOf(blockposition).subtract(vec3d).normalize();
|
||||
+ if (blockposition != null) {
|
||||
+ optional = EntityHuman.findRespawnPositionAndUseSpawnBlock(worldserver1, blockposition, f, flag1, flag);
|
||||
+ } else {
|
||||
+ optional = Optional.empty();
|
||||
+ }
|
||||
|
||||
- f1 = (float) MathHelper.wrapDegrees(MathHelper.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D);
|
||||
+ if (optional.isPresent()) {
|
||||
+ IBlockData iblockdata = worldserver1.getBlockState(blockposition);
|
||||
+ boolean flag3 = iblockdata.is(Blocks.RESPAWN_ANCHOR);
|
||||
+ Vec3D vec3d = (Vec3D) optional.get();
|
||||
+ float f1;
|
||||
+ dimensiontransition = entityplayer.findRespawnPositionAndUseSpawnBlock(flag, DimensionTransition.DO_NOTHING, reason);
|
||||
+
|
||||
+ if (!iblockdata.is(TagsBlock.BEDS) && !flag3) {
|
||||
+ f1 = f;
|
||||
+ } else {
|
||||
+ Vec3D vec3d1 = Vec3D.atBottomCenterOf(blockposition).subtract(vec3d).normalize();
|
||||
+
|
||||
+ f1 = (float) MathHelper.wrapDegrees(MathHelper.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D);
|
||||
+ }
|
||||
+
|
||||
+ // entityplayer1.setRespawnPosition(worldserver1.dimension(), blockposition, f, flag1, false); // CraftBukkit - not required, just copies old location into reused entity
|
||||
+ flag2 = !flag && flag3;
|
||||
+ isBedSpawn = true;
|
||||
+ location = CraftLocation.toBukkit(vec3d, worldserver1.getWorld(), f1, 0.0F);
|
||||
+ } else if (blockposition != null) {
|
||||
+ entityplayer1.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.NO_RESPAWN_BLOCK_AVAILABLE, 0.0F));
|
||||
+ entityplayer1.setRespawnPosition(null, null, 0f, false, false, PlayerSpawnChangeEvent.Cause.RESET); // CraftBukkit - SPIGOT-5988: Clear respawn location when obstructed
|
||||
+ }
|
||||
}
|
||||
|
||||
- entityplayer1.moveTo(vec3d.x, vec3d.y, vec3d.z, f1, 0.0F);
|
||||
- entityplayer1.setRespawnPosition(worldserver1.dimension(), blockposition, f, flag1, false);
|
||||
- flag2 = !flag && flag3;
|
||||
- } else if (blockposition != null) {
|
||||
- entityplayer1.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.NO_RESPAWN_BLOCK_AVAILABLE, 0.0F));
|
||||
+ if (location == null) {
|
||||
+ worldserver1 = this.server.getLevel(World.OVERWORLD);
|
||||
+ blockposition = entityplayer1.getSpawnPoint(worldserver1);
|
||||
+ location = CraftLocation.toBukkit(blockposition, worldserver1.getWorld()).add(0.5F, 0.1F, 0.5F);
|
||||
+ }
|
||||
+
|
||||
+ Player respawnPlayer = entityplayer1.getBukkitEntity();
|
||||
+ PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn && !flag2, flag2, reason);
|
||||
+ cserver.getPluginManager().callEvent(respawnEvent);
|
||||
+
|
||||
+ location = respawnEvent.getRespawnLocation();
|
||||
+ if (!flag) entityplayer.reset(); // SPIGOT-4785
|
||||
+ } else {
|
||||
+ location.setWorld(worldserver.getWorld());
|
||||
}
|
||||
+ WorldServer worldserver1 = ((CraftWorld) location.getWorld()).getHandle();
|
||||
+ entityplayer1.spawnIn(worldserver1);
|
||||
+ dimensiontransition = new DimensionTransition(((CraftWorld) location.getWorld()).getHandle(), CraftLocation.toVec3D(location), Vec3D.ZERO, location.getYaw(), location.getPitch(), DimensionTransition.DO_NOTHING);
|
||||
+ }
|
||||
+ WorldServer worldserver = dimensiontransition.newLevel();
|
||||
+ entityplayer1.spawnIn(worldserver);
|
||||
+ entityplayer1.unsetRemoved();
|
||||
+ entityplayer1.setShiftKeyDown(false);
|
||||
+ entityplayer1.forceSetPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
||||
Vec3D vec3d = dimensiontransition.pos();
|
||||
|
||||
- while (!worldserver1.noCollision((Entity) entityplayer1) && entityplayer1.getY() < (double) worldserver1.getMaxBuildHeight()) {
|
||||
+ while (avoidSuffocation && !worldserver1.noCollision((Entity) entityplayer1) && entityplayer1.getY() < (double) worldserver1.getMaxBuildHeight()) {
|
||||
+ // CraftBukkit end
|
||||
entityplayer1.setPos(entityplayer1.getX(), entityplayer1.getY() + 1.0D, entityplayer1.getZ());
|
||||
- entityplayer1.moveTo(vec3d.x, vec3d.y, vec3d.z, dimensiontransition.yRot(), dimensiontransition.xRot());
|
||||
+ entityplayer1.forceSetPositionRotation(vec3d.x, vec3d.y, vec3d.z, dimensiontransition.yRot(), dimensiontransition.xRot());
|
||||
+ // CraftBukkit end
|
||||
if (dimensiontransition.missingRespawnBlock()) {
|
||||
entityplayer1.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.NO_RESPAWN_BLOCK_AVAILABLE, 0.0F));
|
||||
+ entityplayer1.setRespawnPosition(null, null, 0f, false, false, PlayerSpawnChangeEvent.Cause.RESET); // CraftBukkit - SPIGOT-5988: Clear respawn location when obstructed
|
||||
}
|
||||
|
||||
@@ -540,21 +775,43 @@
|
||||
WorldData worlddata = worldserver2.getLevelData();
|
||||
int i = flag ? 1 : 0;
|
||||
@@ -506,17 +722,19 @@
|
||||
WorldData worlddata = worldserver1.getLevelData();
|
||||
|
||||
entityplayer1.connection.send(new PacketPlayOutRespawn(entityplayer1.createCommonSpawnInfo(worldserver2), (byte) i));
|
||||
entityplayer1.connection.send(new PacketPlayOutRespawn(entityplayer1.createCommonSpawnInfo(worldserver1), (byte) i));
|
||||
- entityplayer1.connection.teleport(entityplayer1.getX(), entityplayer1.getY(), entityplayer1.getZ(), entityplayer1.getYRot(), entityplayer1.getXRot());
|
||||
+ entityplayer1.connection.teleport(CraftLocation.toBukkit(entityplayer1.position(), worldserver2.getWorld(), entityplayer1.getYRot(), entityplayer1.getXRot())); // CraftBukkit
|
||||
entityplayer1.connection.send(new PacketPlayOutSpawnPosition(worldserver1.getSharedSpawnPos(), worldserver1.getSharedSpawnAngle()));
|
||||
+ entityplayer1.connection.teleport(CraftLocation.toBukkit(entityplayer1.position(), worldserver1.getWorld(), entityplayer1.getYRot(), entityplayer1.getXRot())); // CraftBukkit
|
||||
entityplayer1.connection.send(new PacketPlayOutSpawnPosition(worldserver.getSharedSpawnPos(), worldserver.getSharedSpawnAngle()));
|
||||
entityplayer1.connection.send(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked()));
|
||||
entityplayer1.connection.send(new PacketPlayOutExperience(entityplayer1.experienceProgress, entityplayer1.totalExperience, entityplayer1.experienceLevel));
|
||||
this.sendLevelInfo(entityplayer1, worldserver1);
|
||||
this.sendActivePlayerEffects(entityplayer1);
|
||||
this.sendLevelInfo(entityplayer1, worldserver);
|
||||
this.sendPlayerPermissionLevel(entityplayer1);
|
||||
- worldserver1.addRespawnedPlayer(entityplayer1);
|
||||
- worldserver.addRespawnedPlayer(entityplayer1);
|
||||
- this.players.add(entityplayer1);
|
||||
- this.playersByUUID.put(entityplayer1.getUUID(), entityplayer1);
|
||||
- entityplayer1.initInventoryMenu();
|
||||
+ if (!entityplayer.connection.isDisconnected()) {
|
||||
+ worldserver1.addRespawnedPlayer(entityplayer1);
|
||||
+ worldserver.addRespawnedPlayer(entityplayer1);
|
||||
+ this.players.add(entityplayer1);
|
||||
+ this.playersByUUID.put(entityplayer1.getUUID(), entityplayer1);
|
||||
+ }
|
||||
+ // 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, worldserver1.getRandom().nextLong()));
|
||||
if (!flag) {
|
||||
BlockPosition blockposition = BlockPosition.containing(dimensiontransition.pos());
|
||||
@@ -526,6 +744,27 @@
|
||||
entityplayer1.connection.send(new PacketPlayOutNamedSoundEffect(SoundEffects.RESPAWN_ANCHOR_DEPLETE, SoundCategory.BLOCKS, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), 1.0F, 1.0F, worldserver.getRandom().nextLong()));
|
||||
}
|
||||
}
|
||||
+ // Added from changeDimension
|
||||
+ sendAllPlayerInfo(entityplayer); // Update health, etc...
|
||||
@@ -619,23 +569,23 @@
|
||||
+ }
|
||||
+
|
||||
+ // Fire advancement trigger
|
||||
+ entityplayer.triggerDimensionChangeTriggers(((CraftWorld) fromWorld).getHandle());
|
||||
+ entityplayer.triggerDimensionChangeTriggers(worldserver);
|
||||
+
|
||||
+ // Don't fire on respawn
|
||||
+ if (fromWorld != location.getWorld()) {
|
||||
+ PlayerChangedWorldEvent event = new PlayerChangedWorldEvent(entityplayer.getBukkitEntity(), fromWorld);
|
||||
+ if (fromWorld != worldserver) {
|
||||
+ PlayerChangedWorldEvent event = new PlayerChangedWorldEvent(entityplayer.getBukkitEntity(), fromWorld.getWorld());
|
||||
+ server.server.getPluginManager().callEvent(event);
|
||||
+ }
|
||||
|
||||
+
|
||||
+ // Save player file again if they were disconnected
|
||||
+ if (entityplayer.connection.isDisconnected()) {
|
||||
+ this.save(entityplayer);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
return entityplayer1;
|
||||
}
|
||||
|
||||
@@ -567,7 +824,18 @@
|
||||
@@ -554,7 +793,18 @@
|
||||
|
||||
public void tick() {
|
||||
if (++this.sendAllPlayerInfoIn > 600) {
|
||||
@@ -655,7 +605,7 @@
|
||||
this.sendAllPlayerInfoIn = 0;
|
||||
}
|
||||
|
||||
@@ -584,6 +852,25 @@
|
||||
@@ -571,6 +821,25 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -681,7 +631,7 @@
|
||||
public void broadcastAll(Packet<?> packet, ResourceKey<World> resourcekey) {
|
||||
Iterator iterator = this.players.iterator();
|
||||
|
||||
@@ -662,7 +949,7 @@
|
||||
@@ -649,7 +918,7 @@
|
||||
}
|
||||
|
||||
public void deop(GameProfile gameprofile) {
|
||||
@@ -690,7 +640,7 @@
|
||||
EntityPlayer entityplayer = this.getPlayer(gameprofile.getId());
|
||||
|
||||
if (entityplayer != null) {
|
||||
@@ -686,6 +973,7 @@
|
||||
@@ -673,6 +942,7 @@
|
||||
entityplayer.connection.send(new PacketPlayOutEntityStatus(entityplayer, b0));
|
||||
}
|
||||
|
||||
@@ -698,7 +648,7 @@
|
||||
this.server.getCommands().sendCommands(entityplayer);
|
||||
}
|
||||
|
||||
@@ -716,6 +1004,12 @@
|
||||
@@ -703,6 +973,12 @@
|
||||
for (int i = 0; i < this.players.size(); ++i) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) this.players.get(i);
|
||||
|
||||
@@ -711,7 +661,7 @@
|
||||
if (entityplayer != entityhuman && entityplayer.level().dimension() == resourcekey) {
|
||||
double d4 = d0 - entityplayer.getX();
|
||||
double d5 = d1 - entityplayer.getY();
|
||||
@@ -755,15 +1049,19 @@
|
||||
@@ -742,15 +1018,19 @@
|
||||
public void reloadWhiteList() {}
|
||||
|
||||
public void sendLevelInfo(EntityPlayer entityplayer, WorldServer worldserver) {
|
||||
@@ -735,7 +685,7 @@
|
||||
}
|
||||
|
||||
entityplayer.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.LEVEL_CHUNKS_LOAD_START, 0.0F));
|
||||
@@ -772,8 +1070,16 @@
|
||||
@@ -759,8 +1039,16 @@
|
||||
|
||||
public void sendAllPlayerInfo(EntityPlayer entityplayer) {
|
||||
entityplayer.inventoryMenu.sendAllDataToRemote();
|
||||
@@ -753,15 +703,15 @@
|
||||
}
|
||||
|
||||
public int getPlayerCount() {
|
||||
@@ -829,12 +1135,22 @@
|
||||
@@ -816,12 +1104,22 @@
|
||||
}
|
||||
|
||||
public void removeAll() {
|
||||
- for (int i = 0; i < this.players.size(); ++i) {
|
||||
- ((EntityPlayer) this.players.get(i)).connection.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.server_shutdown"));
|
||||
- ((EntityPlayer) this.players.get(i)).connection.disconnect((IChatBaseComponent) 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
|
||||
+ player.connection.disconnect(CraftChatMessage.fromStringOrEmpty(this.server.server.getShutdownMessage())); // CraftBukkit - add custom shutdown message
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
|
||||
@@ -778,7 +728,7 @@
|
||||
public void broadcastSystemMessage(IChatBaseComponent ichatbasecomponent, boolean flag) {
|
||||
this.broadcastSystemMessage(ichatbasecomponent, (entityplayer) -> {
|
||||
return ichatbasecomponent;
|
||||
@@ -892,16 +1208,23 @@
|
||||
@@ -879,16 +1177,23 @@
|
||||
return playerchatmessage.hasSignature() && !playerchatmessage.hasExpiredServer(Instant.now());
|
||||
}
|
||||
|
||||
@@ -806,7 +756,7 @@
|
||||
Path path = file2.toPath();
|
||||
|
||||
if (FileUtils.isPathNormalized(path) && FileUtils.isPathPortable(path) && path.startsWith(file.getPath()) && file2.isFile()) {
|
||||
@@ -910,7 +1233,7 @@
|
||||
@@ -897,7 +1202,7 @@
|
||||
}
|
||||
|
||||
serverstatisticmanager = new ServerStatisticManager(this.server, file1);
|
||||
@@ -815,7 +765,7 @@
|
||||
}
|
||||
|
||||
return serverstatisticmanager;
|
||||
@@ -918,13 +1241,13 @@
|
||||
@@ -905,13 +1210,13 @@
|
||||
|
||||
public AdvancementDataPlayer getPlayerAdvancements(EntityPlayer entityplayer) {
|
||||
UUID uuid = entityplayer.getUUID();
|
||||
@@ -831,7 +781,7 @@
|
||||
}
|
||||
|
||||
advancementdataplayer.setPlayer(entityplayer);
|
||||
@@ -975,13 +1298,20 @@
|
||||
@@ -962,13 +1267,20 @@
|
||||
}
|
||||
|
||||
public void reloadResources() {
|
||||
|
||||
Reference in New Issue
Block a user