Skip to content

Commit

Permalink
Release 1.5.2
Browse files Browse the repository at this point in the history
= Code reformation.
= Updated Documentation.
= Fixed Logback Configuration file.
  • Loading branch information
DxsSucuk committed Dec 31, 2021
1 parent 207a15b commit 33f0bc7
Show file tree
Hide file tree
Showing 61 changed files with 613 additions and 421 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>de.presti</groupId>
<artifactId>Ree6</artifactId>
<version>1.5.1</version>
<version>1.5.2</version>
<build>
<plugins>
<plugin>
Expand Down Expand Up @@ -211,7 +211,7 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.3.0-alpha12</version>
<version>1.2.8</version>
</dependency>
<!-- using a fork of this to fix some issues faster -->
<!-- dependency>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/presti/ree6/addons/AddonLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static void loadAllAddons() {
if (f.getName().endsWith("jar")) {
try {
// Try creating a Local-Addon and adding it into the loaded Addon List.
Main.addonManager.loadAddon(loadAddon(f.getName()));
Main.getInstance().getAddonManager().loadAddon(loadAddon(f.getName()));
} catch (Exception ex) {
// If the Methode loadAddon fails notify.
LoggerImpl.log("AddonManager", "Couldn't load the Addon " + f.getName() + "\nException: " + ex.getCause().getMessage());
Expand Down
24 changes: 12 additions & 12 deletions src/main/java/de/presti/ree6/addons/impl/ChatProtector.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,65 +13,65 @@ public class ChatProtector {

public static void addWordToProtector(String gid, String word) {

ArrayList<String> words = Main.sqlConnector.getSqlWorker().getChatProtectorWords(gid);
ArrayList<String> words = Main.getInstance().getSqlConnector().getSqlWorker().getChatProtectorWords(gid);

if (!words.isEmpty() && !words.contains(word)) {
Main.sqlConnector.getSqlWorker().addChatProtectorWord(gid, word);
Main.getInstance().getSqlConnector().getSqlWorker().addChatProtectorWord(gid, word);
} else if (words.isEmpty()) {
Main.sqlConnector.getSqlWorker().addChatProtectorWord(gid, word);
Main.getInstance().getSqlConnector().getSqlWorker().addChatProtectorWord(gid, word);
}
}

public static void addWordsToProtector(String gid, ArrayList<String> words2) {

ArrayList<String> words = Main.sqlConnector.getSqlWorker().getChatProtectorWords(gid);
ArrayList<String> words = Main.getInstance().getSqlConnector().getSqlWorker().getChatProtectorWords(gid);

if (!words.isEmpty()) {
for (String s : words2) {
if (!words.contains(s)) {
Main.sqlConnector.getSqlWorker().addChatProtectorWord(gid, s);
Main.getInstance().getSqlConnector().getSqlWorker().addChatProtectorWord(gid, s);
words.add(s);
}
}
} else {

for (String s : words2) {
if (!words.contains(s)) {
Main.sqlConnector.getSqlWorker().addChatProtectorWord(gid, s);
Main.getInstance().getSqlConnector().getSqlWorker().addChatProtectorWord(gid, s);
words.add(s);
}
}
}
}

public static void removeWordsFromProtector(String gid, ArrayList<String> words2) {
ArrayList<String> words = Main.sqlConnector.getSqlWorker().getChatProtectorWords(gid);
ArrayList<String> words = Main.getInstance().getSqlConnector().getSqlWorker().getChatProtectorWords(gid);

if (!words.isEmpty()) {
for (String s : words2) {
if (words.contains(s)) {
Main.sqlConnector.getSqlWorker().removeChatProtectorWord(gid, s);
Main.getInstance().getSqlConnector().getSqlWorker().removeChatProtectorWord(gid, s);
words.remove(s);
}
}
}
}

public static void removeWordFromProtector(String gid, String word) {
ArrayList<String> words = Main.sqlConnector.getSqlWorker().getChatProtectorWords(gid);
ArrayList<String> words = Main.getInstance().getSqlConnector().getSqlWorker().getChatProtectorWords(gid);
if(!words.isEmpty()) {
if(words.contains(word)) {
Main.sqlConnector.getSqlWorker().removeChatProtectorWord(gid, word);
Main.getInstance().getSqlConnector().getSqlWorker().removeChatProtectorWord(gid, word);
}
}
}

public static boolean hasChatProtector(String gid) {
return Main.sqlConnector.getSqlWorker().isChatProtectorSetup(gid);
return Main.getInstance().getSqlConnector().getSqlWorker().isChatProtectorSetup(gid);
}

public static ArrayList<String> getChatProtector(String gid) {
return Main.sqlConnector.getSqlWorker().getChatProtectorWords(gid);
return Main.getInstance().getSqlConnector().getSqlWorker().getChatProtectorWords(gid);
}

public static boolean checkMessage(String gid, String message) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/presti/ree6/api/JSONApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public static JSONObject getData(Requests type, String url, String post, String
j.put("_content", rawContent);
}
} catch (NullPointerException ex) {
Main.instance.getLogger().error("Error", ex.getCause());
Main.getInstance().getLogger().error("Error", ex.getCause());
} catch (MalformedURLException ex) {
j.put("_success", false);
j.put("_type", type.name());
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/de/presti/ree6/bot/Webhook.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static void sendWebhook(LoggerMessage loggerMessage, WebhookMessage messa
if (webhookToken.contains("Not setup!") || webhookId == 0) return;

// Check if the given data is in the Database.
if (!Main.sqlConnector.getSqlWorker().existsLogData(webhookId, webhookToken)) return;
if (!Main.getInstance().getSqlConnector().getSqlWorker().existsLogData(webhookId, webhookToken)) return;

// Check if the LoggerMessage is null or canceled.
if (loggerMessage == null || loggerMessage.isCanceled()) {
Expand All @@ -40,7 +40,7 @@ public static void sendWebhook(LoggerMessage loggerMessage, WebhookMessage messa
// If the error 404 comes that means that the webhook is invalid.
if (throwable.getMessage().contains("failure 404")) {
// Inform and delete invalid webhook.
Main.sqlConnector.getSqlWorker().deleteLogWebhook(webhookId, webhookToken);
Main.getInstance().getSqlConnector().getSqlWorker().deleteLogWebhook(webhookId, webhookToken);
LoggerImpl.log("Webhook", "Deleted invalid Webhook: " + webhookId + " - " + webhookToken);
} else if (throwable.getMessage().contains("failure 400")) {
// If 404 inform that the Message had an invalid Body.
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/de/presti/ree6/commands/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void sendMessage(String msg, MessageChannel m, InteractionHook hook) {
}

public void sendMessage(String msg, int deleteSecond, MessageChannel m, InteractionHook hook) {
Main.commandManager.sendMessage(msg, deleteSecond, m, hook);
Main.getInstance().getCommandManager().sendMessage(msg, deleteSecond, m, hook);
}


Expand All @@ -84,11 +84,11 @@ public void sendMessage(EmbedBuilder msg, MessageChannel m, InteractionHook hook
}

public void sendMessage(EmbedBuilder msg, int deleteSecond, MessageChannel m, InteractionHook hook) {
Main.commandManager.sendMessage(msg, deleteSecond, m, hook);
Main.getInstance().getCommandManager().sendMessage(msg, deleteSecond, m, hook);
}

public static void deleteMessage(Message message, InteractionHook hook) {
Main.commandManager.deleteMessage(message, hook);
Main.getInstance().getCommandManager().deleteMessage(message, hook);
}

public boolean isAlias(String arg) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/de/presti/ree6/commands/CommandManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void addCommand(Command c) {

public boolean perform(Member sender, String msg, Message messageSelf, TextChannel m, InteractionHook interactionHook) {

if (!msg.toLowerCase().startsWith(Main.sqlConnector.getSqlWorker().getSetting(sender.getGuild().getId(), "chatprefix").getStringValue()))
if (!msg.toLowerCase().startsWith(Main.getInstance().getSqlConnector().getSqlWorker().getSetting(sender.getGuild().getId(), "chatprefix").getStringValue()))
return false;

if (ArrayUtil.commandCooldown.contains(sender.getUser().getId())) {
Expand All @@ -134,7 +134,7 @@ public boolean perform(Member sender, String msg, Message messageSelf, TextChann
return false;
}

msg = msg.substring(Main.sqlConnector.getSqlWorker().getSetting(sender.getGuild().getId(), "chatprefix").getStringValue().length());
msg = msg.substring(Main.getInstance().getSqlConnector().getSqlWorker().getSetting(sender.getGuild().getId(), "chatprefix").getStringValue().length());

String[] oldArgs = msg.split(" ");

Expand All @@ -143,7 +143,7 @@ public boolean perform(Member sender, String msg, Message messageSelf, TextChann
for (Command cmd : getCommands()) {
if (cmd.getCmd().equalsIgnoreCase(oldArgs[0]) || cmd.isAlias(oldArgs[0])) {

if (!Main.sqlConnector.getSqlWorker().getSetting(m.getGuild().getId(), "command_" + cmd.getCmd().toLowerCase()).getBooleanValue() &&
if (!Main.getInstance().getSqlConnector().getSqlWorker().getSetting(m.getGuild().getId(), "command_" + cmd.getCmd().toLowerCase()).getBooleanValue() &&
cmd.getCategory() != Category.HIDDEN) {
sendMessage("This Command is blocked!", 5, m, interactionHook);
blocked = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public Rainbow() {
public void onPerform(Member sender, Message messageSelf, String[] args, TextChannel m, InteractionHook hook) {
deleteMessage(messageSelf, hook);

if(!Main.sqlConnector.getSqlWorker().isRainbowSetup(m.getGuild().getId())) {
sendMessage("Rainbow Mate searcher isn't setuped!\nAsk a Admin to set it up with "+ Main.sqlConnector.getSqlWorker().getSetting(sender.getGuild().getId(), "chatprefix").getStringValue() + "setup r6", 5, m, hook);
if(!Main.getInstance().getSqlConnector().getSqlWorker().isRainbowSetup(m.getGuild().getId())) {
sendMessage("Rainbow Mate searcher isn't setuped!\nAsk a Admin to set it up with "+ Main.getInstance().getSqlConnector().getSqlWorker().getSetting(sender.getGuild().getId(), "chatprefix").getStringValue() + "setup r6", 5, m, hook);
return;
}

Expand All @@ -46,8 +46,8 @@ public void onPerform(Member sender, Message messageSelf, String[] args, TextCha
wm.addEmbeds(em.build());

for(Guild g : BotInfo.botInstance.getGuilds()) {
if(Main.sqlConnector.getSqlWorker().isRainbowSetup(g.getId())) {
String[] info = Main.sqlConnector.getSqlWorker().getRainbowWebhook(g.getId());
if(Main.getInstance().getSqlConnector().getSqlWorker().isRainbowSetup(g.getId())) {
String[] info = Main.getInstance().getSqlConnector().getSqlWorker().getRainbowWebhook(g.getId());
Webhook.sendWebhook(null, wm.build(), Long.parseLong(info[0]), info[1]);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void onPerform(Member sender, Message messageSelf, String[] args, TextCha
if(args[0].equalsIgnoreCase("list")) {
StringBuilder end = new StringBuilder("```\n");

for(String users : Main.sqlConnector.getSqlWorker().getAllTwitchNames(m.getGuild().getId())) {
for(String users : Main.getInstance().getSqlConnector().getSqlWorker().getAllTwitchNames(m.getGuild().getId())) {
end.append(users).append("\n");
}

Expand All @@ -30,42 +30,42 @@ public void onPerform(Member sender, Message messageSelf, String[] args, TextCha
sendMessage(end.toString(), 10, m, hook);

} else {
sendMessage("Please use " + Main.sqlConnector.getSqlWorker().getSetting(sender.getGuild().getId(), "chatprefix").getStringValue() + "twitch list/add/remove", 5, m, hook);
sendMessage("Please use " + Main.getInstance().getSqlConnector().getSqlWorker().getSetting(sender.getGuild().getId(), "chatprefix").getStringValue() + "twitch list/add/remove", 5, m, hook);
}
} else if(args.length == 3) {

if (messageSelf.getMentionedChannels().size() == 0) {
sendMessage("Please use " + Main.sqlConnector.getSqlWorker().getSetting(sender.getGuild().getId(), "chatprefix").getStringValue() + "twitch add/remove TwitchName #Channel", 5, m, hook);
sendMessage("Please use " + Main.getInstance().getSqlConnector().getSqlWorker().getSetting(sender.getGuild().getId(), "chatprefix").getStringValue() + "twitch add/remove TwitchName #Channel", 5, m, hook);
return;
}

String name = args[1];
if (args[0].equalsIgnoreCase("add")) {
messageSelf.getMentionedChannels().get(0).createWebhook("Ree6-TwitchNotifier-" + name).queue(w -> Main.sqlConnector.getSqlWorker().addTwitchWebhook(sender.getGuild().getId(), name.toLowerCase(), w.getId(), w.getToken()));
messageSelf.getMentionedChannels().get(0).createWebhook("Ree6-TwitchNotifier-" + name).queue(w -> Main.getInstance().getSqlConnector().getSqlWorker().addTwitchWebhook(sender.getGuild().getId(), name.toLowerCase(), w.getId(), w.getToken()));
sendMessage("A TwitchStream Notifier has been created for the User " + name + "!", 5, m, hook);

if (!Main.twitchAPIHandler.isRegisterd(name)) {
Main.twitchAPIHandler.registerChannel(name);
if (!Main.getInstance().getNotifier().isTwitchRegistered(name)) {
Main.getInstance().getNotifier().registerTwitchChannel(name);
}
} else {
sendMessage("Please use " + Main.sqlConnector.getSqlWorker().getSetting(sender.getGuild().getId(), "chatprefix").getStringValue() + "twitch add TwitchName #Channel", 5, m, hook);
sendMessage("Please use " + Main.getInstance().getSqlConnector().getSqlWorker().getSetting(sender.getGuild().getId(), "chatprefix").getStringValue() + "twitch add TwitchName #Channel", 5, m, hook);
}
} else if(args.length == 2) {
String name = args[1];
if(args[0].equalsIgnoreCase("remove")) {
Main.sqlConnector.getSqlWorker().removeTwitchWebhook(sender.getGuild().getId(), name);
Main.getInstance().getSqlConnector().getSqlWorker().removeTwitchWebhook(sender.getGuild().getId(), name);
sendMessage("A TwitchStream Notifier has been removed from the User " + name + "!", 5, m, hook);

if(Main.twitchAPIHandler.isRegisterd(name)) {
if(Main.sqlConnector.getSqlWorker().getTwitchWebhooksByName(name.toLowerCase()).isEmpty()) {
Main.twitchAPIHandler.unregisterChannel(name);
if(Main.getInstance().getNotifier().isTwitchRegistered(name)) {
if(Main.getInstance().getSqlConnector().getSqlWorker().getTwitchWebhooksByName(name.toLowerCase()).isEmpty()) {
Main.getInstance().getNotifier().unregisterTwitchChannel(name);
}
}
} else {
sendMessage("Please use " + Main.sqlConnector.getSqlWorker().getSetting(sender.getGuild().getId(), "chatprefix").getStringValue() + "twitch remove TwitchName", 5, m, hook);
sendMessage("Please use " + Main.getInstance().getSqlConnector().getSqlWorker().getSetting(sender.getGuild().getId(), "chatprefix").getStringValue() + "twitch remove TwitchName", 5, m, hook);
}
} else {
sendMessage("Please use " + Main.sqlConnector.getSqlWorker().getSetting(sender.getGuild().getId(), "chatprefix").getStringValue() + "twitch list/add/remove", 5, m, hook);
sendMessage("Please use " + Main.getInstance().getSqlConnector().getSqlWorker().getSetting(sender.getGuild().getId(), "chatprefix").getStringValue() + "twitch list/add/remove", 5, m, hook);
}
deleteMessage(messageSelf, hook);
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/de/presti/ree6/commands/impl/fun/HornyJail.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void onPerform(Member sender, Message messageSelf, String[] args, TextCha

HttpClient httpClient = HttpClientBuilder.create().build();
HttpGet request = new HttpGet("https://api.dagpi.xyz/image/jail/?url=" + messageSelf.getMentionedMembers().get(0).getUser().getAvatarUrl());
request.setHeader("Authorization", Main.config.getConfig().getString("dagpi.apitoken"));
request.setHeader("Authorization", Main.getInstance().getConfig().getConfig().getString("dagpi.apitoken"));
HttpResponse response = httpClient.execute(request);

try (OutputStream outputStream =
Expand All @@ -54,11 +54,11 @@ public void onPerform(Member sender, Message messageSelf, String[] args, TextCha
m.sendFile(new File("imageapi/hornyjail/" + sender.getUser().getId() + ".png")).queue(message -> new File("imageapi/hornyjail/" + sender.getUser().getId() + ".png").delete());

} catch (Exception ex) {
sendMessage("Error while putting someone in the Hornyjail!\nError: " + ex.getMessage().replaceAll(Main.config.getConfig().getString("dagpi.apitoken"), "Ree6TopSecretAPIToken"), m, hook);
sendMessage("Error while putting someone in the Hornyjail!\nError: " + ex.getMessage().replaceAll(Main.getInstance().getConfig().getConfig().getString("dagpi.apitoken"), "Ree6TopSecretAPIToken"), m, hook);
}
}
} else {
sendMessage("Use " + Main.sqlConnector.getSqlWorker().getSetting(sender.getGuild().getId(), "chatprefix").getStringValue() + "hornyjail @User", 5, m, hook);
sendMessage("Use " + Main.getInstance().getSqlConnector().getSqlWorker().getSetting(sender.getGuild().getId(), "chatprefix").getStringValue() + "hornyjail @User", 5, m, hook);
}
}
}
4 changes: 2 additions & 2 deletions src/main/java/de/presti/ree6/commands/impl/fun/Hug.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void onPerform(Member sender, Message messageSelf, String[] args, TextCha
if (args.length == 1) {
if(messageSelf.getMentionedMembers().isEmpty()) {
sendMessage("No User mentioned!", 5, m, hook);
sendMessage("Use " + Main.sqlConnector.getSqlWorker().getSetting(sender.getGuild().getId(), "chatprefix").getStringValue() + "hug @user", 5, m, hook);
sendMessage("Use " + Main.getInstance().getSqlConnector().getSqlWorker().getSetting(sender.getGuild().getId(), "chatprefix").getStringValue() + "hug @user", 5, m, hook);
} else {

User target = messageSelf.getMentionedMembers().get(0).getUser();
Expand All @@ -45,7 +45,7 @@ public void onPerform(Member sender, Message messageSelf, String[] args, TextCha
}
} else {
sendMessage("Not enough Arguments!", 5, m, hook);
sendMessage("Use " + Main.sqlConnector.getSqlWorker().getSetting(sender.getGuild().getId(), "chatprefix").getStringValue() + "hug @user", 5, m, hook);
sendMessage("Use " + Main.getInstance().getSqlConnector().getSqlWorker().getSetting(sender.getGuild().getId(), "chatprefix").getStringValue() + "hug @user", 5, m, hook);
}
}

Expand Down
Loading

0 comments on commit 33f0bc7

Please sign in to comment.