Merge some packet sendings w/ Better PlayerHandshakeEvent Impl
This commit is contained in:
@@ -319,10 +319,11 @@ public abstract class Container {
|
||||
slot2.f();
|
||||
// CraftBukkit start - Make sure the client has the right slot contents
|
||||
if (entityhuman instanceof EntityPlayer && slot2.getMaxStackSize() != 64) {
|
||||
((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutSetSlot(this.windowId, slot2.rawSlotIndex, slot2.getItem()));
|
||||
boolean crafting = this.getBukkitView().getType() == InventoryType.WORKBENCH || this.getBukkitView().getType() == InventoryType.CRAFTING; // Akarin
|
||||
if (!crafting) ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutSetSlot(this.windowId, slot2.rawSlotIndex, slot2.getItem())); // Akarin
|
||||
// Updating a crafting inventory makes the client reset the result slot, have to send it again
|
||||
if (this.getBukkitView().getType() == InventoryType.WORKBENCH || this.getBukkitView().getType() == InventoryType.CRAFTING) {
|
||||
((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutSetSlot(this.windowId, 0, this.getSlot(0).getItem()));
|
||||
if (crafting) { // Akarin
|
||||
((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutSetSlot(this.windowId, slot2.rawSlotIndex, slot2.getItem()), new PacketPlayOutSetSlot(this.windowId, 0, this.getSlot(0).getItem())); // Akarin
|
||||
}
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
@@ -1010,8 +1010,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
}
|
||||
|
||||
public void a(Container container, NonNullList<ItemStack> nonnulllist) {
|
||||
this.playerConnection.sendPacket(new PacketPlayOutWindowItems(container.windowId, nonnulllist));
|
||||
this.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.inventory.getCarried()));
|
||||
this.playerConnection.sendPacket(new PacketPlayOutWindowItems(container.windowId, nonnulllist), new PacketPlayOutSetSlot(-1, -1, this.inventory.getCarried())); // Akarin
|
||||
// CraftBukkit start - Send a Set Slot to update the crafting result slot
|
||||
if (java.util.EnumSet.of(InventoryType.CRAFTING,InventoryType.WORKBENCH).contains(container.getBukkitView().getType())) {
|
||||
this.playerConnection.sendPacket(new PacketPlayOutSetSlot(container.windowId, 0, container.getSlot(0).getItem()));
|
||||
|
||||
@@ -88,15 +88,15 @@ public class HandshakeListener implements PacketHandshakingInListener {
|
||||
return;
|
||||
}
|
||||
|
||||
packethandshakinginsetprotocol.hostname = event.getServerHostname();
|
||||
this.b.socketAddress = new java.net.InetSocketAddress(event.getSocketAddressHostname(), ((java.net.InetSocketAddress) this.b.getSocketAddress()).getPort());
|
||||
if (event.getServerHostname() != null) packethandshakinginsetprotocol.hostname = event.getServerHostname(); // Akarin - add null check
|
||||
if (event.getSocketAddressHostname() != null) this.b.socketAddress = new java.net.InetSocketAddress(event.getSocketAddressHostname(), ((java.net.InetSocketAddress) this.b.getSocketAddress()).getPort()); // Akarin - add null check
|
||||
this.b.spoofedUUID = event.getUniqueId();
|
||||
this.b.spoofedProfile = gson.fromJson(event.getPropertiesJson(), com.mojang.authlib.properties.Property[].class);
|
||||
handledByEvent = true; // Hooray, we did it!
|
||||
}
|
||||
}
|
||||
// Don't try and handle default logic if it's been handled by the event.
|
||||
if (!handledByEvent && proxyLogicEnabled) {
|
||||
if (!handledByEvent && org.spigotmc.SpigotConfig.bungee) { // Akarin - recheck for plugin hacking
|
||||
// Paper end
|
||||
// Spigot Start
|
||||
//if (org.spigotmc.SpigotConfig.bungee) { // Paper - comment out, we check above!
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
import com.google.common.collect.Queues;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
@@ -18,7 +19,7 @@ import io.netty.util.concurrent.Future;
|
||||
import io.netty.util.concurrent.GenericFutureListener;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.primitives.Doubles;
|
||||
import com.google.common.primitives.Floats;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
@@ -8,6 +9,8 @@ import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.suggestion.Suggestions;
|
||||
import io.netty.util.concurrent.Future;
|
||||
import io.netty.util.concurrent.GenericFutureListener;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
@@ -1493,6 +1496,24 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
||||
public void sendPacket(Packet<?> packet) {
|
||||
this.a(packet, (GenericFutureListener) null);
|
||||
}
|
||||
// Akarin start
|
||||
public void sendPacket(Packet<?>... packets) {
|
||||
if (this.processedDisconnect)
|
||||
return;
|
||||
|
||||
try {
|
||||
this.networkManager.sendPacket(packets);
|
||||
} catch (Throwable throwable) {
|
||||
CrashReport crashreport = CrashReport.a(throwable, "Sending packet");
|
||||
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Packet being sent");
|
||||
|
||||
crashreportsystemdetails.a("Packet classes", () -> {
|
||||
return Lists.newArrayList(packets).toString();
|
||||
});
|
||||
throw new ReportedException(crashreport);
|
||||
}
|
||||
}
|
||||
// Akarin end
|
||||
|
||||
public void a(Packet<?> packet, @Nullable GenericFutureListener<? extends Future<? super Void>> genericfuturelistener) {
|
||||
if (packet instanceof PacketPlayOutChat) {
|
||||
|
||||
@@ -156,13 +156,16 @@ public abstract class PlayerList {
|
||||
|
||||
playerconnection.sendPacket(new PacketPlayOutLogin(entityplayer.getId(), entityplayer.playerInteractManager.getGameMode(), worlddata.isHardcore(), worldserver.worldProvider.getDimensionManager(), worldserver.getDifficulty(), this.getMaxPlayers(), worlddata.getType(), worldserver.getGameRules().getBoolean("reducedDebugInfo")));
|
||||
entityplayer.getBukkitEntity().sendSupportedChannels(); // CraftBukkit
|
||||
playerconnection.sendPacket(new PacketPlayOutCustomPayload(PacketPlayOutCustomPayload.b, (new PacketDataSerializer(Unpooled.buffer())).a(this.getServer().getServerModName())));
|
||||
playerconnection.sendPacket(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked()));
|
||||
playerconnection.sendPacket(new PacketPlayOutAbilities(entityplayer.abilities));
|
||||
playerconnection.sendPacket(new PacketPlayOutHeldItemSlot(entityplayer.inventory.itemInHandIndex));
|
||||
playerconnection.sendPacket(new PacketPlayOutRecipeUpdate(this.server.getCraftingManager().b()));
|
||||
playerconnection.sendPacket(new PacketPlayOutTags(this.server.getTagRegistry()));
|
||||
playerconnection.sendPacket(new PacketPlayOutEntityStatus(entityplayer, (byte) (worldserver.getGameRules().getBoolean("reducedDebugInfo") ? 22 : 23))); // Paper - fix this rule not being initialized on the client
|
||||
// Akarin start
|
||||
playerconnection.sendPacket(
|
||||
new PacketPlayOutCustomPayload(PacketPlayOutCustomPayload.b, (new PacketDataSerializer(Unpooled.buffer())).a(this.getServer().getServerModName())),
|
||||
new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked()),
|
||||
new PacketPlayOutAbilities(entityplayer.abilities),
|
||||
new PacketPlayOutHeldItemSlot(entityplayer.inventory.itemInHandIndex),
|
||||
new PacketPlayOutRecipeUpdate(this.server.getCraftingManager().b()),
|
||||
new PacketPlayOutTags(this.server.getTagRegistry()),
|
||||
new PacketPlayOutEntityStatus(entityplayer, (byte) (worldserver.getGameRules().getBoolean("reducedDebugInfo") ? 22 : 23))); // Paper - fix this rule not being initialized on the client
|
||||
// Akarin end
|
||||
this.f(entityplayer);
|
||||
entityplayer.getStatisticManager().c();
|
||||
entityplayer.B().a(entityplayer);
|
||||
@@ -720,8 +723,7 @@ public abstract class PlayerList {
|
||||
entityplayer1.setSneaking(false);
|
||||
blockposition1 = worldserver.getSpawn();
|
||||
// entityplayer1.playerConnection.a(entityplayer1.locX, entityplayer1.locY, entityplayer1.locZ, entityplayer1.yaw, entityplayer1.pitch);
|
||||
entityplayer1.playerConnection.sendPacket(new PacketPlayOutSpawnPosition(blockposition1));
|
||||
entityplayer1.playerConnection.sendPacket(new PacketPlayOutExperience(entityplayer1.exp, entityplayer1.expTotal, entityplayer1.expLevel));
|
||||
entityplayer1.playerConnection.sendPacket(new PacketPlayOutSpawnPosition(blockposition1), new PacketPlayOutExperience(entityplayer1.exp, entityplayer1.expTotal, entityplayer1.expLevel)); // Akarin
|
||||
this.b(entityplayer1, worldserver);
|
||||
this.f(entityplayer1);
|
||||
if (!entityplayer.playerConnection.isDisconnected()) {
|
||||
@@ -1284,11 +1286,13 @@ public abstract class PlayerList {
|
||||
public void b(EntityPlayer entityplayer, WorldServer worldserver) {
|
||||
WorldBorder worldborder = entityplayer.world.getWorldBorder(); // CraftBukkit
|
||||
|
||||
entityplayer.playerConnection.sendPacket(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.INITIALIZE));
|
||||
entityplayer.playerConnection.sendPacket(new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean("doDaylightCycle")));
|
||||
// Akarin start
|
||||
BlockPosition blockposition = worldserver.getSpawn();
|
||||
|
||||
entityplayer.playerConnection.sendPacket(new PacketPlayOutSpawnPosition(blockposition));
|
||||
entityplayer.playerConnection.sendPacket(
|
||||
new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.INITIALIZE),
|
||||
new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean("doDaylightCycle")),
|
||||
new PacketPlayOutSpawnPosition(blockposition));
|
||||
// Akarin end
|
||||
if (worldserver.isRaining()) {
|
||||
// CraftBukkit start - handle player weather
|
||||
// entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(1, 0.0F));
|
||||
@@ -1305,11 +1309,12 @@ public abstract class PlayerList {
|
||||
entityplayer.updateInventory(entityplayer.defaultContainer);
|
||||
// entityplayer.triggerHealthUpdate();
|
||||
entityplayer.getBukkitEntity().updateScaledHealth(); // CraftBukkit - Update scaled health on respawn and worldchange
|
||||
entityplayer.playerConnection.sendPacket(new PacketPlayOutHeldItemSlot(entityplayer.inventory.itemInHandIndex));
|
||||
// CraftBukkit start - from GameRules
|
||||
// Akarin start
|
||||
int i = entityplayer.world.getGameRules().get("reducedDebugInfo").b() ? 22 : 23;
|
||||
entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityStatus(entityplayer, (byte) i));
|
||||
// CraftBukkit end
|
||||
entityplayer.playerConnection.sendPacket(
|
||||
new PacketPlayOutHeldItemSlot(entityplayer.inventory.itemInHandIndex),
|
||||
new PacketPlayOutEntityStatus(entityplayer, (byte) i));
|
||||
// Akarin end
|
||||
}
|
||||
|
||||
public int getPlayerCount() {
|
||||
|
||||
Reference in New Issue
Block a user