Skip to content

Commit

Permalink
Reformatting & Beautify
Browse files Browse the repository at this point in the history
  • Loading branch information
unordentlich committed Aug 20, 2022
1 parent ba98f04 commit 2f7d81b
Show file tree
Hide file tree
Showing 20 changed files with 1,446 additions and 1,443 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<Boolean> enabled = new ConfigProperty<>(true);

@TextFieldSetting
private final ConfigProperty<String> 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<Boolean> enabled = new ConfigProperty<>(true);

@TextFieldSetting
private final ConfigProperty<String> 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<String> botName = new ConfigProperty<>("StreamChatPlus");
@SettingSection("twitch")
@TextFieldSetting
private final ConfigProperty<String> botName = new ConfigProperty<>("StreamChatPlus");

@TextFieldSetting
private final ConfigProperty<String> twitchChannel = new ConfigProperty<>("");
@TextFieldSetting
private final ConfigProperty<String> twitchChannel = new ConfigProperty<>("");

@TextFieldSetting
private final ConfigProperty<String> twitchToken = new ConfigProperty<>("");
@TextFieldSetting
private final ConfigProperty<String> twitchToken = new ConfigProperty<>("");

@SettingSection("ingame")
@SwitchSetting
private final ConfigProperty<Boolean> ingameChatEnabled = new ConfigProperty<>(false);
@SettingSection("ingame")
@SwitchSetting
private final ConfigProperty<Boolean> ingameChatEnabled = new ConfigProperty<>(false);

@TextFieldSetting
private final ConfigProperty<String> ingameChatPrefix = new ConfigProperty<>("#");
@TextFieldSetting
private final ConfigProperty<String> 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<Boolean> enabled() {
return this.enabled;
}
@Override
public ConfigProperty<Boolean> enabled() {
return this.enabled;
}

public ConfigProperty<String> botName() {
return this.botName;
}
public ConfigProperty<String> botName() {
return this.botName;
}

public ConfigProperty<String> prefix() {
return this.prefix;
}
public ConfigProperty<String> prefix() {
return this.prefix;
}

public ConfigProperty<String> twitchchannel() {
return this.twitchChannel;
}
public ConfigProperty<String> twitchchannel() {
return this.twitchChannel;
}

public ConfigProperty<String> twitchtoken() {
return this.twitchToken;
}
public ConfigProperty<String> twitchtoken() {
return this.twitchToken;
}

public ConfigProperty<Boolean> ingameChatEnabled() {
return this.ingameChatEnabled;
}
public ConfigProperty<Boolean> ingameChatEnabled() {
return this.ingameChatEnabled;
}

public ConfigProperty<String> ingameChatPrefix() {
return this.ingameChatPrefix;
}
public ConfigProperty<String> ingameChatPrefix() {
return this.ingameChatPrefix;
}

public AutoBroadcastSubSettings autoBroadcastSubSettings() {
return autoBroadcastSubSettings;
}
public AutoBroadcastSubSettings autoBroadcastSubSettings() {
return autoBroadcastSubSettings;
}

public CustomCommandSubSettings customCommandSubSettings() {
return customCommandSubSettings;
}
public CustomCommandSubSettings customCommandSubSettings() {
return customCommandSubSettings;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,36 +18,36 @@
@Singleton
@AddonListener
public class StreamChatPlus extends LabyAddon<Configuration> {
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<DebugEntry> debugLog = new ArrayList<>();
public static ArrayList<DebugEntry> 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<Configuration> configurationClass() {
return Configuration.class;
}
@Override
protected Class<Configuration> configurationClass() {
return Configuration.class;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}**/
}

}
Loading

0 comments on commit 2f7d81b

Please sign in to comment.