mirror of
https://github.com/TheDeus-Group/TFM-4.3-Reloaded.git
synced 2024-05-17 12:11:17 +00:00
41 lines
1.6 KiB
Java
41 lines
1.6 KiB
Java
package me.StevenLawson.TotalFreedomMod.commands;
|
|
|
|
import me.StevenLawson.TotalFreedomMod.admin.AdminList;
|
|
import me.StevenLawson.TotalFreedomMod.config.ConfigurationEntry;
|
|
import me.StevenLawson.TotalFreedomMod.util.Utilities;
|
|
import org.bukkit.command.Command;
|
|
import org.bukkit.command.CommandSender;
|
|
import org.bukkit.entity.Player;
|
|
|
|
@CommandPermissions(level = AdminLevel.SUPER, 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, org.bukkit.entity.Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
|
|
if (args.length != 1) {
|
|
return false;
|
|
}
|
|
|
|
if (args[0].equalsIgnoreCase("off")) {
|
|
ConfigurationEntry.ADMIN_ONLY_MODE.setBoolean(false);
|
|
Utilities.adminAction(sender.getName(), "Opening the server to all players.", true);
|
|
return true;
|
|
}
|
|
else if (args[0].equalsIgnoreCase("on"))
|
|
{
|
|
ConfigurationEntry.ADMIN_ONLY_MODE.setBoolean(true);
|
|
Utilities.adminAction(sender.getName(), "Closing the server to non-superadmins.", true);
|
|
for (Player player : server.getOnlinePlayers())
|
|
{
|
|
if (!AdminList.isSuperAdmin(player))
|
|
{
|
|
player.kickPlayer("Server is now closed to non-superadmins.");
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|