Ejemplo n.º 1
0
 public void spawn() {
   World w = World.getInstance();
   WorldPosition position =
       w.createPosition(
           template.getMap(),
           template.getCenter().getX(),
           template.getCenter().getY(),
           template.getCenter().getZ(),
           (byte) 0,
           0);
   this.setPosition(position);
   w.storeObject(this);
   w.spawn(this);
 }
  /** Instance will be destroyed All players moved to bind location All objects - deleted */
  private static void destroyInstance(WorldMapInstance instance) {
    instance.getEmptyInstanceTask().cancel(false);

    int worldId = instance.getMapId();
    int instanceId = instance.getInstanceId();

    WorldMap map = World.getInstance().getWorldMap(worldId);
    map.removeWorldMapInstance(instanceId);

    log.info("Destroying instance:" + worldId + " " + instanceId);

    Iterator<VisibleObject> it = instance.objectIterator();
    while (it.hasNext()) {
      VisibleObject obj = it.next();
      if (obj instanceof Player) {
        Player player = (Player) obj;
        PortalTemplate portal =
            DataManager.PORTAL_DATA.getInstancePortalTemplate(
                worldId, player.getCommonData().getRace());
        moveToEntryPoint((Player) obj, portal, true);
      } else {
        obj.getController().delete();
      }
    }
  }
  @Override
  public void executeCommand(Player admin, String[] params) {
    if (admin.getAccessLevel() < AdminConfig.COMMAND_PRISON) {
      PacketSendUtility.sendMessage(admin, "You dont have enough rights to execute this command!");
      return;
    }

    if (params.length == 0 || params.length > 2) {
      PacketSendUtility.sendMessage(admin, "syntax //rprison <player>");
      return;
    }

    try {
      Player playerFromPrison = World.getInstance().findPlayer(Util.convertName(params[0]));

      if (playerFromPrison != null) {
        PunishmentService.setIsInPrison(playerFromPrison, false, 0);
        PacketSendUtility.sendMessage(
            admin, "Player " + playerFromPrison.getName() + " removed from prison.");
      }
    } catch (NoSuchElementException nsee) {
      PacketSendUtility.sendMessage(admin, "Usage: //rprison <player>");
    } catch (Exception e) {
      PacketSendUtility.sendMessage(admin, "Usage: //rprison <player>");
    }
  }
  /** {@inheritDoc} */
  @Override
  protected void runImpl() {
    Player activePlayer = getConnection().getActivePlayer();

    Iterator<Player> it = World.getInstance().getPlayersIterator();

    List<Player> matches = new ArrayList<Player>(MAX_RESULTS);

    if (activePlayer != null && activePlayer.getLevel() < 10) {
      sendPacket(SM_SYSTEM_MESSAGE.LEVEL_NOT_ENOUGH_FOR_SEARCH("10"));
      return;
    }
    while (it.hasNext() && matches.size() < MAX_RESULTS) {
      Player player = it.next();
      if (!player.isSpawned()) continue;
      else if (player.getFriendList().getStatus() == Status.OFFLINE) continue;
      else if (lfgOnly == 1 && !player.isLookingForGroup()) continue;
      else if (!name.isEmpty() && !player.getName().toLowerCase().contains(name.toLowerCase()))
        continue;
      else if (minLevel != 0xFF && player.getLevel() < minLevel) continue;
      else if (maxLevel != 0xFF && player.getLevel() > maxLevel) continue;
      else if (classMask > 0 && (player.getPlayerClass().getMask() & classMask) == 0) continue;
      else if (region > 0 && player.getActiveRegion().getMapId() != region) continue;
      else if ((player.getCommonData().getRace() != activePlayer.getCommonData().getRace())
          && (CustomConfig.FACTIONS_SEARCH_MODE == false)) continue;
      else
      // This player matches criteria
      {
        matches.add(player);
      }
    }

    sendPacket(new SM_PLAYER_SEARCH(matches, region));
  }
 /**
  * @param worldId
  * @param objectId
  * @return instance or null
  */
 public static WorldMapInstance getRegisteredInstance(int worldId, int objectId) {
   Iterator<WorldMapInstance> iterator = World.getInstance().getWorldMap(worldId).iterator();
   while (iterator.hasNext()) {
     WorldMapInstance instance = iterator.next();
     if (instance.isRegistered(objectId)) return instance;
   }
   return null;
 }
 private void shout_attack() { // MSG Notice 05
   World.getInstance()
       .doOnAllPlayers(
           new Visitor<Player>() {
             @Override
             public void visit(Player player) {
               PacketSendUtility.sendPacket(player, new SM_SYSTEM_MESSAGE(1401827));
             }
           });
 }
  @Override
  protected void runImpl() {
    Player player = getConnection().getActivePlayer();
    Pet pet = player.getPet();

    if (pet == null) {
      return;
    }

    // sometimes client is crazy enough to send -2.4457384E7 as z coordinate
    // TODO (check retail) either its client bug or packet problem somewhere
    // reproducible by flying randomly and falling from long height with fly resume
    if (x1 < 0 || y1 < 0 || z1 < 0) {
      return;
    }
    // log.info("CM_PET_EMOTE emote {}, unk1 {}, unk2 {}", new Object[] { emoteId, unk1, unk2 });
    // switch (emote) {

    if (emote == PetEmote.ALARM) {
      PacketSendUtility.broadcastPacket(player, new SM_PET_EMOTE(pet, emote), true);
    } else if (emote == PetEmote.MOVE_STOP) {
      World.getInstance().updatePosition(pet, x1, y1, z1, h);
      PacketSendUtility.broadcastPacket(player, new SM_PET_EMOTE(pet, emote, x1, y1, z1, h), true);
    } else if (emote == PetEmote.MOVETO) {
      World.getInstance().updatePosition(pet, x1, y1, z1, h);
      pet.getMoveController().setNewDirection(x2, y2, z2, h);
      PacketSendUtility.broadcastPacket(
          player, new SM_PET_EMOTE(pet, emote, x1, y1, z2, x2, y2, z2, h), true);
    } else if (emote == PetEmote.FLY) {
      PacketSendUtility.broadcastPacket(
          player, new SM_PET_EMOTE(pet, emote, emotionId, unk2), true);
    } else if (emote == PetEmote.MOVE_STOP) {
      World.getInstance().updatePosition(pet, x1, y1, z1, h);
      PacketSendUtility.broadcastPacket(player, new SM_PET_EMOTE(pet, emote, x1, y1, z1, h), true);
    } else {
      if (emotionId > 0) {
        PacketSendUtility.sendPacket(player, new SM_PET_EMOTE(pet, emote, emotionId, unk2));
      } else {
        PacketSendUtility.broadcastPacket(player, new SM_PET_EMOTE(pet, emote, 0, unk2), true);
      }
    }
  }
Ejemplo n.º 8
0
  /**
   * This method is used for creating new players
   *
   * @param playerCommonData
   * @param playerAppearance
   * @return Player
   */
  public static Player newPlayer(
      PlayerCommonData playerCommonData, PlayerAppearance playerAppearance) {
    PlayerInitialData playerInitialData = DataManager.PLAYER_INITIAL_DATA;
    LocationData ld = playerInitialData.getSpawnLocation(playerCommonData.getRace());

    WorldPosition position =
        World.getInstance()
            .createPosition(ld.getMapId(), ld.getX(), ld.getY(), ld.getZ(), ld.getHeading());
    playerCommonData.setPosition(position);

    Player newPlayer = new Player(new PlayerController(), playerCommonData, playerAppearance);

    // Starting skills
    SkillLearnService.addNewSkills(newPlayer, true);

    // Starting items
    PlayerCreationData playerCreationData =
        playerInitialData.getPlayerCreationData(playerCommonData.getPlayerClass());

    List<ItemType> items = playerCreationData.getItems();

    Storage playerInventory = new Storage(StorageType.CUBE);
    Storage regularWarehouse = new Storage(StorageType.REGULAR_WAREHOUSE);
    Storage accountWarehouse = new Storage(StorageType.ACCOUNT_WAREHOUSE);

    Equipment equipment = new Equipment(newPlayer);
    newPlayer.setStorage(playerInventory, StorageType.CUBE);
    newPlayer.setStorage(regularWarehouse, StorageType.REGULAR_WAREHOUSE);
    newPlayer.setStorage(accountWarehouse, StorageType.ACCOUNT_WAREHOUSE);
    newPlayer.setEquipment(equipment);
    newPlayer.setMailbox(new Mailbox());

    for (ItemType itemType : items) {
      int itemId = itemType.getTemplate().getTemplateId();
      Item item = ItemService.newItem(itemId, itemType.getCount());
      if (item == null) continue;

      // When creating new player - all equipment that has slot values will be equipped
      // Make sure you will not put into xml file more items than possible to equip.
      ItemTemplate itemTemplate = item.getItemTemplate();
      item.setOwnerId(newPlayer.getObjectId());
      if (itemTemplate.isArmor() || itemTemplate.isWeapon()) {
        item.setEquipped(true);
        List<ItemSlot> itemSlots = ItemSlot.getSlotsFor(itemTemplate.getItemSlot());
        item.setEquipmentSlot(itemSlots.get(0).getSlotIdMask());
        equipment.onLoadHandler(item);
      } else ItemService.onLoadHandler(newPlayer, newPlayer.getInventory(), item);
    }
    equipment.onLoadApplyEquipmentStats();
    /** Mark inventory and equipment as UPDATE_REQUIRED to be saved during character creation */
    playerInventory.setPersistentState(PersistentState.UPDATE_REQUIRED);
    equipment.setPersistentState(PersistentState.UPDATE_REQUIRED);
    return newPlayer;
  }
  public static void checkConnection(Player player) {
    count = 0;
    for (Player p : World.getInstance().getAllPlayers()) {
      if (p.getClientConnection().getIP().equals(player.getClientConnection().getIP())) {
        count++;
      }
    }

    if (count > DualBoxConfig.DUALBOX_ALLOWED_CHARS
        && !isInWhiteList(player.getClientConnection().getIP())) {
      player.getClientConnection().close(new SM_QUIT_RESPONSE(), true);
    }
  }
 public void startIronWallRegistration() {
   registerAvailable = true;
   startUregisterIronWallTask();
   Iterator<Player> iter = World.getInstance().getPlayersIterator();
   while (iter.hasNext()) {
     Player player = iter.next();
     if (player.getLevel() > minlevel && player.getLevel() < maxlevel) {
       PacketSendUtility.sendPacket(
           player, new SM_AUTO_GROUP(maskId, SM_AUTO_GROUP.wnd_EntryIcon));
       // You may participate in the Iron Wall Warfront.
       PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_MSG_INSTANCE_OPEN_BASTION_WAR);
     }
   }
 }
Ejemplo n.º 11
0
 private void spawn(Player player) {
   int mobToSpawn = mobs.get(Rnd.get(0, 3));
   float x = 0;
   float y = 0;
   final float z = 124.942f;
   switch (mobToSpawn) {
     case 218760:
       {
         x = 250.081f;
         y = 268.308f;
         break;
       }
     case 218762:
       {
         x = 273.354f;
         y = 244.489f;
         break;
       }
     case 218761:
       {
         x = 272.994f;
         y = 244.674f;
         break;
       }
     case 218763:
       {
         x = 250.800f;
         y = 222.782f;
         break;
       }
   }
   Npc spawn =
       (Npc)
           QuestService.spawnQuestNpc(
               300330000, player.getInstanceId(), mobToSpawn, x, y, z, (byte) 0);
   Collection<Npc> allNpcs = World.getInstance().getNpcs();
   Npc target = null;
   for (Npc npc : allNpcs) {
     if (npc.getNpcId() == 730493) {
       target = npc;
     }
   }
   if (target != null) {
     spawn.getAggroList().addHate(target, 1);
   }
 }
  /**
   * @param worldId
   * @param destroyTime
   * @return
   */
  public static synchronized WorldMapInstance getNextAvailableInstance(int worldId) {
    WorldMap map = World.getInstance().getWorldMap(worldId);

    if (!map.isInstanceType())
      throw new UnsupportedOperationException(
          "Invalid call for next available instance  of " + worldId);

    int nextInstanceId = map.getNextInstanceId();

    log.info("Creating new instance: " + worldId + " " + nextInstanceId);

    WorldMapInstance worldMapInstance = new WorldMapInstance(map, nextInstanceId);
    startInstanceChecker(worldMapInstance);
    map.addInstance(nextInstanceId, worldMapInstance);
    SpawnEngine.getInstance().spawnInstance(worldId, worldMapInstance.getInstanceId());

    return worldMapInstance;
  }
Ejemplo n.º 13
0
  @Override
  public void executeCommand(Player admin, String[] params) {
    if (admin.getAccessLevel() < AdminConfig.COMMAND_KINAH) {
      PacketSendUtility.sendMessage(admin, "You dont have enough rights to execute this command.");
      return;
    }

    if (params == null || params.length < 1 || params.length > 2) {
      PacketSendUtility.sendMessage(admin, "syntax //kinah [player] <quantity>");
      return;
    }

    long kinahCount;
    Player receiver;

    if (params.length == 1) {
      receiver = admin;
      try {
        kinahCount = Integer.parseInt(params[0]);
      } catch (NumberFormatException e) {
        PacketSendUtility.sendMessage(admin, "Kinah value must be an integer.");
        return;
      }
    } else {
      receiver = World.getInstance().findPlayer(Util.convertName(params[0]));

      if (receiver == null) {
        PacketSendUtility.sendMessage(admin, "Could not find a player by that name.");
        return;
      }

      try {
        kinahCount = Integer.parseInt(params[1]);
      } catch (NumberFormatException e) {
        PacketSendUtility.sendMessage(admin, "Kinah value must be an integer.");
        return;
      }
    }

    ItemService.increaseKinah(receiver, kinahCount);
    PacketSendUtility.sendMessage(admin, "Kinah given successfully.");
    PacketSendUtility.sendMessage(receiver, "An admin gives you some kinah.");
  }
  /**
   * @param player
   * @param portalTemplates
   */
  private static void moveToEntryPoint(
      Player player, PortalTemplate portalTemplate, boolean useTeleport) {
    EntryPoint entryPoint = null;
    List<EntryPoint> entryPoints = portalTemplate.getEntryPoint();

    for (EntryPoint point : entryPoints) {
      if (point.getRace() == null || point.getRace().equals(player.getCommonData().getRace())) {
        entryPoint = point;
        break;
      }
    }

    if (entryPoint == null) {
      log.warn(
          "Entry point not found for "
              + player.getCommonData().getRace()
              + " "
              + player.getWorldId());
      return;
    }

    if (useTeleport) {
      TeleportService.teleportTo(
          player,
          entryPoint.getMapId(),
          1,
          entryPoint.getX(),
          entryPoint.getY(),
          entryPoint.getZ(),
          0);
    } else {
      World.getInstance()
          .setPosition(
              player,
              entryPoint.getMapId(),
              1,
              entryPoint.getX(),
              entryPoint.getY(),
              entryPoint.getZ(),
              player.getHeading());
    }
  }
Ejemplo n.º 15
0
  @Override
  public void execute(Player admin, String... params) {
    if (params == null || params.length < 1) {
      PacketSendUtility.sendMessage(admin, "Syntax: //ungag <player>");
      return;
    }

    String name = Util.convertName(params[0]);
    Player player = World.getInstance().findPlayer(name);
    if (player == null) {
      PacketSendUtility.sendMessage(admin, "Player " + name + " was not found!");
      PacketSendUtility.sendMessage(admin, "Syntax: //ungag <player>");
      return;
    }

    player.setGagged(false);
    Future<?> task = player.getController().getTask(TaskId.GAG);
    if (task != null) player.getController().cancelTask(TaskId.GAG);
    PacketSendUtility.sendMessage(player, "You have been ungagged");

    PacketSendUtility.sendMessage(admin, "Player " + name + " ungagged");
  }
  /** @param player */
  public static void onPlayerLogin(Player player) {
    int worldId = player.getWorldId();

    WorldMapTemplate worldTemplate = DataManager.WORLD_MAPS_DATA.getTemplate(worldId);
    if (worldTemplate.isInstance()) {
      PortalTemplate portalTemplate =
          DataManager.PORTAL_DATA.getInstancePortalTemplate(
              worldId, player.getCommonData().getRace());

      if (portalTemplate == null) {
        log.error("No portal template found for " + worldId);
        return;
      }

      int lookupId = player.getObjectId();
      if (portalTemplate.isGroup() && player.getPlayerGroup() != null) {
        lookupId = player.getPlayerGroup().getGroupId();
      }

      WorldMapInstance registeredInstance = getRegisteredInstance(worldId, lookupId);
      if (registeredInstance != null) {
        World.getInstance()
            .setPosition(
                player,
                worldId,
                registeredInstance.getInstanceId(),
                player.getX(),
                player.getY(),
                player.getZ(),
                player.getHeading());
        return;
      }

      moveToEntryPoint(player, portalTemplate, false);
    }
  }
Ejemplo n.º 17
0
  private void move() {
    /** Demo npc skills - prevent movement while casting */
    if (!owner.canPerformMove() || owner.isCasting()) {
      if (!isStopped) {
        isStopped = true;
        owner.getController().stopMoving();
      }
      return;
    }

    VisibleObject target = owner.getTarget();

    if (isFollowTarget && target != null) {
      setNewDirection(target.getX(), target.getY(), target.getZ());
    }

    float ownerX = owner.getX();
    float ownerY = owner.getY();
    float ownerZ = owner.getZ();

    double dist = MathUtil.getDistance(ownerX, ownerY, ownerZ, targetX, targetY, targetZ);
    if (dist > this.distance) {
      isStopped = false;

      float x2;
      float y2;
      float z2;
      float mod = 1;
      if (dist < speed * 0.5) {
        x2 = (targetX - ownerX);
        y2 = (targetY - ownerY);
        z2 = (targetZ - ownerZ);
      } else {
        x2 = (float) (((targetX - ownerX) / dist) * speed * 0.5);
        y2 = (float) (((targetY - ownerY) / dist) * speed * 0.5);
        z2 = (float) (((targetZ - ownerZ) / dist) * speed * 0.5);
        mod = 0.5f;
      }

      byte heading2 = (byte) (Math.toDegrees(Math.atan2(y2, x2)) / 3);

      if (directionChanged) {
        PacketSendUtility.broadcastPacket(
            owner,
            new SM_MOVE(
                owner.getObjectId(),
                ownerX,
                ownerY,
                ownerZ,
                (x2 / mod),
                (y2 / mod),
                (z2 / mod),
                heading2,
                MovementType.MOVEMENT_START_KEYBOARD));
        directionChanged = false;
      }

      moveCounter++;
      World.getInstance()
          .updatePosition(
              owner, ownerX + x2, ownerY + y2, ownerZ + z2, heading2, moveCounter % 5 == 0);
    } else {
      if (!isStopped) {
        isStopped = true;
        owner.getController().stopMoving();
      }
    }
  }
Ejemplo n.º 18
0
  @Override
  public void execute(Player player, String... params) {
    if ((params.length < 0) || (params.length < 1)) {
      onFail(player, null);
      return;
    }
    int itemId = 0;
    long itemCount = 1;
    Player receiver;

    try {
      String item = params[0];
      // Some item links have space before Id
      if (item.equals("[item:")) {
        item = params[1];
        Pattern id = Pattern.compile("(\\d{9})");
        Matcher result = id.matcher(item);
        if (result.find()) itemId = Integer.parseInt(result.group(1));

        if (params.length == 3) itemCount = Long.parseLong(params[2]);
      } else {
        Pattern id = Pattern.compile("\\[item:(\\d{9})");
        Matcher result = id.matcher(item);

        if (result.find()) itemId = Integer.parseInt(result.group(1));
        else itemId = Integer.parseInt(params[0]);

        if (params.length == 2) itemCount = Long.parseLong(params[1]);
      }
      receiver = player;
    } catch (NumberFormatException e) {
      receiver = World.getInstance().findPlayer(Util.convertName(params[0]));
      if (receiver == null) {
        PacketSendUtility.sendMessage(player, "Could not find a player by that name.");
        return;
      }

      try {
        String item = params[1];
        // Some item links have space before Id
        if (item.equals("[item:")) {
          item = params[2];
          Pattern id = Pattern.compile("(\\d{9})");
          Matcher result = id.matcher(item);
          if (result.find()) itemId = Integer.parseInt(result.group(1));

          if (params.length == 4) itemCount = Long.parseLong(params[3]);
        } else {
          Pattern id = Pattern.compile("\\[item:(\\d{9})");
          Matcher result = id.matcher(item);

          if (result.find()) itemId = Integer.parseInt(result.group(1));
          else itemId = Integer.parseInt(params[1]);

          if (params.length == 3) itemCount = Long.parseLong(params[2]);
        }
      } catch (NumberFormatException ex) {
        PacketSendUtility.sendMessage(player, "You must give number to itemid.");
        return;
      } catch (Exception ex2) {
        PacketSendUtility.sendMessage(player, "Occurs an error.");
        return;
      }
    }

    if (DataManager.ITEM_DATA.getItemTemplate(itemId) == null) {
      PacketSendUtility.sendMessage(player, "Item id is incorrect: " + itemId);
      return;
    }

    if (!AdminService.getInstance().canOperate(player, receiver, itemId, "command //add")) return;

    long count = ItemService.addItem(receiver, itemId, itemCount);

    if (count == 0) {
      if (player != receiver) {
        PacketSendUtility.sendMessage(
            player,
            "You successfully gave "
                + itemCount
                + " x [item:"
                + itemId
                + "] to "
                + receiver.getName()
                + ".");
        PacketSendUtility.sendMessage(
            receiver,
            "You successfully received "
                + itemCount
                + " x [item:"
                + itemId
                + "] from "
                + player.getName()
                + ".");
      } else
        PacketSendUtility.sendMessage(
            player, "You successfully received " + itemCount + " x [item:" + itemId + "]");
    } else {
      PacketSendUtility.sendMessage(player, "Item couldn't be added");
    }
  }
Ejemplo n.º 19
0
  public void executeCommand(Player admin, String[] params) {
    if (params == null || params.length < 1) {
      PacketSendUtility.sendMessage(admin, "syntax //bind < all | elyos | asmos >");
      return;
    }

    if (params[0].equals("all")) {
      if (admin.getAccessLevel() < AdminConfig.COMMAND_MOVETOMEALLALL) {
        PacketSendUtility.sendMessage(admin, "You dont have enough rights to execute this command");
        return;
      }

      World world = admin.getActiveRegion().getWorld();
      Iterator<Player> players = world.getPlayersIterator();
      while (players.hasNext()) {
        Player p = players.next();
        if (!p.equals(admin)) {
          teleportService.teleportTo(
              p,
              admin.getWorldId(),
              admin.getInstanceId(),
              admin.getX(),
              admin.getY(),
              admin.getZ(),
              admin.getHeading(),
              5);
          PacketSendUtility.sendPacket(p, new SM_PLAYER_SPAWN(p));

          PacketSendUtility.sendMessage(admin, "Player " + p.getName() + " teleported.");
          PacketSendUtility.sendMessage(p, "Vous avez ete teleporte par " + admin.getName() + ".");
        }
      }
    }

    if (params[0].equals("elyos")) {
      if (admin.getAccessLevel() < AdminConfig.COMMAND_MOVETOMEALLELYOS) {
        PacketSendUtility.sendMessage(admin, "You dont have enough rights to execute this command");
        return;
      }

      World world = admin.getActiveRegion().getWorld();
      Iterator<Player> players = world.getPlayersIterator();
      while (players.hasNext()) {
        Player p = players.next();
        if (!p.equals(admin)) {
          if (p.getCommonData().getRace() == Race.ELYOS) {
            teleportService.teleportTo(
                p,
                admin.getWorldId(),
                admin.getInstanceId(),
                admin.getX(),
                admin.getY(),
                admin.getZ(),
                admin.getHeading(),
                5);
            PacketSendUtility.sendPacket(p, new SM_PLAYER_SPAWN(p));

            PacketSendUtility.sendMessage(admin, "Player " + p.getName() + " teleported.");
            PacketSendUtility.sendMessage(
                p, "Vous avez ete teleporte par " + admin.getName() + ".");
          }
        }
      }
    }

    if (params[0].equals("asmos")) {
      if (admin.getAccessLevel() < AdminConfig.COMMAND_MOVETOMEALLASMOS) {
        PacketSendUtility.sendMessage(admin, "You dont have enough rights to execute this command");
        return;
      }

      World world = admin.getActiveRegion().getWorld();
      Iterator<Player> players = world.getPlayersIterator();
      while (players.hasNext()) {
        Player p = players.next();
        if (!p.equals(admin)) {
          if (p.getCommonData().getRace() == Race.ASMODIANS) {
            teleportService.teleportTo(
                p,
                admin.getWorldId(),
                admin.getInstanceId(),
                admin.getX(),
                admin.getY(),
                admin.getZ(),
                admin.getHeading(),
                5);
            PacketSendUtility.sendPacket(p, new SM_PLAYER_SPAWN(p));

            PacketSendUtility.sendMessage(admin, "Player " + p.getName() + " teleported.");
            PacketSendUtility.sendMessage(
                p, "Vous avez ete teleporte par " + admin.getName() + ".");
          }
        }
      }
    }
  }
  /** {@inheritDoc} */
  @Override
  protected void runImpl() {
    AionConnection client = getConnection();
    Account account = client.getAccount();
    PlayerAccountData playerAccData = client.getAccount().getPlayerAccountData(objectId);

    if (playerAccData == null) {
      // Somebody wanted to login on character that is not at his account
      return;
    }

    Player player = PlayerService.getPlayer(objectId, account);

    if (player != null && client.setActivePlayer(player)) {
      player.setClientConnection(client);
      /*
       * Store player into World.
       */
      World.getInstance().storeObject(player);

      sendPacket(new SM_SKILL_LIST(player));
      StigmaService.onPlayerLogin(player);

      if (player.getSkillCoolDowns() != null)
        sendPacket(new SM_SKILL_COOLDOWN(player.getSkillCoolDowns()));

      if (player.getItemCoolDowns() != null)
        sendPacket(new SM_ITEM_COOLDOWN(player.getItemCoolDowns()));

      sendPacket(new SM_QUEST_LIST(player));
      sendPacket(new SM_RECIPE_LIST(player.getRecipeList().getRecipeList()));

      /*
       * Needed
       */
      sendPacket(new SM_ENTER_WORLD_CHECK());

      byte[] uiSettings = player.getPlayerSettings().getUiSettings();
      byte[] shortcuts = player.getPlayerSettings().getShortcuts();

      if (uiSettings != null) sendPacket(new SM_UI_SETTINGS(uiSettings, 0));

      if (shortcuts != null) sendPacket(new SM_UI_SETTINGS(shortcuts, 1));

      // Cubesize limit set in inventory.
      int cubeSize = player.getCubeSize();
      player.getInventory().setLimit(27 + cubeSize * 9);

      // items
      Storage inventory = player.getInventory();
      List<Item> equipedItems = player.getEquipment().getEquippedItems();
      if (equipedItems.size() != 0) {
        sendPacket(new SM_INVENTORY_INFO(player.getEquipment().getEquippedItems(), cubeSize));
      }

      List<Item> unequipedItems = inventory.getAllItems();
      int itemsSize = unequipedItems.size();

      if (itemsSize != 0) {
        int index = 0;
        while (index + 10 < itemsSize) {
          sendPacket(new SM_INVENTORY_INFO(unequipedItems.subList(index, index + 10), cubeSize));
          index += 10;
        }
        sendPacket(new SM_INVENTORY_INFO(unequipedItems.subList(index, itemsSize), cubeSize));
      }

      sendPacket(new SM_INVENTORY_INFO());

      PlayerService.playerLoggedIn(player);

      sendPacket(new SM_STATS_INFO(player));
      sendPacket(new SM_CUBE_UPDATE(player, 6));

      KiskService.onLogin(player);
      TeleportService.sendSetBindPoint(player);

      sendPacket(new SM_MACRO_LIST(player));
      sendPacket(new SM_GAME_TIME());
      player.getController().updateNearbyQuests();

      sendPacket(new SM_TITLE_LIST(player));
      sendPacket(new SM_CHANNEL_INFO(player.getPosition()));
      sendPacket(new SM_PLAYER_SPAWN(player));
      sendPacket(new SM_EMOTION_LIST());
      sendPacket(new SM_INFLUENCE_RATIO());
      sendPacket(new SM_PRICES(player.getPrices()));
      sendPacket(new SM_PLAYER_ID(player));
      sendPacket(new SM_ABYSS_RANK(player.getAbyssRank()));

      sendPacket(
          new SM_MESSAGE(
              0,
              null,
              "Welcome to "
                  + GSConfig.SERVER_NAME
                  + " server\nPowered by aion-unique software\ndeveloped by www.aion-unique.org team.\nCopyright 2010",
              ChatType.ANNOUNCEMENTS));

      if (player.isInPrison()) PunishmentService.updatePrisonStatus(player);

      if (player.isLegionMember()) LegionService.getInstance().onLogin(player);

      if (player.isInGroup()) GroupService.getInstance().onLogin(player);

      player.setRates(Rates.getRatesFor(client.getAccount().getMembership()));

      ClassChangeService.showClassChangeDialog(player);

      /** Notify mail service to load all mails */
      MailService.getInstance().onPlayerLogin(player);
      /** Schedule periodic saving of this player */
      PeriodicSaveService.getInstance().onPlayerLogin(player);
      /** Notify player if have broker settled items */
      BrokerService.getInstance().onPlayerLogin(player);
      /** Start initializing chat connection(/1, /2, /3, /4 channels) */
      if (!GSConfig.DISABLE_CHAT_SERVER) ChatService.onPlayerLogin(player);
    } else {
      // TODO this is an client error - inform client.
    }
  }
Ejemplo n.º 21
0
  @Override
  public void executeCommand(Player admin, String[] params) {
    if (admin.getAccessLevel() < AdminConfig.COMMAND_POWERUP) {
      PacketSendUtility.sendMessage(admin, "You dont have enough rights to execute this command");
      return;
    }
    int index = 2;
    int i = 0;
    Player player = null;
    if (params.length != 0) {
      if ("help".startsWith(params[i])) {
        PacketSendUtility.sendMessage(admin, "0 to return to normal state");
        PacketSendUtility.sendMessage(admin, "//powerup <Multiplier = 2>");
        PacketSendUtility.sendMessage(
            admin,
            "Syntax:  //powerup [playerName] [Multiplier = 2]\n"
                + "  This command multiplies your actual power to the number given.\n"
                + "  Using 0 as the Multiplier resets the power to normal.\n"
                + "  Notice: You can ommit parameters between [], especially playerName.\n"
                + "  Target: Named player, then targeted player, only then self.\n"
                + "  Default Value: Multiplier is 2.");
        return;
      }
      player = World.getInstance().findPlayer(Util.convertName(params[i]));
      if (player == null) {
        VisibleObject target = admin.getTarget();
        if (target instanceof Player) player = (Player) target;
        else player = admin;
      } else i++;
      try {
        index = Integer.parseInt(params[i]);
      } catch (NumberFormatException ex) {
        PacketSendUtility.sendMessage(admin, "Wrong input use //powerup help");
        return;
      } catch (Exception ex2) {
        PacketSendUtility.sendMessage(admin, "Occurs an error.");
        return;
      }
    }
    if (index == 0) {
      player.getGameStats().recomputeStats();
      player.getLifeStats().increaseHp(TYPE.HP, admin.getLifeStats().getMaxHp() + 1);
      player.getLifeStats().increaseMp(TYPE.MP, admin.getLifeStats().getMaxMp() + 1);
      PacketSendUtility.sendPacket(player, new SM_STATS_INFO(admin));
      if (player == admin) PacketSendUtility.sendMessage(player, "You are now normal again.");
      else {
        PacketSendUtility.sendMessage(
            admin, "Player " + player.getName() + " is now normal again.");
        PacketSendUtility.sendMessage(
            player, "Admin " + admin.getName() + " made you normal again.");
      }
      return;
    }
    player.getGameStats().setStat(StatEnum.MAXMP, admin.getLifeStats().getMaxHp() * index);
    player.getGameStats().setStat(StatEnum.MAXHP, admin.getLifeStats().getMaxMp() * index);

    player
        .getGameStats()
        .setStat(StatEnum.BLOCK, admin.getGameStats().getStatBonus(StatEnum.BLOCK) * index);
    player
        .getGameStats()
        .setStat(StatEnum.EVASION, admin.getGameStats().getStatBonus(StatEnum.EVASION) * index);
    player
        .getGameStats()
        .setStat(StatEnum.HEALTH, admin.getGameStats().getStatBonus(StatEnum.HEALTH) * index);
    player
        .getGameStats()
        .setStat(StatEnum.ACCURACY, admin.getGameStats().getStatBonus(StatEnum.ACCURACY) * index);
    player
        .getGameStats()
        .setStat(StatEnum.PARRY, admin.getGameStats().getStatBonus(StatEnum.PARRY) * index);

    player
        .getGameStats()
        .setStat(
            StatEnum.MAIN_HAND_ACCURACY,
            admin.getGameStats().getStatBonus(StatEnum.MAIN_HAND_ACCURACY) * index);
    player
        .getGameStats()
        .setStat(
            StatEnum.MAIN_HAND_CRITICAL,
            admin.getGameStats().getStatBonus(StatEnum.MAIN_HAND_CRITICAL) * index);
    player
        .getGameStats()
        .setStat(
            StatEnum.MAIN_HAND_POWER,
            admin.getGameStats().getStatBonus(StatEnum.MAIN_HAND_POWER) * index);
    player
        .getGameStats()
        .setStat(
            StatEnum.MAIN_HAND_ATTACK_SPEED,
            admin.getGameStats().getStatBonus(StatEnum.MAIN_HAND_POWER) * index);
    player
        .getGameStats()
        .setStat(
            StatEnum.OFF_HAND_ACCURACY,
            admin.getGameStats().getStatBonus(StatEnum.OFF_HAND_ACCURACY) * index);
    player
        .getGameStats()
        .setStat(
            StatEnum.OFF_HAND_CRITICAL,
            admin.getGameStats().getStatBonus(StatEnum.OFF_HAND_CRITICAL) * index);
    player
        .getGameStats()
        .setStat(
            StatEnum.OFF_HAND_POWER,
            admin.getGameStats().getStatBonus(StatEnum.OFF_HAND_POWER) * index);
    player
        .getGameStats()
        .setStat(
            StatEnum.OFF_HAND_ATTACK_SPEED,
            admin.getGameStats().getStatBonus(StatEnum.OFF_HAND_ATTACK_SPEED) * index);

    player
        .getGameStats()
        .setStat(
            StatEnum.MAGICAL_ATTACK,
            admin.getGameStats().getStatBonus(StatEnum.MAGICAL_ATTACK) * index);
    player
        .getGameStats()
        .setStat(
            StatEnum.MAGICAL_ACCURACY,
            admin.getGameStats().getStatBonus(StatEnum.MAGICAL_ACCURACY) * index);
    player
        .getGameStats()
        .setStat(
            StatEnum.MAGICAL_CRITICAL,
            admin.getGameStats().getStatBonus(StatEnum.MAGICAL_CRITICAL) * index);
    player
        .getGameStats()
        .setStat(
            StatEnum.MAGICAL_RESIST,
            admin.getGameStats().getStatBonus(StatEnum.MAGICAL_RESIST) * index);
    player
        .getGameStats()
        .setStat(
            StatEnum.BOOST_MAGICAL_SKILL,
            admin.getGameStats().getStatBonus(StatEnum.BOOST_MAGICAL_SKILL) * index * 15);

    player
        .getGameStats()
        .setStat(StatEnum.REGEN_MP, admin.getGameStats().getStatBonus(StatEnum.REGEN_MP) * index);
    player
        .getGameStats()
        .setStat(StatEnum.REGEN_HP, admin.getGameStats().getStatBonus(StatEnum.REGEN_HP) * index);

    player.getLifeStats().increaseHp(TYPE.HP, admin.getLifeStats().getMaxHp() + 1);
    player.getLifeStats().increaseMp(TYPE.MP, admin.getLifeStats().getMaxMp() + 1);
    PacketSendUtility.sendPacket(player, new SM_STATS_INFO(admin));
    if (player == admin)
      PacketSendUtility.sendMessage(
          player, "You are now " + index + " times more powerfull than before.");
    else {
      PacketSendUtility.sendMessage(
          admin,
          "Player " + player.getName() + " is now " + index + " times more powerfull than before.");
      PacketSendUtility.sendMessage(
          player,
          "Admin " + admin.getName() + " made you " + index + " times more powerfull than before.");
    }
  }
 /**
  * @param worldId
  * @param instanceId
  * @return
  */
 public static boolean isInstanceExist(int worldId, int instanceId) {
   return World.getInstance().getWorldMap(worldId).getWorldMapInstanceById(instanceId) != null;
 }
Ejemplo n.º 23
0
 private void onDie() {
   RespawnTaskManager.getInstance().addRespawnTask(this);
   World.getInstance().despawn(this);
 }