mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-17 04:46:11 +00:00
a0058869c9
Moved resources to correct folder Fixed and improved build information, no longer tracking build.properties
46 lines
1.6 KiB
Java
46 lines
1.6 KiB
Java
package me.totalfreedom.totalfreedommod.commands;
|
|
|
|
import me.totalfreedom.totalfreedommod.rank.PlayerRank;
|
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
import org.bukkit.command.Command;
|
|
import org.bukkit.command.CommandSender;
|
|
import org.bukkit.entity.Player;
|
|
|
|
@CommandPermissions(level = PlayerRank.SUPER_ADMIN, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
|
|
@CommandParameters(description = "Close server to non-superadmins.", usage = "/<command> [on | off]")
|
|
public class Command_adminmode extends FreedomCommand
|
|
{
|
|
|
|
@Override
|
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
{
|
|
if (args.length != 1)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (args[0].equalsIgnoreCase("off"))
|
|
{
|
|
ConfigEntry.ADMIN_ONLY_MODE.setBoolean(false);
|
|
FUtil.adminAction(sender.getName(), "Opening the server to all players.", true);
|
|
return true;
|
|
}
|
|
else if (args[0].equalsIgnoreCase("on"))
|
|
{
|
|
ConfigEntry.ADMIN_ONLY_MODE.setBoolean(true);
|
|
FUtil.adminAction(sender.getName(), "Closing the server to non-superadmins.", true);
|
|
for (Player player : server.getOnlinePlayers())
|
|
{
|
|
if (!isAdmin(player))
|
|
{
|
|
player.kickPlayer("Server is now closed to non-superadmins.");
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|