SPIGOT-7195, SPIGOT-7197: Add DataPack API

By: Doc <nachito94@msn.com>
This commit is contained in:
Bukkit/Spigot
2023-05-30 19:05:41 +10:00
parent dc42ac1025
commit f45d2e6a77
10 changed files with 283 additions and 0 deletions

View File

@@ -0,0 +1,107 @@
package org.bukkit.packs;
import java.util.Set;
import org.bukkit.FeatureFlag;
import org.bukkit.Keyed;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
/**
* Represents a data pack.
*/
@ApiStatus.Experimental
public interface DataPack extends Keyed {
/**
* Gets the title of the data pack.
*
* @return the title
*/
@NotNull
public String getTitle();
/**
* Gets the description of the data pack.
*
* @return the description
*/
@NotNull
public String getDescription();
/**
* Gets the pack version.
* <br>
* This is related to the server version to work.
*
* @return the pack version
*/
public int getPackFormat();
/**
* Gets if the data pack is enabled on the server.
*
* @return True if is enabled
*/
public boolean isEnabled();
/**
* Gets if the data pack is required on the server.
*
* @return True if is required
*/
public boolean isRequired();
/**
* Gets the compatibility of this data pack with the server.
*
* @return an enum
*/
@NotNull
public Compatibility getCompatibility();
/**
* Gets a set of features requested by this data pack.
*
* @return a set of features
*/
@NotNull
public Set<FeatureFlag> getRequestedFeatures();
/**
* Gets the source of this data pack.
*
* @return the source
*/
@NotNull
public Source getSource();
/**
* Show the compatibility of the data pack with the server.
*/
public enum Compatibility {
/**
* It's newer than the server pack version.
*/
NEW,
/**
* It's older than the server pack version.
*/
OLD,
/**
* Its compatible with the server pack version.
*/
COMPATIBLE;
}
/**
* Represent the source of a data pack.
*/
public enum Source {
DEFAULT,
BUILT_IN,
FEATURE,
WORLD,
SERVER;
}
}

View File

@@ -0,0 +1,70 @@
package org.bukkit.packs;
import java.util.Collection;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.World;
import org.bukkit.entity.EntityType;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Manager of data packs.
*/
@ApiStatus.Experimental
public interface DataPackManager {
/**
* Return all the available {@link DataPack}s on the server.
*
* @return a Collection of {@link DataPack}
*/
@NotNull
public Collection<DataPack> getDataPacks();
/**
* Gets a {@link DataPack} by its key.
*
* @param dataPackKey the key of the {@link DataPack}
* @return the {@link DataPack} or null if it does not exist
*/
@Nullable
public DataPack getDataPack(@NotNull NamespacedKey dataPackKey);
/**
* Return all the enabled {@link DataPack} in the World.
*
* @param world the world to search
* @return a Collection of {@link DataPack}
*/
@NotNull
public Collection<DataPack> getEnabledDataPacks(@NotNull World world);
/**
* Return all the disabled {@link DataPack} in the World.
*
* @param world the world to search
* @return a Collection of {@link DataPack}
*/
@NotNull
public Collection<DataPack> getDisabledDataPacks(@NotNull World world);
/**
* Gets if the Material is enabled for use by the features in World.
*
* @param material Material to check (needs to be an {@link Material#isItem()} or {@link Material#isBlock()})
* @param world World to check
* @return {@code True} if the Item/Block related to the material is enabled
*/
public boolean isEnabledByFeature(@NotNull Material material, @NotNull World world);
/**
* Gets if the EntityType is enabled for use by the Features in World.
*
* @param entityType EntityType to check
* @param world World to check
* @return {@code True} if the type of entity is enabled
*/
public boolean isEnabledByFeature(@NotNull EntityType entityType, @NotNull World world);
}

View File

@@ -0,0 +1,5 @@
/**
* Classes dedicated to handling data pack information.
*/
@org.jetbrains.annotations.ApiStatus.Experimental
package org.bukkit.packs;