mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-29 22:23:59 +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());
|
NPC npc = npcManager.getNPC(event.getEntity());
|
||||||
Player player = (Player) event.getTarget();
|
Player player = (Player) event.getTarget();
|
||||||
if (!npcManager.npcIsSelectedByPlayer(player, npc)) {
|
if (!npcManager.isNPCSelectedByPlayer(player, npc)) {
|
||||||
if (player.hasPermission("citizens.npc.select")
|
if (player.hasPermission("citizens.npc.select")
|
||||||
&& player.getItemInHand().getTypeId() == Setting.SELECTION_ITEM.asInt()
|
&& player.getItemInHand().getTypeId() == Setting.SELECTION_ITEM.asInt()
|
||||||
&& npc.getTrait(Owner.class).getOwner().equals(player.getName())) {
|
&& npc.getTrait(Owner.class).getOwner().equals(player.getName())) {
|
||||||
|
@ -86,6 +86,7 @@ public class CitizensNPCManager implements NPCManager {
|
|||||||
return npcs;
|
return npcs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public NPC getSelectedNPC(Player player) {
|
public NPC getSelectedNPC(Player player) {
|
||||||
for (int id : selected.keySet()) {
|
for (int id : selected.keySet()) {
|
||||||
if (selected.get(id).contains(player.getName()))
|
if (selected.get(id).contains(player.getName()))
|
||||||
@ -104,7 +105,8 @@ public class CitizensNPCManager implements NPCManager {
|
|||||||
return npcs.iterator();
|
return npcs.iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean npcIsSelectedByPlayer(Player player, NPC npc) {
|
@Override
|
||||||
|
public boolean isNPCSelectedByPlayer(Player player, NPC npc) {
|
||||||
if (!selected.containsKey(npc.getId()))
|
if (!selected.containsKey(npc.getId()))
|
||||||
return false;
|
return false;
|
||||||
return selected.get(npc.getId()).contains(player.getName());
|
return selected.get(npc.getId()).contains(player.getName());
|
||||||
@ -118,6 +120,7 @@ public class CitizensNPCManager implements NPCManager {
|
|||||||
selected.removeAll(npc.getId());
|
selected.removeAll(npc.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void selectNPC(Player player, NPC npc) {
|
public void selectNPC(Player player, NPC npc) {
|
||||||
// Remove existing selection if any
|
// Remove existing selection if any
|
||||||
NPC existing = getSelectedNPC(player);
|
NPC existing = getSelectedNPC(player);
|
||||||
|
Loading…
Reference in New Issue
Block a user