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;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
player.openInventory(npc.getInventory());
|
|
||||||
if (npc.getCharacter() != null)
|
if (npc.getCharacter() != null)
|
||||||
npc.getCharacter().onRightClick(npc, player);
|
npc.getCharacter().onRightClick(npc, player);
|
||||||
}
|
}
|
||||||
|
@ -240,6 +240,7 @@ public class NPCCommands {
|
|||||||
modifiers = { "remove" },
|
modifiers = { "remove" },
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 2)
|
max = 2)
|
||||||
|
@Requirements
|
||||||
public void remove(CommandContext args, Player player, NPC npc) throws CommandException {
|
public void remove(CommandContext args, Player player, NPC npc) throws CommandException {
|
||||||
if (args.argsLength() == 2) {
|
if (args.argsLength() == 2) {
|
||||||
if (!args.getString(1).equals("all"))
|
if (!args.getString(1).equals("all"))
|
||||||
|
@ -98,42 +98,21 @@ public class CitizensNPCManager implements NPCManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void remove(NPC npc) {
|
public void remove(NPC npc) {
|
||||||
if (npc.isSpawned())
|
|
||||||
npc.getBukkitEntity().remove();
|
|
||||||
npcs.remove(npc.getId());
|
npcs.remove(npc.getId());
|
||||||
saves.getKey("npc").removeKey(String.valueOf(npc.getId()));
|
saves.getKey("npc").removeKey(String.valueOf(npc.getId()));
|
||||||
|
|
||||||
// Remove metadata from selectors
|
// Remove metadata from selectors
|
||||||
if (npc.hasMetadata("selectors"))
|
if (npc.hasMetadata("selectors")) {
|
||||||
for (MetadataValue value : npc.getMetadata("selectors"))
|
for (MetadataValue value : npc.getMetadata("selectors"))
|
||||||
if (Bukkit.getPlayer(value.asString()) != null)
|
if (Bukkit.getPlayer(value.asString()) != null)
|
||||||
Bukkit.getPlayer(value.asString()).removeMetadata("selected", plugin);
|
Bukkit.getPlayer(value.asString()).removeMetadata("selected", plugin);
|
||||||
npc.removeMetadata("selectors", plugin);
|
npc.removeMetadata("selectors", plugin);
|
||||||
// TODO: merge this and removeAll();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeAll() {
|
public void removeAll() {
|
||||||
Iterator<NPC> itr = iterator();
|
while (iterator().hasNext())
|
||||||
while (itr.hasNext()) {
|
iterator().next().remove();
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectNPC(Player player, NPC npc) {
|
public void selectNPC(Player player, NPC npc) {
|
||||||
|
Loading…
Reference in New Issue
Block a user