TFM-4.3-Reloaded/src/me/StevenLawson/TotalFreedomMod/Commands/Command_orbit.java

66 lines
1.8 KiB
Java
Raw Normal View History

2011-10-19 00:37:00 +00:00
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_UserInfo;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
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;
@CommandPermissions(level = ADMIN_LEVEL.SUPER, source = SOURCE_TYPE_ALLOWED.BOTH, ignore_permissions = false)
2011-10-19 00:37:00 +00:00
public class Command_orbit extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length == 0)
2011-10-19 00:37:00 +00:00
{
return false;
}
Player p;
try
{
p = getPlayer(args[0]);
}
catch (CantFindPlayerException ex)
{
sender.sendMessage(ex.getMessage());
return true;
}
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
double strength = 10.0;
if (args.length >= 2)
{
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;
2011-10-19 00:37:00 +00:00
}
try
2011-10-19 00:37:00 +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)
2011-10-19 00:37:00 +00:00
{
}
}
2011-10-19 00:37:00 +00:00
p.setGameMode(GameMode.SURVIVAL);
playerdata.startOrbiting(strength);
2011-10-19 00:37:00 +00:00
p.setVelocity(new Vector(0, strength, 0));
2011-10-19 00:37:00 +00:00
sender.sendMessage(ChatColor.GRAY + "Orbiting " + p.getName());
2011-10-19 00:37:00 +00:00
return true;
}
}