mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-27 21:29:14 +01:00
Allow /npc remove to ignore the ownership requirement when called from console
This commit is contained in:
parent
7d7f6b5415
commit
5df6499dae
@ -33,11 +33,12 @@ public class Settings {
|
||||
|
||||
public void reload() {
|
||||
config.load();
|
||||
for (Setting setting : Setting.values())
|
||||
if (root.keyExists(setting.path))
|
||||
for (Setting setting : Setting.values()) {
|
||||
if (root.keyExists(setting.path)) {
|
||||
setting.loadFromKey(root);
|
||||
}
|
||||
}
|
||||
updateMessagingSettings();
|
||||
|
||||
save();
|
||||
}
|
||||
|
||||
|
@ -783,9 +783,9 @@ public class NPCCommands {
|
||||
@Requirements(selected = true, ownership = true, types = EntityType.PLAYER)
|
||||
public void playerlist(CommandContext args, CommandSender sender, NPC npc) {
|
||||
boolean remove = !npc.data().get("removefromplayerlist", Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
|
||||
if (args.hasFlag('a'))
|
||||
if (args.hasFlag('a')) {
|
||||
remove = false;
|
||||
else if (args.hasFlag('r'))
|
||||
} else if (args.hasFlag('r'))
|
||||
remove = true;
|
||||
npc.data().setPersistent("removefromplayerlist", remove);
|
||||
if (npc.isSpawned())
|
||||
@ -897,7 +897,7 @@ public class NPCCommands {
|
||||
}
|
||||
if (npc == null)
|
||||
throw new CommandException(Messages.COMMAND_MUST_HAVE_SELECTED);
|
||||
if (!npc.getTrait(Owner.class).isOwnedBy(sender))
|
||||
if (!(sender instanceof ConsoleCommandSender) && !npc.getTrait(Owner.class).isOwnedBy(sender))
|
||||
throw new CommandException(Messages.COMMAND_MUST_BE_OWNER);
|
||||
if (!sender.hasPermission("citizens.npc.remove") && !sender.hasPermission("citizens.admin"))
|
||||
throw new NoPermissionsException();
|
||||
|
@ -2,7 +2,6 @@ package net.citizensnpcs.trait.text;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
@ -33,8 +32,10 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
public class Text extends Trait implements Runnable, Toggleable, Listener, ConversationAbandonedListener {
|
||||
private final Map<String, Date> cooldowns = new HashMap<String, Date>();
|
||||
private final Map<String, Date> cooldowns = Maps.newHashMap();
|
||||
private int currentIndex;
|
||||
private String itemInHandPattern = "default";
|
||||
private final Plugin plugin;
|
||||
@ -67,7 +68,6 @@ public class Text extends Trait implements Runnable, Toggleable, Listener, Conve
|
||||
.withLocalEcho(false).withEscapeSequence("/npc text").withEscapeSequence("exit").withModality(false)
|
||||
.withFirstPrompt(new TextStartPrompt(this)).buildConversation(player);
|
||||
return new Editor() {
|
||||
|
||||
@Override
|
||||
public void begin() {
|
||||
Messaging.sendTr(player, Messages.TEXT_EDITOR_BEGIN);
|
||||
@ -90,12 +90,15 @@ public class Text extends Trait implements Runnable, Toggleable, Listener, Conve
|
||||
public void load(DataKey key) throws NPCLoadException {
|
||||
text.clear();
|
||||
// TODO: legacy, remove later
|
||||
for (DataKey sub : key.getIntegerSubKeys())
|
||||
for (DataKey sub : key.getIntegerSubKeys()) {
|
||||
text.add(sub.getString(""));
|
||||
for (DataKey sub : key.getRelative("text").getIntegerSubKeys())
|
||||
}
|
||||
for (DataKey sub : key.getRelative("text").getIntegerSubKeys()) {
|
||||
text.add(sub.getString(""));
|
||||
if (text.isEmpty())
|
||||
}
|
||||
if (text.isEmpty()) {
|
||||
populateDefaultText();
|
||||
}
|
||||
|
||||
talkClose = key.getBoolean("talk-close", talkClose);
|
||||
realisticLooker = key.getBoolean("realistic-looking", realisticLooker);
|
||||
|
Loading…
Reference in New Issue
Block a user