Skip to content

Commit

Permalink
6.9.14
Browse files Browse the repository at this point in the history
  • Loading branch information
kangarko committed Jan 6, 2025
1 parent 7841b46 commit 78b5841
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 46 deletions.
9 changes: 5 additions & 4 deletions jitpack.yml
Original file line number Diff line number Diff line change
@@ -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
- openjdk23
before_install:
- sdk install maven
install:
- mvn clean install -Dmaven.javadoc.skip=true -DskipTests
27 changes: 18 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<groupId>org.mineacademy</groupId>
<artifactId>Foundation</artifactId>
<version>6.9.13</version>
<version>6.9.14</version>
<packaging>jar</packaging>

<name>Foundation</name>
Expand All @@ -19,6 +19,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<lombok.version>1.18.36</lombok.version>
</properties>

<repositories>
Expand Down Expand Up @@ -46,15 +47,15 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.34</version>
<version>${lombok.version}</version>
</dependency>

<!-- This is NOT used anywhere in Foundation, only here to prevent compile
errors from missing the log4j dependency that is shipped in the server jar -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.23.1</version>
<version>2.24.3</version>
<scope>provided</scope>
</dependency>

Expand All @@ -70,6 +71,8 @@
<dependency>
<groupId>com.mojang</groupId>
<artifactId>datafixerupper</artifactId>

<!-- DO NOT CHANGE VERSION - breaks 1.8.8 -->
<version>4.0.26</version>
</dependency>

Expand Down Expand Up @@ -204,19 +207,18 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<version>3.4.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.12.1</version>
<version>3.13.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<!-- Incompatible with Java 21 and jitpack -->
<!--<plugin>
<plugin>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-maven-plugin</artifactId>
<version>1.18.20.0</version>
Expand All @@ -233,11 +235,18 @@
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.6.3</version>
<version>3.11.2</version>
<configuration>
<doclint>none</doclint>
</configuration>
Expand All @@ -249,7 +258,7 @@
</goals>
</execution>
</executions>
</plugin>-->
</plugin>
</plugins>
</build>
</project>
54 changes: 21 additions & 33 deletions src/main/java/org/mineacademy/fo/remain/CompSound.java
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand All @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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)
Expand All @@ -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();

Expand All @@ -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");

Expand All @@ -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)
Expand Down Expand Up @@ -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();
}

// ------------------------------------------------------------------------------------------------------------
Expand All @@ -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));
}

Expand All @@ -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;
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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");
Expand All @@ -2018,12 +2013,5 @@ public void run() {
* Bukkit to legacy and back names translation.
*/
class Data {

static final Map<String, Sound> BUKKIT_NAMES = new WeakHashMap<>();
static final Map<String, CompSound> NAMES = new HashMap<>();

static {
for (final Sound sound : ReflectionUtil.getEnumValues(Sound.class))
BUKKIT_NAMES.put(ReflectionUtil.getEnumName(sound), sound);
}
}

0 comments on commit 78b5841

Please sign in to comment.