mirror of
https://github.com/ProjectSWGCore/NGECore2.git
synced 2026-08-01 02:16:15 -04:00
Fixed several AI bugs, added log system
- Fixes 0000031: Incap is not working correctly - NPC AI now considers deathblow values correctly - AI state transition further debugged - Pet now follows owner after killing attacker - Added debug log system - Cleaned up system console from system.out messages
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
package tools;
|
||||
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.nio.file.*;
|
||||
|
||||
public class CharonPacketLogger extends Thread {
|
||||
private static final CharonPacketLogger instance = new CharonPacketLogger();
|
||||
|
||||
private BlockingQueue<String> itemsToLog =
|
||||
new ArrayBlockingQueue<String>(100);
|
||||
|
||||
private static final String SHUTDOWN_REQ = "SHUTDOWN";
|
||||
private volatile boolean shuttingDown, loggerTerminated;
|
||||
|
||||
public static CharonPacketLogger getLogger() {
|
||||
return instance;
|
||||
}
|
||||
private CharonPacketLogger() {
|
||||
start();
|
||||
}
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
String item;
|
||||
while ((item = itemsToLog.take()) != SHUTDOWN_REQ) {
|
||||
System.out.println(item);
|
||||
}
|
||||
} catch (InterruptedException iex) {
|
||||
} finally {
|
||||
loggerTerminated = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void log(String str) {
|
||||
if (shuttingDown || loggerTerminated) return;
|
||||
try {
|
||||
itemsToLog.put(str);
|
||||
} catch (InterruptedException iex) {
|
||||
Thread.currentThread().interrupt();
|
||||
throw new RuntimeException("Unexpected interruption");
|
||||
}
|
||||
}
|
||||
|
||||
public void log(String str,Path path) {
|
||||
if (shuttingDown || loggerTerminated) return;
|
||||
try {
|
||||
itemsToLog.put(str);
|
||||
CharonPacketUtils.appendToLog(str, path);
|
||||
} catch (InterruptedException iex) {
|
||||
Thread.currentThread().interrupt();
|
||||
throw new RuntimeException("Unexpected interruption");
|
||||
}
|
||||
}
|
||||
|
||||
public void shutDown() throws InterruptedException {
|
||||
shuttingDown = true;
|
||||
itemsToLog.put(SHUTDOWN_REQ);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user