Minor AdminEnchant cleanup.

This commit is contained in:
MobiusDevelopment
2022-08-28 16:27:11 +00:00
parent d0fae0be8f
commit 07fdf2056e

View File

@@ -62,65 +62,65 @@ public class AdminEnchant implements IAdminCommandHandler
} }
else else
{ {
int armorType = -1; int slot = -1;
if (command.startsWith("admin_seteh")) if (command.startsWith("admin_seteh"))
{ {
armorType = Inventory.PAPERDOLL_HEAD; slot = Inventory.PAPERDOLL_HEAD;
} }
else if (command.startsWith("admin_setec")) else if (command.startsWith("admin_setec"))
{ {
armorType = Inventory.PAPERDOLL_CHEST; slot = Inventory.PAPERDOLL_CHEST;
} }
else if (command.startsWith("admin_seteg")) else if (command.startsWith("admin_seteg"))
{ {
armorType = Inventory.PAPERDOLL_GLOVES; slot = Inventory.PAPERDOLL_GLOVES;
} }
else if (command.startsWith("admin_seteb")) else if (command.startsWith("admin_seteb"))
{ {
armorType = Inventory.PAPERDOLL_FEET; slot = Inventory.PAPERDOLL_FEET;
} }
else if (command.startsWith("admin_setel")) else if (command.startsWith("admin_setel"))
{ {
armorType = Inventory.PAPERDOLL_LEGS; slot = Inventory.PAPERDOLL_LEGS;
} }
else if (command.startsWith("admin_setew")) else if (command.startsWith("admin_setew"))
{ {
armorType = Inventory.PAPERDOLL_RHAND; slot = Inventory.PAPERDOLL_RHAND;
} }
else if (command.startsWith("admin_setes")) else if (command.startsWith("admin_setes"))
{ {
armorType = Inventory.PAPERDOLL_LHAND; slot = Inventory.PAPERDOLL_LHAND;
} }
else if (command.startsWith("admin_setle")) else if (command.startsWith("admin_setle"))
{ {
armorType = Inventory.PAPERDOLL_LEAR; slot = Inventory.PAPERDOLL_LEAR;
} }
else if (command.startsWith("admin_setre")) else if (command.startsWith("admin_setre"))
{ {
armorType = Inventory.PAPERDOLL_REAR; slot = Inventory.PAPERDOLL_REAR;
} }
else if (command.startsWith("admin_setlf")) else if (command.startsWith("admin_setlf"))
{ {
armorType = Inventory.PAPERDOLL_LFINGER; slot = Inventory.PAPERDOLL_LFINGER;
} }
else if (command.startsWith("admin_setrf")) else if (command.startsWith("admin_setrf"))
{ {
armorType = Inventory.PAPERDOLL_RFINGER; slot = Inventory.PAPERDOLL_RFINGER;
} }
else if (command.startsWith("admin_seten")) else if (command.startsWith("admin_seten"))
{ {
armorType = Inventory.PAPERDOLL_NECK; slot = Inventory.PAPERDOLL_NECK;
} }
else if (command.startsWith("admin_setun")) else if (command.startsWith("admin_setun"))
{ {
armorType = Inventory.PAPERDOLL_UNDER; slot = Inventory.PAPERDOLL_UNDER;
} }
else if (command.startsWith("admin_setba")) else if (command.startsWith("admin_setba"))
{ {
armorType = Inventory.PAPERDOLL_BACK; slot = Inventory.PAPERDOLL_BACK;
} }
if (armorType != -1) if (slot != -1)
{ {
try try
{ {
@@ -133,7 +133,7 @@ public class AdminEnchant implements IAdminCommandHandler
} }
else else
{ {
setEnchant(activeChar, ench, armorType); setEnchant(activeChar, ench, slot);
} }
} }
catch (StringIndexOutOfBoundsException e) catch (StringIndexOutOfBoundsException e)
@@ -153,7 +153,7 @@ public class AdminEnchant implements IAdminCommandHandler
return true; return true;
} }
private void setEnchant(Player activeChar, int ench, int armorType) private void setEnchant(Player activeChar, int ench, int slot)
{ {
// get the target // get the target
WorldObject target = activeChar.getTarget(); WorldObject target = activeChar.getTarget();
@@ -178,18 +178,18 @@ public class AdminEnchant implements IAdminCommandHandler
Item itemInstance = null; Item itemInstance = null;
// only attempt to enchant if there is a weapon equipped // only attempt to enchant if there is a weapon equipped
Item parmorInstance = player.getInventory().getPaperdollItem(armorType); Item paperdollInstance = player.getInventory().getPaperdollItem(slot);
if ((parmorInstance != null) && (parmorInstance.getEquipSlot() == armorType)) if ((paperdollInstance != null) && (paperdollInstance.getEquipSlot() == slot))
{ {
itemInstance = parmorInstance; itemInstance = paperdollInstance;
} }
else else
{ {
// for bows and double handed weapons // for bows and double handed weapons
parmorInstance = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LRHAND); paperdollInstance = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LRHAND);
if ((parmorInstance != null) && (parmorInstance.getEquipSlot() == Inventory.PAPERDOLL_LRHAND)) if ((paperdollInstance != null) && (paperdollInstance.getEquipSlot() == Inventory.PAPERDOLL_LRHAND))
{ {
itemInstance = parmorInstance; itemInstance = paperdollInstance;
} }
} }