Ejemplo n.º 1
0
  public KingdomPlayer getPlayer(Player player) {

    for (KingdomPlayerCacher p : players) {
      if (player.equals(p.player)) return p.kingdomPlayer;
    }
    return null;
  }
 public void updateInvisible(Player player) {
   for (Player invisiblePlayer : invisible.values()) {
     if (getDistance(invisiblePlayer, player) <= RANGE && !player.equals(invisiblePlayer)) {
       invisible(invisiblePlayer, player);
     }
   }
 }
Ejemplo n.º 3
0
  public boolean contains(Player player) {

    for (KingdomPlayerCacher p : players) {
      if (player.equals(p.player)) return true;
    }
    return false;
  }
Ejemplo n.º 4
0
 @EventHandler
 void onPlayerInteractEntityEvent(PlayerInteractEntityEvent event) {
   if (event.getPlayer().hasMetadata("give-pet")) {
     if (event.getRightClicked() instanceof Tameable) {
       Tameable pet = (Tameable) event.getRightClicked();
       if (pet.isTamed() && pet.getOwner() instanceof Player) {
         Player player = (Player) pet.getOwner();
         if (player.equals(event.getPlayer())
             || event.getPlayer().hasPermission("omneity3.give-pet.override")) {
           OfflinePlayer reciever =
               plugin
                   .getServer()
                   .getOfflinePlayer(
                       (String) event.getPlayer().getMetadata("give-pet").get(0).value());
           pet.setOwner(reciever);
           event.getPlayer().removeMetadata("give-pet", plugin);
         } else {
           event.getPlayer().sendMessage("This pet is not yours to give");
           event.getPlayer().removeMetadata("give-pet", plugin);
         }
       } else {
         event.getPlayer().sendMessage("This pet is not tamed");
         event.getPlayer().removeMetadata("give-pet", plugin);
       }
     } else {
       event.getPlayer().sendMessage("That entity can not be a pet");
       event.getPlayer().removeMetadata("give-pet", plugin);
     }
   }
 }
Ejemplo n.º 5
0
  /*
   * @Return: True if they have an ability matching the held item. False if
   * they do not have any abilities matching held item
   */
  public boolean useAbility(Player sender, Player target) {
    // check if they're holding anything
    if (sender.getItemInHand() == null) {
      return false;
    }

    ItemStack i = sender.getItemInHand();

    // sees if they are fightclassed
    FightClass f = FightClass.get(sender);
    // goes through each ability, seeeing if any of the MID's match the
    // lore of the item
    for (Ability a : f.getAbilities()) {
      if (i.getItemMeta().hasLore()
          && i.getItemMeta().getLore().get(0).equalsIgnoreCase(a.getMID())) {
        // check if cost is able to be paid, and pay it
        if (a.useCost(sender)) {
          if (!sender.equals(target)) {
            a.effect(sender, target);
          }
        } else {
          // nothing
        }
        return true;
      }
    }
    return false;
  }
Ejemplo n.º 6
0
  @Override
  public boolean execute(CommandSender sender, String[] args) {
    if (args.length <= 2) {
      LocalWeather.printPlayerList(
          sender, args.length == 2 && args[1].matches("\\d+") ? Integer.parseInt(args[1]) : 1);
    } else {

      String playerName = args[1];
      if (!isKnownPlayer(playerName)) {
        return M.WTH_UNKNOWNPLAYER.print(playerName);
      }

      @SuppressWarnings("deprecation")
      Player player = Bukkit.getPlayerExact(playerName);

      switch (args[2].toLowerCase()) {
        case "rain":
        case "storm":
          LocalWeather.setPlayerRain(player, true);
          M.WTH_PLAYERWEATHER.print(sender, playerName, M.RAIN);
          if (player != null && !player.equals(sender)) {
            M.MY_WEATHER_SET.print(player, M.RAIN);
          }
          break;
        case "sun":
        case "clear":
          LocalWeather.setPlayerRain(player, false);
          M.WTH_PLAYERWEATHER.print(sender, playerName, M.CLEAR);
          if (player != null && !player.equals(sender)) {
            M.MY_WEATHER_SET.print(player, M.CLEAR);
          }
          break;
        case "remove":
        case "delete":
          LocalWeather.clearPlayerRain(player);
          M.WTH_PLAYERWEATHERREMOVED.print(sender, playerName);
          if (player != null && !player.equals(sender)) {
            M.MY_WEATHER_REMOVED.print(player);
          }
          break;
        default:
          M.WTH_UNKNOWNWEATHER.print(sender, args[2]);
          break;
      }
    }
    return true;
  }
Ejemplo n.º 7
0
  /**
   * @param player the player who sent the command
   * @param args the command arguments
   * @return whether the command was successful
   */
  private boolean doCommand(Player player, String[] args) {

    if (!player.hasPermission("vgtrade.trade")) {
      player.sendMessage(
          ChatColor.GREEN + LanguageManager.getString(LanguageManager.Strings.UNABLE));
      return true;
    }

    if (args.length == 0) {
      // You must specify an option
      player.sendMessage(ChatColor.RED + languageManager.getString(LanguageManager.Strings.OPTION));

    } else if ("accept".equalsIgnoreCase(args[0]) || "decline".equalsIgnoreCase(args[0])) {

      manager.handleCommand(args[0], player);

    } else if ("ignore".equalsIgnoreCase(args[0])) {

      if (playersIgnoring.contains(player.getName())) {
        playersIgnoring.remove(player.getName());
        player.sendMessage(
            ChatColor.GREEN + LanguageManager.getString(LanguageManager.Strings.NOTIGNORING));
      } else {
        playersIgnoring.add(player.getName());
        player.sendMessage(
            ChatColor.GREEN + LanguageManager.getString(LanguageManager.Strings.IGNORING));
      }

    } else {

      Player target;

      if ((target = getServer().getPlayer(args[0])) == null) {
        player.sendMessage(
            ChatColor.RED
                // The player you specified is not online
                + languageManager.getString(LanguageManager.Strings.ONLINE));
        return true;
      } else if (player.equals(target)) {
        player.sendMessage(
            ChatColor.RED
                // You can't trade with yourself!
                + languageManager.getString(LanguageManager.Strings.YOURSELF));
        return true;
      }

      if (!isBusy(player)) {
        requestTrade(player, target);
      } else {
        // Unable to trade with <target name>
        player.sendMessage(
            ChatColor.RED
                + LanguageManager.getString(LanguageManager.Strings.UNABLE)
                + " "
                + target.getName());
      }
    }
    return true;
  }
Ejemplo n.º 8
0
  private void teleportAll(Player player, Location loc) {
    for (Player p : plugin.getServer().getOnlinePlayers()) {
      if (player.equals(p)) continue;

      p.teleport(loc);
      p.sendMessage(player.getName() + " has brought you to their location.");
    }
  }
Ejemplo n.º 9
0
 /**
  * This function calculates the distance between two players. Unlike Bukkit's built in function
  * this will not cause an exception if the players aren't in the same world but return {@link
  * Double#POSITIVE_INFINITY}.
  *
  * @param player1 The first player.
  * @param player2 The second player.
  * @return The distance between the players. {@link Double#POSITIVE_INFINITY} if the players
  *     aren't in the same world.
  */
 public static double getDistance(@NotNull Player player1, @NotNull Player player2) {
   if (player1.equals(player2)) {
     return 0;
   }
   if (player1.getWorld().getName().equalsIgnoreCase(player2.getWorld().getName())) {
     return player1.getLocation().distance(player2.getLocation());
   }
   return Double.POSITIVE_INFINITY;
 }
    @EventHandler
    public void onProjectileHit(ProjectileHitEvent projectile) {
      Heroes.debug.startTask("HeroesSkillListener");

      if (!(projectile.getEntity() instanceof Arrow)) {
        Heroes.debug.stopTask("HeroesSkillListener");
        return;
      }

      Arrow arrow = (Arrow) projectile.getEntity();

      if (!(arrow.getShooter() instanceof Player)) {
        Heroes.debug.stopTask("HeroesSkillListener");
        return;
      }

      Player player = (Player) arrow.getShooter();
      Hero hero = SkillExplodingArrow.this.plugin.getCharacterManager().getHero(player);
      if (!hero.hasEffect("ExplodingArrowBuff")) {
        Heroes.debug.stopTask("HeroesSkillListener");
        return;
      }

      int radius =
          (int)
              Math.pow(
                  SkillConfigManager.getUseSetting(hero, this.skill, "radius", 5, false), 2.0D);

      float damage = SkillConfigManager.getUseSetting(hero, this.skill, "DAMAGE", 5, false);
      float blockdamage = damage;
      int block_dmg = SkillConfigManager.getUseSetting(hero, this.skill, "block-dmg", 0, false);

      if (block_dmg == 0) {
        blockdamage = 0.0F;

        for (Entity t_entity : player.getWorld().getEntities()) {
          if ((t_entity instanceof Player)) {
            Player heroes = (Player) t_entity;
            if ((heroes.equals(player))
                || (heroes.getLocation().distanceSquared(arrow.getLocation()) > radius)) continue;
            damageEntity(
                heroes, player, (int) damage, EntityDamageEvent.DamageCause.ENTITY_EXPLOSION);
          } else if ((t_entity instanceof Creature)) {
            Creature mob = (Creature) t_entity;
            if (t_entity.getLocation().distanceSquared(arrow.getLocation()) <= radius) {
              damageEntity(
                  mob, player, (int) damage, EntityDamageEvent.DamageCause.ENTITY_EXPLOSION);
            }
          }
        }
      }

      arrow.getWorld().createExplosion(arrow.getLocation(), blockdamage);

      Heroes.debug.stopTask("HeroesSkillListener");
    }
 public void updateInvisibleForAll() {
   Player[] playerList = getServer().getOnlinePlayers();
   for (Player invisiblePlayer : invisible.values()) {
     for (Player p : playerList) {
       if (getDistance(invisiblePlayer, p) <= RANGE && !p.equals(invisiblePlayer)) {
         invisible(invisiblePlayer, p);
       }
     }
   }
 }
Ejemplo n.º 12
0
  /**
   * Checks that player is not trying to combatlog/is allowed to teleport Returns an error message
   * to be displayed if the player is not allowed to teleport Returns null if the player is allowed
   * to teleport
   */
  private static String teleportCheck(Player player) {

    Location pLoc = player.getLocation();

    World world = player.getWorld();

    /* Check if there are any players within 50 blocks */
    for (Player p : world.getPlayers()) {

      if (!p.equals(player)
          && p.getLocation().distance(pLoc) < 50
          && player.canSee(p)
          && !p.isDead()) {
        return ChatColor.RED
            + "You cannot use this command while within 50 blocks of any other players.";
      }
    }

    /* Check if there are any hostile mobs within 5 blocks */
    for (Entity entity :
        world.getEntitiesByClasses(
            Blaze.class,
            CaveSpider.class,
            Creeper.class,
            Enderman.class,
            Ghast.class,
            MagmaCube.class,
            PigZombie.class,
            Skeleton.class,
            Silverfish.class,
            Slime.class,
            Spider.class,
            Witch.class,
            Zombie.class)) {

      if (entity.getLocation().distance(pLoc) < 5) {
        return ChatColor.RED
            + "You cannot use this command while within 5 blocks of any hostile mobs.";
      }
    }

    /* Check if the player is falling */
    if (player.getVelocity().getY() < -0.079 || player.getVelocity().getY() > 0.08) {
      return ChatColor.RED + "You cannot use this command while falling.";
    }

    /* Check if the player is burning */
    if (player.getFireTicks() > 0 && !player.hasPotionEffect(PotionEffectType.FIRE_RESISTANCE)) {
      return ChatColor.RED + "You cannot use this command while on fire.";
    }

    /* Default to allow teleport */
    return null;
  }
 public static boolean annihilateBlasts(Location location, double radius, Player source) {
   boolean broke = false;
   for (int id : instances.keySet()) {
     EarthBlast blast = instances.get(id);
     if (blast.location.getWorld().equals(location.getWorld()) && !source.equals(blast.player)) {
       if (blast.location.distance(location) <= radius) {
         blast.breakBlock();
         broke = true;
       }
     }
   }
   return broke;
 }
Ejemplo n.º 14
0
  public static GuestPlayer getGuestPlayer(Player player) {
    Iterator<GuestPlayer> it = guestPlayers.listIterator();

    while (it.hasNext()) {
      GuestPlayer gp = it.next();

      if (player.equals(gp.getPlayer())) {
        return gp;
      }
    }

    return new GuestPlayer(player);
  }
Ejemplo n.º 15
0
  public static String getColor(Player player, LivingEntity target) {
    if ((target instanceof Player)) {
      for (String arg : default_colours.keySet()) {
        if (((arg.equals("op")) && (((Player) target).isOp()))
            || (arg.equals("default"))
            || (((Player) target).hasPermission(arg))) {
          String color = (String) default_colours.get(arg);
          if (color.matches("[0-9a-f]")) {
            return new StringBuilder().append("§").append(color).toString();
          }
          return ChatColor.valueOf(color.toUpperCase()).toString();
        }
      }
      return ((Player) target).isOp() ? ChatColor.GOLD.toString() : ChatColor.YELLOW.toString();
    }
    if ((target instanceof Monster)) {
      if ((player != null) && (player.equals(((Monster) target).getTarget()))) {
        return ChatColor.RED.toString();
      }
      return ChatColor.YELLOW.toString();
    }
    if ((target instanceof WaterMob)) return ChatColor.GREEN.toString();
    if ((target instanceof Flying)) return ChatColor.YELLOW.toString();
    if ((target instanceof Animals)) {
      if ((player != null) && (player.equals(((Animals) target).getTarget())))
        return ChatColor.RED.toString();
      if ((target instanceof Tameable)) {
        Tameable pet = (Tameable) target;
        if (pet.isTamed()) {
          return ChatColor.GREEN.toString();
        }
        return ChatColor.YELLOW.toString();
      }

      return ChatColor.GRAY.toString();
    }

    return ChatColor.GRAY.toString();
  }
Ejemplo n.º 16
0
 /**
  * Removes all instances of Suffocate at loc within the radius threshold. The location of a
  * Suffocate is defined at the benders location, not the location of the entities being
  * suffocated.
  *
  * @param causer The player causing this instance to be removed
  */
 public static boolean removeAtLocation(Player causer, Location loc, double radius) {
   for (Player player : instances.keySet()) {
     Suffocate suff = instances.get(player);
     if (causer == null || !player.equals(causer)) {
       Location playerLoc = suff.getPlayer().getLocation();
       if (playerLoc.getWorld().equals(loc.getWorld()) && playerLoc.distance(loc) <= radius) {
         suff.remove();
         return true;
       }
     }
   }
   return false;
 }
Ejemplo n.º 17
0
 /*
  * (non-Javadoc)
  *
  * @see
  * be.Balor.Manager.ACCommands#execute(org.bukkit.command.CommandSender,
  * java.lang.String[])
  */
 @Override
 public void execute(final CommandSender sender, final CommandArgs args)
     throws ActionNotPermitedException, PlayerNotFound {
   final String timeOut = args.getValueFlag('t');
   final Player player = Utils.getUser(sender, args, permNode);
   if (player != null) {
     final HashMap<String, String> replace = new HashMap<String, String>();
     replace.put("player", Utils.getPlayerName(player));
     final ACPlayer acp = ACPlayer.getPlayer(player);
     if (acp.hasPower(Type.GOD)) {
       acp.removePower(Type.GOD);
       Utils.sI18n(player, "godDisabled");
       if (!player.equals(sender)) {
         Utils.sI18n(sender, "godDisabledTarget", replace);
       }
     } else {
       acp.setPower(Type.GOD);
       Utils.sI18n(player, "godEnabled");
       if (!player.equals(sender)) {
         Utils.sI18n(sender, "godEnabledTarget", replace);
       }
       if (timeOut == null) {
         return;
       }
       int timeOutValue;
       try {
         timeOutValue = Integer.parseInt(timeOut);
       } catch (final Exception e) {
         Utils.sI18n(sender, "NaN", "number", timeOut);
         return;
       }
       ACPluginManager.getScheduler()
           .runTaskLaterAsynchronously(
               ACPluginManager.getCorePlugin(),
               new RemovePowerTask(acp, Type.GOD, sender),
               Utils.secInTick * ConfigEnum.SCALE_TIMEOUT.getInt() * timeOutValue);
     }
   }
 }
  @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
  public void onPlayerSwing(PlayerAnimationEvent event) {
    Player player = event.getPlayer();
    if (this.interact.contains(player.getUniqueId())) {
      this.interact.remove(player.getUniqueId());
      return;
    }
    if (Bloodbending.isBloodbended(player) || Concussion.getTarget(player) != null) {
      event.setCancelled(true);
      return;
    }

    String ability = EntityTools.getBendingAbility(player);
    RegisteredAbility registered = AbilityManager.getManager().getRegisteredAbility(ability);
    if (registered == null) {
      return;
    }

    if (EntityTools.canBend(player, registered)
        && (registered.canBeUsedWithTools()
            || !EntityTools.isTool(player.getInventory().getItemInMainHand().getType()))) {
      Map<Object, BendingAbility> abilities = AbilityManager.getManager().getInstances(ability);
      boolean shouldCreateNew = true;
      for (BendingAbility a : abilities.values()) {
        if (player.equals(a.getPlayer()) && !((BendingActiveAbility) a).swing()) {
          shouldCreateNew = false;
        }
      }
      if (shouldCreateNew) {
        BendingActiveAbility ab = AbilityManager.getManager().buildAbility(ability, player);
        if (ab == null) {
          Bending.getInstance()
              .getLogger()
              .log(
                  Level.SEVERE,
                  "Ability "
                      + ability
                      + " failed to construct with buildAbility for player "
                      + player.getName());
          return;
        }
        if (ab.canBeInitialized()) {
          ab.swing();
          if (ab.getState() != BendingAbilityState.START
              && ab.getState() != BendingAbilityState.ENDED) {
            AbilityManager.getManager().addInstance(ab);
          }
        }
      }
    }
  }
Ejemplo n.º 19
0
  @Override
  public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    switch (args.length) {
      case 2:
        String targetName = CommandUtils.getMatchedPlayerName(args[1]);
        McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName);

        if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
          return false;
        }

        Player target = mcMMOTarget.getPlayer();
        Player player = (Player) sender;
        McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
        String playerName = player.getName();

        if (player.equals(target)) {
          sender.sendMessage(LocaleLoader.getString("Party.Invite.Self"));
          return true;
        }

        if (PartyManager.inSameParty(player, target)) {
          sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", targetName));
          return true;
        }

        if (!PartyManager.canInvite(mcMMOPlayer)) {
          player.sendMessage(LocaleLoader.getString("Party.Locked"));
          return true;
        }

        Party playerParty = mcMMOPlayer.getParty();
        mcMMOTarget.setPartyInvite(playerParty);

        sender.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
        target.sendMessage(
            LocaleLoader.getString("Commands.Party.Invite.0", playerParty.getName(), playerName));
        target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.1"));
        return true;

      default:
        sender.sendMessage(
            LocaleLoader.getString(
                "Commands.Usage.2",
                "party",
                "invite",
                "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
        return true;
    }
  }
Ejemplo n.º 20
0
 public boolean teleport(final String victimName, final Player destination) {
   if (victimName.equalsIgnoreCase("*")) {
     Player[] players = getServer().getOnlinePlayers();
     for (Player victim : players) {
       if (!victim.equals(destination)) {
         teleport(victim, destination);
       }
     }
     return true;
   } else {
     Player victim = getServer().getPlayer(victimName);
     return teleport(victim, destination);
   }
 }
Ejemplo n.º 21
0
 /**
  * Flicker the player for anyone in a set of players who can see him.
  *
  * @param player
  * @param forWhom
  */
 public static void refreshPlayer(Player player, Set<Player> forWhom) {
   TagAPI.check();
   if (player == null) {
     throw new TagAPIException("Can't submit null player!");
   }
   if ((forWhom == null) || forWhom.isEmpty()) {
     throw new TagAPIException("Can't submit empty forWhom!");
   }
   for (final Player whom : forWhom) {
     if ((whom != null) && (!player.equals(whom))) {
       TagAPI.refreshPlayer(player, whom);
     }
   }
 }
Ejemplo n.º 22
0
 @EventHandler
 public void onQuit(PlayerQuitEvent evt) {
   for (Player p : Bukkit.getOnlinePlayers()) {
     if (p.equals(evt.getPlayer())) continue;
     for (Friendship f : FriendMe.friendships) {
       if (f.getSender().equals(evt.getPlayer())) {
         FriendMe.sendMessage(f.getReceiver(), Type.FRIEND_OFF, evt.getPlayer());
         break;
       } else if (f.getReceiver().equals(evt.getPlayer())) {
         FriendMe.sendMessage(f.getSender(), Type.FRIEND_OFF, evt.getPlayer());
         break;
       }
     }
   }
 }
 public void vanish(Player player) {
   if (invisible.get(player.getName()) != null) {
     reappear(player);
     return;
   }
   invisible.put(player.getName(), player);
   Player[] playerList = getServer().getOnlinePlayers();
   for (Player p : playerList) {
     if (getDistance(player, p) <= RANGE && !p.equals(player)) {
       invisible(player, p);
     }
   }
   log.info(player.getName() + " disappeared.");
   player.sendMessage(ChatColor.RED + "Poof!");
 }
 public void reappear(Player player) {
   if (invisible.get(player.getName()) != null) {
     invisible.remove(player.getName());
     // make someone really disappear if there's any doubt, should remove
     // cloning
     updateInvisibleForAll();
     Player[] playerList = getServer().getOnlinePlayers();
     for (Player p : playerList) {
       if (getDistance(player, p) < RANGE && !p.equals(player)) {
         uninvisible(player, p);
       }
     }
     log.info(player.getName() + " reappeared.");
     player.sendMessage(ChatColor.RED + "You have reappeared!");
   }
 }
Ejemplo n.º 25
0
  /* Makes p1 visible to p2 */
  private void uninvisible(Player p1, Player p2) {
    if (p1.equals(p2)) return;

    if (getDistanceSquared(p1, p2) > RANGE_SQUARED) return;

    CraftPlayer unHide = (CraftPlayer) p1;
    CraftPlayer unHideFrom = (CraftPlayer) p2;
    unHideFrom
        .getHandle()
        .netServerHandler
        .sendPacket(new Packet29DestroyEntity(unHide.getEntityId()));
    unHideFrom
        .getHandle()
        .netServerHandler
        .sendPacket(new Packet20NamedEntitySpawn(unHide.getHandle()));
  }
Ejemplo n.º 26
0
  /* Makes p1 invisible to p2 */
  private void invisible(Player p1, Player p2) {
    if (p1 == null) {
      return;
    }
    if (p2 == null) {
      return;
    }
    if (p1.equals(p2)) return;

    if ((check(p2, "vanish.dont.hide"))) return;

    if (getDistanceSquared(p1, p2) > RANGE_SQUARED) return;

    CraftPlayer hide = (CraftPlayer) p1;
    CraftPlayer hideFrom = (CraftPlayer) p2;
    hideFrom.getHandle().netServerHandler.sendPacket(new Packet29DestroyEntity(hide.getEntityId()));
  }
Ejemplo n.º 27
0
 /**
  * Flicker the player for anyone who can see him.
  *
  * @param player
  */
 public static void refreshPlayer(Player player) {
   TagAPI.check();
   if (player == null) {
     throw new TagAPIException("Can't submit null player!");
   }
   if (!player.isOnline()) {
     throw new TagAPIException("Can't submit offline player!");
   }
   final ShowBomb bomb = TagAPI.instance.new ShowBomb();
   for (final Player otherGuy : player.getWorld().getPlayers()) {
     if ((!otherGuy.equals(player)) && otherGuy.canSee(player)) {
       otherGuy.hidePlayer(player);
       bomb.queue(TagAPI.instance.new RefreshPair(otherGuy, player));
     }
   }
   TagAPI.instance.getServer().getScheduler().scheduleSyncDelayedTask(TagAPI.instance, bomb, 2);
 }
Ejemplo n.º 28
0
 /**
  * Flicker the player for a player who can see him.
  *
  * @param player
  * @param forWhom
  */
 public static void refreshPlayer(Player player, Player forWhom) {
   TagAPI.check();
   if (player == null) {
     throw new TagAPIException("Can't submit null player!");
   }
   if (forWhom == null) {
     throw new TagAPIException("Can't submit null forWhom!");
   }
   if (player.equals(forWhom)) {
     throw new TagAPIException("Can't submit player on self!");
   }
   final ShowBomb bomb = TagAPI.instance.new ShowBomb();
   if (forWhom.canSee(player) && player.getWorld().equals(forWhom.getWorld())) {
     forWhom.hidePlayer(player);
     bomb.queue(TagAPI.instance.new RefreshPair(forWhom, player));
   }
   TagAPI.instance.getServer().getScheduler().scheduleSyncDelayedTask(TagAPI.instance, bomb, 2);
 }
Ejemplo n.º 29
0
  // Instead of slamming the main object with compares we do all that stuff here
  public boolean canReceive(Player sender, Player player) {
    if (sender.equals(player)) {
      return true;
    }
    // If the player receiving the message is a op or has the below permission they can hear
    // everything.
    if (player.hasPermission("amchat.radio.hearall") || player.isOp()) {
      return true;
    }

    if (!isRadioOn(player)) { // The player doesn't even have his radio on		
      return false;
    }

    if (!sender.getWorld().equals(player.getWorld())) { // we can't talk to the other side.
      return false;
    }

    if (playerRadioChannel.get(sender)
        < (playerRadioChannel.get(player) - playerRadioCutoff.get(player))) {
      // Radio chat is below cutoff limit
      return false;
    } else if (playerRadioChannel.get(sender)
        > (playerRadioChannel.get(player) + playerRadioCutoff.get(player))) {
      // Radio channel is above the cutoff limit
      return false;
    }
    // TODO:Change this comparison, This might cause issues on certain channel/code combinations
    if ((playerRadioChannel.get(sender) != playerRadioChannel.get(player))
        && (playerRadioCode.get(sender) != playerRadioCode.get(player))
        && (playerRadioFilter.get(player))) {
      // message is encrypted and we don't want to hear that.
      return false;
    }
    if (varLimitRadioChat) {
      if (amcTools.getDistance(sender.getLocation(), player.getLocation()) > varRadioMaxChatDist) {
        // Radio chat is limited and they are too far
        return false;
      }
    }
    return true;
  }
Ejemplo n.º 30
0
 // same logic for checking if players can receive is implied here.
 public boolean canRead(Player sender, Player player) {
   // Sender is Receiver
   if (sender.equals(player)) {
     return true;
   }
   // Sender is not encrypting chat
   if (playerRadioCode.get(sender) == 0) {
     return true;
   }
   // Receiver has read all permission
   if (player.hasPermission("amchat.radio.readall") || player.isOp()) {
     return true;
   }
   // the player and receiver are on the same channel with the same key
   if ((playerRadioCode.get(sender).equals(playerRadioCode.get(player)))
       && (playerRadioChannel.get(sender).equals(playerRadioChannel.get(player)))) {
     return true;
   }
   return false;
 }