diff --git a/jitpack.yml b/jitpack.yml index 9bb03932..49f4f6fe 100644 --- a/jitpack.yml +++ b/jitpack.yml @@ -1,5 +1,6 @@ -before_install: - - wget https://github.com/sormuras/bach/raw/master/install-jdk.sh - - source ./install-jdk.sh --feature 21 jdk: - - openjdk21 \ No newline at end of file + - openjdk23 +before_install: + - sdk install maven +install: + - mvn clean install -Dmaven.javadoc.skip=true -DskipTests \ No newline at end of file diff --git a/pom.xml b/pom.xml index a81b5ece..8bb47f0c 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ org.mineacademy Foundation - 6.9.13 + 6.9.14 jar Foundation @@ -19,6 +19,7 @@ UTF-8 1.8 + 1.18.36 @@ -46,7 +47,7 @@ org.projectlombok lombok - 1.18.34 + ${lombok.version} 4.0.26 @@ -204,19 +207,18 @@ org.apache.maven.plugins maven-jar-plugin - 3.3.0 + 3.4.2 org.apache.maven.plugins maven-compiler-plugin - 3.12.1 + 3.13.0 ${java.version} ${java.version} - - + diff --git a/src/main/java/org/mineacademy/fo/remain/CompSound.java b/src/main/java/org/mineacademy/fo/remain/CompSound.java index d27612a6..799dbd49 100644 --- a/src/main/java/org/mineacademy/fo/remain/CompSound.java +++ b/src/main/java/org/mineacademy/fo/remain/CompSound.java @@ -1,10 +1,7 @@ package org.mineacademy.fo.remain; -import java.util.Arrays; import java.util.HashMap; import java.util.Map; -import java.util.WeakHashMap; -import java.util.stream.Collectors; import javax.annotation.Nullable; @@ -1386,7 +1383,7 @@ public enum CompSound { ENTITY_VILLAGER_DEATH("VILLAGER_DEATH"), ENTITY_VILLAGER_HURT("VILLAGER_HIT"), ENTITY_VILLAGER_NO("VILLAGER_NO"), - ENTITY_VILLAGER_TRADE("VILLAGER_HAGGLE", "ENTITY_VILLAGER_TRADING"), + ENTITY_VILLAGER_TRADE("VILLAGER_HAGGLE", "ENTITY_VILLAGER_TRADING", "VILLAGER_TRADE"), ENTITY_VILLAGER_WORK_ARMORER, ENTITY_VILLAGER_WORK_BUTCHER, ENTITY_VILLAGER_WORK_CARTOGRAPHER, @@ -1723,12 +1720,12 @@ public enum CompSound { @Getter private final boolean modern; - CompSound(String... legacyNames) { - Sound bukkitSound = Data.BUKKIT_NAMES.get(this.name()); + CompSound(final String... legacyNames) { + Sound bukkitSound = ReflectionUtil.lookupEnumSilent(Sound.class, this.name()); if (bukkitSound == null) - for (final String legacy : legacyNames) { - bukkitSound = Data.BUKKIT_NAMES.get(legacy); + for (final String legacyName : legacyNames) { + bukkitSound = ReflectionUtil.lookupEnumSilent(Sound.class, legacyName); if (bukkitSound != null) break; @@ -1749,7 +1746,7 @@ public enum CompSound { * * @param location the location to play the sound in. */ - public void play(Location location) { + public void play(final Location location) { this.play(location, DEFAULT_VOLUME, DEFAULT_PITCH); } @@ -1760,7 +1757,7 @@ public void play(Location location) { * * @since 1.0.0 */ - public void play(Entity entity) { + public void play(final Entity entity) { this.play(entity, DEFAULT_VOLUME, DEFAULT_PITCH); } @@ -1771,14 +1768,14 @@ public void play(Entity entity) { * @param volume the volume of the sound, 1 is normal. * @param pitch the pitch of the sound, 0 is normal. */ - public void play(@NonNull Location location, float volume, float pitch) { + public void play(@NonNull final Location location, final float volume, final float pitch) { if (Bukkit.isPrimaryThread()) this.play0(location, volume, pitch); else Common.runLater(() -> this.play0(location, volume, pitch)); } - private void play0(@NonNull Location location, float volume, float pitch) { + private void play0(@NonNull final Location location, final float volume, final float pitch) { final Sound sound = this.getSound(); if (sound != null) @@ -1792,14 +1789,14 @@ private void play0(@NonNull Location location, float volume, float pitch) { * @param volume the volume of the sound, 1 is normal. * @param pitch the pitch of the sound, 0 is normal. */ - public void play(@NonNull Entity entity, float volume, float pitch) { + public void play(@NonNull final Entity entity, final float volume, final float pitch) { if (Bukkit.isPrimaryThread()) this.play0(entity, volume, pitch); else Common.runLater(() -> this.play0(entity, volume, pitch)); } - private void play0(@NonNull Entity entity, float volume, float pitch) { + private void play0(@NonNull final Entity entity, final float volume, final float pitch) { if (entity instanceof Player) { final Sound sound = this.getSound(); @@ -1822,7 +1819,7 @@ private void play0(@NonNull Entity entity, float volume, float pitch) { * @return the async task handling this operation. * @see #play(Location, float, float) */ - public BukkitTask playRepeatedly(@NonNull Entity entity, float volume, float pitch, int repeat, int delay) { + public BukkitTask playRepeatedly(@NonNull final Entity entity, final float volume, final float pitch, final int repeat, final int delay) { if (repeat <= 0) throw new IllegalArgumentException("Cannot repeat playing sound " + repeat + " times"); @@ -1848,14 +1845,14 @@ public void run() { * * @see #stopMusic(Player) */ - public void stopSound(@NonNull Player player) { + public void stopSound(@NonNull final Player player) { if (Bukkit.isPrimaryThread()) - stopSound0(player); + this.stopSound0(player); else - Common.runLater(() -> stopSound0(player)); + Common.runLater(() -> this.stopSound0(player)); } - private void stopSound0(@NonNull Player player) { + private void stopSound0(@NonNull final Player player) { final Sound sound = this.getSound(); if (sound != null) @@ -1883,9 +1880,7 @@ public Sound getSound() { */ @Override public String toString() { - return Arrays.stream(this.name().split("_")) - .map(t -> t.charAt(0) + t.substring(1).toLowerCase()) - .collect(Collectors.joining(" ")); + return this.name().toLowerCase(); } // ------------------------------------------------------------------------------------------------------------ @@ -1899,7 +1894,7 @@ public String toString() { * * @return a matched sound. */ - public static CompSound fromSound(@NonNull Sound sound) { + public static CompSound fromSound(@NonNull final Sound sound) { return Data.NAMES.get(ReflectionUtil.getEnumName(sound)); } @@ -1911,7 +1906,7 @@ public static CompSound fromSound(@NonNull Sound sound) { * @return a matched CompSound. */ @Nullable - public static CompSound fromName(@NonNull String soundName) { + public static CompSound fromName(@NonNull final String soundName) { final int len = soundName.length(); final char[] chs = new char[len]; int count = 0; @@ -1955,7 +1950,7 @@ public static CompSound fromName(@NonNull String soundName) { * * @see #stopSound(Player) */ - public static void stopMusic(@NonNull Player player) { + public static void stopMusic(@NonNull final Player player) { // We don't need to cache because it's rarely used. final CompSound[] musics = { @@ -1991,7 +1986,7 @@ public static void stopMusic(@NonNull Player player) { * * @return the async task handling the operation. */ - public static BukkitTask playAscendingNote(@NonNull Player player, @NonNull Entity playTo, Instrument instrument, int ascendLevel, int delay) { + public static BukkitTask playAscendingNote(@NonNull final Player player, @NonNull final Entity playTo, final Instrument instrument, final int ascendLevel, final int delay) { if (ascendLevel <= 0) throw new IllegalArgumentException("Note ascend level cannot be lower than 1"); @@ -2018,12 +2013,5 @@ public void run() { * Bukkit to legacy and back names translation. */ class Data { - - static final Map BUKKIT_NAMES = new WeakHashMap<>(); static final Map NAMES = new HashMap<>(); - - static { - for (final Sound sound : ReflectionUtil.getEnumValues(Sound.class)) - BUKKIT_NAMES.put(ReflectionUtil.getEnumName(sound), sound); - } } \ No newline at end of file