TotalFreedomMod/src/me/totalfreedom/totalfreedommod/commands/Command_survival.java
JeromSar 848f103afa [Bleeding] TotalFreedomMod 5.0
Mass Refractoring, now uses me.totalfreedom.totalfreedommod as package
Uses Aero https://github.com/Pravian/Aero
Revamped command system
Remove all TFM_ prefixes
Revamp rank system
Use new service based system
Cleanup
2015-10-19 19:43:46 +02:00

76 lines
2.4 KiB
Java

package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.permission.PlayerRank;
import me.totalfreedom.totalfreedommod.admin.AdminList;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.GameMode;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = PlayerRank.OP, source = SourceType.BOTH)
@CommandParameters(description = "Quickly change your own gamemode to survival, or define someone's username to change theirs.", usage = "/<command> <[partialname] | -a>", aliases = "gms")
public class Command_survival extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (senderIsConsole)
{
if (args.length == 0)
{
playerMsg("When used from the console, you must define a target user to change gamemode on.");
return true;
}
}
Player player;
if (args.length == 0)
{
player = sender_p;
}
else
{
if (args[0].equalsIgnoreCase("-a"))
{
if (!plugin.al.isAdmin(sender) || senderIsConsole)
{
sender.sendMessage(FreedomCommand.MSG_NO_PERMS);
return true;
}
for (Player targetPlayer : server.getOnlinePlayers())
{
targetPlayer.setGameMode(GameMode.SURVIVAL);
}
FUtil.adminAction(sender.getName(), "Changing everyone's gamemode to survival", false);
return true;
}
if (senderIsConsole || plugin.al.isAdmin(sender))
{
player = getPlayer(args[0]);
if (player == null)
{
playerMsg(FreedomCommand.PLAYER_NOT_FOUND);
return true;
}
}
else
{
playerMsg("Only superadmins can change other user's gamemode.");
return true;
}
}
playerMsg("Setting " + player.getName() + " to game mode 'Survival'.");
player.sendMessage(sender.getName() + " set your game mode to 'Survival'.");
player.setGameMode(GameMode.SURVIVAL);
return true;
}
}