/** * Assigns the correct interface for the player based on the item. * * @param player the player to assign the interface for. * @param item the item to base the interface on. */ public static void assignInterface(Player player, Item item) { /** Block if this item isn't a weapon. */ if (item == null || item.getDefinition().getEquipmentSlot() != Misc.EQUIPMENT_SLOT_WEAPON) { return; } /** Retrieve the interface for the weapon from the map. */ WeaponInterface weapon = weaponInterface.get(item.getId()); /** Write the interface to the sidebar. */ if (weapon == WeaponInterface.UNARMED) { player.getPacketBuilder().sendSidebarInterface(0, weapon.getInterfaceId()); player.getPacketBuilder().sendString("Unarmed", weapon.getNameLineId()); player.setWeapon(WeaponInterface.UNARMED); return; } else if (weapon == WeaponInterface.CROSSBOW) { player.getPacketBuilder().sendString("Weapon: ", weapon.getNameLineId() - 1); } else if (weapon == WeaponInterface.WHIP) { player.getPacketBuilder().sendString("Weapon: ", weapon.getNameLineId() - 1); } player.getPacketBuilder().sendItemOnInterface(weapon.getInterfaceId() + 1, 200, item.getId()); player.getPacketBuilder().sendSidebarInterface(0, weapon.getInterfaceId()); player .getPacketBuilder() .sendString("" + item.getDefinition().getItemName() + "", weapon.getNameLineId()); player.setWeapon(weapon); }
/** * Resets the sidebar when an item is unequipped from the weapon slot. * * @param player the player to reset the sidebar for. */ public static void reset(Player player) { /** Reset the sidebar back to "unarmed". */ player.getPacketBuilder().sendSidebarInterface(0, WeaponInterface.UNARMED.getInterfaceId()); player.getPacketBuilder().sendString("Unarmed", WeaponInterface.UNARMED.getNameLineId()); player.setWeapon(WeaponInterface.UNARMED); }
@Override public void fire() { /** When the timer reaches 0 unskull the player. */ if (player.getSkullTimer() == 0) { player.getPacketBuilder().sendMessage("You have been successfully unskulled."); player.setSkullIcon(-1); player.getFlags().flag(Flag.APPEARANCE); this.cancel(); return; } /** Otherwise decrement the timer. */ player.decrementSkullTimer(); }