2015-10-19 17:43:46 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.commands;
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.permission.PlayerRank;
|
|
|
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
|
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
2011-10-19 00:37:00 +00:00
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.GameMode;
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.util.Vector;
|
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
@CommandPermissions(level = PlayerRank.SUPER_ADMIN, source = SourceType.BOTH)
|
2014-05-05 13:31:12 +00:00
|
|
|
@CommandParameters(description = "POW!!! Right in the kisser! One of these days Alice, straight to the Moon!",
|
|
|
|
usage = "/<command> <target> [<<power> | stop>]")
|
2015-10-19 17:43:46 +00:00
|
|
|
public class Command_orbit extends FreedomCommand
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
|
|
{
|
2012-11-24 01:22:52 +00:00
|
|
|
if (args.length == 0)
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2012-11-24 01:22:52 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-04-26 11:55:24 +00:00
|
|
|
Player player = getPlayer(args[0]);
|
2014-05-04 21:03:34 +00:00
|
|
|
|
2014-04-26 11:55:24 +00:00
|
|
|
if (player == null)
|
2012-11-24 01:22:52 +00:00
|
|
|
{
|
2015-10-19 17:43:46 +00:00
|
|
|
playerMsg(FreedomCommand.PLAYER_NOT_FOUND, ChatColor.RED);
|
2012-11-24 01:22:52 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
FPlayer playerdata = plugin.pl.getPlayer(player);
|
2012-11-24 01:22:52 +00:00
|
|
|
|
|
|
|
double strength = 10.0;
|
|
|
|
|
|
|
|
if (args.length >= 2)
|
|
|
|
{
|
2014-05-05 13:31:12 +00:00
|
|
|
if (args[1].equals("stop"))
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2013-08-14 14:01:42 +00:00
|
|
|
playerMsg("Stopped orbiting " + player.getName());
|
2012-11-24 01:22:52 +00:00
|
|
|
playerdata.stopOrbiting();
|
|
|
|
return true;
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
|
|
|
|
2011-10-19 02:52:32 +00:00
|
|
|
try
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2012-11-24 01:22:52 +00:00
|
|
|
strength = Math.max(1.0, Math.min(150.0, Double.parseDouble(args[1])));
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
2013-08-14 13:28:19 +00:00
|
|
|
catch (NumberFormatException ex)
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2013-08-14 13:28:19 +00:00
|
|
|
playerMsg(ex.getMessage(), ChatColor.RED);
|
2011-10-19 02:52:32 +00:00
|
|
|
return true;
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
2012-11-24 01:22:52 +00:00
|
|
|
}
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2013-08-14 14:01:42 +00:00
|
|
|
player.setGameMode(GameMode.SURVIVAL);
|
2012-11-24 01:22:52 +00:00
|
|
|
playerdata.startOrbiting(strength);
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2013-08-14 14:01:42 +00:00
|
|
|
player.setVelocity(new Vector(0, strength, 0));
|
2015-10-19 17:43:46 +00:00
|
|
|
FUtil.adminAction(sender.getName(), "Orbiting " + player.getName(), false);
|
2011-10-19 00:37:00 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|