示例#1
0
 @EventHandler(priority = EventPriority.HIGH)
 public void onBlockIgniteEvent(BlockIgniteEvent event) {
   if (event.isCancelled()) {
     return;
   }
   if (event.getPlayer() == null) {
     return;
   }
   Player player = event.getPlayer();
   if (vanishNoPacket.isPlayerInvisible(player)) {
     return;
   }
   Block block = event.getBlock();
   Set<Snitch> snitches = snitchManager.findSnitches(block.getWorld(), block.getLocation());
   for (Snitch snitch : snitches) {
     if (!snitch.shouldLog()) {
       continue;
     }
     if (!isOnSnitch(snitch, player.getName()) || isDebugging()) {
       if (checkProximity(snitch, player.getName())) {
         plugin.getJaLogger().logSnitchIgnite(snitch, player, block);
       }
     }
   }
 }
示例#2
0
 @EventHandler(priority = EventPriority.HIGHEST)
 public void onInventoryOpenEvent(InventoryOpenEvent e) {
   Player player = (Player) e.getPlayer();
   if (e.isCancelled()) {
     return;
   }
   if (vanishNoPacket.isPlayerInvisible(player)) {
     return;
   }
   Block block;
   if (e.getInventory().getHolder() instanceof Chest) {
     Chest chest = (Chest) e.getInventory().getHolder();
     block = chest.getBlock();
   } else if (e.getInventory().getHolder() instanceof DoubleChest) {
     DoubleChest chest = (DoubleChest) e.getInventory().getHolder();
     block = chest.getLocation().getBlock();
   } else {
     return;
   }
   Set<Snitch> snitches = snitchManager.findSnitches(player.getWorld(), player.getLocation());
   for (Snitch snitch : snitches) {
     if (!isOnSnitch(snitch, player.getName()) || isDebugging()) {
       if (checkProximity(snitch, player.getName())) {
         plugin.getJaLogger().logUsed(snitch, player, block);
       }
     }
   }
 }
示例#3
0
 @EventHandler(priority = EventPriority.HIGH)
 public void playerKillEntity(EntityDeathEvent event) {
   LivingEntity entity = event.getEntity();
   LivingEntity killer = entity.getKiller();
   // TODO: This should never be true, bug?
   if (entity instanceof Player) {
     return;
   }
   if (!(killer instanceof Player)) {
     return;
   }
   if (vanishNoPacket.isPlayerInvisible((Player) killer)) {
     return;
   }
   Player player = (Player) killer;
   Set<Snitch> snitches = snitchManager.findSnitches(player.getWorld(), player.getLocation());
   for (Snitch snitch : snitches) {
     if (!snitch.shouldLog()) {
       continue;
     }
     if (!isOnSnitch(snitch, player.getName()) || isDebugging()) {
       if (checkProximity(snitch, player.getName())) {
         plugin.getJaLogger().logSnitchEntityKill(snitch, player, entity);
       }
     }
   }
 }
  @EventHandler(priority = EventPriority.HIGH)
  public void enterSnitchProximity(PlayerMoveEvent event) {
    Location from = event.getFrom();
    Location to = event.getTo();

    if (from.getBlockX() == to.getBlockX()
        && from.getBlockY() == to.getBlockY()
        && from.getBlockZ() == to.getBlockZ()
        && from.getWorld().equals(to.getWorld())) {
      // Player didn't move by at least one block.
      return;
    }
    Player player = event.getPlayer();
    if (vanishNoPacket.isPlayerInvisible(player)) {
      return;
    }
    String playerName = player.getName();
    Location location = player.getLocation();
    World world = location.getWorld();
    Set<Snitch> inList = playersInSnitches.get(playerName);
    if (inList == null) {
      inList = new TreeSet<Snitch>();
      playersInSnitches.put(player.getName(), inList);
    }
    Set<Snitch> snitches = snitchManager.findSnitches(world, location);
    for (Snitch snitch : snitches) {
      if (!isOnSnitch(snitch, playerName) && doesSnitchExist(snitch, true) || isDebugging()) {
        if (!inList.contains(snitch)) {
          inList.add(snitch);
          for (Player remoteplayer : playerManager.getPlayers()) {
            String remoteName = remoteplayer.getName();
            if (isOnSnitch(snitch, remoteName)) {
              remoteplayer.sendMessage(
                  ChatColor.AQUA
                      + " * "
                      + playerName
                      + " entered snitch at "
                      + snitch.getName()
                      + " ["
                      + snitch.getX()
                      + " "
                      + snitch.getY()
                      + " "
                      + snitch.getZ()
                      + "]");
            }
          }
          plugin.getJaLogger().logSnitchEntry(snitch, location, player);
        }
      }
    }
    Set<Snitch> rmList = new TreeSet<Snitch>();
    for (Snitch snitch : inList) {
      if (snitches.contains(snitch)) {
        continue;
      }
      rmList.add(snitch);
    }
    inList.removeAll(rmList);
  }
 @EventHandler(priority = EventPriority.HIGH)
 public void onBlockBurnEvent(BlockBurnEvent event) {
   if (event.isCancelled()) {
     return;
   }
   Block block = event.getBlock();
   Set<Snitch> snitches = snitchManager.findSnitches(block.getWorld(), block.getLocation());
   for (Snitch snitch : snitches) {
     if (snitch.getGroup() != null) {
       continue;
     }
     plugin.getJaLogger().logSnitchBlockBurn(snitch, block);
   }
 }
 @EventHandler(priority = EventPriority.HIGH)
 public void playerFillBucket(PlayerBucketFillEvent event) {
   if (event.isCancelled()) {
     return;
   }
   Player player = event.getPlayer();
   if (vanishNoPacket.isPlayerInvisible(player)) {
     return;
   }
   Block block = event.getBlockClicked();
   Set<Snitch> snitches = snitchManager.findSnitches(block.getWorld(), block.getLocation());
   for (Snitch snitch : snitches) {
     if (!isOnSnitch(snitch, player.getName()) || isDebugging()) {
       if (checkProximity(snitch, player.getName())) {
         plugin.getJaLogger().logSnitchBucketFill(snitch, player, block);
       }
     }
   }
 }
 @EventHandler(priority = EventPriority.HIGH)
 public void playerKillPlayer(PlayerDeathEvent event) {
   if (!(event.getEntity().getKiller() instanceof Player)) {
     return;
   }
   Player killed = event.getEntity();
   Player killer = killed.getKiller();
   if (vanishNoPacket.isPlayerInvisible(killer)) {
     return;
   }
   Set<Snitch> snitches = snitchManager.findSnitches(killed.getWorld(), killed.getLocation());
   for (Snitch snitch : snitches) {
     if (!isOnSnitch(snitch, killer.getName()) || isDebugging()) {
       if (checkProximity(snitch, killed.getName()) || checkProximity(snitch, killer.getName())) {
         plugin.getJaLogger().logSnitchPlayerKill(snitch, killer, killed);
       }
     }
   }
 }
示例#8
0
  @EventHandler(priority = EventPriority.HIGHEST)
  public void playerJoinEvent(PlayerJoinEvent event) {
    Player player = event.getPlayer();
    if (vanishNoPacket.isPlayerInvisible(player)) {
      return;
    }
    String playerName = player.getName();
    Set<Snitch> inList = new TreeSet<Snitch>();
    playersInSnitches.put(player.getName(), inList);

    Location location = player.getLocation();
    World world = location.getWorld();
    Set<Snitch> snitches = snitchManager.findSnitches(world, location);
    for (Snitch snitch : snitches) {
      if (!isOnSnitch(snitch, playerName)) {
        inList.add(snitch);
        for (Player remoteplayer : playerManager.getPlayers()) {
          String remoteName = remoteplayer.getName();
          if (isOnSnitch(snitch, remoteName)) {
            remoteplayer.sendMessage(
                ChatColor.AQUA
                    + " * "
                    + playerName
                    + " logged in to snitch at "
                    + snitch.getName()
                    + " ["
                    + snitch.getX()
                    + " "
                    + snitch.getY()
                    + " "
                    + snitch.getZ()
                    + "]");
          }
        }
        plugin.getJaLogger().logSnitchLogin(snitch, location, player);
      }
    }
  }
示例#9
0
  public void handlePlayerExit(PlayerEvent event) {
    Player player = event.getPlayer();
    if (vanishNoPacket.isPlayerInvisible(player)) {
      return;
    }
    String playerName = player.getName();
    playersInSnitches.remove(playerName);

    Location location = player.getLocation();
    World world = location.getWorld();
    Set<Snitch> snitches = snitchManager.findSnitches(world, location);
    for (Snitch snitch : snitches) {
      if (!isOnSnitch(snitch, playerName)) {
        for (Player remoteplayer : playerManager.getPlayers()) {
          if (snitch.getGroup().isMember(remoteplayer.getName())
              || snitch.getGroup().isFounder(remoteplayer.getName())
              || snitch.getGroup().isModerator(remoteplayer.getName())) {
            remoteplayer.sendMessage(
                ChatColor.AQUA
                    + " * "
                    + playerName
                    + " logged out in snitch at "
                    + snitch.getName()
                    + " ["
                    + snitch.getX()
                    + " "
                    + snitch.getY()
                    + " "
                    + snitch.getZ()
                    + "]");
          }
        }
        plugin.getJaLogger().logSnitchLogout(snitch, location, player);
      }
    }
  }