chore: Minor changes
This commit is contained in:
parent
5d37f7d74f
commit
fd6fcf950c
@ -253,7 +253,7 @@ public class Game implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
if (inventory.getItemInHand().isPresent()) {
|
||||
if (inventory.getItemInHand().isPresent() && inventory.getItemInHand().get().getMaxDurability() != 0) {
|
||||
boolean broken = inventory.getItemInHand().get().use();
|
||||
if (broken) {
|
||||
inventory.decreaseItemInHand();
|
||||
|
@ -7,5 +7,5 @@ import java.lang.annotation.ElementType;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface ThreadAnnotation {
|
||||
public @interface ThreadRegistry {
|
||||
}
|
@ -4,7 +4,6 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.foreign.SegmentAllocator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -5,7 +5,7 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import cz.jzitnik.game.Game;
|
||||
import cz.jzitnik.game.annotations.ThreadAnnotation;
|
||||
import cz.jzitnik.game.annotations.ThreadRegistry;
|
||||
import cz.jzitnik.game.entities.Player;
|
||||
import cz.jzitnik.tui.ScreenRenderer;
|
||||
|
||||
@ -35,7 +35,7 @@ public class ThreadProvider {
|
||||
|
||||
private void registerHandlers() {
|
||||
Reflections reflections = new Reflections("cz.jzitnik.game.threads");
|
||||
Set<Class<?>> handlerClasses = reflections.getTypesAnnotatedWith(ThreadAnnotation.class);
|
||||
Set<Class<?>> handlerClasses = reflections.getTypesAnnotatedWith(ThreadRegistry.class);
|
||||
|
||||
for (Class<?> clazz : handlerClasses) {
|
||||
if (Thread.class.isAssignableFrom(clazz)) {
|
||||
|
@ -1,11 +1,11 @@
|
||||
package cz.jzitnik.game.threads.list;
|
||||
|
||||
import cz.jzitnik.game.annotations.ThreadAnnotation;
|
||||
import cz.jzitnik.game.annotations.ThreadRegistry;
|
||||
import cz.jzitnik.game.entities.Player;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
@AllArgsConstructor
|
||||
@ThreadAnnotation
|
||||
@ThreadRegistry
|
||||
public class HealthRegenerationThread extends Thread {
|
||||
private final Player player;
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
package cz.jzitnik.game.threads.list;
|
||||
|
||||
import cz.jzitnik.game.annotations.ThreadAnnotation;
|
||||
import cz.jzitnik.game.annotations.ThreadRegistry;
|
||||
import cz.jzitnik.game.entities.Player;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
@AllArgsConstructor
|
||||
@ThreadAnnotation
|
||||
@ThreadRegistry
|
||||
public class HungerDrainThread extends Thread {
|
||||
private final Player player;
|
||||
|
||||
|
@ -11,9 +11,9 @@ import org.jline.terminal.Terminal;
|
||||
import java.io.IOException;
|
||||
import java.nio.BufferUnderflowException;
|
||||
import java.util.Optional;
|
||||
import cz.jzitnik.game.annotations.ThreadAnnotation;
|
||||
import cz.jzitnik.game.annotations.ThreadRegistry;
|
||||
|
||||
@ThreadAnnotation
|
||||
@ThreadRegistry
|
||||
public class InputHandlerThread extends Thread {
|
||||
private final Game game;
|
||||
private final Terminal terminal;
|
||||
|
@ -1,11 +1,11 @@
|
||||
package cz.jzitnik.game.threads.list;
|
||||
|
||||
import cz.jzitnik.game.annotations.ThreadAnnotation;
|
||||
import cz.jzitnik.game.annotations.ThreadRegistry;
|
||||
import cz.jzitnik.game.entities.Player;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
@AllArgsConstructor
|
||||
@ThreadAnnotation
|
||||
@ThreadRegistry
|
||||
public class NoHungerThread extends Thread {
|
||||
private final Player player;
|
||||
|
||||
|
@ -22,3 +22,7 @@ public class ScreenMovingCalculationProvider {
|
||||
return new int[] { startX, endX, startY, endY };
|
||||
}
|
||||
}
|
||||
|
||||
class Something {
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user