Skip to content

Commit

Permalink
Cleanup secure seed command
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreeam-qwq committed Mar 30, 2024
1 parent 16ef939 commit c4ef047
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions patches/server/0084-Matter-Seed-Command.patch
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,34 @@ Original license: GPLv3
Original project: https://github.com/plasmoapp/matter

diff --git a/src/main/java/net/minecraft/server/commands/SeedCommand.java b/src/main/java/net/minecraft/server/commands/SeedCommand.java
index 342362c217df5476a927eb54cef3cafcea3889fd..5f426ea20cd777f007212978402edf9af056fc54 100644
index 342362c217df5476a927eb54cef3cafcea3889fd..a05e0d998fffd8a50643f118b2ddf4af6804cc14 100644
--- a/src/main/java/net/minecraft/server/commands/SeedCommand.java
+++ b/src/main/java/net/minecraft/server/commands/SeedCommand.java
@@ -6,17 +6,37 @@ import net.minecraft.commands.Commands;
@@ -6,6 +6,10 @@ import net.minecraft.commands.Commands;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.ComponentUtils;

+// Leaf start - Matter - Feature Secure Seed
+import net.minecraft.ChatFormatting;
+import net.minecraft.network.chat.ClickEvent;
+import net.minecraft.network.chat.HoverEvent;
+import su.plo.matter.Globals;
+// Leaf end - Matter
+
public class SeedCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean dedicated) {
dispatcher.register(Commands.literal("seed").requires((source) -> {
return !dedicated || source.hasPermission(2);
}).executes((context) -> {
long l = context.getSource().getLevel().getSeed();
- Component component = ComponentUtils.copyOnClickText(String.valueOf(l));
- context.getSource().sendSuccess(() -> {
- return Component.translatable("commands.seed.success", component);
- }, false);
@@ -16,7 +20,19 @@ public class SeedCommand {
context.getSource().sendSuccess(() -> {
return Component.translatable("commands.seed.success", component);
}, false);
- return (int)l;
+
+ // Leaf start - Matter - SecureSeed Command
+ if (org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
+ Globals.setupGlobals(context.getSource().getLevel());
+ String seedStr = Globals.seedToString(Globals.worldSeed);
+
+ Component seedComponent = ComponentUtils.wrapInSquareBrackets(Component.literal(String.valueOf(l)).withStyle((style) -> style.withColor(ChatFormatting.GREEN).withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, String.valueOf(l))).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.translatable("chat.copy.click"))).withInsertion(String.valueOf(l))));
+ Component featureSeedComponent = ComponentUtils.wrapInSquareBrackets(Component.translatable("chat.copy.click").withStyle((style) -> style.withColor(ChatFormatting.GREEN).withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, seedStr)).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.translatable("chat.copy.click"))).withInsertion(seedStr)));
+ Component featureSeedComponent = ComponentUtils.copyOnClickText(seedStr);
+
+ context.getSource().sendSuccess(() -> Component.translatable("commands.seed.success", seedComponent), false);
+ context.getSource().sendSuccess(() -> Component.translatable(("Feature seed: %s"), featureSeedComponent), false);
+ } else {
+ Component component = ComponentUtils.copyOnClickText(String.valueOf(l));
+ context.getSource().sendSuccess(() -> Component.translatable("commands.seed.success", component), false);
+ }
+ // Leaf end - Matter
+
Expand Down

0 comments on commit c4ef047

Please sign in to comment.