2011-10-19 00:37:00 +00:00
|
|
|
package me.StevenLawson.TotalFreedomMod.Commands;
|
|
|
|
|
2012-11-13 01:42:30 +00:00
|
|
|
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
|
2011-10-19 00:37:00 +00:00
|
|
|
import me.StevenLawson.TotalFreedomMod.TFM_UserInfo;
|
|
|
|
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
|
|
|
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
|
|
|
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;
|
|
|
|
|
|
|
|
public class Command_orbit extends TFM_Command
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
|
|
{
|
2012-11-13 01:42:30 +00:00
|
|
|
if (senderIsConsole || TFM_SuperadminList.isUserSuperadmin(sender))
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
|
|
|
if (args.length == 0)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
Player p;
|
2011-10-19 02:52:32 +00:00
|
|
|
try
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2011-10-19 02:52:32 +00:00
|
|
|
p = getPlayer(args[0]);
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
2011-10-19 02:52:32 +00:00
|
|
|
catch (CantFindPlayerException ex)
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2011-10-19 02:52:32 +00:00
|
|
|
sender.sendMessage(ex.getMessage());
|
|
|
|
return true;
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
|
|
|
|
2011-11-08 00:29:33 +00:00
|
|
|
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
|
2011-10-19 00:37:00 +00:00
|
|
|
|
|
|
|
double strength = 10.0;
|
|
|
|
|
|
|
|
if (args.length >= 2)
|
|
|
|
{
|
2011-11-07 13:11:13 +00:00
|
|
|
if (TFM_Util.isStopCommand(args[1]))
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
|
|
|
sender.sendMessage(ChatColor.GRAY + "Stopped orbiting " + p.getName());
|
|
|
|
playerdata.stopOrbiting();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2011-10-19 02:52:32 +00:00
|
|
|
strength = Math.max(1.0, Math.min(150.0, Double.parseDouble(args[1])));
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
|
|
|
catch (NumberFormatException nfex)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
p.setGameMode(GameMode.SURVIVAL);
|
|
|
|
playerdata.startOrbiting(strength);
|
|
|
|
|
|
|
|
p.setVelocity(new Vector(0, strength, 0));
|
|
|
|
|
|
|
|
sender.sendMessage(ChatColor.GRAY + "Orbiting " + p.getName());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|