From 7b2ecdbf7b8b84fdf4950ad5ebe2397f041ebae1 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Wed, 7 Aug 2019 18:28:47 +0200 Subject: [PATCH] Renamed config methods to match the keys --- .idea/ButtonChat.iml | 2 +- .../components/announce/AnnounceCommand.java | 16 ++++++++-------- .../components/announce/AnnouncerComponent.java | 12 ++++++------ .../chat/components/flair/AcceptCommand.java | 2 +- .../chat/components/flair/FlairComponent.java | 4 ++-- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.idea/ButtonChat.iml b/.idea/ButtonChat.iml index 3d32cdf..9f0759b 100644 --- a/.idea/ButtonChat.iml +++ b/.idea/ButtonChat.iml @@ -26,7 +26,7 @@ - + diff --git a/src/main/java/buttondevteam/chat/components/announce/AnnounceCommand.java b/src/main/java/buttondevteam/chat/components/announce/AnnounceCommand.java index 050687d..d6864d1 100644 --- a/src/main/java/buttondevteam/chat/components/announce/AnnounceCommand.java +++ b/src/main/java/buttondevteam/chat/components/announce/AnnounceCommand.java @@ -20,7 +20,7 @@ public class AnnounceCommand extends UCommandBase { }) public boolean add(CommandSender sender, @Command2.TextArg String text) { String finalmessage = text.replace('&', '§'); - component.AnnounceMessages().get().add(finalmessage); + component.announceMessages().get().add(finalmessage); sender.sendMessage("§bAnnouncement added.§r"); return true; } @@ -34,9 +34,9 @@ public class AnnounceCommand extends UCommandBase { String finalmessage1 = text.replace('&', '§'); if (index > 100) return false; - while (component.AnnounceMessages().get().size() <= index) - component.AnnounceMessages().get().add(""); - component.AnnounceMessages().get().set(index, finalmessage1); + while (component.announceMessages().get().size() <= index) + component.announceMessages().get().add(""); + component.announceMessages().get().set(index, finalmessage1); sender.sendMessage("Announcement edited."); return true; } @@ -49,10 +49,10 @@ public class AnnounceCommand extends UCommandBase { sender.sendMessage("§bList of announce messages:§r"); sender.sendMessage("§bFormat: [index] message§r"); int i = 0; - for (String message : component.AnnounceMessages().get()) + for (String message : component.announceMessages().get()) sender.sendMessage("[" + i++ + "] " + message); sender.sendMessage("§bCurrent wait time between announcements: " - + component.AnnounceTime().get() / 60 / 1000 + " minute(s)§r"); + + component.announceTime().get() / 60 / 1000 + " minute(s)§r"); return true; } @@ -61,7 +61,7 @@ public class AnnounceCommand extends UCommandBase { "This command removes an announcement" }) public boolean remove(CommandSender sender, int index) { - val msgs = component.AnnounceMessages().get(); + val msgs = component.announceMessages().get(); if (index < 0 || index > msgs.size()) return false; msgs.remove(index); sender.sendMessage("Announcement removed."); @@ -73,7 +73,7 @@ public class AnnounceCommand extends UCommandBase { "This command sets the time between the announcements" }) public boolean settime(CommandSender sender, int minutes) { - component.AnnounceTime().set(minutes * 60 * 1000); + component.announceTime().set(minutes * 60 * 1000); sender.sendMessage("Time set between announce messages to " + minutes + " minutes"); return true; } diff --git a/src/main/java/buttondevteam/chat/components/announce/AnnouncerComponent.java b/src/main/java/buttondevteam/chat/components/announce/AnnouncerComponent.java index cecc285..1d41d62 100644 --- a/src/main/java/buttondevteam/chat/components/announce/AnnouncerComponent.java +++ b/src/main/java/buttondevteam/chat/components/announce/AnnouncerComponent.java @@ -11,11 +11,11 @@ import org.bukkit.Bukkit; import java.util.ArrayList; public class AnnouncerComponent extends Component implements Runnable { - public ConfigData> AnnounceMessages() { + public ConfigData> announceMessages() { return getConfig().getData("announceMessages", new ArrayList<>(0)); } - public ConfigData AnnounceTime() { + public ConfigData announceTime() { return getConfig().getData("announceTime", 15 * 60 * 1000); } @@ -27,15 +27,15 @@ public class AnnouncerComponent extends Component implements Runnabl public void run() { while (isEnabled()) { try { - Thread.sleep(AnnounceTime().get()); + Thread.sleep(announceTime().get()); } catch (InterruptedException ex) { Thread.currentThread().interrupt(); } if (Bukkit.getOnlinePlayers().size() == 0) continue; //Don't post to Discord if nobody is on - if (AnnounceMessages().get().size() > AnnounceMessageIndex) { - TBMCChatAPI.SendSystemMessage(Channel.GlobalChat, Channel.RecipientTestResult.ALL, AnnounceMessages().get().get(AnnounceMessageIndex), target); + if (announceMessages().get().size() > AnnounceMessageIndex) { + TBMCChatAPI.SendSystemMessage(Channel.GlobalChat, Channel.RecipientTestResult.ALL, announceMessages().get().get(AnnounceMessageIndex), target); AnnounceMessageIndex++; - if (AnnounceMessageIndex == AnnounceMessages().get().size()) + if (AnnounceMessageIndex == announceMessages().get().size()) AnnounceMessageIndex = 0; } } diff --git a/src/main/java/buttondevteam/chat/components/flair/AcceptCommand.java b/src/main/java/buttondevteam/chat/components/flair/AcceptCommand.java index 8ebd6ed..1c47167 100644 --- a/src/main/java/buttondevteam/chat/components/flair/AcceptCommand.java +++ b/src/main/java/buttondevteam/chat/components/flair/AcceptCommand.java @@ -39,7 +39,7 @@ public class AcceptCommand extends UCommandBase { } if (p.FlairState().get().equals(FlairStates.NoComment) || p.UserNames().size() == 0) { player.sendMessage("§cError: You need to write your username to the reddit thread§r"); - player.sendMessage(component.FlairThreadURL().get()); + player.sendMessage(component.flairThreadURL().get()); return true; } if (username != null && !p.UserNames().contains(username)) { diff --git a/src/main/java/buttondevteam/chat/components/flair/FlairComponent.java b/src/main/java/buttondevteam/chat/components/flair/FlairComponent.java index a5f4878..7c8440a 100644 --- a/src/main/java/buttondevteam/chat/components/flair/FlairComponent.java +++ b/src/main/java/buttondevteam/chat/components/flair/FlairComponent.java @@ -23,7 +23,7 @@ import java.text.SimpleDateFormat; import java.util.*; public class FlairComponent extends Component { - ConfigData FlairThreadURL() { + ConfigData flairThreadURL() { return getConfig().getData("flairThreadURL", "https://www.reddit.com/r/Chromagamers/comments/51ys94/flair_thread_for_the_mc_server/"); } @@ -54,7 +54,7 @@ public class FlairComponent extends Component { int errorcount = 0; while (isEnabled()) { try { - String body = TBMCCoreAPI.DownloadString(FlairThreadURL().get() + ".json?limit=1000"); + String body = TBMCCoreAPI.DownloadString(flairThreadURL().get() + ".json?limit=1000"); JsonArray json = new JsonParser().parse(body).getAsJsonArray().get(1).getAsJsonObject().get("data") .getAsJsonObject().get("children").getAsJsonArray(); for (Object obj : json) {