From cdce32ca49deea25c38f2c552b09c96733645ad0 Mon Sep 17 00:00:00 2001 From: lax1dude Date: Thu, 9 May 2024 22:53:10 -0700 Subject: [PATCH] fix issues --- .../eaglermotd/EaglerMOTDConfiguration.java | 8 ++++---- .../eaglermotd/EaglerMOTDConnectionUpdater.java | 1 + .../v1_8/plugin/eaglermotd/QueryType.java | 2 +- .../bungee/command/CommandMOTDReloadBungee.java | 17 +++++++++++++---- src/main/resources/plugin.yml | 4 +++- 5 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/main/java/net/lax1dude/eaglercraft/v1_8/plugin/eaglermotd/EaglerMOTDConfiguration.java b/src/main/java/net/lax1dude/eaglercraft/v1_8/plugin/eaglermotd/EaglerMOTDConfiguration.java index 547f936..eb9ddf5 100644 --- a/src/main/java/net/lax1dude/eaglercraft/v1_8/plugin/eaglermotd/EaglerMOTDConfiguration.java +++ b/src/main/java/net/lax1dude/eaglercraft/v1_8/plugin/eaglermotd/EaglerMOTDConfiguration.java @@ -276,7 +276,7 @@ public class EaglerMOTDConfiguration { } private static int optInt(JsonElement el, int def) { - if(el != null && !el.isJsonPrimitive()) { + if(el != null && el.isJsonPrimitive()) { JsonPrimitive prim = el.getAsJsonPrimitive(); return prim.isNumber() ? prim.getAsInt() : def; }else { @@ -285,7 +285,7 @@ public class EaglerMOTDConfiguration { } private static boolean optBoolean(JsonElement el, boolean def) { - if(el != null && !el.isJsonPrimitive()) { + if(el != null && el.isJsonPrimitive()) { JsonPrimitive prim = el.getAsJsonPrimitive(); return prim.isBoolean() ? prim.getAsBoolean() : def; }else { @@ -294,7 +294,7 @@ public class EaglerMOTDConfiguration { } private static float optFloat(JsonElement el, float def) { - if(el != null && !el.isJsonPrimitive()) { + if(el != null && el.isJsonPrimitive()) { JsonPrimitive prim = el.getAsJsonPrimitive(); return prim.isNumber() ? prim.getAsFloat() : def; }else { @@ -303,7 +303,7 @@ public class EaglerMOTDConfiguration { } private static String optString(JsonElement el, String def) { - if(el != null && !el.isJsonPrimitive()) { + if(el != null && el.isJsonPrimitive()) { JsonPrimitive prim = el.getAsJsonPrimitive(); return prim.isString() ? prim.getAsString() : def; }else { diff --git a/src/main/java/net/lax1dude/eaglercraft/v1_8/plugin/eaglermotd/EaglerMOTDConnectionUpdater.java b/src/main/java/net/lax1dude/eaglercraft/v1_8/plugin/eaglermotd/EaglerMOTDConnectionUpdater.java index edd5109..aaeeebc 100644 --- a/src/main/java/net/lax1dude/eaglercraft/v1_8/plugin/eaglermotd/EaglerMOTDConnectionUpdater.java +++ b/src/main/java/net/lax1dude/eaglercraft/v1_8/plugin/eaglermotd/EaglerMOTDConnectionUpdater.java @@ -83,6 +83,7 @@ public class EaglerMOTDConnectionUpdater { public boolean tick() { ageTimer++; if(this.motd.isClosed()) { + System.out.println("dead"); return false; } if(ageTimer > conf.close_socket_after) { diff --git a/src/main/java/net/lax1dude/eaglercraft/v1_8/plugin/eaglermotd/QueryType.java b/src/main/java/net/lax1dude/eaglercraft/v1_8/plugin/eaglermotd/QueryType.java index b192e92..848f1dd 100644 --- a/src/main/java/net/lax1dude/eaglercraft/v1_8/plugin/eaglermotd/QueryType.java +++ b/src/main/java/net/lax1dude/eaglercraft/v1_8/plugin/eaglermotd/QueryType.java @@ -92,7 +92,7 @@ public class QueryType { }else if(dataTextFile != null) { String txt = QueryCache.getStringFile(dataTextFile); if(txt == null) { - query.errorResponse("Error: could not load text file '" + dataJSONFile + "' for query '" + type + "'"); + query.errorResponse("Error: could not load text file '" + dataTextFile + "' for query '" + type + "'"); return; }else { query.stringResponse(type, txt); diff --git a/src/main/java/net/lax1dude/eaglercraft/v1_8/plugin/eaglermotd/bungee/command/CommandMOTDReloadBungee.java b/src/main/java/net/lax1dude/eaglercraft/v1_8/plugin/eaglermotd/bungee/command/CommandMOTDReloadBungee.java index 1b10dfa..c42a50c 100644 --- a/src/main/java/net/lax1dude/eaglercraft/v1_8/plugin/eaglermotd/bungee/command/CommandMOTDReloadBungee.java +++ b/src/main/java/net/lax1dude/eaglercraft/v1_8/plugin/eaglermotd/bungee/command/CommandMOTDReloadBungee.java @@ -8,6 +8,7 @@ import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.plugin.Command; +import net.md_5.bungee.command.ConsoleCommandSender; /** * Copyright (c) 2024 lax1dude. All Rights Reserved. @@ -41,24 +42,32 @@ public class CommandMOTDReloadBungee extends Command { @Override public void info(String msg) { CommandMOTDReloadBungee.this.plugin.getLogger().info(msg); - arg0.sendMessage(new TextComponent(ChatColor.GREEN + "[EaglerMOTD] " + msg)); + if(!(arg0 instanceof ConsoleCommandSender)) { + arg0.sendMessage(new TextComponent(ChatColor.GREEN + "[EaglerMOTD] " + msg)); + } } @Override public void warn(String msg) { CommandMOTDReloadBungee.this.plugin.getLogger().warning(msg); - arg0.sendMessage(new TextComponent(ChatColor.YELLOW + "[EaglerMOTD] " + msg)); + if(!(arg0 instanceof ConsoleCommandSender)) { + arg0.sendMessage(new TextComponent(ChatColor.YELLOW + "[EaglerMOTD] " + msg)); + } } @Override public void error(String msg) { CommandMOTDReloadBungee.this.plugin.getLogger().severe(msg); - arg0.sendMessage(new TextComponent(ChatColor.RED + "[EaglerMOTD] " + msg)); + if(!(arg0 instanceof ConsoleCommandSender)) { + arg0.sendMessage(new TextComponent(ChatColor.RED + "[EaglerMOTD] " + msg)); + } } }, plugin.getListenerNames()); plugin.installQueryHandlers(); }catch(Throwable ex) { - arg0.sendMessage(new TextComponent(ChatColor.RED + "[EaglerMOTD] Failed to reload! " + ex.toString())); + if(!(arg0 instanceof ConsoleCommandSender)) { + arg0.sendMessage(new TextComponent(ChatColor.RED + "[EaglerMOTD] Failed to reload! " + ex.toString())); + } plugin.getLogger().log(Level.SEVERE, "Exception thrown while reloading config!", ex); } } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 180e0c1..a9efde7 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,5 +1,7 @@ name: EaglerMOTD main: net.lax1dude.eaglercraft.v1_8.plugin.eaglermotd.bungee.EaglerMOTDPluginBungee version: 1.0.0 +description: Plugin to add an animated MOTDs to your EaglercraftXBungee server author: lax1dude -description: Plugin to add an animated MOTDs to your EaglercraftXBungee server \ No newline at end of file +depends: +- EaglercraftXBungee \ No newline at end of file