@Override public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception { IUser user = null; if (sender instanceof Player) { user = ess.getUser(((Player)sender)); } if ((args.length < 1 || !Permissions.LIGHTNING_OTHERS.isAuthorized(user)) && user != null) { user.getWorld().strikeLightning(user.getTargetBlock(null, 600).getLocation()); return; } if (server.matchPlayer(args[0]).isEmpty()) { throw new Exception(_("playerNotFound")); } int power = 5; if (args.length > 1) { try { power = Integer.parseInt(args[1]); } catch (NumberFormatException ex) { } } for (Player matchPlayer : server.matchPlayer(args[0])) { sender.sendMessage(_("lightningUse", matchPlayer.getDisplayName())); final LightningStrike strike = matchPlayer.getWorld().strikeLightningEffect(matchPlayer.getLocation()); if (!ess.getUser(matchPlayer).isGodModeEnabled()) { matchPlayer.damage(power, strike); } @Cleanup final ISettings settings = ess.getSettings(); settings.acquireReadLock(); if (settings.getData().getCommands().getLightning().isWarnPlayer()) { matchPlayer.sendMessage(_("lightningSmited")); } } }
@Override public void run(final IUser user, final String commandLabel, final String[] args) throws Exception { @Cleanup ISettings settings = ess.getSettings(); settings.acquireReadLock(); switch (args.length) { case 0: throw new NotEnoughArgumentsException(); case 1: @Cleanup final IUser player = ess.getUserMap().matchUser(args[0], false, false); player.acquireReadLock(); if (!player.getData().isTeleportEnabled()) { throw new Exception(_("teleportDisabled", player.getDisplayName())); } if (user.getWorld() != player.getWorld() && settings.getData().getGeneral().isWorldTeleportPermissions() && !WorldPermissions.getPermission(player.getWorld().getName()).isAuthorized(user)) { throw new Exception(_("noPerm", "essentials.world." + player.getWorld().getName())); } user.sendMessage(_("teleporting")); final Trade charge = new Trade(commandName, ess); charge.isAffordableFor(user); user.getTeleport().teleport(player, charge, TeleportCause.COMMAND); throw new NoChargeException(); default: if (!Permissions.TPOHERE.isAuthorized(user)) { throw new Exception(_("needTpohere")); } user.sendMessage(_("teleporting")); @Cleanup final IUser target = ess.getUserMap().matchUser(args[0], false, false); @Cleanup final IUser toPlayer = ess.getUserMap().matchUser(args[1], false, false); target.acquireReadLock(); toPlayer.acquireReadLock(); if (!target.getData().isTeleportEnabled()) { throw new Exception(_("teleportDisabled", target.getDisplayName())); } if (!toPlayer.getData().isTeleportEnabled()) { throw new Exception(_("teleportDisabled", toPlayer.getDisplayName())); } if (target.getWorld() != toPlayer.getWorld() && settings.getData().getGeneral().isWorldTeleportPermissions() && !WorldPermissions.getPermission(toPlayer.getWorld().getName()).isAuthorized(user)) { throw new Exception(_("noPerm", "essentials.world." + toPlayer.getWorld().getName())); } target.getTeleport().now(toPlayer, false, TeleportCause.COMMAND); target.sendMessage(_("teleportAtoB", user.getDisplayName(), toPlayer.getDisplayName())); break; } }