2015-05-25 12:37:24 +02:00
|
|
|
--- a/net/minecraft/server/PlayerConnection.java
|
|
|
|
+++ b/net/minecraft/server/PlayerConnection.java
|
2016-02-29 22:32:46 +01:00
|
|
|
@@ -3,7 +3,6 @@
|
|
|
|
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;
|
|
|
|
import io.netty.buffer.Unpooled;
|
|
|
|
import io.netty.util.concurrent.Future;
|
|
|
|
import io.netty.util.concurrent.GenericFutureListener;
|
2016-03-04 05:24:51 +01:00
|
|
|
@@ -18,6 +17,48 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
import org.apache.logging.log4j.LogManager;
|
|
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
|
|
|
|
+// CraftBukkit start
|
2016-02-29 22:32:46 +01:00
|
|
|
+import java.util.HashSet;
|
2014-11-25 22:32:16 +01:00
|
|
|
+import java.util.concurrent.ExecutionException;
|
|
|
|
+import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
|
2016-02-29 22:32:46 +01:00
|
|
|
+import org.bukkit.Location;
|
2014-11-25 22:32:16 +01:00
|
|
|
+import org.bukkit.craftbukkit.entity.CraftPlayer;
|
|
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
|
|
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
|
|
|
|
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
|
|
|
+import org.bukkit.craftbukkit.util.CraftChatMessage;
|
|
|
|
+import org.bukkit.craftbukkit.util.LazyPlayerSet;
|
|
|
|
+import org.bukkit.craftbukkit.util.Waitable;
|
|
|
|
+import org.bukkit.entity.Player;
|
|
|
|
+import org.bukkit.event.Event;
|
|
|
|
+import org.bukkit.event.block.Action;
|
|
|
|
+import org.bukkit.event.block.SignChangeEvent;
|
|
|
|
+import org.bukkit.event.inventory.ClickType;
|
|
|
|
+import org.bukkit.event.inventory.CraftItemEvent;
|
|
|
|
+import org.bukkit.event.inventory.InventoryAction;
|
|
|
|
+import org.bukkit.event.inventory.InventoryClickEvent;
|
|
|
|
+import org.bukkit.event.inventory.InventoryCreativeEvent;
|
|
|
|
+import org.bukkit.event.inventory.InventoryType.SlotType;
|
|
|
|
+import org.bukkit.event.player.AsyncPlayerChatEvent;
|
|
|
|
+import org.bukkit.event.player.PlayerAnimationEvent;
|
|
|
|
+import org.bukkit.event.player.PlayerChatEvent;
|
|
|
|
+import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
|
|
|
+import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
2016-02-29 22:32:46 +01:00
|
|
|
+import org.bukkit.event.player.PlayerInteractEntityEvent;
|
2014-11-25 22:32:16 +01:00
|
|
|
+import org.bukkit.event.player.PlayerItemHeldEvent;
|
|
|
|
+import org.bukkit.event.player.PlayerKickEvent;
|
|
|
|
+import org.bukkit.event.player.PlayerMoveEvent;
|
2015-07-25 10:19:37 +02:00
|
|
|
+import org.bukkit.event.player.PlayerResourcePackStatusEvent;
|
2014-11-25 22:32:16 +01:00
|
|
|
+import org.bukkit.event.player.PlayerTeleportEvent;
|
|
|
|
+import org.bukkit.event.player.PlayerToggleFlightEvent;
|
|
|
|
+import org.bukkit.event.player.PlayerToggleSneakEvent;
|
|
|
|
+import org.bukkit.event.player.PlayerToggleSprintEvent;
|
|
|
|
+import org.bukkit.inventory.CraftingInventory;
|
2016-03-04 05:24:51 +01:00
|
|
|
+import org.bukkit.inventory.EquipmentSlot;
|
2014-11-25 22:32:16 +01:00
|
|
|
+import org.bukkit.inventory.InventoryView;
|
|
|
|
+import org.bukkit.util.NumberConversions;
|
|
|
|
+// CraftBukkit end
|
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
private static final Logger LOGGER = LogManager.getLogger();
|
2016-03-04 05:24:51 +01:00
|
|
|
@@ -28,7 +69,10 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
private int f;
|
|
|
|
private long g;
|
|
|
|
private long h;
|
2014-11-25 22:32:16 +01:00
|
|
|
- private int chatThrottle;
|
|
|
|
+ // CraftBukkit start - multithreaded fields
|
|
|
|
+ private volatile int chatThrottle;
|
|
|
|
+ private static final AtomicIntegerFieldUpdater chatSpamField = AtomicIntegerFieldUpdater.newUpdater(PlayerConnection.class, "chatThrottle");
|
|
|
|
+ // CraftBukkit end
|
2016-02-29 22:32:46 +01:00
|
|
|
private int j;
|
|
|
|
private final IntHashMap<Short> k = new IntHashMap();
|
|
|
|
private double l;
|
2016-03-04 05:24:51 +01:00
|
|
|
@@ -53,6 +97,7 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
private int E;
|
|
|
|
private int F;
|
|
|
|
private int G;
|
|
|
|
+ private boolean processedDisconnect; // CraftBukkit - Added
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
public PlayerConnection(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayer entityplayer) {
|
|
|
|
this.minecraftServer = minecraftserver;
|
2016-03-04 05:24:51 +01:00
|
|
|
@@ -60,7 +105,32 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
networkmanager.setPacketListener(this);
|
2014-11-25 22:32:16 +01:00
|
|
|
this.player = entityplayer;
|
|
|
|
entityplayer.playerConnection = this;
|
|
|
|
+
|
|
|
|
+ // CraftBukkit start - add fields and methods
|
|
|
|
+ this.server = minecraftserver.server;
|
2015-07-20 23:31:49 +02:00
|
|
|
+ }
|
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
+ private final org.bukkit.craftbukkit.CraftServer server;
|
|
|
|
+ private int lastTick = MinecraftServer.currentTick;
|
2016-02-29 22:32:46 +01:00
|
|
|
+ private int allowedPlayerTicks = 1;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ private int lastDropTick = MinecraftServer.currentTick;
|
|
|
|
+ private int dropCount = 0;
|
|
|
|
+ private static final int SURVIVAL_PLACE_DISTANCE_SQUARED = 6 * 6;
|
|
|
|
+ private static final int CREATIVE_PLACE_DISTANCE_SQUARED = 7 * 7;
|
|
|
|
+
|
|
|
|
+ // Get position of last block hit for BlockDamageLevel.STOPPED
|
|
|
|
+ private double lastPosX = Double.MAX_VALUE;
|
|
|
|
+ private double lastPosY = Double.MAX_VALUE;
|
|
|
|
+ private double lastPosZ = Double.MAX_VALUE;
|
|
|
|
+ private float lastPitch = Float.MAX_VALUE;
|
|
|
|
+ private float lastYaw = Float.MAX_VALUE;
|
|
|
|
+ private boolean justTeleported = false;
|
|
|
|
+
|
|
|
|
+ public CraftPlayer getPlayer() {
|
|
|
|
+ return (this.player == null) ? null : (CraftPlayer) this.player.getBukkitEntity();
|
2015-07-20 23:31:49 +02:00
|
|
|
}
|
2014-11-25 22:32:16 +01:00
|
|
|
+ private final static HashSet<Integer> invalidItems = new HashSet<Integer>(java.util.Arrays.asList(8, 9, 10, 11, 26, 34, 36, 43, 51, 52, 55, 59, 60, 62, 63, 64, 68, 71, 74, 75, 83, 90, 92, 93, 94, 104, 105, 115, 117, 118, 119, 125, 127, 132, 140, 141, 142, 144)); // TODO: Check after every update.
|
|
|
|
+ // CraftBukkit end
|
2015-07-20 23:31:49 +02:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
public void c() {
|
2016-02-29 22:32:46 +01:00
|
|
|
this.d();
|
2016-03-04 05:24:51 +01:00
|
|
|
@@ -112,15 +182,21 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
this.minecraftServer.methodProfiler.b();
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ for (int spam; (spam = this.chatThrottle) > 0 && !chatSpamField.compareAndSet(this, spam, spam - 1); ) ;
|
|
|
|
+ /* Use thread-safe field access instead
|
|
|
|
if (this.chatThrottle > 0) {
|
|
|
|
--this.chatThrottle;
|
|
|
|
}
|
|
|
|
+ */
|
|
|
|
+ // CraftBukkit end
|
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
if (this.j > 0) {
|
|
|
|
--this.j;
|
2015-05-21 09:15:47 +02:00
|
|
|
}
|
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
if (this.player.I() > 0L && this.minecraftServer.getIdleTimeout() > 0 && MinecraftServer.av() - this.player.I() > (long) (this.minecraftServer.getIdleTimeout() * 1000 * 60)) {
|
2015-05-21 09:15:47 +02:00
|
|
|
+ this.player.resetIdleTimer(); // CraftBukkit - SPIGOT-854
|
|
|
|
this.disconnect("You have been idle for too long!");
|
|
|
|
}
|
|
|
|
|
2016-03-04 05:24:51 +01:00
|
|
|
@@ -140,19 +216,37 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void disconnect(String s) {
|
|
|
|
+ // CraftBukkit start - fire PlayerKickEvent
|
|
|
|
+ String leaveMessage = EnumChatFormat.YELLOW + this.player.getName() + " left the game.";
|
|
|
|
+
|
|
|
|
+ PlayerKickEvent event = new PlayerKickEvent(this.server.getPlayer(this.player), s, leaveMessage);
|
|
|
|
+
|
|
|
|
+ if (this.server.getServer().isRunning()) {
|
|
|
|
+ this.server.getPluginManager().callEvent(event);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (event.isCancelled()) {
|
|
|
|
+ // Do not kick the player
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // Send the possibly modified leave message
|
|
|
|
+ s = event.getReason();
|
|
|
|
+ // CraftBukkit end
|
2015-02-26 23:41:06 +01:00
|
|
|
final ChatComponentText chatcomponenttext = new ChatComponentText(s);
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
this.networkManager.sendPacket(new PacketPlayOutKickDisconnect(chatcomponenttext), new GenericFutureListener() {
|
2015-02-26 23:41:06 +01:00
|
|
|
- public void operationComplete(Future<? super Void> future) throws Exception {
|
2016-02-29 22:32:46 +01:00
|
|
|
+ public void operationComplete(Future future) throws Exception { // CraftBukkit - decompile error
|
2015-02-26 23:41:06 +01:00
|
|
|
PlayerConnection.this.networkManager.close(chatcomponenttext);
|
|
|
|
}
|
|
|
|
}, new GenericFutureListener[0]);
|
2015-01-04 21:12:02 +01:00
|
|
|
+ this.a(chatcomponenttext); // CraftBukkit - fire quit instantly
|
2016-02-29 22:32:46 +01:00
|
|
|
this.networkManager.stopReading();
|
2015-02-26 23:41:06 +01:00
|
|
|
- Futures.getUnchecked(this.minecraftServer.postToMainThread(new Runnable() {
|
2015-04-17 12:55:10 +02:00
|
|
|
+ // CraftBukkit - Don't wait
|
|
|
|
+ this.minecraftServer.postToMainThread(new Runnable() {
|
2016-02-29 22:32:46 +01:00
|
|
|
public void run() {
|
|
|
|
PlayerConnection.this.networkManager.handleDisconnection();
|
2015-04-17 12:55:10 +02:00
|
|
|
}
|
2015-02-26 23:41:06 +01:00
|
|
|
- }));
|
2015-04-17 12:55:10 +02:00
|
|
|
+ });
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void a(PacketPlayInSteerVehicle packetplayinsteervehicle) {
|
2016-03-06 22:33:27 +01:00
|
|
|
@@ -191,7 +285,34 @@
|
|
|
|
double d9 = entity.motX * entity.motX + entity.motY * entity.motY + entity.motZ * entity.motZ;
|
|
|
|
double d10 = d6 * d6 + d7 * d7 + d8 * d8;
|
|
|
|
|
|
|
|
- if (d10 - d9 > 100.0D && (!this.minecraftServer.R() || !this.minecraftServer.Q().equals(entity.getName()))) {
|
|
|
|
+
|
|
|
|
+ // CraftBukkit start - handle custom speeds and skipped ticks
|
|
|
|
+ this.allowedPlayerTicks += (System.currentTimeMillis() / 50) - this.lastTick;
|
|
|
|
+ this.allowedPlayerTicks = Math.max(this.allowedPlayerTicks, 1);
|
|
|
|
+ this.lastTick = (int) (System.currentTimeMillis() / 50);
|
|
|
|
+
|
|
|
|
+ ++this.F;
|
|
|
|
+ int i = this.F - this.G; // PAIL: Rename
|
|
|
|
+ if (i > Math.max(this.allowedPlayerTicks, 5)) {
|
|
|
|
+ PlayerConnection.LOGGER.debug(this.player.getName() + " is sending move packets too frequently (" + i + " packets since last tick)");
|
|
|
|
+ i = 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (d10 > 0) {
|
|
|
|
+ allowedPlayerTicks -= 1;
|
|
|
|
+ } else {
|
|
|
|
+ allowedPlayerTicks = 20;
|
|
|
|
+ }
|
|
|
|
+ float speed;
|
|
|
|
+ if (player.abilities.isFlying) {
|
|
|
|
+ speed = player.abilities.flySpeed * 20f;
|
|
|
|
+ } else {
|
|
|
|
+ speed = player.abilities.walkSpeed * 10f;
|
|
|
|
+ }
|
|
|
|
+ speed *= 2f; // TODO: Get the speed of the vehicle instead of the player
|
|
|
|
+
|
|
|
|
+ if (d10 - d9 > Math.pow((double) (10.0F * (float) i * speed), 2) && (!this.minecraftServer.R() || !this.minecraftServer.Q().equals(entity.getName()))) {
|
|
|
|
+ // CraftBukkit end
|
|
|
|
PlayerConnection.LOGGER.warn(entity.getName() + " (vehicle of " + this.player.getName() + ") moved too quickly! " + d6 + "," + d7 + "," + d8);
|
|
|
|
this.networkManager.sendPacket(new PacketPlayOutVehicleMove(entity));
|
|
|
|
return;
|
|
|
|
@@ -229,6 +350,62 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
return;
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
2016-02-29 22:32:46 +01:00
|
|
|
|
2015-05-22 15:33:34 +02:00
|
|
|
+ // CraftBukkit start - fire PlayerMoveEvent
|
|
|
|
+ Player player = this.getPlayer();
|
|
|
|
+ Location from = new Location(player.getWorld(), lastPosX, lastPosY, lastPosZ, lastYaw, lastPitch); // Get the Players previous Event location.
|
|
|
|
+ Location to = player.getLocation().clone(); // Start off the To location as the Players current location.
|
|
|
|
+
|
|
|
|
+ // If the packet contains movement information then we update the To location with the correct XYZ.
|
2016-02-29 22:32:46 +01:00
|
|
|
+ to.setX(packetplayinvehiclemove.getX());
|
|
|
|
+ to.setY(packetplayinvehiclemove.getY());
|
|
|
|
+ to.setZ(packetplayinvehiclemove.getZ());
|
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
2015-05-22 15:33:34 +02:00
|
|
|
+ // If the packet contains look information then we update the To location with the correct Yaw & Pitch.
|
2016-02-29 22:32:46 +01:00
|
|
|
+ to.setYaw(packetplayinvehiclemove.getYaw());
|
|
|
|
+ to.setPitch(packetplayinvehiclemove.getPitch());
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
2015-05-22 15:33:34 +02:00
|
|
|
+ // Prevent 40 event-calls for less than a single pixel of movement >.>
|
|
|
|
+ double delta = Math.pow(this.lastPosX - to.getX(), 2) + Math.pow(this.lastPosY - to.getY(), 2) + Math.pow(this.lastPosZ - to.getZ(), 2);
|
|
|
|
+ float deltaAngle = Math.abs(this.lastYaw - to.getYaw()) + Math.abs(this.lastPitch - to.getPitch());
|
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
+ if ((delta > 1f / 256 || deltaAngle > 10f) && !this.player.dead) {
|
2015-05-22 15:33:34 +02:00
|
|
|
+ this.lastPosX = to.getX();
|
|
|
|
+ this.lastPosY = to.getY();
|
|
|
|
+ this.lastPosZ = to.getZ();
|
|
|
|
+ this.lastYaw = to.getYaw();
|
|
|
|
+ this.lastPitch = to.getPitch();
|
|
|
|
+
|
|
|
|
+ // Skip the first time we do this
|
|
|
|
+ if (from.getX() != Double.MAX_VALUE) {
|
|
|
|
+ Location oldTo = to.clone();
|
|
|
|
+ PlayerMoveEvent event = new PlayerMoveEvent(player, from, to);
|
|
|
|
+ this.server.getPluginManager().callEvent(event);
|
|
|
|
+
|
|
|
|
+ // If the event is cancelled we move the player back to their old location.
|
|
|
|
+ if (event.isCancelled()) {
|
2016-03-06 23:17:32 +01:00
|
|
|
+ teleport(from);
|
2015-05-22 15:33:34 +02:00
|
|
|
+ return;
|
|
|
|
+ }
|
2016-02-29 22:32:46 +01:00
|
|
|
+
|
|
|
|
+ // If a Plugin has changed the To destination then we teleport the Player
|
|
|
|
+ // there to avoid any 'Moved wrongly' or 'Moved too quickly' errors.
|
|
|
|
+ // We only do this if the Event was not cancelled.
|
2015-05-22 15:33:34 +02:00
|
|
|
+ if (!oldTo.equals(event.getTo()) && !event.isCancelled()) {
|
|
|
|
+ this.player.getBukkitEntity().teleport(event.getTo(), PlayerTeleportEvent.TeleportCause.UNKNOWN);
|
|
|
|
+ return;
|
|
|
|
+ }
|
2015-04-15 17:24:53 +02:00
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
+ // Check to see if the Players Location has some how changed during the call of the event.
|
|
|
|
+ // This can happen due to a plugin teleporting the player instead of using .setTo()
|
2015-05-22 15:33:34 +02:00
|
|
|
+ if (!from.equals(this.getPlayer().getLocation()) && this.justTeleported) {
|
|
|
|
+ this.justTeleported = false;
|
|
|
|
+ return;
|
|
|
|
+ }
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+ }
|
2016-02-29 22:32:46 +01:00
|
|
|
+ // CraftBukkit end
|
2015-07-20 23:31:49 +02:00
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
this.minecraftServer.getPlayerList().d(this.player);
|
|
|
|
this.player.checkMovement(this.player.locX - d0, this.player.locY - d1, this.player.locZ - d2);
|
|
|
|
this.D = d11 >= -0.03125D && !this.minecraftServer.getAllowFlight() && !worldserver.d(entity.getBoundingBox().g(0.0625D).a(0.0D, -0.55D, 0.0D));
|
2016-03-06 22:33:27 +01:00
|
|
|
@@ -273,13 +450,21 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
this.A = this.e;
|
|
|
|
this.a(this.teleportPos.x, this.teleportPos.y, this.teleportPos.z, this.player.yaw, this.player.pitch);
|
|
|
|
}
|
|
|
|
-
|
|
|
|
+ this.allowedPlayerTicks = 20; // CraftBukkit
|
|
|
|
} else {
|
|
|
|
this.A = this.e;
|
|
|
|
if (this.player.isPassenger()) {
|
|
|
|
this.player.setLocation(this.player.locX, this.player.locY, this.player.locZ, packetplayinflying.a(this.player.yaw), packetplayinflying.b(this.player.pitch));
|
2015-05-22 15:33:34 +02:00
|
|
|
this.minecraftServer.getPlayerList().d(this.player);
|
2016-02-29 22:32:46 +01:00
|
|
|
+ this.allowedPlayerTicks = 20; // CraftBukkit
|
|
|
|
} else {
|
2016-03-03 12:15:04 +01:00
|
|
|
+ // CraftBukkit - Make sure the move is valid but then reset it for plugins to modify
|
|
|
|
+ double prevX = player.locX;
|
|
|
|
+ double prevY = player.locY;
|
|
|
|
+ double prevZ = player.locZ;
|
|
|
|
+ float prevYaw = player.yaw;
|
|
|
|
+ float prevPitch = player.pitch;
|
|
|
|
+ // CraftBukkit end
|
2016-02-29 22:32:46 +01:00
|
|
|
double d0 = this.player.locX;
|
|
|
|
double d1 = this.player.locY;
|
2016-03-03 12:15:04 +01:00
|
|
|
double d2 = this.player.locZ;
|
2016-03-06 22:33:27 +01:00
|
|
|
@@ -298,15 +483,33 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
++this.F;
|
|
|
|
int i = this.F - this.G;
|
|
|
|
|
|
|
|
- if (i > 5) {
|
|
|
|
+ // CraftBukkit start - handle custom speeds and skipped ticks
|
|
|
|
+ this.allowedPlayerTicks += (System.currentTimeMillis() / 50) - this.lastTick;
|
|
|
|
+ this.allowedPlayerTicks = Math.max(this.allowedPlayerTicks, 1);
|
|
|
|
+ this.lastTick = (int) (System.currentTimeMillis() / 50);
|
|
|
|
+
|
|
|
|
+ if (i > Math.max(this.allowedPlayerTicks, 5)) {
|
|
|
|
PlayerConnection.LOGGER.debug(this.player.getName() + " is sending move packets too frequently (" + i + " packets since last tick)");
|
|
|
|
i = 1;
|
|
|
|
}
|
2015-05-22 15:33:34 +02:00
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
+ if (packetplayinflying.hasLook || d11 > 0) {
|
|
|
|
+ allowedPlayerTicks -= 1;
|
|
|
|
+ } else {
|
|
|
|
+ allowedPlayerTicks = 20;
|
|
|
|
+ }
|
|
|
|
+ float speed;
|
|
|
|
+ if (player.abilities.isFlying) {
|
|
|
|
+ speed = player.abilities.flySpeed * 20f;
|
|
|
|
+ } else {
|
|
|
|
+ speed = player.abilities.walkSpeed * 10f;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
if (!this.player.K() && (!this.player.x().getGameRules().getBoolean("disableElytraMovementCheck") || !this.player.cB())) {
|
|
|
|
float f2 = this.player.cB() ? 300.0F : 100.0F;
|
|
|
|
|
|
|
|
- if (d11 - d10 > (double) (f2 * (float) i) && (!this.minecraftServer.R() || !this.minecraftServer.Q().equals(this.player.getName()))) {
|
|
|
|
+ if (d11 - d10 > Math.pow((double) (10.0F * (float) i * speed), 2) && (!this.minecraftServer.R() || !this.minecraftServer.Q().equals(this.player.getName()))) {
|
2016-03-06 22:33:27 +01:00
|
|
|
+ // CraftBukkit end
|
2016-02-29 22:32:46 +01:00
|
|
|
PlayerConnection.LOGGER.warn(this.player.getName() + " moved too quickly! " + d7 + "," + d8 + "," + d9);
|
2015-05-22 15:33:34 +02:00
|
|
|
this.a(this.player.locX, this.player.locY, this.player.locZ, this.player.yaw, this.player.pitch);
|
2016-02-29 22:32:46 +01:00
|
|
|
return;
|
2016-03-06 22:33:27 +01:00
|
|
|
@@ -352,6 +555,69 @@
|
2015-05-22 15:33:34 +02:00
|
|
|
}
|
|
|
|
}
|
2015-04-15 17:29:02 +02:00
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
+ // CraftBukkit start - fire PlayerMoveEvent
|
2016-03-03 00:06:25 +01:00
|
|
|
+ // Rest to old location first
|
|
|
|
+ this.player.setLocation(prevX, prevY, prevZ, prevYaw, prevPitch);
|
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
+ Player player = this.getPlayer();
|
|
|
|
+ Location from = new Location(player.getWorld(), lastPosX, lastPosY, lastPosZ, lastYaw, lastPitch); // Get the Players previous Event location.
|
|
|
|
+ Location to = player.getLocation().clone(); // Start off the To location as the Players current location.
|
2015-05-22 15:33:34 +02:00
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
+ // If the packet contains movement information then we update the To location with the correct XYZ.
|
|
|
|
+ if (packetplayinflying.hasPos) {
|
|
|
|
+ to.setX(packetplayinflying.x);
|
|
|
|
+ to.setY(packetplayinflying.y);
|
|
|
|
+ to.setZ(packetplayinflying.z);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // If the packet contains look information then we update the To location with the correct Yaw & Pitch.
|
|
|
|
+ if (packetplayinflying.hasLook) {
|
|
|
|
+ to.setYaw(packetplayinflying.yaw);
|
|
|
|
+ to.setPitch(packetplayinflying.pitch);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Prevent 40 event-calls for less than a single pixel of movement >.>
|
|
|
|
+ double delta = Math.pow(this.lastPosX - to.getX(), 2) + Math.pow(this.lastPosY - to.getY(), 2) + Math.pow(this.lastPosZ - to.getZ(), 2);
|
|
|
|
+ float deltaAngle = Math.abs(this.lastYaw - to.getYaw()) + Math.abs(this.lastPitch - to.getPitch());
|
|
|
|
+
|
|
|
|
+ if ((delta > 1f / 256 || deltaAngle > 10f) && !this.player.dead) {
|
|
|
|
+ this.lastPosX = to.getX();
|
|
|
|
+ this.lastPosY = to.getY();
|
|
|
|
+ this.lastPosZ = to.getZ();
|
|
|
|
+ this.lastYaw = to.getYaw();
|
|
|
|
+ this.lastPitch = to.getPitch();
|
|
|
|
+
|
|
|
|
+ // Skip the first time we do this
|
|
|
|
+ if (from.getX() != Double.MAX_VALUE) {
|
|
|
|
+ Location oldTo = to.clone();
|
|
|
|
+ PlayerMoveEvent event = new PlayerMoveEvent(player, from, to);
|
|
|
|
+ this.server.getPluginManager().callEvent(event);
|
|
|
|
+
|
|
|
|
+ // If the event is cancelled we move the player back to their old location.
|
|
|
|
+ if (event.isCancelled()) {
|
2016-03-06 23:17:32 +01:00
|
|
|
+ teleport(from);
|
2016-02-29 22:32:46 +01:00
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // If a Plugin has changed the To destination then we teleport the Player
|
|
|
|
+ // there to avoid any 'Moved wrongly' or 'Moved too quickly' errors.
|
|
|
|
+ // We only do this if the Event was not cancelled.
|
|
|
|
+ if (!oldTo.equals(event.getTo()) && !event.isCancelled()) {
|
|
|
|
+ this.player.getBukkitEntity().teleport(event.getTo(), PlayerTeleportEvent.TeleportCause.UNKNOWN);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Check to see if the Players Location has some how changed during the call of the event.
|
|
|
|
+ // This can happen due to a plugin teleporting the player instead of using .setTo()
|
|
|
|
+ if (!from.equals(this.getPlayer().getLocation()) && this.justTeleported) {
|
|
|
|
+ this.justTeleported = false;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
2016-03-03 00:06:25 +01:00
|
|
|
+ this.player.setLocation(d4, d5, d6, f, f1); // Copied from above
|
2016-02-29 22:32:46 +01:00
|
|
|
+ // CraftBukkit end
|
|
|
|
+
|
|
|
|
this.B = d12 >= -0.03125D;
|
|
|
|
this.B &= !this.minecraftServer.getAllowFlight() && !this.player.abilities.canFly;
|
|
|
|
this.B &= !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.cB() && !worldserver.d(this.player.getBoundingBox().g(0.0625D).a(0.0D, -0.55D, 0.0D));
|
2016-03-06 22:33:27 +01:00
|
|
|
@@ -368,15 +634,79 @@
|
2015-02-26 23:41:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void a(double d0, double d1, double d2, float f, float f1) {
|
|
|
|
- this.a(d0, d1, d2, f, f1, Collections.emptySet());
|
2016-02-29 22:32:46 +01:00
|
|
|
+ this.a(d0, d1, d2, f, f1, Collections.<PacketPlayOutPosition.EnumPlayerTeleportFlags>emptySet());
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
2015-02-26 23:41:06 +01:00
|
|
|
public void a(double d0, double d1, double d2, float f, float f1, Set<PacketPlayOutPosition.EnumPlayerTeleportFlags> set) {
|
2016-02-29 22:32:46 +01:00
|
|
|
- double d3 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.X) ? this.player.locX : 0.0D;
|
|
|
|
- double d4 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Y) ? this.player.locY : 0.0D;
|
|
|
|
- double d5 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Z) ? this.player.locZ : 0.0D;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start - Delegate to teleport(Location)
|
|
|
|
+ Player player = this.getPlayer();
|
|
|
|
+ Location from = player.getLocation();
|
2015-07-20 23:31:49 +02:00
|
|
|
+
|
|
|
|
+ double x = d0;
|
|
|
|
+ double y = d1;
|
|
|
|
+ double z = d2;
|
|
|
|
+ float yaw = f;
|
|
|
|
+ float pitch = f1;
|
|
|
|
+ if (set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.X)) {
|
|
|
|
+ x += from.getX();
|
|
|
|
+ }
|
|
|
|
+ if (set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Y)) {
|
|
|
|
+ y += from.getY();
|
|
|
|
+ }
|
|
|
|
+ if (set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Z)) {
|
|
|
|
+ z += from.getZ();
|
|
|
|
+ }
|
|
|
|
+ if (set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Y_ROT)) {
|
|
|
|
+ yaw += from.getYaw();
|
|
|
|
+ }
|
|
|
|
+ if (set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.X_ROT)) {
|
|
|
|
+ pitch += from.getPitch();
|
|
|
|
+ }
|
2016-03-06 22:33:27 +01:00
|
|
|
|
|
|
|
- this.teleportPos = new Vec3D(d0 + d3, d1 + d4, d2 + d5);
|
2015-07-20 23:31:49 +02:00
|
|
|
+
|
|
|
|
+ Location to = new Location(this.getPlayer().getWorld(), x, y, z, yaw, pitch);
|
|
|
|
+ PlayerTeleportEvent event = new PlayerTeleportEvent(player, from.clone(), to.clone(), PlayerTeleportEvent.TeleportCause.UNKNOWN);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ this.server.getPluginManager().callEvent(event);
|
|
|
|
+
|
2015-07-20 23:31:49 +02:00
|
|
|
+ if (event.isCancelled() || to.equals(event.getTo())) {
|
|
|
|
+ set.clear(); // Can't relative teleport
|
|
|
|
+ to = event.isCancelled() ? event.getFrom() : event.getTo();
|
|
|
|
+ d0 = to.getX();
|
|
|
|
+ d1 = to.getY();
|
|
|
|
+ d2 = to.getZ();
|
|
|
|
+ f = to.getYaw();
|
|
|
|
+ f1 = to.getPitch();
|
|
|
|
+ }
|
2016-03-01 03:52:34 +01:00
|
|
|
+
|
2016-02-29 23:58:55 +01:00
|
|
|
+ this.internalTeleport(d0, d1, d2, f, f1, set);
|
|
|
|
+ }
|
2016-03-06 22:33:27 +01:00
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
+ public void teleport(Location dest) {
|
2015-07-20 23:31:49 +02:00
|
|
|
+ internalTeleport(dest.getX(), dest.getY(), dest.getZ(), dest.getYaw(), dest.getPitch(), Collections.emptySet());
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+
|
2015-07-20 23:31:49 +02:00
|
|
|
+ private void internalTeleport(double d0, double d1, double d2, float f, float f1, Set set) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ if (Float.isNaN(f)) {
|
|
|
|
+ f = 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (Float.isNaN(f1)) {
|
|
|
|
+ f1 = 0;
|
|
|
|
+ }
|
|
|
|
+ this.justTeleported = true;
|
2016-02-29 22:32:46 +01:00
|
|
|
+ this.teleportPos = new Vec3D(d0, d1, d2);
|
|
|
|
+ if (set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.X)) {
|
|
|
|
+ this.teleportPos = this.teleportPos.add(this.player.locX, 0.0D, 0.0D);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Y)) {
|
|
|
|
+ this.teleportPos = this.teleportPos.add(0.0D, this.player.locY, 0.0D);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Z)) {
|
|
|
|
+ this.teleportPos = this.teleportPos.add(0.0D, 0.0D, this.player.locZ);
|
|
|
|
+ }
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit end
|
2016-02-29 22:32:46 +01:00
|
|
|
float f2 = f;
|
|
|
|
float f3 = f1;
|
|
|
|
|
2016-03-06 22:33:27 +01:00
|
|
|
@@ -388,6 +718,14 @@
|
2015-07-23 21:37:58 +02:00
|
|
|
f3 = f1 + this.player.pitch;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // CraftBukkit start - update last location
|
2016-02-29 22:32:46 +01:00
|
|
|
+ this.lastPosX = this.teleportPos.x;
|
|
|
|
+ this.lastPosY = this.teleportPos.y;
|
|
|
|
+ this.lastPosZ = this.teleportPos.z;
|
2015-07-23 21:37:58 +02:00
|
|
|
+ this.lastYaw = f2;
|
|
|
|
+ this.lastPitch = f3;
|
|
|
|
+ // CraftBukkit end
|
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
if (++this.teleportAwait == Integer.MAX_VALUE) {
|
|
|
|
this.teleportAwait = 0;
|
|
|
|
}
|
2016-03-12 11:07:17 +01:00
|
|
|
@@ -399,14 +737,16 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
public void a(PacketPlayInBlockDig packetplayinblockdig) {
|
2016-02-29 22:32:46 +01:00
|
|
|
PlayerConnectionUtils.ensureMainThread(packetplayinblockdig, this, this.player.x());
|
2014-11-25 22:32:16 +01:00
|
|
|
+ if (this.player.dead) return; // CraftBukkit
|
|
|
|
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
|
|
|
|
BlockPosition blockposition = packetplayinblockdig.a();
|
|
|
|
|
2015-05-05 22:43:47 +02:00
|
|
|
this.player.resetIdleTimer();
|
2016-02-29 22:32:46 +01:00
|
|
|
ItemStack itemstack;
|
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
2015-02-26 23:41:06 +01:00
|
|
|
switch (PlayerConnection.SyntheticClass_1.a[packetplayinblockdig.c().ordinal()]) {
|
2014-11-25 22:32:16 +01:00
|
|
|
- case 1:
|
2016-03-12 11:07:17 +01:00
|
|
|
+ case 1: // SWAP_HELD_ITEMS
|
|
|
|
if (!this.player.isSpectator()) {
|
|
|
|
itemstack = this.player.b(EnumHand.OFF_HAND);
|
|
|
|
this.player.a(EnumHand.OFF_HAND, this.player.b(EnumHand.MAIN_HAND));
|
|
|
|
@@ -415,21 +755,36 @@
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
- case 2:
|
|
|
|
+ case 2: // DROP_ITEM
|
2015-05-05 22:43:47 +02:00
|
|
|
if (!this.player.isSpectator()) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // limit how quickly items can be dropped
|
|
|
|
+ // If the ticks aren't the same then the count starts from 0 and we update the lastDropTick.
|
|
|
|
+ if (this.lastDropTick != MinecraftServer.currentTick) {
|
|
|
|
+ this.dropCount = 0;
|
|
|
|
+ this.lastDropTick = MinecraftServer.currentTick;
|
|
|
|
+ } else {
|
|
|
|
+ // Else we increment the drop count and check the amount.
|
|
|
|
+ this.dropCount++;
|
|
|
|
+ if (this.dropCount >= 20) {
|
2016-03-12 11:07:17 +01:00
|
|
|
+ LOGGER.warn(this.player.getName() + " dropped their items too quickly!");
|
2014-11-25 22:32:16 +01:00
|
|
|
+ this.disconnect("You dropped your items too quickly (Hacking?)");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2016-02-29 22:32:46 +01:00
|
|
|
this.player.a(false);
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
- case 3:
|
2016-03-12 11:07:17 +01:00
|
|
|
+ case 3: // DROP_ALL_ITEMS
|
2016-02-29 22:32:46 +01:00
|
|
|
if (!this.player.isSpectator()) {
|
|
|
|
this.player.a(true);
|
|
|
|
}
|
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
- case 4:
|
2016-03-12 11:07:17 +01:00
|
|
|
+ case 4: // RELEASE_USE_ITEM
|
2016-02-29 22:32:46 +01:00
|
|
|
this.player.clearActiveItem();
|
|
|
|
itemstack = this.player.getItemInMainHand();
|
|
|
|
if (itemstack != null && itemstack.count == 0) {
|
2016-03-12 11:07:17 +01:00
|
|
|
@@ -438,9 +793,9 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
|
|
|
|
return;
|
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
- case 5:
|
|
|
|
- case 6:
|
2016-03-12 11:07:17 +01:00
|
|
|
- case 7:
|
|
|
|
+ case 5: // START_DESTROY_BLOCK
|
|
|
|
+ case 6: // ABORT_DESTROY_BLOCK
|
|
|
|
+ case 7: // STOP_DESTROY_BLOCK
|
2014-11-25 22:32:16 +01:00
|
|
|
double d0 = this.player.locX - ((double) blockposition.getX() + 0.5D);
|
|
|
|
double d1 = this.player.locY - ((double) blockposition.getY() + 0.5D) + 1.5D;
|
2016-03-12 11:07:17 +01:00
|
|
|
double d2 = this.player.locZ - ((double) blockposition.getZ() + 0.5D);
|
2016-03-06 22:33:27 +01:00
|
|
|
@@ -455,7 +810,15 @@
|
2015-02-26 23:41:06 +01:00
|
|
|
if (!this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.getWorldBorder().a(blockposition)) {
|
2014-11-25 22:32:16 +01:00
|
|
|
this.player.playerInteractManager.a(blockposition, packetplayinblockdig.b());
|
|
|
|
} else {
|
|
|
|
+ // CraftBukkit start - fire PlayerInteractEvent
|
2016-03-04 05:24:51 +01:00
|
|
|
+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, packetplayinblockdig.b(), this.player.inventory.getItemInHand(), EnumHand.MAIN_HAND);
|
2014-11-25 22:32:16 +01:00
|
|
|
this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(worldserver, blockposition));
|
|
|
|
+ // Update any tile entity data for this block
|
|
|
|
+ TileEntity tileentity = worldserver.getTileEntity(blockposition);
|
|
|
|
+ if (tileentity != null) {
|
|
|
|
+ this.player.playerConnection.sendPacket(tileentity.getUpdatePacket());
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
} else {
|
2015-02-26 23:41:06 +01:00
|
|
|
if (packetplayinblockdig.c() == PacketPlayInBlockDig.EnumPlayerDigType.STOP_DESTROY_BLOCK) {
|
2016-03-06 22:33:27 +01:00
|
|
|
@@ -475,10 +838,12 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
default:
|
|
|
|
throw new IllegalArgumentException("Invalid player action");
|
|
|
|
}
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
public void a(PacketPlayInUseItem packetplayinuseitem) {
|
|
|
|
PlayerConnectionUtils.ensureMainThread(packetplayinuseitem, this, this.player.x());
|
|
|
|
+ if (this.player.dead) return; // CraftBukkit
|
|
|
|
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
|
|
|
|
EnumHand enumhand = packetplayinuseitem.c();
|
|
|
|
ItemStack itemstack = this.player.b(enumhand);
|
2016-03-06 22:33:27 +01:00
|
|
|
@@ -492,6 +857,13 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
chatmessage.getChatModifier().setColor(EnumChatFormat.RED);
|
|
|
|
this.player.playerConnection.sendPacket(new PacketPlayOutChat(chatmessage));
|
|
|
|
} else if (this.teleportPos == null && this.player.e((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && !this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.getWorldBorder().a(blockposition)) {
|
|
|
|
+ // CraftBukkit start - Check if we can actually do something over this large a distance
|
|
|
|
+ Location eyeLoc = this.getPlayer().getEyeLocation();
|
|
|
|
+ double reachDistance = NumberConversions.square(eyeLoc.getX() - blockposition.getX()) + NumberConversions.square(eyeLoc.getY() - blockposition.getY()) + NumberConversions.square(eyeLoc.getZ() - blockposition.getZ());
|
|
|
|
+ if (reachDistance > (this.getPlayer().getGameMode() == org.bukkit.GameMode.CREATIVE ? CREATIVE_PLACE_DISTANCE_SQUARED : SURVIVAL_PLACE_DISTANCE_SQUARED)) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand, blockposition, enumdirection, packetplayinuseitem.d(), packetplayinuseitem.e(), packetplayinuseitem.f());
|
|
|
|
}
|
|
|
|
|
2016-03-06 22:33:27 +01:00
|
|
|
@@ -507,19 +879,55 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
public void a(PacketPlayInBlockPlace packetplayinblockplace) {
|
2016-02-29 22:32:46 +01:00
|
|
|
PlayerConnectionUtils.ensureMainThread(packetplayinblockplace, this, this.player.x());
|
|
|
|
+ if (this.player.dead) return; // CraftBukkit
|
2014-11-25 22:32:16 +01:00
|
|
|
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
|
2016-02-29 22:32:46 +01:00
|
|
|
EnumHand enumhand = packetplayinblockplace.a();
|
|
|
|
ItemStack itemstack = this.player.b(enumhand);
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
this.player.resetIdleTimer();
|
|
|
|
if (itemstack != null) {
|
|
|
|
- this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand);
|
|
|
|
- itemstack = this.player.b(enumhand);
|
|
|
|
- if (itemstack != null && itemstack.count == 0) {
|
|
|
|
- this.player.a(enumhand, (ItemStack) null);
|
|
|
|
- itemstack = null;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
2014-12-07 12:04:22 +01:00
|
|
|
+ // Raytrace to look for 'rogue armswings'
|
|
|
|
+ float f1 = this.player.pitch;
|
|
|
|
+ float f2 = this.player.yaw;
|
|
|
|
+ double d0 = this.player.locX;
|
|
|
|
+ double d1 = this.player.locY + (double) this.player.getHeadHeight();
|
|
|
|
+ double d2 = this.player.locZ;
|
|
|
|
+ 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 f5 = -MathHelper.cos(-f1 * 0.017453292F);
|
|
|
|
+ float f6 = MathHelper.sin(-f1 * 0.017453292F);
|
|
|
|
+ float f7 = f4 * f5;
|
|
|
|
+ float f8 = f3 * f5;
|
2015-02-26 23:41:06 +01:00
|
|
|
+ double d3 = player.playerInteractManager.getGameMode() == WorldSettings.EnumGamemode.CREATIVE ? 5.0D : 4.5D;
|
2014-12-07 12:04:22 +01:00
|
|
|
+ Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
|
|
|
|
+ MovingObjectPosition movingobjectposition = this.player.world.rayTrace(vec3d, vec3d1, false);
|
|
|
|
+
|
2014-12-09 13:20:44 +01:00
|
|
|
+ boolean cancelled = false;
|
2015-02-26 23:41:06 +01:00
|
|
|
+ if (movingobjectposition == null || movingobjectposition.type != MovingObjectPosition.EnumMovingObjectType.BLOCK) {
|
2016-03-08 19:00:23 +01:00
|
|
|
+ org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.RIGHT_CLICK_AIR, itemstack, enumhand);
|
2014-12-09 13:20:44 +01:00
|
|
|
+ cancelled = event.useItemInHand() == Event.Result.DENY;
|
|
|
|
+ } else {
|
|
|
|
+ if (player.playerInteractManager.firedInteract) {
|
|
|
|
+ player.playerInteractManager.firedInteract = false;
|
|
|
|
+ cancelled = player.playerInteractManager.interactResult;
|
|
|
|
+ } else {
|
2016-03-08 19:00:23 +01:00
|
|
|
+ org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, movingobjectposition.a(), movingobjectposition.direction, itemstack, true, enumhand);
|
2014-12-09 13:20:44 +01:00
|
|
|
+ cancelled = event.useItemInHand() == Event.Result.DENY;
|
|
|
|
+ }
|
2016-02-29 22:32:46 +01:00
|
|
|
}
|
|
|
|
|
2014-12-09 13:20:44 +01:00
|
|
|
+ if (!cancelled) {
|
2016-02-29 22:32:46 +01:00
|
|
|
+ this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand);
|
|
|
|
+ itemstack = this.player.b(enumhand);
|
|
|
|
+ if (itemstack != null && itemstack.count == 0) {
|
|
|
|
+ this.player.a(enumhand, (ItemStack) null);
|
|
|
|
+ itemstack = null;
|
|
|
|
+ }
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
2016-02-29 22:32:46 +01:00
|
|
|
}
|
|
|
|
|
2016-03-06 22:33:27 +01:00
|
|
|
@@ -530,8 +938,8 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
WorldServer[] aworldserver = this.minecraftServer.worldServer;
|
|
|
|
int i = aworldserver.length;
|
|
|
|
|
|
|
|
- for (int j = 0; j < i; ++j) {
|
|
|
|
- WorldServer worldserver = aworldserver[j];
|
|
|
|
+ // CraftBukkit - use the worlds array list
|
|
|
|
+ for (WorldServer worldserver : minecraftServer.worlds) {
|
|
|
|
|
|
|
|
if (worldserver != null) {
|
|
|
|
entity = packetplayinspectate.a(worldserver);
|
2016-03-06 22:33:27 +01:00
|
|
|
@@ -544,6 +952,8 @@
|
2015-01-06 21:21:14 +01:00
|
|
|
if (entity != null) {
|
2015-05-05 22:43:47 +02:00
|
|
|
this.player.setSpectatorTarget(this.player);
|
2016-02-29 22:32:46 +01:00
|
|
|
this.player.stopRiding();
|
2015-01-06 21:21:14 +01:00
|
|
|
+
|
|
|
|
+ /* CraftBukkit start - replace with bukkit handling for multi-world
|
|
|
|
if (entity.world != this.player.world) {
|
2016-02-29 22:32:46 +01:00
|
|
|
WorldServer worldserver1 = this.player.x();
|
2014-11-25 22:32:16 +01:00
|
|
|
WorldServer worldserver2 = (WorldServer) entity.world;
|
2016-03-06 22:33:27 +01:00
|
|
|
@@ -569,12 +979,19 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
} else {
|
|
|
|
this.player.enderTeleportTo(entity.locX, entity.locY, entity.locZ);
|
|
|
|
}
|
2015-01-06 21:21:14 +01:00
|
|
|
+ */
|
|
|
|
+ this.player.getBukkitEntity().teleport(entity.getBukkitEntity(), PlayerTeleportEvent.TeleportCause.SPECTATE);
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-25 10:19:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- public void a(PacketPlayInResourcePackStatus packetplayinresourcepackstatus) {}
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ public void a(PacketPlayInResourcePackStatus packetplayinresourcepackstatus) {
|
2016-02-29 22:32:46 +01:00
|
|
|
+ this.server.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(getPlayer(), PlayerResourcePackStatusEvent.Status.values()[packetplayinresourcepackstatus.status.ordinal()]));
|
2015-07-25 10:19:37 +02:00
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
public void a(PacketPlayInBoatMove packetplayinboatmove) {
|
|
|
|
PlayerConnectionUtils.ensureMainThread(packetplayinboatmove, this, this.player.x());
|
2016-03-06 22:33:27 +01:00
|
|
|
@@ -587,14 +1004,29 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
public void a(IChatBaseComponent ichatbasecomponent) {
|
2016-02-29 22:32:46 +01:00
|
|
|
- PlayerConnection.LOGGER.info(this.player.getName() + " lost connection: " + ichatbasecomponent);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start - Rarely it would send a disconnect line twice
|
|
|
|
+ if (this.processedDisconnect) {
|
|
|
|
+ return;
|
|
|
|
+ } else {
|
|
|
|
+ this.processedDisconnect = true;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2016-02-29 22:32:46 +01:00
|
|
|
+ PlayerConnection.LOGGER.info(this.player.getName() + " lost connection: " + ichatbasecomponent.toPlainText()); // CraftBukkit: Don't toString().
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start - Replace vanilla quit message handling with our own.
|
|
|
|
+ /*
|
2016-02-29 22:32:46 +01:00
|
|
|
this.minecraftServer.aC();
|
2014-11-25 22:32:16 +01:00
|
|
|
ChatMessage chatmessage = new ChatMessage("multiplayer.player.left", new Object[] { this.player.getScoreboardDisplayName()});
|
|
|
|
|
|
|
|
chatmessage.getChatModifier().setColor(EnumChatFormat.YELLOW);
|
|
|
|
this.minecraftServer.getPlayerList().sendMessage(chatmessage);
|
|
|
|
+ */
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
this.player.t();
|
2014-11-25 22:32:16 +01:00
|
|
|
- this.minecraftServer.getPlayerList().disconnect(this.player);
|
|
|
|
+ String quitMessage = this.minecraftServer.getPlayerList().disconnect(this.player);
|
|
|
|
+ if ((quitMessage != null) && (quitMessage.length() > 0)) {
|
|
|
|
+ this.minecraftServer.getPlayerList().sendMessage(CraftChatMessage.fromString(quitMessage));
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2016-02-29 22:32:46 +01:00
|
|
|
if (this.minecraftServer.R() && this.player.getName().equals(this.minecraftServer.Q())) {
|
|
|
|
PlayerConnection.LOGGER.info("Stopping singleplayer server as player logged out");
|
2014-11-25 22:32:16 +01:00
|
|
|
this.minecraftServer.safeShutdown();
|
2016-03-06 22:33:27 +01:00
|
|
|
@@ -616,6 +1048,15 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
}
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (packet == null) {
|
|
|
|
+ return;
|
|
|
|
+ } else if (packet instanceof PacketPlayOutSpawnPosition) {
|
|
|
|
+ PacketPlayOutSpawnPosition packet6 = (PacketPlayOutSpawnPosition) packet;
|
|
|
|
+ this.player.compassTarget = new Location(this.getPlayer().getWorld(), packet6.position.getX(), packet6.position.getY(), packet6.position.getZ());
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
try {
|
2016-02-29 22:32:46 +01:00
|
|
|
this.networkManager.sendPacket(packet);
|
2015-02-26 23:41:06 +01:00
|
|
|
} catch (Throwable throwable) {
|
2016-03-06 22:33:27 +01:00
|
|
|
@@ -637,17 +1078,32 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
|
2016-02-29 22:32:46 +01:00
|
|
|
PlayerConnectionUtils.ensureMainThread(packetplayinhelditemslot, this, this.player.x());
|
|
|
|
+ if (this.player.dead) return; // CraftBukkit
|
2014-11-25 22:32:16 +01:00
|
|
|
if (packetplayinhelditemslot.a() >= 0 && packetplayinhelditemslot.a() < PlayerInventory.getHotbarSize()) {
|
|
|
|
+ PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayer(), this.player.inventory.itemInHandIndex, packetplayinhelditemslot.a());
|
|
|
|
+ this.server.getPluginManager().callEvent(event);
|
|
|
|
+ if (event.isCancelled()) {
|
|
|
|
+ this.sendPacket(new PacketPlayOutHeldItemSlot(this.player.inventory.itemInHandIndex));
|
2015-05-05 22:43:47 +02:00
|
|
|
+ this.player.resetIdleTimer();
|
2014-11-25 22:32:16 +01:00
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
this.player.inventory.itemInHandIndex = packetplayinhelditemslot.a();
|
2015-05-05 22:43:47 +02:00
|
|
|
this.player.resetIdleTimer();
|
2014-11-25 22:32:16 +01:00
|
|
|
} else {
|
2016-02-29 22:32:46 +01:00
|
|
|
PlayerConnection.LOGGER.warn(this.player.getName() + " tried to set an invalid carried item");
|
2014-11-25 22:32:16 +01:00
|
|
|
+ this.disconnect("Nope!"); // CraftBukkit
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(PacketPlayInChat packetplayinchat) {
|
2016-02-29 22:32:46 +01:00
|
|
|
- PlayerConnectionUtils.ensureMainThread(packetplayinchat, this, this.player.x());
|
2015-02-26 23:41:06 +01:00
|
|
|
- if (this.player.getChatFlags() == EntityHuman.EnumChatVisibility.HIDDEN) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start - async chat
|
|
|
|
+ boolean isSync = packetplayinchat.a().startsWith("/");
|
|
|
|
+ if (packetplayinchat.a().startsWith("/")) {
|
2016-02-29 22:32:46 +01:00
|
|
|
+ PlayerConnectionUtils.ensureMainThread(packetplayinchat, this, this.player.x());
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2015-02-26 23:41:06 +01:00
|
|
|
+ if (this.player.dead || this.player.getChatFlags() == EntityHuman.EnumChatVisibility.HIDDEN) { // CraftBukkit - dead men tell no tales
|
2014-11-25 22:32:16 +01:00
|
|
|
ChatMessage chatmessage = new ChatMessage("chat.cannotSend", new Object[0]);
|
|
|
|
|
|
|
|
chatmessage.getChatModifier().setColor(EnumChatFormat.RED);
|
2016-03-06 22:33:27 +01:00
|
|
|
@@ -660,39 +1116,249 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
for (int i = 0; i < s.length(); ++i) {
|
|
|
|
if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) {
|
|
|
|
- this.disconnect("Illegal characters in chat");
|
|
|
|
+ // CraftBukkit start - threadsafety
|
|
|
|
+ if (!isSync) {
|
|
|
|
+ Waitable waitable = new Waitable() {
|
|
|
|
+ @Override
|
|
|
|
+ protected Object evaluate() {
|
|
|
|
+ PlayerConnection.this.disconnect("Illegal characters in chat");
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ this.minecraftServer.processQueue.add(waitable);
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ waitable.get();
|
|
|
|
+ } catch (InterruptedException e) {
|
|
|
|
+ Thread.currentThread().interrupt();
|
|
|
|
+ } catch (ExecutionException e) {
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ this.disconnect("Illegal characters in chat");
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- if (s.startsWith("/")) {
|
|
|
|
- this.handleCommand(s);
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (isSync) {
|
|
|
|
+ try {
|
|
|
|
+ this.minecraftServer.server.playerCommandState = true;
|
|
|
|
+ this.handleCommand(s);
|
|
|
|
+ } finally {
|
|
|
|
+ this.minecraftServer.server.playerCommandState = false;
|
|
|
|
+ }
|
|
|
|
+ } else if (s.isEmpty()) {
|
2016-02-29 22:32:46 +01:00
|
|
|
+ LOGGER.warn(this.player.getName() + " tried to send an empty message");
|
2014-11-25 22:32:16 +01:00
|
|
|
+ } else if (getPlayer().isConversing()) {
|
|
|
|
+ getPlayer().acceptConversationInput(s);
|
2015-02-26 23:41:06 +01:00
|
|
|
+ } else if (this.player.getChatFlags() == EntityHuman.EnumChatVisibility.SYSTEM) { // Re-add "Command Only" flag check
|
2014-11-25 22:32:16 +01:00
|
|
|
+ ChatMessage chatmessage = new ChatMessage("chat.cannotSend", new Object[0]);
|
|
|
|
+
|
|
|
|
+ chatmessage.getChatModifier().setColor(EnumChatFormat.RED);
|
|
|
|
+ this.sendPacket(new PacketPlayOutChat(chatmessage));
|
|
|
|
+ } else if (true) {
|
|
|
|
+ this.chat(s, true);
|
|
|
|
+ // CraftBukkit end - the below is for reference. :)
|
|
|
|
} else {
|
|
|
|
ChatMessage chatmessage1 = new ChatMessage("chat.type.text", new Object[] { this.player.getScoreboardDisplayName(), s});
|
|
|
|
|
|
|
|
this.minecraftServer.getPlayerList().sendMessage(chatmessage1, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
- this.chatThrottle += 20;
|
|
|
|
- if (this.chatThrottle > 200 && !this.minecraftServer.getPlayerList().isOp(this.player.getProfile())) {
|
|
|
|
- this.disconnect("disconnect.spam");
|
|
|
|
+ // CraftBukkit start - replaced with thread safe throttle
|
|
|
|
+ // this.chatThrottle += 20;
|
|
|
|
+ if (chatSpamField.addAndGet(this, 20) > 200 && !this.minecraftServer.getPlayerList().isOp(this.player.getProfile())) {
|
|
|
|
+ if (!isSync) {
|
|
|
|
+ Waitable waitable = new Waitable() {
|
|
|
|
+ @Override
|
|
|
|
+ protected Object evaluate() {
|
|
|
|
+ PlayerConnection.this.disconnect("disconnect.spam");
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ };
|
2014-12-05 16:04:01 +01:00
|
|
|
+
|
2014-11-29 00:06:03 +01:00
|
|
|
+ this.minecraftServer.processQueue.add(waitable);
|
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
+ try {
|
|
|
|
+ waitable.get();
|
|
|
|
+ } catch (InterruptedException e) {
|
|
|
|
+ Thread.currentThread().interrupt();
|
|
|
|
+ } catch (ExecutionException e) {
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ this.disconnect("disconnect.spam");
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2015-02-26 23:41:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- private void handleCommand(String s) {
|
|
|
|
- this.minecraftServer.getCommandHandler().a(this.player, s);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start - add method
|
|
|
|
+ public void chat(String s, boolean async) {
|
2015-02-26 23:41:06 +01:00
|
|
|
+ if (s.isEmpty() || this.player.getChatFlags() == EntityHuman.EnumChatVisibility.HIDDEN) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!async && s.startsWith("/")) {
|
|
|
|
+ this.handleCommand(s);
|
2015-02-26 23:41:06 +01:00
|
|
|
+ } else if (this.player.getChatFlags() == EntityHuman.EnumChatVisibility.SYSTEM) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // Do nothing, this is coming from a plugin
|
|
|
|
+ } else {
|
|
|
|
+ Player player = this.getPlayer();
|
2016-02-29 22:32:46 +01:00
|
|
|
+ AsyncPlayerChatEvent event = new AsyncPlayerChatEvent(async, player, s, new LazyPlayerSet(minecraftServer));
|
2014-11-25 22:32:16 +01:00
|
|
|
+ this.server.getPluginManager().callEvent(event);
|
|
|
|
+
|
|
|
|
+ if (PlayerChatEvent.getHandlerList().getRegisteredListeners().length != 0) {
|
|
|
|
+ // Evil plugins still listening to deprecated event
|
|
|
|
+ final PlayerChatEvent queueEvent = new PlayerChatEvent(player, event.getMessage(), event.getFormat(), event.getRecipients());
|
|
|
|
+ queueEvent.setCancelled(event.isCancelled());
|
|
|
|
+ Waitable waitable = new Waitable() {
|
|
|
|
+ @Override
|
|
|
|
+ protected Object evaluate() {
|
|
|
|
+ org.bukkit.Bukkit.getPluginManager().callEvent(queueEvent);
|
2014-12-07 12:04:22 +01:00
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
+ if (queueEvent.isCancelled()) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String message = String.format(queueEvent.getFormat(), queueEvent.getPlayer().getDisplayName(), queueEvent.getMessage());
|
|
|
|
+ PlayerConnection.this.minecraftServer.console.sendMessage(message);
|
|
|
|
+ if (((LazyPlayerSet) queueEvent.getRecipients()).isLazy()) {
|
|
|
|
+ for (Object player : PlayerConnection.this.minecraftServer.getPlayerList().players) {
|
|
|
|
+ ((EntityPlayer) player).sendMessage(CraftChatMessage.fromString(message));
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ for (Player player : queueEvent.getRecipients()) {
|
|
|
|
+ player.sendMessage(message);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }};
|
|
|
|
+ if (async) {
|
|
|
|
+ minecraftServer.processQueue.add(waitable);
|
|
|
|
+ } else {
|
|
|
|
+ waitable.run();
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ waitable.get();
|
|
|
|
+ } catch (InterruptedException e) {
|
|
|
|
+ Thread.currentThread().interrupt(); // This is proper habit for java. If we aren't handling it, pass it on!
|
|
|
|
+ } catch (ExecutionException e) {
|
|
|
|
+ throw new RuntimeException("Exception processing chat event", e.getCause());
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ if (event.isCancelled()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
+ s = String.format(event.getFormat(), event.getPlayer().getDisplayName(), event.getMessage());
|
|
|
|
+ minecraftServer.console.sendMessage(s);
|
|
|
|
+ if (((LazyPlayerSet) event.getRecipients()).isLazy()) {
|
|
|
|
+ for (Object recipient : minecraftServer.getPlayerList().players) {
|
|
|
|
+ ((EntityPlayer) recipient).sendMessage(CraftChatMessage.fromString(s));
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ for (Player recipient : event.getRecipients()) {
|
|
|
|
+ recipient.sendMessage(s);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
2015-02-26 23:41:06 +01:00
|
|
|
+ }
|
|
|
|
+ }
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit end
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
|
|
|
+ private void handleCommand(String s) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start - whole method
|
2016-02-29 22:32:46 +01:00
|
|
|
+ this.LOGGER.info(this.player.getName() + " issued server command: " + s);
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
|
|
|
+ CraftPlayer player = this.getPlayer();
|
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
+ PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(player, s, new LazyPlayerSet(minecraftServer));
|
2014-11-25 22:32:16 +01:00
|
|
|
+ this.server.getPluginManager().callEvent(event);
|
|
|
|
+
|
|
|
|
+ if (event.isCancelled()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ if (this.server.dispatchCommand(event.getPlayer(), event.getMessage().substring(1))) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ } catch (org.bukkit.command.CommandException ex) {
|
|
|
|
+ player.sendMessage(org.bukkit.ChatColor.RED + "An internal error occurred while attempting to perform this command");
|
|
|
|
+ java.util.logging.Logger.getLogger(PlayerConnection.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // this.minecraftServer.getCommandHandler().a(this.player, s);
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(PacketPlayInArmAnimation packetplayinarmanimation) {
|
2016-02-29 22:32:46 +01:00
|
|
|
PlayerConnectionUtils.ensureMainThread(packetplayinarmanimation, this, this.player.x());
|
2014-11-25 22:32:16 +01:00
|
|
|
+ if (this.player.dead) return; // CraftBukkit
|
2015-05-05 22:43:47 +02:00
|
|
|
this.player.resetIdleTimer();
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start - Raytrace to look for 'rogue armswings'
|
2014-11-30 13:10:30 +01:00
|
|
|
+ float f1 = this.player.pitch;
|
|
|
|
+ float f2 = this.player.yaw;
|
|
|
|
+ double d0 = this.player.locX;
|
|
|
|
+ double d1 = this.player.locY + (double) this.player.getHeadHeight();
|
|
|
|
+ double d2 = this.player.locZ;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ 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 f5 = -MathHelper.cos(-f1 * 0.017453292F);
|
|
|
|
+ float f6 = MathHelper.sin(-f1 * 0.017453292F);
|
|
|
|
+ float f7 = f4 * f5;
|
|
|
|
+ float f8 = f3 * f5;
|
2015-02-26 23:41:06 +01:00
|
|
|
+ double d3 = player.playerInteractManager.getGameMode() == WorldSettings.EnumGamemode.CREATIVE ? 5.0D : 4.5D;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
|
|
|
|
+ MovingObjectPosition movingobjectposition = this.player.world.rayTrace(vec3d, vec3d1, false);
|
|
|
|
+
|
2015-02-26 23:41:06 +01:00
|
|
|
+ if (movingobjectposition == null || movingobjectposition.type != MovingObjectPosition.EnumMovingObjectType.BLOCK) {
|
2016-03-04 05:24:51 +01:00
|
|
|
+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.inventory.getItemInHand(), EnumHand.MAIN_HAND);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Arm swing animation
|
|
|
|
+ PlayerAnimationEvent event = new PlayerAnimationEvent(this.getPlayer());
|
|
|
|
+ this.server.getPluginManager().callEvent(event);
|
|
|
|
+
|
|
|
|
+ if (event.isCancelled()) return;
|
|
|
|
+ // CraftBukkit end
|
2016-02-29 22:32:46 +01:00
|
|
|
this.player.a(packetplayinarmanimation.a());
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void a(PacketPlayInEntityAction packetplayinentityaction) {
|
2016-02-29 22:32:46 +01:00
|
|
|
PlayerConnectionUtils.ensureMainThread(packetplayinentityaction, this, this.player.x());
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (this.player.dead) return;
|
|
|
|
+ switch (packetplayinentityaction.b()) {
|
|
|
|
+ case START_SNEAKING:
|
2015-02-26 23:41:06 +01:00
|
|
|
+ case STOP_SNEAKING:
|
|
|
|
+ PlayerToggleSneakEvent event = new PlayerToggleSneakEvent(this.getPlayer(), packetplayinentityaction.b() == PacketPlayInEntityAction.EnumPlayerAction.START_SNEAKING);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ this.server.getPluginManager().callEvent(event);
|
|
|
|
+
|
|
|
|
+ if (event.isCancelled()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case START_SPRINTING:
|
2015-02-26 23:41:06 +01:00
|
|
|
+ case STOP_SPRINTING:
|
|
|
|
+ PlayerToggleSprintEvent e2 = new PlayerToggleSprintEvent(this.getPlayer(), packetplayinentityaction.b() == PacketPlayInEntityAction.EnumPlayerAction.START_SPRINTING);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ this.server.getPluginManager().callEvent(e2);
|
|
|
|
+
|
|
|
|
+ if (e2.isCancelled()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ }
|
2015-02-26 23:41:06 +01:00
|
|
|
+ // CraftBukkit end
|
2015-05-05 22:43:47 +02:00
|
|
|
this.player.resetIdleTimer();
|
2016-02-29 22:32:46 +01:00
|
|
|
IJumpable ijumpable;
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2016-03-06 22:33:27 +01:00
|
|
|
@@ -762,6 +1428,7 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
public void a(PacketPlayInUseEntity packetplayinuseentity) {
|
2016-02-29 22:32:46 +01:00
|
|
|
PlayerConnectionUtils.ensureMainThread(packetplayinuseentity, this, this.player.x());
|
2014-11-25 22:32:16 +01:00
|
|
|
+ if (this.player.dead) return; // CraftBukkit
|
|
|
|
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
|
|
|
|
Entity entity = packetplayinuseentity.a((World) worldserver);
|
|
|
|
|
2016-03-06 22:33:27 +01:00
|
|
|
@@ -778,22 +1445,72 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
EnumHand enumhand;
|
|
|
|
ItemStack itemstack;
|
|
|
|
|
|
|
|
+ ItemStack itemInHand = this.player.b(packetplayinuseentity.b() == null ? EnumHand.MAIN_HAND : packetplayinuseentity.b()); // CraftBukkit
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
|
|
|
+ if (packetplayinuseentity.a() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT
|
|
|
|
+ || packetplayinuseentity.a() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT_AT) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ boolean triggerLeashUpdate = itemInHand != null && itemInHand.getItem() == Items.LEAD && entity instanceof EntityInsentient;
|
2015-04-15 18:35:14 +02:00
|
|
|
+ Item origItem = this.player.inventory.getItemInHand() == null ? null : this.player.inventory.getItemInHand().getItem();
|
2014-11-25 22:32:16 +01:00
|
|
|
+ PlayerInteractEntityEvent event;
|
2015-02-26 23:41:06 +01:00
|
|
|
+ if (packetplayinuseentity.a() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT) {
|
2016-03-04 05:24:51 +01:00
|
|
|
+ event = new PlayerInteractEntityEvent((Player) this.getPlayer(), entity.getBukkitEntity(), (packetplayinuseentity.b() == EnumHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ } else {
|
2016-02-29 22:32:46 +01:00
|
|
|
+ Vec3D target = packetplayinuseentity.c();
|
2016-03-04 05:24:51 +01:00
|
|
|
+ event = new PlayerInteractAtEntityEvent((Player) this.getPlayer(), entity.getBukkitEntity(), new org.bukkit.util.Vector(target.x, target.y, target.z), (packetplayinuseentity.b() == EnumHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+ this.server.getPluginManager().callEvent(event);
|
|
|
|
+
|
|
|
|
+ if (triggerLeashUpdate && (event.isCancelled() || this.player.inventory.getItemInHand() == null || this.player.inventory.getItemInHand().getItem() != Items.LEAD)) {
|
|
|
|
+ // Refresh the current leash state
|
2016-02-29 22:32:46 +01:00
|
|
|
+ this.sendPacket(new PacketPlayOutAttachEntity(entity, ((EntityInsentient) entity).getLeashHolder()));
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+
|
2015-04-15 18:35:14 +02:00
|
|
|
+ if (event.isCancelled() || this.player.inventory.getItemInHand() == null || this.player.inventory.getItemInHand().getItem() != origItem) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // Refresh the current entity metadata
|
|
|
|
+ this.sendPacket(new PacketPlayOutEntityMetadata(entity.getId(), entity.datawatcher, true));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (event.isCancelled()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
+ }
|
2016-02-29 22:32:46 +01:00
|
|
|
+
|
2015-02-26 23:41:06 +01:00
|
|
|
if (packetplayinuseentity.a() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT) {
|
2016-02-29 22:32:46 +01:00
|
|
|
enumhand = packetplayinuseentity.b();
|
|
|
|
itemstack = this.player.b(enumhand);
|
|
|
|
this.player.a(entity, itemstack, enumhand);
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (itemInHand != null && itemInHand.count <= -1) {
|
|
|
|
+ this.player.updateInventory(this.player.activeContainer);
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2015-02-26 23:41:06 +01:00
|
|
|
} else if (packetplayinuseentity.a() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT_AT) {
|
2016-02-29 22:32:46 +01:00
|
|
|
enumhand = packetplayinuseentity.b();
|
|
|
|
itemstack = this.player.b(enumhand);
|
|
|
|
entity.a((EntityHuman) this.player, packetplayinuseentity.c(), itemstack, enumhand);
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (itemInHand != null && itemInHand.count <= -1) {
|
|
|
|
+ this.player.updateInventory(this.player.activeContainer);
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2015-02-26 23:41:06 +01:00
|
|
|
} else if (packetplayinuseentity.a() == PacketPlayInUseEntity.EnumEntityUseAction.ATTACK) {
|
2014-11-25 22:32:16 +01:00
|
|
|
- if (entity instanceof EntityItem || entity instanceof EntityExperienceOrb || entity instanceof EntityArrow || entity == this.player) {
|
2015-05-05 22:43:47 +02:00
|
|
|
+ if (entity instanceof EntityItem || entity instanceof EntityExperienceOrb || entity instanceof EntityArrow || (entity == this.player && !player.isSpectator())) { // CraftBukkit
|
2014-11-25 22:32:16 +01:00
|
|
|
this.disconnect("Attempting to attack an invalid entity");
|
|
|
|
this.minecraftServer.warning("Player " + this.player.getName() + " tried to attack an invalid entity");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.player.attack(entity);
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (itemInHand != null && itemInHand.count <= -1) {
|
|
|
|
+ this.player.updateInventory(this.player.activeContainer);
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-03-06 22:33:27 +01:00
|
|
|
@@ -809,7 +1526,8 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
case 1:
|
|
|
|
if (this.player.viewingCredits) {
|
2016-02-29 22:32:46 +01:00
|
|
|
this.player.viewingCredits = false;
|
2014-11-25 22:32:16 +01:00
|
|
|
- this.player = this.minecraftServer.getPlayerList().moveToWorld(this.player, 0, true);
|
|
|
|
+ // this.player = this.minecraftServer.getPlayerList().moveToWorld(this.player, 0, true);
|
|
|
|
+ this.minecraftServer.getPlayerList().changeDimension(this.player, 0, PlayerTeleportEvent.TeleportCause.END_PORTAL); // CraftBukkit - reroute logic through custom portal management
|
2016-02-29 22:32:46 +01:00
|
|
|
} else {
|
|
|
|
if (this.player.getHealth() > 0.0F) {
|
|
|
|
return;
|
2016-03-06 22:33:27 +01:00
|
|
|
@@ -835,14 +1553,20 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
public void a(PacketPlayInCloseWindow packetplayinclosewindow) {
|
2016-02-29 22:32:46 +01:00
|
|
|
PlayerConnectionUtils.ensureMainThread(packetplayinclosewindow, this, this.player.x());
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
+ if (this.player.dead) return; // CraftBukkit
|
2014-11-25 22:32:16 +01:00
|
|
|
+ CraftEventFactory.handleInventoryCloseEvent(this.player); // CraftBukkit
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
this.player.s();
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void a(PacketPlayInWindowClick packetplayinwindowclick) {
|
2016-02-29 22:32:46 +01:00
|
|
|
PlayerConnectionUtils.ensureMainThread(packetplayinwindowclick, this, this.player.x());
|
2014-11-25 22:32:16 +01:00
|
|
|
+ if (this.player.dead) return; // CraftBukkit
|
2015-05-05 22:43:47 +02:00
|
|
|
this.player.resetIdleTimer();
|
2014-11-25 22:32:16 +01:00
|
|
|
if (this.player.activeContainer.windowId == packetplayinwindowclick.a() && this.player.activeContainer.c(this.player)) {
|
2015-05-05 22:43:47 +02:00
|
|
|
- if (this.player.isSpectator()) {
|
|
|
|
+ boolean cancelled = this.player.isSpectator(); // CraftBukkit - see below if
|
2016-02-29 22:32:46 +01:00
|
|
|
+ if (false/*this.player.isSpectator()*/) { // CraftBukkit
|
2015-01-04 21:23:54 +01:00
|
|
|
ArrayList arraylist = Lists.newArrayList();
|
|
|
|
|
|
|
|
for (int i = 0; i < this.player.activeContainer.c.size(); ++i) {
|
2016-03-06 22:33:27 +01:00
|
|
|
@@ -851,8 +1575,275 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
this.player.a(this.player.activeContainer, (List) arraylist);
|
|
|
|
} else {
|
2016-02-29 22:32:46 +01:00
|
|
|
- ItemStack itemstack = this.player.activeContainer.a(packetplayinwindowclick.b(), packetplayinwindowclick.c(), packetplayinwindowclick.f(), this.player);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start - Call InventoryClickEvent
|
|
|
|
+ if (packetplayinwindowclick.b() < -1 && packetplayinwindowclick.b() != -999) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ InventoryView inventory = this.player.activeContainer.getBukkitView();
|
|
|
|
+ SlotType type = CraftInventoryView.getSlotType(inventory, packetplayinwindowclick.b());
|
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
+ InventoryClickEvent event;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ ClickType click = ClickType.UNKNOWN;
|
|
|
|
+ InventoryAction action = InventoryAction.UNKNOWN;
|
|
|
|
+
|
|
|
|
+ ItemStack itemstack = null;
|
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
+ switch (packetplayinwindowclick.f()) {
|
|
|
|
+ case PICKUP:
|
|
|
|
+ if (packetplayinwindowclick.c() == 0) {
|
|
|
|
+ click = ClickType.LEFT;
|
|
|
|
+ } else if (packetplayinwindowclick.c() == 1) {
|
|
|
|
+ click = ClickType.RIGHT;
|
|
|
|
+ }
|
|
|
|
+ if (packetplayinwindowclick.c() == 0 || packetplayinwindowclick.c() == 1) {
|
|
|
|
+ action = InventoryAction.NOTHING; // Don't want to repeat ourselves
|
|
|
|
+ if (packetplayinwindowclick.b() == -999) {
|
|
|
|
+ if (player.inventory.getCarried() != null) {
|
|
|
|
+ action = packetplayinwindowclick.c() == 0 ? InventoryAction.DROP_ALL_CURSOR : InventoryAction.DROP_ONE_CURSOR;
|
|
|
|
+ }
|
2016-03-01 03:52:34 +01:00
|
|
|
+ } else if (packetplayinwindowclick.b() < 0) {
|
|
|
|
+ action = InventoryAction.NOTHING;
|
2016-02-29 22:32:46 +01:00
|
|
|
+ } else {
|
|
|
|
+ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.b());
|
|
|
|
+ if (slot != null) {
|
|
|
|
+ ItemStack clickedItem = slot.getItem();
|
|
|
|
+ ItemStack cursor = player.inventory.getCarried();
|
|
|
|
+ if (clickedItem == null) {
|
|
|
|
+ if (cursor != null) {
|
|
|
|
+ action = packetplayinwindowclick.c() == 0 ? InventoryAction.PLACE_ALL : InventoryAction.PLACE_ONE;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
2016-02-29 22:32:46 +01:00
|
|
|
+ } else if (slot.isAllowed(player)) {
|
|
|
|
+ if (cursor == null) {
|
|
|
|
+ action = packetplayinwindowclick.c() == 0 ? InventoryAction.PICKUP_ALL : InventoryAction.PICKUP_HALF;
|
|
|
|
+ } else if (slot.isAllowed(cursor)) {
|
|
|
|
+ if (clickedItem.doMaterialsMatch(cursor) && ItemStack.equals(clickedItem, cursor)) {
|
|
|
|
+ int toPlace = packetplayinwindowclick.c() == 0 ? cursor.count : 1;
|
|
|
|
+ toPlace = Math.min(toPlace, clickedItem.getMaxStackSize() - clickedItem.count);
|
|
|
|
+ toPlace = Math.min(toPlace, slot.inventory.getMaxStackSize() - clickedItem.count);
|
|
|
|
+ if (toPlace == 1) {
|
|
|
|
+ action = InventoryAction.PLACE_ONE;
|
|
|
|
+ } else if (toPlace == cursor.count) {
|
|
|
|
+ action = InventoryAction.PLACE_ALL;
|
|
|
|
+ } else if (toPlace < 0) {
|
|
|
|
+ action = toPlace != -1 ? InventoryAction.PICKUP_SOME : InventoryAction.PICKUP_ONE; // this happens with oversized stacks
|
|
|
|
+ } else if (toPlace != 0) {
|
|
|
|
+ action = InventoryAction.PLACE_SOME;
|
|
|
|
+ }
|
|
|
|
+ } else if (cursor.count <= slot.getMaxStackSize()) {
|
|
|
|
+ action = InventoryAction.SWAP_WITH_CURSOR;
|
|
|
|
+ }
|
|
|
|
+ } else if (cursor.getItem() == clickedItem.getItem() && (!cursor.usesData() || cursor.getData() == clickedItem.getData()) && ItemStack.equals(cursor, clickedItem)) {
|
|
|
|
+ if (clickedItem.count >= 0) {
|
|
|
|
+ if (clickedItem.count + cursor.count <= cursor.getMaxStackSize()) {
|
|
|
|
+ // As of 1.5, this is result slots only
|
|
|
|
+ action = InventoryAction.PICKUP_ALL;
|
|
|
|
+ }
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
2016-02-29 22:32:46 +01:00
|
|
|
+ break;
|
|
|
|
+ // TODO check on updates
|
|
|
|
+ case QUICK_MOVE:
|
|
|
|
+ if (packetplayinwindowclick.c() == 0) {
|
|
|
|
+ click = ClickType.SHIFT_LEFT;
|
|
|
|
+ } else if (packetplayinwindowclick.c() == 1) {
|
|
|
|
+ click = ClickType.SHIFT_RIGHT;
|
|
|
|
+ }
|
|
|
|
+ if (packetplayinwindowclick.c() == 0 || packetplayinwindowclick.c() == 1) {
|
|
|
|
+ if (packetplayinwindowclick.b() < 0) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ action = InventoryAction.NOTHING;
|
2016-02-29 22:32:46 +01:00
|
|
|
+ } else {
|
|
|
|
+ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.b());
|
|
|
|
+ if (slot != null && slot.isAllowed(this.player) && slot.hasItem()) {
|
|
|
|
+ action = InventoryAction.MOVE_TO_OTHER_INVENTORY;
|
|
|
|
+ } else {
|
|
|
|
+ action = InventoryAction.NOTHING;
|
|
|
|
+ }
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+ }
|
2016-02-29 22:32:46 +01:00
|
|
|
+ break;
|
|
|
|
+ case SWAP:
|
|
|
|
+ if (packetplayinwindowclick.c() >= 0 && packetplayinwindowclick.c() < 9) {
|
|
|
|
+ click = ClickType.NUMBER_KEY;
|
|
|
|
+ Slot clickedSlot = this.player.activeContainer.getSlot(packetplayinwindowclick.b());
|
|
|
|
+ if (clickedSlot.isAllowed(player)) {
|
|
|
|
+ ItemStack hotbar = this.player.inventory.getItem(packetplayinwindowclick.c());
|
|
|
|
+ boolean canCleanSwap = hotbar == null || (clickedSlot.inventory == player.inventory && clickedSlot.isAllowed(hotbar)); // the slot will accept the hotbar item
|
|
|
|
+ if (clickedSlot.hasItem()) {
|
|
|
|
+ if (canCleanSwap) {
|
|
|
|
+ action = InventoryAction.HOTBAR_SWAP;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ } else {
|
2016-02-29 22:32:46 +01:00
|
|
|
+ int firstEmptySlot = player.inventory.getFirstEmptySlotIndex();
|
|
|
|
+ if (firstEmptySlot > -1) {
|
|
|
|
+ action = InventoryAction.HOTBAR_MOVE_AND_READD;
|
|
|
|
+ } else {
|
|
|
|
+ action = InventoryAction.NOTHING; // This is not sane! Mojang: You should test for other slots of same type
|
|
|
|
+ }
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
2016-02-29 22:32:46 +01:00
|
|
|
+ } else if (!clickedSlot.hasItem() && hotbar != null && clickedSlot.isAllowed(hotbar)) {
|
|
|
|
+ action = InventoryAction.HOTBAR_SWAP;
|
|
|
|
+ } else {
|
|
|
|
+ action = InventoryAction.NOTHING;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ action = InventoryAction.NOTHING;
|
|
|
|
+ }
|
|
|
|
+ }
|
2016-02-29 22:32:46 +01:00
|
|
|
+ break;
|
|
|
|
+ case CLONE:
|
|
|
|
+ if (packetplayinwindowclick.c() == 2) {
|
|
|
|
+ click = ClickType.MIDDLE;
|
|
|
|
+ if (packetplayinwindowclick.b() == -999) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ action = InventoryAction.NOTHING;
|
2016-02-29 22:32:46 +01:00
|
|
|
+ } else {
|
|
|
|
+ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.b());
|
|
|
|
+ if (slot != null && slot.hasItem() && player.abilities.canInstantlyBuild && player.inventory.getCarried() == null) {
|
|
|
|
+ action = InventoryAction.CLONE_STACK;
|
|
|
|
+ } else {
|
|
|
|
+ action = InventoryAction.NOTHING;
|
|
|
|
+ }
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
2016-02-29 22:32:46 +01:00
|
|
|
+ } else {
|
|
|
|
+ click = ClickType.UNKNOWN;
|
|
|
|
+ action = InventoryAction.UNKNOWN;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
2016-02-29 22:32:46 +01:00
|
|
|
+ break;
|
|
|
|
+ case THROW:
|
|
|
|
+ if (packetplayinwindowclick.b() >= 0) {
|
|
|
|
+ if (packetplayinwindowclick.c() == 0) {
|
|
|
|
+ click = ClickType.DROP;
|
|
|
|
+ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.b());
|
|
|
|
+ if (slot != null && slot.hasItem() && slot.isAllowed(player) && slot.getItem() != null && slot.getItem().getItem() != Item.getItemOf(Blocks.AIR)) {
|
|
|
|
+ action = InventoryAction.DROP_ONE_SLOT;
|
|
|
|
+ } else {
|
|
|
|
+ action = InventoryAction.NOTHING;
|
|
|
|
+ }
|
|
|
|
+ } else if (packetplayinwindowclick.c() == 1) {
|
|
|
|
+ click = ClickType.CONTROL_DROP;
|
|
|
|
+ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.b());
|
|
|
|
+ if (slot != null && slot.hasItem() && slot.isAllowed(player) && slot.getItem() != null && slot.getItem().getItem() != Item.getItemOf(Blocks.AIR)) {
|
|
|
|
+ action = InventoryAction.DROP_ALL_SLOT;
|
|
|
|
+ } else {
|
|
|
|
+ action = InventoryAction.NOTHING;
|
|
|
|
+ }
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
2016-02-29 22:32:46 +01:00
|
|
|
+ } else {
|
|
|
|
+ // Sane default (because this happens when they are holding nothing. Don't ask why.)
|
|
|
|
+ click = ClickType.LEFT;
|
|
|
|
+ if (packetplayinwindowclick.c() == 1) {
|
|
|
|
+ click = ClickType.RIGHT;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
2016-02-29 22:32:46 +01:00
|
|
|
+ action = InventoryAction.NOTHING;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
2016-02-29 22:32:46 +01:00
|
|
|
+ break;
|
|
|
|
+ case QUICK_CRAFT:
|
|
|
|
+ itemstack = this.player.activeContainer.a(packetplayinwindowclick.b(), packetplayinwindowclick.c(), packetplayinwindowclick.f(), this.player);
|
|
|
|
+ break;
|
|
|
|
+ case PICKUP_ALL:
|
|
|
|
+ click = ClickType.DOUBLE_CLICK;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ action = InventoryAction.NOTHING;
|
2016-02-29 22:32:46 +01:00
|
|
|
+ if (packetplayinwindowclick.b() >= 0 && this.player.inventory.getCarried() != null) {
|
|
|
|
+ ItemStack cursor = this.player.inventory.getCarried();
|
|
|
|
+ action = InventoryAction.NOTHING;
|
|
|
|
+ // Quick check for if we have any of the item
|
|
|
|
+ if (inventory.getTopInventory().contains(org.bukkit.Material.getMaterial(Item.getId(cursor.getItem()))) || inventory.getBottomInventory().contains(org.bukkit.Material.getMaterial(Item.getId(cursor.getItem())))) {
|
|
|
|
+ action = InventoryAction.COLLECT_TO_CURSOR;
|
|
|
|
+ }
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
2016-02-29 22:32:46 +01:00
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ break;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
+ if (packetplayinwindowclick.f() != InventoryClickType.QUICK_CRAFT) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ if (click == ClickType.NUMBER_KEY) {
|
|
|
|
+ event = new InventoryClickEvent(inventory, type, packetplayinwindowclick.b(), click, action, packetplayinwindowclick.c());
|
|
|
|
+ } else {
|
|
|
|
+ event = new InventoryClickEvent(inventory, type, packetplayinwindowclick.b(), click, action);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ org.bukkit.inventory.Inventory top = inventory.getTopInventory();
|
|
|
|
+ if (packetplayinwindowclick.b() == 0 && top instanceof CraftingInventory) {
|
|
|
|
+ org.bukkit.inventory.Recipe recipe = ((CraftingInventory) top).getRecipe();
|
|
|
|
+ if (recipe != null) {
|
|
|
|
+ if (click == ClickType.NUMBER_KEY) {
|
|
|
|
+ event = new CraftItemEvent(recipe, inventory, type, packetplayinwindowclick.b(), click, action, packetplayinwindowclick.c());
|
|
|
|
+ } else {
|
|
|
|
+ event = new CraftItemEvent(recipe, inventory, type, packetplayinwindowclick.b(), click, action);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
2016-03-06 22:33:27 +01:00
|
|
|
|
2015-01-04 21:23:54 +01:00
|
|
|
+ event.setCancelled(cancelled);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ server.getPluginManager().callEvent(event);
|
2016-03-06 22:33:27 +01:00
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
+ switch (event.getResult()) {
|
|
|
|
+ case ALLOW:
|
|
|
|
+ case DEFAULT:
|
2016-02-29 22:32:46 +01:00
|
|
|
+ itemstack = this.player.activeContainer.a(packetplayinwindowclick.b(), packetplayinwindowclick.c(), packetplayinwindowclick.f(), this.player);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ break;
|
|
|
|
+ case DENY:
|
|
|
|
+ /* Needs enum constructor in InventoryAction
|
|
|
|
+ if (action.modifiesOtherSlots()) {
|
2016-02-29 23:58:55 +01:00
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
+ } else {
|
|
|
|
+ if (action.modifiesCursor()) {
|
|
|
|
+ this.player.playerConnection.sendPacket(new Packet103SetSlot(-1, -1, this.player.inventory.getCarried()));
|
|
|
|
+ }
|
|
|
|
+ if (action.modifiesClicked()) {
|
|
|
|
+ this.player.playerConnection.sendPacket(new Packet103SetSlot(this.player.activeContainer.windowId, packet102windowclick.slot, this.player.activeContainer.getSlot(packet102windowclick.slot).getItem()));
|
|
|
|
+ }
|
|
|
|
+ }*/
|
|
|
|
+ switch (action) {
|
|
|
|
+ // Modified other slots
|
|
|
|
+ case PICKUP_ALL:
|
|
|
|
+ case MOVE_TO_OTHER_INVENTORY:
|
|
|
|
+ case HOTBAR_MOVE_AND_READD:
|
|
|
|
+ case HOTBAR_SWAP:
|
|
|
|
+ case COLLECT_TO_CURSOR:
|
|
|
|
+ case UNKNOWN:
|
|
|
|
+ this.player.updateInventory(this.player.activeContainer);
|
|
|
|
+ break;
|
|
|
|
+ // Modified cursor and clicked
|
|
|
|
+ case PICKUP_SOME:
|
|
|
|
+ case PICKUP_HALF:
|
|
|
|
+ case PICKUP_ONE:
|
|
|
|
+ case PLACE_ALL:
|
|
|
|
+ case PLACE_SOME:
|
|
|
|
+ case PLACE_ONE:
|
|
|
|
+ case SWAP_WITH_CURSOR:
|
|
|
|
+ this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.player.inventory.getCarried()));
|
|
|
|
+ this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot(this.player.activeContainer.windowId, packetplayinwindowclick.b(), this.player.activeContainer.getSlot(packetplayinwindowclick.b()).getItem()));
|
|
|
|
+ break;
|
|
|
|
+ // Modified clicked only
|
|
|
|
+ case DROP_ALL_SLOT:
|
|
|
|
+ case DROP_ONE_SLOT:
|
|
|
|
+ this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot(this.player.activeContainer.windowId, packetplayinwindowclick.b(), this.player.activeContainer.getSlot(packetplayinwindowclick.b()).getItem()));
|
|
|
|
+ break;
|
|
|
|
+ // Modified cursor only
|
|
|
|
+ case DROP_ALL_CURSOR:
|
|
|
|
+ case DROP_ONE_CURSOR:
|
|
|
|
+ case CLONE_STACK:
|
|
|
|
+ this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.player.inventory.getCarried()));
|
|
|
|
+ break;
|
|
|
|
+ // Nothing
|
|
|
|
+ case NOTHING:
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ return;
|
|
|
|
+ }
|
2014-12-05 16:04:01 +01:00
|
|
|
+
|
|
|
|
+ if (event instanceof CraftItemEvent) {
|
|
|
|
+ // Need to update the inventory on crafting to
|
|
|
|
+ // correctly support custom recipes
|
|
|
|
+ player.updateInventory(player.activeContainer);
|
|
|
|
+ }
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
if (ItemStack.matches(packetplayinwindowclick.e(), itemstack)) {
|
|
|
|
this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.a(), packetplayinwindowclick.d(), true));
|
2016-02-29 22:32:46 +01:00
|
|
|
this.player.f = true;
|
2016-03-06 22:33:27 +01:00
|
|
|
@@ -915,8 +1906,48 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
boolean flag1 = packetplayinsetcreativeslot.a() >= 1 && packetplayinsetcreativeslot.a() <= 45;
|
2014-11-25 22:32:16 +01:00
|
|
|
- boolean flag2 = itemstack == null || itemstack.getItem() != null;
|
|
|
|
+ // CraftBukkit - Add invalidItems check
|
|
|
|
+ boolean flag2 = itemstack == null || itemstack.getItem() != null && !invalidItems.contains(Item.getId(itemstack.getItem()));
|
|
|
|
boolean flag3 = itemstack == null || itemstack.getData() >= 0 && itemstack.count <= 64 && itemstack.count > 0;
|
|
|
|
+ // CraftBukkit start - Call click event
|
|
|
|
+ if (flag || (flag1 && !ItemStack.matches(this.player.defaultContainer.getSlot(packetplayinsetcreativeslot.a()).getItem(), packetplayinsetcreativeslot.getItemStack()))) { // Insist on valid slot
|
|
|
|
+
|
|
|
|
+ org.bukkit.entity.HumanEntity player = this.player.getBukkitEntity();
|
|
|
|
+ InventoryView inventory = new CraftInventoryView(player, player.getInventory(), this.player.defaultContainer);
|
|
|
|
+ org.bukkit.inventory.ItemStack item = CraftItemStack.asBukkitCopy(packetplayinsetcreativeslot.getItemStack());
|
|
|
|
+
|
|
|
|
+ SlotType type = SlotType.QUICKBAR;
|
|
|
|
+ if (flag) {
|
|
|
|
+ type = SlotType.OUTSIDE;
|
|
|
|
+ } else if (packetplayinsetcreativeslot.a() < 36) {
|
|
|
|
+ if (packetplayinsetcreativeslot.a() >= 5 && packetplayinsetcreativeslot.a() < 9) {
|
|
|
|
+ type = SlotType.ARMOR;
|
|
|
|
+ } else {
|
|
|
|
+ type = SlotType.CONTAINER;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ InventoryCreativeEvent event = new InventoryCreativeEvent(inventory, type, flag ? -999 : packetplayinsetcreativeslot.a(), item);
|
|
|
|
+ server.getPluginManager().callEvent(event);
|
|
|
|
+
|
|
|
|
+ itemstack = CraftItemStack.asNMSCopy(event.getCursor());
|
|
|
|
+
|
|
|
|
+ switch (event.getResult()) {
|
|
|
|
+ case ALLOW:
|
|
|
|
+ // Plugin cleared the id / stacksize checks
|
|
|
|
+ flag2 = flag3 = true;
|
|
|
|
+ break;
|
|
|
|
+ case DEFAULT:
|
|
|
|
+ break;
|
|
|
|
+ case DENY:
|
|
|
|
+ // Reset the slot
|
|
|
|
+ if (packetplayinsetcreativeslot.a() >= 0) {
|
|
|
|
+ this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot(this.player.defaultContainer.windowId, packetplayinsetcreativeslot.a(), this.player.defaultContainer.getSlot(packetplayinsetcreativeslot.a()).getItem()));
|
|
|
|
+ this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, null));
|
|
|
|
+ }
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
|
|
|
|
if (flag1 && flag2 && flag3) {
|
|
|
|
if (itemstack == null) {
|
2016-03-06 22:33:27 +01:00
|
|
|
@@ -940,6 +1971,7 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
public void a(PacketPlayInTransaction packetplayintransaction) {
|
2016-02-29 22:32:46 +01:00
|
|
|
PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.x());
|
2014-11-25 22:32:16 +01:00
|
|
|
+ if (this.player.dead) return; // CraftBukkit
|
2016-02-29 22:32:46 +01:00
|
|
|
Short oshort = (Short) this.k.get(this.player.activeContainer.windowId);
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
if (oshort != null && packetplayintransaction.b() == oshort.shortValue() && this.player.activeContainer.windowId == packetplayintransaction.a() && !this.player.activeContainer.c(this.player) && !this.player.isSpectator()) {
|
2016-03-06 22:33:27 +01:00
|
|
|
@@ -950,6 +1982,7 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
public void a(PacketPlayInUpdateSign packetplayinupdatesign) {
|
2016-02-29 22:32:46 +01:00
|
|
|
PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.x());
|
2014-11-25 22:32:16 +01:00
|
|
|
+ if (this.player.dead) return; // CraftBukkit
|
2015-05-05 22:43:47 +02:00
|
|
|
this.player.resetIdleTimer();
|
2014-11-25 22:32:16 +01:00
|
|
|
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
|
2016-02-29 22:32:46 +01:00
|
|
|
BlockPosition blockposition = packetplayinupdatesign.a();
|
2016-03-06 22:33:27 +01:00
|
|
|
@@ -966,14 +1999,30 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
if (!tileentitysign.b() || tileentitysign.c() != this.player) {
|
|
|
|
this.minecraftServer.warning("Player " + this.player.getName() + " just tried to change non-editable sign");
|
|
|
|
+ this.sendPacket(new PacketPlayOutUpdateSign(tileentity.world, packetplayinupdatesign.a(), tileentitysign.lines)); // CraftBukkit
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
String[] astring = packetplayinupdatesign.b();
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ Player player = this.server.getPlayer(this.player);
|
|
|
|
+ int x = packetplayinupdatesign.a().getX();
|
|
|
|
+ int y = packetplayinupdatesign.a().getY();
|
|
|
|
+ int z = packetplayinupdatesign.a().getZ();
|
2015-02-26 23:41:06 +01:00
|
|
|
+ String[] lines = new String[4];
|
2015-06-05 12:57:48 +02:00
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
for (int i = 0; i < astring.length; ++i) {
|
|
|
|
- tileentitysign.lines[i] = new ChatComponentText(EnumChatFormat.a(astring[i]));
|
|
|
|
+ lines[i] = EnumChatFormat.a(new ChatComponentText(EnumChatFormat.a(astring[i])).toPlainText());
|
2015-06-05 12:57:48 +02:00
|
|
|
}
|
2015-02-26 23:41:06 +01:00
|
|
|
+ SignChangeEvent event = new SignChangeEvent((org.bukkit.craftbukkit.block.CraftBlock) player.getWorld().getBlockAt(x, y, z), this.server.getPlayer(this.player), lines);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ this.server.getPluginManager().callEvent(event);
|
|
|
|
+
|
|
|
|
+ if (!event.isCancelled()) {
|
|
|
|
+ System.arraycopy(org.bukkit.craftbukkit.block.CraftSign.sanitizeLines(event.getLines()), 0, tileentitysign.lines, 0, 4);
|
|
|
|
+ tileentitysign.isEditable = false;
|
2015-06-05 12:57:48 +02:00
|
|
|
+ }
|
2015-02-26 23:41:06 +01:00
|
|
|
+ // CraftBukkit end
|
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
tileentitysign.update();
|
2016-02-29 22:32:46 +01:00
|
|
|
worldserver.notify(blockposition, iblockdata, iblockdata, 3);
|
2016-03-06 22:33:27 +01:00
|
|
|
@@ -996,11 +2045,27 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
public void a(PacketPlayInAbilities packetplayinabilities) {
|
2016-02-29 22:32:46 +01:00
|
|
|
PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.x());
|
2014-11-25 22:32:16 +01:00
|
|
|
- this.player.abilities.isFlying = packetplayinabilities.isFlying() && this.player.abilities.canFly;
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (this.player.abilities.canFly && this.player.abilities.isFlying != packetplayinabilities.isFlying()) {
|
|
|
|
+ PlayerToggleFlightEvent event = new PlayerToggleFlightEvent(this.server.getPlayer(this.player), packetplayinabilities.isFlying());
|
|
|
|
+ this.server.getPluginManager().callEvent(event);
|
|
|
|
+ if (!event.isCancelled()) {
|
|
|
|
+ this.player.abilities.isFlying = packetplayinabilities.isFlying(); // Actually set the player's flying status
|
|
|
|
+ } else {
|
|
|
|
+ this.player.updateAbilities(); // Tell the player their ability was reverted
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(PacketPlayInTabComplete packetplayintabcomplete) {
|
2016-02-29 22:32:46 +01:00
|
|
|
PlayerConnectionUtils.ensureMainThread(packetplayintabcomplete, this, this.player.x());
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
2015-02-20 05:17:38 +01:00
|
|
|
+ if (chatSpamField.addAndGet(this, 10) > 500 && !this.minecraftServer.getPlayerList().isOp(this.player.getProfile())) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ this.disconnect("disconnect.spam");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
ArrayList arraylist = Lists.newArrayList();
|
2016-02-29 22:32:46 +01:00
|
|
|
Iterator iterator = this.minecraftServer.tabCompleteCommand(this.player, packetplayintabcomplete.a(), packetplayintabcomplete.b(), packetplayintabcomplete.c()).iterator();
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2016-03-06 22:33:27 +01:00
|
|
|
@@ -1334,12 +2399,34 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
packetdataserializer.release();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ else if (packetplayincustompayload.a().equals("REGISTER")) {
|
|
|
|
+ String channels = packetplayincustompayload.b().toString(com.google.common.base.Charsets.UTF_8);
|
|
|
|
+ for (String channel : channels.split("\0")) {
|
|
|
|
+ getPlayer().addChannel(channel);
|
|
|
|
+ }
|
|
|
|
+ } else if (packetplayincustompayload.a().equals("UNREGISTER")) {
|
|
|
|
+ String channels = packetplayincustompayload.b().toString(com.google.common.base.Charsets.UTF_8);
|
|
|
|
+ for (String channel : channels.split("\0")) {
|
|
|
|
+ getPlayer().removeChannel(channel);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ byte[] data = new byte[packetplayincustompayload.b().readableBytes()];
|
|
|
|
+ packetplayincustompayload.b().readBytes(data);
|
|
|
|
+ server.getMessenger().dispatchIncomingMessage(player.getBukkitEntity(), packetplayincustompayload.a(), data);
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-02-29 23:58:55 +01:00
|
|
|
|
|
|
|
}
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
+ // CraftBukkit start - Add "isDisconnected" method
|
|
|
|
+ public final boolean isDisconnected() {
|
2016-02-29 22:32:46 +01:00
|
|
|
+ return !this.player.joining && !this.networkManager.isConnected();
|
2016-02-29 23:58:55 +01:00
|
|
|
+ }
|
|
|
|
+
|
2015-02-26 23:41:06 +01:00
|
|
|
static class SyntheticClass_1 {
|
2016-02-29 23:58:55 +01:00
|
|
|
|
|
|
|
static final int[] a;
|