Code:
package org.rs2server.rs2.model.skills;
import java.util.HashMap;
import java.util.Map;
import org.rs2server.rs2.action.impl.HarvestingAction;
import org.rs2server.rs2.model.Animation;
import org.rs2server.rs2.model.GameObject;
import org.rs2server.rs2.model.Item;
import org.rs2server.rs2.model.Mob;
import org.rs2server.rs2.model.NPC;
import org.rs2server.rs2.model.Player;
import org.rs2server.rs2.model.Skills;
public class Fishing extends HarvestingAction {
private Spot spot;
private NPC npc;
public Fishing(Mob mob, NPC npc, Spot spot) {
super(mob);
this.spot = spot;
this.npc = npc;
}
public enum Spot {
SHRIMP(332, 1, 0.50, 317, new short[] {303}, 100, 620),
TROUT(310, 20, 0.050, 335, new short[] {309, 314}, 100, 622),
SALMON(310, 30, 0.50, 331, new short[] {309, 314}, 100, 622),
LOBSTER(333, 40, 0.50, 377, new short[] {301}, 100, 619),
MONK(313, 62, 0.50, 7944, new short[] {305}, 100, 620);
/**
* The npc id.
*/
private int npc;
/**
* The level required to fish this.
*/
private int level;
private double rate;
/**
* The Fish given
*/
private int fish;
/**
* The gear required
*/
private short[] gear;
private double exp;
private int anim;
/**
* A list of spots.
*/
private static Map<Integer, Spot> spots = new HashMap<>();
/**
* Gets the list of hatchets.
* @return The list of hatchets.
*/
public static Spot forId(int npc) {
return spots.get(npc);
}
/**
* Populates the fish map.
*/
static {
for (Spot spot : Spot.values()) {
spots.put(spot.npc, spot);
}
}
private Spot(int npc, int level, double rate, int fish, short[] gear, double exp, int anim) {
this.npc = npc;
this.level = level;
this.rate = rate;
this.fish = fish;
this.gear = gear;
this.exp = exp;
this.anim = anim;
}
/**
* @return the id
*/
public int getNpc() {
return npc;
}
/**
* @return the level
*/
public int getLevel() {
return level;
}
public double getRate() {
return rate;
}
/**
* @return the animation
*/
public int getFish() {
return fish;
}
public short[] getGear() {
return gear;
}
public double getExp() {
return exp;
}
public int getAnim() {
return anim;
}
}
//if((spot.getLevel() * spot.rate) <= getMob().getSkills().getLevelForExperience(getSkill()) * (spot.rate/2))
@Override
public Animation getAnimation() {
return Animation.create(spot.getAnim());
}
@Override
public int getCycleCount() {
return 3;
//return (int) (getMob().getSkills().getLevelForExperience(getSkill()) * spot.getRate());
}
@Override
public double getExperience() {
return spot.getExp();
}
@Override
public GameObject getGameObject() {
return null;
}
@Override
public int getGameObjectMaxHealth() {
return 100;
}
@Override
public String getHarvestStartedMessage() {
return "you attempt to catch some fish";
}
@Override
public String getLevelTooLowMessage() {
return "You need a " + Skills.SKILL_NAME[getSkill()] + " level of " + spot.getLevel() + " to fish here.";
}
@Override
public int getRequiredLevel() {
return spot.getLevel();
}
@Override
public Item getReward() {
return new Item(spot.getFish(), 1);
}
@Override
public Item[] getConsumedItems() {
if(spot.gear.length > 1) {
return new Item[] { new Item(spot.gear[1])};
} else {
return new Item[] { new Item(spot.gear[0], 0)};
}
}
@Override
public int getSkill() {
return Skills.FISHING;
}
@Override
public String getSuccessfulHarvestMessage() {
return "You catch a " + getReward().getDefinition().getName().toLowerCase() + ".";
}
@Override
public boolean canHarvest() {
/**for(Spot spot : Spot.values()) {
if((getMob().getInventory().contains(spot.gear[0]))
&& getMob().getSkills().getLevelForExperience(getSkill()) >= spot.getRequiredLevel()) {
this.spot = spot;
break;
}
}**/
for(int item : spot.gear) {
if(!getMob().getInventory().contains(item)) {
getMob().getActionSender().sendMessage("You do not have the proper gear to fish here.");
return false;
}
}
return true;
}
@Override
public String getInventoryFullMessage() {
return "Your inventory is too full to hold any more " + getReward().getDefinition().getName().toLowerCase() + ".";
}
@Override
public GameObject getReplacementObject() {
// TODO Auto-generated method stub
return null;
}
@Override
public int getObjectRespawnTimer() {
// TODO Auto-generated method stub
return 0;
}
public NPC getNPC() {
return npc;
}
}