Java Code Examples for net.minecraft.server.command.ServerCommandSource#hasPermissionLevel()

The following examples show how to use net.minecraft.server.command.ServerCommandSource#hasPermissionLevel() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SettingsManager.java    From fabric-carpet with MIT License 6 votes vote down vote up
public static boolean canUseCommand(ServerCommandSource source, String commandLevel)
{
    switch (commandLevel)
    {
        case "true": return true;
        case "false": return false;
        case "ops": return source.hasPermissionLevel(2); // typical for other cheaty commands
        case "0":
        case "1":
        case "2":
        case "3":
        case "4":
            return source.hasPermissionLevel(Integer.parseInt(commandLevel));
    }
    return false;
}
 
Example 2
Source File: CameraModeCommand.java    From fabric-carpet with MIT License 5 votes vote down vote up
private static boolean iCanHasPermissions(ServerCommandSource source, ServerPlayerEntity player)
{
    try
    {
        return source.hasPermissionLevel(2) || source.getPlayer() == player;
    }
    catch (CommandSyntaxException e)
    {
        return true; // shoudn't happen because server has all permissions anyways
    }
}