mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-23 07:41:29 +01:00
inventories now use the full name of an NPC
This commit is contained in:
parent
b8bc6df251
commit
13ebcb54cc
Binary file not shown.
@ -171,11 +171,10 @@ public class Citizens extends JavaPlugin {
|
|||||||
config.load();
|
config.load();
|
||||||
|
|
||||||
// NPC storage
|
// NPC storage
|
||||||
if (Setting.USE_DATABASE.asBoolean()) {
|
if (Setting.USE_DATABASE.asBoolean())
|
||||||
saves = new DatabaseStorage();
|
saves = new DatabaseStorage();
|
||||||
} else {
|
else
|
||||||
saves = new YamlStorage(getDataFolder() + File.separator + "saves.yml");
|
saves = new YamlStorage(getDataFolder() + File.separator + "saves.yml");
|
||||||
}
|
|
||||||
|
|
||||||
// Register API managers
|
// Register API managers
|
||||||
npcManager = new CitizensNPCManager(saves);
|
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.npc.ai.CitizensAI;
|
||||||
import net.citizensnpcs.trait.Inventory;
|
import net.citizensnpcs.trait.Inventory;
|
||||||
import net.citizensnpcs.util.Messaging;
|
import net.citizensnpcs.util.Messaging;
|
||||||
|
|
||||||
import net.minecraft.server.EntityLiving;
|
import net.minecraft.server.EntityLiving;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.citizensnpcs.npc;
|
package net.citizensnpcs.npc;
|
||||||
|
|
||||||
|
import net.citizensnpcs.util.StringHelper;
|
||||||
import net.minecraft.server.EntityHuman;
|
import net.minecraft.server.EntityHuman;
|
||||||
import net.minecraft.server.IInventory;
|
import net.minecraft.server.IInventory;
|
||||||
import net.minecraft.server.ItemStack;
|
import net.minecraft.server.ItemStack;
|
||||||
@ -19,7 +20,7 @@ public class NPCInventory implements IInventory {
|
|||||||
|
|
||||||
public NPCInventory(CitizensNPC npc) {
|
public NPCInventory(CitizensNPC npc) {
|
||||||
this.npc = npc;
|
this.npc = npc;
|
||||||
name = npc.getName();
|
name = StringHelper.parseColors(npc.getFullName());
|
||||||
contents = new ItemStack[size];
|
contents = new ItemStack[size];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,4 +55,4 @@ public class CommandContextTest {
|
|||||||
private static CommandContext getContext(String cmd) {
|
private static CommandContext getContext(String cmd) {
|
||||||
return new CommandContext("dummy " + cmd);
|
return new CommandContext("dummy " + cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -39,21 +39,20 @@ public class Inventory implements Trait {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void save(DataKey key) {
|
public void save(DataKey key) {
|
||||||
int index = 0;
|
int slot = 0;
|
||||||
for (ItemStack item : contents) {
|
for (ItemStack item : contents) {
|
||||||
// Clear previous items to avoid conflicts
|
// Clear previous items to avoid conflicts
|
||||||
key.removeKey(String.valueOf(index));
|
key.removeKey(String.valueOf(slot));
|
||||||
if (item != null)
|
if (item != null)
|
||||||
saveItem(item, key.getRelative(String.valueOf(index)));
|
saveItem(item, key.getRelative(String.valueOf(slot)));
|
||||||
index++;
|
slot++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ItemStack[] parseContents(DataKey key) throws NPCLoadException {
|
private ItemStack[] parseContents(DataKey key) throws NPCLoadException {
|
||||||
ItemStack[] contents = new ItemStack[36];
|
ItemStack[] contents = new ItemStack[36];
|
||||||
for (DataKey slotKey : key.getIntegerSubKeys()) {
|
for (DataKey slotKey : key.getIntegerSubKeys())
|
||||||
contents[Integer.parseInt(slotKey.name())] = getItemStack(slotKey);
|
contents[Integer.parseInt(slotKey.name())] = getItemStack(slotKey);
|
||||||
}
|
|
||||||
return contents;
|
return contents;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,6 +90,6 @@ public class Inventory implements Trait {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Inventory{contents:" + contents + "}";
|
return "Inventory{" + contents + "}";
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user