Search in sources :

Example 1 with PlayerManager

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

the class PeekCommand method execute.

private static int execute(CommandContext<ServerCommandSource> context, boolean isEnderChest) throws CommandSyntaxException {
    ServerCommandSource source = context.getSource();
    PlayerManager playerManager = source.getServer().getPlayerManager();
    GameProfile targetPlayerProfile = GameProfileArgumentType.getProfileArgument(context, "player").iterator().next();
    ServerPlayerEntity targetPlayer = playerManager.getPlayer(targetPlayerProfile.getName());
    ServerPlayerEntity executingPlayer = source.getPlayer();
    if (targetPlayer == null) {
        targetPlayer = playerManager.createPlayer(targetPlayerProfile);
        NbtCompound targetPlayerData = playerManager.loadPlayerData(targetPlayer);
        if (targetPlayerData == null) {
            source.sendError(Text.of("Targeted player's data could not be found. Was he ever in this world?"));
            return 0;
        }
        @SuppressWarnings("deprecation") ServerWorld world = source.getServer().getWorld(DimensionType.worldFromDimensionNbt(new Dynamic<>(NbtOps.INSTANCE, targetPlayerData.get("Dimension"))).result().orElseThrow());
        if (world != null)
            targetPlayer.setWorld(world);
    }
    if (isEnderChest) {
        showEnderChest(executingPlayer, targetPlayer);
    } else {
        showInventory(executingPlayer, targetPlayer);
    }
    return 1;
}
Also used : ServerWorld(net.minecraft.server.world.ServerWorld) Dynamic(com.mojang.serialization.Dynamic) NbtCompound(net.minecraft.nbt.NbtCompound) PlayerManager(net.minecraft.server.PlayerManager) GameProfile(com.mojang.authlib.GameProfile) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) ServerCommandSource(net.minecraft.server.command.ServerCommandSource)

Example 2 with PlayerManager

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

the class FabricServer method checkPlayerPermissions.

@Override
public Set<String> checkPlayerPermissions(String player, Set<String> perms) {
    PlayerManager scm = server.getPlayerManager();
    if (scm == null)
        return Collections.emptySet();
    BannedPlayerList bl = scm.getUserBanList();
    if (bl == null)
        return Collections.emptySet();
    if (bl.contains(getProfileByName(player))) {
        return Collections.emptySet();
    }
    Set<String> rslt = plugin.hasOfflinePermissions(player, perms);
    if (rslt == null) {
        rslt = new HashSet<String>();
        if (plugin.isOp(player)) {
            rslt.addAll(perms);
        }
    }
    return rslt;
}
Also used : BannedPlayerList(net.minecraft.server.BannedPlayerList) PlayerManager(net.minecraft.server.PlayerManager)

Example 3 with PlayerManager

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

the class FabricServer method checkPlayerPermissions.

@Override
public Set<String> checkPlayerPermissions(String player, Set<String> perms) {
    PlayerManager scm = server.getPlayerManager();
    if (scm == null)
        return Collections.emptySet();
    BannedPlayerList bl = scm.getUserBanList();
    if (bl == null)
        return Collections.emptySet();
    if (bl.contains(getProfileByName(player))) {
        return Collections.emptySet();
    }
    Set<String> rslt = plugin.hasOfflinePermissions(player, perms);
    if (rslt == null) {
        rslt = new HashSet<String>();
        if (plugin.isOp(player)) {
            rslt.addAll(perms);
        }
    }
    return rslt;
}
Also used : BannedPlayerList(net.minecraft.server.BannedPlayerList) PlayerManager(net.minecraft.server.PlayerManager)

Example 4 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 5 with PlayerManager

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

the class FabricServer method checkPlayerPermissions.

@Override
public Set<String> checkPlayerPermissions(String player, Set<String> perms) {
    PlayerManager scm = server.getPlayerManager();
    if (scm == null)
        return Collections.emptySet();
    BannedPlayerList bl = scm.getUserBanList();
    if (bl == null)
        return Collections.emptySet();
    if (bl.contains(getProfileByName(player))) {
        return Collections.emptySet();
    }
    Set<String> rslt = plugin.hasOfflinePermissions(player, perms);
    if (rslt == null) {
        rslt = new HashSet<String>();
        if (plugin.isOp(player)) {
            rslt.addAll(perms);
        }
    }
    return rslt;
}
Also used : BannedPlayerList(net.minecraft.server.BannedPlayerList) PlayerManager(net.minecraft.server.PlayerManager)

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