use of com.github.sirblobman.api.item.ArmorType in project CombatLogX by SirBlobman.
the class InventoryManager method dropInventory.
public void dropInventory(OfflinePlayer player, Location location) {
Validate.notNull(player, "player must not be null!");
Validate.notNull(location, "location must not be null!");
World world = location.getWorld();
Validate.notNull(world, "location must have a valid world!");
StoredInventory storedInventory = getStoredInventory(player);
if (storedInventory == null) {
return;
}
for (int slot = 0; slot < 36; slot++) {
ItemStack item = storedInventory.getItem(slot);
dropItem(item, player, location, CitizensSlotType.INVENTORY);
}
ArmorType[] armorTypeArray = ArmorType.values();
for (ArmorType armorType : armorTypeArray) {
ItemStack item = storedInventory.getArmor(armorType);
dropItem(item, player, location, CitizensSlotType.ARMOR);
}
ItemStack item = storedInventory.getOffHandItem();
dropItem(item, player, location, CitizensSlotType.OFFHAND);
removeStoredInventory(player);
}
use of com.github.sirblobman.api.item.ArmorType in project CombatLogX by SirBlobman.
the class StoredInventory method save.
public void save(CitizensExpansion expansion, ConfigurationSection configuration) {
ItemStack mainHand = getMainHandItem();
saveItemStack(expansion, configuration, "main-hand", mainHand);
ItemStack offHand = getOffHandItem();
saveItemStack(expansion, configuration, "off-hand", offHand);
ArmorType[] armorTypeArray = ArmorType.values();
for (ArmorType armorType : armorTypeArray) {
ItemStack item = getArmor(armorType);
String armorTypeName = armorType.name();
String armorTypePath = ("armor." + armorTypeName);
saveItemStack(expansion, configuration, armorTypePath, item);
}
for (int slot = 0; slot < 36; slot++) {
ItemStack item = getItem(slot);
String slotName = Integer.toString(slot);
String slotPath = ("content." + slotName);
saveItemStack(expansion, configuration, slotPath, item);
}
}
use of com.github.sirblobman.api.item.ArmorType in project CombatLogX by SirBlobman.
the class InventoryManager method equipNPC.
public void equipNPC(OfflinePlayer player, NPC npc) {
Validate.notNull(player, "player must not be null!");
Validate.notNull(npc, "npc must not be null!");
Equipment equipmentTrait = npc.getOrAddTrait(Equipment.class);
StoredInventory storedInventory = getStoredInventory(player);
if (storedInventory == null) {
return;
}
ItemStack mainHandItem = storedInventory.getMainHandItem();
if (mainHandItem != null) {
equipmentTrait.set(EquipmentSlot.HAND, mainHandItem);
}
if (VersionUtility.getMinorVersion() > 8) {
ItemStack offHandItem = storedInventory.getOffHandItem();
if (offHandItem != null) {
equipmentTrait.set(EquipmentSlot.OFF_HAND, offHandItem);
}
}
ArmorType[] armorTypeArray = ArmorType.values();
for (ArmorType armorType : armorTypeArray) {
ItemStack item = storedInventory.getArmor(armorType);
if (item != null) {
org.bukkit.inventory.EquipmentSlot bukkitSlot = armorType.getSlot();
EquipmentSlot slot = getNpcSlotFromBukkitSlot(bukkitSlot);
equipmentTrait.set(slot, item);
}
}
}
use of com.github.sirblobman.api.item.ArmorType in project CombatLogX by SirBlobman.
the class StoredInventory method createFrom.
public static StoredInventory createFrom(CitizensExpansion expansion, ConfigurationSection configuration) {
Validate.notNull(configuration, "configuration must not be null!");
StoredInventory storedInventory = new StoredInventory();
ArmorType[] armorTypeArray = ArmorType.values();
for (ArmorType armorType : armorTypeArray) {
String armorTypeName = armorType.name();
String armorTypePath = ("armor." + armorTypeName);
ItemStack item = loadItemStack(expansion, configuration, armorTypePath);
storedInventory.setArmor(armorType, item);
}
ItemStack mainHand = loadItemStack(expansion, configuration, "main-hand");
ItemStack offHand = loadItemStack(expansion, configuration, "off-hand");
storedInventory.setMainHand(mainHand);
storedInventory.setOffHand(offHand);
for (int slot = 0; slot < 36; slot++) {
String slotName = Integer.toString(slot);
String slotPath = ("content." + slotName);
ItemStack item = loadItemStack(expansion, configuration, slotPath);
storedInventory.setItemStack(slot, item);
}
return storedInventory;
}
Aggregations