2011-10-19 00:37:00 +00:00
|
|
|
package me.StevenLawson.TotalFreedomMod.Commands;
|
|
|
|
|
|
|
|
import org.bukkit.Location;
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
2013-03-19 22:05:20 +00:00
|
|
|
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.ONLY_IN_GAME)
|
2011-10-19 00:37:00 +00:00
|
|
|
public class Command_expel extends TFM_Command
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
|
|
{
|
2012-12-01 19:11:10 +00:00
|
|
|
double radius = 15.0;
|
|
|
|
double strength = 20.0;
|
2012-11-24 01:22:52 +00:00
|
|
|
|
|
|
|
if (args.length >= 1)
|
2011-10-24 02:43:52 +00:00
|
|
|
{
|
2012-11-24 01:22:52 +00:00
|
|
|
try
|
|
|
|
{
|
2012-12-01 19:11:10 +00:00
|
|
|
radius = Math.max(1.0, Math.min(100.0, Double.parseDouble(args[0])));
|
2012-11-24 01:22:52 +00:00
|
|
|
}
|
|
|
|
catch (NumberFormatException nfex)
|
|
|
|
{
|
|
|
|
}
|
2011-10-24 02:43:52 +00:00
|
|
|
}
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2012-11-24 01:22:52 +00:00
|
|
|
if (args.length >= 2)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2012-12-01 19:11:10 +00:00
|
|
|
strength = Math.max(0.0, Math.min(50.0, Double.parseDouble(args[1])));
|
2012-11-24 01:22:52 +00:00
|
|
|
}
|
|
|
|
catch (NumberFormatException nfex)
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
|
|
|
}
|
2012-11-24 01:22:52 +00:00
|
|
|
}
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2012-11-24 01:22:52 +00:00
|
|
|
Location sender_pos = sender_p.getLocation();
|
|
|
|
for (Player p : sender_pos.getWorld().getPlayers())
|
|
|
|
{
|
|
|
|
if (!p.equals(sender_p))
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2012-11-24 01:22:52 +00:00
|
|
|
Location target_pos = p.getLocation();
|
|
|
|
|
|
|
|
boolean in_range = false;
|
2011-10-19 00:37:00 +00:00
|
|
|
try
|
|
|
|
{
|
2012-11-24 01:22:52 +00:00
|
|
|
in_range = target_pos.distanceSquared(sender_pos) < (radius * radius);
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
2012-11-24 01:22:52 +00:00
|
|
|
catch (IllegalArgumentException ex)
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-11-24 01:22:52 +00:00
|
|
|
if (in_range)
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2012-12-01 19:11:10 +00:00
|
|
|
p.setVelocity(target_pos.clone().subtract(sender_pos).toVector().normalize().multiply(strength));
|
2013-01-07 14:56:53 +00:00
|
|
|
playerMsg("Pushing " + p.getName() + ".");
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|