regionpostitemwatcher: fix compasses

This commit is contained in:
Torrie Fischer 2021-06-14 13:28:13 -07:00
parent d1045685e5
commit 43a499997d

View File

@ -22,6 +22,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -50,15 +51,14 @@ public class RegionPostItemWatcher implements Listener {
ItemStack stack = new ItemStack(Material.COMPASS); ItemStack stack = new ItemStack(Material.COMPASS);
ItemMeta meta = stack.getItemMeta(); ItemMeta meta = stack.getItemMeta();
List<String> lore = new ArrayList<String>(); List<String> lore = new ArrayList<String>();
if (r == null) {
lore.add("Right click to locate the nearest Region Post"); lore.add("Right click to locate the nearest Region Post");
if (r == null) {
} else { } else {
CompassMeta compassMeta = (CompassMeta)meta; CompassMeta compassMeta = (CompassMeta)meta;
compassMeta.setDisplayName(r.name() + " Region Compass"); compassMeta.setDisplayName(ChatColor.DARK_PURPLE + "Region Compass (" + r.coloredName() + ChatColor.RESET + ChatColor.DARK_PURPLE + ")");
compassMeta.setLodestone(r.location()); compassMeta.setLodestone(r.location());
compassMeta.setLodestoneTracked(false); compassMeta.setLodestoneTracked(false);
lore.add("Right click to locate the nearest Region Post"); lore.add("Tracking: " + r.coloredName());
lore.add("Tracking: " + r.name());
lore.add("Coordinates: " + r.location().getX() + ", " + r.location().getY()); lore.add("Coordinates: " + r.location().getX() + ", " + r.location().getY());
} }
meta.setLore(lore); meta.setLore(lore);
@ -110,7 +110,7 @@ public class RegionPostItemWatcher implements Listener {
if (stack.getType() == m_theCompass.getType()) { if (stack.getType() == m_theCompass.getType()) {
ItemMeta meta = stack.getItemMeta(); ItemMeta meta = stack.getItemMeta();
ItemMeta theItemMeta = m_theCompass.getItemMeta(); ItemMeta theItemMeta = m_theCompass.getItemMeta();
if (meta.getItemFlags() == theItemMeta.getItemFlags()) { if (meta.getLore() != null && meta.getLore().get(0).equals(theItemMeta.getLore().get(0))) {
return true; return true;
} }
} }