int idx = (int) p.readShort();
if (idx < 0 || idx >= player.getInventory().size()) {
player.setSuspiciousPlayer(true);
return;
}
final InvItem item = player.getInventory().getSlot(idx);
if (item == null || item.getDef().getCommand().equals("")) {
player.setSuspiciousPlayer(true);
return;
}
if (item.getDef().isMembers() && Config.f2pWildy
&& player.getLocation().inWilderness() && item.id != 814) {
player.getActionSender().sendMessage(
"Can not use a Member item in the wilderness");
return;
}
world.addEntryToSnapshots(new Activity(player.getUsername(), player
.getUsername()
+ " used item "
+ item.getDef().getName()
+ "("
+ item.id
+ ")"
+ " [CMD: "
+ item.getDef().getCommand()
+ "] at: " + player.getX() + "/" + player.getY()));
if (player.isBusy()) {
if (player.inCombat()) {
player.getActionSender().sendMessage(
"You cannot do that whilst fighting!");
}
return;
}// sip
player.resetAll();
if (item.id == 1263) {
// player.resetPath(); // This isn't how it's done in RSC
// player.setBusy(true); // Shouldn't be here
player.getActionSender()
.sendMessage("You rest in the sleeping bag");
showBubble(player, item);
player.getActionSender().sendEnterSleep();
player.setSleeping(true);
// player.setFatigue(0);
// player.getActionSender().sendFatigue();
// player.getActionSender().sendMessage("You wake up - feeling refreshed");
// player.isSleeping = true;
// player.setBusy(false);
return;
}
if (item.getDef().getCommand().equalsIgnoreCase("identify")) {
if (!Server.isMembers()) {
player.getActionSender().sendMessage(
"This feature is only avaliable on a members server");
return;
}
ItemUnIdentHerbDef herb = ItemAttributes.getUnIdentHerbDef(item.id);
if (herb == null) {
return;
}
if (player.getMaxStat(15) < herb.getLevelRequired()) {
player.getActionSender()
.sendMessage(
"Your herblaw ability is not high enough to clean this herb.");
return;
}
player.setBusy(true);
Instance.getDelayedEventHandler().add(new MiniEvent(player) {
public void action() {
ItemUnIdentHerbDef herb = ItemAttributes
.getUnIdentHerbDef(item.id);
InvItem newItem = new InvItem(herb.getNewId());
owner.getInventory().remove(item.id, item.amount, false);
owner.getInventory().add(newItem.id, newItem.amount, false);
owner.getActionSender().sendMessage(
"You clean the mud off the "
+ newItem.getDef().getName() + ".");
owner.incExp(15, herb.getExp(), true);
owner.getActionSender().sendStat(15);
owner.getActionSender().sendInventory();
owner.setBusy(false);
return;