Search in sources :

Example 11 with PlayerManager

use of net.minecraft.server.PlayerManager in project dynmap by webbukkit.

the class FabricServer method isPlayerBanned.

@Override
public boolean isPlayerBanned(String pid) {
    PlayerManager scm = server.getPlayerManager();
    BannedPlayerList bl = scm.getUserBanList();
    try {
        return bl.contains(getProfileByName(pid).get());
    } catch (NoSuchElementException e) {
        /* If this profile doesn't exist, default to "banned" for good measure. */
        return true;
    }
}
Also used : BannedPlayerList(net.minecraft.server.BannedPlayerList) PlayerManager(net.minecraft.server.PlayerManager)

Example 12 with PlayerManager

use of net.minecraft.server.PlayerManager in project dynmap by webbukkit.

the class FabricServer method checkPlayerPermission.

@Override
public boolean checkPlayerPermission(String player, String perm) {
    PlayerManager scm = server.getPlayerManager();
    if (scm == null)
        return false;
    BannedPlayerList bl = scm.getUserBanList();
    if (bl == null)
        return false;
    if (bl.contains(getProfileByName(player))) {
        return false;
    }
    return plugin.hasOfflinePermission(player, perm);
}
Also used : BannedPlayerList(net.minecraft.server.BannedPlayerList) PlayerManager(net.minecraft.server.PlayerManager)

Example 13 with PlayerManager

use of net.minecraft.server.PlayerManager in project Rug by RubixDev.

the class SudoCommand method register.

public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
    LiteralArgumentBuilder<ServerCommandSource> command = literal("sudo").requires((player) -> SettingsManager.canUseCommand(player, RugSettings.commandSudo)).then(argument("player", StringArgumentType.word()).suggests(((context, builder) -> suggestMatching(getPlayers(context.getSource()), builder))).then(literal("chat").then(argument("message", StringArgumentType.greedyString()).executes(context -> {
        String targetPlayerName = StringArgumentType.getString(context, "player");
        MinecraftServer server = context.getSource().getServer();
        PlayerManager playerManager = server.getPlayerManager();
        ServerPlayerEntity targetPlayer = playerManager.getPlayer(targetPlayerName);
        if (targetPlayer == null) {
            context.getSource().sendError(new LiteralText("Targeted Player could not be found"));
            return 0;
        }
        Text text = new TranslatableText("chat.type.text", targetPlayerName, StringArgumentType.getString(context, "message"));
        playerManager.broadcast(text, MessageType.CHAT, targetPlayer.getUuid());
        return 1;
    }))).then(literal("command").redirect(dispatcher.getRoot(), context -> {
        String targetPlayerName = StringArgumentType.getString(context, "player");
        MinecraftServer server = context.getSource().getServer();
        ServerPlayerEntity player = server.getPlayerManager().getPlayer(targetPlayerName);
        if (player == null) {
            Message errorMessage = new LiteralText("Targeted player could not be found");
            throw new CommandSyntaxException(new SimpleCommandExceptionType(errorMessage), errorMessage);
        }
        return player.getCommandSource();
    })));
    dispatcher.register(command);
}
Also used : LiteralText(net.minecraft.text.LiteralText) CommandDispatcher(com.mojang.brigadier.CommandDispatcher) ServerCommandSource(net.minecraft.server.command.ServerCommandSource) Collection(java.util.Collection) SettingsManager(carpet.settings.SettingsManager) MessageType(net.minecraft.network.MessageType) PlayerManager(net.minecraft.server.PlayerManager) TranslatableText(net.minecraft.text.TranslatableText) RugSettings(de.rubixdev.rug.RugSettings) CommandManager.literal(net.minecraft.server.command.CommandManager.literal) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) SimpleCommandExceptionType(com.mojang.brigadier.exceptions.SimpleCommandExceptionType) CommandManager.argument(net.minecraft.server.command.CommandManager.argument) StringArgumentType(com.mojang.brigadier.arguments.StringArgumentType) MinecraftServer(net.minecraft.server.MinecraftServer) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) CommandSource.suggestMatching(net.minecraft.command.CommandSource.suggestMatching) Message(com.mojang.brigadier.Message) Text(net.minecraft.text.Text) CommandSyntaxException(com.mojang.brigadier.exceptions.CommandSyntaxException) TranslatableText(net.minecraft.text.TranslatableText) Message(com.mojang.brigadier.Message) PlayerManager(net.minecraft.server.PlayerManager) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) LiteralText(net.minecraft.text.LiteralText) TranslatableText(net.minecraft.text.TranslatableText) Text(net.minecraft.text.Text) ServerCommandSource(net.minecraft.server.command.ServerCommandSource) MinecraftServer(net.minecraft.server.MinecraftServer) SimpleCommandExceptionType(com.mojang.brigadier.exceptions.SimpleCommandExceptionType) CommandSyntaxException(com.mojang.brigadier.exceptions.CommandSyntaxException) LiteralText(net.minecraft.text.LiteralText)

Aggregations

PlayerManager (net.minecraft.server.PlayerManager)13 BannedPlayerList (net.minecraft.server.BannedPlayerList)9 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)3 ServerCommandSource (net.minecraft.server.command.ServerCommandSource)2 SettingsManager (carpet.settings.SettingsManager)1 GameProfile (com.mojang.authlib.GameProfile)1 CommandDispatcher (com.mojang.brigadier.CommandDispatcher)1 Message (com.mojang.brigadier.Message)1 StringArgumentType (com.mojang.brigadier.arguments.StringArgumentType)1 LiteralArgumentBuilder (com.mojang.brigadier.builder.LiteralArgumentBuilder)1 CommandSyntaxException (com.mojang.brigadier.exceptions.CommandSyntaxException)1 SimpleCommandExceptionType (com.mojang.brigadier.exceptions.SimpleCommandExceptionType)1 Dynamic (com.mojang.serialization.Dynamic)1 Actor (com.sk89q.worldedit.extension.platform.Actor)1 RugSettings (de.rubixdev.rug.RugSettings)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 CommandSource.suggestMatching (net.minecraft.command.CommandSource.suggestMatching)1 NbtCompound (net.minecraft.nbt.NbtCompound)1 MessageType (net.minecraft.network.MessageType)1