Double quote everything, remove trait data

This commit is contained in:
fullwall 2012-10-26 14:26:57 +08:00
parent 386f9369a4
commit 17452c4ce5
2 changed files with 33 additions and 15 deletions

View File

@ -1,5 +1,7 @@
package net.citizensnpcs.npc;
import java.util.List;
import net.citizensnpcs.EventListen;
import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.ai.Navigator;
@ -25,9 +27,12 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.metadata.FixedMetadataValue;
import com.google.common.collect.Lists;
public abstract class CitizensNPC extends AbstractNPC {
protected EntityLiving mcEntity;
private final CitizensNavigator navigator = new CitizensNavigator(this);
private final List<String> removedTraits = Lists.newArrayList();
protected CitizensNPC(int id, String name) {
super(id, name);
@ -35,6 +40,14 @@ public abstract class CitizensNPC extends AbstractNPC {
protected abstract EntityLiving createHandle(Location loc);
@Override
public void removeTrait(Class<? extends Trait> clazz) {
Trait present = traits.get(clazz);
if (present != null)
removedTraits.add(present.getName());
super.removeTrait(clazz);
}
@Override
public boolean despawn() {
if (!isSpawned())
@ -125,7 +138,12 @@ public abstract class CitizensNPC extends AbstractNPC {
DataKey traitKey = root.getRelative("traits." + trait.getName());
trait.save(traitKey);
PersistenceLoader.save(trait, traitKey);
removedTraits.remove(trait.getName());
}
for (String name : removedTraits) {
root.removeKey("traits." + name);
}
removedTraits.clear();
}
@Override

View File

@ -3,7 +3,7 @@ citizens.commands.citizens.save.help=Use the -a flag to save async (off the main
citizens.commands.console-error=Please report this error: [See console]
citizens.commands.help.command-missing=Command /{0} not found.
citizens.commands.help.header=Help
citizens.commands.id-not-found=Couldn't find any NPC with ID {0}.
citizens.commands.id-not-found=Couldn''t find any NPC with ID {0}.
citizens.commands.invalid-mobtype={0} is not a valid mobtype.
citizens.commands.invalid-number=That is not a valid number.
citizens.commands.npc.age.cannot-be-aged=The mob type {0} cannot be aged.
@ -32,19 +32,19 @@ citizens.commands.npc.create.invalid-mobtype={0} is not a valid mob type. Using
citizens.commands.npc.create.not-living-mobtype={0} is not a living entity type. Using default type.
citizens.commands.npc.create.npc-name-too-long=NPC names cannot be longer than 16 characters. The name has been shortened.
citizens.commands.npc.despawn.despawned=You despawned [[{0}]].
citizens.commands.npc.gamemode.describe={0}'s gamemode is [[{1}]].
citizens.commands.npc.gamemode.describe={0}''s gamemode is [[{1}]].
citizens.commands.npc.gamemode.invalid={0} is not a valid gamemode.
citizens.commands.npc.gamemode.set=Gamemode set to [[{0}]].
citizens.commands.npc.gravity.disabled=Gravity [[disabled]].
citizens.commands.npc.gravity.enabled=Gravity [[enabled]].
citizens.commands.npc.lookclose.set=[[{0}]] will now rotate when players are nearby.
citizens.commands.npc.lookclose.stopped=[[{0}]] will no longer rotate when players are nearby.
citizens.commands.npc.mount.failed=Couldn't mount [[{0}]].
citizens.commands.npc.mount.failed=Couldn''t mount [[{0}]].
citizens.commands.npc.moveto.format=Format is x:y:z(:world) or x y z( world).
citizens.commands.npc.moveto.missing-world=World not found.
citizens.commands.npc.moveto.teleported=[[{0}]] teleported to {1}.
citizens.commands.npc.owner.already-owner={0} is already the owner of {1}.
citizens.commands.npc.owner.owner=[[{0}]]'s owner is [[{1}]].
citizens.commands.npc.owner.owner=[[{0}]]''s owner is [[{1}]].
citizens.commands.npc.owner.set-server=[[The server]] is now the owner of {0}.
citizens.commands.npc.owner.set=[[{1}]] is now the owner of {0}.
citizens.commands.npc.pathfindingrange.set=Pathfinding range set to [[{0}]].
@ -64,9 +64,9 @@ citizens.commands.npc.remove.removed-all=You permanently removed all NPCs.
citizens.commands.npc.remove.removed=You permanently removed [[{0}]].
citizens.commands.npc.rename.renamed=You renamed [[{0}]] to [[{1}]].
citizens.commands.npc.select.already-selected=You already have that NPC selected.
citizens.commands.npc.size.description={0}'s size is [[{1}]].
citizens.commands.npc.size.set={0}'s size set to [[{1}]].
citizens.commands.npc.spawn.already-spawned={0} is already spawned at another location. Use '/npc tphere' to teleport the NPC to your location.
citizens.commands.npc.size.description={0}''s size is [[{1}]].
citizens.commands.npc.size.set={0}''s size set to [[{1}]].
citizens.commands.npc.spawn.already-spawned={0} is already spawned at another location. Use ''/npc tphere'' to teleport the NPC to your location.
citizens.commands.npc.spawn.missing-npc-id=No NPC with the ID {0} exists.
citizens.commands.npc.spawn.no-location=No stored location available - command must be used ingame.
citizens.commands.npc.spawn.spawned=You spawned [[{0}]].
@ -84,25 +84,25 @@ citizens.commands.requirements.must-be-owner=You must be the owner of this NPC t
citizens.commands.requirements.must-have-selected=You must have an NPC selected to execute that command.
citizens.commands.script.compiled=Script compiled.
citizens.commands.script.compiling=Script compiling...
citizens.commands.script.file-missing=The file {0} doesn't exist!
citizens.commands.script.file-missing=The file {0} doesn''t exist!
citizens.commands.template.applied=Template applied to [[{0}]] NPCs.
citizens.commands.template.conflict=A template by that name already exists.
citizens.commands.template.created=Template created.
citizens.commands.template.missing=Template not found.
citizens.commands.trait.added=Added {0} successfully.
citizens.commands.trait.failed-to-add=<7>Couldn't add {0}.
citizens.commands.trait.failed-to-change=<7>Couldn't change {0}.
citizens.commands.trait.failed-to-remove=<7>Couldn't remove {0}.
citizens.commands.trait.failed-to-add=<7>Couldn''t add {0}.
citizens.commands.trait.failed-to-change=<7>Couldn''t change {0}.
citizens.commands.trait.failed-to-remove=<7>Couldn''t remove {0}.
citizens.commands.trait.removed=Removed {0} successfully.
citizens.commands.traitc.missing=Trait not found.
citizens.commands.traitc.not-configurable=That trait is not configurable.
citizens.commands.traitc.not-on-npc=The NPC doesn't have that trait.
citizens.commands.traitc.not-on-npc=The NPC doesn''t have that trait.
citizens.commands.unknown-command=Unknown command. Did you mean:
citizens.conversations.selection.invalid-choice=[[{0}]] is not a valid option.
citizens.economy.error-loading=Unable to use economy handling. Has Vault been enabled?
citizens.economy.minimum-cost-required=Need at least {0}.
citizens.economy.money-withdrawn=Withdrew [[{0}]] for your NPC.
citizens.editors.already-in-editor=You're already in an editor!
citizens.editors.already-in-editor=You''re already in an editor!
citizens.editors.equipment.all-items-removed=[[{0}]] had all of its items removed.
citizens.editors.equipment.begin=<b>Entered the equipment editor!<br>[[Right click]] to equip the NPC!
citizens.editors.equipment.end=Exited the equipment editor.
@ -140,7 +140,7 @@ citizens.editors.waypoints.linear.range-exceeded=Previous waypoint is {0} blocks
citizens.editors.waypoints.linear.removed-waypoint=[[Removed]] a waypoint ([[{0}]] remaining) ([[{1}]])
citizens.editors.waypoints.linear.showing-markers=[[Showing]] waypoint markers.
citizens.limits.over-npc-limt=Over the NPC limit of {0}.
citizens.load-task-error=NPC load task couldn't be scheduled, disabling...
citizens.load-task-error=NPC load task couldn''t be scheduled, disabling...
citizens.nms-errors.clearing-goals=Could not clear goals: {0}.
citizens.nms-errors.getting-field=Could not fetch field {0}: {1}.
citizens.nms-errors.getting-id-mapping=Could not fetch entity id mapping fields: {0}.
@ -175,7 +175,7 @@ citizens.saves.load-failed=Unable to load saves, disabling...
citizens.settings.writing-default=Writing default setting: {0}
citizens.sub-plugins.error-on-load={0} initializing {1}
citizens.sub-plugins.load=Loading {0}
citizens.traits.age-description={0}'s age is [[{1}]]. Locked is [[{2}]].
citizens.traits.age-description={0}''s age is [[{1}]]. Locked is [[{2}]].
citizens.waypoints.available-providers-header=<b>List of available providers
citizens.waypoints.current-provider=The current waypoint provider is [[{0}]].
citizens.waypoints.set-provider=Set the waypoint provider to [[{0}]].