Skip to content

Commit

Permalink
fixed another nullpointer
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugo B committed Aug 8, 2021
1 parent 128c7c2 commit 131c077
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions src/main/java/net/seyarada/pandeloot/nms/v1_17_R1/V1_17_R1.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import org.bukkit.craftbukkit.v1_17_R1.util.CraftChatMessage;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;

import java.util.ArrayList;
Expand Down Expand Up @@ -97,10 +96,11 @@ public static void destroyEntity(int toBeDestroyed, Entity entity) {
public static void spawnHologram(DamageUtil damageUtil) {
UUID uuid = damageUtil.getUUID();
for (UUID playerUUID : DamageTracker.get(uuid).keySet()) {
Player player = Bukkit.getPlayer(playerUUID);
final Player player = Bukkit.getPlayer(playerUUID);
if(player == null) continue;

Location location = Bukkit.getEntity(uuid).getLocation();
WorldServer wS = ((CraftWorld) location.getWorld()).getHandle();
final Location location = Bukkit.getEntity(uuid).getLocation();
final WorldServer wS = ((CraftWorld) location.getWorld()).getHandle();
double lX = location.getX();
double lY = location.getY() + 1.2;
double lZ = location.getZ();
Expand All @@ -124,22 +124,17 @@ public static void spawnHologram(DamageUtil damageUtil) {
PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(armorStand, 1);
PacketPlayOutEntityMetadata metadata = new PacketPlayOutEntityMetadata(armorStand.getId(), armorStand.getDataWatcher(), true);

if (player != null && player.isOnline() && ((CraftPlayer) player).getHandle() != null) {
if (player.isOnline() && ((CraftPlayer) player).getHandle() != null) {
final PlayerConnection connection = ((CraftPlayer) player).getHandle().b;
connection.sendPacket(packetPlayOutSpawnEntity);
connection.sendPacket(metadata);
}
if (player != null) {
new BukkitRunnable() {
@Override
public void run() {
if (player.isOnline()) {
PacketPlayOutEntityDestroy destroy = new PacketPlayOutEntityDestroy(armorStand.getId());
((CraftPlayer) player).getHandle().b.sendPacket(destroy);
}
}
}.runTaskLater(PandeLoot.getInstance(), 300);
}
Bukkit.getScheduler().runTaskLater(PandeLoot.getInstance(), () -> {
if (player.isOnline()) {
PacketPlayOutEntityDestroy destroy = new PacketPlayOutEntityDestroy(armorStand.getId());
((CraftPlayer) player).getHandle().b.sendPacket(destroy);
}
}, 300);
}

}
Expand Down

0 comments on commit 131c077

Please sign in to comment.