Fixed PlayerLoggedOutException

This commit is contained in:
BongoCat 2022-07-27 19:08:00 -07:00
parent 2060408700
commit d68b64cbb9
5 changed files with 8 additions and 12 deletions

View File

@ -62,7 +62,9 @@ public class BossBar {
public void delete() {
if (dragon != null) {
if (dragon.created) {
if (t != null) {
t.cancel();
}
dragon.destroy();
}
}

View File

@ -22,13 +22,6 @@ public class Main extends JavaPlugin {
instance = this;
System.out.println("BossBar is on");
getCommand("bossbar").setExecutor(new FakeWitherCommand());
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(this, PacketType.Play.Server.NAMED_SOUND_EFFECT) {
@Override
public void onPacketSending(PacketEvent event) {
PacketContainer cont = new PacketContainer(event.getPacketType());
//TODO
}
});
}
// Overrides onDisable

View File

@ -4,6 +4,7 @@ import com.comphenix.packetwrapper.Packet18SpawnMob;
import com.comphenix.packetwrapper.Packet1DDestroyEntity;
import com.comphenix.packetwrapper.Packet28EntityMetadata;
import com.comphenix.protocol.ProtocolManager;
import com.comphenix.protocol.injector.PlayerLoggedOutException;
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -33,7 +34,7 @@ public class SpawnFakeWither extends JavaPlugin {
// Unique ID
public int id = NEXT_ID++;
// Default health
public int health = 300;
public int health = 200;
public String customName;
public boolean created;
@ -42,7 +43,7 @@ public class SpawnFakeWither extends JavaPlugin {
public Player p;
public FakeWither(Player p, ProtocolManager manager) {
this.location = new Location(p.getWorld(), p.getLocation().getX(), p.getLocation().getY() - 30, p.getLocation().getZ());
this.location = new Location(p.getWorld(), p.getLocation().getX(), p.getLocation().getY() - 45, p.getLocation().getZ());
this.manager = manager;
this.p = p;
}
@ -135,7 +136,7 @@ public class SpawnFakeWither extends JavaPlugin {
manager.sendServerPacket(p, destroyMe.getHandle());
} catch (InvocationTargetException e) {
Bukkit.getLogger().log(Level.WARNING, "Cannot send " + destroyMe.getHandle() + " to " + p, e);
}
} catch (PlayerLoggedOutException ignored) {}
created = false;
}
}

Binary file not shown.

Binary file not shown.