Search in sources :

Example 1 with FishingTrait

use of com.denizenscript.denizen.npc.traits.FishingTrait in project Denizen-For-Bukkit by DenizenScript.

the class FishCommand method execute.

@Override
public void execute(ScriptEntry scriptEntry) {
    LocationTag location = scriptEntry.getObjectTag("location");
    ElementTag catchtype = scriptEntry.getElement("catch");
    ElementTag stop = scriptEntry.getElement("stop");
    ElementTag percent = scriptEntry.getElement("percent");
    if (scriptEntry.dbCallShouldDebug()) {
        Debug.report(scriptEntry, getName(), location, catchtype, percent, stop);
    }
    NPCTag npc = Utilities.getEntryNPC(scriptEntry);
    FishingTrait trait = npc.getFishingTrait();
    if (stop.asBoolean()) {
        trait.stopFishing();
        return;
    }
    npc.getEquipmentTrait().set(0, new ItemStack(Material.FISHING_ROD));
    trait.setCatchPercent(percent.asInt());
    trait.setCatchType(FishingHelper.CatchType.valueOf(catchtype.asString().toUpperCase()));
    trait.startFishing(location);
}
Also used : LocationTag(com.denizenscript.denizen.objects.LocationTag) NPCTag(com.denizenscript.denizen.objects.NPCTag) FishingTrait(com.denizenscript.denizen.npc.traits.FishingTrait) ElementTag(com.denizenscript.denizencore.objects.core.ElementTag) ItemStack(org.bukkit.inventory.ItemStack)

Aggregations

FishingTrait (com.denizenscript.denizen.npc.traits.FishingTrait)1 LocationTag (com.denizenscript.denizen.objects.LocationTag)1 NPCTag (com.denizenscript.denizen.objects.NPCTag)1 ElementTag (com.denizenscript.denizencore.objects.core.ElementTag)1 ItemStack (org.bukkit.inventory.ItemStack)1