package net.minecraft.server.commands;

import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.network.chat.Style;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.ComponentUtils;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.network.chat.HoverEvent;
import net.minecraft.network.chat.ClickEvent;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.TextComponent;
import com.mojang.brigadier.context.CommandContext;
import net.minecraft.commands.Commands;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import net.minecraft.commands.CommandSourceStack;
import com.mojang.brigadier.CommandDispatcher;

public class SeedCommand {
    public static void register(final CommandDispatcher<CommandSourceStack> commandDispatcher, final boolean boolean2) {
        commandDispatcher.register((LiteralArgumentBuilder)((LiteralArgumentBuilder)Commands.literal("seed").requires(cz -> !boolean2 || cz.hasPermission(2))).executes(commandContext -> {
            final long long2 = ((CommandSourceStack)commandContext.getSource()).getLevel().getSeed();
            final long n;
            final HoverEvent mv;
            final Style style;
            final Component mr4 = ComponentUtils.wrapInSquareBrackets(new TextComponent(String.valueOf(long2)).withStyle(nb -> {
                nb.withColor(ChatFormatting.GREEN).withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, String.valueOf(n)));
                new HoverEvent((HoverEvent.Action<TranslatableComponent>)HoverEvent.Action.SHOW_TEXT, new TranslatableComponent("chat.copy.click"));
                return style.withHoverEvent(mv).withInsertion(String.valueOf(n));
            }));
            ((CommandSourceStack)commandContext.getSource()).sendSuccess(new TranslatableComponent("commands.seed.success", new Object[] { mr4 }), false);
            return (int)long2;
        }));
    }
}
