Esempio n. 1
0
 public boolean handleInterface(int item, int objectId, int objectX, int objectY) {
   CookingItems cook = CookingItems.forId(item);
   if (cook == null) return false;
   player.getActionSender().removeInterfaces();
   if (!Constants.COOKING_ENABLED) {
     player.getActionSender().sendMessage("This skill is currently disabled.");
     return true;
   }
   player.setOldObject(objectId);
   final CacheObject obj =
       ObjectLoader.object(objectId, objectX, objectY, player.getPosition().getZ());
   final GameObjectDef def =
       SkillHandler.getObject(objectId, objectX, objectY, player.getPosition().getZ());
   if (obj != null || def != null) {
     String name =
         GameObjectData.forId(obj != null ? obj.getDef().getId() : def.getId())
             .getName()
             .toLowerCase();
     if (name.equalsIgnoreCase("fire") || name.equalsIgnoreCase("fireplace")) {
       player.setNewSkillTask();
       player.setStatedInterface("cookFire");
       firePosition = new Position(objectX, objectY, player.getPosition().getZ());
       player.setTempInteger(item);
       if (player.getNewComersSide().isInTutorialIslandStage()
           || player.getInventory().getItemAmount(item) == 1) {
         handleCookingTick(player, 1);
         return true;
       }
       Item itemDef = new Item(item);
       player.getActionSender().sendItemOnInterface(13716, 200, item);
       player.getActionSender().sendString("" + itemDef.getDefinition().getName() + "", 13717);
       player.getActionSender().sendChatInterface(1743);
       return true;
     }
     if (name.equalsIgnoreCase("stove")
         || name.equalsIgnoreCase("range")
         || name.equalsIgnoreCase("cooking range")
         || name.equalsIgnoreCase("cooking pot")) {
       player.setNewSkillTask();
       player.setStatedInterface("cookRange");
       player.setTempInteger(item);
       if (player.getNewComersSide().isInTutorialIslandStage()
           || player.getInventory().getItemAmount(item) == 1) {
         handleCookingTick(player, 1);
         player
             .getUpdateFlags()
             .sendFaceToDirection(
                 new Position(player.getPosition().getX(), player.getPosition().getY() - 1));
         return true;
       }
       Item itemDef = new Item(item);
       player.getActionSender().sendItemOnInterface(13716, 200, item);
       player.getActionSender().sendString("" + itemDef.getDefinition().getName() + "", 13717);
       player.getActionSender().sendChatInterface(1743);
       return true;
     }
   }
   return true;
 }
Esempio n. 2
0
  @Override
  public void run() {
    try {
      Thread.currentThread().setName("ServerEngine");
      System.setOut(new Misc.TimestampLogger(System.out));
      System.setErr(new Misc.TimestampLogger(System.err, "./data/err.log"));

      address = new InetSocketAddress(host, port);
      System.out.println("Starting " + Constants.SERVER_NAME + " on " + address + "...");

      // load shutdown hook
      Thread shutdownhook = new ShutDownHook();
      Runtime.getRuntime().addShutdownHook(shutdownhook);

      PacketManager.loadPackets();

      Cache.load();

      // load scripts
      Misc.loadScripts(new File("./data/ruby/"));

      GlobalVariables.patchNotes = Misc.loadPatchNotes();
      GlobalVariables.info = Misc.loadInfo();
      GlobalVariables.npcDump = Misc.getNpcDump();
      GlobalVariables.itemDump = Misc.getItemDump();

      // load all xstream related files.
      XStreamUtil.loadAllFiles();

      // item weights
      ItemDefinition.loadWeight();

      // interfaces
      RSInterface.load();

      // Load plugins
      PluginManager.loadPlugins();

      // Load regions
      ObjectDef.loadConfig();
      Region.load();
      Rangable.load();

      // Load objects
      ObjectLoader objectLoader = new ObjectLoader();
      objectLoader.load();

      GameObjectData.init();

      // load combat manager
      CombatManager.init();

      // Load minute timer
      startMinutesCounter();

      // global drops
      GlobalGroundItem.initialize();

      // load npc ls
      Npc.loadNpcDrops();

      // mage arena timers
      AlchemistPlayground.loadAlchemistPlayGround();
      EnchantingChamber.loadEnchantingChamber();
      CreatureGraveyard.loadCreatureGraveyard();

      // spawning world fishing spots
      FishingSpots.spawnFishingSpots();

      QuestHandler.init();

      NpcLoader.loadAutoSpawn("./data/npcs/spawn-config.cfg");

      HighscoresManager.load();

      // Start up and get a'rollin!
      startup();
      System.out.println("Online!");
      while (!Thread.interrupted()) {
        try {
          cycle();
          sleep();
        } catch (Exception ex) {
          PlayerSave.saveAllPlayers();
          ex.printStackTrace();
        }
      }
      scheduler.schedule(
          new Task() {
            @Override
            protected void execute() {
              if (Thread.interrupted()) {
                PlayerSave.saveAllPlayers();
                stop();
                return;
              }
              try {
                cycle();
              } catch (Exception ex) {
                PlayerSave.saveAllPlayers();
                ex.printStackTrace();
                stop();
              }
            }
          });
    } catch (Exception ex) {
      ex.printStackTrace();
    }
    PluginManager.close();
  }
Esempio n. 3
0
 public static boolean handleDoor(int id, int x, int y, int z) {
   final String objectName =
       GameObjectData.forId(id) != null ? GameObjectData.forId(id).getName().toLowerCase() : "";
   if (!objectName.contains("fence")
           && !objectName.contains("gate")
           && !objectName.contains("door")
       || objectName.contains("trapdoor")
       || objectName.contains("tree")) {
     return false;
   }
   /* Special Doors */
   if (id == 883
       || id == 1805
       || id == 2882
       || id == 2883
       || id == 2623
       || id == 2112
       || id == 1804
       || id == 2266
       || id == 2406
       || id == 2407
       || id == 2631
       || id == 2623
       || id == 8958
       || id == 8959
       || id == 8960
       || id == 1589
       || id == 1590) {
     return false;
   }
   Doors d = getDoor(id, x, y, z);
   if (d == null) {
     return false;
   }
   GameObject g = ObjectHandler.getInstance().getObject(id, x, y, z);
   if (g != null) {
     if (d.type == 9) {
       ObjectHandler.getInstance().removeClip(x, y, z, 9, g.getDef().getFace());
     } else {
       ObjectHandler.getInstance().removeDoorClip(x, y, z, g.getDef().getFace());
     }
   }
   CacheObject c = ObjectLoader.object(id, x, y, z);
   if (c != null) {
     if (d.type == 9) {
       ObjectHandler.getInstance().removeClip(x, y, z, 9, c.getRotation());
     } else {
       ObjectHandler.getInstance().removeDoorClip(x, y, z, c.getRotation());
     }
   }
   int xAdjustment = 0, yAdjustment = 0;
   if (d.type == 0) {
     if (!d.open) {
       if (d.originalFace == 0 && d.currentFace == 0) {
         xAdjustment = -1;
       } else if (d.originalFace == 1 && d.currentFace == 1) {
         yAdjustment = 1;
       } else if (d.originalFace == 2 && d.currentFace == 2) {
         xAdjustment = 1;
       } else if (d.originalFace == 3 && d.currentFace == 3) {
         yAdjustment = -1;
       }
     } else if (d.open) {
       if (d.originalFace == 0 && d.currentFace == 0) {
         yAdjustment = 1;
       } else if (d.originalFace == 1 && d.currentFace == 1) {
         xAdjustment = 1;
       } else if (d.originalFace == 2 && d.currentFace == 2) {
         yAdjustment = -1;
       } else if (d.originalFace == 3 && d.currentFace == 3) {
         xAdjustment = -1;
       }
     }
   } else if (d.type == 9) {
     if (!d.open) {
       if (d.originalFace == 0 && d.currentFace == 0) {
         xAdjustment = 1;
       } else if (d.originalFace == 1 && d.currentFace == 1) {
         xAdjustment = 1;
       } else if (d.originalFace == 2 && d.currentFace == 2) {
         xAdjustment = -1;
       } else if (d.originalFace == 3 && d.currentFace == 3) {
         xAdjustment = -1;
       }
     } else if (d.open) {
       if (d.originalFace == 0 && d.currentFace == 0) {
         xAdjustment = 1;
       } else if (d.originalFace == 1 && d.currentFace == 1) {
         xAdjustment = 1;
       } else if (d.originalFace == 2 && d.currentFace == 2) {
         xAdjustment = -1;
       } else if (d.originalFace == 3 && d.currentFace == 3) {
         xAdjustment = -1;
       }
     }
   }
   if (xAdjustment != 0 || yAdjustment != 0) {
     ObjectHandler.getInstance().removeObject(d.doorX, d.doorY, d.doorZ, 0);
     new GameObject(
         Constants.EMPTY_OBJECT,
         d.doorX,
         d.doorY,
         d.doorZ,
         0,
         d.type,
         Constants.EMPTY_OBJECT,
         999999999);
   }
   if (d.doorX == d.originalX && d.doorY == d.originalY) {
     d.doorX += xAdjustment;
     d.doorY += yAdjustment;
   } else {
     ObjectHandler.getInstance().removeObject(d.doorX, d.doorY, d.doorZ, 0);
     new GameObject(
         Constants.EMPTY_OBJECT,
         d.doorX,
         d.doorY,
         d.doorZ,
         0,
         d.type,
         Constants.EMPTY_OBJECT,
         999999999);
     d.doorX = d.originalX;
     d.doorY = d.originalY;
   }
   if (id == 1513) {
     d.doorId = 1534;
   } else if (id == 22
       || id == 2550
       || id == 2551
       || id == 2556
       || id == 2558
       || id == 2557
       || id == 3014) {
     d.doorId = id;
   } else if (d.doorId == d.originalId) {
     if (!d.open) {
       d.doorId += 1;
     } else if (d.open) {
       d.doorId -= 1;
     }
   } else if (d.doorId != d.originalId) {
     if (!d.open) {
       d.doorId -= 1;
     } else if (d.open) {
       d.doorId += 1;
     }
   }
   int newFace = getNextFace(d);
   ObjectHandler.getInstance().removeObject(d.doorX, d.doorY, d.doorZ, 0);
   new GameObject(
       d.doorId, d.doorX, d.doorY, d.doorZ, newFace, d.type, Constants.EMPTY_OBJECT, 999999);
   return true;
 }