Package uk.co.oliwali.HawkEye.entry

Examples of uk.co.oliwali.HawkEye.entry.DataEntry


   * @return returns a {@link DataEntry}
   * @throws SQLException
   */
  public static DataEntry createEntryFromRes(ResultSet res) throws Exception {
    DataType type = DataType.fromId(res.getInt("action"));
    DataEntry entry = (DataEntry)type.getEntryClass().newInstance();
    entry.setPlayer(DataManager.getPlayer(res.getInt("player_id")));
    entry.setDate(res.getString("date"));
    entry.setDataId(res.getInt("data_id"));
    entry.setType(DataType.fromId(res.getInt("action")));
    entry.interpretSqlData(res.getString("data"));
    entry.setPlugin(res.getString("plugin"));
    entry.setWorld(DataManager.getWorld(res.getInt("world_id")));
    entry.setX(res.getInt("x"));
    entry.setY(res.getInt("y"));
    entry.setZ(res.getInt("z"));
    return entry;
  }
View Full Code Here


    JDCConnection conn = getConnection();
    PreparedStatement stmnt = null;
    try {
      while (!queue.isEmpty()) {

        DataEntry entry = queue.poll();

        //Sort out player IDs
        if (!dbPlayers.containsKey(entry.getPlayer()) && !addPlayer(entry.getPlayer())) {
          Util.debug("Player '" + entry.getPlayer() + "' not found, skipping entry");
          continue;
        }
        if (!dbWorlds.containsKey(entry.getWorld()) && !addWorld(entry.getWorld())) {
          Util.debug("World '" + entry.getWorld() + "' not found, skipping entry");
          continue;
        }

        //If player ID is unable to be found, continue
        if (entry.getPlayer() == null || dbPlayers.get(entry.getPlayer()) == null) {
          Util.debug("No player found, skipping entry");
          continue;
        }

        //If we are re-inserting we need to also insert the data ID
        if (entry.getDataId() > 0) {
          stmnt = conn.prepareStatement("INSERT into `" + Config.DbHawkEyeTable + "` (date, player_id, action, world_id, x, y, z, data, plugin, data_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
          stmnt.setInt(10, entry.getDataId());
        }
        else
          stmnt = conn.prepareStatement("INSERT into `" + Config.DbHawkEyeTable + "` (date, player_id, action, world_id, x, y, z, data, plugin) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);");
        stmnt.setString(1, entry.getDate());
        stmnt.setInt(2, dbPlayers.get(entry.getPlayer()));
        stmnt.setInt(3, entry.getType().getId());
        stmnt.setInt(4, dbWorlds.get(entry.getWorld()));
        stmnt.setDouble(5, entry.getX());
        stmnt.setDouble(6, entry.getY());
        stmnt.setDouble(7, entry.getZ());
        stmnt.setString(8, entry.getSqlData());
        stmnt.setString(9, entry.getPlugin());
        stmnt.executeUpdate();
        stmnt.close();
      }
      conn.close();
    } catch (Exception ex) {
View Full Code Here

  public static boolean addCustomEntry(JavaPlugin plugin, String action, Player player, Location loc, String data) {
    return addCustomEntry(plugin, action, player.getName(), loc, data);
  }
  public static boolean addCustomEntry(JavaPlugin plugin, String action, String player, Location loc, String data) {
    if (plugin == null || action == null || player == null || loc == null || data == null) return false;
    DataEntry entry = new DataEntry(player, DataType.OTHER, loc, action + "-" + data);
    return addEntry(plugin, entry);
  }
View Full Code Here

  @HawkEvent(dataType = DataType.CHAT)
  public void onPlayerChat(PlayerChatEvent event) {
    Player player = event.getPlayer();
    //Check for inventory close
    HawkEye.containerManager.checkInventoryClose(event.getPlayer());
    DataManager.addEntry(new DataEntry(player, DataType.CHAT, player.getLocation(), event.getMessage()));
  }
View Full Code Here

    Player player = event.getPlayer();
    //Check for inventory close
    HawkEye.containerManager.checkInventoryClose(player);
    //Check command filter
    if (Config.CommandFilter.contains(event.getMessage().split(" ")[0])) return;
    DataManager.addEntry(new DataEntry(player, DataType.COMMAND, player.getLocation(), event.getMessage()));
  }
View Full Code Here

  @HawkEvent(dataType = DataType.JOIN)
  public void onPlayerJoin(PlayerJoinEvent event) {
    Player player = event.getPlayer();
    Location loc  = player.getLocation();
    DataManager.addEntry(new DataEntry(player, DataType.JOIN, loc, Config.LogIpAddresses?player.getAddress().getAddress().getHostAddress().toString():""));
  }
View Full Code Here

    String ip = "";
    try {
      ip = player.getAddress().getAddress().getHostAddress().toString();
    } catch (Exception e) { }

    DataManager.addEntry(new DataEntry(player, DataType.QUIT, loc, Config.LogIpAddresses?ip:""));
  }
View Full Code Here

    //Check for inventory close
    HawkEye.containerManager.checkInventoryClose(event.getPlayer());
    Location from = event.getFrom();
    Location to   = event.getTo();
    if (Util.distance(from, to) > 5)
      DataManager.addEntry(new DataEntry(event.getPlayer(), DataType.TELEPORT, from, to.getWorld().getName() + ": " + to.getX() + ", " + to.getY() + ", " + to.getZ()));
  }
View Full Code Here

        case DISPENSER:
        case CHEST:
          if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
            //Call container manager for inventory open
            HawkEye.containerManager.checkInventoryOpen(player, block);
            DataManager.addEntry(new DataEntry(player, DataType.OPEN_CONTAINER, loc, Integer.toString(block.getTypeId())));
          }
          break;
        case WOODEN_DOOR:
        case TRAP_DOOR:
        case FENCE_GATE:
          DataManager.addEntry(new DataEntry(player, DataType.DOOR_INTERACT, loc, ""));
          break;
        case LEVER:
          DataManager.addEntry(new DataEntry(player, DataType.LEVER, loc, ""));
          break;
        case STONE_BUTTON:
          DataManager.addEntry(new DataEntry(player, DataType.STONE_BUTTON, loc, ""));
          break;
      }

      if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
        loc = block.getRelative(event.getBlockFace()).getLocation();
View Full Code Here

    String data = null;
    if (stack.getData() != null)
      data = stack.getAmount() + "x " + stack.getTypeId() + ":" + stack.getData().getData();
    else
      data = stack.getAmount() + "x " + stack.getTypeId();
    DataManager.addEntry(new DataEntry(player, DataType.ITEM_DROP, player.getLocation(), data));
  }
View Full Code Here

TOP

Related Classes of uk.co.oliwali.HawkEye.entry.DataEntry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.