summaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authorTravis Watkins <amaranth@ubuntu.com>2012-05-24 19:11:05 -0500
committerTravis Watkins <amaranth@ubuntu.com>2012-05-24 19:12:56 -0500
commitc1bc0df71852f5d80f5f1c8ddf001ec263c804aa (patch)
tree6f0bac81f618b9c1fc6e6d9165b43f727771efb0 /src/main/java/org
parent2f16b8ffa32a754b86f70694e3e823b097da87fa (diff)
downloadcraftbukkit-c1bc0df71852f5d80f5f1c8ddf001ec263c804aa.tar
craftbukkit-c1bc0df71852f5d80f5f1c8ddf001ec263c804aa.tar.gz
craftbukkit-c1bc0df71852f5d80f5f1c8ddf001ec263c804aa.tar.lz
craftbukkit-c1bc0df71852f5d80f5f1c8ddf001ec263c804aa.tar.xz
craftbukkit-c1bc0df71852f5d80f5f1c8ddf001ec263c804aa.zip
Add in checks for potential NPEs. Fixes BUKKIT-1706 and BUKKIT-1590.
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftWorld.java4
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java2
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java3
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java5
4 files changed, 13 insertions, 1 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 71c3ea75..0ad2920f 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -443,6 +443,8 @@ public class CraftWorld implements World {
// Forces the client to update to the new time immediately
for (Player p : getPlayers()) {
CraftPlayer cp = (CraftPlayer) p;
+ if (cp.getHandle().netServerHandler == null) continue;
+
cp.getHandle().netServerHandler.sendPacket(new Packet4UpdateTime(cp.getHandle().getPlayerTime()));
}
}
@@ -767,6 +769,8 @@ public class CraftWorld implements World {
radius *= radius;
for (Player player : getPlayers()) {
+ if (((CraftPlayer) player).getHandle().netServerHandler == null) continue;
+
distance = (int) player.getLocation().distanceSquared(location);
if (distance <= radius) {
((CraftPlayer) player).getHandle().netServerHandler.sendPacket(packet);
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
index 10020c1d..a50df490 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
@@ -221,6 +221,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
}
private void openCustomInventory(Inventory inventory, EntityPlayer player, int windowType) {
+ if (player.netServerHandler == null) return;
Container container = new CraftContainer(inventory, this, player.nextContainerCounter());
container = CraftEventFactory.callInventoryOpenEvent(player, container);
@@ -270,6 +271,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
public void openInventory(InventoryView inventory) {
if (!(getHandle() instanceof EntityPlayer)) return; // TODO: NPC support?
+ if (((EntityPlayer) getHandle()).netServerHandler == null) return;
if (getHandle().activeContainer != getHandle().defaultContainer) {
// fire INVENTORY_CLOSE if one already open
((EntityPlayer)getHandle()).netServerHandler.handleContainerClose(new Packet101CloseWindow(getHandle().activeContainer.windowId));
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
index 4d071841..c00d8d63 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
@@ -240,7 +240,8 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
getHandle().effects.remove(type.getId());
getHandle().e = true; // Should be called updateEffects
if (getHandle() instanceof EntityPlayer) {
- ((EntityPlayer)getHandle()).netServerHandler.sendPacket(new Packet42RemoveMobEffect(getHandle().id, new MobEffect(type.getId(), 0, 0)));
+ if (((EntityPlayer) getHandle()).netServerHandler == null) return;
+ ((EntityPlayer) getHandle()).netServerHandler.sendPacket(new Packet42RemoveMobEffect(getHandle().id, new MobEffect(type.getId(), 0, 0)));
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index ec269fcb..080a6875 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -178,6 +178,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
Packet201PlayerInfo packet = new Packet201PlayerInfo(name, true, getHandle().ping);
for (int i = 0; i < server.getHandle().players.size(); ++i) {
EntityPlayer entityplayer = (EntityPlayer) server.getHandle().players.get(i);
+ if (entityplayer.netServerHandler == null) continue;
if (entityplayer.getBukkitEntity().canSee(this)) {
entityplayer.netServerHandler.sendPacket(oldpacket);
@@ -587,6 +588,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
public void hidePlayer(Player player) {
Validate.notNull(player, "hidden player cannot be null");
+ if (getHandle().netServerHandler == null) return;
if (equals(player)) return;
if (hiddenPlayers.containsKey(player.getName())) return;
hiddenPlayers.put(player.getName(), player);
@@ -605,6 +607,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
public void showPlayer(Player player) {
Validate.notNull(player, "shown player cannot be null");
+ if (getHandle().netServerHandler == null) return;
if (equals(player)) return;
if (!hiddenPlayers.containsKey(player.getName())) return;
hiddenPlayers.remove(player.getName());
@@ -732,6 +735,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
public void sendPluginMessage(Plugin source, String channel, byte[] message) {
StandardMessenger.validatePluginMessage(server.getMessenger(), source, channel, message);
+ if (getHandle().netServerHandler == null) return;
if (channels.contains(channel)) {
Packet250CustomPayload packet = new Packet250CustomPayload();
@@ -755,6 +759,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
public void sendSupportedChannels() {
+ if (getHandle().netServerHandler == null) return;
Set<String> listening = server.getMessenger().getIncomingChannels();
if (!listening.isEmpty()) {