Skip to content

Commit 883f334

Browse files
committed
Fix NPE on startup
1 parent 063137d commit 883f334

File tree

17 files changed

+2948
-8
lines changed

17 files changed

+2948
-8
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--- a/src/main/java/io/papermc/paper/ServerBuildInfo.java
2+
+++ b/src/main/java/io/papermc/paper/ServerBuildInfo.java
3+
@@ -25,6 +_,14 @@
4+
*/
5+
Key BRAND_PURPUR_ID = Key.key("purpurmc", "purpur");
6+
// Purpur end
7+
+
8+
+ // Plazma start
9+
+ /**
10+
+ * The brand id for Plazma.
11+
+ */
12+
+ Key BRAND_PLAZMA_ID = Key.key("plazmamc", "plazma");
13+
+ // Plazma end
14+
+
15+
/**
16+
* Gets the {@code ServerBuildInfo}.
17+
*
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
--- a/src/main/java/org/bukkit/Server.java
2+
+++ b/src/main/java/org/bukkit/Server.java
3+
@@ -2309,6 +_,11 @@
4+
// Spigot start
5+
public class Spigot {
6+
7+
+ /**
8+
+ * @deprecated Use {@link #getSpigotConfig()} instead.
9+
+ * @return The spigot configuration
10+
+ */
11+
+ @Deprecated(since = "Plazma 1.21.4")
12+
@NotNull
13+
public org.bukkit.configuration.file.YamlConfiguration getConfig() {
14+
throw new UnsupportedOperationException("Not supported yet.");
15+
@@ -2334,17 +_,27 @@
16+
}
17+
// Paper end
18+
19+
+ // Plazma start
20+
// Purpur start
21+
@NotNull
22+
- public org.bukkit.configuration.file.YamlConfiguration getPurpurConfig() {
23+
+ public org.bukkit.configuration.file.YamlConfiguration getPurpurConfig()
24+
+ {
25+
throw new UnsupportedOperationException("Not supported yet.");
26+
}
27+
28+
@NotNull
29+
- public java.util.Properties getServerProperties() {
30+
+ public java.util.Properties getServerProperties()
31+
+ {
32+
throw new UnsupportedOperationException("Not supported yet.");
33+
}
34+
// Purpur end
35+
+
36+
+ @NotNull
37+
+ public org.bukkit.configuration.file.YamlConfiguration getPlazmaConfig()
38+
+ {
39+
+ throw new UnsupportedOperationException("Not supported yet.");
40+
+ }
41+
+ // Plazma end
42+
43+
/**
44+
* Sends the component to the player
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
--- a/src/main/java/org/bukkit/command/defaults/VersionCommand.java
2+
+++ b/src/main/java/org/bukkit/command/defaults/VersionCommand.java
3+
@@ -64,7 +_,7 @@
4+
StringBuilder name = new StringBuilder();
5+
6+
for (String arg : args) {
7+
- if (name.length() > 0) {
8+
+ if (!name.isEmpty()) { // Plazma
9+
name.append(' ');
10+
}
11+
12+
@@ -96,7 +_,7 @@
13+
}
14+
15+
private void describeToSender(@NotNull Plugin plugin, @NotNull CommandSender sender) {
16+
- PluginDescriptionFile desc = plugin.getDescription();
17+
+ io.papermc.paper.plugin.configuration.PluginMeta desc = plugin.getPluginMeta(); // Plazma - Use modern method
18+
// Paper start - version command 2.0
19+
sender.sendMessage(
20+
Component.text()
21+
@@ -198,13 +_,7 @@
22+
sender.sendMessage(Component.text("Checking version, please wait...", NamedTextColor.WHITE, TextDecoration.ITALIC)); // Paper
23+
if (!versionTaskStarted) {
24+
versionTaskStarted = true;
25+
- new Thread(new Runnable() {
26+
-
27+
- @Override
28+
- public void run() {
29+
- obtainVersion();
30+
- }
31+
- }).start();
32+
+ new Thread(this::obtainVersion).start(); // Plazma
33+
}
34+
} finally {
35+
versionLock.unlock();
36+
@@ -219,37 +_,6 @@
37+
return;
38+
}
39+
setVersionMessage(getVersionFetcher().getVersionMessage(version));
40+
- /*
41+
- if (version == null) version = "Custom";
42+
- String[] parts = version.substring(0, version.indexOf(' ')).split("-");
43+
- if (parts.length == 4) {
44+
- int cbVersions = getDistance("craftbukkit", parts[3]);
45+
- int spigotVersions = getDistance("spigot", parts[2]);
46+
- if (cbVersions == -1 || spigotVersions == -1) {
47+
- setVersionMessage("Error obtaining version information");
48+
- } else {
49+
- if (cbVersions == 0 && spigotVersions == 0) {
50+
- setVersionMessage("You are running the latest version");
51+
- } else {
52+
- setVersionMessage("You are " + (cbVersions + spigotVersions) + " version(s) behind");
53+
- }
54+
- }
55+
-
56+
- } else if (parts.length == 3) {
57+
- int cbVersions = getDistance("craftbukkit", parts[2]);
58+
- if (cbVersions == -1) {
59+
- setVersionMessage("Error obtaining version information");
60+
- } else {
61+
- if (cbVersions == 0) {
62+
- setVersionMessage("You are running the latest version");
63+
- } else {
64+
- setVersionMessage("You are " + cbVersions + " version(s) behind");
65+
- }
66+
- }
67+
- } else {
68+
- setVersionMessage("Unknown version, custom build?");
69+
- }
70+
- */
71+
// Paper end
72+
}
73+
74+
@@ -259,7 +_,7 @@
75+
// Purpur start
76+
int distance = getVersionFetcher().distance();
77+
final Component message = Component.join(net.kyori.adventure.text.JoinConfiguration.separator(Component.newline()),
78+
- ChatColor.parseMM("<grey>Current Purpur Version: %s%s*", distance == 0 ? "<green>" : distance > 0 ? "<yellow>" : "<red>", Bukkit.getVersion()),
79+
+ net.kyori.adventure.text.minimessage.MiniMessage.miniMessage().deserialize("<grey>Current Plazma Version: " + (distance == 0 ? "<green>" : distance > 0 ? "<yellow>" : "<red>") + Bukkit.getVersion() + "*"), // Plazma
80+
// Purpur end
81+
msg
82+
);
83+
@@ -279,27 +_,6 @@
84+
versionWaiters.clear();
85+
} finally {
86+
versionLock.unlock();
87+
- }
88+
- }
89+
-
90+
- private static int getDistance(@NotNull String repo, @NotNull String hash) {
91+
- try {
92+
- BufferedReader reader = Resources.asCharSource(
93+
- new URL("https://hub.spigotmc.org/stash/rest/api/1.0/projects/SPIGOT/repos/" + repo + "/commits?since=" + URLEncoder.encode(hash, "UTF-8") + "&withCounts=true"),
94+
- Charsets.UTF_8
95+
- ).openBufferedStream();
96+
- try {
97+
- JsonObject obj = new Gson().fromJson(reader, JsonObject.class);
98+
- return obj.get("totalCount").getAsInt();
99+
- } catch (JsonSyntaxException ex) {
100+
- ex.printStackTrace();
101+
- return -1;
102+
- } finally {
103+
- reader.close();
104+
- }
105+
- } catch (IOException e) {
106+
- e.printStackTrace();
107+
- return -1;
108+
}
109+
}
110+
}

0 commit comments

Comments
 (0)