mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-13 12:38:58 +00:00
![KHobbits](/assets/img/avatar_default.png)
With this permission you can use /lightning <player>, without only strike based on direction.
72 lines
1.7 KiB
Java
72 lines
1.7 KiB
Java
package com.earth2me.essentials.commands;
|
|
|
|
import static com.earth2me.essentials.I18n._;
|
|
import com.earth2me.essentials.User;
|
|
import org.bukkit.Server;
|
|
import org.bukkit.command.CommandSender;
|
|
import org.bukkit.entity.LightningStrike;
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
public class Commandlightning extends EssentialsCommand
|
|
{
|
|
public Commandlightning()
|
|
{
|
|
super("lightning");
|
|
}
|
|
|
|
@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.isAuthorized("essentials.lightning.others")) & user != null)
|
|
{
|
|
user.getWorld().strikeLightning(user.getTargetBlock(null, 600).getLocation());
|
|
return;
|
|
}
|
|
|
|
if (server.matchPlayer(args[0]).isEmpty())
|
|
{
|
|
throw new Exception(_("playerNotFound"));
|
|
}
|
|
|
|
int power = 1;
|
|
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()));
|
|
if (power <= 0)
|
|
{
|
|
matchPlayer.getWorld().strikeLightningEffect(matchPlayer.getLocation());
|
|
}
|
|
else
|
|
{
|
|
LightningStrike strike = matchPlayer.getWorld().strikeLightning(matchPlayer.getLocation());
|
|
matchPlayer.damage(power - 1, strike);
|
|
}
|
|
if (!ess.getUser(matchPlayer).isGodModeEnabled())
|
|
{
|
|
matchPlayer.setHealth(matchPlayer.getHealth() < 5 ? 0 : matchPlayer.getHealth() - 5);
|
|
}
|
|
if (ess.getSettings().warnOnSmite())
|
|
{
|
|
matchPlayer.sendMessage(_("lightningSmited"));
|
|
}
|
|
}
|
|
}
|
|
}
|