36 lines
1.9 KiB
Java
36 lines
1.9 KiB
Java
package net.minecraft.server.commands;
|
|
|
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
|
import net.minecraft.network.chat.Style;
|
|
import net.minecraft.network.chat.ComponentUtils;
|
|
import net.minecraft.network.chat.Component;
|
|
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) {
|
|
commandDispatcher.register((LiteralArgumentBuilder)((LiteralArgumentBuilder)Commands.literal("seed").requires(cq -> cq.getServer().isSingleplayer() || cq.hasPermission(2))).executes(commandContext -> {
|
|
final long long2 = ((CommandSourceStack)commandContext.getSource()).getLevel().getSeed();
|
|
final long n;
|
|
final HoverEvent hoverEvent;
|
|
final Style style;
|
|
final Component lf4 = ComponentUtils.wrapInSquareBrackets(new TextComponent(String.valueOf(long2)).withStyle(ln -> {
|
|
ln.setColor(ChatFormatting.GREEN).setClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, String.valueOf(n)));
|
|
new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslatableComponent("chat.copy.click", new Object[0]));
|
|
style.setHoverEvent(hoverEvent).setInsertion(String.valueOf(n));
|
|
return;
|
|
}));
|
|
((CommandSourceStack)commandContext.getSource()).sendSuccess(new TranslatableComponent("commands.seed.success", new Object[] { lf4 }), false);
|
|
return (int)long2;
|
|
}));
|
|
}
|
|
}
|