Search in sources :

Example 21 with ServerCommandSource

use of net.minecraft.server.command.ServerCommandSource in project LuckPerms by lucko.

the class PermissionCheckListener method onOtherPermissionCheck.

private TriState onOtherPermissionCheck(CommandSource source, String permission) {
    if (source instanceof ServerCommandSource) {
        String name = ((ServerCommandSource) source).getName();
        VerboseCheckTarget target = VerboseCheckTarget.internal(name);
        this.plugin.getVerboseHandler().offerPermissionCheckEvent(CheckOrigin.PLATFORM_API_HAS_PERMISSION, target, QueryOptionsImpl.DEFAULT_CONTEXTUAL, permission, TristateResult.UNDEFINED);
        this.plugin.getPermissionRegistry().offer(permission);
    }
    return TriState.DEFAULT;
}
Also used : VerboseCheckTarget(me.lucko.luckperms.common.verbose.VerboseCheckTarget) ServerCommandSource(net.minecraft.server.command.ServerCommandSource)

Example 22 with ServerCommandSource

use of net.minecraft.server.command.ServerCommandSource in project quilt-standard-libraries by QuiltMC.

the class NetworkingChannelTest method infoCommand.

private static int infoCommand(CommandContext<ServerCommandSource> context, ServerPlayerEntity player) {
    ServerCommandSource source = context.getSource();
    Set<Identifier> channels = ServerPlayNetworking.getSendable(player);
    source.sendFeedback(new LiteralText(String.format("Available channels for player %s", player.getEntityName())), false);
    for (Identifier channel : channels) {
        source.sendFeedback(new LiteralText(channel.toString()), false);
    }
    return 1;
}
Also used : IdentifierArgumentType.getIdentifier(net.minecraft.command.argument.IdentifierArgumentType.getIdentifier) Identifier(net.minecraft.util.Identifier) ServerCommandSource(net.minecraft.server.command.ServerCommandSource) LiteralText(net.minecraft.text.LiteralText)

Example 23 with ServerCommandSource

use of net.minecraft.server.command.ServerCommandSource in project pingspam by BasiqueEvangelist.

the class PingSoundCommand method removePingSound.

private static int removePingSound(CommandContext<ServerCommandSource> ctx) throws CommandSyntaxException {
    ServerCommandSource src = ctx.getSource();
    ServerPlayerEntity player = src.getPlayer();
    PlayerUtils.setPingSound(player, null);
    src.sendFeedback(new LiteralText("Disabled ping sound.").formatted(Formatting.GREEN), false);
    return 0;
}
Also used : ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) ServerCommandSource(net.minecraft.server.command.ServerCommandSource) LiteralText(net.minecraft.text.LiteralText)

Example 24 with ServerCommandSource

use of net.minecraft.server.command.ServerCommandSource in project pingspam by BasiqueEvangelist.

the class PingSoundCommand method setPingSound.

private static int setPingSound(CommandContext<ServerCommandSource> ctx) throws CommandSyntaxException {
    ServerCommandSource src = ctx.getSource();
    ServerPlayerEntity player = src.getPlayer();
    Identifier soundId = IdentifierArgumentType.getIdentifier(ctx, "sound");
    SoundEvent event = Registry.SOUND_EVENT.getOrEmpty(soundId).orElseThrow(INVALID_SOUND::create);
    PlayerUtils.setPingSound(player, event);
    src.sendFeedback(new LiteralText("Set ping sound to ").formatted(Formatting.GREEN).append(new LiteralText(((SoundEventAccessor) PlayerUtils.getPingSound(player)).pingspam$getId().toString()).formatted(Formatting.YELLOW)).append(new LiteralText(".")), false);
    return 0;
}
Also used : SoundEvent(net.minecraft.sound.SoundEvent) Identifier(net.minecraft.util.Identifier) SoundEventAccessor(me.basiqueevangelist.pingspam.mixin.SoundEventAccessor) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) ServerCommandSource(net.minecraft.server.command.ServerCommandSource) LiteralText(net.minecraft.text.LiteralText)

Example 25 with ServerCommandSource

use of net.minecraft.server.command.ServerCommandSource in project pingspam by BasiqueEvangelist.

the class PingSoundCommand method getPingSound.

private static int getPingSound(CommandContext<ServerCommandSource> ctx) throws CommandSyntaxException {
    ServerCommandSource src = ctx.getSource();
    ServerPlayerEntity player = src.getPlayer();
    if (PlayerUtils.getPingSound(player) != null) {
        src.sendFeedback(new LiteralText("Your current ping sound is ").formatted(Formatting.GREEN).append(new LiteralText(((SoundEventAccessor) PlayerUtils.getPingSound(player)).pingspam$getId().toString()).formatted(Formatting.YELLOW)).append(new LiteralText(".")), false);
    } else {
        src.sendFeedback(new LiteralText("You have disabled ping sounds.").formatted(Formatting.GREEN), false);
    }
    return 0;
}
Also used : SoundEventAccessor(me.basiqueevangelist.pingspam.mixin.SoundEventAccessor) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) ServerCommandSource(net.minecraft.server.command.ServerCommandSource) LiteralText(net.minecraft.text.LiteralText)

Aggregations

ServerCommandSource (net.minecraft.server.command.ServerCommandSource)43 LiteralText (net.minecraft.text.LiteralText)35 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)33 CommandDispatcher (com.mojang.brigadier.CommandDispatcher)14 CommandManager.literal (net.minecraft.server.command.CommandManager.literal)11 LiteralArgumentBuilder (com.mojang.brigadier.builder.LiteralArgumentBuilder)9 CommandManager.argument (net.minecraft.server.command.CommandManager.argument)9 Extensions (com.kahzerx.kahzerxmod.Extensions)7 GenericExtension (com.kahzerx.kahzerxmod.extensions.GenericExtension)7 CommandSyntaxException (com.mojang.brigadier.exceptions.CommandSyntaxException)6 UUID (java.util.UUID)6 CommandManager (net.minecraft.server.command.CommandManager)6 ExtensionSettings (com.kahzerx.kahzerxmod.extensions.ExtensionSettings)5 IntegerArgumentType (com.mojang.brigadier.arguments.IntegerArgumentType)5 StringArgumentType (com.mojang.brigadier.arguments.StringArgumentType)5 MinecraftServer (net.minecraft.server.MinecraftServer)5 ExtensionManager (com.kahzerx.kahzerxmod.ExtensionManager)4 GameProfile (com.mojang.authlib.GameProfile)4 ClickEvent (net.minecraft.text.ClickEvent)4 MutableText (net.minecraft.text.MutableText)4