Skip to content

Commit

Permalink
fix javadocs
Browse files Browse the repository at this point in the history
  • Loading branch information
Machine-Maker committed Sep 8, 2024
1 parent a02c120 commit 7730a7f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 26 deletions.
37 changes: 20 additions & 17 deletions patches/api/0490-Add-datapack-registration-lifecycle-event.patch
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ index 7b2ab0be10a21e0496ad1d485ff8cb2c0b92a2cb..e6037cc5b79b5206e5da8d53c5009932
}
diff --git a/src/main/java/io/papermc/paper/datapack/DatapackRegistrar.java b/src/main/java/io/papermc/paper/datapack/DatapackRegistrar.java
new file mode 100644
index 0000000000000000000000000000000000000000..66ee27f25a0f8049e218c8722075fcb1f3c2b7b6
index 0000000000000000000000000000000000000000..a13611009c9c1e2c18535869207ae4f9c8ad7cd8
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datapack/DatapackRegistrar.java
@@ -0,0 +1,198 @@
@@ -0,0 +1,201 @@
+package io.papermc.paper.datapack;
+
+import io.papermc.paper.plugin.configuration.PluginMeta;
Expand Down Expand Up @@ -73,32 +73,35 @@ index 0000000000000000000000000000000000000000..66ee27f25a0f8049e218c8722075fcb1
+public interface DatapackRegistrar extends Registrar {
+
+ /**
+ * Checks if a datapack with the specified id has been discovered.
+ * Checks if a datapack with the specified name has been discovered.
+ *
+ * @param id the id of the pack
+ * @param name the name of the pack
+ * @return true if the pack has been discovered
+ * @see Datapack#getName()
+ */
+ @Contract(pure = true)
+ boolean hasPackDiscovered(@NonNull String id);
+ boolean hasPackDiscovered(@NonNull String name);
+
+ /**
+ * Gets a discovered datapack by its id.
+ * Gets a discovered datapack by its name.
+ *
+ * @param id the id of the pack
+ * @param name the name of the pack
+ * @return the datapack
+ * @throws java.util.NoSuchElementException if the pack is not discovered
+ * @see Datapack#getName()
+ */
+ @Contract(pure = true)
+ @NonNull Datapack getDiscoveredPack(@NonNull String id);
+ @NonNull Datapack getDiscoveredPack(@NonNull String name);
+
+ /**
+ * Removes a discovered datapack by its id.
+ * Removes a discovered datapack by its name.
+ *
+ * @param id the id of the pack
+ * @param name the name of the pack
+ * @return true if the pack was removed
+ * @see Datapack#getName()
+ */
+ @Contract(mutates = "this")
+ boolean removeDiscoveredPack(@NonNull String id);
+ boolean removeDiscoveredPack(@NonNull String name);
+
+ /**
+ * Gets all discovered datapacks.
Expand All @@ -113,7 +116,7 @@ index 0000000000000000000000000000000000000000..66ee27f25a0f8049e218c8722075fcb1
+ * <p>Symlinks obey the {@code allowed_symlinks.txt} in the server root directory.</p>
+ *
+ * @param uri the location of the pack
+ * @param id a unique id
+ * @param id a unique id (will be combined with plugin for the datapacks name)
+ * @return the discovered datapack (or null if it failed)
+ * @throws IOException if any IO error occurs
+ */
Expand All @@ -126,7 +129,7 @@ index 0000000000000000000000000000000000000000..66ee27f25a0f8049e218c8722075fcb1
+ * <p>Symlinks obey the {@code allowed_symlinks.txt} in the server root directory.</p>
+ *
+ * @param uri the location of the pack
+ * @param id a unique id
+ * @param id a unique id (will be combined with plugin for the datapacks name)
+ * @param configurer a configurer for extra options
+ * @return the discovered datapack (or null if it failed)
+ * @throws IOException if any IO error occurs
Expand All @@ -138,7 +141,7 @@ index 0000000000000000000000000000000000000000..66ee27f25a0f8049e218c8722075fcb1
+ * <p>Symlinks obey the {@code allowed_symlinks.txt} in the server root directory.</p>
+ *
+ * @param path the location of the pack
+ * @param id a unique id
+ * @param id a unique id (will be combined with plugin for the datapacks name)
+ * @return the discovered datapack (or null if it failed)
+ * @throws IOException if any IO error occurs
+ */
Expand All @@ -151,7 +154,7 @@ index 0000000000000000000000000000000000000000..66ee27f25a0f8049e218c8722075fcb1
+ * <p>Symlinks obey the {@code allowed_symlinks.txt} in the server root directory.</p>
+ *
+ * @param path the location of the pack
+ * @param id a unique id
+ * @param id a unique id (will be combined with plugin for the datapacks name)
+ * @param configurer a configurer for extra options
+ * @return the discovered datapack (or null if it failed)
+ * @throws IOException if any IO error occurs
Expand All @@ -164,7 +167,7 @@ index 0000000000000000000000000000000000000000..66ee27f25a0f8049e218c8722075fcb1
+ *
+ * @param pluginMeta the plugin which will be the "owner" of this datapack
+ * @param uri the location of the pack
+ * @param id a unique id
+ * @param id a unique id (will be combined with plugin for the datapacks name)
+ * @param configurer a configurer for extra options
+ * @return the discovered datapack (or null if it failed)
+ * @throws IOException if any IO error occurs
Expand All @@ -177,7 +180,7 @@ index 0000000000000000000000000000000000000000..66ee27f25a0f8049e218c8722075fcb1
+ *
+ * @param pluginMeta the plugin which will be the "owner" of this datapack
+ * @param path the location of the pack
+ * @param id a unique id
+ * @param id a unique id (will be combined with plugin for the datapacks name)
+ * @param configurer a configurer for extra options
+ * @return the discovered datapack (or null if it failed)
+ * @throws IOException if any IO error occurs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public net/minecraft/server/packs/repository/FolderRepositorySource$FolderPackDe

diff --git a/src/main/java/io/papermc/paper/datapack/PaperDatapackRegistrarImpl.java b/src/main/java/io/papermc/paper/datapack/PaperDatapackRegistrarImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..9249cf8ddd561b28695177548da020b2123a49f1
index 0000000000000000000000000000000000000000..064675ca69688d4e9aac67ec1b8318c2d0bbbb84
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datapack/PaperDatapackRegistrarImpl.java
@@ -0,0 +1,168 @@
Expand Down Expand Up @@ -70,21 +70,21 @@ index 0000000000000000000000000000000000000000..9249cf8ddd561b28695177548da020b2
+ }
+
+ @Override
+ public boolean hasPackDiscovered(final String id) {
+ return this.discoveredPacks.containsKey(id);
+ public boolean hasPackDiscovered(final String name) {
+ return this.discoveredPacks.containsKey(name);
+ }
+
+ @Override
+ public @NonNull Datapack getDiscoveredPack(final String id) {
+ if (!this.hasPackDiscovered(id)) {
+ throw new NoSuchElementException("No pack with id " + id + " was discovered");
+ public @NonNull Datapack getDiscoveredPack(final String name) {
+ if (!this.hasPackDiscovered(name)) {
+ throw new NoSuchElementException("No pack with id " + name + " was discovered");
+ }
+ return new PaperDatapack(this.discoveredPacks.get(id), this.previouslyEnabledPacks.contains(id));
+ return new PaperDatapack(this.discoveredPacks.get(name), this.previouslyEnabledPacks.contains(name));
+ }
+
+ @Override
+ public boolean removeDiscoveredPack(final String id) {
+ return this.discoveredPacks.remove(id) != null;
+ public boolean removeDiscoveredPack(final String name) {
+ return this.discoveredPacks.remove(name) != null;
+ }
+
+ @Override
Expand Down

0 comments on commit 7730a7f

Please sign in to comment.