formatting applied to most of the source code to tidy things up, and misc refactors

This commit is contained in:
nossr50
2025-07-03 14:03:43 -07:00
parent f322d05159
commit e52371aeb3
440 changed files with 11762 additions and 7365 deletions

View File

@@ -2,15 +2,14 @@ package com.gmail.nossr50.util.sounds;
import com.gmail.nossr50.config.SoundConfig;
import com.gmail.nossr50.util.Misc;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.SoundCategory;
import org.bukkit.World;
import org.bukkit.entity.Player;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class SoundManager {
private static Sound CRIPPLE_SOUND;
@@ -22,15 +21,18 @@ public class SoundManager {
/**
* Sends a sound to the player
*
* @param soundType the type of sound
*/
public static void sendSound(Player player, Location location, SoundType soundType) {
if (SoundConfig.getInstance().getIsEnabled(soundType))
if (SoundConfig.getInstance().getIsEnabled(soundType)) {
player.playSound(location, getSound(soundType),
SoundCategory.MASTER, getVolume(soundType), getPitch(soundType));
}
}
public static void sendCategorizedSound(Location location, SoundType soundType, SoundCategory soundCategory) {
public static void sendCategorizedSound(Location location, SoundType soundType,
SoundCategory soundCategory) {
if (SoundConfig.getInstance().getIsEnabled(soundType)) {
final World world = location.getWorld();
if (world != null) {
@@ -40,57 +42,69 @@ public class SoundManager {
}
}
public static void sendCategorizedSound(Location location, SoundType soundType, SoundCategory soundCategory,
float pitchModifier) {
public static void sendCategorizedSound(Location location, SoundType soundType,
SoundCategory soundCategory,
float pitchModifier) {
if (SoundConfig.getInstance().getIsEnabled(soundType)) {
final World world = location.getWorld();
if (world != null) {
float totalPitch = Math.min(2.0F, (getPitch(soundType) + pitchModifier));
world.playSound(location, getSound(soundType), soundCategory, getVolume(soundType), totalPitch);
world.playSound(location, getSound(soundType), soundCategory, getVolume(soundType),
totalPitch);
}
}
}
public static void sendCategorizedSound(Player player, Location location,
SoundType soundType, SoundCategory soundCategory) {
if (SoundConfig.getInstance().getIsEnabled(soundType))
player.playSound(location, getSound(soundType), soundCategory, getVolume(soundType), getPitch(soundType));
SoundType soundType, SoundCategory soundCategory) {
if (SoundConfig.getInstance().getIsEnabled(soundType)) {
player.playSound(location, getSound(soundType), soundCategory, getVolume(soundType),
getPitch(soundType));
}
}
public static void sendCategorizedSound(Player player, Location location,
SoundType soundType, SoundCategory soundCategory, float pitchModifier) {
SoundType soundType, SoundCategory soundCategory, float pitchModifier) {
float totalPitch = Math.min(2.0F, (getPitch(soundType) + pitchModifier));
if (SoundConfig.getInstance().getIsEnabled(soundType))
player.playSound(location, getSound(soundType), soundCategory, getVolume(soundType), totalPitch);
if (SoundConfig.getInstance().getIsEnabled(soundType)) {
player.playSound(location, getSound(soundType), soundCategory, getVolume(soundType),
totalPitch);
}
}
public static void worldSendSound(World world, Location location, SoundType soundType) {
if (SoundConfig.getInstance().getIsEnabled(soundType))
world.playSound(location, getSound(soundType), getVolume(soundType), getPitch(soundType));
if (SoundConfig.getInstance().getIsEnabled(soundType)) {
world.playSound(location, getSound(soundType), getVolume(soundType),
getPitch(soundType));
}
}
public static void worldSendSoundMaxPitch(World world, Location location, SoundType soundType) {
if (SoundConfig.getInstance().getIsEnabled(soundType))
if (SoundConfig.getInstance().getIsEnabled(soundType)) {
world.playSound(location, getSound(soundType), getVolume(soundType), 2.0F);
}
}
/**
* All volume is multiplied by the master volume to get its final value
*
* @param soundType target soundtype
* @return the volume for this soundtype
*/
private static float getVolume(SoundType soundType) {
return SoundConfig.getInstance().getVolume(soundType) * SoundConfig.getInstance().getMasterVolume();
return SoundConfig.getInstance().getVolume(soundType) * SoundConfig.getInstance()
.getMasterVolume();
}
private static float getPitch(SoundType soundType) {
if (soundType == SoundType.FIZZ)
if (soundType == SoundType.FIZZ) {
return getFizzPitch();
else if (soundType == SoundType.POP)
} else if (soundType == SoundType.POP) {
return getPopPitch();
else
} else {
return SoundConfig.getInstance().getPitch(soundType);
}
}
private static Sound getSound(SoundType soundType) {
@@ -123,7 +137,8 @@ public class SoundManager {
final Class<?> clazz = Class.forName(ORG_BUKKIT_SOUND);
final Method valueOf = clazz.getMethod(VALUE_OF);
CRIPPLE_SOUND = (Sound) valueOf.invoke(null, ITEM_MACE_SMASH_GROUND);
} catch (IllegalArgumentException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException
} catch (IllegalArgumentException | ClassNotFoundException | NoSuchMethodException |
InvocationTargetException
| IllegalAccessException e) {
CRIPPLE_SOUND = Sound.BLOCK_ANVIL_PLACE;
}