2010-12-28 22:52:39 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2011-01-11 09:25:13 +01:00
|
|
|
import java.io.PrintStream;
|
2010-12-28 22:52:39 +01:00
|
|
|
import java.util.*;
|
|
|
|
import java.util.logging.Logger;
|
2011-01-08 11:49:42 +01:00
|
|
|
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit start
|
2011-01-08 11:49:42 +01:00
|
|
|
import org.bukkit.BlockFace;
|
2011-01-11 09:25:13 +01:00
|
|
|
import org.bukkit.BlockDamageLevel;
|
2010-12-29 02:25:32 +01:00
|
|
|
import org.bukkit.Location;
|
2011-01-05 10:54:23 +01:00
|
|
|
import org.bukkit.craftbukkit.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;
|
|
|
|
import org.bukkit.event.Event.Type;
|
2011-01-15 21:26:05 +01:00
|
|
|
import org.bukkit.event.block.BlockDamageEvent;
|
|
|
|
import org.bukkit.event.block.BlockRightClickEvent;
|
2010-12-28 22:52:39 +01:00
|
|
|
import org.bukkit.event.player.PlayerChatEvent;
|
2011-01-07 11:46:11 +01:00
|
|
|
import org.bukkit.event.player.PlayerItemEvent;
|
2010-12-29 02:25:32 +01:00
|
|
|
import org.bukkit.event.player.PlayerMoveEvent;
|
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");
|
|
|
|
public NetworkManager b;
|
|
|
|
public boolean c;
|
|
|
|
private MinecraftServer d;
|
|
|
|
private EntityPlayerMP e;
|
|
|
|
private int f;
|
|
|
|
private double g;
|
|
|
|
private double h;
|
|
|
|
private double i;
|
|
|
|
private boolean j;
|
2011-01-11 09:25:13 +01:00
|
|
|
private Map k;
|
|
|
|
|
|
|
|
// CraftBukkit start - next 2 lines
|
2010-12-30 06:35:30 +01:00
|
|
|
private final CraftServer server;
|
|
|
|
private final CraftPlayer player;
|
2010-12-28 22:52:39 +01:00
|
|
|
|
2011-01-11 09:25:13 +01:00
|
|
|
public CraftPlayer getPlayer() {
|
|
|
|
return player;
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2010-12-28 22:52:39 +01:00
|
|
|
public NetServerHandler(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayerMP entityplayermp) {
|
|
|
|
c = false;
|
|
|
|
f = 0;
|
|
|
|
j = true;
|
2011-01-11 09:25:13 +01:00
|
|
|
k = ((Map) (new HashMap()));
|
2010-12-28 22:52:39 +01:00
|
|
|
d = minecraftserver;
|
|
|
|
b = networkmanager;
|
2011-01-11 09:25:13 +01:00
|
|
|
networkmanager.a(((NetHandler) (this)));
|
2010-12-28 22:52:39 +01:00
|
|
|
e = entityplayermp;
|
|
|
|
entityplayermp.a = this;
|
2010-12-30 06:35:30 +01:00
|
|
|
|
|
|
|
// CraftBukkit - next 2 lines
|
|
|
|
server = minecraftserver.server;
|
|
|
|
player = new CraftPlayer(server, e);
|
|
|
|
}
|
|
|
|
|
2010-12-28 22:52:39 +01:00
|
|
|
public void a() {
|
|
|
|
b.a();
|
|
|
|
if (f++ % 20 == 0) {
|
2011-01-11 09:25:13 +01:00
|
|
|
b.a(((Packet) (new Packet0KeepAlive())));
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(String s) {
|
2011-01-11 09:25:13 +01:00
|
|
|
b.a(((Packet) (new Packet255KickDisconnect(s))));
|
2010-12-28 22:52:39 +01:00
|
|
|
b.c();
|
2011-01-11 09:25:13 +01:00
|
|
|
d.f.a(((Packet) (new Packet3Chat((new StringBuilder()).append("\247e").append(e.aw).append(" left the game.").toString()))));
|
2010-12-28 22:52:39 +01:00
|
|
|
d.f.c(e);
|
|
|
|
c = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(Packet10Flying packet10flying) {
|
|
|
|
if (!j) {
|
|
|
|
double d1 = packet10flying.b - h;
|
|
|
|
|
|
|
|
if (packet10flying.a == g && d1 * d1 < 0.01D && packet10flying.c == i) {
|
|
|
|
j = true;
|
|
|
|
}
|
|
|
|
}
|
2010-12-29 02:25:32 +01:00
|
|
|
|
|
|
|
// CraftBukkit start
|
|
|
|
Location from = new Location(player.getWorld(), g, h, i, e.v, e.w);
|
|
|
|
Location to = player.getLocation();
|
2010-12-30 21:34:26 +01:00
|
|
|
if (!from.equals(to)) {
|
|
|
|
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
|
|
|
|
2010-12-30 21:34:26 +01:00
|
|
|
e.p = to.getX();
|
|
|
|
e.q = to.getY();
|
|
|
|
e.r = to.getZ();
|
|
|
|
e.v = to.getYaw();
|
|
|
|
e.w = to.getPitch();
|
|
|
|
}
|
2010-12-29 02:25:32 +01:00
|
|
|
// CraftBukkit end
|
|
|
|
|
2010-12-28 22:52:39 +01:00
|
|
|
if (j) {
|
|
|
|
if (e.k != null) {
|
|
|
|
float f1 = e.v;
|
|
|
|
float f2 = e.w;
|
|
|
|
|
2011-01-14 14:31:10 +01:00
|
|
|
e.k.E();
|
2010-12-28 22:52:39 +01:00
|
|
|
double d3 = e.p;
|
|
|
|
double d5 = e.q;
|
|
|
|
double d7 = e.r;
|
|
|
|
double d9 = 0.0D;
|
|
|
|
double d10 = 0.0D;
|
|
|
|
|
|
|
|
if (packet10flying.i) {
|
|
|
|
f1 = packet10flying.e;
|
|
|
|
f2 = packet10flying.f;
|
|
|
|
}
|
|
|
|
if (packet10flying.h && packet10flying.b == -999D && packet10flying.d == -999D) {
|
|
|
|
d9 = packet10flying.a;
|
|
|
|
d10 = packet10flying.c;
|
|
|
|
}
|
|
|
|
e.A = packet10flying.g;
|
2011-01-14 14:31:10 +01:00
|
|
|
e.n();
|
2010-12-28 22:52:39 +01:00
|
|
|
e.c(d9, 0.0D, d10);
|
|
|
|
e.b(d3, d5, d7, f1, f2);
|
|
|
|
e.s = d9;
|
|
|
|
e.u = d10;
|
|
|
|
if (e.k != null) {
|
|
|
|
d.e.b(e.k, true);
|
|
|
|
}
|
|
|
|
if (e.k != null) {
|
2011-01-14 14:31:10 +01:00
|
|
|
e.k.E();
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
d.f.b(e);
|
|
|
|
g = e.p;
|
|
|
|
h = e.q;
|
|
|
|
i = e.r;
|
2011-01-11 09:25:13 +01:00
|
|
|
d.e.f(((Entity) (e)));
|
2010-12-28 22:52:39 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
double d2 = e.q;
|
|
|
|
|
|
|
|
g = e.p;
|
|
|
|
h = e.q;
|
|
|
|
i = e.r;
|
|
|
|
double d4 = e.p;
|
|
|
|
double d6 = e.q;
|
|
|
|
double d8 = e.r;
|
|
|
|
float f3 = e.v;
|
|
|
|
float f4 = e.w;
|
|
|
|
|
|
|
|
if (packet10flying.h && packet10flying.b == -999D && packet10flying.d == -999D) {
|
|
|
|
packet10flying.h = false;
|
|
|
|
}
|
|
|
|
if (packet10flying.h) {
|
|
|
|
d4 = packet10flying.a;
|
|
|
|
d6 = packet10flying.b;
|
|
|
|
d8 = packet10flying.c;
|
|
|
|
double d11 = packet10flying.d - packet10flying.b;
|
|
|
|
|
|
|
|
if (d11 > 1.6499999999999999D || d11 < 0.10000000000000001D) {
|
|
|
|
a("Illegal stance");
|
|
|
|
a.warning((new StringBuilder()).append(e.aw).append(" had an illegal stance: ").append(d11).toString());
|
|
|
|
}
|
2011-01-14 14:31:10 +01:00
|
|
|
e.al = packet10flying.d;
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
if (packet10flying.i) {
|
|
|
|
f3 = packet10flying.e;
|
|
|
|
f4 = packet10flying.f;
|
|
|
|
}
|
2011-01-14 14:31:10 +01:00
|
|
|
e.n();
|
2010-12-28 22:52:39 +01:00
|
|
|
e.R = 0.0F;
|
|
|
|
e.b(g, h, i, f3, f4);
|
|
|
|
double d12 = d4 - e.p;
|
|
|
|
double d13 = d6 - e.q;
|
|
|
|
double d14 = d8 - e.r;
|
|
|
|
float f5 = 0.0625F;
|
2011-01-11 09:25:13 +01:00
|
|
|
boolean flag = d.e.a(((Entity) (e)), e.z.b().e(f5, f5, f5)).size() == 0;
|
2010-12-28 22:52:39 +01:00
|
|
|
|
|
|
|
e.c(d12, d13, d14);
|
|
|
|
d12 = d4 - e.p;
|
|
|
|
d13 = d6 - e.q;
|
|
|
|
if (d13 > -0.5D || d13 < 0.5D) {
|
|
|
|
d13 = 0.0D;
|
|
|
|
}
|
|
|
|
d14 = d8 - e.r;
|
|
|
|
double d15 = d12 * d12 + d13 * d13 + d14 * d14;
|
|
|
|
boolean flag1 = false;
|
|
|
|
|
|
|
|
if (d15 > 0.0625D) {
|
|
|
|
flag1 = true;
|
|
|
|
a.warning((new StringBuilder()).append(e.aw).append(" moved wrongly!").toString());
|
|
|
|
System.out.println((new StringBuilder()).append("Got position ").append(d4).append(", ").append(d6).append(", ").append(d8).toString());
|
|
|
|
System.out.println((new StringBuilder()).append("Expected ").append(e.p).append(", ").append(e.q).append(", ").append(e.r).toString());
|
|
|
|
}
|
|
|
|
e.b(d4, d6, d8, f3, f4);
|
2011-01-11 09:25:13 +01:00
|
|
|
boolean flag2 = d.e.a(((Entity) (e)), e.z.b().e(f5, f5, f5)).size() == 0;
|
2010-12-28 22:52:39 +01:00
|
|
|
|
|
|
|
if (flag && (flag1 || !flag2)) {
|
|
|
|
a(g, h, i, f3, f4);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
e.A = packet10flying.g;
|
|
|
|
d.f.b(e);
|
|
|
|
e.b(e.q - d2, packet10flying.g);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-11 09:25:13 +01:00
|
|
|
public void a(double d1, double d2, double d3, float f1, float f2) {
|
2010-12-29 02:25:32 +01:00
|
|
|
// CraftBukkit start
|
|
|
|
Location from = player.getLocation();
|
|
|
|
Location to = new Location(player.getWorld(), d1, d2, d3, f1, f2);
|
|
|
|
PlayerMoveEvent event = new PlayerMoveEvent(Type.PLAYER_TELEPORT, player, from, to);
|
|
|
|
server.getPluginManager().callEvent(event);
|
|
|
|
|
|
|
|
from = event.getFrom();
|
|
|
|
to = event.isCancelled() ? from : event.getTo();
|
|
|
|
|
|
|
|
d1 = to.getX();
|
|
|
|
d2 = to.getY();
|
|
|
|
d3 = to.getZ();
|
|
|
|
f1 = to.getYaw();
|
|
|
|
f2 = to.getPitch();
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2010-12-28 22:52:39 +01:00
|
|
|
j = false;
|
|
|
|
g = d1;
|
|
|
|
h = d2;
|
|
|
|
i = d3;
|
|
|
|
e.b(d1, d2, d3, f1, f2);
|
2011-01-11 09:25:13 +01:00
|
|
|
e.a.b(((Packet) (new Packet13PlayerLookMove(d1, d2 + 1.6200000047683716D, d2, d3, f1, f2, false))));
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
|
2011-01-10 02:57:47 +01:00
|
|
|
// CraftBukkit start
|
|
|
|
// Get position of last block hit for BlockDamageLevel.STOPPED
|
|
|
|
private int lastX;
|
|
|
|
private int lastY;
|
|
|
|
private int lastZ;
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit end
|
2011-01-10 02:57:47 +01:00
|
|
|
|
2010-12-28 22:52:39 +01:00
|
|
|
public void a(Packet14BlockDig packet14blockdig) {
|
|
|
|
if (packet14blockdig.e == 4) {
|
2011-01-14 14:31:10 +01:00
|
|
|
e.O();
|
2010-12-28 22:52:39 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
boolean flag = d.e.B = d.f.g(e.aw);
|
|
|
|
boolean flag1 = false;
|
|
|
|
|
|
|
|
if (packet14blockdig.e == 0) {
|
|
|
|
flag1 = true;
|
|
|
|
}
|
|
|
|
if (packet14blockdig.e == 1) {
|
|
|
|
flag1 = true;
|
|
|
|
}
|
|
|
|
int l = packet14blockdig.a;
|
|
|
|
int i1 = packet14blockdig.b;
|
|
|
|
int j1 = packet14blockdig.c;
|
|
|
|
|
|
|
|
if (flag1) {
|
|
|
|
double d1 = e.p - ((double) l + 0.5D);
|
|
|
|
double d2 = e.q - ((double) i1 + 0.5D);
|
|
|
|
double d3 = e.r - ((double) j1 + 0.5D);
|
|
|
|
double d4 = d1 * d1 + d2 * d2 + d3 * d3;
|
|
|
|
|
|
|
|
if (d4 > 36D) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
double d5 = e.q;
|
|
|
|
|
2011-01-14 14:31:10 +01:00
|
|
|
e.q = e.al;
|
2010-12-28 22:52:39 +01:00
|
|
|
e.q = d5;
|
|
|
|
}
|
|
|
|
int k1 = packet14blockdig.d;
|
|
|
|
int l1 = (int) MathHelper.e(l - d.e.m);
|
|
|
|
int i2 = (int) MathHelper.e(j1 - d.e.o);
|
|
|
|
|
|
|
|
if (l1 > i2) {
|
|
|
|
i2 = l1;
|
|
|
|
}
|
2011-01-10 02:36:19 +01:00
|
|
|
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit start
|
2011-01-10 02:36:19 +01:00
|
|
|
CraftBlock block = (CraftBlock) player.getWorld().getBlockAt(l, i1, j1);
|
2011-01-15 20:53:20 +01:00
|
|
|
int blockId = block.getTypeId();
|
2011-01-10 04:00:53 +01:00
|
|
|
float damage = 0;
|
2011-01-15 20:53:20 +01:00
|
|
|
if(Block.m[blockId] != null) {
|
|
|
|
damage = Block.m[blockId].a(player.getHandle()); //Get amount of damage going to block
|
2011-01-10 04:00:53 +01:00
|
|
|
}
|
|
|
|
|
2010-12-28 22:52:39 +01:00
|
|
|
if (packet14blockdig.e == 0) {
|
|
|
|
if (i2 > 16 || flag) {
|
2011-01-15 20:53:20 +01:00
|
|
|
if(blockId > 0) {
|
2011-01-15 21:26:05 +01:00
|
|
|
BlockDamageEvent event;
|
2011-01-10 02:36:19 +01:00
|
|
|
// 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)
|
2011-01-11 09:25:13 +01:00
|
|
|
if (damage >= 1.0F) {
|
2011-01-15 21:26:05 +01:00
|
|
|
event = new BlockDamageEvent(Type.BLOCK_DAMAGED, block, BlockDamageLevel.BROKEN, player);
|
2011-01-10 02:36:19 +01:00
|
|
|
} else {
|
2011-01-15 21:26:05 +01:00
|
|
|
event = new BlockDamageEvent(Type.BLOCK_DAMAGED, block, BlockDamageLevel.STARTED, player);
|
2011-01-10 02:36:19 +01:00
|
|
|
}
|
|
|
|
server.getPluginManager().callEvent(event);
|
|
|
|
if (!event.isCancelled()) {
|
|
|
|
e.c.a(l, i1, j1);
|
|
|
|
}
|
|
|
|
}
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
} else if (packet14blockdig.e == 2) {
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit start - Get last block that the player hit
|
2011-01-10 02:57:47 +01:00
|
|
|
// Otherwise the block is a Bedrock @(0,0,0)
|
|
|
|
block = (CraftBlock) player.getWorld().getBlockAt(lastX, lastY, lastZ);
|
2011-01-15 21:26:05 +01:00
|
|
|
BlockDamageEvent event = new BlockDamageEvent(Type.BLOCK_DAMAGED, block, BlockDamageLevel.STOPPED, player);
|
2011-01-10 02:36:19 +01:00
|
|
|
server.getPluginManager().callEvent(event);
|
|
|
|
if (!event.isCancelled()) {
|
|
|
|
e.c.a();
|
|
|
|
}
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit end
|
2010-12-28 22:52:39 +01:00
|
|
|
} else if (packet14blockdig.e == 1) {
|
|
|
|
if (i2 > 16 || flag) {
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit start
|
2011-01-15 21:26:05 +01:00
|
|
|
BlockDamageEvent event;
|
2011-01-10 02:36:19 +01:00
|
|
|
// If the amount of damage going to the block plus the current amount
|
|
|
|
// of damage is greater than 1, the block is going to break.
|
|
|
|
if (e.c.d + damage >= 1.0F) {
|
2011-01-15 21:26:05 +01:00
|
|
|
event = new BlockDamageEvent(Type.BLOCK_DAMAGED, block, BlockDamageLevel.BROKEN, player);
|
2011-01-10 02:36:19 +01:00
|
|
|
} else {
|
2011-01-15 21:26:05 +01:00
|
|
|
event = new BlockDamageEvent(Type.BLOCK_DAMAGED, block, BlockDamageLevel.DIGGING, player);
|
2011-01-10 02:36:19 +01:00
|
|
|
}
|
|
|
|
server.getPluginManager().callEvent(event);
|
|
|
|
if (!event.isCancelled()) {
|
|
|
|
e.c.a(l, i1, j1, k1);
|
2011-01-11 03:05:45 +01:00
|
|
|
} else {
|
|
|
|
e.c.d = 0; // Reset the amount of damage if stopping break.
|
2011-01-10 02:36:19 +01:00
|
|
|
}
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit end
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
} else if (packet14blockdig.e == 3) {
|
|
|
|
double d6 = e.p - ((double) l + 0.5D);
|
|
|
|
double d7 = e.q - ((double) i1 + 0.5D);
|
|
|
|
double d8 = e.r - ((double) j1 + 0.5D);
|
|
|
|
double d9 = d6 * d6 + d7 * d7 + d8 * d8;
|
|
|
|
|
|
|
|
if (d9 < 256D) {
|
2011-01-11 09:25:13 +01:00
|
|
|
e.a.b(((Packet) (new Packet53BlockChange(l, i1, j1, ((World) (d.e))))));
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
}
|
2011-01-11 09:25:13 +01:00
|
|
|
|
|
|
|
// CraftBukkit start
|
2011-01-10 02:57:47 +01:00
|
|
|
lastX = l;
|
|
|
|
lastY = i1;
|
|
|
|
lastZ = j1;
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit end
|
2011-01-10 02:57:47 +01:00
|
|
|
|
2010-12-28 22:52:39 +01:00
|
|
|
d.e.B = false;
|
|
|
|
}
|
2011-01-11 09:25:13 +01:00
|
|
|
|
|
|
|
// CraftBukkit start - store the last block right clicked and what type it was
|
2011-01-08 11:49:42 +01:00
|
|
|
CraftBlock lastRightClicked;
|
|
|
|
int lastMaterial;
|
2011-01-10 02:36:19 +01:00
|
|
|
|
2010-12-28 22:52:39 +01:00
|
|
|
public void a(Packet15Place packet15place) {
|
|
|
|
ItemStack itemstack = e.an.e();
|
2011-01-11 09:25:13 +01:00
|
|
|
boolean flag = d.e.B = d.f.g(e.aw);
|
2011-01-10 02:36:19 +01:00
|
|
|
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit start
|
2011-01-08 11:49:42 +01:00
|
|
|
CraftBlock blockClicked = null;
|
|
|
|
BlockFace blockFace = null;
|
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-01-08 11:49:42 +01:00
|
|
|
if (packet15place.e != null && packet15place.e.c == lastMaterial) {
|
|
|
|
blockClicked = lastRightClicked;
|
|
|
|
} else if (lastMaterial == 0) {
|
|
|
|
blockClicked = lastRightClicked;
|
|
|
|
}
|
|
|
|
lastRightClicked = null;
|
|
|
|
lastMaterial = 0;
|
|
|
|
} else {
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit RIGHTCLICK or BLOCK_PLACE .. or nothing
|
2011-01-08 11:49:42 +01:00
|
|
|
blockClicked = (CraftBlock) d.e.getWorld().getBlockAt(packet15place.a, packet15place.b, packet15place.c);
|
|
|
|
lastRightClicked = blockClicked;
|
|
|
|
lastMaterial = (packet15place.e == null) ? 0 : packet15place.e.c;
|
|
|
|
}
|
2011-01-10 02:36:19 +01:00
|
|
|
|
2011-01-08 11:49:42 +01:00
|
|
|
if (blockClicked != null && itemstack != null) {
|
2011-01-10 02:36:19 +01:00
|
|
|
blockFace = CraftBlock.notchToBlockFace(packet15place.d);
|
2011-01-08 11:49:42 +01:00
|
|
|
} else {
|
2011-01-15 21:16:30 +01:00
|
|
|
blockFace = BlockFace.SELF;
|
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-07 11:46:11 +01:00
|
|
|
CraftItemStack craftItem = new CraftItemStack(itemstack);
|
|
|
|
CraftPlayer player = new CraftPlayer(server, e);
|
2011-01-08 11:49:42 +01:00
|
|
|
PlayerItemEvent pie = new PlayerItemEvent(Type.PLAYER_ITEM, player, craftItem, blockClicked, blockFace);
|
2011-01-10 02:36:19 +01:00
|
|
|
|
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
|
|
|
|
switch (craftItem.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:
|
|
|
|
server.getPluginManager().callEvent(pie);
|
2011-01-08 11:49:42 +01:00
|
|
|
}
|
|
|
|
|
2011-01-07 11:46:11 +01:00
|
|
|
if (!pie.isCancelled()) {
|
|
|
|
int itemstackAmount = itemstack.a;
|
2011-01-11 09:25:13 +01:00
|
|
|
e.c.a(((EntityPlayer) (e)), ((World) (d.e)), itemstack);
|
|
|
|
// 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-07 11:46:11 +01:00
|
|
|
always = (itemstack.a != itemstackAmount);
|
|
|
|
}
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit end
|
2010-12-28 22:52:39 +01:00
|
|
|
} else {
|
|
|
|
int l = packet15place.a;
|
|
|
|
int i1 = packet15place.b;
|
|
|
|
int j1 = packet15place.c;
|
|
|
|
int k1 = packet15place.d;
|
|
|
|
int l1 = (int) MathHelper.e(l - d.e.m);
|
|
|
|
int i2 = (int) MathHelper.e(j1 - d.e.o);
|
|
|
|
|
|
|
|
if (l1 > i2) {
|
|
|
|
i2 = l1;
|
|
|
|
}
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit start - spawn proection moved to ItemBlock!!!
|
2011-01-07 11:46:11 +01:00
|
|
|
CraftItemStack craftItem = new CraftItemStack(itemstack);
|
|
|
|
CraftPlayer player = new CraftPlayer(server, e);
|
2011-01-15 21:26:05 +01:00
|
|
|
BlockRightClickEvent brce = new BlockRightClickEvent(Type.BLOCK_RIGHTCLICKED, blockClicked, blockFace, craftItem, player);
|
2011-01-08 11:49:42 +01:00
|
|
|
server.getPluginManager().callEvent(brce);
|
2011-01-10 02:36:19 +01:00
|
|
|
|
2011-01-11 09:25:13 +01:00
|
|
|
e.c.a(((EntityPlayer) (e)), ((World) (d.e)), itemstack, l, i1, j1, k1);
|
|
|
|
// CraftBukkit end
|
2011-01-10 02:36:19 +01:00
|
|
|
|
2011-01-11 09:25:13 +01:00
|
|
|
e.a.b(((Packet) (new Packet53BlockChange(l, i1, j1, ((World) (d.e))))));
|
2011-01-08 11:49:42 +01:00
|
|
|
if (k1 == 0) {
|
|
|
|
i1--;
|
|
|
|
}
|
|
|
|
if (k1 == 1) {
|
|
|
|
i1++;
|
|
|
|
}
|
|
|
|
if (k1 == 2) {
|
|
|
|
j1--;
|
|
|
|
}
|
|
|
|
if (k1 == 3) {
|
|
|
|
j1++;
|
|
|
|
}
|
|
|
|
if (k1 == 4) {
|
|
|
|
l--;
|
|
|
|
}
|
|
|
|
if (k1 == 5) {
|
|
|
|
l++;
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
2011-01-11 09:25:13 +01:00
|
|
|
e.a.b(((Packet) (new Packet53BlockChange(l, i1, j1, ((World) (d.e))))));
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
if (itemstack != null && itemstack.a == 0) {
|
|
|
|
e.an.a[e.an.c] = null;
|
|
|
|
}
|
|
|
|
e.am = true;
|
2011-01-14 14:31:10 +01:00
|
|
|
e.an.a[e.an.c] = ItemStack.b(e.an.a[e.an.c]);
|
2011-01-11 09:25:13 +01:00
|
|
|
Slot slot = e.ap.a(((IInventory) (e.an)), e.an.c);
|
2010-12-28 22:52:39 +01:00
|
|
|
|
|
|
|
e.ap.a();
|
|
|
|
e.am = false;
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit - Boolean flag
|
|
|
|
if (!ItemStack.a(e.an.e(), packet15place.e) || always) {
|
|
|
|
b(((Packet) (new Packet103(e.ap.f, slot.c, e.an.e()))));
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
d.e.B = false;
|
|
|
|
}
|
2011-01-10 02:36:19 +01:00
|
|
|
|
2010-12-28 22:52:39 +01:00
|
|
|
public void a(String s, Object aobj[]) {
|
|
|
|
a.info((new StringBuilder()).append(e.aw).append(" lost connection: ").append(s).toString());
|
2011-01-11 09:25:13 +01:00
|
|
|
d.f.a(((Packet) (new Packet3Chat((new StringBuilder()).append("\247e").append(e.aw).append(" left the game.").toString()))));
|
2010-12-28 22:52:39 +01:00
|
|
|
d.f.c(e);
|
|
|
|
c = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(Packet packet) {
|
2011-01-11 09:25:13 +01:00
|
|
|
a.warning((new StringBuilder()).append((((this).getClass()))).append(" wasn't prepared to deal with a ").append(((((packet)).getClass()))).toString());
|
2010-12-28 22:52:39 +01:00
|
|
|
a("Protocol error, unexpected packet");
|
|
|
|
}
|
|
|
|
|
|
|
|
public void b(Packet packet) {
|
|
|
|
b.a(packet);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(Packet16BlockItemSwitch packet16blockitemswitch) {
|
|
|
|
e.an.c = packet16blockitemswitch.a;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(Packet3Chat packet3chat) {
|
|
|
|
String s = packet3chat.a;
|
|
|
|
|
|
|
|
if (s.length() > 100) {
|
|
|
|
a("Chat message too long");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
s = s.trim();
|
|
|
|
for (int l = 0; l < s.length(); l++) {
|
2011-01-11 09:25:13 +01:00
|
|
|
if (FontAllowedCharacters.a.indexOf(((int) (s.charAt(l)))) < 0) {
|
2010-12-28 22:52:39 +01:00
|
|
|
a("Illegal characters in chat");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (s.startsWith("/")) {
|
|
|
|
c(s);
|
|
|
|
} else {
|
|
|
|
// CraftBukkit start
|
2010-12-30 06:35:30 +01:00
|
|
|
PlayerChatEvent event = new PlayerChatEvent(Type.PLAYER_CHAT, player, s);
|
2010-12-28 22:52:39 +01:00
|
|
|
server.getPluginManager().callEvent(event);
|
2011-01-07 14:34:24 +01:00
|
|
|
s = String.format(event.getFormat(), event.getPlayer().getDisplayName(), event.getMessage());
|
2011-01-10 02:36:19 +01:00
|
|
|
if (event.isCancelled()) {
|
|
|
|
return;
|
|
|
|
}
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit end
|
2011-01-01 14:06:04 +01:00
|
|
|
|
2010-12-28 22:52:39 +01:00
|
|
|
a.info(s);
|
2011-01-11 09:25:13 +01:00
|
|
|
d.f.a(((Packet) (new Packet3Chat(s))));
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void c(String s) {
|
|
|
|
// CraftBukkit start
|
2010-12-30 06:35:30 +01:00
|
|
|
PlayerChatEvent event = new PlayerChatEvent(Type.PLAYER_COMMAND, 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;
|
|
|
|
}
|
2010-12-28 22:52:39 +01:00
|
|
|
s = event.getMessage();
|
2011-01-10 02:36:19 +01:00
|
|
|
CraftPlayer player = (CraftPlayer) event.getPlayer();
|
2010-12-30 05:30:12 +01:00
|
|
|
EntityPlayerMP e = player.getHandle();
|
2010-12-28 22:52:39 +01:00
|
|
|
// CraftBukkit stop
|
|
|
|
|
|
|
|
if (s.toLowerCase().startsWith("/me ")) {
|
|
|
|
s = (new StringBuilder()).append("* ").append(e.aw).append(" ").append(s.substring(s.indexOf(" ")).trim()).toString();
|
|
|
|
a.info(s);
|
2011-01-11 09:25:13 +01:00
|
|
|
d.f.a(((Packet) (new Packet3Chat(s))));
|
2010-12-28 22:52:39 +01:00
|
|
|
} else if (s.toLowerCase().startsWith("/kill")) {
|
2011-01-11 09:25:13 +01:00
|
|
|
e.a(((Entity) (null)), 1000);
|
2010-12-28 22:52:39 +01:00
|
|
|
} else if (s.toLowerCase().startsWith("/tell ")) {
|
|
|
|
String as[] = s.split(" ");
|
|
|
|
|
|
|
|
if (as.length >= 3) {
|
|
|
|
s = s.substring(s.indexOf(" ")).trim();
|
|
|
|
s = s.substring(s.indexOf(" ")).trim();
|
|
|
|
s = (new StringBuilder()).append("\2477").append(e.aw).append(" whispers ").append(s).toString();
|
|
|
|
a.info((new StringBuilder()).append(s).append(" to ").append(as[1]).toString());
|
2011-01-11 09:25:13 +01:00
|
|
|
if (!d.f.a(as[1], ((Packet) (new Packet3Chat(s))))) {
|
|
|
|
b(((Packet) (new Packet3Chat("\247cThere's no player by that name online."))));
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (d.f.g(e.aw)) {
|
|
|
|
String s1 = s.substring(1);
|
|
|
|
|
|
|
|
a.info((new StringBuilder()).append(e.aw).append(" issued server command: ").append(s1).toString());
|
2011-01-11 09:25:13 +01:00
|
|
|
d.a(s1, ((ICommandListener) (this)));
|
2010-12-28 22:52:39 +01:00
|
|
|
} else {
|
|
|
|
String s2 = s.substring(1);
|
|
|
|
|
|
|
|
a.info((new StringBuilder()).append(e.aw).append(" tried command: ").append(s2).toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(Packet18ArmAnimation packet18armanimation) {
|
|
|
|
if (packet18armanimation.b == 1) {
|
2011-01-14 14:31:10 +01:00
|
|
|
e.K();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(Packet19 packet19) {
|
|
|
|
if (packet19.b == 1) {
|
|
|
|
e.b(true);
|
|
|
|
} else if (packet19.b == 2) {
|
|
|
|
e.b(false);
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(Packet255KickDisconnect packet255kickdisconnect) {
|
|
|
|
b.a("disconnect.quitting", new Object[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int b() {
|
|
|
|
return b.d();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void b(String s) {
|
|
|
|
b(((Packet) (new Packet3Chat((new StringBuilder()).append("\2477").append(s).toString()))));
|
|
|
|
}
|
|
|
|
|
|
|
|
public String c() {
|
|
|
|
return e.aw;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(Packet7 packet7) {
|
|
|
|
Entity entity = d.e.a(packet7.b);
|
|
|
|
|
|
|
|
if (entity != null && e.i(entity)) {
|
|
|
|
if (packet7.c == 0) {
|
|
|
|
e.g(entity);
|
|
|
|
} else if (packet7.c == 1) {
|
|
|
|
e.h(entity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(Packet9 packet9) {
|
2011-01-14 14:31:10 +01:00
|
|
|
if (e.aZ > 0) {
|
2010-12-28 22:52:39 +01:00
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
e = d.f.d(e);
|
2010-12-30 21:34:26 +01:00
|
|
|
player.setHandle(e); // CraftBukkit
|
2010-12-28 22:52:39 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(Packet101 packet101) {
|
2011-01-14 14:31:10 +01:00
|
|
|
e.N();
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void a(Packet102 packet102) {
|
2011-01-11 09:25:13 +01:00
|
|
|
if (e.ap.f == packet102.a && e.ap.c(((EntityPlayer) (e)))) {
|
|
|
|
ItemStack itemstack = e.ap.a(packet102.b, packet102.c, ((EntityPlayer) (e)));
|
2010-12-28 22:52:39 +01:00
|
|
|
|
|
|
|
if (ItemStack.a(packet102.e, itemstack)) {
|
2011-01-11 09:25:13 +01:00
|
|
|
e.a.b(((Packet) (new Packet106(packet102.a, packet102.d, true))));
|
2010-12-28 22:52:39 +01:00
|
|
|
e.am = true;
|
|
|
|
e.ap.a();
|
2011-01-14 14:31:10 +01:00
|
|
|
e.M();
|
2010-12-28 22:52:39 +01:00
|
|
|
e.am = false;
|
|
|
|
} else {
|
2011-01-11 09:25:13 +01:00
|
|
|
k.put(((Integer.valueOf(e.ap.f))), ((Short.valueOf(packet102.d))));
|
|
|
|
e.a.b(((Packet) (new Packet106(packet102.a, packet102.d, false))));
|
|
|
|
e.ap.a(((EntityPlayer) (e)), false);
|
|
|
|
ArrayList arraylist = new ArrayList();
|
2010-12-28 22:52:39 +01:00
|
|
|
|
|
|
|
for (int l = 0; l < e.ap.e.size(); l++) {
|
2011-01-11 09:25:13 +01:00
|
|
|
((List) (arraylist)).add(((((Slot) e.ap.e.get(l)).c())));
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
|
2011-01-11 09:25:13 +01:00
|
|
|
e.a(e.ap, ((List) (arraylist)));
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(Packet106 packet106) {
|
2011-01-11 09:25:13 +01:00
|
|
|
Short short1 = (Short) k.get(((Integer.valueOf(e.ap.f))));
|
2010-12-28 22:52:39 +01:00
|
|
|
|
2011-01-11 09:25:13 +01:00
|
|
|
if (short1 != null && packet106.b == short1.shortValue() && e.ap.f == packet106.a && !e.ap.c(((EntityPlayer) (e)))) {
|
|
|
|
e.ap.a(((EntityPlayer) (e)), true);
|
2010-12-28 22:52:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(Packet130 packet130) {
|
|
|
|
if (d.e.f(packet130.a, packet130.b, packet130.c)) {
|
2011-01-14 14:31:10 +01:00
|
|
|
TileEntity tileentity = d.e.m(packet130.a, packet130.b, packet130.c);
|
2010-12-28 22:52:39 +01:00
|
|
|
|
|
|
|
for (int l = 0; l < 4; l++) {
|
|
|
|
boolean flag = true;
|
|
|
|
|
|
|
|
if (packet130.d[l].length() > 15) {
|
|
|
|
flag = false;
|
|
|
|
} else {
|
|
|
|
for (int k1 = 0; k1 < packet130.d[l].length(); k1++) {
|
2011-01-11 09:25:13 +01:00
|
|
|
if (FontAllowedCharacters.a.indexOf(((int) (packet130.d[l].charAt(k1)))) < 0) {
|
2010-12-28 22:52:39 +01:00
|
|
|
flag = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!flag) {
|
|
|
|
packet130.d[l] = "!?";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tileentity instanceof TileEntitySign) {
|
|
|
|
int i1 = packet130.a;
|
|
|
|
int j1 = packet130.b;
|
|
|
|
int l1 = packet130.c;
|
|
|
|
TileEntitySign tileentitysign = (TileEntitySign) tileentity;
|
|
|
|
|
|
|
|
for (int i2 = 0; i2 < 4; i2++) {
|
|
|
|
tileentitysign.e[i2] = packet130.d[i2];
|
|
|
|
}
|
|
|
|
|
|
|
|
tileentitysign.d();
|
|
|
|
d.e.g(i1, j1, l1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|