TotalFreedomMod/src/me/StevenLawson/TotalFreedomMod/Commands/Command_creative.java

54 lines
1.4 KiB
Java
Raw Normal View History

2011-10-19 00:37:00 +00:00
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.GameMode;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Command_creative extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (senderIsConsole)
{
if (args.length == 0)
{
sender.sendMessage("When used from the console, you must define a target user to change gamemode on.");
return true;
}
}
if (!sender.isOp())
2011-10-19 00:37:00 +00:00
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
return true;
2011-10-19 00:37:00 +00:00
}
Player p;
if (args.length == 0)
{
p = sender_p;
2011-10-19 00:37:00 +00:00
}
else
{
try
2011-10-19 00:37:00 +00:00
{
p = getPlayer(args[0]);
2011-10-19 00:37:00 +00:00
}
catch (CantFindPlayerException ex)
2011-10-19 00:37:00 +00:00
{
sender.sendMessage(ex.getMessage());
return true;
2011-10-19 00:37:00 +00:00
}
}
sender.sendMessage("Setting " + p.getName() + " to game mode 'Creative'.");
p.sendMessage(sender.getName() + " set your game mode to 'Creative'.");
p.setGameMode(GameMode.CREATIVE);
return true;
}
}