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-23 13:56:36 +01:00
|
|
|
import java.util.logging.Level;
|
2011-02-18 17:25:56 +01:00
|
|
|
import org.bukkit.ChatColor;
|
2011-01-15 22:36:57 +01:00
|
|
|
import org.bukkit.block.BlockFace;
|
|
|
|
import org.bukkit.block.BlockDamageLevel;
|
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:29:17 +01:00
|
|
|
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
2011-01-15 22:23:28 +01:00
|
|
|
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
2010-12-28 22:52:39 +01:00
|
|
|
import org.bukkit.craftbukkit.CraftServer;
|
2011-02-20 13:38:27 +01:00
|
|
|
import org.bukkit.craftbukkit.TextWrapper;
|
2011-01-23 13:23:13 +01:00
|
|
|
import org.bukkit.entity.Player;
|
2010-12-28 22:52:39 +01:00
|
|
|
import org.bukkit.event.Event.Type;
|
2011-02-21 23:30:01 +01:00
|
|
|
import org.bukkit.event.block.*;
|
|
|
|
import org.bukkit.event.player.*;
|
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
|
|
|
|
2011-03-09 20:43:49 +01:00
|
|
|
private static final int PLACE_DISTANCE_SQUARED = 6 * 6; // CraftBukkit here for now
|
2010-12-28 22:52:39 +01:00
|
|
|
public static Logger a = Logger.getLogger("Minecraft");
|
|
|
|
public NetworkManager b;
|
2011-01-29 22:50:29 +01:00
|
|
|
public boolean c = false;
|
2010-12-28 22:52:39 +01:00
|
|
|
private MinecraftServer d;
|
2011-02-23 13:56:36 +01:00
|
|
|
public EntityPlayer e; // CraftBukkit - private->public
|
2011-02-23 03:37:56 +01:00
|
|
|
private int f;
|
|
|
|
private int g;
|
|
|
|
private boolean h;
|
2010-12-28 22:52:39 +01:00
|
|
|
private double i;
|
2011-02-23 03:37:56 +01:00
|
|
|
private double j;
|
|
|
|
private double k;
|
|
|
|
private boolean l = true;
|
|
|
|
private Map m = 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) {
|
|
|
|
this.d = minecraftserver;
|
|
|
|
this.b = networkmanager;
|
|
|
|
networkmanager.a((NetHandler) this);
|
|
|
|
this.e = entityplayer;
|
|
|
|
entityplayer.a = this;
|
|
|
|
|
|
|
|
// CraftBukkit start
|
|
|
|
server = minecraftserver.server;
|
|
|
|
}
|
2010-12-30 06:35:30 +01:00
|
|
|
private final CraftServer server;
|
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
|
|
|
|
private int lastX;
|
|
|
|
private int lastY;
|
|
|
|
private int lastZ;
|
|
|
|
|
2011-02-25 22:40:06 +01:00
|
|
|
private double lastPosX = Double.MIN_VALUE;
|
|
|
|
private double lastPosY = Double.MIN_VALUE;
|
|
|
|
private double lastPosZ = Double.MIN_VALUE;
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
// Store the last block right clicked and what type it was
|
|
|
|
private CraftBlock lastRightClicked;
|
2011-02-25 21:59:35 +01:00
|
|
|
private BlockFace lastRightClickedFace;
|
2011-01-29 22:50:29 +01:00
|
|
|
private int lastMaterial;
|
|
|
|
|
2011-01-11 09:25:13 +01:00
|
|
|
public CraftPlayer getPlayer() {
|
2011-01-29 22:50:29 +01:00
|
|
|
return (e == null) ? null : (CraftPlayer) e.getBukkitEntity();
|
2011-01-11 09:25:13 +01:00
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2010-12-28 22:52:39 +01:00
|
|
|
public void a() {
|
2011-02-23 03:37:56 +01:00
|
|
|
this.h = false;
|
2011-01-29 22:50:29 +01:00
|
|
|
this.b.a();
|
2011-02-23 03:37:56 +01:00
|
|
|
if (this.f - this.g > 20) {
|
|
|
|
this.b((Packet) (new Packet0KeepAlive()));
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(String s) {
|
2011-02-04 16:04:28 +01:00
|
|
|
// CraftBukkit start
|
2011-02-19 21:29:51 +01:00
|
|
|
String leaveMessage = "\u00A7e" + this.e.name + " left the game.";
|
2011-02-23 13:56:36 +01:00
|
|
|
PlayerKickEvent event = new PlayerKickEvent(org.bukkit.event.Event.Type.PLAYER_KICK, server.getPlayer(this.e), s, leaveMessage);
|
|
|
|
server.getPluginManager().callEvent(event);
|
|
|
|
if (event.isCancelled()) {
|
2011-02-04 16:04:28 +01:00
|
|
|
// Do not kick the player
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Send the possibly modified leave message
|
2011-02-23 13:56:36 +01:00
|
|
|
this.b.a((Packet) (new Packet255KickDisconnect( event.getReason() )));
|
2011-02-04 16:04:28 +01:00
|
|
|
this.b.c();
|
2011-02-23 13:56:36 +01:00
|
|
|
this.d.f.a((Packet) (new Packet3Chat( event.getLeaveMessage() )));
|
2011-02-23 03:37:56 +01:00
|
|
|
// CraftBukkit end
|
|
|
|
this.d.f.c(this.e);
|
2011-01-29 22:50:29 +01:00
|
|
|
this.c = true;
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
public void a(Packet27 packet27) {
|
|
|
|
this.e.a(packet27.c(), packet27.e(), packet27.g(), packet27.h(), packet27.d(), packet27.f());
|
|
|
|
}
|
|
|
|
|
2010-12-28 22:52:39 +01:00
|
|
|
public void a(Packet10Flying packet10flying) {
|
2011-02-23 03:37:56 +01:00
|
|
|
this.h = true;
|
2011-01-29 22:50:29 +01:00
|
|
|
double d0;
|
2010-12-28 22:52:39 +01:00
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
if (!this.l) {
|
|
|
|
d0 = packet10flying.b - this.j;
|
|
|
|
if (packet10flying.a == this.i && d0 * d0 < 0.01D && packet10flying.c == this.k) {
|
|
|
|
this.l = true;
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
}
|
2010-12-29 02:25:32 +01:00
|
|
|
|
|
|
|
// CraftBukkit start
|
2011-01-23 13:23:13 +01:00
|
|
|
Player player = getPlayer();
|
2011-02-23 03:37:56 +01:00
|
|
|
Location from = new Location(player.getWorld(), i, j, k, this.e.yaw, this.e.pitch);
|
2010-12-29 02:25:32 +01:00
|
|
|
Location to = player.getLocation();
|
2011-02-25 22:40:06 +01:00
|
|
|
|
|
|
|
// Prevent 40 event-calls for less than a single pixel of movement >.>
|
|
|
|
double delta = Math.pow( this.lastPosX - this.i, 2) + Math.pow( this.lastPosY - this.j, 2) + Math.pow( this.lastPosZ - this.k, 2);
|
|
|
|
if (delta > 1f/256) {
|
2010-12-30 21:34:26 +01:00
|
|
|
PlayerMoveEvent event = new PlayerMoveEvent(Type.PLAYER_MOVE, player, from, to);
|
|
|
|
server.getPluginManager().callEvent(event);
|
2010-12-29 02:25:32 +01:00
|
|
|
|
2010-12-30 21:34:26 +01:00
|
|
|
from = event.getFrom();
|
|
|
|
to = event.isCancelled() ? from : event.getTo();
|
2010-12-29 02:25:32 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
this.e.locX = to.getX();
|
|
|
|
this.e.locY = to.getY();
|
|
|
|
this.e.locZ = to.getZ();
|
|
|
|
this.e.yaw = to.getYaw();
|
|
|
|
this.e.pitch = to.getPitch();
|
2011-02-25 22:40:06 +01:00
|
|
|
|
|
|
|
this.lastPosX = this.e.locX;
|
|
|
|
this.lastPosY = this.e.locY;
|
|
|
|
this.lastPosZ = this.e.locZ;
|
2010-12-30 21:34:26 +01:00
|
|
|
}
|
2010-12-29 02:25:32 +01:00
|
|
|
// CraftBukkit end
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
if (this.l) {
|
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-01-29 22:50:29 +01:00
|
|
|
if (this.e.vehicle != null) {
|
|
|
|
float f = this.e.yaw;
|
|
|
|
float f1 = this.e.pitch;
|
2010-12-28 22:52:39 +01:00
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
this.e.vehicle.h_();
|
2011-01-29 22:50:29 +01:00
|
|
|
d1 = this.e.locX;
|
|
|
|
d2 = this.e.locY;
|
|
|
|
d3 = this.e.locZ;
|
|
|
|
double d5 = 0.0D;
|
|
|
|
|
|
|
|
d4 = 0.0D;
|
2010-12-28 22:52:39 +01:00
|
|
|
if (packet10flying.i) {
|
2011-01-29 22:50:29 +01:00
|
|
|
f = packet10flying.e;
|
|
|
|
f1 = packet10flying.f;
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
if (packet10flying.h && packet10flying.b == -999.0D && packet10flying.d == -999.0D) {
|
|
|
|
d5 = packet10flying.a;
|
|
|
|
d4 = packet10flying.c;
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
this.e.onGround = packet10flying.g;
|
2011-02-23 03:37:56 +01:00
|
|
|
this.e.a(true);
|
2011-01-29 22:50:29 +01:00
|
|
|
this.e.c(d5, 0.0D, d4);
|
|
|
|
this.e.b(d1, d2, d3, f, f1);
|
|
|
|
this.e.motX = d5;
|
|
|
|
this.e.motZ = d4;
|
|
|
|
if (this.e.vehicle != null) {
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit
|
|
|
|
((WorldServer) this.e.world).b(this.e.vehicle, true);
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
if (this.e.vehicle != null) {
|
2011-02-23 03:37:56 +01:00
|
|
|
this.e.vehicle.h_();
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
this.d.f.b(this.e);
|
2011-02-23 03:37:56 +01:00
|
|
|
this.i = this.e.locX;
|
|
|
|
this.j = this.e.locY;
|
|
|
|
this.k = this.e.locZ;
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit
|
|
|
|
this.e.world.f(this.e);
|
2010-12-28 22:52:39 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
d0 = this.e.locY;
|
2011-02-23 03:37:56 +01:00
|
|
|
this.i = this.e.locX;
|
|
|
|
this.j = this.e.locY;
|
|
|
|
this.k = this.e.locZ;
|
2011-01-29 22:50:29 +01:00
|
|
|
d1 = this.e.locX;
|
|
|
|
d2 = this.e.locY;
|
|
|
|
d3 = this.e.locZ;
|
|
|
|
float f2 = this.e.yaw;
|
|
|
|
float f3 = this.e.pitch;
|
|
|
|
|
|
|
|
if (packet10flying.h && packet10flying.b == -999.0D && packet10flying.d == -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-01-29 22:50:29 +01:00
|
|
|
d1 = packet10flying.a;
|
|
|
|
d2 = packet10flying.b;
|
|
|
|
d3 = packet10flying.c;
|
|
|
|
d4 = packet10flying.d - packet10flying.b;
|
|
|
|
if (d4 > 1.65D || d4 < 0.1D) {
|
|
|
|
this.a("Illegal stance");
|
|
|
|
a.warning(this.e.name + " had an illegal stance: " + d4);
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2010-12-28 22:52:39 +01:00
|
|
|
if (packet10flying.i) {
|
2011-01-29 22:50:29 +01:00
|
|
|
f2 = packet10flying.e;
|
|
|
|
f3 = packet10flying.f;
|
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
this.e.a(true);
|
|
|
|
this.e.bl = 0.0F;
|
|
|
|
this.e.b(this.i, this.j, this.k, f2, f3);
|
2011-01-29 22:50:29 +01:00
|
|
|
d4 = d1 - this.e.locX;
|
|
|
|
double d6 = d2 - this.e.locY;
|
|
|
|
double d7 = d3 - this.e.locZ;
|
|
|
|
float f4 = 0.0625F;
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit
|
|
|
|
boolean flag = this.e.world.a(this.e, this.e.boundingBox.b().e((double) f4, (double) f4, (double) f4)).size() == 0;
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
this.e.c(d4, d6, d7);
|
|
|
|
d4 = d1 - this.e.locX;
|
|
|
|
d6 = d2 - this.e.locY;
|
|
|
|
if (d6 > -0.5D || d6 < 0.5D) {
|
|
|
|
d6 = 0.0D;
|
|
|
|
}
|
|
|
|
|
|
|
|
d7 = d3 - this.e.locZ;
|
|
|
|
double d8 = d4 * d4 + d6 * d6 + d7 * d7;
|
2010-12-28 22:52:39 +01:00
|
|
|
boolean flag1 = false;
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
if (d8 > 0.0625D && !this.e.E()) {
|
2010-12-28 22:52:39 +01:00
|
|
|
flag1 = true;
|
2011-01-29 22:50:29 +01:00
|
|
|
a.warning(this.e.name + " moved wrongly!");
|
|
|
|
System.out.println("Got position " + d1 + ", " + d2 + ", " + d3);
|
|
|
|
System.out.println("Expected " + this.e.locX + ", " + this.e.locY + ", " + this.e.locZ);
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
this.e.b(d1, d2, d3, f2, f3);
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit
|
|
|
|
boolean flag2 = this.e.world.a(this.e, this.e.boundingBox.b().e((double) f4, (double) f4, (double) f4)).size() == 0;
|
2010-12-28 22:52:39 +01:00
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
if (flag && (flag1 || !flag2) && !this.e.E()) {
|
|
|
|
this.a(this.i, this.j, this.k, f2, f3);
|
2010-12-28 22:52:39 +01:00
|
|
|
return;
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
this.e.onGround = packet10flying.g;
|
|
|
|
this.d.f.b(this.e);
|
|
|
|
this.e.b(this.e.locY - d0, packet10flying.g);
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public void a(double d0, double d1, double d2, float f, float f1) {
|
2010-12-29 02:25:32 +01:00
|
|
|
// CraftBukkit start
|
2011-01-23 13:23:13 +01:00
|
|
|
Player player = getPlayer();
|
2010-12-29 02:25:32 +01:00
|
|
|
Location from = player.getLocation();
|
2011-01-29 22:50:29 +01:00
|
|
|
Location to = new Location(player.getWorld(), d0, d1, d2, f, f1);
|
2010-12-29 02:25:32 +01:00
|
|
|
PlayerMoveEvent event = new PlayerMoveEvent(Type.PLAYER_TELEPORT, player, from, to);
|
|
|
|
server.getPluginManager().callEvent(event);
|
|
|
|
|
|
|
|
from = event.getFrom();
|
|
|
|
to = event.isCancelled() ? from : event.getTo();
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
d0 = to.getX();
|
|
|
|
d1 = to.getY();
|
|
|
|
d2 = to.getZ();
|
|
|
|
f = to.getYaw();
|
|
|
|
f1 = to.getPitch();
|
2010-12-29 02:25:32 +01:00
|
|
|
// CraftBukkit end
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
this.l = false;
|
|
|
|
this.i = d0;
|
|
|
|
this.j = d1;
|
|
|
|
this.k = d2;
|
2011-01-29 22:50:29 +01:00
|
|
|
this.e.b(d0, d1, d2, f, f1);
|
|
|
|
this.e.a.b((Packet) (new Packet13PlayerLookMove(d0, d1 + 1.6200000047683716D, d1, d2, f, f1, false)));
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void a(Packet14BlockDig packet14blockdig) {
|
|
|
|
if (packet14blockdig.e == 4) {
|
2011-02-23 03:37:56 +01:00
|
|
|
this.e.y();
|
2011-01-29 22:50:29 +01:00
|
|
|
} else {
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit
|
|
|
|
boolean flag = ((WorldServer) this.e.world).v = this.d.f.h(this.e.name);
|
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) {
|
|
|
|
double d0 = this.e.locX - ((double) i + 0.5D);
|
|
|
|
double d1 = this.e.locY - ((double) j + 0.5D);
|
|
|
|
double d2 = this.e.locZ - ((double) k + 0.5D);
|
|
|
|
double d3 = d0 * d0 + d1 * d1 + d2 * d2;
|
|
|
|
|
|
|
|
if (d3 > 36.0D) {
|
|
|
|
return;
|
|
|
|
}
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit
|
|
|
|
ChunkCoordinates chunkcoordinates = this.e.world.l();
|
2011-02-23 03:37:56 +01:00
|
|
|
int l = (int) MathHelper.e((float) (i - chunkcoordinates.a));
|
|
|
|
int i1 = (int) MathHelper.e((float) (k - chunkcoordinates.c));
|
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
|
|
|
// CraftBukkit start
|
|
|
|
CraftPlayer player = getPlayer();
|
2011-01-31 01:02:47 +01:00
|
|
|
CraftBlock block = (CraftBlock) player.getWorld().getBlockAt(i, j, k);
|
2011-01-29 22:50:29 +01:00
|
|
|
int blockId = block.getTypeId();
|
|
|
|
float damage = 0;
|
2011-02-09 07:21:19 +01:00
|
|
|
if (Block.byId[blockId] != null) {
|
2011-02-23 13:56:36 +01:00
|
|
|
damage = Block.byId[blockId].a(player.getHandle()); // Get amount of damage going to block
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2011-01-10 04:00:53 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (packet14blockdig.e == 0) {
|
2011-02-10 05:02:37 +01:00
|
|
|
// CraftBukkit start
|
2011-02-23 03:37:56 +01:00
|
|
|
if (i1 > this.d.spawnProtection || flag) {
|
2011-02-28 05:52:46 +01:00
|
|
|
BlockDamageEvent event;
|
|
|
|
// If the amount of damage that the player is going to do to the block
|
|
|
|
// is >= 1, then the block is going to break (eg, flowers, torches)
|
|
|
|
if (damage >= 1.0F) {
|
|
|
|
// if we are destroying either a redstone wire with a current greater than 0 or
|
|
|
|
// a redstone torch that is on, then we should notify plugins that this block has
|
|
|
|
// returned to a current value of 0 (since it will once the redstone is destroyed)
|
2011-03-04 15:20:05 +01:00
|
|
|
if ((blockId == Block.REDSTONE_WIRE.id && block.getData() > 0) || blockId == Block.REDSTONE_TORCH_ON.id) {
|
|
|
|
server.getPluginManager().callEvent( new BlockRedstoneEvent(block, (blockId == Block.REDSTONE_WIRE.id ? block.getData() : 15), 0));
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
2011-02-28 05:52:46 +01:00
|
|
|
event = new BlockDamageEvent(Type.BLOCK_DAMAGED, block, BlockDamageLevel.BROKEN, player);
|
|
|
|
} else {
|
|
|
|
event = new BlockDamageEvent(Type.BLOCK_DAMAGED, block, BlockDamageLevel.STARTED, player);
|
|
|
|
}
|
|
|
|
server.getPluginManager().callEvent(event);
|
|
|
|
if (!event.isCancelled()) {
|
|
|
|
this.e.c.a(i, j, k);
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
} else if (packet14blockdig.e == 2) {
|
|
|
|
// CraftBukkit start - Get last block that the player hit
|
|
|
|
// Otherwise the block is a Bedrock @(0,0,0)
|
|
|
|
block = (CraftBlock) player.getWorld().getBlockAt(lastX, lastY, lastZ);
|
|
|
|
BlockDamageEvent event = new BlockDamageEvent(Type.BLOCK_DAMAGED, block, BlockDamageLevel.STOPPED, player);
|
|
|
|
server.getPluginManager().callEvent(event);
|
|
|
|
if (!event.isCancelled()) {
|
2011-02-23 03:37:56 +01:00
|
|
|
this.e.c.b(i, j, k);
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
} else if (packet14blockdig.e == 3) {
|
2011-02-23 03:37:56 +01:00
|
|
|
double d4 = this.e.locX - ((double) i + 0.5D);
|
|
|
|
double d5 = this.e.locY - ((double) j + 0.5D);
|
|
|
|
double d6 = this.e.locZ - ((double) k + 0.5D);
|
|
|
|
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-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit
|
2011-02-23 03:37:56 +01:00
|
|
|
this.e.a.b((Packet) (new Packet53BlockChange(i, j, k, this.e.world)));
|
2011-01-10 02:36:19 +01:00
|
|
|
}
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit start
|
2011-01-29 22:50:29 +01:00
|
|
|
lastX = i;
|
|
|
|
lastY = j;
|
|
|
|
lastZ = k;
|
2011-01-10 02:57:47 +01:00
|
|
|
|
2011-02-23 13:56:36 +01:00
|
|
|
((WorldServer) this.e.world).v = false;
|
2011-02-23 03:37:56 +01:00
|
|
|
// CraftBukkit end
|
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-02-23 03:37:56 +01:00
|
|
|
ItemStack itemstack = this.e.inventory.b();
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit start
|
2011-02-23 13:56:36 +01:00
|
|
|
boolean flag = ((WorldServer) this.e.world).v = this.d.f.h(this.e.name);
|
|
|
|
|
2011-01-08 11:49:42 +01:00
|
|
|
CraftBlock blockClicked = null;
|
2011-02-25 21:59:35 +01:00
|
|
|
BlockFace blockFace = BlockFace.SELF;
|
2011-01-10 02:36:19 +01:00
|
|
|
|
2011-01-08 11:49:42 +01:00
|
|
|
if (packet15place.d == 255) {
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit ITEM_USE -- if we have a lastRightClicked then it could be a usable location
|
2011-02-25 21:59:35 +01:00
|
|
|
if ((packet15place.e != null && packet15place.e.id == lastMaterial) || lastMaterial == 0) {
|
|
|
|
blockClicked = this.lastRightClicked;
|
|
|
|
blockFace = this.lastRightClickedFace;
|
2011-01-08 11:49:42 +01:00
|
|
|
}
|
2011-02-25 21:59:35 +01:00
|
|
|
this.lastRightClicked = null;
|
|
|
|
this.lastRightClickedFace = null;
|
|
|
|
this.lastMaterial = 0;
|
2011-01-08 11:49:42 +01:00
|
|
|
} else {
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit RIGHTCLICK or BLOCK_PLACE .. or nothing
|
2011-02-23 13:56:36 +01:00
|
|
|
blockClicked = (CraftBlock) ((WorldServer) e.world).getWorld().getBlockAt(packet15place.a, packet15place.b, packet15place.c);
|
2011-01-10 02:36:19 +01:00
|
|
|
blockFace = CraftBlock.notchToBlockFace(packet15place.d);
|
2011-02-25 21:59:35 +01:00
|
|
|
|
|
|
|
this.lastRightClicked = blockClicked;
|
|
|
|
this.lastMaterial = (packet15place.e == null) ? 0 : packet15place.e.id;
|
|
|
|
this.lastRightClickedFace = blockFace;
|
2011-01-08 11:49:42 +01:00
|
|
|
}
|
2011-01-10 02:36:19 +01:00
|
|
|
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit if rightclick decremented the item, always send the update packet.
|
|
|
|
// this is not here for CraftBukkit's own functionality; rather it is to fix
|
2011-01-07 11:46:11 +01:00
|
|
|
// a notch bug where the item doesn't update correctly.
|
|
|
|
boolean always = false;
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit end
|
2011-01-10 02:36:19 +01:00
|
|
|
|
2010-12-28 22:52:39 +01:00
|
|
|
if (packet15place.d == 255) {
|
|
|
|
if (itemstack == null) {
|
|
|
|
return;
|
|
|
|
}
|
2011-01-10 02:36:19 +01:00
|
|
|
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit start
|
2011-01-23 13:23:13 +01:00
|
|
|
Type eventType = Type.PLAYER_ITEM;
|
2011-01-29 22:50:29 +01:00
|
|
|
Player who = (this.e == null) ? null : (Player) this.e.getBukkitEntity();
|
2011-01-23 13:23:13 +01:00
|
|
|
org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-02-02 00:32:18 +01:00
|
|
|
PlayerItemEvent event = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
|
2011-01-10 02:36:19 +01:00
|
|
|
|
2011-03-09 20:43:49 +01:00
|
|
|
if (blockClicked != null && blockFace != null) {
|
|
|
|
CraftBlock block = (CraftBlock)blockClicked.getFace(blockFace);
|
|
|
|
Location eyeLoc = getPlayer().getEyeLocation();
|
|
|
|
if (Math.pow(eyeLoc.getX() - block.getX(), 2) + Math.pow(eyeLoc.getY() - block.getY(), 2) + Math.pow(eyeLoc.getZ() - block.getZ(), 2) > PLACE_DISTANCE_SQUARED) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit We still call this event even in spawn protection.
|
2011-01-08 11:49:42 +01:00
|
|
|
// Don't call this event if using Buckets / signs
|
2011-01-23 13:23:13 +01:00
|
|
|
switch (itemInHand.getType()) {
|
2011-01-14 14:31:10 +01:00
|
|
|
case SIGN:
|
|
|
|
case BUCKET:
|
|
|
|
case WATER_BUCKET:
|
|
|
|
case LAVA_BUCKET:
|
2011-01-10 02:36:19 +01:00
|
|
|
break;
|
|
|
|
default:
|
2011-01-29 22:50:29 +01:00
|
|
|
server.getPluginManager().callEvent(event);
|
2011-01-08 11:49:42 +01:00
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (!event.isCancelled()) {
|
|
|
|
int itemstackAmount = itemstack.count;
|
2011-02-05 19:15:04 +01:00
|
|
|
this.e.c.a(this.e, this.e.world, itemstack);
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit notch decrements the counter by 1 in the above method with food,
|
2011-01-08 11:49:42 +01:00
|
|
|
// snowballs and so forth, but he does it in a place that doesnt cause the
|
|
|
|
// inventory update packet to get sent
|
2011-01-29 22:50:29 +01:00
|
|
|
always = (itemstack.count != itemstackAmount);
|
2011-01-07 11:46:11 +01:00
|
|
|
}
|
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;
|
|
|
|
int l = packet15place.d;
|
2011-02-25 21:59:35 +01:00
|
|
|
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit
|
|
|
|
ChunkCoordinates chunkcoordinates = this.e.world.l();
|
2011-02-23 03:37:56 +01:00
|
|
|
int i1 = (int) MathHelper.e((float) (i - chunkcoordinates.a));
|
|
|
|
int j1 = (int) MathHelper.e((float) (k - chunkcoordinates.c));
|
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
|
|
|
|
|
|
|
// CraftBukkit start - spawn protection moved to ItemBlock!!!
|
2011-03-09 20:43:49 +01:00
|
|
|
Location eyeLoc = getPlayer().getEyeLocation();
|
|
|
|
if (Math.pow(eyeLoc.getX() - i, 2) + Math.pow(eyeLoc.getY() - j, 2) + Math.pow(eyeLoc.getZ() - k, 2) > PLACE_DISTANCE_SQUARED) {
|
|
|
|
return;
|
|
|
|
}
|
2011-01-07 11:46:11 +01:00
|
|
|
CraftItemStack craftItem = new CraftItemStack(itemstack);
|
2011-01-23 13:23:13 +01:00
|
|
|
Player player = getPlayer();
|
2011-01-29 22:50:29 +01:00
|
|
|
BlockRightClickEvent event = new BlockRightClickEvent(Type.BLOCK_RIGHTCLICKED, blockClicked, blockFace, craftItem, player);
|
|
|
|
server.getPluginManager().callEvent(event);
|
2011-01-10 02:36:19 +01:00
|
|
|
|
2011-02-05 19:15:04 +01:00
|
|
|
this.e.c.a(this.e, this.e.world, itemstack, i, j, k, l);
|
2011-02-21 23:30:01 +01:00
|
|
|
this.e.a.b((Packet) (new Packet53BlockChange(i, j, k, this.e.world)));
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit end
|
2011-02-25 21:59:35 +01:00
|
|
|
|
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-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit
|
|
|
|
this.e.a.b((Packet) (new Packet53BlockChange(i, j, k, this.e.world)));
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
if (itemstack != null && itemstack.count == 0) {
|
|
|
|
this.e.inventory.a[this.e.inventory.c] = null;
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
this.e.h = true;
|
2011-01-29 22:50:29 +01:00
|
|
|
this.e.inventory.a[this.e.inventory.c] = ItemStack.b(this.e.inventory.a[this.e.inventory.c]);
|
|
|
|
Slot slot = this.e.activeContainer.a(this.e.inventory, this.e.inventory.c);
|
|
|
|
|
|
|
|
this.e.activeContainer.a();
|
2011-02-23 03:37:56 +01:00
|
|
|
this.e.h = false;
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit
|
|
|
|
if (!ItemStack.a(this.e.inventory.b(), packet15place.e) || always) {
|
2011-02-23 03:37:56 +01:00
|
|
|
this.b((Packet) (new Packet103SetSlot(this.e.activeContainer.f, slot.a, this.e.inventory.b())));
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit
|
|
|
|
((WorldServer) this.e.world).v = 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-03-10 01:16:16 +01:00
|
|
|
if (!this.c) {
|
|
|
|
a.info(this.e.name + " lost connection: " + s);
|
|
|
|
this.d.f.a((Packet) (new Packet3Chat("\u00A7e" + this.e.name + " left the game.")));
|
|
|
|
this.d.f.c(this.e);
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
this.c = 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());
|
|
|
|
this.a("Protocol error, unexpected packet");
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void b(Packet packet) {
|
2011-01-29 22:50:29 +01:00
|
|
|
this.b.a(packet);
|
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-03-10 21:17:01 +01:00
|
|
|
// CraftBukkit start
|
2011-03-09 18:23:20 +01:00
|
|
|
if (packet16blockitemswitch.a < 0 || packet16blockitemswitch.a > 8) {
|
|
|
|
server.getLogger().severe(
|
|
|
|
"Player " + getPlayer().getName() + "/" + getPlayer().getAddress().toString() +
|
2011-03-10 21:17:01 +01:00
|
|
|
" just sent an invalid ItemInHandIndex: " + packet16blockitemswitch.a +
|
2011-03-09 18:23:20 +01:00
|
|
|
" - very likely a crashing exploit attempt. Recommend ban, and sending a package of joy their way."
|
|
|
|
);
|
2011-03-09 22:45:57 +01:00
|
|
|
this.b(new Packet1Login("", "", 0, 0, (byte)0));
|
|
|
|
this.a("Exploits.");
|
2011-03-09 18:23:20 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-01-31 02:35:29 +01:00
|
|
|
PlayerItemHeldEvent event = new PlayerItemHeldEvent(Type.PLAYER_ITEM_HELD, getPlayer(), e.inventory.c, packet16blockitemswitch.a);
|
|
|
|
server.getPluginManager().callEvent(event);
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit end
|
2011-01-31 02:35:29 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
this.e.inventory.c = packet16blockitemswitch.a;
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void a(Packet3Chat packet3chat) {
|
|
|
|
String s = packet3chat.a;
|
|
|
|
|
|
|
|
if (s.length() > 100) {
|
2011-01-29 22:50:29 +01:00
|
|
|
this.a("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) {
|
|
|
|
if (FontAllowedCharacters.a.indexOf(s.charAt(i)) < 0) {
|
|
|
|
this.a("Illegal characters in chat");
|
|
|
|
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
|
|
|
|
chat(s);
|
2011-02-17 06:46:01 +01:00
|
|
|
}
|
|
|
|
}
|
2011-02-20 13:38:27 +01:00
|
|
|
|
2011-02-17 06:46:01 +01:00
|
|
|
public boolean chat(String msg) {
|
|
|
|
if (msg.startsWith("/")) {
|
|
|
|
this.c(msg);
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
// CraftBukkit start
|
|
|
|
Player player = getPlayer();
|
|
|
|
PlayerChatEvent event = new PlayerChatEvent(Type.PLAYER_CHAT, player, msg);
|
|
|
|
server.getPluginManager().callEvent(event);
|
2011-02-23 13:56:36 +01:00
|
|
|
|
2011-02-17 06:46:01 +01:00
|
|
|
if (event.isCancelled()) {
|
|
|
|
return true;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
2011-02-17 06:46:01 +01:00
|
|
|
|
2011-02-23 13:56:36 +01:00
|
|
|
msg = String.format(event.getFormat(), event.getPlayer().getDisplayName(), event.getMessage());
|
2011-02-17 06:46:01 +01:00
|
|
|
a.info(msg);
|
2011-02-26 20:37:19 +01:00
|
|
|
for (Player recipient : event.getRecipients()) {
|
|
|
|
recipient.sendMessage(msg);
|
2011-02-20 13:38:27 +01:00
|
|
|
}
|
|
|
|
// CraftBukkit end
|
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;
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
2011-02-17 06:46:01 +01:00
|
|
|
// CraftBukkit end
|
2010-12-28 22:52:39 +01:00
|
|
|
|
|
|
|
private void c(String s) {
|
|
|
|
// CraftBukkit start
|
2011-01-23 13:23:13 +01:00
|
|
|
CraftPlayer player = getPlayer();
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-02-19 10:40:32 +01:00
|
|
|
PlayerChatEvent event = new PlayerChatEvent(Type.PLAYER_COMMAND_PREPROCESS, player, s);
|
2010-12-28 22:52:39 +01:00
|
|
|
server.getPluginManager().callEvent(event);
|
2011-01-10 02:36:19 +01:00
|
|
|
if (event.isCancelled()) {
|
|
|
|
return;
|
|
|
|
}
|
2011-02-18 17:25:56 +01:00
|
|
|
|
|
|
|
boolean targetPluginFound = false;
|
|
|
|
|
|
|
|
try {
|
|
|
|
targetPluginFound = server.dispatchCommand(player, s.substring(1));
|
|
|
|
} catch (CommandException ex) {
|
|
|
|
player.sendMessage(ChatColor.RED + "An internal error occured while attempting to perform this command");
|
|
|
|
Logger.getLogger(NetServerHandler.class.getName()).log(Level.SEVERE, null, ex);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-02-17 06:46:01 +01:00
|
|
|
if (targetPluginFound) {
|
|
|
|
return;
|
|
|
|
}
|
2011-02-19 10:40:32 +01:00
|
|
|
|
2010-12-28 22:52:39 +01:00
|
|
|
// CraftBukkit stop
|
|
|
|
|
|
|
|
if (s.toLowerCase().startsWith("/me ")) {
|
2011-01-29 22:50:29 +01:00
|
|
|
s = "* " + this.e.name + " " + s.substring(s.indexOf(" ")).trim();
|
2010-12-28 22:52:39 +01:00
|
|
|
a.info(s);
|
2011-01-29 22:50:29 +01:00
|
|
|
this.d.f.a((Packet) (new Packet3Chat(s)));
|
2010-12-28 22:52:39 +01:00
|
|
|
} else if (s.toLowerCase().startsWith("/kill")) {
|
2011-01-29 22:50:29 +01:00
|
|
|
this.e.a((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-02-19 21:29:51 +01:00
|
|
|
s = "\u00A77" + this.e.name + " whispers " + s;
|
2011-01-29 22:50:29 +01:00
|
|
|
a.info(s + " to " + astring[1]);
|
|
|
|
if (!this.d.f.a(astring[1], (Packet) (new Packet3Chat(s)))) {
|
2011-02-19 21:29:51 +01:00
|
|
|
this.b((Packet) (new Packet3Chat("\u00A7cThere\'s no player by that name online.")));
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2011-01-29 22:50:29 +01:00
|
|
|
String s1;
|
2010-12-28 22:52:39 +01:00
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
if (this.d.f.h(this.e.name)) {
|
2011-01-29 22:50:29 +01:00
|
|
|
s1 = s.substring(1);
|
|
|
|
a.info(this.e.name + " issued server command: " + s1);
|
|
|
|
this.d.a(s1, (ICommandListener) this);
|
|
|
|
} else {
|
|
|
|
s1 = s.substring(1);
|
|
|
|
a.info(this.e.name + " tried command: " + s1);
|
|
|
|
}
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(Packet18ArmAnimation packet18armanimation) {
|
|
|
|
if (packet18armanimation.b == 1) {
|
2011-01-29 22:50:29 +01:00
|
|
|
// CraftBukkit start - Arm swing animation
|
2011-01-23 13:23:13 +01:00
|
|
|
Player player = getPlayer();
|
|
|
|
PlayerAnimationEvent event = new PlayerAnimationEvent(Type.PLAYER_ANIMATION, player);
|
2011-01-18 17:07:49 +01:00
|
|
|
server.getPluginManager().callEvent(event);
|
2011-01-29 22:50:29 +01:00
|
|
|
// CraftBukkit end
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
this.e.r();
|
2011-01-14 14:31:10 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public void a(Packet19EntityAction packet19entityaction) {
|
2011-01-25 19:08:54 +01:00
|
|
|
// CraftBukkit: Toggle Sneak
|
|
|
|
if (packet19entityaction.b == 1 || packet19entityaction.b == 2) {
|
|
|
|
Player player = getPlayer();
|
|
|
|
PlayerToggleSneakEvent event = new PlayerToggleSneakEvent(Type.PLAYER_TOGGLE_SNEAK, player);
|
|
|
|
server.getPluginManager().callEvent(event);
|
|
|
|
if (event.isCancelled()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// CraftBukkit: Set Sneaking
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (packet19entityaction.b == 1) {
|
|
|
|
this.e.b(true);
|
|
|
|
} else if (packet19entityaction.b == 2) {
|
|
|
|
this.e.b(false);
|
2011-02-23 03:37:56 +01:00
|
|
|
} else if (packet19entityaction.b == 3) {
|
|
|
|
this.e.a(false, true);
|
|
|
|
this.l = false;
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(Packet255KickDisconnect packet255kickdisconnect) {
|
2011-01-29 22:50:29 +01:00
|
|
|
this.b.a("disconnect.quitting", new Object[0]);
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public int b() {
|
2011-01-29 22:50:29 +01:00
|
|
|
return this.b.d();
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void b(String s) {
|
2011-02-19 21:29:51 +01:00
|
|
|
this.b((Packet) (new Packet3Chat("\u00A77" + s)));
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public String c() {
|
2011-01-29 22:50:29 +01:00
|
|
|
return this.e.name;
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public void a(Packet7UseEntity packet7useentity) {
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit
|
|
|
|
Entity entity = ((WorldServer) this.e.world).a(packet7useentity.b);
|
2010-12-28 22:52:39 +01:00
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
if (entity != null && this.e.e(entity) && this.e.f(entity) < 4.0F) {
|
2011-01-29 22:50:29 +01:00
|
|
|
if (packet7useentity.c == 0) {
|
2011-02-23 03:37:56 +01:00
|
|
|
this.e.c(entity);
|
2011-01-29 22:50:29 +01:00
|
|
|
} else if (packet7useentity.c == 1) {
|
2011-02-23 03:37:56 +01:00
|
|
|
this.e.d(entity);
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public void a(Packet9Respawn packet9respawn) {
|
|
|
|
if (this.e.health <= 0) {
|
|
|
|
this.e = this.d.f.d(this.e);
|
|
|
|
|
|
|
|
// CraftBukkit start
|
2011-01-23 13:23:13 +01:00
|
|
|
CraftPlayer player = getPlayer();
|
2011-02-23 13:56:36 +01:00
|
|
|
player.setHandle(this.e);
|
2011-01-29 22:50:29 +01:00
|
|
|
// CraftBukkit end
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public void a(Packet101CloseWindow packet101closewindow) {
|
2011-02-23 03:37:56 +01:00
|
|
|
this.e.v();
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public void a(Packet102WindowClick packet102windowclick) {
|
|
|
|
if (this.e.activeContainer.f == packet102windowclick.a && this.e.activeContainer.c(this.e)) {
|
|
|
|
ItemStack itemstack = this.e.activeContainer.a(packet102windowclick.b, packet102windowclick.c, this.e);
|
2010-12-28 22:52:39 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (ItemStack.a(packet102windowclick.e, itemstack)) {
|
|
|
|
this.e.a.b((Packet) (new Packet106Transaction(packet102windowclick.a, packet102windowclick.d, true)));
|
2011-02-23 03:37:56 +01:00
|
|
|
this.e.h = true;
|
2011-01-29 22:50:29 +01:00
|
|
|
this.e.activeContainer.a();
|
2011-02-23 03:37:56 +01:00
|
|
|
this.e.u();
|
|
|
|
this.e.h = false;
|
2010-12-28 22:52:39 +01:00
|
|
|
} else {
|
2011-02-23 03:37:56 +01:00
|
|
|
this.m.put(Integer.valueOf(this.e.activeContainer.f), Short.valueOf(packet102windowclick.d));
|
2011-01-29 22:50:29 +01:00
|
|
|
this.e.a.b((Packet) (new Packet106Transaction(packet102windowclick.a, packet102windowclick.d, false)));
|
|
|
|
this.e.activeContainer.a(this.e, false);
|
2011-01-11 09:25:13 +01:00
|
|
|
ArrayList arraylist = new ArrayList();
|
2010-12-28 22:52:39 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
for (int i = 0; i < this.e.activeContainer.e.size(); ++i) {
|
2011-02-23 03:37:56 +01:00
|
|
|
arraylist.add(((Slot) this.e.activeContainer.e.get(i)).b());
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
this.e.a(this.e.activeContainer, arraylist);
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public void a(Packet106Transaction packet106transaction) {
|
2011-02-23 03:37:56 +01:00
|
|
|
Short oshort = (Short) this.m.get(Integer.valueOf(this.e.activeContainer.f));
|
2010-12-28 22:52:39 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (oshort != null && packet106transaction.b == oshort.shortValue() && this.e.activeContainer.f == packet106transaction.a && !this.e.activeContainer.c(this.e)) {
|
|
|
|
this.e.activeContainer.a(this.e, true);
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public void a(Packet130UpdateSign packet130updatesign) {
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit start
|
|
|
|
if (this.e.world.f(packet130updatesign.a, packet130updatesign.b, packet130updatesign.c)) {
|
|
|
|
TileEntity tileentity = this.e.world.getTileEntity(packet130updatesign.a, packet130updatesign.b, packet130updatesign.c);
|
2011-03-09 00:18:14 +01:00
|
|
|
if (tileentity instanceof TileEntitySign) {
|
|
|
|
TileEntitySign sign = (TileEntitySign)tileentity;
|
|
|
|
if (!sign.fresh) {
|
|
|
|
int x = packet130updatesign.a;
|
|
|
|
int y = packet130updatesign.b;
|
|
|
|
int z = packet130updatesign.c;
|
|
|
|
server.getLogger().severe("Player " + getPlayer().getName() + "/" + getPlayer().getAddress().toString() + " just tried to change the sign text at " +
|
2011-03-09 17:56:22 +01:00
|
|
|
x + "," + y + "," + z + " - very likely an exploit attempt. Recommend ban, and sending a package of joy their way.");
|
2011-03-09 22:45:57 +01:00
|
|
|
this.b(new Packet1Login("", "", 0, 0, (byte)0));
|
|
|
|
this.a("Exploits.");
|
2011-03-09 00:18:14 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit end
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
int i;
|
|
|
|
int j;
|
2010-12-28 22:52:39 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
for (i = 0; i < 4; ++i) {
|
2010-12-28 22:52:39 +01:00
|
|
|
boolean flag = true;
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (packet130updatesign.d[i].length() > 15) {
|
2010-12-28 22:52:39 +01:00
|
|
|
flag = false;
|
|
|
|
} else {
|
2011-01-29 22:50:29 +01:00
|
|
|
for (j = 0; j < packet130updatesign.d[i].length(); ++j) {
|
|
|
|
if (FontAllowedCharacters.a.indexOf(packet130updatesign.d[i].charAt(j)) < 0) {
|
2010-12-28 22:52:39 +01:00
|
|
|
flag = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2010-12-28 22:52:39 +01:00
|
|
|
if (!flag) {
|
2011-01-29 22:50:29 +01:00
|
|
|
packet130updatesign.d[i] = "!?";
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tileentity instanceof TileEntitySign) {
|
2011-01-29 22:50:29 +01:00
|
|
|
i = packet130updatesign.a;
|
|
|
|
int k = packet130updatesign.b;
|
|
|
|
|
|
|
|
j = packet130updatesign.c;
|
2010-12-28 22:52:39 +01:00
|
|
|
TileEntitySign tileentitysign = (TileEntitySign) tileentity;
|
|
|
|
|
2011-02-11 03:15:59 +01:00
|
|
|
// CraftBukkit start - SIGN_CHANGE hook
|
|
|
|
Player player = server.getPlayer(this.e);
|
2011-02-23 13:56:36 +01:00
|
|
|
SignChangeEvent event = new SignChangeEvent(org.bukkit.event.Event.Type.SIGN_CHANGE, (CraftBlock) player.getWorld().getBlockAt(i, k, j), server.getPlayer(this.e), packet130updatesign.d);
|
|
|
|
server.getPluginManager().callEvent(event);
|
|
|
|
|
|
|
|
if (event.isCancelled()) {
|
2011-02-11 03:15:59 +01:00
|
|
|
// Normally we would return here, but we have to update the sign with blank text if it's been cancelled
|
|
|
|
// Otherwise the client will have bad text on their sign (client shows text changes as they type)
|
2011-02-23 13:56:36 +01:00
|
|
|
for (int l = 0; l < 4; ++l) {
|
|
|
|
event.setLine(l, "");
|
2011-02-11 03:15:59 +01:00
|
|
|
}
|
2011-03-09 00:18:14 +01:00
|
|
|
} else {
|
|
|
|
tileentitysign.fresh = false;
|
2011-02-11 03:15:59 +01:00
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
for (int l = 0; l < 4; ++l) {
|
2011-02-23 13:56:36 +01:00
|
|
|
tileentitysign.a[l] = event.getLine(l);
|
|
|
|
// CraftBukkit
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
tileentitysign.h();
|
2011-02-23 13:56:36 +01:00
|
|
|
this.e.world.g(i, k, j); // CraftBukkit
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|