Registry Modification API (#10893)

* Registry Modification API

* some fixes

* even more fixes
This commit is contained in:
Jake Potrebic
2024-06-16 12:39:59 -07:00
parent c675152a56
commit 25c3a98398
11 changed files with 2497 additions and 157 deletions

View File

@@ -770,6 +770,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import io.papermc.paper.plugin.storage.BootstrapProviderStorage;
+import io.papermc.paper.plugin.storage.ProviderStorage;
+import io.papermc.paper.plugin.storage.ServerPluginProviderStorage;
+import it.unimi.dsi.fastutil.objects.Object2BooleanMap;
+import it.unimi.dsi.fastutil.objects.Object2BooleanOpenHashMap;
+import org.jetbrains.annotations.ApiStatus;
+
+import java.util.HashMap;
@@ -782,9 +784,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
+ public static final LaunchEntryPointHandler INSTANCE = new LaunchEntryPointHandler();
+ private final Map<Entrypoint<?>, ProviderStorage<?>> storage = new HashMap<>();
+ private final Object2BooleanMap<Entrypoint<?>> enteredMap = new Object2BooleanOpenHashMap<>();
+
+ LaunchEntryPointHandler() {
+ this.populateProviderStorage();
+ this.enteredMap.defaultReturnValue(false);
+ }
+
+ // Utility
@@ -800,6 +804,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+
+ storage.enter();
+ this.enteredMap.put(entrypoint, true);
+ }
+
+ @Override
@@ -823,6 +828,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return storage;
+ }
+
+ public boolean hasEntered(Entrypoint<?> entrypoint) {
+ return this.enteredMap.getBoolean(entrypoint);
+ }
+
+ // Reload only
+ public void populateProviderStorage() {
+ this.storage.put(Entrypoint.BOOTSTRAPPER, new BootstrapProviderStorage());