diff --git a/core/src/main/java/de/unordentlich/streamchatplus/core/Configuration.java b/core/src/main/java/de/unordentlich/streamchatplus/core/Configuration.java index 9ea6a26..6bcca1c 100644 --- a/core/src/main/java/de/unordentlich/streamchatplus/core/Configuration.java +++ b/core/src/main/java/de/unordentlich/streamchatplus/core/Configuration.java @@ -3,8 +3,6 @@ import de.unordentlich.streamchatplus.core.subconfigurations.AutoBroadcastSubSettings; import de.unordentlich.streamchatplus.core.subconfigurations.CustomCommandSubSettings; import de.unordentlich.streamchatplus.core.utils.support.DebugTool; -import java.io.IOException; - import net.labymod.api.Laby; import net.labymod.api.addon.AddonConfig; import net.labymod.api.client.gui.screen.widget.widgets.input.ButtonWidget.ButtonSetting; @@ -16,104 +14,106 @@ import net.labymod.api.configuration.settings.annotation.SettingSection; import net.labymod.api.util.MethodOrder; +import java.io.IOException; + @SuppressWarnings("FieldMayBeFinal") @ConfigName("settings") public class Configuration extends AddonConfig { - @SwitchSetting - private final ConfigProperty enabled = new ConfigProperty<>(true); - - @TextFieldSetting - private final ConfigProperty prefix = new ConfigProperty<>( - "§5✪ §d%user% §8> §7%message%"); - - @MethodOrder(after = "prefix") - @ButtonSetting(translation = "streamchatplus.settings.openSupportLink.text") - public void openSupportLink(Setting setting) { - DebugTool.lastClick = System.currentTimeMillis(); - long thisClick = System.currentTimeMillis(); - Configuration thisConfig = this; - if(DebugTool.isFirstClick) { - DebugTool.isFirstClick = false; - new java.util.Timer().schedule( - new java.util.TimerTask() { - @Override - public void run() { - if (DebugTool.lastClick > thisClick) { - try { - String link = new DebugTool(thisConfig).createDebugLog(); - Laby.labyAPI().minecraft().chatExecutor() - .openUrl(link, false); - Laby.labyAPI().minecraft().setClipboard(link); - DebugTool.isFirstClick = true; - } catch (IOException e) { - throw new RuntimeException(e); - } - } else { - Laby.labyAPI().minecraft().chatExecutor() - .openUrl("https://discord.gg/GhdDA4yyvR", false); - DebugTool.isFirstClick = true; - } - } - }, 650); + @SwitchSetting + private final ConfigProperty enabled = new ConfigProperty<>(true); + + @TextFieldSetting + private final ConfigProperty prefix = new ConfigProperty<>( + "§5✪ §d%user% §8> §7%message%"); + + @MethodOrder(after = "prefix") + @ButtonSetting(translation = "streamchatplus.settings.openSupportLink.text") + public void openSupportLink(Setting setting) { + DebugTool.lastClick = System.currentTimeMillis(); + long thisClick = System.currentTimeMillis(); + Configuration thisConfig = this; + if (DebugTool.isFirstClick) { + DebugTool.isFirstClick = false; + new java.util.Timer().schedule( + new java.util.TimerTask() { + @Override + public void run() { + if (DebugTool.lastClick > thisClick) { + try { + String link = new DebugTool(thisConfig).createDebugLog(); + Laby.labyAPI().minecraft().chatExecutor() + .openUrl(link, false); + Laby.labyAPI().minecraft().setClipboard(link); + DebugTool.isFirstClick = true; + } catch (IOException e) { + throw new RuntimeException(e); + } + } else { + Laby.labyAPI().minecraft().chatExecutor() + .openUrl("https://discord.gg/GhdDA4yyvR", false); + DebugTool.isFirstClick = true; + } + } + }, 650); + } } - } - @SettingSection("twitch") - @TextFieldSetting - private final ConfigProperty botName = new ConfigProperty<>("StreamChatPlus"); + @SettingSection("twitch") + @TextFieldSetting + private final ConfigProperty botName = new ConfigProperty<>("StreamChatPlus"); - @TextFieldSetting - private final ConfigProperty twitchChannel = new ConfigProperty<>(""); + @TextFieldSetting + private final ConfigProperty twitchChannel = new ConfigProperty<>(""); - @TextFieldSetting - private final ConfigProperty twitchToken = new ConfigProperty<>(""); + @TextFieldSetting + private final ConfigProperty twitchToken = new ConfigProperty<>(""); - @SettingSection("ingame") - @SwitchSetting - private final ConfigProperty ingameChatEnabled = new ConfigProperty<>(false); + @SettingSection("ingame") + @SwitchSetting + private final ConfigProperty ingameChatEnabled = new ConfigProperty<>(false); - @TextFieldSetting - private final ConfigProperty ingameChatPrefix = new ConfigProperty<>("#"); + @TextFieldSetting + private final ConfigProperty ingameChatPrefix = new ConfigProperty<>("#"); - @SettingSection("extras") - private AutoBroadcastSubSettings autoBroadcastSubSettings = new AutoBroadcastSubSettings(); - private CustomCommandSubSettings customCommandSubSettings = new CustomCommandSubSettings(); + @SettingSection("extras") + private AutoBroadcastSubSettings autoBroadcastSubSettings = new AutoBroadcastSubSettings(); + private CustomCommandSubSettings customCommandSubSettings = new CustomCommandSubSettings(); - @Override - public ConfigProperty enabled() { - return this.enabled; - } + @Override + public ConfigProperty enabled() { + return this.enabled; + } - public ConfigProperty botName() { - return this.botName; - } + public ConfigProperty botName() { + return this.botName; + } - public ConfigProperty prefix() { - return this.prefix; - } + public ConfigProperty prefix() { + return this.prefix; + } - public ConfigProperty twitchchannel() { - return this.twitchChannel; - } + public ConfigProperty twitchchannel() { + return this.twitchChannel; + } - public ConfigProperty twitchtoken() { - return this.twitchToken; - } + public ConfigProperty twitchtoken() { + return this.twitchToken; + } - public ConfigProperty ingameChatEnabled() { - return this.ingameChatEnabled; - } + public ConfigProperty ingameChatEnabled() { + return this.ingameChatEnabled; + } - public ConfigProperty ingameChatPrefix() { - return this.ingameChatPrefix; - } + public ConfigProperty ingameChatPrefix() { + return this.ingameChatPrefix; + } - public AutoBroadcastSubSettings autoBroadcastSubSettings() { - return autoBroadcastSubSettings; - } + public AutoBroadcastSubSettings autoBroadcastSubSettings() { + return autoBroadcastSubSettings; + } - public CustomCommandSubSettings customCommandSubSettings() { - return customCommandSubSettings; - } + public CustomCommandSubSettings customCommandSubSettings() { + return customCommandSubSettings; + } } diff --git a/core/src/main/java/de/unordentlich/streamchatplus/core/StreamChatPlus.java b/core/src/main/java/de/unordentlich/streamchatplus/core/StreamChatPlus.java index b425080..7e6756f 100644 --- a/core/src/main/java/de/unordentlich/streamchatplus/core/StreamChatPlus.java +++ b/core/src/main/java/de/unordentlich/streamchatplus/core/StreamChatPlus.java @@ -18,36 +18,36 @@ @Singleton @AddonListener public class StreamChatPlus extends LabyAddon { - public static TwitchBot bot; - public static CustomCommandManager customCommandManager; - public static AutoBroadcastManager autoBroadcastManager; + public static TwitchBot bot; + public static CustomCommandManager customCommandManager; + public static AutoBroadcastManager autoBroadcastManager; - public static ArrayList debugLog = new ArrayList<>(); + public static ArrayList debugLog = new ArrayList<>(); - public static InstalledAddonInfo addonInfo; + public static InstalledAddonInfo addonInfo; - @Override - protected void enable() { - this.registerSettingCategory(); - bot = new TwitchBot(this); + @Override + protected void enable() { + this.registerSettingCategory(); + bot = new TwitchBot(this); - this.registerListener(ChatMessageSendListener.class); - this.registerListener(WorldJoinListener.class); - this.registerListener(WorldLeaveListener.class); - this.registerListener(PropertyUpdateListener.class); + this.registerListener(ChatMessageSendListener.class); + this.registerListener(WorldJoinListener.class); + this.registerListener(WorldLeaveListener.class); + this.registerListener(PropertyUpdateListener.class); - customCommandManager = new CustomCommandManager(this); - customCommandManager.initializeCustomCommands(); + customCommandManager = new CustomCommandManager(this); + customCommandManager.initializeCustomCommands(); - autoBroadcastManager = new AutoBroadcastManager(this); - autoBroadcastManager.initializeAutoBroadcasts(); + autoBroadcastManager = new AutoBroadcastManager(this); + autoBroadcastManager.initializeAutoBroadcasts(); - this.logger().info("StreamChat+ | Addon successfully enabled. (v" + this.addonInfo().getVersion() + ")"); - addonInfo = this.addonInfo(); - } + this.logger().info("StreamChat+ | Addon successfully enabled. (v" + this.addonInfo().getVersion() + ")"); + addonInfo = this.addonInfo(); + } - @Override - protected Class configurationClass() { - return Configuration.class; - } + @Override + protected Class configurationClass() { + return Configuration.class; + } } diff --git a/core/src/main/java/de/unordentlich/streamchatplus/core/listener/ChatMessageSendListener.java b/core/src/main/java/de/unordentlich/streamchatplus/core/listener/ChatMessageSendListener.java index e243733..16d085e 100644 --- a/core/src/main/java/de/unordentlich/streamchatplus/core/listener/ChatMessageSendListener.java +++ b/core/src/main/java/de/unordentlich/streamchatplus/core/listener/ChatMessageSendListener.java @@ -14,31 +14,31 @@ public class ChatMessageSendListener { - private final StreamChatPlus addon; + private final StreamChatPlus addon; - @Inject - private ChatMessageSendListener(StreamChatPlus addon) { - this.addon = addon; - } + @Inject + private ChatMessageSendListener(StreamChatPlus addon) { + this.addon = addon; + } - @Subscribe - public void onChatMessageSend(ChatMessageSendEvent event) { - DebugTool.log("ChatMessageSendEvent has been triggered", DebugActionExecuter.USER, getClass()); - Configuration config = this.addon.configuration(); - if (event.getMessage().startsWith(config.ingameChatPrefix().get())) { - if (config.ingameChatEnabled().get()) { - StreamChatPlus.bot.sendMessage(event.getOriginalMessage()); - DebugTool.log("Sent message in Twitch Chat", getClass()); - LabyGuice.getInstance(StreamChatPlus.class) - .displayMessage( - ColorCodeTranslator.translateColorCodes(config.prefix().get()).replace("%user%", - Laby.labyAPI().minecraft().clientPlayer().getName()).replace("%message%", - event.getOriginalMessage().replaceFirst(config.ingameChatPrefix().get(), ""))); - DebugTool.log("ChatMessageSendEvent has been cancelled", DebugPriority.WARNING, getClass()); - event.setCancelled(true); - } + @Subscribe + public void onChatMessageSend(ChatMessageSendEvent event) { + DebugTool.log("ChatMessageSendEvent has been triggered", DebugActionExecuter.USER, getClass()); + Configuration config = this.addon.configuration(); + if (event.getMessage().startsWith(config.ingameChatPrefix().get())) { + if (config.ingameChatEnabled().get()) { + StreamChatPlus.bot.sendMessage(event.getOriginalMessage()); + DebugTool.log("Sent message in Twitch Chat", getClass()); + LabyGuice.getInstance(StreamChatPlus.class) + .displayMessage( + ColorCodeTranslator.translateColorCodes(config.prefix().get()).replace("%user%", + Laby.labyAPI().minecraft().clientPlayer().getName()).replace("%message%", + event.getOriginalMessage().replaceFirst(config.ingameChatPrefix().get(), ""))); + DebugTool.log("ChatMessageSendEvent has been cancelled", DebugPriority.WARNING, getClass()); + event.setCancelled(true); + } + } + return; } - return; - } } diff --git a/core/src/main/java/de/unordentlich/streamchatplus/core/listener/PropertyUpdateListener.java b/core/src/main/java/de/unordentlich/streamchatplus/core/listener/PropertyUpdateListener.java index 3264c77..c7e0b45 100644 --- a/core/src/main/java/de/unordentlich/streamchatplus/core/listener/PropertyUpdateListener.java +++ b/core/src/main/java/de/unordentlich/streamchatplus/core/listener/PropertyUpdateListener.java @@ -11,42 +11,42 @@ public class PropertyUpdateListener { - private final StreamChatPlus addon; - - @Inject - private PropertyUpdateListener(StreamChatPlus addon) { - this.addon = addon; - } - - @Subscribe - public void onSettingUpdate(SettingUpdateEvent event) { - DebugTool.log("SettingUpdateEvent has been triggered", DebugActionExecuter.USER, getClass()); - if (event.setting().getId().equals("enabled")) { - if (!(boolean) event.getValue()) { - if (StreamChatPlus.bot.isConnected()) { - StreamChatPlus.bot.stop(); - DebugTool.log("TwitchBot was stopped because addon was disabled", DebugPriority.WARNING, getClass()); + private final StreamChatPlus addon; + + @Inject + private PropertyUpdateListener(StreamChatPlus addon) { + this.addon = addon; + } + + @Subscribe + public void onSettingUpdate(SettingUpdateEvent event) { + DebugTool.log("SettingUpdateEvent has been triggered", DebugActionExecuter.USER, getClass()); + if (event.setting().getId().equals("enabled")) { + if (!(boolean) event.getValue()) { + if (StreamChatPlus.bot.isConnected()) { + StreamChatPlus.bot.stop(); + DebugTool.log("TwitchBot was stopped because addon was disabled", DebugPriority.WARNING, getClass()); + } + } } - } + return; + } + + @Subscribe + public void onSettingInit(SettingWidgetInitializeEvent event) { + DebugTool.log("SettingWidgetInitializeEvent has been triggered", getClass()); + /**if(!event.holder().getPath().equals("settings.streamchatplus")) { + return; + } + + for (Widget setting : event.getSettings()) { + if(!(setting instanceof SettingHeaderWidget)) { + continue; + } + + SettingHeaderWidget settingHeaderWidget = (SettingHeaderWidget) setting; + //settingHeaderWidget.component(Component.text("sdfwsdfsdf")); + }**/ } - return; - } - - @Subscribe - public void onSettingInit(SettingWidgetInitializeEvent event) { - DebugTool.log("SettingWidgetInitializeEvent has been triggered", getClass()); - /**if(!event.holder().getPath().equals("settings.streamchatplus")) { - return; - } - - for (Widget setting : event.getSettings()) { - if(!(setting instanceof SettingHeaderWidget)) { - continue; - } - - SettingHeaderWidget settingHeaderWidget = (SettingHeaderWidget) setting; - //settingHeaderWidget.component(Component.text("sdfwsdfsdf")); - }**/ - } } diff --git a/core/src/main/java/de/unordentlich/streamchatplus/core/listener/WorldJoinListener.java b/core/src/main/java/de/unordentlich/streamchatplus/core/listener/WorldJoinListener.java index f48313e..3924b3f 100644 --- a/core/src/main/java/de/unordentlich/streamchatplus/core/listener/WorldJoinListener.java +++ b/core/src/main/java/de/unordentlich/streamchatplus/core/listener/WorldJoinListener.java @@ -11,20 +11,20 @@ public class WorldJoinListener { - private final StreamChatPlus addon; + private final StreamChatPlus addon; - @Inject - private WorldJoinListener(StreamChatPlus addon) { - this.addon = addon; - } + @Inject + private WorldJoinListener(StreamChatPlus addon) { + this.addon = addon; + } - @Subscribe - public void onWorldEnter(WorldEnterEvent event) { - DebugTool.log("WorldJoinEvent has been triggered", DebugActionExecuter.USER, getClass()); - StreamChatPlus.bot = new TwitchBot(addon); - DebugTool.log("bot was redefined by 'new TwitchBot(addon)'", getClass()); - StreamChatPlus.bot.start(); - DebugTool.log("TwitchBot was started because user joined world or server", DebugPriority.WARNING, getClass()); - return; - } + @Subscribe + public void onWorldEnter(WorldEnterEvent event) { + DebugTool.log("WorldJoinEvent has been triggered", DebugActionExecuter.USER, getClass()); + StreamChatPlus.bot = new TwitchBot(addon); + DebugTool.log("bot was redefined by 'new TwitchBot(addon)'", getClass()); + StreamChatPlus.bot.start(); + DebugTool.log("TwitchBot was started because user joined world or server", DebugPriority.WARNING, getClass()); + return; + } } diff --git a/core/src/main/java/de/unordentlich/streamchatplus/core/listener/WorldLeaveListener.java b/core/src/main/java/de/unordentlich/streamchatplus/core/listener/WorldLeaveListener.java index 66bbc67..28cb7e1 100644 --- a/core/src/main/java/de/unordentlich/streamchatplus/core/listener/WorldLeaveListener.java +++ b/core/src/main/java/de/unordentlich/streamchatplus/core/listener/WorldLeaveListener.java @@ -10,19 +10,19 @@ public class WorldLeaveListener { - private final StreamChatPlus addon; + private final StreamChatPlus addon; - @Inject - private WorldLeaveListener(StreamChatPlus addon) { - this.addon = addon; - } + @Inject + private WorldLeaveListener(StreamChatPlus addon) { + this.addon = addon; + } - @Subscribe - public void onWorldLeave(WorldLeaveEvent event) { - DebugTool.log("WorldLeaveEvent has been triggered", DebugActionExecuter.USER, getClass()); - StreamChatPlus.bot.stop(); - DebugTool.log("TwitchBot was stopped because user left world or server", DebugPriority.WARNING, getClass()); - return; - } + @Subscribe + public void onWorldLeave(WorldLeaveEvent event) { + DebugTool.log("WorldLeaveEvent has been triggered", DebugActionExecuter.USER, getClass()); + StreamChatPlus.bot.stop(); + DebugTool.log("TwitchBot was stopped because user left world or server", DebugPriority.WARNING, getClass()); + return; + } } diff --git a/core/src/main/java/de/unordentlich/streamchatplus/core/subconfigurations/AutoBroadcastSubSettings.java b/core/src/main/java/de/unordentlich/streamchatplus/core/subconfigurations/AutoBroadcastSubSettings.java index cda2ed8..c43320e 100644 --- a/core/src/main/java/de/unordentlich/streamchatplus/core/subconfigurations/AutoBroadcastSubSettings.java +++ b/core/src/main/java/de/unordentlich/streamchatplus/core/subconfigurations/AutoBroadcastSubSettings.java @@ -14,168 +14,168 @@ public class AutoBroadcastSubSettings extends Config { - @ParentSwitch - @SwitchSetting - private ConfigProperty enabled = new ConfigProperty<>(true); + @ParentSwitch + @SwitchSetting + private final ConfigProperty enabled = new ConfigProperty<>(true); - @MethodOrder(after = "enabled") - @ButtonSetting(translation = "streamchatplus.settings.autoBroadcastSubSettings.reloadBroadcasts.text") - public void reloadBroadcasts(Setting setting) { - StreamChatPlus.customCommandManager.initializeCustomCommands(); - } + @MethodOrder(after = "enabled") + @ButtonSetting(translation = "streamchatplus.settings.autoBroadcastSubSettings.reloadBroadcasts.text") + public void reloadBroadcasts(Setting setting) { + StreamChatPlus.customCommandManager.initializeCustomCommands(); + } - @SettingSection("introduction") - @SliderSetting(min = 3, max = 60, steps = 1) - private final ConfigProperty interval1 = new ConfigProperty<>(5); + @SettingSection("introduction") + @SliderSetting(min = 3, max = 60, steps = 1) + private final ConfigProperty interval1 = new ConfigProperty<>(5); - @TextFieldSetting - private final ConfigProperty message1 = new ConfigProperty<>( - "This is your first Custom Broadcast. It will be executed every 5 minutes in your twitch chat!"); + @TextFieldSetting + private final ConfigProperty message1 = new ConfigProperty<>( + "This is your first Custom Broadcast. It will be executed every 5 minutes in your twitch chat!"); - @SettingSection("autoBroadcast") - @SliderSetting(min = 3, max = 60, steps = 1) - private final ConfigProperty interval2 = new ConfigProperty<>(5); + @SettingSection("autoBroadcast") + @SliderSetting(min = 3, max = 60, steps = 1) + private final ConfigProperty interval2 = new ConfigProperty<>(5); - @TextFieldSetting - private final ConfigProperty message2 = new ConfigProperty<>(""); + @TextFieldSetting + private final ConfigProperty message2 = new ConfigProperty<>(""); - @SettingSection("autoBroadcast") - @SliderSetting(min = 3, max = 60, steps = 1) - private final ConfigProperty interval3 = new ConfigProperty<>(5); + @SettingSection("autoBroadcast") + @SliderSetting(min = 3, max = 60, steps = 1) + private final ConfigProperty interval3 = new ConfigProperty<>(5); - @TextFieldSetting - private final ConfigProperty message3 = new ConfigProperty<>(""); + @TextFieldSetting + private final ConfigProperty message3 = new ConfigProperty<>(""); - @SettingSection("autoBroadcast") - @SliderSetting(min = 3, max = 60, steps = 1) - private final ConfigProperty interval4 = new ConfigProperty<>(5); + @SettingSection("autoBroadcast") + @SliderSetting(min = 3, max = 60, steps = 1) + private final ConfigProperty interval4 = new ConfigProperty<>(5); - @TextFieldSetting - private final ConfigProperty message4 = new ConfigProperty<>(""); + @TextFieldSetting + private final ConfigProperty message4 = new ConfigProperty<>(""); - @SettingSection("autoBroadcast") - @SliderSetting(min = 3, max = 60, steps = 1) - private final ConfigProperty interval5 = new ConfigProperty<>(5); + @SettingSection("autoBroadcast") + @SliderSetting(min = 3, max = 60, steps = 1) + private final ConfigProperty interval5 = new ConfigProperty<>(5); - @TextFieldSetting - private final ConfigProperty message5 = new ConfigProperty<>(""); + @TextFieldSetting + private final ConfigProperty message5 = new ConfigProperty<>(""); - @SettingSection("autoBroadcast") - @SliderSetting(min = 3, max = 60, steps = 1) - private final ConfigProperty interval6 = new ConfigProperty<>(5); + @SettingSection("autoBroadcast") + @SliderSetting(min = 3, max = 60, steps = 1) + private final ConfigProperty interval6 = new ConfigProperty<>(5); - @TextFieldSetting - private final ConfigProperty message6 = new ConfigProperty<>(""); + @TextFieldSetting + private final ConfigProperty message6 = new ConfigProperty<>(""); - @SettingSection("autoBroadcast") - @SliderSetting(min = 3, max = 60, steps = 1) - private final ConfigProperty interval7 = new ConfigProperty<>(5); + @SettingSection("autoBroadcast") + @SliderSetting(min = 3, max = 60, steps = 1) + private final ConfigProperty interval7 = new ConfigProperty<>(5); - @TextFieldSetting - private final ConfigProperty message7 = new ConfigProperty<>(""); + @TextFieldSetting + private final ConfigProperty message7 = new ConfigProperty<>(""); - @SettingSection("autoBroadcast") - @SliderSetting(min = 3, max = 60, steps = 1) - private final ConfigProperty interval8 = new ConfigProperty<>(5); + @SettingSection("autoBroadcast") + @SliderSetting(min = 3, max = 60, steps = 1) + private final ConfigProperty interval8 = new ConfigProperty<>(5); - @TextFieldSetting - private final ConfigProperty message8 = new ConfigProperty<>(""); + @TextFieldSetting + private final ConfigProperty message8 = new ConfigProperty<>(""); - @SettingSection("autoBroadcast") - @SliderSetting(min = 3, max = 60, steps = 1) - private final ConfigProperty interval9 = new ConfigProperty<>(5); + @SettingSection("autoBroadcast") + @SliderSetting(min = 3, max = 60, steps = 1) + private final ConfigProperty interval9 = new ConfigProperty<>(5); - @TextFieldSetting - private final ConfigProperty message9 = new ConfigProperty<>(""); + @TextFieldSetting + private final ConfigProperty message9 = new ConfigProperty<>(""); - @SettingSection("autoBroadcast") - @SliderSetting(min = 3, max = 60, steps = 1) - private final ConfigProperty interval10 = new ConfigProperty<>(5); + @SettingSection("autoBroadcast") + @SliderSetting(min = 3, max = 60, steps = 1) + private final ConfigProperty interval10 = new ConfigProperty<>(5); - @TextFieldSetting - private final ConfigProperty message10 = new ConfigProperty<>(""); + @TextFieldSetting + private final ConfigProperty message10 = new ConfigProperty<>(""); - public ConfigProperty enabled() { - return enabled; - } + public ConfigProperty enabled() { + return enabled; + } - public ConfigProperty interval1() { - return interval1; - } + public ConfigProperty interval1() { + return interval1; + } - public ConfigProperty message1() { - return message1; - } + public ConfigProperty message1() { + return message1; + } - public ConfigProperty interval2() { - return interval2; - } + public ConfigProperty interval2() { + return interval2; + } - public ConfigProperty message2() { - return message2; - } + public ConfigProperty message2() { + return message2; + } - public ConfigProperty interval3() { - return interval3; - } + public ConfigProperty interval3() { + return interval3; + } - public ConfigProperty message3() { - return message3; - } + public ConfigProperty message3() { + return message3; + } - public ConfigProperty interval4() { - return interval4; - } + public ConfigProperty interval4() { + return interval4; + } - public ConfigProperty message4() { - return message4; - } + public ConfigProperty message4() { + return message4; + } - public ConfigProperty interval5() { - return interval5; - } + public ConfigProperty interval5() { + return interval5; + } - public ConfigProperty message5() { - return message5; - } + public ConfigProperty message5() { + return message5; + } - public ConfigProperty interval6() { - return interval6; - } + public ConfigProperty interval6() { + return interval6; + } - public ConfigProperty message6() { - return message6; - } + public ConfigProperty message6() { + return message6; + } - public ConfigProperty interval7() { - return interval7; - } + public ConfigProperty interval7() { + return interval7; + } - public ConfigProperty message7() { - return message7; - } + public ConfigProperty message7() { + return message7; + } - public ConfigProperty interval8() { - return interval8; - } + public ConfigProperty interval8() { + return interval8; + } - public ConfigProperty message8() { - return message8; - } + public ConfigProperty message8() { + return message8; + } - public ConfigProperty interval9() { - return interval9; - } + public ConfigProperty interval9() { + return interval9; + } - public ConfigProperty message9() { - return message9; - } + public ConfigProperty message9() { + return message9; + } - public ConfigProperty interval10() { - return interval10; - } + public ConfigProperty interval10() { + return interval10; + } - public ConfigProperty message10() { - return message10; - } + public ConfigProperty message10() { + return message10; + } } diff --git a/core/src/main/java/de/unordentlich/streamchatplus/core/subconfigurations/CustomCommandSubSettings.java b/core/src/main/java/de/unordentlich/streamchatplus/core/subconfigurations/CustomCommandSubSettings.java index 0e05415..51240b0 100644 --- a/core/src/main/java/de/unordentlich/streamchatplus/core/subconfigurations/CustomCommandSubSettings.java +++ b/core/src/main/java/de/unordentlich/streamchatplus/core/subconfigurations/CustomCommandSubSettings.java @@ -13,168 +13,168 @@ public class CustomCommandSubSettings extends Config { - @ParentSwitch - @SwitchSetting - private ConfigProperty enabled = new ConfigProperty<>(true); + @ParentSwitch + @SwitchSetting + private final ConfigProperty enabled = new ConfigProperty<>(true); - @MethodOrder(after = "enabled") - @ButtonSetting(translation = "streamchatplus.settings.customCommandSubSettings.reloadCommands.text") - public void reloadCommands(Setting setting) { - StreamChatPlus.customCommandManager.initializeCustomCommands(); - } + @MethodOrder(after = "enabled") + @ButtonSetting(translation = "streamchatplus.settings.customCommandSubSettings.reloadCommands.text") + public void reloadCommands(Setting setting) { + StreamChatPlus.customCommandManager.initializeCustomCommands(); + } - @SettingSection("introduction") - @TextFieldSetting - private final ConfigProperty command1 = new ConfigProperty<>("!example"); + @SettingSection("introduction") + @TextFieldSetting + private final ConfigProperty command1 = new ConfigProperty<>("!example"); - @TextFieldSetting - private final ConfigProperty response1 = new ConfigProperty<>( - "This is your first Custom Command. It can be executed in your twitch chat!"); + @TextFieldSetting + private final ConfigProperty response1 = new ConfigProperty<>( + "This is your first Custom Command. It can be executed in your twitch chat!"); - @SettingSection("customCommand") - @TextFieldSetting - private final ConfigProperty command2 = new ConfigProperty<>(""); + @SettingSection("customCommand") + @TextFieldSetting + private final ConfigProperty command2 = new ConfigProperty<>(""); - @TextFieldSetting - private final ConfigProperty response2 = new ConfigProperty<>(""); + @TextFieldSetting + private final ConfigProperty response2 = new ConfigProperty<>(""); - @SettingSection("customCommand") - @TextFieldSetting - private final ConfigProperty command3 = new ConfigProperty<>(""); + @SettingSection("customCommand") + @TextFieldSetting + private final ConfigProperty command3 = new ConfigProperty<>(""); - @TextFieldSetting - private final ConfigProperty response3 = new ConfigProperty<>(""); + @TextFieldSetting + private final ConfigProperty response3 = new ConfigProperty<>(""); - @SettingSection("customCommand") - @TextFieldSetting - private final ConfigProperty command4 = new ConfigProperty<>(""); + @SettingSection("customCommand") + @TextFieldSetting + private final ConfigProperty command4 = new ConfigProperty<>(""); - @TextFieldSetting - private final ConfigProperty response4 = new ConfigProperty<>(""); + @TextFieldSetting + private final ConfigProperty response4 = new ConfigProperty<>(""); - @SettingSection("customCommand") - @TextFieldSetting - private final ConfigProperty command5 = new ConfigProperty<>(""); + @SettingSection("customCommand") + @TextFieldSetting + private final ConfigProperty command5 = new ConfigProperty<>(""); - @TextFieldSetting - private final ConfigProperty response5 = new ConfigProperty<>(""); + @TextFieldSetting + private final ConfigProperty response5 = new ConfigProperty<>(""); - @SettingSection("customCommand") - @TextFieldSetting - private final ConfigProperty command6 = new ConfigProperty<>(""); + @SettingSection("customCommand") + @TextFieldSetting + private final ConfigProperty command6 = new ConfigProperty<>(""); - @TextFieldSetting - private final ConfigProperty response6 = new ConfigProperty<>(""); + @TextFieldSetting + private final ConfigProperty response6 = new ConfigProperty<>(""); - @SettingSection("customCommand") - @TextFieldSetting - private final ConfigProperty command7 = new ConfigProperty<>(""); + @SettingSection("customCommand") + @TextFieldSetting + private final ConfigProperty command7 = new ConfigProperty<>(""); - @TextFieldSetting - private final ConfigProperty response7 = new ConfigProperty<>(""); + @TextFieldSetting + private final ConfigProperty response7 = new ConfigProperty<>(""); - @SettingSection("customCommand") - @TextFieldSetting - private final ConfigProperty command8 = new ConfigProperty<>(""); + @SettingSection("customCommand") + @TextFieldSetting + private final ConfigProperty command8 = new ConfigProperty<>(""); - @TextFieldSetting - private final ConfigProperty response8 = new ConfigProperty<>(""); + @TextFieldSetting + private final ConfigProperty response8 = new ConfigProperty<>(""); - @SettingSection("customCommand") - @TextFieldSetting - private final ConfigProperty command9 = new ConfigProperty<>(""); + @SettingSection("customCommand") + @TextFieldSetting + private final ConfigProperty command9 = new ConfigProperty<>(""); - @TextFieldSetting - private final ConfigProperty response9 = new ConfigProperty<>(""); + @TextFieldSetting + private final ConfigProperty response9 = new ConfigProperty<>(""); - @SettingSection("customCommand") - @TextFieldSetting - private final ConfigProperty command10 = new ConfigProperty<>(""); + @SettingSection("customCommand") + @TextFieldSetting + private final ConfigProperty command10 = new ConfigProperty<>(""); - @TextFieldSetting - private final ConfigProperty response10 = new ConfigProperty<>(""); + @TextFieldSetting + private final ConfigProperty response10 = new ConfigProperty<>(""); - public ConfigProperty enabled() { - return enabled; - } + public ConfigProperty enabled() { + return enabled; + } - public ConfigProperty command1() { - return command1; - } + public ConfigProperty command1() { + return command1; + } - public ConfigProperty response1() { - return response1; - } + public ConfigProperty response1() { + return response1; + } - public ConfigProperty command2() { - return command2; - } + public ConfigProperty command2() { + return command2; + } - public ConfigProperty response2() { - return response2; - } + public ConfigProperty response2() { + return response2; + } - public ConfigProperty command3() { - return command3; - } + public ConfigProperty command3() { + return command3; + } - public ConfigProperty response3() { - return response3; - } + public ConfigProperty response3() { + return response3; + } - public ConfigProperty command4() { - return command4; - } + public ConfigProperty command4() { + return command4; + } - public ConfigProperty response4() { - return response4; - } + public ConfigProperty response4() { + return response4; + } - public ConfigProperty command5() { - return command5; - } + public ConfigProperty command5() { + return command5; + } - public ConfigProperty response5() { - return response5; - } + public ConfigProperty response5() { + return response5; + } - public ConfigProperty command6() { - return command6; - } + public ConfigProperty command6() { + return command6; + } - public ConfigProperty response6() { - return response6; - } + public ConfigProperty response6() { + return response6; + } - public ConfigProperty command7() { - return command7; - } + public ConfigProperty command7() { + return command7; + } - public ConfigProperty response7() { - return response7; - } + public ConfigProperty response7() { + return response7; + } - public ConfigProperty command8() { - return command8; - } + public ConfigProperty command8() { + return command8; + } - public ConfigProperty response8() { - return response8; - } + public ConfigProperty response8() { + return response8; + } - public ConfigProperty command9() { - return command9; - } + public ConfigProperty command9() { + return command9; + } - public ConfigProperty response9() { - return response9; - } + public ConfigProperty response9() { + return response9; + } - public ConfigProperty command10() { - return command10; - } + public ConfigProperty command10() { + return command10; + } - public ConfigProperty response10() { - return response10; - } + public ConfigProperty response10() { + return response10; + } } diff --git a/core/src/main/java/de/unordentlich/streamchatplus/core/utils/ColorCodeTranslator.java b/core/src/main/java/de/unordentlich/streamchatplus/core/utils/ColorCodeTranslator.java index 878e89a..ac9da8f 100644 --- a/core/src/main/java/de/unordentlich/streamchatplus/core/utils/ColorCodeTranslator.java +++ b/core/src/main/java/de/unordentlich/streamchatplus/core/utils/ColorCodeTranslator.java @@ -2,30 +2,30 @@ public class ColorCodeTranslator { - public static String translateColorCodes(String message) { - return message - .replaceAll("&0", "§0") - .replaceAll("&1", "§1") - .replaceAll("&2", "§2") - .replaceAll("&3", "§3") - .replaceAll("&4", "§4") - .replaceAll("&5", "§5") - .replaceAll("&6", "§6") - .replaceAll("&7", "§7") - .replaceAll("&8", "§8") - .replaceAll("&9", "§9") - .replaceAll("&a", "§a") - .replaceAll("&b", "§b") - .replaceAll("&c", "§c") - .replaceAll("&d", "§d") - .replaceAll("&e", "§e") - .replaceAll("&f", "§f") - .replaceAll("&k", "§k") - .replaceAll("&l", "§l") - .replaceAll("&m", "§m") - .replaceAll("&n", "§n") - .replaceAll("&o", "§o") - .replaceAll("&r", "§r"); - } + public static String translateColorCodes(String message) { + return message + .replaceAll("&0", "§0") + .replaceAll("&1", "§1") + .replaceAll("&2", "§2") + .replaceAll("&3", "§3") + .replaceAll("&4", "§4") + .replaceAll("&5", "§5") + .replaceAll("&6", "§6") + .replaceAll("&7", "§7") + .replaceAll("&8", "§8") + .replaceAll("&9", "§9") + .replaceAll("&a", "§a") + .replaceAll("&b", "§b") + .replaceAll("&c", "§c") + .replaceAll("&d", "§d") + .replaceAll("&e", "§e") + .replaceAll("&f", "§f") + .replaceAll("&k", "§k") + .replaceAll("&l", "§l") + .replaceAll("&m", "§m") + .replaceAll("&n", "§n") + .replaceAll("&o", "§o") + .replaceAll("&r", "§r"); + } } diff --git a/core/src/main/java/de/unordentlich/streamchatplus/core/utils/TwitchBot.java b/core/src/main/java/de/unordentlich/streamchatplus/core/utils/TwitchBot.java index b1e7a97..f4c9d4a 100644 --- a/core/src/main/java/de/unordentlich/streamchatplus/core/utils/TwitchBot.java +++ b/core/src/main/java/de/unordentlich/streamchatplus/core/utils/TwitchBot.java @@ -2,11 +2,6 @@ import de.unordentlich.streamchatplus.core.Configuration; import de.unordentlich.streamchatplus.core.StreamChatPlus; -import java.io.IOException; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; -import javax.inject.Inject; import de.unordentlich.streamchatplus.core.utils.support.DebugTool; import de.unordentlich.streamchatplus.core.utils.support.ErrorCode; import de.unordentlich.streamchatplus.core.utils.support.ErrorManager; @@ -15,98 +10,104 @@ import org.jibble.pircbot.IrcException; import org.jibble.pircbot.PircBot; +import javax.inject.Inject; +import java.io.IOException; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + public class TwitchBot extends PircBot { - private final StreamChatPlus addon; - private Configuration config; + private final StreamChatPlus addon; + private final Configuration config; - @Inject - public TwitchBot(StreamChatPlus addon) { - this.addon = addon; - config = this.addon.configuration(); - this.setName(config.botName().get()); - this.isConnected(); - DebugTool.log("TwitchBot instance has been initialized with the configured name", this.getClass()); - } + @Inject + public TwitchBot(StreamChatPlus addon) { + this.addon = addon; + config = this.addon.configuration(); + this.setName(config.botName().get()); + this.isConnected(); + DebugTool.log("TwitchBot instance has been initialized with the configured name", this.getClass()); + } - public void start() { - if (config.enabled().get()) { - if (isConfiguredCorrectly()) { - this.setVerbose(true); - DebugTool.log("TwitchBot instance has been requested to connect..."); - boolean token_working; - try { - this.connect("irc.twitch.tv", 6667, config.twitchtoken().get()); - DebugTool.log("(TwitchBot) Connecting to irc.twitch.tv:6667 with token from configuration..."); - token_working = true; - } catch (IOException e) { - ErrorManager.sendErrorMessage(ErrorCode.SCP01); - DebugTool.log("TwitchBot instance has not been connected! (failed)", DebugPriority.ERROR, this.getClass()); - token_working = false; - } catch (IrcException e) { - ErrorManager.sendErrorMessage(ErrorCode.SCP02); - DebugTool.log("TwitchBot instance has not been connected! (failed)", DebugPriority.ERROR, this.getClass()); - token_working = false; + public void start() { + if (config.enabled().get()) { + if (isConfiguredCorrectly()) { + this.setVerbose(true); + DebugTool.log("TwitchBot instance has been requested to connect..."); + boolean token_working; + try { + this.connect("irc.twitch.tv", 6667, config.twitchtoken().get()); + DebugTool.log("(TwitchBot) Connecting to irc.twitch.tv:6667 with token from configuration..."); + token_working = true; + } catch (IOException e) { + ErrorManager.sendErrorMessage(ErrorCode.SCP01); + DebugTool.log("TwitchBot instance has not been connected! (failed)", DebugPriority.ERROR, this.getClass()); + token_working = false; + } catch (IrcException e) { + ErrorManager.sendErrorMessage(ErrorCode.SCP02); + DebugTool.log("TwitchBot instance has not been connected! (failed)", DebugPriority.ERROR, this.getClass()); + token_working = false; + } + if (token_working) { + this.joinChannel("#" + config.twitchchannel().get().toLowerCase()); + StreamChatPlus.autoBroadcastManager.startAutoBroadcasts(); + DebugTool.log("TwitchBot instance has been connected successfully", this.getClass()); + } + } } - if (token_working) { - this.joinChannel("#" + config.twitchchannel().get().toLowerCase()); - StreamChatPlus.autoBroadcastManager.startAutoBroadcasts(); - DebugTool.log("TwitchBot instance has been connected successfully", this.getClass()); - } - } } - } - public void stop() { - this.disconnect(); - StreamChatPlus.autoBroadcastManager.stopAutoBroadcasts(); - } + public void stop() { + this.disconnect(); + StreamChatPlus.autoBroadcastManager.stopAutoBroadcasts(); + } - public void restart() { - stop(); - final ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor(); - executorService.scheduleAtFixedRate(new Runnable() { - @Override - public void run() { - start(); - } - }, 0, 1, TimeUnit.SECONDS); - } + public void restart() { + stop(); + final ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor(); + executorService.scheduleAtFixedRate(new Runnable() { + @Override + public void run() { + start(); + } + }, 0, 1, TimeUnit.SECONDS); + } - @Override - public void onMessage(String channel, String sender, String login, String hostname, - String message) { - if (config.enabled().get()) { - if (!StreamChatPlus.customCommandManager.checkForCommand(message)) { - LabyGuice.getInstance(StreamChatPlus.class) - .displayMessage(ColorCodeTranslator.translateColorCodes(config.prefix().get()).replace("%user%", sender) - .replace("%message%", message).replace("@" + config.twitchchannel().get(), - "§l@" + config.twitchchannel().get())); - } + @Override + public void onMessage(String channel, String sender, String login, String hostname, + String message) { + if (config.enabled().get()) { + if (!StreamChatPlus.customCommandManager.checkForCommand(message)) { + LabyGuice.getInstance(StreamChatPlus.class) + .displayMessage(ColorCodeTranslator.translateColorCodes(config.prefix().get()).replace("%user%", sender) + .replace("%message%", message).replace("@" + config.twitchchannel().get(), + "§l@" + config.twitchchannel().get())); + } + } } - } - public void sendMessage(String message) { - this.sendMessage("#" + config.twitchchannel().get().toLowerCase(), - message.replaceFirst(config.ingameChatPrefix().get(), "")); - } + public void sendMessage(String message) { + this.sendMessage("#" + config.twitchchannel().get().toLowerCase(), + message.replaceFirst(config.ingameChatPrefix().get(), "")); + } - private boolean isConfiguredCorrectly() { - DebugTool.log("Checking configuration for all important data...", getClass()); - if (config.twitchchannel() != null && - config.twitchtoken() != null && - config.botName() != null) { - if (!config.twitchtoken().get().startsWith("oauth:")) { - ErrorManager.sendErrorMessage(ErrorCode.SCP03); - DebugTool.log("(ConfigurationCheck) Configuration contains invalid oauth format! (failed)", DebugPriority.ERROR, getClass()); - return false; - } else { - return true; - } - } else { - ErrorManager.sendErrorMessage(ErrorCode.SCP05); - DebugTool.log("(ConfigurationCheck) Required configuration fields \"Twitch Channel\", \"Twitch Token\" or \"Bot Name\" were not completed! (failed)", DebugPriority.ERROR, getClass()); - return false; + private boolean isConfiguredCorrectly() { + DebugTool.log("Checking configuration for all important data...", getClass()); + if (config.twitchchannel() != null && + config.twitchtoken() != null && + config.botName() != null) { + if (!config.twitchtoken().get().startsWith("oauth:")) { + ErrorManager.sendErrorMessage(ErrorCode.SCP03); + DebugTool.log("(ConfigurationCheck) Configuration contains invalid oauth format! (failed)", DebugPriority.ERROR, getClass()); + return false; + } else { + return true; + } + } else { + ErrorManager.sendErrorMessage(ErrorCode.SCP05); + DebugTool.log("(ConfigurationCheck) Required configuration fields \"Twitch Channel\", \"Twitch Token\" or \"Bot Name\" were not completed! (failed)", DebugPriority.ERROR, getClass()); + return false; + } } - } } diff --git a/core/src/main/java/de/unordentlich/streamchatplus/core/utils/autobroadcast/AutoBroadcastManager.java b/core/src/main/java/de/unordentlich/streamchatplus/core/utils/autobroadcast/AutoBroadcastManager.java index bd13746..feacaf3 100644 --- a/core/src/main/java/de/unordentlich/streamchatplus/core/utils/autobroadcast/AutoBroadcastManager.java +++ b/core/src/main/java/de/unordentlich/streamchatplus/core/utils/autobroadcast/AutoBroadcastManager.java @@ -6,98 +6,98 @@ import de.unordentlich.streamchatplus.core.utils.support.DebugTool; import de.unordentlich.streamchatplus.core.utils.support.objects.DebugPriority; +import javax.inject.Inject; import java.util.ArrayList; import java.util.Objects; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; -import javax.inject.Inject; public class AutoBroadcastManager { - private final StreamChatPlus addon; - private AutoBroadcastSubSettings config; + private final StreamChatPlus addon; + private final AutoBroadcastSubSettings config; - public ArrayList autoBroadcast = new ArrayList(); - public ScheduledExecutorService executor; + public ArrayList autoBroadcast = new ArrayList(); + public ScheduledExecutorService executor; - //TODO option to decide, if the broadcast start/stop should be bound to client- or world/server-startup + //TODO option to decide, if the broadcast start/stop should be bound to client- or world/server-startup - @Inject - public AutoBroadcastManager(StreamChatPlus addon) { - this.addon = addon; - config = this.addon.configuration().autoBroadcastSubSettings(); - DebugTool.log("AutoBroadcaster has been initialized", getClass()); - } + @Inject + public AutoBroadcastManager(StreamChatPlus addon) { + this.addon = addon; + config = this.addon.configuration().autoBroadcastSubSettings(); + DebugTool.log("AutoBroadcaster has been initialized", getClass()); + } - public void startAutoBroadcasts() { - executor = Executors.newScheduledThreadPool(1); - autoBroadcast.forEach(ab -> { - Runnable broadcastRunnable = new Runnable() { - public void run() { - if (StreamChatPlus.bot.isConnected()) { - StreamChatPlus.bot.sendMessage(ab.getMessage()); - DebugTool.log("AutoBroadcaster sent broadcast \"" + (ab.getMessage().length() > 10 ? ab.getMessage().substring(0, 10) + "..." : ab.getMessage()) + "\" with an interval of " + ab.getInterval() + " minutes", getClass()); - } - } - }; - executor.scheduleAtFixedRate(broadcastRunnable, ab.getInterval(), ab.getInterval(), - TimeUnit.MINUTES); - }); - DebugTool.log("AutoBroadcaster has been started", getClass()); - } + public void startAutoBroadcasts() { + executor = Executors.newScheduledThreadPool(1); + autoBroadcast.forEach(ab -> { + Runnable broadcastRunnable = new Runnable() { + public void run() { + if (StreamChatPlus.bot.isConnected()) { + StreamChatPlus.bot.sendMessage(ab.getMessage()); + DebugTool.log("AutoBroadcaster sent broadcast \"" + (ab.getMessage().length() > 10 ? ab.getMessage().substring(0, 10) + "..." : ab.getMessage()) + "\" with an interval of " + ab.getInterval() + " minutes", getClass()); + } + } + }; + executor.scheduleAtFixedRate(broadcastRunnable, ab.getInterval(), ab.getInterval(), + TimeUnit.MINUTES); + }); + DebugTool.log("AutoBroadcaster has been started", getClass()); + } - public void stopAutoBroadcasts() { - executor.shutdown(); - DebugTool.log("AutoBroadcaster has been manually stopped", DebugPriority.WARNING, getClass()); - } + public void stopAutoBroadcasts() { + executor.shutdown(); + DebugTool.log("AutoBroadcaster has been manually stopped", DebugPriority.WARNING, getClass()); + } - public void initializeAutoBroadcasts() { - if (config.enabled().get()) { - autoBroadcast.clear(); - if (!Objects.equals(config.message1().get(), "")) { - if (!config.message1().get().equalsIgnoreCase( - "This is your first Custom Broadcast. It will be executed every 5 minutes in your twitch chat!")) { - autoBroadcast.add(new AutoBroadcast(config.interval1().get(), config.message1().get())); - DebugTool.log(" AutoBroadcast #1 has been loaded from configuration", getClass()); + public void initializeAutoBroadcasts() { + if (config.enabled().get()) { + autoBroadcast.clear(); + if (!Objects.equals(config.message1().get(), "")) { + if (!config.message1().get().equalsIgnoreCase( + "This is your first Custom Broadcast. It will be executed every 5 minutes in your twitch chat!")) { + autoBroadcast.add(new AutoBroadcast(config.interval1().get(), config.message1().get())); + DebugTool.log(" AutoBroadcast #1 has been loaded from configuration", getClass()); + } + } + if (!Objects.equals(config.message2().get(), "")) { + autoBroadcast.add(new AutoBroadcast(config.interval2().get(), config.message2().get())); + DebugTool.log(" AutoBroadcast #2 has been loaded from configuration", getClass()); + } + if (!Objects.equals(config.message3().get(), "")) { + autoBroadcast.add(new AutoBroadcast(config.interval3().get(), config.message3().get())); + DebugTool.log(" AutoBroadcast #3 has been loaded from configuration", getClass()); + } + if (!Objects.equals(config.message4().get(), "")) { + autoBroadcast.add(new AutoBroadcast(config.interval4().get(), config.message4().get())); + DebugTool.log(" AutoBroadcast #4 has been loaded from configuration", getClass()); + } + if (!Objects.equals(config.message5().get(), "")) { + autoBroadcast.add(new AutoBroadcast(config.interval5().get(), config.message5().get())); + DebugTool.log(" AutoBroadcast #5 has been loaded from configuration", getClass()); + } + if (!Objects.equals(config.message6().get(), "")) { + autoBroadcast.add(new AutoBroadcast(config.interval6().get(), config.message6().get())); + DebugTool.log(" AutoBroadcast #6 has been loaded from configuration", getClass()); + } + if (!Objects.equals(config.message7().get(), "")) { + autoBroadcast.add(new AutoBroadcast(config.interval7().get(), config.message7().get())); + DebugTool.log(" AutoBroadcast #7 has been loaded from configuration", getClass()); + } + if (!Objects.equals(config.message8().get(), "")) { + autoBroadcast.add(new AutoBroadcast(config.interval8().get(), config.message8().get())); + DebugTool.log(" AutoBroadcast #8 has been loaded from configuration", getClass()); + } + if (!Objects.equals(config.message9().get(), "")) { + autoBroadcast.add(new AutoBroadcast(config.interval9().get(), config.message9().get())); + DebugTool.log(" AutoBroadcast #9 has been loaded from configuration", getClass()); + } + if (!Objects.equals(config.message10().get(), "")) { + autoBroadcast.add(new AutoBroadcast(config.interval10().get(), config.message10().get())); + DebugTool.log(" AutoBroadcast #10 has been loaded from configuration", getClass()); + } } - } - if (!Objects.equals(config.message2().get(), "")) { - autoBroadcast.add(new AutoBroadcast(config.interval2().get(), config.message2().get())); - DebugTool.log(" AutoBroadcast #2 has been loaded from configuration", getClass()); - } - if (!Objects.equals(config.message3().get(), "")) { - autoBroadcast.add(new AutoBroadcast(config.interval3().get(), config.message3().get())); - DebugTool.log(" AutoBroadcast #3 has been loaded from configuration", getClass()); - } - if (!Objects.equals(config.message4().get(), "")) { - autoBroadcast.add(new AutoBroadcast(config.interval4().get(), config.message4().get())); - DebugTool.log(" AutoBroadcast #4 has been loaded from configuration", getClass()); - } - if (!Objects.equals(config.message5().get(), "")) { - autoBroadcast.add(new AutoBroadcast(config.interval5().get(), config.message5().get())); - DebugTool.log(" AutoBroadcast #5 has been loaded from configuration", getClass()); - } - if (!Objects.equals(config.message6().get(), "")) { - autoBroadcast.add(new AutoBroadcast(config.interval6().get(), config.message6().get())); - DebugTool.log(" AutoBroadcast #6 has been loaded from configuration", getClass()); - } - if (!Objects.equals(config.message7().get(), "")) { - autoBroadcast.add(new AutoBroadcast(config.interval7().get(), config.message7().get())); - DebugTool.log(" AutoBroadcast #7 has been loaded from configuration", getClass()); - } - if (!Objects.equals(config.message8().get(), "")) { - autoBroadcast.add(new AutoBroadcast(config.interval8().get(), config.message8().get())); - DebugTool.log(" AutoBroadcast #8 has been loaded from configuration", getClass()); - } - if (!Objects.equals(config.message9().get(), "")) { - autoBroadcast.add(new AutoBroadcast(config.interval9().get(), config.message9().get())); - DebugTool.log(" AutoBroadcast #9 has been loaded from configuration", getClass()); - } - if (!Objects.equals(config.message10().get(), "")) { - autoBroadcast.add(new AutoBroadcast(config.interval10().get(), config.message10().get())); - DebugTool.log(" AutoBroadcast #10 has been loaded from configuration", getClass()); - } } - } } diff --git a/core/src/main/java/de/unordentlich/streamchatplus/core/utils/autobroadcast/objects/AutoBroadcast.java b/core/src/main/java/de/unordentlich/streamchatplus/core/utils/autobroadcast/objects/AutoBroadcast.java index a94f5dc..61abc02 100644 --- a/core/src/main/java/de/unordentlich/streamchatplus/core/utils/autobroadcast/objects/AutoBroadcast.java +++ b/core/src/main/java/de/unordentlich/streamchatplus/core/utils/autobroadcast/objects/AutoBroadcast.java @@ -2,19 +2,19 @@ public class AutoBroadcast { - int interval; - String message; + int interval; + String message; - public AutoBroadcast(int interval, String message) { - this.interval = interval; - this.message = message; - } + public AutoBroadcast(int interval, String message) { + this.interval = interval; + this.message = message; + } - public int getInterval() { - return interval; - } + public int getInterval() { + return interval; + } - public String getMessage() { - return message; - } + public String getMessage() { + return message; + } } diff --git a/core/src/main/java/de/unordentlich/streamchatplus/core/utils/customcommands/CustomCommandManager.java b/core/src/main/java/de/unordentlich/streamchatplus/core/utils/customcommands/CustomCommandManager.java index 183fc66..f27c9a6 100644 --- a/core/src/main/java/de/unordentlich/streamchatplus/core/utils/customcommands/CustomCommandManager.java +++ b/core/src/main/java/de/unordentlich/streamchatplus/core/utils/customcommands/CustomCommandManager.java @@ -3,118 +3,119 @@ import de.unordentlich.streamchatplus.core.StreamChatPlus; import de.unordentlich.streamchatplus.core.subconfigurations.CustomCommandSubSettings; import de.unordentlich.streamchatplus.core.utils.customcommands.objects.CustomCommand; -import java.util.HashMap; -import java.util.Objects; -import javax.inject.Inject; import de.unordentlich.streamchatplus.core.utils.support.DebugTool; import net.labymod.api.Laby; +import javax.inject.Inject; +import java.util.HashMap; +import java.util.Objects; + public class CustomCommandManager { - private final StreamChatPlus addon; - private CustomCommandSubSettings config; + private final StreamChatPlus addon; + private final CustomCommandSubSettings config; - public HashMap commands = new HashMap<>(); + public HashMap commands = new HashMap<>(); - @Inject - public CustomCommandManager(StreamChatPlus addon) { - this.addon = addon; - config = this.addon.configuration().customCommandSubSettings(); - DebugTool.log("CustomCommands have been initialized", getClass()); - } + @Inject + public CustomCommandManager(StreamChatPlus addon) { + this.addon = addon; + config = this.addon.configuration().customCommandSubSettings(); + DebugTool.log("CustomCommands have been initialized", getClass()); + } - public boolean checkForCommand(String message) { - if (config.enabled().get()) { - if (commands.containsKey(message.toLowerCase())) { - if (StreamChatPlus.bot.isConnected()) { - StreamChatPlus.bot.sendMessage(initializeResponse(message.toLowerCase())); - DebugTool.log("String was interpreted as a command and responded", getClass()); - return true; + public boolean checkForCommand(String message) { + if (config.enabled().get()) { + if (commands.containsKey(message.toLowerCase())) { + if (StreamChatPlus.bot.isConnected()) { + StreamChatPlus.bot.sendMessage(initializeResponse(message.toLowerCase())); + DebugTool.log("String was interpreted as a command and responded", getClass()); + return true; + } + return false; + } + return false; } return false; - } - return false; } - return false; - } - public String initializeResponse(String keyword) { - return commands.get(keyword).getResponse() - .replace("%name%", Laby.labyAPI().minecraft().clientPlayer().getName()) - .replace("%version%", Laby.labyAPI().minecraft().getVersion()) - .replace("%server%", (Laby.labyAPI().minecraft().isSingleplayer() ? "Singleplayer" - : Laby.labyAPI().serverController().getCurrentServerData().getName())) - .replace("%labynet%", - "https://laby.net/@" + Laby.labyAPI().minecraft().clientPlayer().getName()); - } + public String initializeResponse(String keyword) { + return commands.get(keyword).getResponse() + .replace("%name%", Laby.labyAPI().minecraft().clientPlayer().getName()) + .replace("%version%", Laby.labyAPI().minecraft().getVersion()) + .replace("%server%", (Laby.labyAPI().minecraft().isSingleplayer() ? "Singleplayer" + : Laby.labyAPI().serverController().getCurrentServerData().getName())) + .replace("%labynet%", + "https://laby.net/@" + Laby.labyAPI().minecraft().clientPlayer().getName()); + } - public void initializeCustomCommands() { - if (config.enabled().get()) { - commands.clear(); - if (!Objects.equals(config.command1().get(), "")) { - if (!config.command1().get().equalsIgnoreCase("!example") - && !config.response1().get().equalsIgnoreCase( - "This is your first Custom Command. It can be executed in your twitch chat!")) { - commands.put(config.command1().get().toLowerCase(), - new CustomCommand(config.command1().get(), config.response1().get())); - DebugTool.log(" CustomCommand #1 has been loaded from configuration", getClass()); + public void initializeCustomCommands() { + if (config.enabled().get()) { + commands.clear(); + if (!Objects.equals(config.command1().get(), "")) { + if (!config.command1().get().equalsIgnoreCase("!example") + && !config.response1().get().equalsIgnoreCase( + "This is your first Custom Command. It can be executed in your twitch chat!")) { + commands.put(config.command1().get().toLowerCase(), + new CustomCommand(config.command1().get(), config.response1().get())); + DebugTool.log(" CustomCommand #1 has been loaded from configuration", getClass()); + } + } + if (!Objects.equals(config.command2().get(), "") && !Objects.equals(config.response2().get(), + "")) { + commands.put(config.command2().get().toLowerCase(), + new CustomCommand(config.command2().get(), config.response2().get())); + DebugTool.log(" CustomCommand #2 has been loaded from configuration", getClass()); + } + if (!Objects.equals(config.command3().get(), "") && !Objects.equals(config.response3().get(), + "")) { + commands.put(config.command3().get().toLowerCase(), + new CustomCommand(config.command3().get(), config.response3().get())); + DebugTool.log(" CustomCommand #3 has been loaded from configuration", getClass()); + } + if (!Objects.equals(config.command4().get(), "") && !Objects.equals(config.response4().get(), + "")) { + commands.put(config.command4().get().toLowerCase(), + new CustomCommand(config.command4().get(), config.response4().get())); + DebugTool.log(" CustomCommand #4 has been loaded from configuration", getClass()); + } + if (!Objects.equals(config.command5().get(), "") && !Objects.equals(config.response5().get(), + "")) { + commands.put(config.command5().get().toLowerCase(), + new CustomCommand(config.command5().get(), config.response5().get())); + DebugTool.log(" CustomCommand #5 has been loaded from configuration", getClass()); + } + if (!Objects.equals(config.command6().get(), "") && !Objects.equals(config.response6().get(), + "")) { + commands.put(config.command6().get().toLowerCase(), + new CustomCommand(config.command6().get(), config.response6().get())); + DebugTool.log(" CustomCommand #6 has been loaded from configuration", getClass()); + } + if (!Objects.equals(config.command7().get(), "") && !Objects.equals(config.response7().get(), + "")) { + commands.put(config.command7().get().toLowerCase(), + new CustomCommand(config.command7().get(), config.response7().get())); + DebugTool.log(" CustomCommand #7 has been loaded from configuration", getClass()); + } + if (!Objects.equals(config.command8().get(), "") && !Objects.equals(config.response8().get(), + "")) { + commands.put(config.command8().get().toLowerCase(), + new CustomCommand(config.command8().get(), config.response8().get())); + DebugTool.log(" CustomCommand #8 has been loaded from configuration", getClass()); + } + if (!Objects.equals(config.command9().get(), "") && !Objects.equals(config.response9().get(), + "")) { + commands.put(config.command9().get().toLowerCase(), + new CustomCommand(config.command9().get(), config.response9().get())); + DebugTool.log(" CustomCommand #9 has been loaded from configuration", getClass()); + } + if (!Objects.equals(config.command10().get(), "") && !Objects.equals( + config.response10().get(), + "")) { + commands.put(config.command10().get().toLowerCase(), + new CustomCommand(config.command10().get(), config.response10().get())); + DebugTool.log(" CustomCommand #10 has been loaded from configuration", getClass()); + } } - } - if (!Objects.equals(config.command2().get(), "") && !Objects.equals(config.response2().get(), - "")) { - commands.put(config.command2().get().toLowerCase(), - new CustomCommand(config.command2().get(), config.response2().get())); - DebugTool.log(" CustomCommand #2 has been loaded from configuration", getClass()); - } - if (!Objects.equals(config.command3().get(), "") && !Objects.equals(config.response3().get(), - "")) { - commands.put(config.command3().get().toLowerCase(), - new CustomCommand(config.command3().get(), config.response3().get())); - DebugTool.log(" CustomCommand #3 has been loaded from configuration", getClass()); - } - if (!Objects.equals(config.command4().get(), "") && !Objects.equals(config.response4().get(), - "")) { - commands.put(config.command4().get().toLowerCase(), - new CustomCommand(config.command4().get(), config.response4().get())); - DebugTool.log(" CustomCommand #4 has been loaded from configuration", getClass()); - } - if (!Objects.equals(config.command5().get(), "") && !Objects.equals(config.response5().get(), - "")) { - commands.put(config.command5().get().toLowerCase(), - new CustomCommand(config.command5().get(), config.response5().get())); - DebugTool.log(" CustomCommand #5 has been loaded from configuration", getClass()); - } - if (!Objects.equals(config.command6().get(), "") && !Objects.equals(config.response6().get(), - "")) { - commands.put(config.command6().get().toLowerCase(), - new CustomCommand(config.command6().get(), config.response6().get())); - DebugTool.log(" CustomCommand #6 has been loaded from configuration", getClass()); - } - if (!Objects.equals(config.command7().get(), "") && !Objects.equals(config.response7().get(), - "")) { - commands.put(config.command7().get().toLowerCase(), - new CustomCommand(config.command7().get(), config.response7().get())); - DebugTool.log(" CustomCommand #7 has been loaded from configuration", getClass()); - } - if (!Objects.equals(config.command8().get(), "") && !Objects.equals(config.response8().get(), - "")) { - commands.put(config.command8().get().toLowerCase(), - new CustomCommand(config.command8().get(), config.response8().get())); - DebugTool.log(" CustomCommand #8 has been loaded from configuration", getClass()); - } - if (!Objects.equals(config.command9().get(), "") && !Objects.equals(config.response9().get(), - "")) { - commands.put(config.command9().get().toLowerCase(), - new CustomCommand(config.command9().get(), config.response9().get())); - DebugTool.log(" CustomCommand #9 has been loaded from configuration", getClass()); - } - if (!Objects.equals(config.command10().get(), "") && !Objects.equals( - config.response10().get(), - "")) { - commands.put(config.command10().get().toLowerCase(), - new CustomCommand(config.command10().get(), config.response10().get())); - DebugTool.log(" CustomCommand #10 has been loaded from configuration", getClass()); - } } - } } diff --git a/core/src/main/java/de/unordentlich/streamchatplus/core/utils/customcommands/objects/CustomCommand.java b/core/src/main/java/de/unordentlich/streamchatplus/core/utils/customcommands/objects/CustomCommand.java index be237e1..a82ef76 100644 --- a/core/src/main/java/de/unordentlich/streamchatplus/core/utils/customcommands/objects/CustomCommand.java +++ b/core/src/main/java/de/unordentlich/streamchatplus/core/utils/customcommands/objects/CustomCommand.java @@ -2,27 +2,27 @@ public class CustomCommand { - String keyword; - String response; + String keyword; + String response; - public CustomCommand(String keyword, String response) { - this.keyword = keyword; - this.response = response; - } + public CustomCommand(String keyword, String response) { + this.keyword = keyword; + this.response = response; + } - public String getKeyword() { - return keyword; - } + public String getKeyword() { + return keyword; + } - public void setKeyword(String keyword) { - this.keyword = keyword; - } + public void setKeyword(String keyword) { + this.keyword = keyword; + } - public String getResponse() { - return response; - } + public String getResponse() { + return response; + } - public void setResponse(String response) { - this.response = response; - } + public void setResponse(String response) { + this.response = response; + } } diff --git a/core/src/main/java/de/unordentlich/streamchatplus/core/utils/support/DebugTool.java b/core/src/main/java/de/unordentlich/streamchatplus/core/utils/support/DebugTool.java index e126adb..9137307 100644 --- a/core/src/main/java/de/unordentlich/streamchatplus/core/utils/support/DebugTool.java +++ b/core/src/main/java/de/unordentlich/streamchatplus/core/utils/support/DebugTool.java @@ -2,6 +2,12 @@ import de.unordentlich.streamchatplus.core.Configuration; import de.unordentlich.streamchatplus.core.StreamChatPlus; +import de.unordentlich.streamchatplus.core.utils.support.objects.DebugActionExecuter; +import de.unordentlich.streamchatplus.core.utils.support.objects.DebugEntry; +import de.unordentlich.streamchatplus.core.utils.support.objects.DebugPriority; +import net.labymod.api.Laby; + +import javax.inject.Inject; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; @@ -11,614 +17,609 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.stream.Collectors; -import javax.inject.Inject; -import de.unordentlich.streamchatplus.core.utils.support.objects.DebugActionExecuter; -import de.unordentlich.streamchatplus.core.utils.support.objects.DebugEntry; -import de.unordentlich.streamchatplus.core.utils.support.objects.DebugPriority; -import net.labymod.api.Laby; public class DebugTool { - private final Configuration configuration; - public static boolean isFirstClick = true; - public static long lastClick = 0; - - @Inject - public DebugTool(Configuration config) { - this.configuration = config; - } - - public String createDebugLog() throws IOException { - URL url = new URL("https://paste.labymod.net/documents"); - URLConnection connection = url.openConnection(); - - connection.setRequestProperty("authority", "paste.labymod.net"); - connection.setRequestProperty("accept", "application/json, text/javascript, /; q=0.01"); - connection.setRequestProperty("x-requested-with", "XMLHttpRequest"); - connection.setRequestProperty("user-agent", - "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.92 Safari/537.36'"); - connection.setRequestProperty("content-type", "application/json; charset=UTF-8"); - connection.setDoOutput(true); - - OutputStream stream = connection.getOutputStream(); - stream.write((prepareDebugLog()).getBytes()); - stream.flush(); - stream.close(); - - BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); - String response = reader.lines().collect(Collectors.joining("\n")); - - return "https://paste.labymod.net/" + response.split("\"")[3]; - } - - private String prepareDebugLog() { - StringBuilder log = new StringBuilder(new SimpleDateFormat("dd.MM.yyyy '//' HH:mm:ss").format( - new Date(System.currentTimeMillis())) + " (" + System.currentTimeMillis() + ")"); - - /** LOGO **/ - log - .append("\n\n") - .append(" _____ _ _____ _ _ \n") - .append(" / ____| | / ____| | | | _ \n") - .append("| (___ | |_ _ __ ___ __ _ _ __ ___ | | | |__ __ _| |_ _| |_ \n") - .append(" \\___ \\| __| '__/ _ \\/ _` | '_ ` _ \\| | | '_ \\ / _` | __|_ _|\n") - .append(" ____) | |_| | | __/ (_| | | | | | | |____| | | | (_| | |_ |_| \n") - .append("|_____/ \\__|_| \\___|\\__,_|_| |_| |_|\\_____|_| |_|\\__,_|\\__| \n\n") - .append(" made by unordentlich \n") - .append("\n"); - - /** DESCRIPTION **/ - log - .append( - "\n\n This log helps the Addon Support Team to evaluate possible errors and problems. \n" - + " If you are asked for this log in the support, just double-click on the \"Support\" button and \n" - + " paste the link via the context menu or CTRL+V in the support ticket. We will help you as soon as possible!\n\n"); - - /** DISCLAIMER **/ - log - .append(" _____________________________________________\n") - .append(" | |\n") - .append(" | By sharing this log, |\n") - .append(" | you are revealing the following data: |\n") - .append(" | |\n") - .append(" |———————————————————————————————————————————|\n") - .append(" | |\n") - .append(" | › Your Minecraft Username |\n") - .append(" | › Your Minecraft UUID |\n") - .append(" | › Your Minecraft Version |\n") - .append(" | › Your LabyMod Version |\n") - .append(" | › Your Addon Version |\n") - .append(" | › Your Operating System |\n") - .append(" | › Your JVM Version |\n") - .append(" | › Your Minecraft Language |\n") - .append(" | › Your configuration of this addon |\n") - .append(" | › The names of your installed addons |\n") - .append(" | |\n") - .append(" |———————————————————————————————————————————|\n") - .append(" | |\n") - .append(" | However, by sharing this log, |\n") - .append( - " | we will »NEVER« reveal the following data |\n") - .append(" | |\n") - .append(" |‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾|\n") - .append(" | |\n") - .append(" | › Your Twitch Auth Token |\n") - .append(" | › Any account credentials |\n") - .append(" | › Your IP address |\n") - .append(" | › Any personal information like mail |\n") - .append(" | |\n") - .append(" ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾") - .append("\n"); - - /** USER INFORMATIONS **/ - log - .append("\n") - .append(" #################################################################\n") - .append(" # User Information |"); - int leftSpaces = 63 - 20 - 18 - Laby.labyAPI().getName().length(); - for (int i = 0; i < leftSpaces; i++) { - log.append(" "); + private final Configuration configuration; + public static boolean isFirstClick = true; + public static long lastClick = 0; + + @Inject + public DebugTool(Configuration config) { + this.configuration = config; + } + + public String createDebugLog() throws IOException { + URL url = new URL("https://paste.labymod.net/documents"); + URLConnection connection = url.openConnection(); + + connection.setRequestProperty("authority", "paste.labymod.net"); + connection.setRequestProperty("accept", "application/json, text/javascript, /; q=0.01"); + connection.setRequestProperty("x-requested-with", "XMLHttpRequest"); + connection.setRequestProperty("user-agent", + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.92 Safari/537.36'"); + connection.setRequestProperty("content-type", "application/json; charset=UTF-8"); + connection.setDoOutput(true); + + OutputStream stream = connection.getOutputStream(); + stream.write((prepareDebugLog()).getBytes()); + stream.flush(); + stream.close(); + + BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); + String response = reader.lines().collect(Collectors.joining("\n")); + + return "https://paste.labymod.net/" + response.split("\"")[3]; } - log - .append("https://laby.net/@") - .append(Laby.labyAPI().getName()) - .append(" #\n") - .append(" # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ #\n") - .append(" # Username: ") - .append(Laby.labyAPI().getName()); - leftSpaces = (63 - 11) - Laby.labyAPI().getName().length(); - for (int i = 0; i < leftSpaces; i++) { - log.append(" "); + + private String prepareDebugLog() { + StringBuilder log = new StringBuilder(new SimpleDateFormat("dd.MM.yyyy '//' HH:mm:ss").format( + new Date(System.currentTimeMillis())) + " (" + System.currentTimeMillis() + ")"); + + /** LOGO **/ + log + .append("\n\n") + .append(" _____ _ _____ _ _ \n") + .append(" / ____| | / ____| | | | _ \n") + .append("| (___ | |_ _ __ ___ __ _ _ __ ___ | | | |__ __ _| |_ _| |_ \n") + .append(" \\___ \\| __| '__/ _ \\/ _` | '_ ` _ \\| | | '_ \\ / _` | __|_ _|\n") + .append(" ____) | |_| | | __/ (_| | | | | | | |____| | | | (_| | |_ |_| \n") + .append("|_____/ \\__|_| \\___|\\__,_|_| |_| |_|\\_____|_| |_|\\__,_|\\__| \n\n") + .append(" made by unordentlich \n") + .append("\n"); + + /** DESCRIPTION **/ + log + .append( + "\n\n This log helps the Addon Support Team to evaluate possible errors and problems. \n" + + " If you are asked for this log in the support, just double-click on the \"Support\" button and \n" + + " paste the link via the context menu or CTRL+V in the support ticket. We will help you as soon as possible!\n\n"); + + /** DISCLAIMER **/ + log + .append(" _____________________________________________\n") + .append(" | |\n") + .append(" | By sharing this log, |\n") + .append(" | you are revealing the following data: |\n") + .append(" | |\n") + .append(" |———————————————————————————————————————————|\n") + .append(" | |\n") + .append(" | › Your Minecraft Username |\n") + .append(" | › Your Minecraft UUID |\n") + .append(" | › Your Minecraft Version |\n") + .append(" | › Your LabyMod Version |\n") + .append(" | › Your Addon Version |\n") + .append(" | › Your Operating System |\n") + .append(" | › Your JVM Version |\n") + .append(" | › Your Minecraft Language |\n") + .append(" | › Your configuration of this addon |\n") + .append(" | › The names of your installed addons |\n") + .append(" | |\n") + .append(" |———————————————————————————————————————————|\n") + .append(" | |\n") + .append(" | However, by sharing this log, |\n") + .append( + " | we will »NEVER« reveal the following data |\n") + .append(" | |\n") + .append(" |‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾|\n") + .append(" | |\n") + .append(" | › Your Twitch Auth Token |\n") + .append(" | › Any account credentials |\n") + .append(" | › Your IP address |\n") + .append(" | › Any personal information like mail |\n") + .append(" | |\n") + .append(" ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾") + .append("\n"); + + /** USER INFORMATIONS **/ + log + .append("\n") + .append(" #################################################################\n") + .append(" # User Information |"); + int leftSpaces = 63 - 20 - 18 - Laby.labyAPI().getName().length(); + for (int i = 0; i < leftSpaces; i++) { + log.append(" "); + } + log + .append("https://laby.net/@") + .append(Laby.labyAPI().getName()) + .append(" #\n") + .append(" # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ #\n") + .append(" # Username: ") + .append(Laby.labyAPI().getName()); + leftSpaces = (63 - 11) - Laby.labyAPI().getName().length(); + for (int i = 0; i < leftSpaces; i++) { + log.append(" "); + } + + // UUID + log + .append("#\n") + .append(" # UUID: ") + .append(Laby.labyAPI().getUniqueId().toString()); + leftSpaces = + (63 - 7) - Laby.labyAPI().getUniqueId().toString().length(); + for (int i = 0; i < leftSpaces; i++) { + log.append(" "); + } + + // VERSION + log + .append("#\n") + .append(" # #\n") + .append(" # Version: ") + .append(Laby.labyAPI().minecraft().getVersion()); + leftSpaces = + (63 - 10) - Laby.labyAPI().minecraft().getVersion().length(); + for (int i = 0; i < leftSpaces; i++) { + log.append(" "); + } + + // LABYMOD VERSION + log + .append("#\n") + .append(" # LabyMod Version: ") + .append(Laby.labyAPI().getVersion()); + leftSpaces = (63 - 18) - Laby.labyAPI().getVersion().length(); + for (int i = 0; i < leftSpaces; i++) { + log.append(" "); + } + + // ADDON VERSION + log + .append("#\n") + .append(" # Addon Version: ") + .append("v" + StreamChatPlus.addonInfo.getVersion()); + leftSpaces = (63 - 16) - (StreamChatPlus.addonInfo.getVersion().length() + 1); + for (int i = 0; i < leftSpaces; i++) { + log.append(" "); + } + + //ADDONS + log + .append("#\n"); + int addonsAmount = Laby.labyAPI().addonService().getLoadedAddons().size(); + log + .append(" # Addons (") + .append(addonsAmount) + .append("): ") + .append(calculateSpaces(63 - 13, String.valueOf(addonsAmount))) + .append("#\n"); + + Laby.labyAPI().addonService().getLoadedAddons().forEach(addon -> { + log + .append(" # › " + addon.info().getDisplayName()) + .append(calculateSpaces(63 - 6, addon.info().getDisplayName())) + .append("#\n"); + }); + + // OPERATING SYSTEM + log + .append(" # #\n") + .append(" # Operating System (OS): ") + .append(System.getProperty("os.name")); + leftSpaces = (63 - 24) - (System.getProperty("os.name").length()); + for (int i = 0; i < leftSpaces; i++) { + log.append(" "); + } + + // JVM SYSTEM + log + .append("#\n") + .append(" # Java VM Version: ") + .append(System.getProperty("java.vm.version")); + leftSpaces = (63 - 18) - (System.getProperty("java.vm.version").length()); + for (int i = 0; i < leftSpaces; i++) { + log.append(" "); + } + + // MINECRAFT LANGUAGE + log + .append("#\n") + .append(" # Language: ") + .append(Laby.labyAPI().minecraft().options().getCurrentLanguage()); + leftSpaces = (63 - 11) - (Laby.labyAPI().minecraft().options().getCurrentLanguage().length()); + for (int i = 0; i < leftSpaces; i++) { + log.append(" "); + } + log.append("#\n") + .append(" # #\n") + .append(" #################################################################"); + + log.append("\n\n\n"); + + log + .append( + " #################################################################################################################################################\n") + .append( + " # Addon Configuration | #\n") + .append( + " # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ #\n") + .append(" # ") + .append("enabled: ") + .append(configuration.enabled().get()) + .append(calculateSpaces(141 - 9, configuration.enabled().get().toString())) + .append("#\n") + .append(" # ") + .append("prefix: ") + .append(configuration.prefix().get()) + .append(calculateSpaces(141 - 8, configuration.prefix().get())) + .append("#\n") + .append(" # ") + .append("botName: ") + .append(configuration.botName().get()) + .append(calculateSpaces(141 - 9, configuration.botName().get())) + .append("#\n") + .append(" # ") + .append("twitchChannel: ") + .append(configuration.twitchchannel().get()) + .append(calculateSpaces(141 - 15, configuration.twitchchannel().get())) + .append("#\n") + .append(" # ") + .append("twitchToken: ") + .append(hidingInformation()) + .append(calculateSpaces(141 - 8, "Hidden due to security restrictions")) + .append("#\n") + .append(" # ") + .append("ingameChatEnabled: ") + .append(configuration.ingameChatEnabled().get()) + .append(calculateSpaces(141 - 19, configuration.ingameChatEnabled().get().toString())) + .append("#\n") + .append(" # ") + .append("ingameChatPrefix: ") + .append(configuration.ingameChatPrefix().get()) + .append(calculateSpaces(141 - 18, configuration.ingameChatPrefix().get())) + .append("#\n") + .append( + " # autoBroadcastSubSettings: #\n") // AutoBroadcast (subtract 4 from every SpaceCalculation due to indentation) + .append(" # ") + .append("enabled: ") + .append(configuration.autoBroadcastSubSettings().enabled().get()) + .append(calculateSpaces(141 - 4 - 9, + configuration.autoBroadcastSubSettings().enabled().get().toString())) + .append("#\n") + .append(" # ") + .append("interval1: ") + .append(configuration.autoBroadcastSubSettings().interval1().get()) + .append(calculateSpaces(141 - 4 - 11, + configuration.autoBroadcastSubSettings().interval1().get().toString())) + .append("#\n") + .append(" # ") + .append("message1: ") + .append(configuration.autoBroadcastSubSettings().message1().get()) + .append(calculateSpaces(141 - 4 - 10, + configuration.autoBroadcastSubSettings().message1().get())) + .append("#\n") + .append(" # ") + .append("interval2: ") + .append(configuration.autoBroadcastSubSettings().interval2().get()) + .append(calculateSpaces(141 - 4 - 11, + configuration.autoBroadcastSubSettings().interval2().get().toString())) + .append("#\n") + .append(" # ") + .append("message2: ") + .append(configuration.autoBroadcastSubSettings().message2().get()) + .append(calculateSpaces(141 - 4 - 10, + configuration.autoBroadcastSubSettings().message2().get())) + .append("#\n") + .append(" # ") + .append("interval3: ") + .append(configuration.autoBroadcastSubSettings().interval3().get()) + .append(calculateSpaces(141 - 4 - 11, + configuration.autoBroadcastSubSettings().interval3().get().toString())) + .append("#\n") + .append(" # ") + .append("message3: ") + .append(configuration.autoBroadcastSubSettings().message3().get()) + .append(calculateSpaces(141 - 4 - 10, + configuration.autoBroadcastSubSettings().message3().get())) + .append("#\n") + .append(" # ") + .append("interval4: ") + .append(configuration.autoBroadcastSubSettings().interval4().get()) + .append(calculateSpaces(141 - 4 - 11, + configuration.autoBroadcastSubSettings().interval4().get().toString())) + .append("#\n") + .append(" # ") + .append("message4: ") + .append(configuration.autoBroadcastSubSettings().message4().get()) + .append(calculateSpaces(141 - 4 - 10, + configuration.autoBroadcastSubSettings().message4().get())) + .append("#\n") + .append(" # ") + .append("interval5: ") + .append(configuration.autoBroadcastSubSettings().interval5().get()) + .append(calculateSpaces(141 - 4 - 11, + configuration.autoBroadcastSubSettings().interval5().get().toString())) + .append("#\n") + .append(" # ") + .append("message5: ") + .append(configuration.autoBroadcastSubSettings().message5().get()) + .append(calculateSpaces(141 - 4 - 10, + configuration.autoBroadcastSubSettings().message5().get())) + .append("#\n") + .append(" # ") + .append("interval6: ") + .append(configuration.autoBroadcastSubSettings().interval6().get()) + .append(calculateSpaces(141 - 4 - 11, + configuration.autoBroadcastSubSettings().interval6().get().toString())) + .append("#\n") + .append(" # ") + .append("message6: ") + .append(configuration.autoBroadcastSubSettings().message6().get()) + .append(calculateSpaces(141 - 4 - 10, + configuration.autoBroadcastSubSettings().message6().get())) + .append("#\n") + .append(" # ") + .append("interval7: ") + .append(configuration.autoBroadcastSubSettings().interval7().get()) + .append(calculateSpaces(141 - 4 - 11, + configuration.autoBroadcastSubSettings().interval7().get().toString())) + .append("#\n") + .append(" # ") + .append("message7: ") + .append(configuration.autoBroadcastSubSettings().message7().get()) + .append(calculateSpaces(141 - 4 - 10, + configuration.autoBroadcastSubSettings().message7().get())) + .append("#\n") + .append(" # ") + .append("interval8: ") + .append(configuration.autoBroadcastSubSettings().interval8().get()) + .append(calculateSpaces(141 - 4 - 11, + configuration.autoBroadcastSubSettings().interval8().get().toString())) + .append("#\n") + .append(" # ") + .append("message8: ") + .append(configuration.autoBroadcastSubSettings().message8().get()) + .append(calculateSpaces(141 - 4 - 10, + configuration.autoBroadcastSubSettings().message8().get())) + .append("#\n") + .append(" # ") + .append("interval9: ") + .append(configuration.autoBroadcastSubSettings().interval9().get()) + .append(calculateSpaces(141 - 4 - 11, + configuration.autoBroadcastSubSettings().interval9().get().toString())) + .append("#\n") + .append(" # ") + .append("message9: ") + .append(configuration.autoBroadcastSubSettings().message9().get()) + .append(calculateSpaces(141 - 4 - 10, + configuration.autoBroadcastSubSettings().message9().get())) + .append("#\n") + .append(" # ") + .append("interval10: ") + .append(configuration.autoBroadcastSubSettings().interval10().get()) + .append(calculateSpaces(141 - 4 - 12, + configuration.autoBroadcastSubSettings().interval10().get().toString())) + .append("#\n") + .append(" # ") + .append("message10: ") + .append(configuration.autoBroadcastSubSettings().message10().get()) + .append(calculateSpaces(141 - 4 - 11, + configuration.autoBroadcastSubSettings().message10().get())) + .append("#\n") // AutoBroadcast end + .append( + " # customCommandSubSettings: #\n") // CustomCommand (subtract 4 from every SpaceCalculation due to indentation) + .append(" # ") + .append("enabled: ") + .append(configuration.customCommandSubSettings().enabled().get()) + .append(calculateSpaces(141 - 4 - 9, + configuration.customCommandSubSettings().enabled().get().toString())) + .append("#\n") + .append(" # ") + .append("command1: ") + .append(configuration.customCommandSubSettings().command1().get()) + .append(calculateSpaces(141 - 4 - 10, + configuration.customCommandSubSettings().command1().get())) + .append("#\n") + .append(" # ") + .append("response1: ") + .append(configuration.customCommandSubSettings().response1().get()) + .append(calculateSpaces(141 - 4 - 11, + configuration.customCommandSubSettings().response1().get())) + .append("#\n") + .append(" # ") + .append("command2: ") + .append(configuration.customCommandSubSettings().command2().get()) + .append(calculateSpaces(141 - 4 - 10, + configuration.customCommandSubSettings().command2().get())) + .append("#\n") + .append(" # ") + .append("response2: ") + .append(configuration.customCommandSubSettings().response2().get()) + .append(calculateSpaces(141 - 4 - 11, + configuration.customCommandSubSettings().response2().get())) + .append("#\n") + .append(" # ") + .append("command3: ") + .append(configuration.customCommandSubSettings().command3().get()) + .append(calculateSpaces(141 - 4 - 10, + configuration.customCommandSubSettings().command3().get())) + .append("#\n") + .append(" # ") + .append("response3: ") + .append(configuration.customCommandSubSettings().response3().get()) + .append(calculateSpaces(141 - 4 - 11, + configuration.customCommandSubSettings().response3().get())) + .append("#\n") + .append(" # ") + .append("command4: ") + .append(configuration.customCommandSubSettings().command4().get()) + .append(calculateSpaces(141 - 4 - 10, + configuration.customCommandSubSettings().command4().get())) + .append("#\n") + .append(" # ") + .append("response4: ") + .append(configuration.customCommandSubSettings().response4().get()) + .append(calculateSpaces(141 - 4 - 11, + configuration.customCommandSubSettings().response4().get())) + .append("#\n") + .append(" # ") + .append("command5: ") + .append(configuration.customCommandSubSettings().command5().get()) + .append(calculateSpaces(141 - 4 - 10, + configuration.customCommandSubSettings().command5().get())) + .append("#\n") + .append(" # ") + .append("response5: ") + .append(configuration.customCommandSubSettings().response5().get()) + .append(calculateSpaces(141 - 4 - 11, + configuration.customCommandSubSettings().response5().get())) + .append("#\n") + .append(" # ") + .append("command6: ") + .append(configuration.customCommandSubSettings().command6().get()) + .append(calculateSpaces(141 - 4 - 10, + configuration.customCommandSubSettings().command6().get())) + .append("#\n") + .append(" # ") + .append("response6: ") + .append(configuration.customCommandSubSettings().response6().get()) + .append(calculateSpaces(141 - 4 - 11, + configuration.customCommandSubSettings().response6().get())) + .append("#\n") + .append(" # ") + .append("command7: ") + .append(configuration.customCommandSubSettings().command7().get()) + .append(calculateSpaces(141 - 4 - 10, + configuration.customCommandSubSettings().command7().get())) + .append("#\n") + .append(" # ") + .append("response7: ") + .append(configuration.customCommandSubSettings().response7().get()) + .append(calculateSpaces(141 - 4 - 11, + configuration.customCommandSubSettings().response7().get())) + .append("#\n") + .append(" # ") + .append("command8: ") + .append(configuration.customCommandSubSettings().command8().get()) + .append(calculateSpaces(141 - 4 - 10, + configuration.customCommandSubSettings().command8().get())) + .append("#\n") + .append(" # ") + .append("response8: ") + .append(configuration.customCommandSubSettings().response8().get()) + .append(calculateSpaces(141 - 4 - 11, + configuration.customCommandSubSettings().response8().get())) + .append("#\n") + .append(" # ") + .append("command9: ") + .append(configuration.customCommandSubSettings().command9().get()) + .append(calculateSpaces(141 - 4 - 10, + configuration.customCommandSubSettings().command9().get())) + .append("#\n") + .append(" # ") + .append("response9: ") + .append(configuration.customCommandSubSettings().response9().get()) + .append(calculateSpaces(141 - 4 - 11, + configuration.customCommandSubSettings().response9().get())) + .append("#\n") + .append(" # ") + .append("command10: ") + .append(configuration.customCommandSubSettings().command10().get()) + .append(calculateSpaces(141 - 4 - 11, + configuration.customCommandSubSettings().command10().get())) + .append("#\n") + .append(" # ") + .append("response10: ") + .append(configuration.customCommandSubSettings().response10().get()) + .append(calculateSpaces(141 - 4 - 12, + configuration.customCommandSubSettings().response10().get())) + .append("#\n") // CustomCommands end + .append( + " # #\n") + .append( + " #################################################################################################################################################\n") + + .append("\n\n") + .append(" // Debug Console //") + .append(loadDebugEntries()); + return log.toString(); } - // UUID - log - .append("#\n") - .append(" # UUID: ") - .append(Laby.labyAPI().getUniqueId().toString()); - leftSpaces = - (63 - 7) - Laby.labyAPI().getUniqueId().toString().length(); - for (int i = 0; i < leftSpaces; i++) { - log.append(" "); + public static void log(String event, DebugPriority priority, DebugActionExecuter executer) { + DebugEntry entry = new DebugEntry(event, priority).executer(executer); + StreamChatPlus.debugLog.add(entry); } - // VERSION - log - .append("#\n") - .append(" # #\n") - .append(" # Version: ") - .append(Laby.labyAPI().minecraft().getVersion()); - leftSpaces = - (63 - 10) - Laby.labyAPI().minecraft().getVersion().length(); - for (int i = 0; i < leftSpaces; i++) { - log.append(" "); + public static void log(String event, DebugPriority priority) { + DebugEntry entry = new DebugEntry(event, priority); + StreamChatPlus.debugLog.add(entry); } - // LABYMOD VERSION - log - .append("#\n") - .append(" # LabyMod Version: ") - .append(Laby.labyAPI().getVersion()); - leftSpaces = (63 - 18) - Laby.labyAPI().getVersion().length(); - for (int i = 0; i < leftSpaces; i++) { - log.append(" "); + public static void log(String event, DebugActionExecuter executer) { + DebugEntry entry = new DebugEntry(event).executer(executer); + StreamChatPlus.debugLog.add(entry); } - // ADDON VERSION - log - .append("#\n") - .append(" # Addon Version: ") - .append("v" + StreamChatPlus.addonInfo.getVersion()); - leftSpaces = (63 - 16) - (StreamChatPlus.addonInfo.getVersion().length() + 1); - for (int i = 0; i < leftSpaces; i++) { - log.append(" "); + public static void log(String event) { + DebugEntry entry = new DebugEntry(event); + StreamChatPlus.debugLog.add(entry); } - //ADDONS - log - .append("#\n"); - int addonsAmount = Laby.labyAPI().addonService().getLoadedAddons().size(); - log - .append(" # Addons (") - .append(addonsAmount) - .append("): ") - .append(calculateSpaces(63 - 13, String.valueOf(addonsAmount))) - .append("#\n"); - - Laby.labyAPI().addonService().getLoadedAddons().forEach(addon -> { - log - .append(" # › " + addon.info().getDisplayName()) - .append(calculateSpaces(63 - 6, addon.info().getDisplayName())) - .append("#\n"); - }); - - // OPERATING SYSTEM - log - .append(" # #\n") - .append(" # Operating System (OS): ") - .append(System.getProperty("os.name")); - leftSpaces = (63 - 24) - (System.getProperty("os.name").length()); - for (int i = 0; i < leftSpaces; i++) { - log.append(" "); + public static void log(String event, DebugPriority priority, DebugActionExecuter executer, Class executedClass) { + DebugEntry entry = new DebugEntry(event, priority, executedClass).executer(executer); + StreamChatPlus.debugLog.add(entry); } - // JVM SYSTEM - log - .append("#\n") - .append(" # Java VM Version: ") - .append(System.getProperty("java.vm.version")); - leftSpaces = (63 - 18) - (System.getProperty("java.vm.version").length()); - for (int i = 0; i < leftSpaces; i++) { - log.append(" "); + public static void log(String event, DebugPriority priority, Class executedClass) { + DebugEntry entry = new DebugEntry(event, priority, executedClass); + StreamChatPlus.debugLog.add(entry); } - // MINECRAFT LANGUAGE - log - .append("#\n") - .append(" # Language: ") - .append(Laby.labyAPI().minecraft().options().getCurrentLanguage()); - leftSpaces = (63 - 11) - (Laby.labyAPI().minecraft().options().getCurrentLanguage().length()); - for (int i = 0; i < leftSpaces; i++) { - log.append(" "); + public static void log(String event, DebugActionExecuter executer, Class executedClass) { + DebugEntry entry = new DebugEntry(event, executedClass).executer(executer); + StreamChatPlus.debugLog.add(entry); } - log.append("#\n") - .append(" # #\n") - .append(" #################################################################"); - - log.append("\n\n\n"); - - log - .append( - " #################################################################################################################################################\n") - .append( - " # Addon Configuration | #\n") - .append( - " # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ #\n") - .append(" # ") - .append("enabled: ") - .append(configuration.enabled().get()) - .append(calculateSpaces(141 - 9, configuration.enabled().get().toString())) - .append("#\n") - .append(" # ") - .append("prefix: ") - .append(configuration.prefix().get()) - .append(calculateSpaces(141 - 8, configuration.prefix().get())) - .append("#\n") - .append(" # ") - .append("botName: ") - .append(configuration.botName().get()) - .append(calculateSpaces(141 - 9, configuration.botName().get())) - .append("#\n") - .append(" # ") - .append("twitchChannel: ") - .append(configuration.twitchchannel().get()) - .append(calculateSpaces(141 - 15, configuration.twitchchannel().get())) - .append("#\n") - .append(" # ") - .append("twitchToken: ") - .append(hidingInformation()) - .append(calculateSpaces(141 - 8, "Hidden due to security restrictions")) - .append("#\n") - .append(" # ") - .append("ingameChatEnabled: ") - .append(configuration.ingameChatEnabled().get()) - .append(calculateSpaces(141 - 19, configuration.ingameChatEnabled().get().toString())) - .append("#\n") - .append(" # ") - .append("ingameChatPrefix: ") - .append(configuration.ingameChatPrefix().get()) - .append(calculateSpaces(141 - 18, configuration.ingameChatPrefix().get())) - .append("#\n") - .append( - " # autoBroadcastSubSettings: #\n") // AutoBroadcast (subtract 4 from every SpaceCalculation due to indentation) - .append(" # ") - .append("enabled: ") - .append(configuration.autoBroadcastSubSettings().enabled().get()) - .append(calculateSpaces(141 - 4 - 9, - configuration.autoBroadcastSubSettings().enabled().get().toString())) - .append("#\n") - .append(" # ") - .append("interval1: ") - .append(configuration.autoBroadcastSubSettings().interval1().get()) - .append(calculateSpaces(141 - 4 - 11, - configuration.autoBroadcastSubSettings().interval1().get().toString())) - .append("#\n") - .append(" # ") - .append("message1: ") - .append(configuration.autoBroadcastSubSettings().message1().get()) - .append(calculateSpaces(141 - 4 - 10, - configuration.autoBroadcastSubSettings().message1().get().toString())) - .append("#\n") - .append(" # ") - .append("interval2: ") - .append(configuration.autoBroadcastSubSettings().interval2().get()) - .append(calculateSpaces(141 - 4 - 11, - configuration.autoBroadcastSubSettings().interval2().get().toString())) - .append("#\n") - .append(" # ") - .append("message2: ") - .append(configuration.autoBroadcastSubSettings().message2().get()) - .append(calculateSpaces(141 - 4 - 10, - configuration.autoBroadcastSubSettings().message2().get().toString())) - .append("#\n") - .append(" # ") - .append("interval3: ") - .append(configuration.autoBroadcastSubSettings().interval3().get()) - .append(calculateSpaces(141 - 4 - 11, - configuration.autoBroadcastSubSettings().interval3().get().toString())) - .append("#\n") - .append(" # ") - .append("message3: ") - .append(configuration.autoBroadcastSubSettings().message3().get()) - .append(calculateSpaces(141 - 4 - 10, - configuration.autoBroadcastSubSettings().message3().get().toString())) - .append("#\n") - .append(" # ") - .append("interval4: ") - .append(configuration.autoBroadcastSubSettings().interval4().get()) - .append(calculateSpaces(141 - 4 - 11, - configuration.autoBroadcastSubSettings().interval4().get().toString())) - .append("#\n") - .append(" # ") - .append("message4: ") - .append(configuration.autoBroadcastSubSettings().message4().get()) - .append(calculateSpaces(141 - 4 - 10, - configuration.autoBroadcastSubSettings().message4().get().toString())) - .append("#\n") - .append(" # ") - .append("interval5: ") - .append(configuration.autoBroadcastSubSettings().interval5().get()) - .append(calculateSpaces(141 - 4 - 11, - configuration.autoBroadcastSubSettings().interval5().get().toString())) - .append("#\n") - .append(" # ") - .append("message5: ") - .append(configuration.autoBroadcastSubSettings().message5().get()) - .append(calculateSpaces(141 - 4 - 10, - configuration.autoBroadcastSubSettings().message5().get().toString())) - .append("#\n") - .append(" # ") - .append("interval6: ") - .append(configuration.autoBroadcastSubSettings().interval6().get()) - .append(calculateSpaces(141 - 4 - 11, - configuration.autoBroadcastSubSettings().interval6().get().toString())) - .append("#\n") - .append(" # ") - .append("message6: ") - .append(configuration.autoBroadcastSubSettings().message6().get()) - .append(calculateSpaces(141 - 4 - 10, - configuration.autoBroadcastSubSettings().message6().get().toString())) - .append("#\n") - .append(" # ") - .append("interval7: ") - .append(configuration.autoBroadcastSubSettings().interval7().get()) - .append(calculateSpaces(141 - 4 - 11, - configuration.autoBroadcastSubSettings().interval7().get().toString())) - .append("#\n") - .append(" # ") - .append("message7: ") - .append(configuration.autoBroadcastSubSettings().message7().get()) - .append(calculateSpaces(141 - 4 - 10, - configuration.autoBroadcastSubSettings().message7().get().toString())) - .append("#\n") - .append(" # ") - .append("interval8: ") - .append(configuration.autoBroadcastSubSettings().interval8().get()) - .append(calculateSpaces(141 - 4 - 11, - configuration.autoBroadcastSubSettings().interval8().get().toString())) - .append("#\n") - .append(" # ") - .append("message8: ") - .append(configuration.autoBroadcastSubSettings().message8().get()) - .append(calculateSpaces(141 - 4 - 10, - configuration.autoBroadcastSubSettings().message8().get().toString())) - .append("#\n") - .append(" # ") - .append("interval9: ") - .append(configuration.autoBroadcastSubSettings().interval9().get()) - .append(calculateSpaces(141 - 4 - 11, - configuration.autoBroadcastSubSettings().interval9().get().toString())) - .append("#\n") - .append(" # ") - .append("message9: ") - .append(configuration.autoBroadcastSubSettings().message9().get()) - .append(calculateSpaces(141 - 4 - 10, - configuration.autoBroadcastSubSettings().message9().get().toString())) - .append("#\n") - .append(" # ") - .append("interval10: ") - .append(configuration.autoBroadcastSubSettings().interval10().get()) - .append(calculateSpaces(141 - 4 - 12, - configuration.autoBroadcastSubSettings().interval10().get().toString())) - .append("#\n") - .append(" # ") - .append("message10: ") - .append(configuration.autoBroadcastSubSettings().message10().get()) - .append(calculateSpaces(141 - 4 - 11, - configuration.autoBroadcastSubSettings().message10().get().toString())) - .append("#\n") // AutoBroadcast end - .append( - " # customCommandSubSettings: #\n") // CustomCommand (subtract 4 from every SpaceCalculation due to indentation) - .append(" # ") - .append("enabled: ") - .append(configuration.customCommandSubSettings().enabled().get()) - .append(calculateSpaces(141 - 4 - 9, - configuration.customCommandSubSettings().enabled().get().toString())) - .append("#\n") - .append(" # ") - .append("command1: ") - .append(configuration.customCommandSubSettings().command1().get()) - .append(calculateSpaces(141 - 4 - 10, - configuration.customCommandSubSettings().command1().get().toString())) - .append("#\n") - .append(" # ") - .append("response1: ") - .append(configuration.customCommandSubSettings().response1().get()) - .append(calculateSpaces(141 - 4 - 11, - configuration.customCommandSubSettings().response1().get().toString())) - .append("#\n") - .append(" # ") - .append("command2: ") - .append(configuration.customCommandSubSettings().command2().get()) - .append(calculateSpaces(141 - 4 - 10, - configuration.customCommandSubSettings().command2().get().toString())) - .append("#\n") - .append(" # ") - .append("response2: ") - .append(configuration.customCommandSubSettings().response2().get()) - .append(calculateSpaces(141 - 4 - 11, - configuration.customCommandSubSettings().response2().get().toString())) - .append("#\n") - .append(" # ") - .append("command3: ") - .append(configuration.customCommandSubSettings().command3().get()) - .append(calculateSpaces(141 - 4 - 10, - configuration.customCommandSubSettings().command3().get().toString())) - .append("#\n") - .append(" # ") - .append("response3: ") - .append(configuration.customCommandSubSettings().response3().get()) - .append(calculateSpaces(141 - 4 - 11, - configuration.customCommandSubSettings().response3().get().toString())) - .append("#\n") - .append(" # ") - .append("command4: ") - .append(configuration.customCommandSubSettings().command4().get()) - .append(calculateSpaces(141 - 4 - 10, - configuration.customCommandSubSettings().command4().get().toString())) - .append("#\n") - .append(" # ") - .append("response4: ") - .append(configuration.customCommandSubSettings().response4().get()) - .append(calculateSpaces(141 - 4 - 11, - configuration.customCommandSubSettings().response4().get().toString())) - .append("#\n") - .append(" # ") - .append("command5: ") - .append(configuration.customCommandSubSettings().command5().get()) - .append(calculateSpaces(141 - 4 - 10, - configuration.customCommandSubSettings().command5().get().toString())) - .append("#\n") - .append(" # ") - .append("response5: ") - .append(configuration.customCommandSubSettings().response5().get()) - .append(calculateSpaces(141 - 4 - 11, - configuration.customCommandSubSettings().response5().get().toString())) - .append("#\n") - .append(" # ") - .append("command6: ") - .append(configuration.customCommandSubSettings().command6().get()) - .append(calculateSpaces(141 - 4 - 10, - configuration.customCommandSubSettings().command6().get().toString())) - .append("#\n") - .append(" # ") - .append("response6: ") - .append(configuration.customCommandSubSettings().response6().get()) - .append(calculateSpaces(141 - 4 - 11, - configuration.customCommandSubSettings().response6().get().toString())) - .append("#\n") - .append(" # ") - .append("command7: ") - .append(configuration.customCommandSubSettings().command7().get()) - .append(calculateSpaces(141 - 4 - 10, - configuration.customCommandSubSettings().command7().get().toString())) - .append("#\n") - .append(" # ") - .append("response7: ") - .append(configuration.customCommandSubSettings().response7().get()) - .append(calculateSpaces(141 - 4 - 11, - configuration.customCommandSubSettings().response7().get().toString())) - .append("#\n") - .append(" # ") - .append("command8: ") - .append(configuration.customCommandSubSettings().command8().get()) - .append(calculateSpaces(141 - 4 - 10, - configuration.customCommandSubSettings().command8().get().toString())) - .append("#\n") - .append(" # ") - .append("response8: ") - .append(configuration.customCommandSubSettings().response8().get()) - .append(calculateSpaces(141 - 4 - 11, - configuration.customCommandSubSettings().response8().get().toString())) - .append("#\n") - .append(" # ") - .append("command9: ") - .append(configuration.customCommandSubSettings().command9().get()) - .append(calculateSpaces(141 - 4 - 10, - configuration.customCommandSubSettings().command9().get().toString())) - .append("#\n") - .append(" # ") - .append("response9: ") - .append(configuration.customCommandSubSettings().response9().get()) - .append(calculateSpaces(141 - 4 - 11, - configuration.customCommandSubSettings().response9().get().toString())) - .append("#\n") - .append(" # ") - .append("command10: ") - .append(configuration.customCommandSubSettings().command10().get()) - .append(calculateSpaces(141 - 4 - 11, - configuration.customCommandSubSettings().command10().get().toString())) - .append("#\n") - .append(" # ") - .append("response10: ") - .append(configuration.customCommandSubSettings().response10().get()) - .append(calculateSpaces(141 - 4 - 12, - configuration.customCommandSubSettings().response10().get().toString())) - .append("#\n") // CustomCommands end - .append( - " # #\n") - .append( - " #################################################################################################################################################\n") - - .append("\n\n") - .append(" // Debug Console //") - .append(loadDebugEntries()); - return log.toString(); - } - - public static void log(String event, DebugPriority priority, DebugActionExecuter executer) { - DebugEntry entry = new DebugEntry(event, priority).executer(executer); - StreamChatPlus.debugLog.add(entry); - } - - public static void log(String event, DebugPriority priority) { - DebugEntry entry = new DebugEntry(event, priority); - StreamChatPlus.debugLog.add(entry); - } - - public static void log(String event, DebugActionExecuter executer) { - DebugEntry entry = new DebugEntry(event).executer(executer); - StreamChatPlus.debugLog.add(entry); - } - - public static void log(String event) { - DebugEntry entry = new DebugEntry(event); - StreamChatPlus.debugLog.add(entry); - } - - public static void log(String event, DebugPriority priority, DebugActionExecuter executer, Class executedClass) { - DebugEntry entry = new DebugEntry(event, priority, executedClass).executer(executer); - StreamChatPlus.debugLog.add(entry); - } - - public static void log(String event, DebugPriority priority, Class executedClass) { - DebugEntry entry = new DebugEntry(event, priority, executedClass); - StreamChatPlus.debugLog.add(entry); - } - - public static void log(String event, DebugActionExecuter executer, Class executedClass) { - DebugEntry entry = new DebugEntry(event, executedClass).executer(executer); - StreamChatPlus.debugLog.add(entry); - } - - public static void log(String event, Class executedClass) { - DebugEntry entry = new DebugEntry(event, executedClass); - StreamChatPlus.debugLog.add(entry); - } - - private String calculateSpaces(int expectedAmount, String value) { - int leftSpaces = expectedAmount - value.length(); - StringBuilder returnBuild = new StringBuilder(); - for (int i = 0; i <= leftSpaces; i++) { - returnBuild.append(" "); + + public static void log(String event, Class executedClass) { + DebugEntry entry = new DebugEntry(event, executedClass); + StreamChatPlus.debugLog.add(entry); + } + + private String calculateSpaces(int expectedAmount, String value) { + int leftSpaces = expectedAmount - value.length(); + StringBuilder returnBuild = new StringBuilder(); + for (int i = 0; i <= leftSpaces; i++) { + returnBuild.append(" "); + } + return returnBuild.toString(); + } + + private String hidingInformation() { + //https://ts3index.com/?page=generator (Math Sans Italic) + return "\uD835\uDE0F\uD835\uDE2A\uD835\uDE25\uD835\uDE25\uD835\uDE26\uD835\uDE2F " + + "\uD835\uDE25\uD835\uDE36\uD835\uDE26 " + + "\uD835\uDE35\uD835\uDE30 " + + "\uD835\uDE34\uD835\uDE26\uD835\uDE24\uD835\uDE36\uD835\uDE33\uD835\uDE2A\uD835\uDE35\uD835\uDE3A " + + "\uD835\uDE33\uD835\uDE26\uD835\uDE34\uD835\uDE35\uD835\uDE33\uD835\uDE2A\uD835\uDE24\uD835\uDE35\uD835\uDE2A\uD835\uDE30\uD835\uDE2F\uD835\uDE34"; + } + + private String loadDebugEntries() { + StringBuilder returnBuilder = new StringBuilder(); + StreamChatPlus.debugLog.forEach(entry -> { + returnBuilder + .append("\n") + .append(" [") + .append(entry.getExecuter().name()) + .append("] ") + .append(" [") + .append(entry.getType().name()) + .append("] ") + .append("[") + .append(new SimpleDateFormat("HH:mm:ss:SS").format(new Date(entry.getTimestamp()))) + .append(" (") + .append(entry.getTimestamp()) + .append(")"); + if (entry.getExecutedClass() != null) { + returnBuilder + .append(" | ") + .append(entry.getExecutedClass().getSimpleName()); + } + returnBuilder + .append("] ") + .append(entry.getEvent()); + }); + return returnBuilder.toString(); } - return returnBuild.toString(); - } - - private String hidingInformation() { - //https://ts3index.com/?page=generator (Math Sans Italic) - return "\uD835\uDE0F\uD835\uDE2A\uD835\uDE25\uD835\uDE25\uD835\uDE26\uD835\uDE2F " - + "\uD835\uDE25\uD835\uDE36\uD835\uDE26 " - + "\uD835\uDE35\uD835\uDE30 " - + "\uD835\uDE34\uD835\uDE26\uD835\uDE24\uD835\uDE36\uD835\uDE33\uD835\uDE2A\uD835\uDE35\uD835\uDE3A " - + "\uD835\uDE33\uD835\uDE26\uD835\uDE34\uD835\uDE35\uD835\uDE33\uD835\uDE2A\uD835\uDE24\uD835\uDE35\uD835\uDE2A\uD835\uDE30\uD835\uDE2F\uD835\uDE34"; - } - - private String loadDebugEntries() { - StringBuilder returnBuilder = new StringBuilder(); - StreamChatPlus.debugLog.forEach(entry -> { - returnBuilder - .append("\n") - .append(" [") - .append(entry.getExecuter().name()) - .append("] ") - .append(" [") - .append(entry.getType().name()) - .append("] ") - .append("[") - .append(new SimpleDateFormat("HH:mm:ss:SS").format(new Date(entry.getTimestamp()))) - .append(" (") - .append(entry.getTimestamp()) - .append(")"); - if(entry.getExecutedClass() != null) { - returnBuilder - .append(" | ") - .append(entry.getExecutedClass().getSimpleName()); - } - returnBuilder - .append("] ") - .append(entry.getEvent()); - }); - return returnBuilder.toString(); - } } diff --git a/core/src/main/java/de/unordentlich/streamchatplus/core/utils/support/ErrorCode.java b/core/src/main/java/de/unordentlich/streamchatplus/core/utils/support/ErrorCode.java index a857bd3..f99d14d 100644 --- a/core/src/main/java/de/unordentlich/streamchatplus/core/utils/support/ErrorCode.java +++ b/core/src/main/java/de/unordentlich/streamchatplus/core/utils/support/ErrorCode.java @@ -1,15 +1,15 @@ package de.unordentlich.streamchatplus.core.utils.support; public enum ErrorCode { - SCP01("IOException"), - SCP02("IRCException"), - SCP03("TokenFormatException"), - SCP04("UsernameFormatException"), - SCP05("MissingRequiredConfigValuesException"); + SCP01("IOException"), + SCP02("IRCException"), + SCP03("TokenFormatException"), + SCP04("UsernameFormatException"), + SCP05("MissingRequiredConfigValuesException"); - public final String ExceptionName; + public final String ExceptionName; - private ErrorCode(String label) { - this.ExceptionName = label; - } + ErrorCode(String label) { + this.ExceptionName = label; + } } diff --git a/core/src/main/java/de/unordentlich/streamchatplus/core/utils/support/ErrorManager.java b/core/src/main/java/de/unordentlich/streamchatplus/core/utils/support/ErrorManager.java index 17af4fa..733c056 100644 --- a/core/src/main/java/de/unordentlich/streamchatplus/core/utils/support/ErrorManager.java +++ b/core/src/main/java/de/unordentlich/streamchatplus/core/utils/support/ErrorManager.java @@ -8,23 +8,23 @@ public class ErrorManager { - public static void sendErrorMessage() { - System.out.println("StreamChat+ | Addon couldn't connect to twitch profile!"); - LabyGuice.getInstance(StreamChatPlus.class).displayMessage(Component - .translatable("streamchatplus.messages.error.message")); - DebugTool.log("An error was thrown!", DebugPriority.ERROR); - } + public static void sendErrorMessage() { + System.out.println("StreamChat+ | Addon couldn't connect to twitch profile!"); + LabyGuice.getInstance(StreamChatPlus.class).displayMessage(Component + .translatable("streamchatplus.messages.error.message")); + DebugTool.log("An error was thrown!", DebugPriority.ERROR); + } - public static void sendErrorMessage(ErrorCode code) { - System.out.println("StreamChat+ | Addon couldn't connect to twitch profile! (#" + code + ")"); - DebugTool.log("An error with the code #" + code + " was thrown!", DebugPriority.ERROR); - Component message = Component - .translatable("streamchatplus.messages.error.message") - .hoverEvent(HoverEvent.showText(Component - .translatable("streamchatplus.messages.error.description") - .append(Component.text(" §c#" + code)) - .append(Component.text(" §7(" + code.ExceptionName + "§7)")))); - LabyGuice.getInstance(StreamChatPlus.class).displayMessage(message); - } + public static void sendErrorMessage(ErrorCode code) { + System.out.println("StreamChat+ | Addon couldn't connect to twitch profile! (#" + code + ")"); + DebugTool.log("An error with the code #" + code + " was thrown!", DebugPriority.ERROR); + Component message = Component + .translatable("streamchatplus.messages.error.message") + .hoverEvent(HoverEvent.showText(Component + .translatable("streamchatplus.messages.error.description") + .append(Component.text(" §c#" + code)) + .append(Component.text(" §7(" + code.ExceptionName + "§7)")))); + LabyGuice.getInstance(StreamChatPlus.class).displayMessage(message); + } } diff --git a/core/src/main/java/de/unordentlich/streamchatplus/core/utils/support/objects/DebugActionExecuter.java b/core/src/main/java/de/unordentlich/streamchatplus/core/utils/support/objects/DebugActionExecuter.java index afc72c7..617c261 100644 --- a/core/src/main/java/de/unordentlich/streamchatplus/core/utils/support/objects/DebugActionExecuter.java +++ b/core/src/main/java/de/unordentlich/streamchatplus/core/utils/support/objects/DebugActionExecuter.java @@ -1,8 +1,8 @@ package de.unordentlich.streamchatplus.core.utils.support.objects; public enum DebugActionExecuter { - MINECRAFT, - LABYMOD, - ADDON, - USER + MINECRAFT, + LABYMOD, + ADDON, + USER } diff --git a/core/src/main/java/de/unordentlich/streamchatplus/core/utils/support/objects/DebugEntry.java b/core/src/main/java/de/unordentlich/streamchatplus/core/utils/support/objects/DebugEntry.java index 9abbbe6..ab27109 100644 --- a/core/src/main/java/de/unordentlich/streamchatplus/core/utils/support/objects/DebugEntry.java +++ b/core/src/main/java/de/unordentlich/streamchatplus/core/utils/support/objects/DebugEntry.java @@ -2,71 +2,71 @@ public class DebugEntry { - String event; - long timestamp = System.currentTimeMillis(); - DebugPriority type = DebugPriority.INFO; - DebugActionExecuter executer = DebugActionExecuter.ADDON; - - Class executedClass; - - public DebugEntry(String event) { - this.event = event; - } - - public DebugEntry(String event, DebugPriority type) { - this.event = event; - this.type = type; - } - - public DebugEntry(String event, Class executedClass) { - this.event = event; - this.executedClass = executedClass; - } - - public DebugEntry(String event, DebugPriority type, Class executedClass) { - this.event = event; - this.type = type; - this.executedClass = executedClass; - } - - public DebugActionExecuter getExecuter() { - return executer; - } - - public DebugEntry executer(DebugActionExecuter executer) { - this.executer = executer; - return this; - } - - public String getEvent() { - return event; - } - - public void setEvent(String event) { - this.event = event; - } - - public long getTimestamp() { - return timestamp; - } - - public void setTimestamp(long timestamp) { - this.timestamp = timestamp; - } - - public DebugPriority getType() { - return type; - } - - public void setType(DebugPriority type) { - this.type = type; - } - - public Class getExecutedClass() { - return executedClass; - } - - public void setExecutedClass(Class executedClass) { - this.executedClass = executedClass; - } + String event; + long timestamp = System.currentTimeMillis(); + DebugPriority type = DebugPriority.INFO; + DebugActionExecuter executer = DebugActionExecuter.ADDON; + + Class executedClass; + + public DebugEntry(String event) { + this.event = event; + } + + public DebugEntry(String event, DebugPriority type) { + this.event = event; + this.type = type; + } + + public DebugEntry(String event, Class executedClass) { + this.event = event; + this.executedClass = executedClass; + } + + public DebugEntry(String event, DebugPriority type, Class executedClass) { + this.event = event; + this.type = type; + this.executedClass = executedClass; + } + + public DebugActionExecuter getExecuter() { + return executer; + } + + public DebugEntry executer(DebugActionExecuter executer) { + this.executer = executer; + return this; + } + + public String getEvent() { + return event; + } + + public void setEvent(String event) { + this.event = event; + } + + public long getTimestamp() { + return timestamp; + } + + public void setTimestamp(long timestamp) { + this.timestamp = timestamp; + } + + public DebugPriority getType() { + return type; + } + + public void setType(DebugPriority type) { + this.type = type; + } + + public Class getExecutedClass() { + return executedClass; + } + + public void setExecutedClass(Class executedClass) { + this.executedClass = executedClass; + } } diff --git a/core/src/main/java/de/unordentlich/streamchatplus/core/utils/support/objects/DebugPriority.java b/core/src/main/java/de/unordentlich/streamchatplus/core/utils/support/objects/DebugPriority.java index 77facfa..0120a06 100644 --- a/core/src/main/java/de/unordentlich/streamchatplus/core/utils/support/objects/DebugPriority.java +++ b/core/src/main/java/de/unordentlich/streamchatplus/core/utils/support/objects/DebugPriority.java @@ -1,8 +1,8 @@ package de.unordentlich.streamchatplus.core.utils.support.objects; public enum DebugPriority { - DEBUG, - INFO, - WARNING, - ERROR + DEBUG, + INFO, + WARNING, + ERROR }