From 1e3d3e575495f5207e19068489caa0c5551531d5 Mon Sep 17 00:00:00 2001 From: fullwall Date: Sat, 4 Feb 2012 22:49:16 +0800 Subject: [PATCH] Revert to old socket, fix NPE --- .../npc/entity/CitizensHumanNPC.java | 2 ++ .../citizensnpcs/resource/lib/NPCSocket.java | 17 +++++------------ 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/net/citizensnpcs/npc/entity/CitizensHumanNPC.java b/src/net/citizensnpcs/npc/entity/CitizensHumanNPC.java index cc068ae26..be3785d2b 100644 --- a/src/net/citizensnpcs/npc/entity/CitizensHumanNPC.java +++ b/src/net/citizensnpcs/npc/entity/CitizensHumanNPC.java @@ -24,6 +24,8 @@ public class CitizensHumanNPC extends CitizensNPC { @Override public void update() { super.update(); + if (mcEntity == null) + return; if (mcEntity.noDamageTicks > 0) mcEntity.noDamageTicks--; if (mcEntity.attackTicks > 0) diff --git a/src/net/citizensnpcs/resource/lib/NPCSocket.java b/src/net/citizensnpcs/resource/lib/NPCSocket.java index 9e01123aa..c110337ba 100644 --- a/src/net/citizensnpcs/resource/lib/NPCSocket.java +++ b/src/net/citizensnpcs/resource/lib/NPCSocket.java @@ -1,27 +1,20 @@ package net.citizensnpcs.resource.lib; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.io.OutputStream; import java.net.Socket; public class NPCSocket extends Socket { + @Override public InputStream getInputStream() { - return new InputStream() { - @Override - public int read() { - return 0; // NOP - } - }; + return new ByteArrayInputStream(new byte[10]); } @Override public OutputStream getOutputStream() { - return new OutputStream() { - @Override - public void write(int b) { - // NOP - } - }; + return new ByteArrayOutputStream(); } } \ No newline at end of file