mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-12-25 10:37:35 +01:00
inventories now use the full name of an NPC
This commit is contained in:
parent
89bd263aad
commit
2a51adcaab
Binary file not shown.
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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];
|
||||
}
|
||||
|
||||
|
@ -55,4 +55,4 @@ public class CommandContextTest {
|
||||
private static CommandContext getContext(String cmd) {
|
||||
return new CommandContext("dummy " + cmd);
|
||||
}
|
||||
}
|
||||
}
|
@ -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 + "}";
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user