TFM-4.3-Reloaded/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_adminmode.java

38 lines
1.2 KiB
Java
Raw Normal View History

2022-03-20 12:35:43 +00:00
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;
2022-03-22 18:01:37 +00:00
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH, blockHostConsole = true)
2022-03-20 12:35:43 +00:00
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;
}
2022-03-20 12:35:43 +00:00
if (args[0].equalsIgnoreCase("off")) {
ConfigurationEntry.ADMIN_ONLY_MODE.setBoolean(false);
Utilities.adminAction(sender.getName(), "Deactivating adminmode.", true);
return true;
} else if (args[0].equalsIgnoreCase("on")) {
ConfigurationEntry.ADMIN_ONLY_MODE.setBoolean(true);
Utilities.adminAction(sender.getName(), "Activating adminmode.", true);
for (Player player : server.getOnlinePlayers()) {
if (!AdminList.isSuperAdmin(player)) {
player.kickPlayer("Server is now in adminmode.");
}
}
return true;
}
return false;
}
2022-03-20 12:35:43 +00:00
}