From 3aec0e5ef43d88a290eb2e0c200de69733c69b18 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 26 Feb 2013 10:07:00 -0500 Subject: [PATCH] Using UUID is safer. --- .../java/com/gmail/nossr50/skills/archery/Archery.java | 2 +- .../com/gmail/nossr50/skills/archery/TrackedEntity.java | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/skills/archery/Archery.java b/src/main/java/com/gmail/nossr50/skills/archery/Archery.java index ce393d1ca..7ebc022cc 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/Archery.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/Archery.java @@ -75,7 +75,7 @@ public class Archery { for (Iterator entityIterator = trackedEntities.iterator(); entityIterator.hasNext(); ) { TrackedEntity trackedEntity = entityIterator.next(); - if (trackedEntity.getLivingEntity().getEntityId() == livingEntity.getEntityId()) { + if (trackedEntity.getID() == livingEntity.getUniqueId()) { Misc.dropItems(livingEntity.getLocation(), new ItemStack(Material.ARROW), trackedEntity.getArrowCount()); entityIterator.remove(); return; diff --git a/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java b/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java index 49c01c067..b78d01f90 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java @@ -1,5 +1,7 @@ package com.gmail.nossr50.skills.archery; +import java.util.UUID; + import org.bukkit.entity.LivingEntity; import org.bukkit.scheduler.BukkitScheduler; @@ -7,12 +9,14 @@ import com.gmail.nossr50.mcMMO; public class TrackedEntity implements Runnable { private LivingEntity livingEntity; + private UUID id; private int arrowCount; private int taskId; private BukkitScheduler scheduler; protected TrackedEntity(LivingEntity livingEntity) { this.livingEntity = livingEntity; + this.id = livingEntity.getUniqueId(); this.scheduler = mcMMO.p.getServer().getScheduler(); this.taskId = scheduler.scheduleSyncRepeatingTask(mcMMO.p, this, 12000, 12000); } @@ -21,6 +25,10 @@ public class TrackedEntity implements Runnable { return livingEntity; } + protected UUID getID() { + return id; + } + protected int getArrowCount() { return arrowCount; }