mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-27 05:05:20 +01:00
fix remove all bug
This commit is contained in:
parent
db2847ebab
commit
d0b0815a18
@ -112,7 +112,6 @@ public class EventListen implements Listener {
|
||||
return;
|
||||
}
|
||||
}
|
||||
player.openInventory(npc.getInventory());
|
||||
if (npc.getCharacter() != null)
|
||||
npc.getCharacter().onRightClick(npc, player);
|
||||
}
|
||||
|
@ -240,6 +240,7 @@ public class NPCCommands {
|
||||
modifiers = { "remove" },
|
||||
min = 1,
|
||||
max = 2)
|
||||
@Requirements
|
||||
public void remove(CommandContext args, Player player, NPC npc) throws CommandException {
|
||||
if (args.argsLength() == 2) {
|
||||
if (!args.getString(1).equals("all"))
|
||||
|
@ -98,42 +98,21 @@ public class CitizensNPCManager implements NPCManager {
|
||||
}
|
||||
|
||||
public void remove(NPC npc) {
|
||||
if (npc.isSpawned())
|
||||
npc.getBukkitEntity().remove();
|
||||
npcs.remove(npc.getId());
|
||||
saves.getKey("npc").removeKey(String.valueOf(npc.getId()));
|
||||
|
||||
// Remove metadata from selectors
|
||||
if (npc.hasMetadata("selectors"))
|
||||
if (npc.hasMetadata("selectors")) {
|
||||
for (MetadataValue value : npc.getMetadata("selectors"))
|
||||
if (Bukkit.getPlayer(value.asString()) != null)
|
||||
Bukkit.getPlayer(value.asString()).removeMetadata("selected", plugin);
|
||||
npc.removeMetadata("selectors", plugin);
|
||||
// TODO: merge this and removeAll();
|
||||
}
|
||||
}
|
||||
|
||||
public void removeAll() {
|
||||
Iterator<NPC> itr = iterator();
|
||||
while (itr.hasNext()) {
|
||||
NPC npc = itr.next();
|
||||
saves.getKey("npc").removeKey(String.valueOf(npc.getId()));
|
||||
|
||||
// Remove metadata from selectors
|
||||
if (npc.hasMetadata("selectors")) {
|
||||
for (MetadataValue value : npc.getMetadata("selectors")) {
|
||||
if (Bukkit.getPlayer(value.asString()) != null) {
|
||||
Bukkit.getPlayer(value.asString()).removeMetadata("selected", plugin);
|
||||
}
|
||||
}
|
||||
npc.removeMetadata("selectors", plugin);
|
||||
}
|
||||
|
||||
if (npc.isSpawned()) {
|
||||
npc.getBukkitEntity().remove();
|
||||
}
|
||||
|
||||
itr.remove();
|
||||
}
|
||||
while (iterator().hasNext())
|
||||
iterator().next().remove();
|
||||
}
|
||||
|
||||
public void selectNPC(Player player, NPC npc) {
|
||||
|
Loading…
Reference in New Issue
Block a user