Example #1
0
  /* (non-Javadoc)
   * @see me.tabinol.secuboid.commands.executor.CommandInterface#commandExecute()
   */
  @Override
  public void commandExecute() throws SecuboidCommandException {

    checkSelections(true, null);
    checkPermission(true, true, null, null);

    String curArg = entity.argList.getNext();
    if (BannedWords.isBannedWord(curArg)) {
      throw new SecuboidCommandException("CommandRename", entity.player, "COMMAND.RENAME.HINTUSE");
    }

    // Check for collision
    if (checkCollision(
        curArg,
        land,
        null,
        Collisions.LandAction.LAND_RENAME,
        0,
        null,
        land.getParent(),
        land.getOwner(),
        0,
        true)) {
      return;
    }

    String oldName = land.getName();

    try {
      Secuboid.getThisPlugin().getLands().renameLand(oldName, curArg);
    } catch (SecuboidLandException ex) {
      Logger.getLogger(CommandRename.class.getName()).log(Level.SEVERE, "On land rename", ex);
      throw new SecuboidCommandException("On land rename", entity.player, "GENERAL.ERROR");
    }
    entity.player.sendMessage(
        ChatColor.GREEN
            + "[Secuboid] "
            + Secuboid.getThisPlugin()
                .getLanguage()
                .getMessage("COMMAND.RENAME.ISDONE", oldName, curArg));
    Secuboid.getThisPlugin()
        .getLog()
        .write(entity.playerName + " has renamed " + oldName + " to " + curArg);

    // Cancel the selection
    new CommandCancel(entity.playerConf, true).commandExecute();
  }
Example #2
0
  /**
   * On entity damage.
   *
   * @param event the events
   */
  @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
  public void onEntityDamage(EntityDamageEvent event) {

    // Check for fire cancel
    if (event.getEntity() instanceof Player
        && (event.getCause() == DamageCause.FIRE || event.getCause() == DamageCause.FIRE_TICK)) {

      Player player = (Player) event.getEntity();
      ApiPlayerConfEntry entry = playerConf.get(player);

      if (entry != null) {
        Location loc = player.getLocation();
        ApiDummyLand land = Secuboid.getThisPlugin().getLands().getLandOrOutsideArea(loc);

        // Check for fire near the player
        for (Map.Entry<Location, ApiPlayerContainerPlayer> fireEntry :
            playerFireLocation.entrySet()) {

          if (loc.getWorld() == fireEntry.getKey().getWorld()
              && loc.distanceSquared(fireEntry.getKey()) < 5) {
            Block block = loc.getBlock();
            if ((block.getType() == Material.FIRE || block.getType() == Material.AIR)
                && !isPvpValid(land, fireEntry.getValue(), entry.getPlayerContainer())) {

              // remove fire
              Secuboid.getThisPlugin()
                  .getLog()
                  .write(
                      "Anti-pvp from "
                          + entry.getPlayerContainer().getPlayer().getName()
                          + " to "
                          + player.getName());
              block.setType(Material.AIR);
              player.setFireTicks(0);
              event.setDamage(0);
              event.setCancelled(true);
            }
          }
        }
      }
    }
  }
Example #3
0
  /**
   * Check when a player deposits fire and add it to list
   *
   * @param event the events
   * @param player the player
   */
  private void checkForPvpFire(BlockEvent event, Player player) {

    ApiPlayerConfEntry entry;

    if (player != null && (entry = playerConf.get(player)) != null) {

      Location loc = event.getBlock().getLocation();
      ApiDummyLand land = Secuboid.getThisPlugin().getLands().getLandOrOutsideArea(loc);

      if (land.getFlagAndInherit(FlagList.FULL_PVP.getFlagType()).getValueBoolean() == false
          || land.getFlagAndInherit(FlagList.FULL_PVP.getFlagType()).getValueBoolean() == false) {

        // Add fire for pvp listen
        playerFireLocation.put(loc, entry.getPlayerContainer());
      }
    }
  }
Example #4
0
  /**
   * On entity damage by entity.
   *
   * @param event the events
   */
  @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
  public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {

    ApiPlayerConfEntry entry;
    ApiPlayerConfEntry entryVictim;

    // Check if a player break a ItemFrame
    Player player = getSourcePlayer(event.getDamager());

    if (player != null) {
      ApiDummyLand land =
          Secuboid.getThisPlugin().getLands().getLandOrOutsideArea(event.getEntity().getLocation());
      Entity entity = event.getEntity();

      // For PVP
      if (entity instanceof Player
          && (entry = playerConf.get(player)) != null
          && (entryVictim = playerConf.get((Player) entity)) != null
          && !isPvpValid(land, entry.getPlayerContainer(), entryVictim.getPlayerContainer())) {
        event.setCancelled(true);
      }
    }
  }
Example #5
0
  /** Instantiates a new pvp listener. */
  public PvpListener() {

    super();
    playerConf = Secuboid.getThisPlugin().getPlayerConf();
    playerFireLocation = new ExpirableHashMap<Location, ApiPlayerContainerPlayer>(FIRE_EXPIRE);
  }