Skip to content

Commit 8053b32

Browse files
committed
v11.3.0
* Replaced all JavaX annotations with JetBrains annotations. * Added more annotations to XSkull APIs. * Fixed some errors with XSkull API (specially when used for XItemStack) (Fixes #300) * Added AggregateReflectiveSupplier * Added more tests. * XSkull will now try to create less verbose profile values which can be used for XItemStack but requires extra settings.
1 parent 95b0796 commit 8053b32

40 files changed

+1035
-606
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.github.cryptomorin</groupId>
88
<artifactId>XSeries</artifactId>
9-
<version>11.2.2</version>
9+
<version>11.3.0</version>
1010

1111
<name>XSeries</name>
1212
<description>A set of utilities for Minecraft plugins</description>

src/main/java/com/cryptomorin/xseries/NoteBlockMusic.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
import org.bukkit.plugin.Plugin;
3131
import org.bukkit.scheduler.BukkitRunnable;
3232
import org.bukkit.scheduler.BukkitTask;
33+
import org.jetbrains.annotations.NotNull;
34+
import org.jetbrains.annotations.Nullable;
3335

34-
import javax.annotation.Nonnull;
35-
import javax.annotation.Nullable;
3636
import java.io.BufferedReader;
3737
import java.io.IOException;
3838
import java.nio.charset.StandardCharsets;
@@ -118,8 +118,8 @@ public final class NoteBlockMusic {
118118
private NoteBlockMusic() {
119119
}
120120

121-
@Nonnull
122-
public static XSound getSoundFromInstrument(@Nonnull Instrument instrument) {
121+
@NotNull
122+
public static XSound getSoundFromInstrument(@NotNull Instrument instrument) {
123123
return INSTRUMENT_TO_SOUND.get(instrument);
124124
}
125125

@@ -167,7 +167,7 @@ public static Note.Tone getNoteTone(char ch) {
167167
* @return the async task handling the notes.
168168
* @since 1.0.0
169169
*/
170-
public static CompletableFuture<Void> testMusic(@Nonnull Player player) {
170+
public static CompletableFuture<Void> testMusic(@NotNull Player player) {
171171
return playMusic(player, player::getLocation, // Starting piece of Megalovania (not perfectly toned, it's screwed up)
172172
"PIANO,D,2,100 PIANO,B#1 200 PIANO,F 250 PIANO,E 250 PIANO,B 200 PIANO,A 100 PIANO,B 100 PIANO,E");
173173
}
@@ -183,7 +183,7 @@ public static CompletableFuture<Void> testMusic(@Nonnull Player player) {
183183
* @see #playMusic(Player, Supplier, String)
184184
* @since 1.0.0
185185
*/
186-
public static CompletableFuture<Void> fromFile(@Nonnull Player player, @Nonnull Supplier<Location> location, @Nonnull Path path) {
186+
public static CompletableFuture<Void> fromFile(@NotNull Player player, @NotNull Supplier<Location> location, @NotNull Path path) {
187187
return CompletableFuture.runAsync(() -> {
188188
try (BufferedReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
189189
String line;
@@ -244,7 +244,7 @@ public static CompletableFuture<Void> fromFile(@Nonnull Player player, @Nonnull
244244
* @see #fromFile(Player, Supplier, Path)
245245
* @since 1.0.0
246246
*/
247-
public static CompletableFuture<Void> playMusic(@Nonnull Player player, @Nonnull Supplier<Location> location, @Nullable String script) {
247+
public static CompletableFuture<Void> playMusic(@NotNull Player player, @NotNull Supplier<Location> location, @Nullable String script) {
248248
// We don't want to mess around in the main thread.
249249
// Sounds are thread-safe.
250250
return CompletableFuture.runAsync(() -> {
@@ -257,7 +257,7 @@ public static CompletableFuture<Void> playMusic(@Nonnull Player player, @Nonnull
257257
});
258258
}
259259

260-
public static Sequence parseInstructions(@Nonnull CharSequence script) {
260+
public static Sequence parseInstructions(@NotNull CharSequence script) {
261261
return new InstructionBuilder(script).sequence;
262262
}
263263

@@ -299,7 +299,7 @@ private static void sleep(long fermata) {
299299
* @since 3.0.0
300300
*/
301301
@Nullable
302-
public static Note parseNote(@Nonnull String note) {
302+
public static Note parseNote(@NotNull String note) {
303303
Note.Tone tone = getNoteTone((char) (note.charAt(0) & 0x5f)); // Doesn't matter if it's already uppercase.
304304
if (tone == null) return null;
305305

@@ -336,7 +336,7 @@ private static boolean isDigit(char ch) {
336336
}
337337

338338
@SuppressWarnings("deprecation")
339-
public static float noteToPitch(@Nonnull Note note) {
339+
public static float noteToPitch(@NotNull Note note) {
340340
return (float) Math.pow(2.0D, ((double) note.getId() - 12.0D) / 12.0D);
341341
}
342342

@@ -422,7 +422,7 @@ protected char checkup(char ch) {
422422

423423
@SuppressWarnings("StringBufferField")
424424
private static final class InstructionBuilder {
425-
@Nonnull final CharSequence script;
425+
@NotNull final CharSequence script;
426426
final int len;
427427
final StringBuilder
428428
instrumentBuilder = new StringBuilder(10),
@@ -436,7 +436,7 @@ private static final class InstructionBuilder {
436436
StringBuilder currentBuilder;
437437

438438

439-
public InstructionBuilder(@Nonnull CharSequence script) {
439+
public InstructionBuilder(@NotNull CharSequence script) {
440440
this.script = script;
441441
len = script.length();
442442

@@ -665,8 +665,8 @@ public String toString() {
665665
* @return the async task handling the operation.
666666
* @since 2.0.0
667667
*/
668-
@Nonnull
669-
public static BukkitTask playAscendingNote(@Nonnull Plugin plugin, @Nonnull Player player, @Nonnull Entity playTo, @Nonnull Instrument instrument,
668+
@NotNull
669+
public static BukkitTask playAscendingNote(@NotNull Plugin plugin, @NotNull Player player, @NotNull Entity playTo, @NotNull Instrument instrument,
670670
int ascendLevel, int delay) {
671671
Objects.requireNonNull(player, "Cannot play note from null player");
672672
Objects.requireNonNull(playTo, "Cannot play note to null entity");

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

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
import org.bukkit.World;
2828
import org.bukkit.block.Biome;
2929
import org.bukkit.block.Block;
30+
import org.jetbrains.annotations.NotNull;
31+
import org.jetbrains.annotations.Nullable;
3032

31-
import javax.annotation.Nonnull;
32-
import javax.annotation.Nullable;
3333
import java.util.HashMap;
3434
import java.util.Map;
3535
import java.util.Objects;
@@ -161,22 +161,22 @@ public enum XBiome {
161161
private static final boolean HORIZONTAL_SUPPORT = XMaterial.supports(16), EXTENDED_MINIMUM = XMaterial.supports(17);
162162
@Nullable
163163
private final Biome biome;
164-
@Nonnull
164+
@NotNull
165165
private final World.Environment environment;
166166

167-
XBiome(@Nonnull World.Environment environment, @Nonnull String... legacies) {
167+
XBiome(@NotNull World.Environment environment, @NotNull String... legacies) {
168168
this(environment, null, legacies);
169169
}
170170

171-
XBiome(@Nonnull String... legacies) {
171+
XBiome(@NotNull String... legacies) {
172172
this(World.Environment.NORMAL, legacies);
173173
}
174174

175-
XBiome(@Nullable XBiome newVersion, @Nonnull String... legacies) {
175+
XBiome(@Nullable XBiome newVersion, @NotNull String... legacies) {
176176
this(World.Environment.NORMAL, newVersion, legacies);
177177
}
178178

179-
XBiome(@Nonnull World.Environment environment, @Nullable XBiome newVersion, @Nonnull String... legacies) {
179+
XBiome(@NotNull World.Environment environment, @Nullable XBiome newVersion, @NotNull String... legacies) {
180180
this.environment = environment;
181181
Data.NAMES.put(this.name(), this);
182182
for (String legacy : legacies) Data.NAMES.put(legacy, this);
@@ -204,8 +204,8 @@ public enum XBiome {
204204
* @return an enum name.
205205
* @since 1.0.0
206206
*/
207-
@Nonnull
208-
private static String format(@Nonnull String name) {
207+
@NotNull
208+
private static String format(@NotNull String name) {
209209
int len = name.length();
210210
char[] chs = new char[len];
211211
int count = 0;
@@ -236,8 +236,8 @@ private static String format(@Nonnull String name) {
236236
* @return a matched XBiome.
237237
* @since 1.0.0
238238
*/
239-
@Nonnull
240-
public static Optional<XBiome> matchXBiome(@Nonnull String biome) {
239+
@NotNull
240+
public static Optional<XBiome> matchXBiome(@NotNull String biome) {
241241
if (biome == null || biome.isEmpty())
242242
throw new IllegalArgumentException("Cannot match XBiome of a null or empty biome name");
243243
return Optional.ofNullable(Data.NAMES.get(format(biome)));
@@ -251,8 +251,8 @@ public static Optional<XBiome> matchXBiome(@Nonnull String biome) {
251251
* @throws IllegalArgumentException may be thrown as an unexpected exception.
252252
* @since 1.0.0
253253
*/
254-
@Nonnull
255-
public static XBiome matchXBiome(@Nonnull Biome biome) {
254+
@NotNull
255+
public static XBiome matchXBiome(@NotNull Biome biome) {
256256
Objects.requireNonNull(biome, "Cannot match XBiome of a null biome");
257257
return Objects.requireNonNull(Data.NAMES.get(biome.name()), () -> "Unsupported biome: " + biome.name());
258258
}
@@ -293,7 +293,7 @@ public XBiome or(@Nullable XBiome alternateBiome) {
293293
* @return the environment that this biome belongs to.
294294
* @since 4.0.0
295295
*/
296-
@Nonnull
296+
@NotNull
297297
public World.Environment getEnvironment() {
298298
return environment;
299299
}
@@ -318,8 +318,8 @@ public Biome getBiome() {
318318
* @return the async task handling this operation.
319319
* @since 1.0.0
320320
*/
321-
@Nonnull
322-
public CompletableFuture<Void> setBiome(@Nonnull Chunk chunk) {
321+
@NotNull
322+
public CompletableFuture<Void> setBiome(@NotNull Chunk chunk) {
323323
Objects.requireNonNull(biome, () -> "Unsupported biome: " + this.name());
324324
Objects.requireNonNull(chunk, "Cannot set biome of null chunk");
325325
if (!chunk.isLoaded()) {
@@ -357,8 +357,8 @@ public CompletableFuture<Void> setBiome(@Nonnull Chunk chunk) {
357357
* @param end the end position.
358358
* @since 1.0.0
359359
*/
360-
@Nonnull
361-
public CompletableFuture<Void> setBiome(@Nonnull Location start, @Nonnull Location end) {
360+
@NotNull
361+
public CompletableFuture<Void> setBiome(@NotNull Location start, @NotNull Location end) {
362362
Objects.requireNonNull(start, "Start location cannot be null");
363363
Objects.requireNonNull(end, "End location cannot be null");
364364
Objects.requireNonNull(biome, () -> "Unsupported biome: " + this.name());

src/main/java/com/cryptomorin/xseries/XBlock.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
import org.bukkit.block.data.BlockData;
3232
import org.bukkit.inventory.InventoryHolder;
3333
import org.bukkit.material.*;
34+
import org.jetbrains.annotations.NotNull;
35+
import org.jetbrains.annotations.Nullable;
3436

35-
import javax.annotation.Nonnull;
36-
import javax.annotation.Nullable;
3737
import java.util.*;
3838

3939
/**
@@ -242,7 +242,7 @@ public static boolean setDirection(Block block, BlockFace facing) {
242242
return false;
243243
}
244244

245-
public static boolean setType(@Nonnull Block block, @Nullable XMaterial material, boolean applyPhysics) {
245+
public static boolean setType(@NotNull Block block, @Nullable XMaterial material, boolean applyPhysics) {
246246
Objects.requireNonNull(block, "Cannot set type of null block");
247247
if (material == null) material = XMaterial.AIR;
248248
XMaterial smartConversion = ITEM_TO_BLOCK.get(material);
@@ -406,7 +406,7 @@ public static SkullType getSkullType(XMaterial material) {
406406
}
407407
}
408408

409-
public static boolean setType(@Nonnull Block block, @Nullable XMaterial material) {
409+
public static boolean setType(@NotNull Block block, @Nullable XMaterial material) {
410410
return setType(block, material, true);
411411
}
412412

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
import org.bukkit.entity.EntityType;
3030
import org.bukkit.inventory.ItemStack;
3131
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
32+
import org.jetbrains.annotations.NotNull;
33+
import org.jetbrains.annotations.Nullable;
3234

33-
import javax.annotation.Nonnull;
34-
import javax.annotation.Nullable;
3535
import java.util.*;
3636
import java.util.stream.Collectors;
3737

@@ -146,7 +146,7 @@ public enum XEnchantment {
146146
*
147147
* @see NamespacedKey#getKey()
148148
*/
149-
XEnchantment(@Nonnull String... aliases) {
149+
XEnchantment(@NotNull String... aliases) {
150150
Enchantment enchantment = getBukkitEnchant(this.name());
151151

152152
Data.NAMES.put(this.name(), this);
@@ -205,8 +205,8 @@ public static boolean isArthropodsEffectiveAgainst(@Nullable EntityType type) {
205205
* @return an enum name.
206206
* @since 1.0.0
207207
*/
208-
@Nonnull
209-
private static String format(@Nonnull String name) {
208+
@NotNull
209+
private static String format(@NotNull String name) {
210210
int len = name.length();
211211
char[] chs = new char[len];
212212
int count = 0;
@@ -239,8 +239,8 @@ private static String format(@Nonnull String name) {
239239
* @return an enchantment.
240240
* @since 1.0.0
241241
*/
242-
@Nonnull
243-
public static Optional<XEnchantment> matchXEnchantment(@Nonnull String enchantment) {
242+
@NotNull
243+
public static Optional<XEnchantment> matchXEnchantment(@NotNull String enchantment) {
244244
if (enchantment == null || enchantment.isEmpty())
245245
throw new IllegalArgumentException("Enchantment name cannot be null or empty");
246246
return Optional.ofNullable(Data.NAMES.get(format(enchantment)));
@@ -255,9 +255,9 @@ public static Optional<XEnchantment> matchXEnchantment(@Nonnull String enchantme
255255
* @throws IllegalArgumentException may be thrown as an unexpected exception.
256256
* @since 1.0.0
257257
*/
258-
@Nonnull
258+
@NotNull
259259
@SuppressWarnings("deprecation")
260-
public static XEnchantment matchXEnchantment(@Nonnull Enchantment enchantment) {
260+
public static XEnchantment matchXEnchantment(@NotNull Enchantment enchantment) {
261261
Objects.requireNonNull(enchantment, "Cannot parse XEnchantment of a null enchantment");
262262
return Objects.requireNonNull(Data.NAMES.get(enchantment.getName()), () -> "Unsupported enchantment: " + enchantment.getName());
263263
}
@@ -269,7 +269,7 @@ public static XEnchantment matchXEnchantment(@Nonnull Enchantment enchantment) {
269269
* @return an enchanted book.
270270
* @since 1.0.0
271271
*/
272-
@Nonnull
272+
@NotNull
273273
public ItemStack getBook(int level) {
274274
ItemStack book = new ItemStack(Material.ENCHANTED_BOOK);
275275
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) book.getItemMeta();
@@ -327,7 +327,7 @@ public XEnchantment or(@Nullable XEnchantment alternateEnchantment) {
327327
* @return a friendly readable string name.
328328
*/
329329
@Override
330-
@Nonnull
330+
@NotNull
331331
public String toString() {
332332
return Arrays.stream(name().split("_"))
333333
.map(t -> t.charAt(0) + t.substring(1).toLowerCase())

src/main/java/com/cryptomorin/xseries/XEntity.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,8 @@
3838
import org.bukkit.inventory.ItemStack;
3939
import org.bukkit.loot.Lootable;
4040
import org.jetbrains.annotations.NotNull;
41+
import org.jetbrains.annotations.Nullable;
4142

42-
import javax.annotation.Nonnull;
43-
import javax.annotation.Nullable;
4443
import java.lang.invoke.MethodHandle;
4544
import java.lang.invoke.MethodHandles;
4645
import java.lang.reflect.Method;
@@ -244,7 +243,7 @@ public static boolean isUndead(@Nullable EntityType type) {
244243
}
245244

246245
@Nullable
247-
public static Entity spawn(@Nonnull Location location, @Nonnull ConfigurationSection config) {
246+
public static Entity spawn(@NotNull Location location, @NotNull ConfigurationSection config) {
248247
Objects.requireNonNull(location, "Cannot spawn entity at a null location.");
249248
Objects.requireNonNull(config, "Cannot spawn entity from a null configuration section");
250249

@@ -270,8 +269,8 @@ private static void map(Class<?> target, Entity entity, ConfigurationSection con
270269
}
271270

272271
@SuppressWarnings({"deprecation", "Guava"})
273-
@Nonnull
274-
public static Entity edit(@Nonnull Entity entity, @Nonnull ConfigurationSection config) {
272+
@NotNull
273+
public static Entity edit(@NotNull Entity entity, @NotNull ConfigurationSection config) {
275274
Objects.requireNonNull(entity, "Cannot edit properties of a null entity");
276275
Objects.requireNonNull(config, "Cannot edit an entity from a null configuration section");
277276

0 commit comments

Comments
 (0)