2016-03-02 19:28:01 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.command;
|
2015-10-19 17:43:46 +00:00
|
|
|
|
2019-01-29 04:57:41 +00:00
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
2015-10-19 17:43:46 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
2016-03-06 15:56:15 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
2015-10-19 17:43:46 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
2016-03-06 15:56:15 +00:00
|
|
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
|
2018-01-07 19:33:58 +00:00
|
|
|
@CommandParameters(description = "Close server to non-admins.", usage = "/<command> [on | off]")
|
2015-10-19 17:43:46 +00:00
|
|
|
public class Command_adminmode extends FreedomCommand
|
|
|
|
{
|
2015-11-22 18:26:47 +00:00
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
@Override
|
2015-11-22 18:26:47 +00:00
|
|
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
2015-10-19 17:43:46 +00:00
|
|
|
{
|
|
|
|
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);
|
2018-01-07 19:33:58 +00:00
|
|
|
FUtil.adminAction(sender.getName(), "Closing the server to non-admins.", true);
|
2015-10-19 17:43:46 +00:00
|
|
|
for (Player player : server.getOnlinePlayers())
|
|
|
|
{
|
|
|
|
if (!isAdmin(player))
|
|
|
|
{
|
2018-01-07 19:33:58 +00:00
|
|
|
player.kickPlayer("Server is now closed to non-admins.");
|
2015-10-19 17:43:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2019-01-29 04:57:41 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
|
|
|
{
|
|
|
|
if (args.length == 1 && plugin.al.isAdmin(sender) && !(sender instanceof Player))
|
|
|
|
{
|
|
|
|
return Arrays.asList("on", "off");
|
|
|
|
}
|
|
|
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
}
|
2015-10-19 17:43:46 +00:00
|
|
|
}
|