Fixed bugs and oversights

This commit is contained in:
Bas de Jong
2025-10-07 22:39:47 +02:00
parent ed3cb902e4
commit 72e322675e
9 changed files with 14 additions and 20 deletions

View File

@@ -2,7 +2,8 @@
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="AutoCloseableResource" enabled="true" level="WARNING" enabled_by_default="true">
<option name="METHOD_MATCHER_CONFIG" value="java.util.Formatter,format,java.io.Writer,append,com.google.common.base.Preconditions,checkNotNull,org.hibernate.Session,close,java.io.PrintWriter,printf,java.io.PrintStream,printf,java.lang.foreign.Arena,ofAuto,java.lang.foreign.Arena,global,org.toop.framework.audio.AudioPlayer,play" />
<option name="METHOD_MATCHER_CONFIG" value="java.util.Formatter,format,java.io.Writer,append,com.google.common.base.Preconditions,checkNotNull,org.hibernate.Session,close,java.io.PrintWriter,printf,java.io.PrintStream,printf,java.lang.foreign.Arena,ofAuto,java.lang.foreign.Arena,global,org.toop.framework.audio.AudioPlayer,play,java.util.Map,remove" />
</inspection_tool>
<inspection_tool class="WriteOnlyObject" enabled="false" level="WARNING" enabled_by_default="false" />
</profile>
</component>

View File

@@ -8,7 +8,7 @@ import org.toop.framework.networking.NetworkingClientManager;
import org.toop.framework.networking.NetworkingInitializationException;
public final class Main {
public static void main(String[] args) {
static void main(String[] args) {
initSystems();
App.run(args);
}

View File

@@ -1,5 +1,6 @@
package org.toop.app.layer.layers.game;
import java.util.Objects;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -153,6 +154,7 @@ public final class TicTacToeLayer extends Layer {
if (legalMove.position() == wants.position()
&& legalMove.value() == wants.value()) {
move = wants;
// TODO: maybe add break?
}
}
} catch (InterruptedException _) {
@@ -315,7 +317,7 @@ public final class TicTacToeLayer extends Layer {
ticTacToe.get(),
compurterDifficultyToDepth(10, information.computerDifficulty()[0]));
position = move.position();
position = Objects.requireNonNull(move).position();
}
new EventFlow()

View File

@@ -9,7 +9,7 @@ import org.toop.framework.asset.resources.*;
/**
* Centralized manager for all loaded assets in the application.
*
* <p>{@code ResourceManager} maintains a thread-safe registry of {@link Asset} objects and provides
* <p>{@code ResourceManager} maintains a thread-safe registry of {@link ResourceMeta} objects and provides
* utility methods to retrieve assets by name, ID, or type. It works together with {@link
* ResourceLoader} to register assets automatically when they are loaded from the file system.
*
@@ -50,21 +50,11 @@ import org.toop.framework.asset.resources.*;
*/
public class ResourceManager {
private static final Logger logger = LogManager.getLogger(ResourceManager.class);
private static final ResourceManager INSTANCE = new ResourceManager();
private static final Map<String, ResourceMeta<? extends BaseResource>> assets =
new ConcurrentHashMap<>();
private ResourceManager() {}
/**
* Returns the singleton instance of {@code ResourceManager}.
*
* @return the shared instance
*/
public static ResourceManager getInstance() {
return INSTANCE;
}
/**
* Loads all assets from a given {@link ResourceLoader} into the manager.
*

View File

@@ -61,7 +61,8 @@ public class JsonAsset<T> extends BaseResource implements LoadableResource {
File file = getFile();
File parent = file.getParentFile();
if (parent != null && !parent.exists()) {
parent.mkdirs();
boolean isDirectoryMade = parent.mkdirs();
assert isDirectoryMade;
}
try (FileWriter writer = new FileWriter(file)) {
gson.toJson(content, writer);

View File

@@ -120,7 +120,7 @@ public class SoundManager {
logger.info("Playing background music: {}", ma.getFile().getName());
logger.info(
"Background music next in line: {}",
backgroundMusicQueue.peek().getFile().getName());
backgroundMusicQueue.peek() != null ? backgroundMusicQueue.peek().getFile().getName() : null);
}
private long playSound(String audioFileName, boolean loop)

View File

@@ -1,7 +1,7 @@
package org.toop.framework.eventbus;
public class ListenerHandler {
private Object listener = null;
private Object listener;
// private boolean unsubscribeAfterSuccess = true;

View File

@@ -136,7 +136,7 @@ public class NetworkingGameClientHandler extends ChannelInboundHandlerAdapter {
try {
String[] msg =
Pattern.compile(
"(?:CHALLENGER|GAMETYPE|CHALLENGENUMBER):\\s*\"?(.*?)\"?\\s*(?:,|})")
"(?:CHALLENGER|GAMETYPE|CHALLENGENUMBER):\\s*\"?(.*?)\"?\\s*[,}]")
.matcher(rec)
.results()
.map(m -> m.group().trim())