Jump to content

Get Other Players Equipment


LoudPacks

Recommended Posts

private List<String> getOthersEquipment(Player p) {
		List<String> equipmentList = new LinkedList<String>();
                if(p != null) {
		int[] equipment = p.getDefinition().getAppearance();
		for (int i = 0; i < equipment.length; i++) {
			if (equipment[i] - 512 > 0)
			equipmentList.add(ItemDefinition.forId(equipment[i] - 512).getName());
		}
                }
		return equipmentList;
	}

Note:

int[] equipment = p.getDefinition().getAppearance(); 

Index Order:

[0] = helmet

[1] = cape

[2] = necklace

[3] = weapon

[4] = chest

[5] = shield

[7] = legs

[9] = gloves

[10] = boots

- Can only grab visible items (no ring or ammo, etc.)

- Each value from getAppearance() needs to have 512 subtracted from it in order to get the item id

 

Or if you want it so you can grab specific pieces:

	private HashMap<EquipmentSlot, String> getOthersEquipment(Player p) {
		HashMap<EquipmentSlot, String> equipmentList = new HashMap<EquipmentSlot, String>();
		if (p != null) {
			int[] equipment = p.getDefinition().getAppearance();
			for (int i = 0; i < equipment.length; i++) {
                          if(equipment[i] - 512 > 0){
				switch(i){
					case 0:
						equipmentList.put(EquipmentSlot.HAT, ItemDefinition.forId(equipment[i] - 512).getName());
						break;
					case 1:
						equipmentList.put(EquipmentSlot.CAPE, ItemDefinition.forId(equipment[i] - 512).getName());	
						break;
					case 2:
						equipmentList.put(EquipmentSlot.AMULET, ItemDefinition.forId(equipment[i] - 512).getName());
						break;
					case 3:
						equipmentList.put(EquipmentSlot.WEAPON, ItemDefinition.forId(equipment[i] - 512).getName());				
						break;
					case 4:
						equipmentList.put(EquipmentSlot.CHEST, ItemDefinition.forId(equipment[i] - 512).getName());				
						break;
					case 5:
						equipmentList.put(EquipmentSlot.SHIELD, ItemDefinition.forId(equipment[i] - 512).getName());				
						break;
					case 7:
						equipmentList.put(EquipmentSlot.LEGS, ItemDefinition.forId(equipment[i] - 512).getName());				
						break;
					case 9:
						equipmentList.put(EquipmentSlot.HANDS, ItemDefinition.forId(equipment[i] - 512).getName());				
						break;
					case 10:
						equipmentList.put(EquipmentSlot.FEET, ItemDefinition.forId(equipment[i] - 512).getName());				
						break;
					
				}
                            }     
			}
		}
		return equipmentList;
	}
Edited by LoudPacks
  • Like 19
Link to comment
Share on other sites

  • 8 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...