Ejemplo n.º 1
0
 @EventHandler(ignoreCancelled = true)
 public void onGroupDeletion(GroupChangeEvent event) {
   if (event.getType() != GroupChangeType.DELETE) {
     return;
   }
   String groupName = event.getFactionName();
   Set<Snitch> removeSet = new TreeSet<Snitch>();
   for (Snitch snitch : snitchManager.getAllSnitches()) {
     if (snitch.getGroup().getName().equalsIgnoreCase(groupName)) {
       removeSet.add(snitch);
     }
   }
   for (Snitch snitch : removeSet) {
     Location loc = snitch.getLoc();
     plugin
         .getJaLogger()
         .logSnitchBreak(
             loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
     snitchManager.removeSnitch(snitch);
   }
 }
Ejemplo n.º 2
0
 @EventHandler(priority = EventPriority.HIGHEST)
 public void breakSnitchBlock(BlockBreakEvent event) {
   if (event.isCancelled()) {
     return;
   }
   Block block = event.getBlock();
   if (!block.getType().equals(Material.JUKEBOX)) {
     return;
   }
   if (vanishNoPacket.isPlayerInvisible(event.getPlayer())) {
     return;
   }
   Location loc = block.getLocation();
   if (snitchManager.getSnitch(loc.getWorld(), loc) != null) {
     snitchManager.removeSnitch(snitchManager.getSnitch(loc.getWorld(), loc));
     plugin
         .getJaLogger()
         .logSnitchBreak(
             loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
   }
 }
Ejemplo n.º 3
0
  @EventHandler(priority = EventPriority.HIGHEST)
  public void reinforceSnitchBlock(CreateReinforcementEvent event) {
    if (event.isCancelled()) {
      return;
    }
    Block block = event.getBlock();
    if (block.getType().equals(Material.JUKEBOX)) {

      Player player = event.getPlayer();
      Location loc = block.getLocation();
      AccessDelegate access = AccessDelegate.getDelegate(block);
      IReinforcement rei = event.getReinforcement();
      if (rei instanceof PlayerReinforcement) {
        PlayerReinforcement reinforcement = (PlayerReinforcement) rei;
        Faction owner = reinforcement.getOwner();
        if (reinforcement.getSecurityLevel().equals(SecurityLevel.GROUP)) {
          Snitch snitch;
          if (snitchManager.getSnitch(loc.getWorld(), loc) != null) {
            snitch = snitchManager.getSnitch(loc.getWorld(), loc);
            plugin
                .getJaLogger()
                .updateSnitchGroup(snitchManager.getSnitch(loc.getWorld(), loc), owner.getName());
            snitchManager.removeSnitch(snitch);
            snitch.setGroup(owner);
          } else {
            snitch = new Snitch(loc, owner, true);
            plugin
                .getJaLogger()
                .logSnitchPlace(
                    player.getWorld().getName(),
                    owner.getName(),
                    "",
                    loc.getBlockX(),
                    loc.getBlockY(),
                    loc.getBlockZ(),
                    true);
            snitch.setId(plugin.getJaLogger().getLastSnitchID());
            plugin.getJaLogger().increaseLastSnitchID();
          }
          snitchManager.addSnitch(snitch);

          player.sendMessage(
              ChatColor.AQUA
                  + "You've created a snitch block registered to the group "
                  + owner.getName()
                  + ".  To name your snitch, type /janame.");
        } else {
          Snitch snitch;
          if (snitchManager.getSnitch(loc.getWorld(), loc) != null) {
            snitch = snitchManager.getSnitch(loc.getWorld(), loc);
            plugin
                .getJaLogger()
                .updateSnitchGroup(
                    snitchManager.getSnitch(loc.getWorld(), loc), owner.getFounder());
            snitchManager.removeSnitch(snitch);
            snitch.setGroup(owner);
          } else {
            snitch = new Snitch(loc, owner, true);
            plugin
                .getJaLogger()
                .logSnitchPlace(
                    player.getWorld().getName(),
                    owner.getFounder(),
                    "",
                    loc.getBlockX(),
                    loc.getBlockY(),
                    loc.getBlockZ(),
                    true);
            snitch.setId(plugin.getJaLogger().getLastSnitchID());
            plugin.getJaLogger().increaseLastSnitchID();
          }
          snitchManager.addSnitch(snitch);

          player.sendMessage(
              ChatColor.AQUA
                  + "You've created a private snitch block; reinforce it with a group to register members.  To name your snitch, type /janame.");
        }
      }
    } else if (block.getType().equals(Material.NOTE_BLOCK)) {
      Player player = event.getPlayer();
      Location loc = block.getLocation();
      AccessDelegate access = AccessDelegate.getDelegate(block);
      IReinforcement rei = event.getReinforcement();
      if (rei instanceof PlayerReinforcement) {
        PlayerReinforcement reinforcement = (PlayerReinforcement) rei;
        Faction owner = reinforcement.getOwner();
        if (reinforcement.getSecurityLevel().equals(SecurityLevel.GROUP)) {
          Snitch snitch;
          if (snitchManager.getSnitch(loc.getWorld(), loc) != null) {
            snitch = snitchManager.getSnitch(loc.getWorld(), loc);
            plugin
                .getJaLogger()
                .updateSnitchGroup(snitchManager.getSnitch(loc.getWorld(), loc), owner.getName());
            snitchManager.removeSnitch(snitch);
            snitch.setGroup(owner);
          } else {
            snitch = new Snitch(loc, owner, false);
            plugin
                .getJaLogger()
                .logSnitchPlace(
                    player.getWorld().getName(),
                    owner.getName(),
                    "",
                    loc.getBlockX(),
                    loc.getBlockY(),
                    loc.getBlockZ(),
                    false);
            snitch.setId(plugin.getJaLogger().getLastSnitchID());
            plugin.getJaLogger().increaseLastSnitchID();
          }
          snitchManager.addSnitch(snitch);

          player.sendMessage(
              ChatColor.AQUA
                  + "You've created an entry snitch registered to the group "
                  + owner.getName()
                  + ".  To name your entry snitch, type /janame.");
        } else {
          Snitch snitch;
          if (snitchManager.getSnitch(loc.getWorld(), loc) != null) {
            snitch = snitchManager.getSnitch(loc.getWorld(), loc);
            plugin
                .getJaLogger()
                .updateSnitchGroup(
                    snitchManager.getSnitch(loc.getWorld(), loc), owner.getFounder());
            snitchManager.removeSnitch(snitch);
            snitch.setGroup(owner);
          } else {
            snitch = new Snitch(loc, owner, false);
            plugin
                .getJaLogger()
                .logSnitchPlace(
                    player.getWorld().getName(),
                    owner.getFounder(),
                    "",
                    loc.getBlockX(),
                    loc.getBlockY(),
                    loc.getBlockZ(),
                    false);
            snitch.setId(plugin.getJaLogger().getLastSnitchID());
            plugin.getJaLogger().increaseLastSnitchID();
          }
          snitchManager.addSnitch(snitch);

          player.sendMessage(
              ChatColor.AQUA
                  + "You've created a private entry snitch; reinforce it with a group to register members.  To name your entry snitch, type /janame.");
        }
      }
    }
  }