Mineplex2018-withcommit/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/GameCmdModeCommand.java

62 lines
1.3 KiB
Java

package nautilus.game.arcade.command;
import java.io.File;
import java.io.IOException;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import nautilus.game.arcade.ArcadeManager;
/**
* A command to toggle this server's game command mode state.
*/
public class GameCmdModeCommand extends CommandBase<ArcadeManager>
{
public GameCmdModeCommand(ArcadeManager plugin)
{
super(plugin, Rank.JNR_DEV, "gamecmdmode");
}
@Override
public void Execute(Player caller, String[] args)
{
File file = new File(ArcadeManager.GAME_CMD_MODE_FILE);
if (Plugin.isGameCommandMode())
{
// Disable game command mode.
if (file.exists())
{
file.delete();
}
Plugin.setGameCommandMode(false);
caller.sendMessage(F.main("Server", "Game commands are now " + C.cRed + "disabled" +
C.cGray + "."));
}
else
{
// Enable game command mode.
if (!file.exists())
{
try
{
file.createNewFile();
}
catch (IOException e)
{
e.printStackTrace();
}
}
Plugin.setGameCommandMode(true);
caller.sendMessage(F.main("Server", "Game commands are now " + C.cGreen + "enabled" +
C.cGray + "."));
}
}
}