示例#1
0
  @Override
  public boolean useAdminCommand(String command, L2PcInstance activeChar) {
    int id;
    int count = 1;
    final String[] data = command.split(" ");
    try {
      id = Integer.parseInt(data[1]);
      if (data.length > 2) {
        count = Integer.parseInt(data[2]);
      }
    } catch (NumberFormatException nfe) {
      activeChar.sendMessage("Incorrect format for command 'summon'");
      return false;
    }

    String subCommand;
    if (id < 1000000) {
      subCommand = "admin_create_item";
      if (!AdminData.getInstance().hasAccess(subCommand, activeChar.getAccessLevel())) {
        activeChar.sendMessage("You don't have the access right to use this command!");
        _log.warning(
            "Character "
                + activeChar.getName()
                + " tryed to use admin command "
                + subCommand
                + ", but have no access to it!");
        return false;
      }
      final IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler(subCommand);
      ach.useAdminCommand(subCommand + " " + id + " " + count, activeChar);
    } else {
      subCommand = "admin_spawn_once";
      if (!AdminData.getInstance().hasAccess(subCommand, activeChar.getAccessLevel())) {
        activeChar.sendMessage("You don't have the access right to use this command!");
        _log.warning(
            "Character "
                + activeChar.getName()
                + " tryed to use admin command "
                + subCommand
                + ", but have no access to it!");
        return false;
      }
      final IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler(subCommand);

      activeChar.sendMessage("This is only a temporary spawn.  The mob(s) will NOT respawn.");
      id -= 1000000;
      ach.useAdminCommand(subCommand + " " + id + " " + count, activeChar);
    }
    return true;
  }
  @Override
  public boolean action(L2PcInstance activeChar, L2Object target, boolean interact) {
    if (activeChar.getAccessLevel().isGm()) {
      activeChar.setTarget(target);
      final L2DoorInstance door = (L2DoorInstance) target;
      activeChar.sendPacket(new StaticObject(door, activeChar.isGM()));

      final NpcHtmlMessage html = new NpcHtmlMessage();
      html.setFile(activeChar.getHtmlPrefix(), "html/admin/doorinfo.htm");
      html.replace("%class%", target.getClass().getSimpleName());
      html.replace("%hp%", String.valueOf((int) door.getCurrentHp()));
      html.replace("%hpmax%", String.valueOf(door.getMaxHp()));
      html.replace("%objid%", String.valueOf(target.getObjectId()));
      html.replace("%doorid%", String.valueOf(door.getId()));

      html.replace("%minx%", String.valueOf(door.getX(0)));
      html.replace("%miny%", String.valueOf(door.getY(0)));
      html.replace("%minz%", String.valueOf(door.getZMin()));

      html.replace("%maxx%", String.valueOf(door.getX(2)));
      html.replace("%maxy%", String.valueOf(door.getY(2)));
      html.replace("%maxz%", String.valueOf(door.getZMax()));
      html.replace(
          "%unlock%",
          door.isOpenableBySkill()
              ? "<font color=00FF00>YES<font>"
              : "<font color=FF0000>NO</font>");

      activeChar.sendPacket(html);
    }
    return true;
  }