mirror of
https://github.com/IdalecioSch/TKNLogs.git
synced 2026-07-28 00:30:08 -03:00
asda
This commit is contained in:
@@ -27,16 +27,15 @@ public class LoggerReader {
|
|||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
try {
|
try {
|
||||||
// Configura o WatchService para monitorar modificações no diretório
|
|
||||||
watchService = FileSystems.getDefault().newWatchService();
|
watchService = FileSystems.getDefault().newWatchService();
|
||||||
logDir.register(watchService, ENTRY_MODIFY);
|
logDir.register(watchService, ENTRY_MODIFY);
|
||||||
|
|
||||||
// Inicia a thread de monitoramento assíncrona
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||||
while (!Thread.currentThread().isInterrupted()) {
|
while (!Thread.currentThread().isInterrupted()) {
|
||||||
WatchKey key;
|
WatchKey key;
|
||||||
try {
|
try {
|
||||||
key = watchService.take(); // Aguarda eventos
|
key = watchService.take();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
return;
|
return;
|
||||||
@@ -61,9 +60,9 @@ public class LoggerReader {
|
|||||||
|
|
||||||
private void processLogChanges(File logFile) {
|
private void processLogChanges(File logFile) {
|
||||||
try (RandomAccessFile raf = new RandomAccessFile(logFile, "r")) {
|
try (RandomAccessFile raf = new RandomAccessFile(logFile, "r")) {
|
||||||
// Pula para a última posição lida
|
|
||||||
if (raf.length() < lastReadPosition) {
|
if (raf.length() < lastReadPosition) {
|
||||||
lastReadPosition = 0; // Log foi reiniciado (ex: servidor reiniciou)
|
lastReadPosition = 0;
|
||||||
}
|
}
|
||||||
raf.seek(lastReadPosition);
|
raf.seek(lastReadPosition);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user