Skip to content

Commit d68b64c

Browse files
committed
Fixed PlayerLoggedOutException
1 parent 2060408 commit d68b64c

File tree

5 files changed

+8
-12
lines changed

5 files changed

+8
-12
lines changed

Diff for: src/main/java/tech/nully/BossBarAPI/BossBar.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ public void display() {
6262
public void delete() {
6363
if (dragon != null) {
6464
if (dragon.created) {
65-
t.cancel();
65+
if (t != null) {
66+
t.cancel();
67+
}
6668
dragon.destroy();
6769
}
6870
}

Diff for: src/main/java/tech/nully/BossBarAPI/Main.java

+1-8
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,7 @@ public void onEnable() {
2222
instance = this;
2323
System.out.println("BossBar is on");
2424
getCommand("bossbar").setExecutor(new FakeWitherCommand());
25-
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(this, PacketType.Play.Server.NAMED_SOUND_EFFECT) {
26-
@Override
27-
public void onPacketSending(PacketEvent event) {
28-
PacketContainer cont = new PacketContainer(event.getPacketType());
29-
//TODO
30-
}
31-
});
32-
}
25+
}
3326

3427
// Overrides onDisable
3528
@Override

Diff for: src/main/java/tech/nully/BossBarAPI/SpawnFakeWither.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.comphenix.packetwrapper.Packet1DDestroyEntity;
55
import com.comphenix.packetwrapper.Packet28EntityMetadata;
66
import com.comphenix.protocol.ProtocolManager;
7+
import com.comphenix.protocol.injector.PlayerLoggedOutException;
78
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
89
import org.bukkit.Bukkit;
910
import org.bukkit.Location;
@@ -33,7 +34,7 @@ public static class FakeWither {
3334
// Unique ID
3435
public int id = NEXT_ID++;
3536
// Default health
36-
public int health = 300;
37+
public int health = 200;
3738
public String customName;
3839
public boolean created;
3940

@@ -42,7 +43,7 @@ public static class FakeWither {
4243
public Player p;
4344

4445
public FakeWither(Player p, ProtocolManager manager) {
45-
this.location = new Location(p.getWorld(), p.getLocation().getX(), p.getLocation().getY() - 30, p.getLocation().getZ());
46+
this.location = new Location(p.getWorld(), p.getLocation().getX(), p.getLocation().getY() - 45, p.getLocation().getZ());
4647
this.manager = manager;
4748
this.p = p;
4849
}
@@ -135,7 +136,7 @@ public void destroy() {
135136
manager.sendServerPacket(p, destroyMe.getHandle());
136137
} catch (InvocationTargetException e) {
137138
Bukkit.getLogger().log(Level.WARNING, "Cannot send " + destroyMe.getHandle() + " to " + p, e);
138-
}
139+
} catch (PlayerLoggedOutException ignored) {}
139140
created = false;
140141
}
141142
}

Diff for: target/BossBarAPI-0.0.1.jar

-98 Bytes
Binary file not shown.

Diff for: target/original-BossBarAPI-0.0.1.jar

-98 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)