Renamed config methods to match the keys

This commit is contained in:
Norbi Peti 2019-08-07 18:28:47 +02:00
parent 4956837e5d
commit 7b2ecdbf7b
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
5 changed files with 18 additions and 18 deletions

View file

@ -26,7 +26,7 @@
<orderEntry type="library" name="Maven: com.google.code.findbugs:annotations:2.0.1" level="project" />
<orderEntry type="library" name="Maven: net.ess3:Essentials:2.13.1" level="project" />
<orderEntry type="library" name="Maven: com.github.TBMCPlugins.ButtonCore:Towny:8d3b6b6" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.milkbowl:VaultAPI:master-68f14eca20-1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.milkbowl:VaultAPI:master-af0353b1d7-1" level="project" />
<orderEntry type="library" name="Maven: org.bukkit:bukkit:1.13.1-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.projectlombok:lombok:1.16.16" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot:1.12.2-R0.1-SNAPSHOT" level="project" />

View file

@ -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;
}

View file

@ -11,11 +11,11 @@ import org.bukkit.Bukkit;
import java.util.ArrayList;
public class AnnouncerComponent extends Component<PluginMain> implements Runnable {
public ConfigData<ArrayList<String>> AnnounceMessages() {
public ConfigData<ArrayList<String>> announceMessages() {
return getConfig().getData("announceMessages", new ArrayList<>(0));
}
public ConfigData<Integer> AnnounceTime() {
public ConfigData<Integer> announceTime() {
return getConfig().getData("announceTime", 15 * 60 * 1000);
}
@ -27,15 +27,15 @@ public class AnnouncerComponent extends Component<PluginMain> 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;
}
}

View file

@ -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)) {

View file

@ -23,7 +23,7 @@ import java.text.SimpleDateFormat;
import java.util.*;
public class FlairComponent extends Component<PluginMain> {
ConfigData<String> FlairThreadURL() {
ConfigData<String> 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<PluginMain> {
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) {