mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-16 20:36:12 +00:00
37 lines
1.2 KiB
Java
37 lines
1.2 KiB
Java
package me.totalfreedom.totalfreedommod.command;
|
|
|
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
import org.bukkit.GameMode;
|
|
import org.bukkit.command.Command;
|
|
import org.bukkit.command.CommandSender;
|
|
import org.bukkit.entity.Player;
|
|
|
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
|
@CommandParameters(description = "Op everyone on the server, optionally change everyone's gamemode at the same time.", usage = "/<command> [-c | -s | -a]")
|
|
public class Command_opall extends FreedomCommand
|
|
{
|
|
|
|
@Override
|
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
{
|
|
FUtil.adminAction(sender.getName(), "Opping all players on the server", false);
|
|
|
|
boolean doSetGamemode = false;
|
|
GameMode targetGamemode = GameMode.CREATIVE;
|
|
|
|
for (Player player : server.getOnlinePlayers())
|
|
{
|
|
player.setOp(true);
|
|
player.sendMessage(FreedomCommand.YOU_ARE_OP);
|
|
|
|
if (doSetGamemode && !player.getGameMode().equals(GameMode.SPECTATOR))
|
|
{
|
|
player.setGameMode(targetGamemode);
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|