Ejemplo n.º 1
0
  @Override
  public void run(Server server, CommandSender sender, String commandLabel, String[] args)
      throws Exception {

    User user = null;
    if (sender instanceof Player) {
      user = ess.getUser(((Player) sender));
    }
    if (args.length < 1 & user != null) {
      user.getWorld().strikeLightning(user.getTargetBlock(null, 600).getLocation());
      return;
    }

    if (server.matchPlayer(args[0]).isEmpty()) {
      throw new Exception(Util.i18n("playerNotFound"));
    }

    for (Player p : server.matchPlayer(args[0])) {
      sender.sendMessage(Util.format("lightningUse", p.getDisplayName()));
      p.getWorld().strikeLightning(p.getLocation());
      if (!ess.getUser(p).isGodModeEnabled()) {
        p.setHealth(p.getHealth() < 5 ? 0 : p.getHealth() - 5);
      }
      if (ess.getSettings().warnOnSmite()) {
        p.sendMessage(Util.i18n("lightningSmited"));
      }
    }
  }
Ejemplo n.º 2
0
	@Override
	public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
	{

		User user = null;
		if (sender instanceof Player)
		{
			user = ess.getUser(((Player)sender));
			if ((args.length < 1 || user != null && !user.isAuthorized("essentials.lightning.others")))
			{
				user.getWorld().strikeLightning(user.getTargetBlock(null, 600).getLocation());
				return;
			}
		}

		int power = 5;
		if (args.length > 1)
		{
			try
			{
				power = Integer.parseInt(args[1]);
			}
			catch (NumberFormatException ex)
			{
			}
		}

		if (args[0].trim().length() < 2)
		{
			throw new Exception(_("playerNotFound"));
		}

		final List<Player> matchedPlayers = server.matchPlayer(args[0]);
		for (Player matchPlayer : matchedPlayers)
		{
			sender.sendMessage(_("lightningUse", matchPlayer.getDisplayName()));

			final LightningStrike strike = matchPlayer.getWorld().strikeLightningEffect(matchPlayer.getLocation());

			if (!ess.getUser(matchPlayer).isGodModeEnabled())
			{
				matchPlayer.damage(power, strike);
			}
			if (ess.getSettings().warnOnSmite())
			{
				matchPlayer.sendMessage(_("lightningSmited"));
			}
		}
	}