inventories now use the full name of an NPC

This commit is contained in:
aPunch 2012-02-07 02:31:28 -06:00
parent 89bd263aad
commit 2a51adcaab
6 changed files with 12 additions and 12 deletions

Binary file not shown.

View File

@ -171,11 +171,10 @@ public class Citizens extends JavaPlugin {
config.load();
// NPC storage
if (Setting.USE_DATABASE.asBoolean()) {
if (Setting.USE_DATABASE.asBoolean())
saves = new DatabaseStorage();
} else {
else
saves = new YamlStorage(getDataFolder() + File.separator + "saves.yml");
}
// Register API managers
npcManager = new CitizensNPCManager(saves);

View File

@ -8,6 +8,7 @@ import net.citizensnpcs.api.npc.trait.trait.Spawned;
import net.citizensnpcs.npc.ai.CitizensAI;
import net.citizensnpcs.trait.Inventory;
import net.citizensnpcs.util.Messaging;
import net.minecraft.server.EntityLiving;
import org.bukkit.Bukkit;

View File

@ -1,5 +1,6 @@
package net.citizensnpcs.npc;
import net.citizensnpcs.util.StringHelper;
import net.minecraft.server.EntityHuman;
import net.minecraft.server.IInventory;
import net.minecraft.server.ItemStack;
@ -19,7 +20,7 @@ public class NPCInventory implements IInventory {
public NPCInventory(CitizensNPC npc) {
this.npc = npc;
name = npc.getName();
name = StringHelper.parseColors(npc.getFullName());
contents = new ItemStack[size];
}

View File

@ -55,4 +55,4 @@ public class CommandContextTest {
private static CommandContext getContext(String cmd) {
return new CommandContext("dummy " + cmd);
}
}
}

View File

@ -39,21 +39,20 @@ public class Inventory implements Trait {
@Override
public void save(DataKey key) {
int index = 0;
int slot = 0;
for (ItemStack item : contents) {
// Clear previous items to avoid conflicts
key.removeKey(String.valueOf(index));
key.removeKey(String.valueOf(slot));
if (item != null)
saveItem(item, key.getRelative(String.valueOf(index)));
index++;
saveItem(item, key.getRelative(String.valueOf(slot)));
slot++;
}
}
private ItemStack[] parseContents(DataKey key) throws NPCLoadException {
ItemStack[] contents = new ItemStack[36];
for (DataKey slotKey : key.getIntegerSubKeys()) {
for (DataKey slotKey : key.getIntegerSubKeys())
contents[Integer.parseInt(slotKey.name())] = getItemStack(slotKey);
}
return contents;
}
@ -91,6 +90,6 @@ public class Inventory implements Trait {
@Override
public String toString() {
return "Inventory{contents:" + contents + "}";
return "Inventory{" + contents + "}";
}
}