예제 #1
0
        public static bool regrowWeeds(Patch patch)
        {
            bool shouldRemoveFromList = false;

            if (!patch.patchOccupied())
            {
                if (misc.random(4) != 0 || patch.isWeeding())
                {
                    return(false);
                }
                Player owner = Server.getPlayerForName(patch.getOwnerName());
                patch.setHasWeeds(true);
                patch.setStatus(patch.getStatus() - 1);
                if (patch.getStatus() <= -1)
                {
                    patch.setStatus(0);
                    shouldRemoveFromList = true;
                }
                if (owner != null)
                {
                    setConfig(owner, patch);
                }
            }
            return(shouldRemoveFromList);
        }
예제 #2
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);
        }
예제 #3
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);
 }
예제 #4
0
 public static bool regrowWeeds(Patch patch)
 {
     bool shouldRemoveFromList = false;
     if (!patch.patchOccupied()) {
         if (misc.random(4) != 0 || patch.isWeeding()) {
             return false;
         }
         Player owner = Server.getPlayerForName(patch.getOwnerName());
         patch.setHasWeeds(true);
         patch.setStatus(patch.getStatus() - 1);
         if (patch.getStatus() <= -1) {
             patch.setStatus(0);
             shouldRemoveFromList = true;
         }
         if (owner != null) {
             setConfig(owner, patch);
         }
     }
     return shouldRemoveFromList;
 }