Package uk.co.oliwali.HawkEye.entry

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


    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_PICKUP, player.getLocation(), data));
  }
View Full Code Here


      //Mob or PVP death
      if (victim.getLastDamageCause() instanceof EntityDamageByEntityEvent) {
        Entity damager = ((EntityDamageByEntityEvent)(victim.getLastDamageCause())).getDamager();
        if (damager instanceof Player) {
          if (!Config.isLogged(DataType.PVP_DEATH) && !Config.LogDeathDrops) return;
          DataManager.addEntry(new DataEntry(victim, DataType.PVP_DEATH, victim.getLocation(), Util.getEntityName(damager)));
        } else {
          if (!Config.isLogged(DataType.MOB_DEATH) && !Config.LogDeathDrops) return;
          DataManager.addEntry(new DataEntry(victim, DataType.MOB_DEATH, victim.getLocation(), Util.getEntityName(damager)));
        }
      //Other death
      } else {
        if (!Config.isLogged(DataType.OTHER_DEATH) && !Config.LogDeathDrops) return;
        EntityDamageEvent dEvent = victim.getLastDamageCause();
        String cause = dEvent == null?"Unknown":victim.getLastDamageCause().getCause().name();
        String[] words = cause.split("_");
        for (int i = 0; i < words.length; i++)
          words[i] = words[i].substring(0,1).toUpperCase() + words[i].substring(1).toLowerCase();
        cause = Util.join(Arrays.asList(words), " ");
        DataManager.addEntry(new DataEntry(victim, DataType.OTHER_DEATH, victim.getLocation(), cause));
      }

      //Log item drops
      if (Config.LogDeathDrops) {
        String data = null;
        for (ItemStack stack : event.getDrops()) {
          if (stack.getData() != null)
            data = stack.getAmount() + "x " + stack.getTypeId() + ":" + stack.getData().getData();
            else
              data = stack.getAmount() + "x " + stack.getTypeId();
            DataManager.addEntry(new DataEntry(victim, DataType.ITEM_DROP, victim.getLocation(), data));
        }
      }
    } else { //Mob Death
      if (!Config.isLogged(DataType.ENTITY_KILL)) return;

      if (entity.getLastDamageCause() instanceof EntityDamageByEntityEvent) {
        Entity damager = ((EntityDamageByEntityEvent) entity.getLastDamageCause()).getDamager();

        //Only interested in player kills
        if (!(damager instanceof Player)) return;

        Player player = (Player) damager;
        DataManager.addEntry(new DataEntry(player, DataType.ENTITY_KILL, entity.getLocation(), Util.getEntityName(entity)));
      }
    }
  }
View Full Code Here

  @HawkEvent(dataType = DataType.PAINTING_BREAK)
  public void onPaintingBreak(PaintingBreakEvent event) {
    if (event.getCause() != RemoveCause.ENTITY) return;
    PaintingBreakByEntityEvent e = (PaintingBreakByEntityEvent)event;
    if (e.getRemover() instanceof Player)
      DataManager.addEntry(new DataEntry((Player)e.getRemover(), DataType.PAINTING_BREAK, e.getPainting().getLocation(), ""));
  }
View Full Code Here

      DataManager.addEntry(new DataEntry((Player)e.getRemover(), DataType.PAINTING_BREAK, e.getPainting().getLocation(), ""));
  }

  @HawkEvent(dataType = DataType.PAINTING_PLACE)
  public void onPaintingPlace(PaintingPlaceEvent event) {
    DataManager.addEntry(new DataEntry(event.getPlayer(), DataType.PAINTING_PLACE, event.getPainting().getLocation(), ""));
  }
View Full Code Here

    //Start rollback process
    int i = 0;
    while (i < 200 && rebuildQueue.hasNext()) {
      i++;

      DataEntry entry = rebuildQueue.next();

      //If the action can't be rolled back, skip this entry
      if (entry.getType() == null || !entry.getType().canRollback())
        continue;

      //If the world doesn't exist, skip this entry
      World world = HawkEye.server.getWorld(entry.getWorld());
      if (world == null)
        continue;

      //Get some data from the entry
      Location loc = new Location(world, entry.getX(), entry.getY(), entry.getZ());
      Block block = world.getBlockAt(loc);

      //Rebuild it
      entry.rebuild(block);

      counter++;

    }
View Full Code Here

    //Start rollback process
    int i = 0;
    while (i < 200 && undoQueue.hasNext()) {

      //If undo doesn't exist
      DataEntry entry = undoQueue.next();
      if (entry.getUndoState() == null) continue;

      //Global undo
      if (undoType == RollbackType.GLOBAL) {
        entry.getUndoState().update(true);
        //Add back into database if delete data is on
        if (Config.DeleteDataOnRollback)
          DataManager.addEntry(entry);
      }

      //Player undo
      else {
        Player player = (Player)session.getSender();
        Block block = entry.getUndoState().getBlock();
        player.sendBlockChange(block.getLocation(), block.getType(), block.getData());
      }

      counter++;
View Full Code Here

    Util.sendMessage(session.getSender(), "&8--------------------- &7Page (&c" + page + "&7/&c" + maxPages + "&7) &8--------------------" + (maxPages < 9?"-":""));

    for (int i = (page-1) * maxLines; i < ((page-1) * maxLines) + maxLines; i++) {
      if (i == results.size())
        break;
      DataEntry entry = results.get(i);

      sendLine(session.getSender(), "&cid:" + entry.getDataId() + " &7" + entry.getDate().substring(5) + " &c" + entry.getPlayer() + " &7" + entry.getType().getConfigName());
      sendLine(session.getSender(), "   &cLoc: &7" + entry.getWorld() + "-" + entry.getX() + "," + entry.getY() + "," + entry.getZ() + " &cData: &7" + entry.getStringData());
    }
    Util.sendMessage(session.getSender(), "&8-----------------------------------------------------");
    return;
  }
View Full Code Here

    //Start rollback process
    int i = 0;
    while (i < 200 && rollbackQueue.hasNext()) {
      i++;

      DataEntry entry = rollbackQueue.next();

      //If the action can't be rolled back, skip this entry
      if (entry.getType() == null || !entry.getType().canRollback())
        continue;

      //If the world doesn't exist, skip this entry
      World world = HawkEye.server.getWorld(entry.getWorld());
      if (world == null)
        continue;

      //Get some data from the entry
      Location loc = new Location(world, entry.getX(), entry.getY(), entry.getZ());
      Block block = world.getBlockAt(loc);
      BlockState state = block.getState();

      //Attempt global rollback
      if (rollbackType == RollbackType.GLOBAL && entry.rollback(world.getBlockAt(loc))) {
        entry.setUndoState(state);
        undo.add(entry);
      }
      //Local rollback preview
      else if (rollbackType == RollbackType.LOCAL && entry.rollbackPlayer(block, (Player)session.getSender())) {
        entry.setUndoState(state);
        undo.add(entry);
      }

    }
View Full Code Here

  public boolean execute() {
    if (!Util.isInteger(args.get(0))) {
      Util.sendMessage(sender, "&cPlease supply a entry id!");
      return true;
    }
    DataEntry entry = DataManager.getEntry(Integer.parseInt(args.get(0)));
    if (entry == null) {
      Util.sendMessage(sender, "&cEntry not found");
      return true;
    }
    World world = HawkEye.server.getWorld(entry.getWorld());
    if (world == null) {
      Util.sendMessage(sender, "&cWorld &7" + entry.getWorld() + "&c does not exist!");
      return true;
    }
    Location loc = new Location(world, entry.getX(), entry.getY(), entry.getZ());
    player.teleport(loc);
    Util.sendMessage(sender, "&7Teleported to location of data entry &c" + args.get(0));
    return true;
  }
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.