Merge branch 'master' of https://hub.spigotmc.org/stash/scm/~derfrzocker/bukkit into enums-to-registers

 Conflicts:
	src/main/java/org/bukkit/Material.java
	src/main/java/org/bukkit/UnsafeValues.java
This commit is contained in:
DerFrZocker 2022-03-05 13:56:39 +01:00
commit 7d3a91d3cf
No known key found for this signature in database
GPG key ID: 713F71FFFE1DDF91
3 changed files with 67 additions and 0 deletions

View file

@ -8,6 +8,7 @@ import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeModifier;
import org.bukkit.block.BlockType;
import org.bukkit.block.data.BlockData;
import org.bukkit.inventory.CreativeCategory;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemType;
import org.bukkit.material.MaterialData;
@ -2688,4 +2689,14 @@ public interface Material extends Keyed, Comparable<Material> {
*/
@Deprecated
public abstract int ordinal();
/**
* Get the {@link CreativeCategory} to which this material belongs.
*
* @return the creative category. null if does not belong to a category
*/
@Nullable
public CreativeCategory getCreativeCategory() {
return Bukkit.getUnsafe().getCreativeCategory(this);
}
}

View file

@ -2,6 +2,7 @@ package org.bukkit;
import org.bukkit.advancement.Advancement;
import org.bukkit.block.data.BlockData;
import org.bukkit.inventory.CreativeCategory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
import org.bukkit.plugin.InvalidPluginException;
@ -74,4 +75,6 @@ public interface UnsafeValues {
@Deprecated
Material createLegacyMaterial(String name, int id, int maxStackSize, short maxDurability, Class<? extends MaterialData> materialData);
CreativeCategory getCreativeCategory(Material material);
}

View file

@ -0,0 +1,53 @@
package org.bukkit.inventory;
/**
* Represents a category in the creative inventory.
*/
public enum CreativeCategory {
/**
* An assortment of building blocks including dirt, bricks, planks, ores
* slabs, etc.
*/
BUILDING_BLOCKS,
/**
* Blocks and items typically used for decorative purposes including
* candles, saplings, flora, fauna, fences, walls, carpets, etc.
*/
DECORATIONS,
/**
* Blocks used and associated with redstone contraptions including buttons,
* levers, pressure plates, redstone components, pistons, etc.
*/
REDSTONE,
/**
* Items pertaining to transportation including minecarts, rails, boats,
* elytra, etc.
*/
TRANSPORTATION,
/**
* Miscellaneous items and blocks that do not fit into other categories
* including gems, dyes, spawn eggs, discs, banner patterns, etc.
*/
MISC,
/**
* Food items consumable by the player including meats, berries, edible
* drops from creatures, etc.
*/
FOOD,
/**
* Equipment items meant for general utility including pickaxes, axes, hoes,
* flint and steel, and useful enchantment books for said tools.
*/
TOOLS,
/**
* Equipment items meant for combat including armor, swords, bows, tipped
* arrows, and useful enchantment books for said equipment.
*/
COMBAT,
/**
* All items related to brewing and potions including all types of potions,
* their variants, and ingredients to brew them.
*/
BREWING;
}