mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-27 13:06:02 +01:00
Add in checks for potential NPEs. Fixes BUKKIT-1706 and BUKKIT-1590.
This commit is contained in:
parent
2f16b8ffa3
commit
c1bc0df718
@ -443,6 +443,8 @@ public class CraftWorld implements World {
|
|||||||
// Forces the client to update to the new time immediately
|
// Forces the client to update to the new time immediately
|
||||||
for (Player p : getPlayers()) {
|
for (Player p : getPlayers()) {
|
||||||
CraftPlayer cp = (CraftPlayer) p;
|
CraftPlayer cp = (CraftPlayer) p;
|
||||||
|
if (cp.getHandle().netServerHandler == null) continue;
|
||||||
|
|
||||||
cp.getHandle().netServerHandler.sendPacket(new Packet4UpdateTime(cp.getHandle().getPlayerTime()));
|
cp.getHandle().netServerHandler.sendPacket(new Packet4UpdateTime(cp.getHandle().getPlayerTime()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -767,6 +769,8 @@ public class CraftWorld implements World {
|
|||||||
radius *= radius;
|
radius *= radius;
|
||||||
|
|
||||||
for (Player player : getPlayers()) {
|
for (Player player : getPlayers()) {
|
||||||
|
if (((CraftPlayer) player).getHandle().netServerHandler == null) continue;
|
||||||
|
|
||||||
distance = (int) player.getLocation().distanceSquared(location);
|
distance = (int) player.getLocation().distanceSquared(location);
|
||||||
if (distance <= radius) {
|
if (distance <= radius) {
|
||||||
((CraftPlayer) player).getHandle().netServerHandler.sendPacket(packet);
|
((CraftPlayer) player).getHandle().netServerHandler.sendPacket(packet);
|
||||||
|
@ -221,6 +221,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void openCustomInventory(Inventory inventory, EntityPlayer player, int windowType) {
|
private void openCustomInventory(Inventory inventory, EntityPlayer player, int windowType) {
|
||||||
|
if (player.netServerHandler == null) return;
|
||||||
Container container = new CraftContainer(inventory, this, player.nextContainerCounter());
|
Container container = new CraftContainer(inventory, this, player.nextContainerCounter());
|
||||||
|
|
||||||
container = CraftEventFactory.callInventoryOpenEvent(player, container);
|
container = CraftEventFactory.callInventoryOpenEvent(player, container);
|
||||||
@ -270,6 +271,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
|||||||
|
|
||||||
public void openInventory(InventoryView inventory) {
|
public void openInventory(InventoryView inventory) {
|
||||||
if (!(getHandle() instanceof EntityPlayer)) return; // TODO: NPC support?
|
if (!(getHandle() instanceof EntityPlayer)) return; // TODO: NPC support?
|
||||||
|
if (((EntityPlayer) getHandle()).netServerHandler == null) return;
|
||||||
if (getHandle().activeContainer != getHandle().defaultContainer) {
|
if (getHandle().activeContainer != getHandle().defaultContainer) {
|
||||||
// fire INVENTORY_CLOSE if one already open
|
// fire INVENTORY_CLOSE if one already open
|
||||||
((EntityPlayer)getHandle()).netServerHandler.handleContainerClose(new Packet101CloseWindow(getHandle().activeContainer.windowId));
|
((EntityPlayer)getHandle()).netServerHandler.handleContainerClose(new Packet101CloseWindow(getHandle().activeContainer.windowId));
|
||||||
|
@ -240,6 +240,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
|||||||
getHandle().effects.remove(type.getId());
|
getHandle().effects.remove(type.getId());
|
||||||
getHandle().e = true; // Should be called updateEffects
|
getHandle().e = true; // Should be called updateEffects
|
||||||
if (getHandle() instanceof EntityPlayer) {
|
if (getHandle() instanceof EntityPlayer) {
|
||||||
|
if (((EntityPlayer) getHandle()).netServerHandler == null) return;
|
||||||
((EntityPlayer) getHandle()).netServerHandler.sendPacket(new Packet42RemoveMobEffect(getHandle().id, new MobEffect(type.getId(), 0, 0)));
|
((EntityPlayer) getHandle()).netServerHandler.sendPacket(new Packet42RemoveMobEffect(getHandle().id, new MobEffect(type.getId(), 0, 0)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -178,6 +178,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||||||
Packet201PlayerInfo packet = new Packet201PlayerInfo(name, true, getHandle().ping);
|
Packet201PlayerInfo packet = new Packet201PlayerInfo(name, true, getHandle().ping);
|
||||||
for (int i = 0; i < server.getHandle().players.size(); ++i) {
|
for (int i = 0; i < server.getHandle().players.size(); ++i) {
|
||||||
EntityPlayer entityplayer = (EntityPlayer) server.getHandle().players.get(i);
|
EntityPlayer entityplayer = (EntityPlayer) server.getHandle().players.get(i);
|
||||||
|
if (entityplayer.netServerHandler == null) continue;
|
||||||
|
|
||||||
if (entityplayer.getBukkitEntity().canSee(this)) {
|
if (entityplayer.getBukkitEntity().canSee(this)) {
|
||||||
entityplayer.netServerHandler.sendPacket(oldpacket);
|
entityplayer.netServerHandler.sendPacket(oldpacket);
|
||||||
@ -587,6 +588,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||||||
|
|
||||||
public void hidePlayer(Player player) {
|
public void hidePlayer(Player player) {
|
||||||
Validate.notNull(player, "hidden player cannot be null");
|
Validate.notNull(player, "hidden player cannot be null");
|
||||||
|
if (getHandle().netServerHandler == null) return;
|
||||||
if (equals(player)) return;
|
if (equals(player)) return;
|
||||||
if (hiddenPlayers.containsKey(player.getName())) return;
|
if (hiddenPlayers.containsKey(player.getName())) return;
|
||||||
hiddenPlayers.put(player.getName(), player);
|
hiddenPlayers.put(player.getName(), player);
|
||||||
@ -605,6 +607,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||||||
|
|
||||||
public void showPlayer(Player player) {
|
public void showPlayer(Player player) {
|
||||||
Validate.notNull(player, "shown player cannot be null");
|
Validate.notNull(player, "shown player cannot be null");
|
||||||
|
if (getHandle().netServerHandler == null) return;
|
||||||
if (equals(player)) return;
|
if (equals(player)) return;
|
||||||
if (!hiddenPlayers.containsKey(player.getName())) return;
|
if (!hiddenPlayers.containsKey(player.getName())) return;
|
||||||
hiddenPlayers.remove(player.getName());
|
hiddenPlayers.remove(player.getName());
|
||||||
@ -732,6 +735,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||||||
|
|
||||||
public void sendPluginMessage(Plugin source, String channel, byte[] message) {
|
public void sendPluginMessage(Plugin source, String channel, byte[] message) {
|
||||||
StandardMessenger.validatePluginMessage(server.getMessenger(), source, channel, message);
|
StandardMessenger.validatePluginMessage(server.getMessenger(), source, channel, message);
|
||||||
|
if (getHandle().netServerHandler == null) return;
|
||||||
|
|
||||||
if (channels.contains(channel)) {
|
if (channels.contains(channel)) {
|
||||||
Packet250CustomPayload packet = new Packet250CustomPayload();
|
Packet250CustomPayload packet = new Packet250CustomPayload();
|
||||||
@ -755,6 +759,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sendSupportedChannels() {
|
public void sendSupportedChannels() {
|
||||||
|
if (getHandle().netServerHandler == null) return;
|
||||||
Set<String> listening = server.getMessenger().getIncomingChannels();
|
Set<String> listening = server.getMessenger().getIncomingChannels();
|
||||||
|
|
||||||
if (!listening.isEmpty()) {
|
if (!listening.isEmpty()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user