@Override
 public L1NpcHtml executeWithAmount(String actionName, L1PcInstance pc, L1Object obj, int amount) {
   L1NpcInstance npc = (L1NpcInstance) obj;
   L1NpcHtml result = null;
   if (makeItems(pc, npc.getNpcTemplate().get_name(), amount)) {
     if (_actionOnSucceed != null) {
       result = _actionOnSucceed.execute(actionName, pc, obj, new byte[0]);
     }
   } else {
     if (_actionOnFail != null) {
       result = _actionOnFail.execute(actionName, pc, obj, new byte[0]);
     }
   }
   return result == null ? L1NpcHtml.HTML_CLOSE : result;
 }
Ejemplo n.º 2
0
  public void fillSpawnTable(int mapid, int type) {
    Connection con = null;
    PreparedStatement pstm = null;
    ResultSet rs = null;
    try {
      con = L1DatabaseFactory.getInstance().getConnection();
      pstm = con.prepareStatement("SELECT * FROM spawnlist_antaras");
      rs = pstm.executeQuery();
      while (rs.next()) {
        if (type != rs.getInt("type")) continue;

        L1Npc l1npc = NpcTable.getInstance().getTemplate(rs.getInt("npc_id"));
        if (l1npc != null) {
          L1NpcInstance field;
          try {
            field = NpcTable.getInstance().newNpcInstance(rs.getInt("npc_id"));
            field.setId(ObjectIdFactory.getInstance().nextId());
            field.setX(rs.getInt("locx"));
            field.setY(rs.getInt("locy"));
            field.setMap((short) mapid);
            field.setHomeX(field.getX());
            field.setHomeY(field.getY());
            field.getMoveState().setHeading(0);
            field.setLightSize(l1npc.getLightSize());
            field.getLight().turnOnOffLight();

            L1World.getInstance().storeObject(field);
            L1World.getInstance().addVisibleObject(field);
          } catch (Exception e) {
            _log.log(Level.SEVERE, "AntarasRaidSpawn.java error occurred", e);
          }
        }
      }
    } catch (SQLException e) {
      _log.log(Level.SEVERE, "AntarasRaidSpawn.java error occurred", e);
    } catch (SecurityException e) {
      _log.log(Level.SEVERE, "AntarasRaidSpawn.java error occurred", e);
    } catch (IllegalArgumentException e) {
      _log.log(Level.SEVERE, "AntarasRaidSpawn.java error occurred", e);
    } finally {
      SQLUtil.close(rs);
      SQLUtil.close(pstm);
      SQLUtil.close(con);
    }
  }