mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-28 05:35:45 +01:00
Add setting for removing NPCs from player list (testing it out), --trait is applied after spawn
This commit is contained in:
parent
e2b0af6ac1
commit
d3ae5bcd61
@ -72,6 +72,7 @@ public class Settings {
|
|||||||
MAX_NPC_LIMIT_CHECKS("npc.limits.max-permission-checks", 100),
|
MAX_NPC_LIMIT_CHECKS("npc.limits.max-permission-checks", 100),
|
||||||
NPC_COST("economy.npc.cost", 100D),
|
NPC_COST("economy.npc.cost", 100D),
|
||||||
QUICK_SELECT("npc.selection.quick-select", false),
|
QUICK_SELECT("npc.selection.quick-select", false),
|
||||||
|
REMOVE_PLAYERS_FROM_PLAYER_LIST("npc.player.remove-from-list", true),
|
||||||
SAVE_TASK_DELAY("storage.save-task.delay", 20 * 60 * 60),
|
SAVE_TASK_DELAY("storage.save-task.delay", 20 * 60 * 60),
|
||||||
SELECTION_ITEM("npc.selection.item", "280"),
|
SELECTION_ITEM("npc.selection.item", "280"),
|
||||||
SELECTION_MESSAGE("npc.selection.message", "<b>You selected <a><npc><b>!"),
|
SELECTION_MESSAGE("npc.selection.message", "<b>You selected <a><npc><b>!"),
|
||||||
|
@ -207,21 +207,6 @@ public class NPCCommands {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.hasValueFlag("trait")) {
|
|
||||||
Iterable<String> parts = Splitter.on(",").trimResults().split(args.getFlag("trait"));
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
for (String tr : parts) {
|
|
||||||
Trait trait = CitizensAPI.getTraitFactory().getTrait(tr);
|
|
||||||
if (trait == null)
|
|
||||||
continue;
|
|
||||||
npc.addTrait(trait);
|
|
||||||
builder.append(StringHelper.wrap(tr) + ", ");
|
|
||||||
}
|
|
||||||
if (builder.length() > 0)
|
|
||||||
builder.delete(builder.length() - 2, builder.length());
|
|
||||||
msg += " with traits " + builder.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.hasValueFlag("b")) {
|
if (args.hasValueFlag("b")) {
|
||||||
npc.getTrait(Behaviour.class).addScripts(Splitter.on(",").split(args.getFlag("behaviour")));
|
npc.getTrait(Behaviour.class).addScripts(Splitter.on(",").split(args.getFlag("behaviour")));
|
||||||
msg += " with the specified behaviours";
|
msg += " with the specified behaviours";
|
||||||
@ -245,6 +230,21 @@ public class NPCCommands {
|
|||||||
throw new CommandException(reason);
|
throw new CommandException(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args.hasValueFlag("trait")) {
|
||||||
|
Iterable<String> parts = Splitter.on(",").trimResults().split(args.getFlag("trait"));
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
for (String tr : parts) {
|
||||||
|
Trait trait = CitizensAPI.getTraitFactory().getTrait(tr);
|
||||||
|
if (trait == null)
|
||||||
|
continue;
|
||||||
|
npc.addTrait(trait);
|
||||||
|
builder.append(StringHelper.wrap(tr) + ", ");
|
||||||
|
}
|
||||||
|
if (builder.length() > 0)
|
||||||
|
builder.delete(builder.length() - 2, builder.length());
|
||||||
|
msg += " with traits " + builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
// Set age after entity spawns
|
// Set age after entity spawns
|
||||||
if (npc.getBukkitEntity() instanceof Ageable)
|
if (npc.getBukkitEntity() instanceof Ageable)
|
||||||
npc.getTrait(Age.class).setAge(age);
|
npc.getTrait(Age.class).setAge(age);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package net.citizensnpcs.npc;
|
package net.citizensnpcs.npc;
|
||||||
|
|
||||||
import net.citizensnpcs.EventListen;
|
import net.citizensnpcs.EventListen;
|
||||||
|
import net.citizensnpcs.Settings.Setting;
|
||||||
import net.citizensnpcs.api.CitizensAPI;
|
import net.citizensnpcs.api.CitizensAPI;
|
||||||
import net.citizensnpcs.api.ai.Navigator;
|
import net.citizensnpcs.api.ai.Navigator;
|
||||||
import net.citizensnpcs.api.event.NPCDespawnEvent;
|
import net.citizensnpcs.api.event.NPCDespawnEvent;
|
||||||
@ -14,6 +15,7 @@ import net.citizensnpcs.npc.ai.CitizensNavigator;
|
|||||||
import net.citizensnpcs.trait.CurrentLocation;
|
import net.citizensnpcs.trait.CurrentLocation;
|
||||||
import net.citizensnpcs.util.Messaging;
|
import net.citizensnpcs.util.Messaging;
|
||||||
import net.minecraft.server.EntityLiving;
|
import net.minecraft.server.EntityLiving;
|
||||||
|
import net.minecraft.server.EntityPlayer;
|
||||||
|
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -143,7 +145,8 @@ public abstract class CitizensNPC extends AbstractNPC {
|
|||||||
EventListen.add(loc, getId());
|
EventListen.add(loc, getId());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
mcEntity.world.players.remove(mcEntity);
|
if (mcEntity instanceof EntityPlayer && Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean())
|
||||||
|
mcEntity.world.players.remove(mcEntity);
|
||||||
|
|
||||||
NPCSpawnEvent spawnEvent = new NPCSpawnEvent(this, loc);
|
NPCSpawnEvent spawnEvent = new NPCSpawnEvent(this, loc);
|
||||||
Bukkit.getPluginManager().callEvent(spawnEvent);
|
Bukkit.getPluginManager().callEvent(spawnEvent);
|
||||||
|
Loading…
Reference in New Issue
Block a user