Skip to content

Commit 920ff3c

Browse files
committed
MC v1.21.5 support
1 parent fc4ed95 commit 920ff3c

File tree

22 files changed

+1169
-534
lines changed

22 files changed

+1169
-534
lines changed

core/.flattened-pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
<dependency>
8888
<groupId>org.spigotmc</groupId>
8989
<artifactId>spigot</artifactId>
90-
<version>1.21.4-R0.1-SNAPSHOT</version>
90+
<version>1.21.5-R0.1-SNAPSHOT</version>
9191
<scope>provided</scope>
9292
</dependency>
9393
<dependency>

core/dependency-reduced-pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
<dependency>
6868
<groupId>org.spigotmc</groupId>
6969
<artifactId>spigot</artifactId>
70-
<version>1.21.4-R0.1-SNAPSHOT</version>
70+
<version>1.21.5-R0.1-SNAPSHOT</version>
7171
<scope>provided</scope>
7272
</dependency>
7373
<dependency>

core/src/main/java/com/cryptomorin/xseries/XAttribute.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ private XAttribute(Attribute attribute, String[] names) {
101101
super(attribute, names);
102102
}
103103

104+
static {
105+
REGISTRY.discardMetadata();
106+
}
107+
104108
/**
105109
* Creates a new {@link AttributeModifier}.
106110
*

core/src/main/java/com/cryptomorin/xseries/XBiome.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ private XBiome(Biome biome, String[] names) {
203203
this(null, biome, names);
204204
}
205205

206+
static {
207+
REGISTRY.discardMetadata();
208+
}
209+
206210
/**
207211
* Gets the environment (world type) which this biome originally belongs to.
208212
* If the biome is non-standard (registered by another program) this will return {@link Optional#empty()}.

core/src/main/java/com/cryptomorin/xseries/XEnchantment.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,10 @@ public final class XEnchantment extends XModule<XEnchantment, Enchantment> {
218218
}
219219
}
220220

221+
static {
222+
REGISTRY.discardMetadata();
223+
}
224+
221225
private XEnchantment(Enchantment enchantment, String[] names) {
222226
super(enchantment, names);
223227
}

core/src/main/java/com/cryptomorin/xseries/XEntityType.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,14 @@ public enum XEntityType implements XBase<XEntityType, EntityType> {
145145
PILLAGER,
146146
PLAYER,
147147
POLAR_BEAR,
148-
POTION("SPLASH_POTION"),
148+
149+
@XInfo(since = "1.21.5")
150+
@XChange(version = "1.21.5", from = "POTION", to = "SPLASH_POTION")
151+
SPLASH_POTION("POTION"),
152+
153+
@XInfo(since = "1.21.5")
154+
LINGERING_POTION,
155+
149156
PUFFERFISH,
150157
RABBIT,
151158
RAVAGER,
@@ -208,6 +215,10 @@ private static final class Data {
208215
this.entityType = Data.REGISTRY.stdEnum(this, names);
209216
}
210217

218+
static {
219+
REGISTRY.discardMetadata();
220+
}
221+
211222
@NotNull
212223
@Unmodifiable
213224
public static Collection<XEntityType> getValues() {

core/src/main/java/com/cryptomorin/xseries/XItemFlag.java

Lines changed: 229 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,23 @@
3232
import org.jetbrains.annotations.Nullable;
3333
import org.jetbrains.annotations.Unmodifiable;
3434

35+
import java.util.Arrays;
3536
import java.util.Collection;
3637
import java.util.Optional;
3738
import java.util.Set;
3839
import java.util.stream.Collectors;
3940

41+
/**
42+
* An ItemFlag can hide some attributes from {@link ItemStack}.
43+
* These are also known as {@code HideFlags} in Vanilla Minecraft.
44+
* <p>
45+
* You might find {@link #decorationOnly(ItemMeta)} useful if you're using this for GUIs.
46+
*/
4047
public enum XItemFlag implements XBase<XItemFlag, ItemFlag> {
4148
/**
4249
* Setting to show/hide potion effects, book and firework information, map tooltips, patterns of banners.
4350
*
44-
* @see #HIDE_STORED_ENCHANTS for hiding stored enchants (like on enchanted books)
51+
* @see #HIDE_STORED_ENCHANTMENTS for hiding stored enchants (like on enchanted books)
4552
* @see XPatternType
4653
* @see org.bukkit.inventory.meta.FireworkMeta
4754
* @see org.bukkit.inventory.meta.MapMeta
@@ -88,7 +95,10 @@ public enum XItemFlag implements XBase<XItemFlag, ItemFlag> {
8895
/**
8996
* @see XEnchantment
9097
* @see ItemMeta#getEnchants()
91-
* @see #HIDE_STORED_ENCHANTS for enchantment books.
98+
* @see #HIDE_STORED_ENCHANTMENTS for enchantment books.
99+
* @see #HIDE_ENCHANTMENTS
100+
* @see #HIDE_ENCHANTMENT_GLINT_OVERRIDE
101+
* @see #HIDE_ENCHANTABLE
92102
*/
93103
HIDE_ENCHANTS,
94104

@@ -120,18 +130,212 @@ public enum XItemFlag implements XBase<XItemFlag, ItemFlag> {
120130
* @see org.bukkit.inventory.meta.EnchantmentStorageMeta
121131
*/
122132
@XInfo(since = "1.21.3")
123-
HIDE_STORED_ENCHANTS,
133+
@XChange(version = "1.21.5", from = "HIDE_STORED_ENCHANTS", to = "HIDE_STORED_ENCHANTMENTS")
134+
HIDE_STORED_ENCHANTMENTS("HIDE_STORED_ENCHANTS"),
124135

125136
/**
126137
* This is not the same as {@link XEnchantment#UNBREAKING} enchant.
127138
* For the blue "Unbreakable" text below attributes.
128139
*
129140
* @see ItemMeta#setUnbreakable(boolean)
130141
*/
131-
HIDE_UNBREAKABLE;
142+
HIDE_UNBREAKABLE,
143+
144+
@XInfo(since = "1.21.5")
145+
HIDE_CUSTOM_DATA,
146+
@XInfo(since = "1.21.5")
147+
HIDE_MAX_STACK_SIZE,
148+
@XInfo(since = "1.21.5")
149+
HIDE_MAX_DAMAGE,
150+
@XInfo(since = "1.21.5")
151+
HIDE_DAMAGE,
152+
@XInfo(since = "1.21.5")
153+
HIDE_CUSTOM_NAME,
154+
@XInfo(since = "1.21.5")
155+
HIDE_ITEM_NAME,
156+
@XInfo(since = "1.21.5")
157+
HIDE_ITEM_MODEL,
158+
@XInfo(since = "1.21.5")
159+
HIDE_LORE,
160+
@XInfo(since = "1.21.5")
161+
HIDE_RARITY,
162+
@XInfo(since = "1.21.5")
163+
HIDE_ENCHANTMENTS,
164+
@XInfo(since = "1.21.5")
165+
HIDE_CAN_PLACE_ON,
166+
@XInfo(since = "1.21.5")
167+
HIDE_CAN_BREAK,
168+
@XInfo(since = "1.21.5")
169+
HIDE_ATTRIBUTE_MODIFIERS,
170+
@XInfo(since = "1.21.5")
171+
HIDE_CUSTOM_MODEL_DATA,
172+
@XInfo(since = "1.21.5")
173+
HIDE_TOOLTIP_DISPLAY,
174+
@XInfo(since = "1.21.5")
175+
HIDE_REPAIR_COST,
176+
@XInfo(since = "1.21.5")
177+
HIDE_CREATIVE_SLOT_LOCK,
178+
@XInfo(since = "1.21.5")
179+
HIDE_ENCHANTMENT_GLINT_OVERRIDE,
180+
@XInfo(since = "1.21.5")
181+
HIDE_INTANGIBLE_PROJECTILE,
182+
@XInfo(since = "1.21.5")
183+
HIDE_FOOD,
184+
@XInfo(since = "1.21.5")
185+
HIDE_CONSUMABLE,
186+
@XInfo(since = "1.21.5")
187+
HIDE_USE_REMAINDER,
188+
@XInfo(since = "1.21.5")
189+
HIDE_USE_COOLDOWN,
190+
@XInfo(since = "1.21.5")
191+
HIDE_DAMAGE_RESISTANT,
192+
@XInfo(since = "1.21.5")
193+
HIDE_TOOL,
194+
@XInfo(since = "1.21.5")
195+
HIDE_WEAPON,
196+
@XInfo(since = "1.21.5")
197+
HIDE_ENCHANTABLE,
198+
@XInfo(since = "1.21.5")
199+
HIDE_EQUIPPABLE,
200+
@XInfo(since = "1.21.5")
201+
HIDE_REPAIRABLE,
202+
@XInfo(since = "1.21.5")
203+
HIDE_GLIDER,
204+
@XInfo(since = "1.21.5")
205+
HIDE_TOOLTIP_STYLE,
206+
@XInfo(since = "1.21.5")
207+
HIDE_DEATH_PROTECTION,
208+
@XInfo(since = "1.21.5")
209+
HIDE_BLOCKS_ATTACKS,
210+
@XInfo(since = "1.21.5")
211+
HIDE_DYED_COLOR,
212+
@XInfo(since = "1.21.5")
213+
HIDE_MAP_COLOR,
214+
@XInfo(since = "1.21.5")
215+
HIDE_MAP_ID,
216+
@XInfo(since = "1.21.5")
217+
HIDE_MAP_DECORATIONS,
218+
@XInfo(since = "1.21.5")
219+
HIDE_MAP_POST_PROCESSING,
220+
@XInfo(since = "1.21.5")
221+
HIDE_CHARGED_PROJECTILES,
222+
@XInfo(since = "1.21.5")
223+
HIDE_BUNDLE_CONTENTS,
224+
@XInfo(since = "1.21.5")
225+
HIDE_POTION_CONTENTS,
226+
@XInfo(since = "1.21.5")
227+
HIDE_POTION_DURATION_SCALE,
228+
@XInfo(since = "1.21.5")
229+
HIDE_SUSPICIOUS_STEW_EFFECTS,
230+
@XInfo(since = "1.21.5")
231+
HIDE_WRITABLE_BOOK_CONTENT,
232+
@XInfo(since = "1.21.5")
233+
HIDE_WRITTEN_BOOK_CONTENT,
234+
@XInfo(since = "1.21.5")
235+
HIDE_TRIM,
236+
@XInfo(since = "1.21.5")
237+
HIDE_DEBUG_STICK_STATE,
238+
@XInfo(since = "1.21.5")
239+
HIDE_ENTITY_DATA,
240+
@XInfo(since = "1.21.5")
241+
HIDE_BUCKET_ENTITY_DATA,
242+
@XInfo(since = "1.21.5")
243+
HIDE_BLOCK_ENTITY_DATA,
244+
@XInfo(since = "1.21.5")
245+
HIDE_INSTRUMENT,
246+
@XInfo(since = "1.21.5")
247+
HIDE_PROVIDES_TRIM_MATERIAL,
248+
@XInfo(since = "1.21.5")
249+
HIDE_OMINOUS_BOTTLE_AMPLIFIER,
250+
@XInfo(since = "1.21.5")
251+
HIDE_JUKEBOX_PLAYABLE,
252+
@XInfo(since = "1.21.5")
253+
HIDE_PROVIDES_BANNER_PATTERNS,
254+
@XInfo(since = "1.21.5")
255+
HIDE_RECIPES,
256+
@XInfo(since = "1.21.5")
257+
HIDE_LODESTONE_TRACKER,
258+
@XInfo(since = "1.21.5")
259+
HIDE_FIREWORK_EXPLOSION,
260+
@XInfo(since = "1.21.5")
261+
HIDE_FIREWORKS,
262+
@XInfo(since = "1.21.5")
263+
HIDE_PROFILE,
264+
@XInfo(since = "1.21.5")
265+
HIDE_NOTE_BLOCK_SOUND,
266+
@XInfo(since = "1.21.5")
267+
HIDE_BANNER_PATTERNS,
268+
@XInfo(since = "1.21.5")
269+
HIDE_BASE_COLOR,
270+
@XInfo(since = "1.21.5")
271+
HIDE_POT_DECORATIONS,
272+
@XInfo(since = "1.21.5")
273+
HIDE_CONTAINER,
274+
@XInfo(since = "1.21.5")
275+
HIDE_BLOCK_STATE,
276+
@XInfo(since = "1.21.5")
277+
HIDE_BEES,
278+
@XInfo(since = "1.21.5")
279+
HIDE_LOCK,
280+
@XInfo(since = "1.21.5")
281+
HIDE_CONTAINER_LOOT,
282+
@XInfo(since = "1.21.5")
283+
HIDE_BREAK_SOUND,
284+
@XInfo(since = "1.21.5")
285+
HIDE_VILLAGER_VARIANT,
286+
@XInfo(since = "1.21.5")
287+
HIDE_WOLF_VARIANT,
288+
@XInfo(since = "1.21.5")
289+
HIDE_WOLF_SOUND_VARIANT,
290+
@XInfo(since = "1.21.5")
291+
HIDE_WOLF_COLLAR,
292+
@XInfo(since = "1.21.5")
293+
HIDE_FOX_VARIANT,
294+
@XInfo(since = "1.21.5")
295+
HIDE_SALMON_SIZE,
296+
@XInfo(since = "1.21.5")
297+
HIDE_PARROT_VARIANT,
298+
@XInfo(since = "1.21.5")
299+
HIDE_TROPICAL_FISH_PATTERN,
300+
@XInfo(since = "1.21.5")
301+
HIDE_TROPICAL_FISH_BASE_COLOR,
302+
@XInfo(since = "1.21.5")
303+
HIDE_TROPICAL_FISH_PATTERN_COLOR,
304+
@XInfo(since = "1.21.5")
305+
HIDE_MOOSHROOM_VARIANT,
306+
@XInfo(since = "1.21.5")
307+
HIDE_RABBIT_VARIANT,
308+
@XInfo(since = "1.21.5")
309+
HIDE_PIG_VARIANT,
310+
@XInfo(since = "1.21.5")
311+
HIDE_COW_VARIANT,
312+
@XInfo(since = "1.21.5")
313+
HIDE_CHICKEN_VARIANT,
314+
@XInfo(since = "1.21.5")
315+
HIDE_FROG_VARIANT,
316+
@XInfo(since = "1.21.5")
317+
HIDE_HORSE_VARIANT,
318+
@XInfo(since = "1.21.5")
319+
HIDE_PAINTING_VARIANT,
320+
@XInfo(since = "1.21.5")
321+
HIDE_LLAMA_VARIANT,
322+
@XInfo(since = "1.21.5")
323+
HIDE_AXOLOTL_VARIANT,
324+
@XInfo(since = "1.21.5")
325+
HIDE_CAT_VARIANT,
326+
@XInfo(since = "1.21.5")
327+
HIDE_CAT_COLLAR,
328+
@XInfo(since = "1.21.5")
329+
HIDE_SHEEP_COLOR,
330+
@XInfo(since = "1.21.5")
331+
HIDE_SHULKER_COLOR;
132332

133333
public static final XRegistry<XItemFlag, ItemFlag> REGISTRY = Data.REGISTRY;
134-
private static final ItemFlag[] BUKKIT_VALUES = ItemFlag.values();
334+
private static final ItemFlag[] NONE_DECORATION_FLAGS = Arrays.stream(XItemFlag.values())
335+
.filter(x -> x != HIDE_LORE && x != HIDE_ITEM_NAME && x != HIDE_CUSTOM_NAME)
336+
.filter(XBase::isSupported)
337+
.map(XItemFlag::get)
338+
.toArray(ItemFlag[]::new);
135339

136340
private final ItemFlag itemFlag;
137341

@@ -144,6 +348,10 @@ private static final class Data {
144348
new XRegistry<>(ItemFlag.class, XItemFlag.class, XItemFlag[]::new);
145349
}
146350

351+
static {
352+
REGISTRY.discardMetadata();
353+
}
354+
147355
public static XItemFlag of(ItemFlag itemFlag) {
148356
return REGISTRY.getByBukkitForm(itemFlag);
149357
}
@@ -205,9 +413,23 @@ public boolean has(ItemMeta meta) {
205413
}
206414

207415
/**
208-
* Useful for decorative items.
416+
* @deprecated The name of this method is misleading as of {@code v1.21.5}. Use {@link #decorationOnly(ItemMeta)} instead.
209417
*/
418+
@Deprecated
210419
public static void hideEverything(ItemMeta meta) {
211-
meta.addItemFlags(BUKKIT_VALUES);
420+
decorationOnly(meta);
421+
}
422+
423+
/**
424+
* This is mostly meant for items inside GUIs. It hides everything
425+
* that would be considered redundant/metadata to show to the player.
426+
* For example, the item attributes, blocks it can break/place, item id, etc.
427+
* There are some rare cases where some of these attributes could be considered
428+
* useful even in a GUI, but not in most cases when used as decoration.
429+
*
430+
* @since 13.2.0
431+
*/
432+
public static void decorationOnly(ItemMeta meta) {
433+
meta.addItemFlags(NONE_DECORATION_FLAGS);
212434
}
213435
}

0 commit comments

Comments
 (0)