mirror of
https://github.com/BX-Team/DivineMC.git
synced 2025-12-22 00:09:15 +00:00
apply api and branding
This commit is contained in:
@@ -1,37 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||
Date: Sat, 18 May 2024 01:10:38 +0300
|
||||
Subject: [PATCH] Divine Branding
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/ServerBuildInfo.java b/src/main/java/io/papermc/paper/ServerBuildInfo.java
|
||||
index 7107eabf02d9d9b69d97c978ba421ad52031ec3f..f6005cb48750fdcf903609f3fb693895df229bc2 100644
|
||||
--- a/src/main/java/io/papermc/paper/ServerBuildInfo.java
|
||||
+++ b/src/main/java/io/papermc/paper/ServerBuildInfo.java
|
||||
@@ -25,6 +25,13 @@ public interface ServerBuildInfo {
|
||||
Key BRAND_PURPUR_ID = Key.key("purpurmc", "purpur");
|
||||
// Purpur end
|
||||
|
||||
+ // DivineMC start
|
||||
+ /**
|
||||
+ * The brand id for DivineMC.
|
||||
+ */
|
||||
+ Key BRAND_DIVINEMC_ID = Key.key("divinemc", "divinemc");
|
||||
+ // DivineMC end
|
||||
+
|
||||
/**
|
||||
* Gets the {@code ServerBuildInfo}.
|
||||
*
|
||||
diff --git a/src/main/java/org/bukkit/command/defaults/VersionCommand.java b/src/main/java/org/bukkit/command/defaults/VersionCommand.java
|
||||
index c880d0010849ab733ad13bbd18fab3c864d0cf61..de6522adba933dca90338bfb19f833486e696b8d 100644
|
||||
--- a/src/main/java/org/bukkit/command/defaults/VersionCommand.java
|
||||
+++ b/src/main/java/org/bukkit/command/defaults/VersionCommand.java
|
||||
@@ -259,7 +259,7 @@ public class VersionCommand extends BukkitCommand {
|
||||
// Purpur start
|
||||
int distance = getVersionFetcher().distance();
|
||||
final Component message = Component.join(net.kyori.adventure.text.JoinConfiguration.separator(Component.newline()),
|
||||
- ChatColor.parseMM("<grey>Current Purpur Version: %s%s*", distance == 0 ? "<green>" : distance > 0 ? "<yellow>" : "<red>", Bukkit.getVersion()),
|
||||
+ ChatColor.parseMM("<grey>Current DivineMC Version: %s%s*", distance == 0 ? "<green>" : distance > 0 ? "<yellow>" : "<red>", Bukkit.getVersion()), // DivineMC
|
||||
// Purpur end
|
||||
msg
|
||||
);
|
||||
@@ -1,24 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||
Date: Mon, 27 Mar 2023 17:50:05 +0300
|
||||
Subject: [PATCH] Divine Configuration
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||
index ec8b9b2cbe65838a194281f7d76d0e17defc5211..adeb76886e99bd8f8374102471c71694ab5a30e4 100644
|
||||
--- a/src/main/java/org/bukkit/Server.java
|
||||
+++ b/src/main/java/org/bukkit/Server.java
|
||||
@@ -2269,6 +2269,13 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||
}
|
||||
// Purpur end
|
||||
|
||||
+ // DivineMC start
|
||||
+ @NotNull
|
||||
+ public org.bukkit.configuration.file.YamlConfiguration getDivineConfig() {
|
||||
+ throw new UnsupportedOperationException("Not supported yet");
|
||||
+ }
|
||||
+ // DivineMC end
|
||||
+
|
||||
/**
|
||||
* Sends the component to the player
|
||||
*
|
||||
@@ -1,119 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||
Date: Mon, 12 Jun 2023 00:23:38 +0300
|
||||
Subject: [PATCH] Disable reload command by default
|
||||
|
||||
This is fully rewritten reload command, you can enable or disable it with -DDivineMC.EnableReloadCommand flag
|
||||
Read this article why reload is VERY UNSAFE in Bukkit: https://madelinemiller.dev/blog/problem-with-reload/
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/command/defaults/ReloadCommand.java b/src/main/java/org/bukkit/command/defaults/ReloadCommand.java
|
||||
index bdfe68b386b5ca2878475e548d3c9a3808fce848..0a21f2138969f75425b720487e626aac796821d1 100644
|
||||
--- a/src/main/java/org/bukkit/command/defaults/ReloadCommand.java
|
||||
+++ b/src/main/java/org/bukkit/command/defaults/ReloadCommand.java
|
||||
@@ -1,8 +1,7 @@
|
||||
package org.bukkit.command.defaults;
|
||||
|
||||
-import java.util.Arrays;
|
||||
-import java.util.Collections;
|
||||
import java.util.List;
|
||||
+
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
@@ -15,7 +14,7 @@ public class ReloadCommand extends BukkitCommand {
|
||||
this.description = "Reloads the server configuration and plugins";
|
||||
this.usageMessage = "/reload [permissions|commands|confirm]"; // Paper
|
||||
this.setPermission("bukkit.command.reload");
|
||||
- this.setAliases(Arrays.asList("rl"));
|
||||
+ this.setAliases(List.of("rl"));
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.ApiStatus.Internal // Paper
|
||||
@@ -25,48 +24,53 @@ public class ReloadCommand extends BukkitCommand {
|
||||
public boolean execute(@NotNull CommandSender sender, @NotNull String currentAlias, @NotNull String[] args) { // Paper
|
||||
if (!testPermission(sender)) return true;
|
||||
|
||||
- // Paper start - Reload permissions.yml & require confirm
|
||||
- boolean confirmed = System.getProperty("LetMeReload") != null;
|
||||
- if (args.length == 1) {
|
||||
- if (args[0].equalsIgnoreCase("permissions")) {
|
||||
- Bukkit.getServer().reloadPermissions();
|
||||
- Command.broadcastCommandMessage(sender, net.kyori.adventure.text.Component.text("Permissions successfully reloaded.", net.kyori.adventure.text.format.NamedTextColor.GREEN));
|
||||
- return true;
|
||||
- } else if ("commands".equalsIgnoreCase(args[0])) {
|
||||
- if (Bukkit.getServer().reloadCommandAliases()) {
|
||||
- Command.broadcastCommandMessage(sender, net.kyori.adventure.text.Component.text("Command aliases successfully reloaded.", net.kyori.adventure.text.format.NamedTextColor.GREEN));
|
||||
+ // DivineMC start - disable reload command by default & add startup flag
|
||||
+ if (System.getProperty("DivineMC.EnableReloadCommand") == null || false) {
|
||||
+ sender.sendMessage(net.kyori.adventure.text.Component.text("Operation denied, command disabled.", net.kyori.adventure.text.format.NamedTextColor.RED ));
|
||||
+ sender.sendMessage(net.kyori.adventure.text.Component.text("Reload command SHOULD NEVER be used in whatever circumstances.", net.kyori.adventure.text.format.NamedTextColor.YELLOW));
|
||||
+ sender.sendMessage(net.kyori.adventure.text.Component.text("DivineMC has intentionally disabled it in order to stop you using it, instead of restarting your server.", net.kyori.adventure.text.format.NamedTextColor.YELLOW));
|
||||
+ sender.sendMessage(net.kyori.adventure.text.Component.text("If you still want to enable reload command, add -DDivineMC.EnableReloadCommand=true flag to your startup arguments.", net.kyori.adventure.text.format.NamedTextColor.YELLOW));
|
||||
+ sender.sendMessage(net.kyori.adventure.text.Component.text("---------------------------------------------", net.kyori.adventure.text.format.NamedTextColor.GREEN));
|
||||
+ sender.sendMessage(net.kyori.adventure.text.Component.text("RESTART YOUR SERVER AND NEVER USE /reload", net.kyori.adventure.text.format.NamedTextColor.YELLOW));
|
||||
+ sender.sendMessage(net.kyori.adventure.text.Component.text("To learn more, read this article: https://madelinemiller.dev/blog/problem-with-reload", net.kyori.adventure.text.format.NamedTextColor.GREEN));
|
||||
+ } else {
|
||||
+ if (args.length == 1) {
|
||||
+ if (args[0].equalsIgnoreCase("permissions")) {
|
||||
+ Bukkit.getServer().reloadPermissions();
|
||||
+ Command.broadcastCommandMessage(sender, net.kyori.adventure.text.Component.text("Permissions successfully reloaded.", net.kyori.adventure.text.format.NamedTextColor.GREEN));
|
||||
+ return true;
|
||||
+ } else if ("commands".equalsIgnoreCase(args[0])) {
|
||||
+ if (Bukkit.getServer().reloadCommandAliases()) {
|
||||
+ Command.broadcastCommandMessage(sender, net.kyori.adventure.text.Component.text("Command aliases successfully reloaded.", net.kyori.adventure.text.format.NamedTextColor.GREEN));
|
||||
+ } else {
|
||||
+ Command.broadcastCommandMessage(sender, net.kyori.adventure.text.Component.text("An error occurred while trying to reload command aliases.", net.kyori.adventure.text.format.NamedTextColor.RED));
|
||||
+ }
|
||||
+ return true;
|
||||
} else {
|
||||
- Command.broadcastCommandMessage(sender, net.kyori.adventure.text.Component.text("An error occurred while trying to reload command aliases.", net.kyori.adventure.text.format.NamedTextColor.RED));
|
||||
+ Command.broadcastCommandMessage(sender, net.kyori.adventure.text.Component.text("Usage: " + usageMessage, net.kyori.adventure.text.format.NamedTextColor.RED));
|
||||
+ return true;
|
||||
}
|
||||
- return true;
|
||||
- } else if ("confirm".equalsIgnoreCase(args[0])) {
|
||||
- confirmed = true;
|
||||
- } else {
|
||||
- Command.broadcastCommandMessage(sender, net.kyori.adventure.text.Component.text("Usage: " + usageMessage, net.kyori.adventure.text.format.NamedTextColor.RED));
|
||||
- return true;
|
||||
}
|
||||
- }
|
||||
- if (!confirmed) {
|
||||
- Command.broadcastCommandMessage(sender, net.kyori.adventure.text.Component.text("Are you sure you wish to reload your server? Doing so may cause bugs and memory leaks. It is recommended to restart instead of using /reload. To confirm, please type ", net.kyori.adventure.text.format.NamedTextColor.RED).append(net.kyori.adventure.text.Component.text("/reload confirm", net.kyori.adventure.text.format.NamedTextColor.YELLOW)));
|
||||
- return true;
|
||||
- }
|
||||
- // Paper end
|
||||
|
||||
- Command.broadcastCommandMessage(sender, ChatColor.RED + "Please note that this command is not supported and may cause issues when using some plugins.");
|
||||
- Command.broadcastCommandMessage(sender, ChatColor.RED + "If you encounter any issues please use the /stop command to restart your server.");
|
||||
- // Paper start - lifecycle events
|
||||
- try {
|
||||
- Bukkit.reload();
|
||||
- } catch (final IllegalStateException ex) {
|
||||
- if (ex.getMessage().equals(RELOADING_DISABLED_MESSAGE)) {
|
||||
- Command.broadcastCommandMessage(sender, ChatColor.RED + RELOADING_DISABLED_MESSAGE);
|
||||
- return true;
|
||||
+ Command.broadcastCommandMessage(sender, ChatColor.RED + "Please note that this command is not supported and may cause issues when using some plugins.");
|
||||
+ Command.broadcastCommandMessage(sender, ChatColor.RED + "If you encounter any issues please use the /stop command to restart your server.");
|
||||
+ // Paper start - lifecycle events
|
||||
+ try {
|
||||
+ Bukkit.reload();
|
||||
+ } catch (final IllegalStateException ex) {
|
||||
+ if (ex.getMessage().equals(RELOADING_DISABLED_MESSAGE)) {
|
||||
+ Command.broadcastCommandMessage(sender, ChatColor.RED + RELOADING_DISABLED_MESSAGE);
|
||||
+ return true;
|
||||
+ }
|
||||
}
|
||||
+ // Paper end - lifecycle events
|
||||
+ Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Reload complete.");
|
||||
+
|
||||
+ return true;
|
||||
}
|
||||
- // Paper end - lifecycle events
|
||||
- Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Reload complete.");
|
||||
|
||||
return true;
|
||||
+ // DivineMC end
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -1,114 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||
Date: Sun, 25 Jun 2023 13:35:28 +0300
|
||||
Subject: [PATCH] Optimize Paper Event Manager
|
||||
|
||||
Original project: lynxplay/ktp
|
||||
Link: https://github.com/lynxplay/ktp
|
||||
Modified by NONPLAYT
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/event/Event.java b/src/main/java/org/bukkit/event/Event.java
|
||||
index 8ec56cd6b8e0f5c5dd8c7c88b4671e18dcf109d0..d464812eb5e398733b8ea5b09339afa0b555f698 100644
|
||||
--- a/src/main/java/org/bukkit/event/Event.java
|
||||
+++ b/src/main/java/org/bukkit/event/Event.java
|
||||
@@ -6,7 +6,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents an event.
|
||||
- *
|
||||
+ * <p>
|
||||
* All events require a static method named getHandlerList() which returns the same {@link HandlerList} as {@link #getHandlers()}.
|
||||
*
|
||||
* @see PluginManager#callEvent(Event)
|
||||
@@ -14,7 +14,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
*/
|
||||
public abstract class Event {
|
||||
private String name;
|
||||
- private final boolean async;
|
||||
+ private final net.kyori.adventure.util.TriState async; // DivineMC - Optimize Paper Event Manager
|
||||
|
||||
/**
|
||||
* The default constructor is defined for cleaner code. This constructor
|
||||
@@ -31,10 +31,20 @@ public abstract class Event {
|
||||
* @param isAsync true indicates the event will fire asynchronously, false
|
||||
* by default from default constructor
|
||||
*/
|
||||
+ // DivineMC start - Optimize Paper Event Manager
|
||||
public Event(boolean isAsync) {
|
||||
+ this(net.kyori.adventure.util.TriState.byBoolean(isAsync));
|
||||
+ }
|
||||
+
|
||||
+ public Event(@NotNull final net.kyori.adventure.util.TriState isAsync) {
|
||||
this.async = isAsync;
|
||||
}
|
||||
|
||||
+ public final @NotNull net.kyori.adventure.util.TriState asynchronous() {
|
||||
+ return this.async;
|
||||
+ }
|
||||
+ // DivineMC end
|
||||
+
|
||||
// Paper start
|
||||
/**
|
||||
* Calls the event and tests if cancelled.
|
||||
@@ -70,7 +80,7 @@ public abstract class Event {
|
||||
public abstract HandlerList getHandlers();
|
||||
|
||||
/**
|
||||
- * Any custom event that should not by synchronized with other events must
|
||||
+ * Any custom event that should not be synchronized with other events must
|
||||
* use the specific constructor. These are the caveats of using an
|
||||
* asynchronous event:
|
||||
* <ul>
|
||||
@@ -92,7 +102,7 @@ public abstract class Event {
|
||||
* @return false by default, true if the event fires asynchronously
|
||||
*/
|
||||
public final boolean isAsynchronous() {
|
||||
- return async;
|
||||
+ return this.async == net.kyori.adventure.util.TriState.TRUE; // DivineMC - Optimize Paper Event Manager
|
||||
}
|
||||
|
||||
public enum Result {
|
||||
@@ -113,6 +123,6 @@ public abstract class Event {
|
||||
* take place if possible, even if the server would not normally allow
|
||||
* the action. Some actions may not be allowed.
|
||||
*/
|
||||
- ALLOW;
|
||||
+ ALLOW
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/plugin/RegisteredListener.java b/src/main/java/org/bukkit/plugin/RegisteredListener.java
|
||||
index 3b3d9642a8d63798dc28f2f8df77f0466451cbff..9c43c51858b20ace8e32eb2d7f5a2fba6a2090e6 100644
|
||||
--- a/src/main/java/org/bukkit/plugin/RegisteredListener.java
|
||||
+++ b/src/main/java/org/bukkit/plugin/RegisteredListener.java
|
||||
@@ -62,11 +62,13 @@ public class RegisteredListener {
|
||||
* @throws EventException If an event handler throws an exception.
|
||||
*/
|
||||
public void callEvent(@NotNull final Event event) throws EventException {
|
||||
- if (event instanceof Cancellable) {
|
||||
- if (((Cancellable) event).isCancelled() && isIgnoringCancelled()) {
|
||||
+ // DivineMC start - Optimize Paper Event Manager
|
||||
+ if (isIgnoringCancelled()) {
|
||||
+ if (event instanceof Cancellable cancellable && cancellable.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
+ // DivineMC end
|
||||
executor.execute(listener, event);
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
||||
index 7e4f7cb2afbc145e532285c793573ad107bc3033..86279f35af76fbffe233e6aba64e1b5dc2aa69c3 100644
|
||||
--- a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
||||
+++ b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
||||
@@ -318,4 +318,11 @@ public final class PluginClassLoader extends URLClassLoader implements io.paperm
|
||||
}
|
||||
|
||||
// Paper end
|
||||
+
|
||||
+ // DivineMC start - Optimize Paper Event Manager
|
||||
+ @Override
|
||||
+ public void addURL(final URL url) {
|
||||
+ super.addURL(url);
|
||||
+ }
|
||||
+ // DivineMC end
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,25 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||
Date: Tue, 14 May 2024 17:22:39 +0300
|
||||
Subject: [PATCH] DivineMC API Publish
|
||||
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index 6aef83558a5ef7e84873b127c3bb43a6468c9a24..78cae5a080f65646494e7d1d8a52df969db6d3b1 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -222,3 +222,14 @@ tasks.check {
|
||||
dependsOn(scanJarForOldGeneratedCode)
|
||||
}
|
||||
// Paper end
|
||||
+
|
||||
+// DivineMC start - publish to GitHub Packages
|
||||
+publishing {
|
||||
+ repositories {
|
||||
+ maven("https://repo.bx-team.space/snapshots") {
|
||||
+ name = "divinemc"
|
||||
+ credentials(PasswordCredentials::class)
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+// DivineMC end
|
||||
@@ -1,35 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||
Date: Mon, 20 May 2024 07:14:21 +0300
|
||||
Subject: [PATCH] Hide unnecessary compilation warnings
|
||||
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index 78cae5a080f65646494e7d1d8a52df969db6d3b1..e33a4bd94cbaf07ed10f0b160ca0e65ec2383b66 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -130,6 +130,15 @@ val generateApiVersioningFile by tasks.registering {
|
||||
}
|
||||
}
|
||||
|
||||
+// DivineMC start - Hide unnecessary compilation warnings
|
||||
+tasks.withType<JavaCompile> {
|
||||
+ val compilerArgs = options.compilerArgs
|
||||
+ compilerArgs.add("-Xlint:-module")
|
||||
+ compilerArgs.add("-Xlint:-removal")
|
||||
+ compilerArgs.add("-Xlint:-dep-ann")
|
||||
+}
|
||||
+// DivineMC end
|
||||
+
|
||||
tasks.jar {
|
||||
from(generateApiVersioningFile.map { it.outputs.files.singleFile }) {
|
||||
into("META-INF/maven/${project.group}/${project.name}")
|
||||
@@ -189,6 +198,8 @@ tasks.withType<Javadoc> {
|
||||
into("build/docs/javadoc")
|
||||
}
|
||||
}
|
||||
+
|
||||
+ options.addStringOption("Xdoclint:none", "-quiet") // DivineMC - Hide unnecessary compilation warnings
|
||||
}
|
||||
|
||||
tasks.test {
|
||||
Reference in New Issue
Block a user