Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
Permission && Event Manager
Browse files Browse the repository at this point in the history
  • Loading branch information
404Setup committed Sep 8, 2024
1 parent 9c05ac8 commit 4a74445
Show file tree
Hide file tree
Showing 95 changed files with 123 additions and 5 deletions.
39 changes: 39 additions & 0 deletions patches/server/0016-EventManager.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: 404Setup <153366651+404Setup@users.noreply.github.com>
Date: Sun, 8 Sep 2024 21:38:31 +0800
Subject: [PATCH] EventManager


diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 4d9438c2c351058eba536fc05d84f1751226754c..8368aeaf37fe5b89e92fcde429a5ed778aab9af6 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1145,6 +1145,7 @@ public final class CraftServer implements Server {
this.enablePlugins(PluginLoadOrder.STARTUP);
this.enablePlugins(PluginLoadOrder.POSTWORLD);
if (io.papermc.paper.plugin.PluginInitializerManager.instance().pluginRemapper != null) io.papermc.paper.plugin.PluginInitializerManager.instance().pluginRemapper.pluginsEnabled(); // Paper - Remap plugins
+ one.tranic.vine.event.EventManager.INSTANCE.register(); // Vine
// Paper start - brigadier command API
io.papermc.paper.command.brigadier.PaperCommands.INSTANCE.setValid(); // to clear invalid state for event fire below
io.papermc.paper.plugin.lifecycle.event.LifecycleEventRunner.INSTANCE.callReloadableRegistrarEvent(io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents.COMMANDS, io.papermc.paper.command.brigadier.PaperCommands.INSTANCE, org.bukkit.plugin.Plugin.class, io.papermc.paper.plugin.lifecycle.event.registrar.ReloadableRegistrarEvent.Cause.RELOAD); // call commands event for regular plugins
diff --git a/src/main/kotlin/one/tranic/vine/event/EventManager.kt b/src/main/kotlin/one/tranic/vine/event/EventManager.kt
new file mode 100644
index 0000000000000000000000000000000000000000..30072eb1bf44aafd95ea7397916aa6dfe0c96d76
--- /dev/null
+++ b/src/main/kotlin/one/tranic/vine/event/EventManager.kt
@@ -0,0 +1,14 @@
+package one.tranic.vine.event
+
+import one.tranic.vine.util.Reflect
+import org.bukkit.Bukkit
+import org.bukkit.craftbukkit.scheduler.MinecraftInternalPlugin
+import org.bukkit.event.Listener
+
+object EventManager {
+ fun register() {
+ Reflect.findAllClass<Listener>("one.tranic.event.module").forEach {
+ Bukkit.getPluginManager().registerEvents(it, MinecraftInternalPlugin())
+ }
+ }
+}
\ No newline at end of file
79 changes: 79 additions & 0 deletions patches/server/0017-PermissionManager.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: 404Setup <153366651+404Setup@users.noreply.github.com>
Date: Sun, 8 Sep 2024 22:12:01 +0800
Subject: [PATCH] PermissionManager


diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 8368aeaf37fe5b89e92fcde429a5ed778aab9af6..0aa23076acd87ae5d9b5c079831ce2619c1acb6f 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -611,6 +611,7 @@ public final class CraftServer implements Server {
DefaultPermissions.registerCorePermissions();
CraftDefaultPermissions.registerCorePermissions();
ShreddedPaperPermissions.registerCorePermissions(); // ShreddedPaper
+ one.tranic.vine.permission.PermissionManager.INSTANCE.registerCorePermissions(); // Vine
if (!io.papermc.paper.configuration.GlobalConfiguration.get().misc.loadPermissionsYmlBeforePlugins) this.loadCustomPermissions(); // Paper
this.helpMap.initializeCommands();
this.syncCommands();
@@ -3278,6 +3279,8 @@ public final class CraftServer implements Server {
if (!io.papermc.paper.configuration.GlobalConfiguration.get().misc.loadPermissionsYmlBeforePlugins) loadCustomPermissions();
DefaultPermissions.registerCorePermissions();
CraftDefaultPermissions.registerCorePermissions();
+ ShreddedPaperPermissions.registerCorePermissions(); // Vine - ShreddedPaper
+ one.tranic.vine.permission.PermissionManager.INSTANCE.registerCorePermissions(); // Vine
}

@Override
diff --git a/src/main/kotlin/one/tranic/vine/permission/PermissionManager.kt b/src/main/kotlin/one/tranic/vine/permission/PermissionManager.kt
new file mode 100644
index 0000000000000000000000000000000000000000..c714ed520954fd4f16b3a57dfd43946ecabd8ea4
--- /dev/null
+++ b/src/main/kotlin/one/tranic/vine/permission/PermissionManager.kt
@@ -0,0 +1,45 @@
+package one.tranic.vine.permission
+
+import org.bukkit.permissions.Permission
+import org.bukkit.permissions.PermissionDefault
+import org.bukkit.util.permissions.DefaultPermissions
+
+object PermissionManager {
+ const val ROOT: String = "vine."
+
+ fun registerCorePermissions() {
+ val parent = DefaultPermissions.registerPermission(
+ ROOT,
+ "Gives the user the ability to use all Vine utilities and commands"
+ )
+ syncPermissions(parent)
+ parent.recalculatePermissibles()
+ }
+
+ private fun syncPermissions(parent: Permission) {
+ val commands = DefaultPermissions.registerPermission(
+ "vine",
+ "Gives the user the ability to use all Vine commands",
+ parent
+ )
+
+ setPermission(
+ "commands.cfg",
+ "Vine Config Command",
+ PermissionDefault.OP,
+ commands
+ )
+ setPermission(
+ "commands.threads",
+ "Vine Threads Command",
+ PermissionDefault.OP,
+ commands
+ )
+
+ commands.recalculatePermissibles()
+ }
+
+ private fun setPermission(permission: String, desc: String, def: PermissionDefault, parent: Permission) {
+ DefaultPermissions.registerPermission(ROOT + permission, desc, def, parent)
+ }
+}
\ No newline at end of file
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Subject: [PATCH] Leaf: Cache player profileResult


diff --git a/build.gradle.kts b/build.gradle.kts
index abd320434647bf901ed79e6a1bf2fa50908c437c..42f1bde01585886868590902844bb27e186cfd68 100644
index 0dfe4f14099d5e3ff4da943d32bd14a1e788d903..4777451dc9378f1bed1c5f663cf444dabe42ff4e 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -106,6 +106,7 @@ dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ index 70dbf7267b43357578c07fcd46618f656410a8e2..1a76d356c07262344a5d2dffe0d41e3e
Rotation rotation = Rotation.getRandom(worldgenRandom);
StructureTemplatePool structureTemplatePool = structurePool.unwrapKey()
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 4d9438c2c351058eba536fc05d84f1751226754c..da26299242edc71b210bc146793f7db69cbd636f 100644
index 0aa23076acd87ae5d9b5c079831ce2619c1acb6f..4a7ae711b21e8095f7ae2b92f6e9a506fbd7d9e8 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -268,6 +268,9 @@ import io.multipaper.shreddedpaper.region.ShreddedPaperRegionSchedulerApiImpl;
Expand All @@ -548,7 +548,7 @@ index 4d9438c2c351058eba536fc05d84f1751226754c..da26299242edc71b210bc146793f7db6
public final class CraftServer implements Server {
private final String serverName = io.papermc.paper.ServerBuildInfo.buildInfo().brandName(); // Paper
private final String serverVersion;
@@ -1387,7 +1390,7 @@ public final class CraftServer implements Server {
@@ -1389,7 +1392,7 @@ public final class CraftServer implements Server {
iregistrycustom_dimension = leveldataanddimensions.dimensions().dimensionsRegistryAccess();
} else {
LevelSettings worldsettings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
Gale - https://galemc.org

diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index da26299242edc71b210bc146793f7db69cbd636f..08d2a14210f5f30a0a0b3a3b08d0c6a99a9cda1e 100644
index 4a7ae711b21e8095f7ae2b92f6e9a506fbd7d9e8..5322f8f92f25a9f381e8d2a53f3c1815872d95c3 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -3184,6 +3184,23 @@ public final class CraftServer implements Server {
@@ -3186,6 +3186,23 @@ public final class CraftServer implements Server {
};
}

Expand Down

0 comments on commit 4a74445

Please sign in to comment.