fix: Annotation on annotation

Yeah I'm dumb I know. But whatever this code doesn't have any real value
anyways other than finding weird things about java. Like really why am I
doing this to my self.

Why do I even code? What’s the point? Does it even matter? I don’t even enjoy it—I do it because I’m not good at anything else. I've lost all motivation to code. I have about 30 unfinished projects and not a single one completed.

I go to school, but honestly, it feels like a waste of time... Yet, what else would I do? Code? For what? What is programming even for?
Sometimes I wonder, what value do I even have in this life?

What’s the point of school? To get a good job? And what’s the point of a good job? Money? And money—what for? To survive? And surviving—for what? To... To...

Why am I even coding in Java? Why do I do this to myself? I could be peacefully writing in Rust, but no—I’m stuck here, suffering with this cursed Java.

Hope nobody’s reading this. And if you are, well—I hope you have a great day.
Got a little carried away there. Alright, back to focusing on English class...

But why should I? I can speak English just fine. Why do we study history? "Because it’s basic knowledge." Yeah, well, you can shove your basic knowledge where the sun doesn’t shine.

I feel like I’m wasting my life. The last five years...
This commit is contained in:
Jakub Žitník 2025-03-28 08:50:53 +01:00
parent a8e80c405d
commit 25fb664b8d
Signed by: jzitnik
GPG Key ID: C577A802A6AF4EF3
2 changed files with 17 additions and 22 deletions

View File

@ -208,8 +208,8 @@ public class Game extends AutoTransientSupport {
for (Block block : blocks) {
if (block.getClass().isAnnotationPresent(MiningSound.class)) {
new Thread(() -> {
gameStates.dependencies.sound.playSound(configuration,
block.getClass().getAnnotation(MiningSound.class).value());
var anot = block.getClass().getAnnotation(MiningSound.class);
gameStates.dependencies.sound.playSound(configuration, anot.value(), anot.annotationType());
}).start();
}
}
@ -223,8 +223,8 @@ public class Game extends AutoTransientSupport {
for (Block block : blocks) {
if (block.getClass().isAnnotationPresent(MiningSound.class)) {
new Thread(() -> {
gameStates.dependencies.sound.playSound(configuration,
block.getClass().getAnnotation(MiningSound.class).value());
var anot = block.getClass().getAnnotation(MiningSound.class);
gameStates.dependencies.sound.playSound(configuration, anot.value(), anot.annotationType());
}).start();
}
}
@ -238,8 +238,8 @@ public class Game extends AutoTransientSupport {
for (Block block : blocks) {
if (block.getClass().isAnnotationPresent(MiningSound.class)) {
new Thread(() -> {
gameStates.dependencies.sound.playSound(configuration,
block.getClass().getAnnotation(MiningSound.class).value());
var anot = block.getClass().getAnnotation(MiningSound.class);
gameStates.dependencies.sound.playSound(configuration, anot.value(), anot.annotationType());
}).start();
}
}
@ -309,10 +309,9 @@ public class Game extends AutoTransientSupport {
for (Block block : blocksCopy) {
if (block.getClass().isAnnotationPresent(MineSound.class)) {
var key = block.getClass().getAnnotation(MineSound.class).value();
new Thread(() -> {
gameStates.dependencies.sound.playSound(configuration, key);
var anot = block.getClass().getAnnotation(MiningSound.class);
gameStates.dependencies.sound.playSound(configuration, anot.value(), anot.annotationType());
}).start();
}
}
@ -473,9 +472,8 @@ public class Game extends AutoTransientSupport {
blocks.removeAll(blocksRemove);
for (Block block : blocks) {
if (block.getClass().isAnnotationPresent(PlaceSound.class)) {
var key = block.getClass().getAnnotation(PlaceSound.class).value();
gameStates.dependencies.sound.playSound(configuration, key);
var anot = block.getClass().getAnnotation(PlaceSound.class);
gameStates.dependencies.sound.playSound(configuration, anot.value(), anot.annotationType());
}
}
gameStates.dependencies.eventHandlerProvider.handlePlace(screenRenderer, this, x, y);
@ -518,9 +516,8 @@ public class Game extends AutoTransientSupport {
for (Block block : blocks) {
if (block.getClass().isAnnotationPresent(WalkSound.class)) {
var key = block.getClass().getAnnotation(WalkSound.class).value();
gameStates.dependencies.sound.playSound(configuration, key);
var anot = block.getClass().getAnnotation(WalkSound.class);
gameStates.dependencies.sound.playSound(configuration, anot.value(), anot.annotationType());
}
}
}

View File

@ -1,6 +1,7 @@
package cz.jzitnik.game.core.sound;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.util.HashMap;
import java.util.Random;
import java.util.Set;
@ -37,7 +38,7 @@ public class Sound {
}
}
public void playSound(Configuration configuration, SoundKey soundKey) {
public void playSound(Configuration configuration, SoundKey soundKey, Class<? extends Annotation> anot) {
var volume = configuration.getSoundVolume();
var annotation = map.get(soundKey);
@ -45,17 +46,14 @@ public class Sound {
var resources = annotation.resourceLocation();
var resource = resources[random.nextInt(resources.length)];
var typeVolume = annotation.getClass().isAnnotationPresent(SoundTypeSet.class)
? annotation.getClass().getAnnotation(SoundTypeSet.class).value().getVolume()
var typeVolume = anot.isAnnotationPresent(SoundTypeSet.class)
? anot.getAnnotation(SoundTypeSet.class).value().getVolume()
: 0;
log.debug("Type volume: {}", typeVolume);
log.debug("Config volume: {}", volume);
new Thread(() -> {
try {
SoundPlayer.playSound(resource, typeVolume, volume);
} catch (LineUnavailableException | IOException | UnsupportedAudioFileException e) {
} catch (LineUnavailableException | IOException | UnsupportedAudioFileException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}