2010-12-28 22:52:39 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Map;
|
2010-12-28 22:52:39 +01:00
|
|
|
import java.util.logging.Logger;
|
2011-01-08 11:49:42 +01:00
|
|
|
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit start
|
2011-02-18 17:25:56 +01:00
|
|
|
import org.bukkit.ChatColor;
|
2010-12-29 02:25:32 +01:00
|
|
|
import org.bukkit.Location;
|
2011-02-18 17:25:56 +01:00
|
|
|
import org.bukkit.command.CommandException;
|
2011-01-15 22:40:18 +01:00
|
|
|
import org.bukkit.craftbukkit.block.CraftBlock;
|
2011-01-15 22:23:28 +01:00
|
|
|
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
2011-03-23 12:22:13 +01:00
|
|
|
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
2010-12-28 22:52:39 +01:00
|
|
|
import org.bukkit.craftbukkit.CraftServer;
|
2011-04-25 18:14:06 +02:00
|
|
|
import org.bukkit.craftbukkit.TextWrapper;
|
2011-01-23 13:23:13 +01:00
|
|
|
import org.bukkit.entity.Player;
|
2011-03-24 23:27:40 +01:00
|
|
|
import org.bukkit.event.Event;
|
2011-06-27 00:25:01 +02:00
|
|
|
import org.bukkit.event.block.Action;
|
|
|
|
import org.bukkit.event.block.SignChangeEvent;
|
|
|
|
import org.bukkit.event.player.PlayerAnimationEvent;
|
|
|
|
import org.bukkit.event.player.PlayerChatEvent;
|
|
|
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
|
|
|
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
|
|
|
import org.bukkit.event.player.PlayerInteractEvent;
|
|
|
|
import org.bukkit.event.player.PlayerItemHeldEvent;
|
|
|
|
import org.bukkit.event.player.PlayerKickEvent;
|
|
|
|
import org.bukkit.event.player.PlayerMoveEvent;
|
|
|
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
|
|
|
import org.bukkit.event.player.PlayerToggleSneakEvent;
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit end
|
2010-12-28 22:52:39 +01:00
|
|
|
|
2011-01-11 09:25:13 +01:00
|
|
|
public class NetServerHandler extends NetHandler implements ICommandListener {
|
2010-12-28 22:52:39 +01:00
|
|
|
|
|
|
|
public static Logger a = Logger.getLogger("Minecraft");
|
2011-04-20 19:05:14 +02:00
|
|
|
public NetworkManager networkManager;
|
|
|
|
public boolean disconnected = false;
|
|
|
|
private MinecraftServer minecraftServer;
|
2011-05-14 16:29:42 +02:00
|
|
|
public EntityPlayer player; // CraftBukkit - private -> public
|
2011-02-23 03:37:56 +01:00
|
|
|
private int f;
|
|
|
|
private int g;
|
2011-04-20 22:47:26 +02:00
|
|
|
private int h;
|
|
|
|
private boolean i;
|
2011-04-20 19:05:14 +02:00
|
|
|
private double x;
|
|
|
|
private double y;
|
|
|
|
private double z;
|
2011-06-27 00:25:01 +02:00
|
|
|
private boolean checkMovement = true;
|
2011-04-20 22:47:26 +02:00
|
|
|
private Map n = new HashMap();
|
2011-01-11 09:25:13 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public NetServerHandler(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayer entityplayer) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.minecraftServer = minecraftserver;
|
|
|
|
this.networkManager = networkmanager;
|
2011-01-29 22:50:29 +01:00
|
|
|
networkmanager.a((NetHandler) this);
|
2011-04-20 19:05:14 +02:00
|
|
|
this.player = entityplayer;
|
|
|
|
entityplayer.netServerHandler = this;
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
// CraftBukkit start
|
2011-06-27 00:25:01 +02:00
|
|
|
this.server = minecraftserver.server;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
2010-12-30 06:35:30 +01:00
|
|
|
private final CraftServer server;
|
2011-05-14 16:29:42 +02:00
|
|
|
private int lastTick = MinecraftServer.currentTick;
|
|
|
|
private static final int PLACE_DISTANCE_SQUARED = 6 * 6;
|
2010-12-28 22:52:39 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
// Get position of last block hit for BlockDamageLevel.STOPPED
|
2011-03-08 00:06:50 +01:00
|
|
|
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;
|
2011-02-25 22:40:06 +01:00
|
|
|
|
2011-03-24 00:10:05 +01:00
|
|
|
// For the packet15 hack :(
|
|
|
|
Long lastPacket;
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
// Store the last block right clicked and what type it was
|
|
|
|
private int lastMaterial;
|
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
public CraftPlayer getPlayer() {
|
|
|
|
return (this.player == null) ? null : (CraftPlayer) this.player.getBukkitEntity();
|
2011-01-11 09:25:13 +01:00
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2010-12-28 22:52:39 +01:00
|
|
|
public void a() {
|
2011-04-20 22:47:26 +02:00
|
|
|
this.i = false;
|
2011-05-26 14:48:22 +02:00
|
|
|
this.networkManager.b();
|
2011-02-23 03:37:56 +01:00
|
|
|
if (this.f - this.g > 20) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.sendPacket(new Packet0KeepAlive());
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void disconnect(String s) {
|
2011-02-04 16:04:28 +01:00
|
|
|
// CraftBukkit start
|
2011-04-20 19:05:14 +02:00
|
|
|
String leaveMessage = "\u00A7e" + this.player.name + " left the game.";
|
2011-06-27 00:25:01 +02:00
|
|
|
|
|
|
|
PlayerKickEvent event = new PlayerKickEvent(this.server.getPlayer(this.player), s, leaveMessage);
|
|
|
|
this.server.getPluginManager().callEvent(event);
|
|
|
|
|
2011-02-23 13:56:36 +01:00
|
|
|
if (event.isCancelled()) {
|
2011-02-04 16:04:28 +01:00
|
|
|
// Do not kick the player
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Send the possibly modified leave message
|
2011-05-26 14:48:22 +02:00
|
|
|
s = event.getReason();
|
2011-05-28 22:50:08 +02:00
|
|
|
// CraftBukkit end
|
|
|
|
|
2011-06-30 00:02:25 +02:00
|
|
|
this.player.B();
|
2011-05-26 14:48:22 +02:00
|
|
|
this.sendPacket(new Packet255KickDisconnect(s));
|
|
|
|
this.networkManager.d();
|
2011-05-28 22:50:08 +02:00
|
|
|
|
2011-06-12 00:02:58 +02:00
|
|
|
// CraftBukkit start
|
2011-03-26 12:31:48 +01:00
|
|
|
leaveMessage = event.getLeaveMessage();
|
|
|
|
if (leaveMessage != null) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.minecraftServer.serverConfigurationManager.sendAll(new Packet3Chat(leaveMessage));
|
2011-03-26 12:31:48 +01:00
|
|
|
}
|
2011-02-23 03:37:56 +01:00
|
|
|
// CraftBukkit end
|
2011-03-23 12:22:13 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
this.minecraftServer.serverConfigurationManager.disconnect(this.player);
|
|
|
|
this.disconnected = true;
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
public void a(Packet27 packet27) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.player.a(packet27.c(), packet27.e(), packet27.g(), packet27.h(), packet27.d(), packet27.f());
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
|
2010-12-28 22:52:39 +01:00
|
|
|
public void a(Packet10Flying packet10flying) {
|
2011-06-27 00:25:01 +02:00
|
|
|
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
|
2011-05-26 14:48:22 +02:00
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
this.i = true;
|
2011-01-29 22:50:29 +01:00
|
|
|
double d0;
|
2010-12-28 22:52:39 +01:00
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
if (!this.checkMovement) {
|
2011-04-20 19:05:14 +02:00
|
|
|
d0 = packet10flying.y - this.y;
|
|
|
|
if (packet10flying.x == this.x && d0 * d0 < 0.01D && packet10flying.z == this.z) {
|
2011-06-27 00:25:01 +02:00
|
|
|
this.checkMovement = true;
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
}
|
2010-12-29 02:25:32 +01:00
|
|
|
|
|
|
|
// CraftBukkit start
|
2011-06-27 00:25:01 +02:00
|
|
|
Player player = this.getPlayer();
|
2011-06-30 07:26:18 +02:00
|
|
|
Location from = player.getLocation().clone(); // Get the Players current 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.
|
|
|
|
if (packet10flying.h && !(packet10flying.h && packet10flying.y == -999.0D && packet10flying.stance == -999.0D)) {
|
|
|
|
to.setX(packet10flying.x);
|
|
|
|
to.setY(packet10flying.y);
|
|
|
|
to.setZ(packet10flying.z);
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the packet contains look information then we update the To location with the correct Yaw & Pitch.
|
|
|
|
if (packet10flying.hasLook) {
|
|
|
|
to.setYaw(packet10flying.yaw);
|
|
|
|
to.setPitch(packet10flying.pitch);
|
|
|
|
}
|
2011-02-25 22:40:06 +01:00
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
// Prevent 40 event-calls for less than a single pixel of movement >.>
|
2011-05-14 16:29:42 +02:00
|
|
|
double delta = Math.pow(this.lastPosX - this.x, 2) + Math.pow(this.lastPosY - this.y, 2) + Math.pow(this.lastPosZ - this.z, 2);
|
2011-06-12 00:02:58 +02:00
|
|
|
float deltaAngle = Math.abs(this.lastYaw - this.player.yaw) + Math.abs(this.lastPitch - this.player.pitch);
|
2011-03-08 00:06:50 +01:00
|
|
|
|
2011-06-12 00:02:58 +02:00
|
|
|
if (delta > 1f / 256 || deltaAngle > 10f) {
|
2011-03-24 00:52:10 +01:00
|
|
|
// Skip the first time we do this
|
2011-06-27 00:25:01 +02:00
|
|
|
if (this.lastPosX != Double.MAX_VALUE) {
|
2011-03-26 22:32:56 +01:00
|
|
|
PlayerMoveEvent event = new PlayerMoveEvent(player, from, to);
|
2011-06-27 00:25:01 +02:00
|
|
|
this.server.getPluginManager().callEvent(event);
|
2011-03-27 00:34:33 +01:00
|
|
|
|
2011-06-18 01:19:11 +02:00
|
|
|
// If the event is cancelled we move the player back to their old location.
|
|
|
|
if (event.isCancelled()) {
|
2011-06-22 05:04:11 +02:00
|
|
|
this.player.netServerHandler.sendPacket(new Packet13PlayerLookMove(from.getX(), from.getY() + 1.6200000047683716D, from.getY(), from.getZ(), from.getYaw(), from.getPitch(), false));
|
|
|
|
return;
|
2011-06-18 01:19:11 +02: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. */
|
|
|
|
if (!to.equals(event.getTo()) && !event.isCancelled()) {
|
|
|
|
((CraftPlayer) this.player.getBukkitEntity()).teleport(event.getTo());
|
|
|
|
return;
|
|
|
|
}
|
2011-03-24 00:52:10 +01:00
|
|
|
|
2011-06-30 07:26:18 +02: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() */
|
|
|
|
if(!from.equals(this.getPlayer().getLocation())){
|
|
|
|
return;
|
|
|
|
}
|
2011-03-24 00:52:10 +01:00
|
|
|
}
|
2011-02-25 22:40:06 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
this.lastPosX = this.player.locX;
|
|
|
|
this.lastPosY = this.player.locY;
|
|
|
|
this.lastPosZ = this.player.locZ;
|
|
|
|
this.lastYaw = this.player.yaw;
|
|
|
|
this.lastPitch = this.player.pitch;
|
2010-12-30 21:34:26 +01:00
|
|
|
}
|
2011-04-13 04:03:43 +02:00
|
|
|
|
2011-06-30 07:26:18 +02:00
|
|
|
if (Double.isNaN(packet10flying.x) || Double.isNaN(packet10flying.y) || Double.isNaN(packet10flying.z) || Double.isNaN(packet10flying.stance)) {
|
2011-04-29 08:08:46 +02:00
|
|
|
player.teleport(player.getWorld().getSpawnLocation());
|
2011-04-13 04:03:43 +02:00
|
|
|
System.err.println(player.getName() + " was caught trying to crash the server with an invalid position.");
|
|
|
|
player.kickPlayer("Nope!");
|
2011-04-14 02:57:43 +02:00
|
|
|
return;
|
|
|
|
}
|
2010-12-29 02:25:32 +01:00
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
if (this.checkMovement && !this.player.dead) {
|
2011-06-12 00:02:58 +02:00
|
|
|
// CraftBukkit end
|
2011-01-29 22:50:29 +01:00
|
|
|
double d1;
|
|
|
|
double d2;
|
|
|
|
double d3;
|
|
|
|
double d4;
|
2010-12-28 22:52:39 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (this.player.vehicle != null) {
|
|
|
|
float f = this.player.yaw;
|
|
|
|
float f1 = this.player.pitch;
|
2010-12-28 22:52:39 +01:00
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
this.player.vehicle.f();
|
2011-04-20 19:05:14 +02:00
|
|
|
d1 = this.player.locX;
|
|
|
|
d2 = this.player.locY;
|
|
|
|
d3 = this.player.locZ;
|
2011-01-29 22:50:29 +01:00
|
|
|
double d5 = 0.0D;
|
|
|
|
|
|
|
|
d4 = 0.0D;
|
2011-04-20 19:05:14 +02:00
|
|
|
if (packet10flying.hasLook) {
|
|
|
|
f = packet10flying.yaw;
|
|
|
|
f1 = packet10flying.pitch;
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (packet10flying.h && packet10flying.y == -999.0D && packet10flying.stance == -999.0D) {
|
|
|
|
d5 = packet10flying.x;
|
|
|
|
d4 = packet10flying.z;
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-04-29 10:55:04 +02:00
|
|
|
this.player.onGround = packet10flying.g;
|
2011-06-09 20:24:21 +02:00
|
|
|
this.player.a(true);
|
2011-04-20 19:05:14 +02:00
|
|
|
this.player.move(d5, 0.0D, d4);
|
|
|
|
this.player.setLocation(d1, d2, d3, f, f1);
|
|
|
|
this.player.motX = d5;
|
|
|
|
this.player.motZ = d4;
|
|
|
|
if (this.player.vehicle != null) {
|
2011-05-26 14:48:22 +02:00
|
|
|
worldserver.vehicleEnteredWorld(this.player.vehicle, true);
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (this.player.vehicle != null) {
|
2011-04-20 22:47:26 +02:00
|
|
|
this.player.vehicle.f();
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
this.minecraftServer.serverConfigurationManager.d(this.player);
|
2011-04-20 19:05:14 +02:00
|
|
|
this.x = this.player.locX;
|
|
|
|
this.y = this.player.locY;
|
|
|
|
this.z = this.player.locZ;
|
2011-05-26 14:48:22 +02:00
|
|
|
worldserver.playerJoinedWorld(this.player);
|
2011-05-31 15:55:45 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.player.isSleeping()) {
|
|
|
|
this.player.a(true);
|
|
|
|
this.player.setLocation(this.x, this.y, this.z, this.player.yaw, this.player.pitch);
|
|
|
|
worldserver.playerJoinedWorld(this.player);
|
2010-12-28 22:52:39 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
d0 = this.player.locY;
|
|
|
|
this.x = this.player.locX;
|
|
|
|
this.y = this.player.locY;
|
|
|
|
this.z = this.player.locZ;
|
|
|
|
d1 = this.player.locX;
|
|
|
|
d2 = this.player.locY;
|
|
|
|
d3 = this.player.locZ;
|
|
|
|
float f2 = this.player.yaw;
|
|
|
|
float f3 = this.player.pitch;
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (packet10flying.h && packet10flying.y == -999.0D && packet10flying.stance == -999.0D) {
|
2010-12-28 22:52:39 +01:00
|
|
|
packet10flying.h = false;
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2010-12-28 22:52:39 +01:00
|
|
|
if (packet10flying.h) {
|
2011-04-20 19:05:14 +02:00
|
|
|
d1 = packet10flying.x;
|
|
|
|
d2 = packet10flying.y;
|
|
|
|
d3 = packet10flying.z;
|
|
|
|
d4 = packet10flying.stance - packet10flying.y;
|
2011-04-20 22:47:26 +02:00
|
|
|
if (!this.player.isSleeping() && (d4 > 1.65D || d4 < 0.1D)) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.disconnect("Illegal stance");
|
|
|
|
a.warning(this.player.name + " had an illegal stance: " + d4);
|
2011-04-20 22:47:26 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Math.abs(packet10flying.x) > 3.2E7D || Math.abs(packet10flying.z) > 3.2E7D) {
|
|
|
|
this.disconnect("Illegal position");
|
|
|
|
return;
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
if (packet10flying.hasLook) {
|
|
|
|
f2 = packet10flying.yaw;
|
|
|
|
f3 = packet10flying.pitch;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.player.a(true);
|
2011-05-28 22:50:08 +02:00
|
|
|
this.player.br = 0.0F;
|
2011-04-20 22:47:26 +02:00
|
|
|
this.player.setLocation(this.x, this.y, this.z, f2, f3);
|
2011-06-27 00:25:01 +02:00
|
|
|
if (!this.checkMovement) {
|
2011-05-26 14:48:22 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
d4 = d1 - this.player.locX;
|
|
|
|
double d6 = d2 - this.player.locY;
|
|
|
|
double d7 = d3 - this.player.locZ;
|
2011-04-19 07:04:13 +02:00
|
|
|
double d8 = d4 * d4 + d6 * d6 + d7 * d7;
|
|
|
|
|
2011-05-09 20:51:01 +02:00
|
|
|
// CraftBukkit start - make the movement speed check behave properly under tick degradation.
|
|
|
|
int elapsedTicks = MinecraftServer.currentTick - this.lastTick;
|
2011-06-12 00:02:58 +02:00
|
|
|
|
2011-05-23 09:36:13 +02:00
|
|
|
// Added this.m condition to solve this check being triggered by teleports
|
2011-06-27 00:25:01 +02:00
|
|
|
if (d8 > 100.0D * (elapsedTicks <= 0 ? 1 : elapsedTicks) && this.checkMovement) {
|
2011-06-12 00:02:58 +02:00
|
|
|
a.warning(this.player.name + " moved too quickly! Elapsed ticks: " + (elapsedTicks == 0 ? 1 : elapsedTicks) + ", Distance change: " + d8);
|
2011-04-20 22:47:26 +02:00
|
|
|
this.disconnect("You moved too quickly :( (Hacking?)");
|
|
|
|
return;
|
2011-04-19 07:04:13 +02:00
|
|
|
}
|
2011-05-09 20:51:01 +02:00
|
|
|
this.lastTick = MinecraftServer.currentTick;
|
|
|
|
// CraftBukkit end
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
float f4 = 0.0625F;
|
2011-05-26 14:48:22 +02:00
|
|
|
boolean flag = worldserver.getEntities(this.player, this.player.boundingBox.clone().shrink((double) f4, (double) f4, (double) f4)).size() == 0;
|
2011-04-20 22:47:26 +02:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
this.player.move(d4, d6, d7);
|
|
|
|
d4 = d1 - this.player.locX;
|
|
|
|
d6 = d2 - this.player.locY;
|
2011-01-29 22:50:29 +01:00
|
|
|
if (d6 > -0.5D || d6 < 0.5D) {
|
|
|
|
d6 = 0.0D;
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
d7 = d3 - this.player.locZ;
|
2011-04-20 22:47:26 +02:00
|
|
|
d8 = d4 * d4 + d6 * d6 + d7 * d7;
|
|
|
|
boolean flag1 = false;
|
2010-12-28 22:52:39 +01:00
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
if (d8 > 0.0625D && !this.player.isSleeping()) {
|
|
|
|
flag1 = true;
|
|
|
|
a.warning(this.player.name + " moved wrongly!");
|
|
|
|
System.out.println("Got position " + d1 + ", " + d2 + ", " + d3);
|
|
|
|
System.out.println("Expected " + this.player.locX + ", " + this.player.locY + ", " + this.player.locZ);
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
this.player.setLocation(d1, d2, d3, f2, f3);
|
2011-05-26 14:48:22 +02:00
|
|
|
boolean flag2 = worldserver.getEntities(this.player, this.player.boundingBox.clone().shrink((double) f4, (double) f4, (double) f4)).size() == 0;
|
2010-12-28 22:52:39 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (flag && (flag1 || !flag2) && !this.player.isSleeping()) {
|
|
|
|
this.a(this.x, this.y, this.z, f2, f3);
|
2010-12-28 22:52:39 +01:00
|
|
|
return;
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
AxisAlignedBB axisalignedbb = this.player.boundingBox.clone().b((double) f4, (double) f4, (double) f4).a(0.0D, -0.55D, 0.0D);
|
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
if (!this.minecraftServer.allowFlight && !worldserver.b(axisalignedbb)) {
|
2011-04-20 22:47:26 +02:00
|
|
|
if (d6 >= -0.03125D) {
|
|
|
|
++this.h;
|
|
|
|
if (this.h > 80) {
|
|
|
|
a.warning(this.player.name + " was kicked for floating too long!");
|
|
|
|
this.disconnect("Flying is not enabled on this server");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this.h = 0;
|
|
|
|
}
|
|
|
|
|
2011-04-29 10:55:04 +02:00
|
|
|
this.player.onGround = packet10flying.g;
|
2011-05-26 14:48:22 +02:00
|
|
|
this.minecraftServer.serverConfigurationManager.d(this.player);
|
2011-04-29 10:55:04 +02:00
|
|
|
this.player.b(this.player.locY - d0, packet10flying.g);
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-23 18:42:36 +01:00
|
|
|
public void a(double d0, double d1, double d2, float f, float f1) {
|
2011-05-14 16:29:42 +02:00
|
|
|
// CraftBukkit start - Delegate to teleport(Location)
|
2011-06-27 00:25:01 +02:00
|
|
|
Player player = this.getPlayer();
|
2010-12-29 02:25:32 +01:00
|
|
|
Location from = player.getLocation();
|
2011-06-27 00:25:01 +02:00
|
|
|
Location to = new Location(this.getPlayer().getWorld(), d0, d1, d2, f, f1);
|
2011-03-27 00:34:33 +01:00
|
|
|
PlayerTeleportEvent event = new PlayerTeleportEvent(player, from, to);
|
2011-06-27 00:25:01 +02:00
|
|
|
this.server.getPluginManager().callEvent(event);
|
2010-12-29 02:25:32 +01:00
|
|
|
|
|
|
|
from = event.getFrom();
|
|
|
|
to = event.isCancelled() ? from : event.getTo();
|
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
this.teleport(to);
|
2011-06-11 04:59:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void teleport(Location dest) {
|
2011-03-23 07:50:14 +01:00
|
|
|
double d0, d1, d2;
|
|
|
|
float f, f1;
|
|
|
|
|
2011-06-11 04:59:54 +02:00
|
|
|
d0 = dest.getX();
|
|
|
|
d1 = dest.getY();
|
|
|
|
d2 = dest.getZ();
|
|
|
|
f = dest.getYaw();
|
|
|
|
f1 = dest.getPitch();
|
2011-04-25 02:14:33 +02:00
|
|
|
|
|
|
|
// TODO: make sure this is the best way to address this.
|
|
|
|
if (Float.isNaN(f)) {
|
|
|
|
f = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Float.isNaN(f1)) {
|
|
|
|
f1 = 0;
|
|
|
|
}
|
2011-03-23 18:42:36 +01:00
|
|
|
// CraftBukkit end
|
2010-12-29 02:25:32 +01:00
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
this.checkMovement = false;
|
2011-04-20 19:05:14 +02:00
|
|
|
this.x = d0;
|
|
|
|
this.y = d1;
|
|
|
|
this.z = d2;
|
|
|
|
this.player.setLocation(d0, d1, d2, f, f1);
|
|
|
|
this.player.netServerHandler.sendPacket(new Packet13PlayerLookMove(d0, d1 + 1.6200000047683716D, d1, d2, f, f1, false));
|
2011-03-23 07:50:14 +01:00
|
|
|
}
|
2010-12-28 22:52:39 +01:00
|
|
|
|
|
|
|
public void a(Packet14BlockDig packet14blockdig) {
|
2011-06-27 00:25:01 +02:00
|
|
|
if (this.player.dead) return; // CraftBukkit
|
2011-05-12 16:22:52 +02:00
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
|
2011-05-26 14:48:22 +02:00
|
|
|
|
2010-12-28 22:52:39 +01:00
|
|
|
if (packet14blockdig.e == 4) {
|
2011-06-30 00:02:25 +02:00
|
|
|
this.player.F();
|
2011-01-29 22:50:29 +01:00
|
|
|
} else {
|
2011-06-12 00:02:58 +02:00
|
|
|
boolean flag = worldserver.weirdIsOpCache = worldserver.dimension != 0 || this.minecraftServer.serverConfigurationManager.isOp(this.player.name); // CraftBukkit
|
2011-01-29 22:50:29 +01:00
|
|
|
boolean flag1 = false;
|
2010-12-28 22:52:39 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (packet14blockdig.e == 0) {
|
|
|
|
flag1 = true;
|
|
|
|
}
|
2010-12-28 22:52:39 +01:00
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
if (packet14blockdig.e == 2) {
|
2011-01-29 22:50:29 +01:00
|
|
|
flag1 = true;
|
|
|
|
}
|
2010-12-28 22:52:39 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
int i = packet14blockdig.a;
|
|
|
|
int j = packet14blockdig.b;
|
|
|
|
int k = packet14blockdig.c;
|
|
|
|
|
|
|
|
if (flag1) {
|
2011-04-20 19:05:14 +02:00
|
|
|
double d0 = this.player.locX - ((double) i + 0.5D);
|
|
|
|
double d1 = this.player.locY - ((double) j + 0.5D);
|
|
|
|
double d2 = this.player.locZ - ((double) k + 0.5D);
|
2011-01-29 22:50:29 +01:00
|
|
|
double d3 = d0 * d0 + d1 * d1 + d2 * d2;
|
|
|
|
|
|
|
|
if (d3 > 36.0D) {
|
|
|
|
return;
|
|
|
|
}
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
ChunkCoordinates chunkcoordinates = worldserver.getSpawn();
|
2011-04-20 19:05:14 +02:00
|
|
|
int l = (int) MathHelper.abs((float) (i - chunkcoordinates.x));
|
|
|
|
int i1 = (int) MathHelper.abs((float) (k - chunkcoordinates.z));
|
2010-12-28 22:52:39 +01:00
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
if (l > i1) {
|
|
|
|
i1 = l;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
2011-01-10 02:36:19 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (packet14blockdig.e == 0) {
|
2011-03-23 16:38:42 +01:00
|
|
|
// CraftBukkit
|
2011-06-27 00:25:01 +02:00
|
|
|
if (i1 < this.server.getSpawnRadius() && !flag) {
|
2011-05-26 14:48:22 +02:00
|
|
|
this.player.netServerHandler.sendPacket(new Packet53BlockChange(i, j, k, worldserver));
|
|
|
|
} else {
|
2011-05-14 16:29:42 +02:00
|
|
|
// CraftBukkit - add face argument
|
2011-04-20 19:05:14 +02:00
|
|
|
this.player.itemInWorldManager.dig(i, j, k, packet14blockdig.face);
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
} else if (packet14blockdig.e == 2) {
|
2011-05-26 14:48:22 +02:00
|
|
|
this.player.itemInWorldManager.a(i, j, k);
|
|
|
|
if (worldserver.getTypeId(i, j, k) != 0) {
|
|
|
|
this.player.netServerHandler.sendPacket(new Packet53BlockChange(i, j, k, worldserver));
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
} else if (packet14blockdig.e == 3) {
|
2011-04-20 19:05:14 +02:00
|
|
|
double d4 = this.player.locX - ((double) i + 0.5D);
|
|
|
|
double d5 = this.player.locY - ((double) j + 0.5D);
|
|
|
|
double d6 = this.player.locZ - ((double) k + 0.5D);
|
2011-02-23 03:37:56 +01:00
|
|
|
double d7 = d4 * d4 + d5 * d5 + d6 * d6;
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
if (d7 < 256.0D) {
|
2011-05-26 14:48:22 +02:00
|
|
|
this.player.netServerHandler.sendPacket(new Packet53BlockChange(i, j, k, worldserver));
|
2011-01-10 02:36:19 +01:00
|
|
|
}
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
worldserver.weirdIsOpCache = false;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
2011-01-11 09:25:13 +01:00
|
|
|
|
2010-12-28 22:52:39 +01:00
|
|
|
public void a(Packet15Place packet15place) {
|
2011-06-27 00:25:01 +02:00
|
|
|
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
|
2011-05-26 14:48:22 +02:00
|
|
|
|
2011-03-24 12:11:28 +01:00
|
|
|
// CraftBukkit start
|
2011-06-27 00:25:01 +02:00
|
|
|
if (this.player.dead) return;
|
2011-05-12 16:22:52 +02:00
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
// This is a horrible hack needed because the client sends 2 packets on 'right mouse click'
|
|
|
|
// aimed at a block. We shouldn't need to get the second packet if the data is handled
|
2011-03-24 00:10:05 +01:00
|
|
|
// but we cannot know what the client will do, so we might still get it
|
|
|
|
//
|
|
|
|
// If the time between packets is small enough, and the 'signature' similar, we discard the
|
|
|
|
// second one. This sadly has to remain until Mojang makes their packets saner. :(
|
|
|
|
// -- Grum
|
2011-01-10 02:36:19 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (packet15place.face == 255) {
|
2011-06-27 00:25:01 +02:00
|
|
|
if (packet15place.itemstack != null && packet15place.itemstack.id == this.lastMaterial && this.lastPacket != null && packet15place.timestamp - this.lastPacket < 100) {
|
|
|
|
this.lastPacket = null;
|
2011-03-24 00:10:05 +01:00
|
|
|
return;
|
2011-01-08 11:49:42 +01:00
|
|
|
}
|
|
|
|
} else {
|
2011-06-27 00:25:01 +02:00
|
|
|
this.lastMaterial = packet15place.itemstack == null ? -1 : packet15place.itemstack.id;
|
|
|
|
this.lastPacket = packet15place.timestamp;
|
2011-01-08 11:49:42 +01:00
|
|
|
}
|
2011-01-10 02:36:19 +01:00
|
|
|
|
2011-05-14 16:29:42 +02:00
|
|
|
// CraftBukkit - if rightclick decremented the item, always send the update packet.
|
2011-01-11 09:25:13 +01:00
|
|
|
// this is not here for CraftBukkit's own functionality; rather it is to fix
|
2011-06-27 00:25:01 +02:00
|
|
|
// a notch bug where the item doesn't update correctly.
|
2011-01-07 11:46:11 +01:00
|
|
|
boolean always = false;
|
2011-03-24 00:10:05 +01:00
|
|
|
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit end
|
2011-01-10 02:36:19 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
ItemStack itemstack = this.player.inventory.getItemInHand();
|
2011-06-12 00:02:58 +02:00
|
|
|
boolean flag = worldserver.weirdIsOpCache = worldserver.dimension != 0 || this.minecraftServer.serverConfigurationManager.isOp(this.player.name); // CraftBukkit
|
2011-03-24 00:10:05 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (packet15place.face == 255) {
|
2010-12-28 22:52:39 +01:00
|
|
|
if (itemstack == null) {
|
|
|
|
return;
|
|
|
|
}
|
2011-01-10 02:36:19 +01:00
|
|
|
|
2011-03-24 12:11:28 +01:00
|
|
|
// CraftBukkit start
|
2011-03-24 23:27:40 +01:00
|
|
|
int itemstackAmount = itemstack.count;
|
2011-04-20 19:05:14 +02:00
|
|
|
PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.RIGHT_CLICK_AIR, itemstack);
|
2011-03-25 07:35:47 +01:00
|
|
|
if (event.useItemInHand() != Event.Result.DENY) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.player.itemInWorldManager.useItem(this.player, this.player.world, itemstack);
|
2011-03-25 07:35:47 +01:00
|
|
|
}
|
2011-01-08 11:49:42 +01:00
|
|
|
|
2011-05-14 16:29:42 +02:00
|
|
|
// CraftBukkit - notch decrements the counter by 1 in the above method with food,
|
2011-06-27 00:25:01 +02:00
|
|
|
// snowballs and so forth, but he does it in a place that doesn't cause the
|
2011-03-24 23:27:40 +01:00
|
|
|
// inventory update packet to get sent
|
|
|
|
always = (itemstack.count != itemstackAmount);
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit end
|
2010-12-28 22:52:39 +01:00
|
|
|
} else {
|
2011-01-29 22:50:29 +01:00
|
|
|
int i = packet15place.a;
|
|
|
|
int j = packet15place.b;
|
|
|
|
int k = packet15place.c;
|
2011-04-20 19:05:14 +02:00
|
|
|
int l = packet15place.face;
|
2011-05-26 14:48:22 +02:00
|
|
|
ChunkCoordinates chunkcoordinates = worldserver.getSpawn();
|
2011-04-20 19:05:14 +02:00
|
|
|
int i1 = (int) MathHelper.abs((float) (i - chunkcoordinates.x));
|
|
|
|
int j1 = (int) MathHelper.abs((float) (k - chunkcoordinates.z));
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
if (i1 > j1) {
|
|
|
|
j1 = i1;
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
// CraftBukkit start - Check if we can actually do something over this large a distance
|
2011-06-27 00:25:01 +02:00
|
|
|
Location eyeLoc = this.getPlayer().getEyeLocation();
|
2011-03-09 20:43:49 +01:00
|
|
|
if (Math.pow(eyeLoc.getX() - i, 2) + Math.pow(eyeLoc.getY() - j, 2) + Math.pow(eyeLoc.getZ() - k, 2) > PLACE_DISTANCE_SQUARED) {
|
|
|
|
return;
|
|
|
|
}
|
2011-05-26 14:48:22 +02:00
|
|
|
flag = true; // spawn protection moved to ItemBlock!!!
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit end
|
2011-02-25 21:59:35 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
if (j1 > 16 || flag) {
|
|
|
|
this.player.itemInWorldManager.interact(this.player, worldserver, itemstack, i, j, k, l);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.player.netServerHandler.sendPacket(new Packet53BlockChange(i, j, k, worldserver));
|
2011-01-29 22:50:29 +01:00
|
|
|
if (l == 0) {
|
|
|
|
--j;
|
2011-01-08 11:49:42 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
if (l == 1) {
|
|
|
|
++j;
|
2011-01-08 11:49:42 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
if (l == 2) {
|
|
|
|
--k;
|
2011-01-08 11:49:42 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
if (l == 3) {
|
|
|
|
++k;
|
2011-01-08 11:49:42 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
if (l == 4) {
|
|
|
|
--i;
|
2011-01-08 11:49:42 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
if (l == 5) {
|
|
|
|
++i;
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
this.player.netServerHandler.sendPacket(new Packet53BlockChange(i, j, k, worldserver));
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
itemstack = this.player.inventory.getItemInHand();
|
2011-01-29 22:50:29 +01:00
|
|
|
if (itemstack != null && itemstack.count == 0) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.player.inventory.items[this.player.inventory.itemInHandIndex] = null;
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
this.player.h = true;
|
|
|
|
this.player.inventory.items[this.player.inventory.itemInHandIndex] = ItemStack.b(this.player.inventory.items[this.player.inventory.itemInHandIndex]);
|
|
|
|
Slot slot = this.player.activeContainer.a(this.player.inventory, this.player.inventory.itemInHandIndex);
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
this.player.activeContainer.a();
|
|
|
|
this.player.h = false;
|
2011-05-14 16:29:42 +02:00
|
|
|
// CraftBukkit
|
|
|
|
if (!ItemStack.equals(this.player.inventory.getItemInHand(), packet15place.itemstack) || always) {
|
2011-06-27 00:25:01 +02:00
|
|
|
this.sendPacket(new Packet103SetSlot(this.player.activeContainer.windowId, slot.a, this.player.inventory.getItemInHand()));
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
worldserver.weirdIsOpCache = false;
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
2011-01-10 02:36:19 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public void a(String s, Object[] aobject) {
|
2011-06-27 00:25:01 +02:00
|
|
|
if (this.disconnected) return; // CraftBukkit - rarely it would send a disconnect line twice
|
2011-04-20 19:05:14 +02:00
|
|
|
|
|
|
|
a.info(this.player.name + " lost connection: " + s);
|
2011-04-26 04:36:55 +02:00
|
|
|
// CraftBukkit start - we need to handle custom quit messages
|
|
|
|
String quitMessage = this.minecraftServer.serverConfigurationManager.disconnect(this.player);
|
|
|
|
if (quitMessage != null) {
|
|
|
|
this.minecraftServer.serverConfigurationManager.sendAll(new Packet3Chat(quitMessage));
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2011-04-20 19:05:14 +02:00
|
|
|
this.disconnected = true;
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void a(Packet packet) {
|
2011-01-29 22:50:29 +01:00
|
|
|
a.warning(this.getClass() + " wasn\'t prepared to deal with a " + packet.getClass());
|
2011-04-20 19:05:14 +02:00
|
|
|
this.disconnect("Protocol error, unexpected packet");
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void sendPacket(Packet packet) {
|
2011-05-14 16:29:42 +02:00
|
|
|
// CraftBukkit start
|
2011-03-25 21:22:03 +01:00
|
|
|
if (packet instanceof Packet6SpawnPosition) {
|
|
|
|
Packet6SpawnPosition packet6 = (Packet6SpawnPosition) packet;
|
2011-06-27 00:25:01 +02:00
|
|
|
this.player.compassTarget = new Location(this.getPlayer().getWorld(), packet6.x, packet6.y, packet6.z);
|
2011-04-25 18:14:06 +02:00
|
|
|
} else if (packet instanceof Packet3Chat) {
|
2011-06-27 00:25:01 +02:00
|
|
|
String message = ((Packet3Chat) packet).message;
|
2011-04-25 18:14:06 +02:00
|
|
|
for (final String line: TextWrapper.wrapText(message)) {
|
2011-06-27 00:25:01 +02:00
|
|
|
this.networkManager.queue(new Packet3Chat(line));
|
2011-04-25 18:14:06 +02:00
|
|
|
}
|
|
|
|
packet = null;
|
2011-03-25 21:22:03 +01:00
|
|
|
}
|
2011-06-27 00:25:01 +02:00
|
|
|
if (packet != null) this.networkManager.queue(packet);
|
2011-05-14 16:29:42 +02:00
|
|
|
// CraftBukkit end
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
this.g = this.f;
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void a(Packet16BlockItemSwitch packet16blockitemswitch) {
|
2011-06-27 00:25:01 +02:00
|
|
|
if (this.player.dead) return; // CraftBukkit
|
2011-05-12 16:22:52 +02:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (packet16blockitemswitch.itemInHandIndex >= 0 && packet16blockitemswitch.itemInHandIndex <= InventoryPlayer.e()) {
|
|
|
|
// CraftBukkit start
|
2011-06-27 00:25:01 +02:00
|
|
|
PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayer(), this.player.inventory.itemInHandIndex, packet16blockitemswitch.itemInHandIndex);
|
|
|
|
this.server.getPluginManager().callEvent(event);
|
2011-04-20 19:05:14 +02:00
|
|
|
// CraftBukkit end
|
2011-05-14 16:29:42 +02:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
this.player.inventory.itemInHandIndex = packet16blockitemswitch.itemInHandIndex;
|
|
|
|
} else {
|
|
|
|
a.warning(this.player.name + " tried to set an invalid carried item");
|
|
|
|
}
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void a(Packet3Chat packet3chat) {
|
2011-06-27 00:25:01 +02:00
|
|
|
String s = packet3chat.message;
|
2010-12-28 22:52:39 +01:00
|
|
|
|
|
|
|
if (s.length() > 100) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.disconnect("Chat message too long");
|
2010-12-28 22:52:39 +01:00
|
|
|
} else {
|
2011-01-29 22:50:29 +01:00
|
|
|
s = s.trim();
|
|
|
|
|
|
|
|
for (int i = 0; i < s.length(); ++i) {
|
2011-06-27 00:25:01 +02:00
|
|
|
if (FontAllowedCharacters.allowedCharacters.indexOf(s.charAt(i)) < 0) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.disconnect("Illegal characters in chat");
|
2011-01-29 22:50:29 +01:00
|
|
|
return;
|
|
|
|
}
|
2011-01-10 02:36:19 +01:00
|
|
|
}
|
2011-01-01 14:06:04 +01:00
|
|
|
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit start
|
2011-06-27 00:25:01 +02:00
|
|
|
this.chat(s);
|
2011-02-17 06:46:01 +01:00
|
|
|
}
|
|
|
|
}
|
2011-02-20 13:38:27 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
public boolean chat(String s) {
|
|
|
|
if (!this.player.dead) {
|
|
|
|
if (s.startsWith("/")) {
|
|
|
|
this.handleCommand(s);
|
2011-02-17 06:46:01 +01:00
|
|
|
return true;
|
2011-05-26 14:48:22 +02:00
|
|
|
} else {
|
2011-06-27 00:25:01 +02:00
|
|
|
Player player = this.getPlayer();
|
2011-05-26 14:48:22 +02:00
|
|
|
PlayerChatEvent event = new PlayerChatEvent(player, s);
|
2011-06-27 00:25:01 +02:00
|
|
|
this.server.getPluginManager().callEvent(event);
|
2011-05-26 14:48:22 +02:00
|
|
|
|
|
|
|
if (event.isCancelled()) {
|
|
|
|
return true;
|
|
|
|
}
|
2011-02-17 06:46:01 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
s = String.format(event.getFormat(), event.getPlayer().getDisplayName(), event.getMessage());
|
|
|
|
a.info(s);
|
|
|
|
for (Player recipient : event.getRecipients()) {
|
|
|
|
recipient.sendMessage(s);
|
|
|
|
}
|
2011-02-20 13:38:27 +01:00
|
|
|
}
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
2011-02-20 13:38:27 +01:00
|
|
|
|
2011-02-17 06:46:01 +01:00
|
|
|
return false;
|
2011-05-14 16:29:42 +02:00
|
|
|
// CraftBukkit end
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
private void handleCommand(String s) {
|
2010-12-28 22:52:39 +01:00
|
|
|
// CraftBukkit start
|
2011-06-27 00:25:01 +02:00
|
|
|
CraftPlayer player = this.getPlayer();
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-03-27 00:34:33 +01:00
|
|
|
PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(player, s);
|
2011-06-27 00:25:01 +02:00
|
|
|
this.server.getPluginManager().callEvent(event);
|
|
|
|
|
2011-01-10 02:36:19 +01:00
|
|
|
if (event.isCancelled()) {
|
|
|
|
return;
|
|
|
|
}
|
2011-02-18 17:25:56 +01:00
|
|
|
|
|
|
|
try {
|
2011-06-27 00:25:01 +02:00
|
|
|
if (this.server.dispatchCommand(player, s.substring(1))) {
|
2011-05-22 21:24:44 +02:00
|
|
|
return;
|
|
|
|
}
|
2011-02-18 17:25:56 +01:00
|
|
|
} catch (CommandException ex) {
|
2011-05-14 16:29:42 +02:00
|
|
|
player.sendMessage(ChatColor.RED + "An internal error occurred while attempting to perform this command");
|
2011-06-27 00:25:01 +02:00
|
|
|
Logger.getLogger(NetServerHandler.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
2011-02-18 17:25:56 +01:00
|
|
|
return;
|
|
|
|
}
|
2011-05-14 16:29:42 +02:00
|
|
|
// CraftBukkit end
|
2010-12-28 22:52:39 +01:00
|
|
|
|
|
|
|
if (s.toLowerCase().startsWith("/me ")) {
|
2011-04-20 19:05:14 +02:00
|
|
|
s = "* " + this.player.name + " " + s.substring(s.indexOf(" ")).trim();
|
2010-12-28 22:52:39 +01:00
|
|
|
a.info(s);
|
2011-04-20 19:05:14 +02:00
|
|
|
this.minecraftServer.serverConfigurationManager.sendAll(new Packet3Chat(s));
|
2010-12-28 22:52:39 +01:00
|
|
|
} else if (s.toLowerCase().startsWith("/kill")) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.player.damageEntity((Entity) null, 1000);
|
2010-12-28 22:52:39 +01:00
|
|
|
} else if (s.toLowerCase().startsWith("/tell ")) {
|
2011-01-29 22:50:29 +01:00
|
|
|
String[] astring = s.split(" ");
|
2010-12-28 22:52:39 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (astring.length >= 3) {
|
2010-12-28 22:52:39 +01:00
|
|
|
s = s.substring(s.indexOf(" ")).trim();
|
|
|
|
s = s.substring(s.indexOf(" ")).trim();
|
2011-04-20 19:05:14 +02:00
|
|
|
s = "\u00A77" + this.player.name + " whispers " + s;
|
2011-01-29 22:50:29 +01:00
|
|
|
a.info(s + " to " + astring[1]);
|
2011-04-20 19:05:14 +02:00
|
|
|
if (!this.minecraftServer.serverConfigurationManager.a(astring[1], (Packet) (new Packet3Chat(s)))) {
|
|
|
|
this.sendPacket(new Packet3Chat("\u00A7cThere\'s no player by that name online."));
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
}
|
2011-05-22 21:24:44 +02:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
/* CraftBukkit start - No longer neaded av we have already handled it server.dispatchCommand above.
|
2010-12-28 22:52:39 +01:00
|
|
|
} else {
|
2011-01-29 22:50:29 +01:00
|
|
|
String s1;
|
2011-05-26 14:48:22 +02:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (this.minecraftServer.serverConfigurationManager.isOp(this.player.name)) {
|
2011-01-29 22:50:29 +01:00
|
|
|
s1 = s.substring(1);
|
2011-04-20 19:05:14 +02:00
|
|
|
a.info(this.player.name + " issued server command: " + s1);
|
|
|
|
this.minecraftServer.issueCommand(s1, this);
|
2011-01-29 22:50:29 +01:00
|
|
|
} else {
|
|
|
|
s1 = s.substring(1);
|
2011-04-20 19:05:14 +02:00
|
|
|
a.info(this.player.name + " tried command: " + s1);
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
2011-06-12 00:02:58 +02:00
|
|
|
// CraftBukkit end */
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(Packet18ArmAnimation packet18armanimation) {
|
2011-06-27 00:25:01 +02:00
|
|
|
if (this.player.dead) return; // CraftBukkit
|
2011-05-12 16:22:52 +02:00
|
|
|
|
2010-12-28 22:52:39 +01:00
|
|
|
if (packet18armanimation.b == 1) {
|
2011-05-14 16:29:42 +02:00
|
|
|
// CraftBukkit start - raytrace to look for 'rogue armswings'
|
2011-03-23 12:22:13 +01:00
|
|
|
float f = 1.0F;
|
2011-04-20 19:05:14 +02:00
|
|
|
float f1 = this.player.lastPitch + (this.player.pitch - this.player.lastPitch) * f;
|
|
|
|
float f2 = this.player.lastYaw + (this.player.yaw - this.player.lastYaw) * f;
|
|
|
|
double d0 = this.player.lastX + (this.player.locX - this.player.lastX) * (double) f;
|
|
|
|
double d1 = this.player.lastY + (this.player.locY - this.player.lastY) * (double) f + 1.62D - (double) this.player.height;
|
|
|
|
double d2 = this.player.lastZ + (this.player.locZ - this.player.lastZ) * (double) f;
|
|
|
|
Vec3D vec3d = Vec3D.create(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);
|
2011-03-23 12:22:13 +01:00
|
|
|
float f7 = f4 * f5;
|
|
|
|
float f8 = f3 * f5;
|
|
|
|
double d3 = 5.0D;
|
2011-04-20 19:05:14 +02:00
|
|
|
Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
|
|
|
|
MovingObjectPosition movingobjectposition = this.player.world.rayTrace(vec3d, vec3d1, true);
|
2011-03-23 12:22:13 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (movingobjectposition == null || movingobjectposition.type != EnumMovingObjectType.TILE) {
|
|
|
|
CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.inventory.getItemInHand());
|
2011-03-23 12:22:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Arm swing animation
|
2011-06-27 00:25:01 +02:00
|
|
|
PlayerAnimationEvent event = new PlayerAnimationEvent(this.getPlayer());
|
|
|
|
this.server.getPluginManager().callEvent(event);
|
2011-01-29 22:50:29 +01:00
|
|
|
// CraftBukkit end
|
|
|
|
|
2011-06-30 00:02:25 +02:00
|
|
|
this.player.w();
|
2011-01-14 14:31:10 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public void a(Packet19EntityAction packet19entityaction) {
|
2011-04-20 19:05:14 +02:00
|
|
|
// CraftBukkit start
|
2011-06-27 00:25:01 +02:00
|
|
|
if (this.player.dead) return;
|
2011-05-12 16:22:52 +02:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (packet19entityaction.animation == 1 || packet19entityaction.animation == 2) {
|
2011-06-27 00:25:01 +02:00
|
|
|
PlayerToggleSneakEvent event = new PlayerToggleSneakEvent(this.getPlayer(), packet19entityaction.animation == 1);
|
|
|
|
this.server.getPluginManager().callEvent(event);
|
|
|
|
|
2011-01-25 19:08:54 +01:00
|
|
|
if (event.isCancelled()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2011-04-20 19:05:14 +02:00
|
|
|
// CraftBukkit end
|
2011-01-25 19:08:54 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (packet19entityaction.animation == 1) {
|
|
|
|
this.player.setSneak(true);
|
|
|
|
} else if (packet19entityaction.animation == 2) {
|
|
|
|
this.player.setSneak(false);
|
|
|
|
} else if (packet19entityaction.animation == 3) {
|
|
|
|
this.player.a(false, true, true);
|
2011-06-27 00:25:01 +02:00
|
|
|
this.checkMovement = false;
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(Packet255KickDisconnect packet255kickdisconnect) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.networkManager.a("disconnect.quitting", new Object[0]);
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public int b() {
|
2011-05-26 14:48:22 +02:00
|
|
|
return this.networkManager.e();
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void sendMessage(String s) {
|
|
|
|
this.sendPacket(new Packet3Chat("\u00A77" + s));
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public String getName() {
|
|
|
|
return this.player.name;
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public void a(Packet7UseEntity packet7useentity) {
|
2011-06-27 00:25:01 +02:00
|
|
|
if (this.player.dead) return; // CraftBukkit
|
2011-05-12 16:22:52 +02:00
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
|
2011-05-26 14:48:22 +02:00
|
|
|
Entity entity = worldserver.getEntity(packet7useentity.target);
|
2011-06-19 19:58:38 +02:00
|
|
|
ItemStack itemInHand = this.player.inventory.getItemInHand();
|
2010-12-28 22:52:39 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
if (entity != null && this.player.e(entity) && this.player.g(entity) < 36.0D) {
|
2011-01-29 22:50:29 +01:00
|
|
|
if (packet7useentity.c == 0) {
|
2011-05-02 10:30:51 +02:00
|
|
|
// CraftBukkit start
|
2011-06-27 00:25:01 +02:00
|
|
|
PlayerInteractEntityEvent event = new PlayerInteractEntityEvent((Player) this.getPlayer(), entity.getBukkitEntity());
|
|
|
|
this.server.getPluginManager().callEvent(event);
|
|
|
|
|
|
|
|
if (event.isCancelled()) {
|
2011-05-02 10:30:51 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2011-04-20 19:05:14 +02:00
|
|
|
this.player.c(entity);
|
2011-06-19 07:44:57 +02:00
|
|
|
// CraftBukkit start - update the client if the item is an infinite one
|
2011-06-19 19:58:38 +02:00
|
|
|
if (itemInHand != null && itemInHand.count <= -1) {
|
2011-06-27 00:25:01 +02:00
|
|
|
this.player.updateInventory(this.player.activeContainer);
|
2011-06-19 07:44:57 +02:00
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2011-01-29 22:50:29 +01:00
|
|
|
} else if (packet7useentity.c == 1) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.player.d(entity);
|
2011-06-19 07:44:57 +02:00
|
|
|
// CraftBukkit start - update the client if the item is an infinite one
|
2011-06-19 19:58:38 +02:00
|
|
|
if (itemInHand != null && itemInHand.count <= -1) {
|
2011-06-27 00:25:01 +02:00
|
|
|
this.player.updateInventory(this.player.activeContainer);
|
2011-06-19 07:44:57 +02:00
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public void a(Packet9Respawn packet9respawn) {
|
2011-04-20 19:05:14 +02:00
|
|
|
if (this.player.health <= 0) {
|
2011-06-27 00:25:01 +02:00
|
|
|
this.player = this.minecraftServer.serverConfigurationManager.moveToWorld(this.player, 0);
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
this.getPlayer().setHandle(this.player); // CraftBukkit
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public void a(Packet101CloseWindow packet101closewindow) {
|
2011-06-27 00:25:01 +02:00
|
|
|
if (this.player.dead) return; // CraftBukkit
|
2011-05-12 16:22:52 +02:00
|
|
|
|
2011-06-30 00:02:25 +02:00
|
|
|
this.player.A();
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public void a(Packet102WindowClick packet102windowclick) {
|
2011-06-27 00:25:01 +02:00
|
|
|
if (this.player.dead) return; // CraftBukkit
|
2011-05-12 16:22:52 +02:00
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
if (this.player.activeContainer.windowId == packet102windowclick.a && this.player.activeContainer.c(this.player)) {
|
2011-04-20 22:47:26 +02:00
|
|
|
ItemStack itemstack = this.player.activeContainer.a(packet102windowclick.b, packet102windowclick.c, packet102windowclick.f, this.player);
|
2011-05-14 16:29:42 +02:00
|
|
|
|
2011-05-05 03:08:43 +02:00
|
|
|
if (ItemStack.equals(packet102windowclick.e, itemstack)) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.player.netServerHandler.sendPacket(new Packet106Transaction(packet102windowclick.a, packet102windowclick.d, true));
|
|
|
|
this.player.h = true;
|
|
|
|
this.player.activeContainer.a();
|
2011-06-30 00:02:25 +02:00
|
|
|
this.player.z();
|
2011-04-20 19:05:14 +02:00
|
|
|
this.player.h = false;
|
2010-12-28 22:52:39 +01:00
|
|
|
} else {
|
2011-06-27 00:25:01 +02:00
|
|
|
this.n.put(Integer.valueOf(this.player.activeContainer.windowId), Short.valueOf(packet102windowclick.d));
|
2011-04-20 19:05:14 +02:00
|
|
|
this.player.netServerHandler.sendPacket(new Packet106Transaction(packet102windowclick.a, packet102windowclick.d, false));
|
|
|
|
this.player.activeContainer.a(this.player, false);
|
2011-01-11 09:25:13 +01:00
|
|
|
ArrayList arraylist = new ArrayList();
|
2010-12-28 22:52:39 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
for (int i = 0; i < this.player.activeContainer.e.size(); ++i) {
|
|
|
|
arraylist.add(((Slot) this.player.activeContainer.e.get(i)).getItem());
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
this.player.a(this.player.activeContainer, arraylist);
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public void a(Packet106Transaction packet106transaction) {
|
2011-06-27 00:25:01 +02:00
|
|
|
if (this.player.dead) return; // CraftBukkit
|
2011-05-12 16:22:52 +02:00
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
Short oshort = (Short) this.n.get(Integer.valueOf(this.player.activeContainer.windowId));
|
2010-12-28 22:52:39 +01:00
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
if (oshort != null && packet106transaction.b == oshort.shortValue() && this.player.activeContainer.windowId == packet106transaction.a && !this.player.activeContainer.c(this.player)) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.player.activeContainer.a(this.player, true);
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public void a(Packet130UpdateSign packet130updatesign) {
|
2011-06-27 00:25:01 +02:00
|
|
|
if (this.player.dead) return; // CraftBukkit
|
|
|
|
|
|
|
|
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
|
2011-05-12 16:22:52 +02:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
if (worldserver.isLoaded(packet130updatesign.x, packet130updatesign.y, packet130updatesign.z)) {
|
|
|
|
TileEntity tileentity = worldserver.getTileEntity(packet130updatesign.x, packet130updatesign.y, packet130updatesign.z);
|
2011-04-20 19:05:14 +02:00
|
|
|
|
2011-03-09 00:18:14 +01:00
|
|
|
if (tileentity instanceof TileEntitySign) {
|
2011-04-20 19:05:14 +02:00
|
|
|
TileEntitySign tileentitysign = (TileEntitySign) tileentity;
|
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
if (!tileentitysign.a()) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.minecraftServer.c("Player " + this.player.name + " just tried to change non-editable sign");
|
2011-05-14 16:29:42 +02:00
|
|
|
// CraftBukkit
|
2011-04-28 07:29:36 +02:00
|
|
|
this.sendPacket(new Packet130UpdateSign(packet130updatesign.x, packet130updatesign.y, packet130updatesign.z, tileentitysign.lines));
|
2011-03-09 00:18:14 +01:00
|
|
|
return;
|
|
|
|
}
|
2011-05-14 16:29:42 +02:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-05-14 16:29:42 +02:00
|
|
|
int i;
|
|
|
|
int j;
|
2010-12-28 22:52:39 +01:00
|
|
|
|
2011-05-14 16:29:42 +02:00
|
|
|
for (j = 0; j < 4; ++j) {
|
|
|
|
boolean flag = true;
|
2010-12-28 22:52:39 +01:00
|
|
|
|
2011-05-14 16:29:42 +02:00
|
|
|
if (packet130updatesign.lines[j].length() > 15) {
|
|
|
|
flag = false;
|
|
|
|
} else {
|
|
|
|
for (i = 0; i < packet130updatesign.lines[j].length(); ++i) {
|
2011-06-27 00:25:01 +02:00
|
|
|
if (FontAllowedCharacters.allowedCharacters.indexOf(packet130updatesign.lines[j].charAt(i)) < 0) {
|
2011-05-14 16:29:42 +02:00
|
|
|
flag = false;
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
}
|
2011-05-14 16:29:42 +02:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-05-14 16:29:42 +02:00
|
|
|
if (!flag) {
|
|
|
|
packet130updatesign.lines[j] = "!?";
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
2011-05-14 16:29:42 +02:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-05-14 16:29:42 +02:00
|
|
|
if (tileentity instanceof TileEntitySign) {
|
|
|
|
j = packet130updatesign.x;
|
|
|
|
int k = packet130updatesign.y;
|
2010-12-28 22:52:39 +01:00
|
|
|
|
2011-05-14 16:29:42 +02:00
|
|
|
i = packet130updatesign.z;
|
|
|
|
TileEntitySign tileentitysign1 = (TileEntitySign) tileentity;
|
2011-02-23 13:56:36 +01:00
|
|
|
|
2011-05-14 16:29:42 +02:00
|
|
|
// CraftBukkit start
|
2011-06-27 00:25:01 +02:00
|
|
|
Player player = this.server.getPlayer(this.player);
|
|
|
|
SignChangeEvent event = new SignChangeEvent((CraftBlock) player.getWorld().getBlockAt(j, k, i), this.server.getPlayer(this.player), packet130updatesign.lines);
|
|
|
|
this.server.getPluginManager().callEvent(event);
|
2011-02-11 03:15:59 +01:00
|
|
|
|
2011-05-14 16:29:42 +02:00
|
|
|
if (!event.isCancelled()) {
|
|
|
|
for (int l = 0; l < 4; ++l) {
|
|
|
|
tileentitysign1.lines[l] = event.getLine(l);
|
|
|
|
}
|
2011-07-08 14:25:53 +02:00
|
|
|
tileentitysign1.a(false);
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
2011-05-14 16:29:42 +02:00
|
|
|
// CraftBukkit end
|
|
|
|
|
|
|
|
tileentitysign1.update();
|
2011-05-26 14:48:22 +02:00
|
|
|
worldserver.notify(j, k, i);
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-04-20 22:47:26 +02:00
|
|
|
|
|
|
|
public boolean c() {
|
|
|
|
return true;
|
|
|
|
}
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|