Example #1
0
        private static void rakePatch(Player p, Patch patch)
        {
            if (patch.isBlankPatch())
            {
                p.getPackets().sendMessage("This patch is clear of weeds.");
                return;
            }
            if (!p.getInventory().hasItem(TOOLS[0]))
            {
                p.getPackets().sendMessage("You need a rake to clear the weeds from this patch.");
                return;
            }
            p.setLastAnimation(new Animation(2273));
            patch.setWeeding(true);
            p.setTemporaryAttribute("harvesting", true);
            Event rakePatchEvent = new Event(1300);

            rakePatchEvent.setAction(() =>
            {
                if (p.isDestroyed() || p.isDisconnected() || p.getTemporaryAttribute("harvesting") == null)
                {
                    rakePatchEvent.stop();
                    patch.setWeeding(false);
                    return;
                }
                if (!p.getInventory().hasItem(TOOLS[0]))
                {
                    p.getPackets().sendMessage("You need a rake to clear the weeds from this patch.");
                    patch.setWeeding(false);
                    rakePatchEvent.stop();
                    return;
                }
                p.getInventory().addItemOrGround(6055);
                p.setLastAnimation(new Animation(2273));
                setConfig(p, patch);
                patch.setStatus(patch.getStatus() + 1);
                if (patch.getStatus() >= 3)
                {
                    p.getPackets().sendMessage("You clear the weeds from the patch, this patch is now suitable for farming.");
                    patch.setHasWeeds(false);
                    patch.setWeeding(false);
                    patch.setStatus(2);
                    setConfig(p, patch);
                    p.setLastAnimation(new Animation(65535));
                    rakePatchEvent.stop();
                    return;
                }
            });
            Server.registerEvent(rakePatchEvent);
        }
Example #2
0
        private static void harvestFruit(Player p, Patch patch)
        {
            if (p.getTemporaryAttribute("unmovable") != null)
            {
                return;
            }
            p.setLastAnimation(new Animation(2282));
            p.setTemporaryAttribute("unmovable", true);
            patch.setWeeding(true);
            Event harvestFruitEvent = new Event(1700);

            harvestFruitEvent.setAction(() =>
            {
                if (patch.getStatus() == patch.chopStatus() || p.isDisconnected() || p.isDestroyed() || p.isDead() || p.getTemporaryAttribute("teleporting") != null)
                {
                    harvestFruitEvent.stop();
                    return;
                }
                p.setLastAnimation(new Animation(2282));
                string s = patch.getSeedIndex() == 41 ? "leaf " : "";
                Event harvestingFruitEvent = new Event(800);
                harvestingFruitEvent.setAction(() =>
                {
                    harvestingFruitEvent.stop();
                    p.getPackets().sendMessage("You pick " + (string)SEEDS[patch.getSeedIndex()][9] + " " + (string)SEEDS[patch.getSeedIndex()][7] + s + " from the tree.");
                    p.getSkills().addXp(Skills.SKILL.FARMING, (double)SEEDS[patch.getSeedIndex()][8]);
                    p.getInventory().addItemOrGround((int)SEEDS[patch.getSeedIndex()][2], 1);
                    patch.setStatus(patch.getStatus() - 1);
                    if (patch.getStatus() == 5)
                    {                        // We have taken all the fruit (it is 5 after we lower the status above)
                        patch.setStatus(13); // Chop option
                        p.removeTemporaryAttribute("unmovable");
                        patch.setWeeding(false);
                    }
                    setConfig(p, patch);
                });
                Server.registerEvent(harvestingFruitEvent);
            });
            Server.registerEvent(harvestFruitEvent);
        }
Example #3
0
        private static void chopFruitTree(Player p, Patch patch)
        {
            if (!Woodcutting.hasAxe(p))
            {
                p.getPackets().sendMessage("You don't have an axe.");
                return;
            }
            patch.setWeeding(true); // prevents it from growing which makes me rage
            p.setLastAnimation(new Animation(Woodcutting.getAxeAnimation(p)));
            p.setTemporaryAttribute("harvesting", true);
            Event chopFruitTreeEvent = new Event(2550);

            chopFruitTreeEvent.setAction(() =>
            {
                if (p.getTemporaryAttribute("harvesting") != null)
                {
                    patch.setStatus(patch.stumpStatus());
                    setConfig(p, patch);
                }
                chopFruitTreeEvent.stop();
                patch.setWeeding(false);
            });
            Server.registerEvent(chopFruitTreeEvent);
        }
Example #4
0
 private static void rakePatch(Player p, Patch patch)
 {
     if (patch.isBlankPatch())
     {
         p.getPackets().sendMessage("This patch is clear of weeds.");
         return;
     }
     if (!p.getInventory().hasItem(TOOLS[0]))
     {
         p.getPackets().sendMessage("You need a rake to clear the weeds from this patch.");
         return;
     }
     p.setLastAnimation(new Animation(2273));
     patch.setWeeding(true);
     p.setTemporaryAttribute("harvesting", true);
     Event rakePatchEvent = new Event(1300);
     rakePatchEvent.setAction(() =>
     {
         if (p.isDestroyed() || p.isDisconnected() || p.getTemporaryAttribute("harvesting") == null)
         {
             rakePatchEvent.stop();
             patch.setWeeding(false);
             return;
         }
         if (!p.getInventory().hasItem(TOOLS[0]))
         {
             p.getPackets().sendMessage("You need a rake to clear the weeds from this patch.");
             patch.setWeeding(false);
             rakePatchEvent.stop();
             return;
         }
         p.getInventory().addItemOrGround(6055);
         p.setLastAnimation(new Animation(2273));
         setConfig(p, patch);
         patch.setStatus(patch.getStatus() + 1);
         if (patch.getStatus() >= 3)
         {
             p.getPackets().sendMessage("You clear the weeds from the patch, this patch is now suitable for farming.");
             patch.setHasWeeds(false);
             patch.setWeeding(false);
             patch.setStatus(2);
             setConfig(p, patch);
             p.setLastAnimation(new Animation(65535));
             rakePatchEvent.stop();
             return;
         }
     });
     Server.registerEvent(rakePatchEvent);
 }
Example #5
0
 private static void harvestFruit(Player p, Patch patch)
 {
     if (p.getTemporaryAttribute("unmovable") != null)
     {
         return;
     }
     p.setLastAnimation(new Animation(2282));
     p.setTemporaryAttribute("unmovable", true);
     patch.setWeeding(true);
     Event harvestFruitEvent = new Event(1700);
     harvestFruitEvent.setAction(() =>
     {
         if (patch.getStatus() == patch.chopStatus() || p.isDisconnected() || p.isDestroyed() || p.isDead() || p.getTemporaryAttribute("teleporting") != null)
         {
             harvestFruitEvent.stop();
             return;
         }
         p.setLastAnimation(new Animation(2282));
         string s = patch.getSeedIndex() == 41 ? "leaf " : "";
         Event harvestingFruitEvent = new Event(800);
         harvestingFruitEvent.setAction(() =>
         {
             harvestingFruitEvent.stop();
             p.getPackets().sendMessage("You pick " + (string)SEEDS[patch.getSeedIndex()][9] + " " + (string)SEEDS[patch.getSeedIndex()][7] + s + " from the tree.");
             p.getSkills().addXp(Skills.SKILL.FARMING, (double)SEEDS[patch.getSeedIndex()][8]);
             p.getInventory().addItemOrGround((int)SEEDS[patch.getSeedIndex()][2], 1);
             patch.setStatus(patch.getStatus() - 1);
             if (patch.getStatus() == 5)
             { // We have taken all the fruit (it is 5 after we lower the status above)
                 patch.setStatus(13); // Chop option
                 p.removeTemporaryAttribute("unmovable");
                 patch.setWeeding(false);
             }
             setConfig(p, patch);
         });
         Server.registerEvent(harvestingFruitEvent);
     });
     Server.registerEvent(harvestFruitEvent);
 }
Example #6
0
 private static void chopFruitTree(Player p, Patch patch)
 {
     if (!Woodcutting.hasAxe(p))
     {
         p.getPackets().sendMessage("You don't have an axe.");
         return;
     }
     patch.setWeeding(true); // prevents it from growing which makes me rage
     p.setLastAnimation(new Animation(Woodcutting.getAxeAnimation(p)));
     p.setTemporaryAttribute("harvesting", true);
     Event chopFruitTreeEvent = new Event(2550);
     chopFruitTreeEvent.setAction(() =>
     {
         if (p.getTemporaryAttribute("harvesting") != null)
         {
             patch.setStatus(patch.stumpStatus());
             setConfig(p, patch);
         }
         chopFruitTreeEvent.stop();
         patch.setWeeding(false);
     });
     Server.registerEvent(chopFruitTreeEvent);
 }