mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-26 12:46:04 +01:00
added temporary selection API until Bukkit adds metadata
This commit is contained in:
parent
7d8f0fb9bb
commit
958751f61f
Binary file not shown.
@ -89,7 +89,7 @@ public class EventListen implements Listener {
|
||||
|
||||
NPC npc = npcManager.getNPC(event.getEntity());
|
||||
Player player = (Player) event.getTarget();
|
||||
if (!npcManager.npcIsSelectedByPlayer(player, npc)) {
|
||||
if (!npcManager.isNPCSelectedByPlayer(player, npc)) {
|
||||
if (player.hasPermission("citizens.npc.select")
|
||||
&& player.getItemInHand().getTypeId() == Setting.SELECTION_ITEM.asInt()
|
||||
&& npc.getTrait(Owner.class).getOwner().equals(player.getName())) {
|
||||
|
@ -86,6 +86,7 @@ public class CitizensNPCManager implements NPCManager {
|
||||
return npcs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getSelectedNPC(Player player) {
|
||||
for (int id : selected.keySet()) {
|
||||
if (selected.get(id).contains(player.getName()))
|
||||
@ -104,7 +105,8 @@ public class CitizensNPCManager implements NPCManager {
|
||||
return npcs.iterator();
|
||||
}
|
||||
|
||||
public boolean npcIsSelectedByPlayer(Player player, NPC npc) {
|
||||
@Override
|
||||
public boolean isNPCSelectedByPlayer(Player player, NPC npc) {
|
||||
if (!selected.containsKey(npc.getId()))
|
||||
return false;
|
||||
return selected.get(npc.getId()).contains(player.getName());
|
||||
@ -118,6 +120,7 @@ public class CitizensNPCManager implements NPCManager {
|
||||
selected.removeAll(npc.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectNPC(Player player, NPC npc) {
|
||||
// Remove existing selection if any
|
||||
NPC existing = getSelectedNPC(player);
|
||||
|
Loading…
Reference in New Issue
Block a user