Skip to content

Commit

Permalink
Migrate sapphire command to minimessage and fix it on mojang-mapped s…
Browse files Browse the repository at this point in the history
…ervers
  • Loading branch information
DenaryDev committed Jan 30, 2024
1 parent a2ef2ec commit 9ad1b8f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 19 deletions.
27 changes: 19 additions & 8 deletions patches/server/0006-Add-sapphire-command.patch
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ Subject: [PATCH] Add sapphire command

diff --git a/src/main/java/io/sapphiremc/sapphire/SapphireCommand.java b/src/main/java/io/sapphiremc/sapphire/SapphireCommand.java
new file mode 100644
index 0000000000000000000000000000000000000000..c337948c82263af20e55570a2c65288aa0123334
index 0000000000000000000000000000000000000000..bbac30b5411a204a59cf291543f05b3d99cfd766
--- /dev/null
+++ b/src/main/java/io/sapphiremc/sapphire/SapphireCommand.java
@@ -0,0 +1,110 @@
@@ -0,0 +1,121 @@
+package io.sapphiremc.sapphire;
+
+import io.papermc.paper.util.JarManifests;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.minimessage.MiniMessage;
+import net.md_5.bungee.api.ChatColor;
+import net.minecraft.server.MinecraftServer;
+import org.bukkit.Bukkit;
Expand Down Expand Up @@ -58,10 +60,10 @@ index 0000000000000000000000000000000000000000..c337948c82263af20e55570a2c65288a
+ @Override
+ public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] args) {
+ if (!testPermission(sender)) return true;
+ String prefix = ChatColor.of("#004EFF") + "" + ChatColor.BOLD + "Sapphire " + ChatColor.of("#1F2B44") + "▶ " + ChatColor.of("#D4E1FF");
+ final var prefix = "<b><#7C67FF>Sapphire</b> <#919192>▶ <#DDDDFF>";
+
+ if (args.length < 1) {
+ sender.sendMessage(prefix + "Usage: " + usageMessage);
+ sender.sendRichMessage(prefix + "Usage: " + usageMessage);
+ return true;
+ }
+
Expand All @@ -72,13 +74,22 @@ index 0000000000000000000000000000000000000000..c337948c82263af20e55570a2c65288a
+ SapphireConfig.init((File) console.options.valueOf("sapphire-settings"));
+ console.server.reloadCount++;
+
+ sender.sendMessage(prefix + "Sapphire config reload complete, but some functions need you to restart the server.");
+ sender.sendRichMessage(prefix + "Sapphire config reload complete, but some functions need you to restart the server.");
+ }
+ }
+ case "ver", "version" -> {
+ if (args.length == 1) {
+ sender.sendMessage(prefix + "This server is running " + Bukkit.getName() + " version " + Bukkit.getVersion() + " (Git: " + getGitInfo() + ")");
+ sender.sendMessage(prefix + "Implementing API version " + Bukkit.getBukkitVersion() + " and NMS version " + Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3]);
+ sender.sendRichMessage(prefix + "This server is running " + Bukkit.getName() + " version " + Bukkit.getVersion() + " (Git: " + getGitInfo() + ")");
+ final var pkg = Bukkit.getServer().getClass().getPackage().getName().split("\\.");
+ final var nmsVersion = new StringBuilder();
+ if (pkg.length == 3) {
+ nmsVersion.append("Mojang").append(" (").append(Bukkit.getServer().getMinecraftVersion()).append(')');
+ } else if (pkg.length == 4) {
+ nmsVersion.append(pkg[3]);
+ } else {
+ nmsVersion.append("Invalid");
+ }
+ sender.sendRichMessage(prefix + "Implementing API version " + Bukkit.getBukkitVersion() + " with NMS version " + nmsVersion);
+ }
+ }
+ default -> sender.sendMessage(prefix + "Usage: " + usageMessage);
Expand Down Expand Up @@ -121,7 +132,7 @@ index 0000000000000000000000000000000000000000..c337948c82263af20e55570a2c65288a
+ }
+}
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
index fe119ad091e53618906e2e6bc5e2270812f44324..263796f0dbcc240a8eb930367df294a8bbf16c3f 100644
index df333d76cb1f58c1e0314b7941f28cd10eddc283..cf7b821c04db53578a26f1858682ed1a31c2907c 100644
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
@@ -225,6 +225,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
Expand Down
22 changes: 11 additions & 11 deletions patches/server/0008-Chromium-client-support.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,41 @@ Subject: [PATCH] Chromium client support


diff --git a/src/main/java/io/sapphiremc/sapphire/SapphireCommand.java b/src/main/java/io/sapphiremc/sapphire/SapphireCommand.java
index c337948c82263af20e55570a2c65288aa0123334..e59f4a767d04046404c266bafba4ccc400dea306 100644
index bbac30b5411a204a59cf291543f05b3d99cfd766..5b1e2eb6e930d26ee16c1499d9c6533319a74361 100644
--- a/src/main/java/io/sapphiremc/sapphire/SapphireCommand.java
+++ b/src/main/java/io/sapphiremc/sapphire/SapphireCommand.java
@@ -7,6 +7,7 @@ import org.bukkit.Bukkit;
@@ -9,6 +9,7 @@ import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

@@ -63,6 +64,22 @@ public class SapphireCommand extends Command {
sender.sendMessage(prefix + "Sapphire config reload complete, but some functions need you to restart the server.");
@@ -65,6 +66,22 @@ public class SapphireCommand extends Command {
sender.sendRichMessage(prefix + "Sapphire config reload complete, but some functions need you to restart the server.");
}
}
+ case "isChromium" -> {
+ if (args.length == 2) {
+ Player player = Bukkit.getServer().getPlayer(args[1]);
+ if (player != null) {
+ if (player.usesChromiumClient()) {
+ sender.sendMessage(prefix + "Player %s is using chromium client".formatted(args[1]));
+ sender.sendRichMessage(prefix + "Player %s is using chromium client".formatted(args[1]));
+ } else {
+ sender.sendMessage(prefix + "Player %s isn't using chromium client".formatted(args[1]));
+ sender.sendRichMessage(prefix + "Player %s isn't using chromium client".formatted(args[1]));
+ }
+ } else {
+ sender.sendMessage(prefix + "Player %s is null".formatted(args[1]));
+ sender.sendRichMessage(prefix + "Player %s is null".formatted(args[1]));
+ }
+ } else {
+ sender.sendMessage(prefix + "Usage: /sapphire isChromium <name>");
+ sender.sendRichMessage(prefix + "Usage: /sapphire isChromium <name>");
+ }
+ }
case "ver", "version" -> {
if (args.length == 1) {
sender.sendMessage(prefix + "This server is running " + Bukkit.getName() + " version " + Bukkit.getVersion() + " (Git: " + getGitInfo() + ")");
@@ -74,7 +91,7 @@ public class SapphireCommand extends Command {
sender.sendRichMessage(prefix + "This server is running " + Bukkit.getName() + " version " + Bukkit.getVersion() + " (Git: " + getGitInfo() + ")");
@@ -85,7 +102,7 @@ public class SapphireCommand extends Command {
return true;
}

Expand All @@ -48,7 +48,7 @@ index c337948c82263af20e55570a2c65288aa0123334..e59f4a767d04046404c266bafba4ccc4

@Override
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args, @Nullable Location location) throws IllegalArgumentException {
@@ -92,6 +109,20 @@ public class SapphireCommand extends Command {
@@ -103,6 +120,20 @@ public class SapphireCommand extends Command {
.toList()
);
}
Expand Down

0 comments on commit 9ad1b8f

Please sign in to comment.