mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Added /onlinemode command.
This commit is contained in:
parent
5c86bf4d0f
commit
bf13858d47
@ -0,0 +1,71 @@
|
|||||||
|
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||||
|
|
||||||
|
import me.StevenLawson.TotalFreedomMod.TFM_Log;
|
||||||
|
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||||
|
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||||
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import net.minecraft.server.PropertyManager;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class Command_onlinemode extends TFM_Command
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (!senderIsConsole)
|
||||||
|
{
|
||||||
|
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length < 1)
|
||||||
|
{
|
||||||
|
sender.sendMessage("Server is currently running with 'online-mode=" + (server.getOnlineMode() ? "true" : "false") + "'.");
|
||||||
|
sender.sendMessage("Use \"/onlinemode on\" and \"/onlinemode off\" to change online mode.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
boolean online_mode;
|
||||||
|
|
||||||
|
if (args[0].equalsIgnoreCase("on"))
|
||||||
|
{
|
||||||
|
online_mode = true;
|
||||||
|
}
|
||||||
|
else if (args[0].equalsIgnoreCase("off"))
|
||||||
|
{
|
||||||
|
online_mode = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PropertyManager prop_man = MinecraftServer.getServer().getPropertyManager();
|
||||||
|
prop_man.a("online-mode", online_mode);
|
||||||
|
prop_man.savePropertiesFile();
|
||||||
|
|
||||||
|
if (online_mode)
|
||||||
|
{
|
||||||
|
for (Player p : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
p.kickPlayer("Server is activating \"online-mode=true\". Please reconnect.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TFM_Util.adminAction(sender.getName(), "Switched 'online-mode=" + (server.getOnlineMode() ? "true" : "false") + "'.", true);
|
||||||
|
|
||||||
|
server.reload();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
TFM_Log.severe(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -409,7 +409,7 @@ public class TFM_PlayerListener implements Listener
|
|||||||
|
|
||||||
if (block_command)
|
if (block_command)
|
||||||
{
|
{
|
||||||
TFM_Util.autoEject(p, "That command is prohibited.");
|
TFM_Util.autoEject(p, "You used a prohibited command: " + command);
|
||||||
TFM_Util.bcastMsg(p.getName() + " was automatically kicked for using harmful commands.", ChatColor.RED);
|
TFM_Util.bcastMsg(p.getName() + " was automatically kicked for using harmful commands.", ChatColor.RED);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -110,6 +110,9 @@ commands:
|
|||||||
nonuke:
|
nonuke:
|
||||||
description: Superadmin command - Attempt to detect "invisible griefers" and "nukers".
|
description: Superadmin command - Attempt to detect "invisible griefers" and "nukers".
|
||||||
usage: /<command> <on | off> [range] [blockrate]
|
usage: /<command> <on | off> [range] [blockrate]
|
||||||
|
onlinemode:
|
||||||
|
description: Console command - Switch server online-mode on and off.
|
||||||
|
usage: /<command> <on | off>
|
||||||
op:
|
op:
|
||||||
description: Makes a player operator
|
description: Makes a player operator
|
||||||
usage: /<command> <playername>
|
usage: /<command> <playername>
|
||||||
|
Loading…
Reference in New Issue
Block a user