Convert all configs

This commit is contained in:
Norbi Peti 2020-10-26 19:56:22 +01:00
parent 77b5a069c5
commit 8e9989caee
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
21 changed files with 68 additions and 165 deletions

View file

@ -1,71 +0,0 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
name: "CodeQL"
on:
push:
branches: [master]
pull_request:
# The branches below must be a subset of the branches above
branches: [master]
schedule:
- cron: '0 10 * * 1'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Override automatic language detection by changing the below list
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
language: ['java']
# Learn more...
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2
# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1

View file

@ -56,7 +56,7 @@ public final class ChatUtils {
}
public static String getMessageString(Channel channel, CommandSender sender, String message) {
return "§c!§r[" + channel.DisplayName().get() + "] <"
return "§c!§r[" + channel.DisplayName.get() + "] <"
+ ChromaUtils.getDisplayName(sender) + "> " + message;
}

View file

@ -40,9 +40,7 @@ public class PluginMain extends ButtonPlugin { // Translated to Java: 2015.07.15
* If enabled, stores and displays the last 10 messages the player can see (public, their town chat etc.)
* Can be used with the Discord plugin so players can see some of the conversation they missed that's visible on Discord anyways.
*/
public ConfigData<Boolean> storeChatHistory() {
return getIConfig().getData("storeChatHistory", true);
}
public ConfigData<Boolean> storeChatHistory = getIConfig().getData("storeChatHistory", true);
// Fired when plugin is first enabled
@Override

View file

@ -31,7 +31,7 @@ public class HistoryCommand extends UCommandBase {
}
public static boolean showHistory(CommandSender sender, String channel) {
if (!PluginMain.Instance.storeChatHistory().get()) {
if (!PluginMain.Instance.storeChatHistory.get()) {
sender.sendMessage("§6Chat history is disabled");
return true;
}
@ -55,7 +55,7 @@ public class HistoryCommand extends UCommandBase {
for (int i = Math.max(0, arr.length - 10); i < arr.length; i++) {
HistoryEntry e = arr[i];
val cm = e.chatMessage;
sender.sendMessage("[" + e.channel.DisplayName().get() + "] " + cm.getSender().getName() + ": " + cm.getMessage());
sender.sendMessage("[" + e.channel.DisplayName.get() + "] " + cm.getSender().getName() + ": " + cm.getMessage());
sent.set(true);
}
}
@ -80,7 +80,7 @@ public class HistoryCommand extends UCommandBase {
}
public static void addChatMessage(ChatMessage chatMessage, Channel channel) {
if (!PluginMain.Instance.storeChatHistory().get()) return;
if (!PluginMain.Instance.storeChatHistory.get()) return;
val groupID = channel.getGroupID(chatMessage.getPermCheck());
if (groupID == null) return; //Just to be sure
synchronized (messages) {

View file

@ -24,7 +24,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;
}
@ -38,9 +38,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;
}
@ -53,7 +53,7 @@ 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()) {
String msg = "[" + i++ + "] " + message;
//noinspection SuspiciousMethodCalls
if (!ComponentManager.isEnabled(FormatterComponent.class) || !Bukkit.getOnlinePlayers().contains(sender)) {
@ -67,7 +67,7 @@ public class AnnounceCommand extends UCommandBase {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + sender.getName() + " " + json);
}
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;
}
@ -76,7 +76,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.");
@ -88,7 +88,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

@ -16,16 +16,12 @@ public class AnnouncerComponent extends Component<PluginMain> implements Runnabl
/**
* The messages to display to players.
*/
public ListConfigData<String> announceMessages() {
return getConfig().getListData("announceMessages");
}
public ListConfigData<String> announceMessages = getConfig().getListData("announceMessages");
/**
* The time in milliseconds between the messages. Use /u announce settime to set minutes.
*/
public ConfigData<Integer> announceTime() {
return getConfig().getData("announceTime", 15 * 60 * 1000);
}
public ConfigData<Integer> announceTime = getConfig().getData("announceTime", 15 * 60 * 1000);
private TBMCSystemChatEvent.BroadcastTarget target;
@ -35,15 +31,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

@ -35,7 +35,7 @@ public class AcceptCommand extends UCommandBase {
}
if (p.FlairState.get().equals(FlairStates.NoComment) || p.UserNames.get().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.get().contains(username)) {

View file

@ -27,9 +27,7 @@ public class FlairComponent extends Component<PluginMain> {
/**
* The Reddit thread to check for account connections. Re-enable the component if this was empty.
*/
ConfigData<String> flairThreadURL() {
return getConfig().getData("flairThreadURL", "");
}
ConfigData<String> flairThreadURL = getConfig().getData("flairThreadURL", "");
/**
* <p>
@ -39,7 +37,7 @@ public class FlairComponent extends Component<PluginMain> {
* It's used because normally it has to load all associated player files every time to read the flair state
* </p>
*/
private Set<String> PlayersWithFlairs = new HashSet<>();
private final Set<String> PlayersWithFlairs = new HashSet<>();
@Override
protected void enable() {
@ -56,9 +54,9 @@ public class FlairComponent extends Component<PluginMain> {
private void FlairGetterThreadMethod() {
int errorcount = 0;
while (isEnabled() && flairThreadURL().get().length() > 0) {
while (isEnabled() && flairThreadURL.get().length() > 0) {
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) {
@ -147,7 +145,7 @@ public class FlairComponent extends Component<PluginMain> {
} catch (Exception e) {
p.FlairState.set(FlairStates.Commented); // Flair unknown
p.SetFlair(ChatPlayer.FlairTimeNone);
TBMCCoreAPI.SendException("Error while checking join date for player " + p.PlayerName() + "!", e, this);
TBMCCoreAPI.SendException("Error while checking join date for player " + p.PlayerName + "!", e, this);
}
return;
default:

View file

@ -50,7 +50,7 @@ public class SetFlairCommand extends AdminCommandBase {
mp.UserNames.get().add(username);
}
sender.sendMessage(
"§bThe flair has been set. Player: " + mp.PlayerName() + " Flair: " + mp.GetFormattedFlair() + "§r");
"§bThe flair has been set. Player: " + mp.PlayerName + " Flair: " + mp.GetFormattedFlair() + "§r");
return true;
}

View file

@ -122,7 +122,7 @@ public class ChatProcessing {
mp = e.getUser().getAs(ChatPlayer.class); //May be null
if (mp != null) {
if (System.nanoTime() - mp.LastMessageTime < 1000 * 1000 * component.minTimeBetweenMessages().get()) { //0.1s by default
if (System.nanoTime() - mp.LastMessageTime < 1000 * 1000 * component.minTimeBetweenMessages.get()) { //0.1s by default
sender.sendMessage("§cYou are sending messages too quickly!");
return true;
}
@ -144,14 +144,14 @@ public class ChatProcessing {
if (Bukkit.getOnlinePlayers().size() == 0) return false; //Don't try to send to nobody (errors on 1.14)
Color colormode = channel.Color().get();
Color colormode = channel.Color.get();
if (mp != null && mp.OtherColorMode != null)
colormode = mp.OtherColorMode;
ArrayList<MatchProviderBase> formatters;
if (component.allowFormatting().get()) {
if (component.allowFormatting.get()) {
formatters = addFormatters(e::shouldSendTo, component);
if (colormode == channel.Color().get() && mp != null && mp.RainbowPresserColorMode) { // Only overwrite channel color
if (colormode == channel.Color.get() && mp != null && mp.RainbowPresserColorMode) { // Only overwrite channel color
createRPC(colormode, formatters);
}
pingedconsole = false; // Will set it to true onmatch (static constructor)
@ -256,7 +256,7 @@ public class ChatProcessing {
}
static String getChannelID(Channel channel, String origin) {
return ("[" + (ChatUtils.MCORIGIN.equals(origin) ? "" : "§8" + origin.substring(0, 1) + "§r|") + channel.DisplayName().get())
return ("[" + (ChatUtils.MCORIGIN.equals(origin) ? "" : "§8" + origin.charAt(0) + "§r|") + channel.DisplayName.get())
+ "]";
}
@ -323,11 +323,11 @@ public class ChatProcessing {
}
private static void playPingSound(Player p, @Nullable FormatterComponent component) {
if (component == null || component.notificationSound().get().length() == 0)
if (component == null || component.notificationSound.get().length() == 0)
p.playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1.0f, 0.5f); // TODO: Airhorn
else
p.playSound(p.getLocation(), component.notificationSound().get(), 1.0f,
component.notificationPitch().get());
p.playSound(p.getLocation(), component.notificationSound.get(), 1.0f,
component.notificationPitch.get());
}
static void doFunStuff(CommandSender sender, TBMCChatEventBase event, String message) {

View file

@ -16,30 +16,22 @@ public class FormatterComponent extends Component<PluginMain> {
/**
* Determines whether Markdown formatting, name mentioning and similar features are enabled.
*/
ConfigData<Boolean> allowFormatting() {
return getConfig().getData("allowFormatting", true);
}
ConfigData<Boolean> allowFormatting = getConfig().getData("allowFormatting", true);
/**
* The sound to play when a player is mentioned. Leave empty to use default.
*/
public ConfigData<String> notificationSound() {
return getConfig().getData("notificationSound", "");
}
public ConfigData<String> notificationSound = getConfig().getData("notificationSound", "");
/**
* The pitch of the notification sound.
*/
public ConfigData<Float> notificationPitch() {
return getConfig().getData("notificationPitch", 1.0f);
}
public ConfigData<Float> notificationPitch = getConfig().getData("notificationPitch", 1.0f);
/**
* The minimum time between messages in milliseconds.
*/
public ConfigData<Integer> minTimeBetweenMessages() {
return getConfig().getData("minTimeBetweenMessages", 100);
}
public ConfigData<Integer> minTimeBetweenMessages = getConfig().getData("minTimeBetweenMessages", 100);
@Override
protected void enable() {

View file

@ -55,7 +55,7 @@ public class FTopCommand extends ICommand2MC {
val ai = new AtomicInteger();
sender.sendMessage("§6---- Top Fs ----");
sender.sendMessage(Arrays.stream(cached).skip((i - 1) * 10).limit(i * 10)
.map(cp -> String.format("%d. %s - %f.2", ai.incrementAndGet(), cp.PlayerName().get(), cp.getF()))
.map(cp -> String.format("%d. %s - %f.2", ai.incrementAndGet(), cp.PlayerName.get(), cp.getF()))
.collect(Collectors.joining("\n")));
});
return true;

View file

@ -36,7 +36,7 @@ public class FunComponent extends Component<PluginMain> implements Listener {
private boolean ActiveF = false;
private ChatPlayer FPlayer = null;
private BukkitTask Ftask = null;
private HashSet<CommandSender> Fs = new HashSet<>();
private final HashSet<CommandSender> Fs = new HashSet<>();
private UnlolCommand command;
private TBMCSystemChatEvent.BroadcastTarget unlolTarget;
private TBMCSystemChatEvent.BroadcastTarget fTarget;
@ -44,26 +44,20 @@ public class FunComponent extends Component<PluginMain> implements Listener {
/**
* The strings that count as laughs, see unlol.
*/
private ConfigData<String[]> laughStrings() {
return getConfig().getData("laughStrings", () -> new String[]{"xd", "lel", "lawl", "kek", "lmao", "hue", "hah", "rofl"});
}
private final ConfigData<String[]> laughStrings = getConfig().getData("laughStrings", () -> new String[]{"xd", "lel", "lawl", "kek", "lmao", "hue", "hah", "rofl"});
/**
* The "Press F to pay respects" meme in Minecraft. It will randomly appear on player death and keep track of how many "F"s are said in chat.
* You can hover over a player's name to see their respect.
*/
private ConfigData<Boolean> respect() {
return getConfig().getData("respect", true);
}
private final ConfigData<Boolean> respect = getConfig().getData("respect", true);
/**
* This is an inside joke on our server.
* It keeps track of laughs (lols and what's defined in laughStrings) and if someone does /unlol or /unlaugh it will unlaugh the last person who laughed.
* Which also blinds the laughing person for a few seconds. This action can only be performed once per laugh.
*/
private ConfigData<Boolean> unlol() {
return getConfig().getData("unlol", true);
}
private final ConfigData<Boolean> unlol = getConfig().getData("unlol", true);
@Override
protected void enable() {
@ -89,14 +83,14 @@ public class FunComponent extends Component<PluginMain> implements Listener {
if (ActiveF && !Fs.contains(sender) && message.equalsIgnoreCase("F"))
Fs.add(sender);
if (unlol().get()) {
if (unlol.get()) {
String msg = message.toLowerCase();
val lld = new UnlolCommand.LastlolData(sender, event, System.nanoTime());
boolean add;
if (add = msg.contains("lol"))
lld.setLolornot(true);
else {
String[] laughs = laughStrings().get();
String[] laughs = laughStrings.get();
for (String laugh : laughs) {
if (add = msg.contains(laugh)) {
lld.setLolornot(false);
@ -112,7 +106,7 @@ public class FunComponent extends Component<PluginMain> implements Listener {
@EventHandler
public void onPlayerDeath(PlayerDeathEvent e) {
// MinigamePlayer mgp = Minigames.plugin.pdata.getMinigamePlayer(e.getEntity());
if (e.getDeathMessage().length() > 0 && respect().get() && new Random().nextBoolean()) { // Don't store Fs for NPCs
if (e.getDeathMessage().length() > 0 && respect.get() && new Random().nextBoolean()) { // Don't store Fs for NPCs
Runnable tt = () -> {
if (ActiveF) {
ActiveF = false;
@ -140,14 +134,14 @@ public class FunComponent extends Component<PluginMain> implements Listener {
@EventHandler
public void onPlayerLeave(PlayerQuitEvent event) {
if (unlol().get())
if (unlol.get())
command.Lastlol.values().removeIf(lld -> lld.getLolowner().equals(event.getPlayer()));
}
@EventHandler(priority = EventPriority.LOWEST)
public void onCommandPreprocess(TBMCCommandPreprocessEvent event) {
if (event.isCancelled()) return;
if (!unlol().get()) return;
if (!unlol.get()) return;
final String cmd = event.getMessage();
// We don't care if we have arguments
if (cmd.toLowerCase().startsWith("/un")) {

View file

@ -50,7 +50,7 @@ public class NColorCommand extends UCommandBase {
return true;
}
var component = TownColorComponent.getComponent();
byte nationColors = (byte) (component.useNationColors().get() ? 1 : 0);
byte nationColors = (byte) (component.useNationColors.get() ? 1 : 0);
if (nameparts.length < towncolors.length + nationColors) { //+1: Nation color
player.sendMessage("§cYou need more vertical lines (|) or colons (:) in your name. (Should have " + (towncolors.length - 1 + 1) + ")"); //Nation color
return true;

View file

@ -31,7 +31,7 @@ public class TownColorCommand extends UCommandBase {
player.sendMessage(msg);
return true;
}
val cc = component.colorCount().get();
val cc = component.colorCount.get();
if (colornames.length > cc) {
player.sendMessage("You can only use " + cc + " color" + (cc > 1 ? "s" : "") + ".");
return true;

View file

@ -53,17 +53,13 @@ public class TownColorComponent extends Component<PluginMain> implements Listene
/**
* The amount of town colors allowed. If more than one is used, players can change how many letters to be in a specific color using /u ncolor.
*/
public ConfigData<Byte> colorCount() {
return getConfig().getData("colorCount", (byte) 1, cc -> ((Integer) cc).byteValue(), Byte::intValue);
}
public ConfigData<Byte> colorCount = getConfig().getData("colorCount", (byte) 1, cc -> ((Integer) cc).byteValue(), Byte::intValue);
/**
* If enabled, players will have a nation-defined color in addition to town colors, white by default.
* They can change how much of each color they want with this as well.
*/
public ConfigData<Boolean> useNationColors() {
return getConfig().getData("useNationColors", true);
}
public ConfigData<Boolean> useNationColors = getConfig().getData("useNationColors", true);
@Getter
private static TownColorComponent component;
@ -75,7 +71,7 @@ public class TownColorComponent extends Component<PluginMain> implements Listene
Consumer<ConfigurationSection> loadTC = cs -> TownColorComponent.TownColors.putAll(cs.getValues(true).entrySet().stream()
.collect(Collectors.toMap(Map.Entry::getKey, v -> ((List<String>) v.getValue()).stream()
.map(Color::valueOf).toArray(Color[]::new))));
boolean usenc = useNationColors().get();
boolean usenc = useNationColors.get();
Consumer<ConfigurationSection> loadNC = ncs ->
TownColorComponent.NationColor.putAll(ncs.getValues(true).entrySet().stream()
.collect(Collectors.toMap(Map.Entry::getKey, v -> Color.valueOf((String) v.getValue()))));
@ -95,10 +91,10 @@ public class TownColorComponent extends Component<PluginMain> implements Listene
initDynmap();
registerCommand(new TownColorCommand(this));
if (useNationColors().get())
if (useNationColors.get())
registerCommand(new NationColorCommand());
registerCommand(new buttondevteam.chat.components.towncolors.admin.TownColorCommand());
if (useNationColors().get())
if (useNationColors.get())
registerCommand(new buttondevteam.chat.components.towncolors.admin.NationColorCommand());
registerCommand(new TCCount());
registerCommand(new NColorCommand());
@ -110,7 +106,7 @@ public class TownColorComponent extends Component<PluginMain> implements Listene
protected void disable() {
getConfig().getConfig().createSection("towncolors", TownColors.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey,
v -> Arrays.stream(v.getValue()).map(Enum::toString).toArray(String[]::new))));
if (useNationColors().get())
if (useNationColors.get())
getConfig().getConfig().createSection("nationcolors", NationColor.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey,
v -> v.getValue().toString())));
getConfig().signalChange();
@ -126,7 +122,7 @@ public class TownColorComponent extends Component<PluginMain> implements Listene
val town = TownyComponent.dataSource.getTown(entry.getKey());
Nation nation;
Color nc;
if (!useNationColors().get())
if (!useNationColors.get())
nc = null;
else if (!town.hasNation() || (nation = town.getNation()) == null || (nc = NationColor.get(nation.getName().toLowerCase())) == null)
nc = Color.White;
@ -187,7 +183,7 @@ public class TownColorComponent extends Component<PluginMain> implements Listene
len = name.length() / (clrs.length+1);
else
len = name.length() / clrs.length;*/
boolean usenc = component.useNationColors().get();
boolean usenc = component.useNationColors.get();
val nclar = cp.NameColorLocations.get();
int[] ncl = nclar == null ? null : nclar.stream().mapToInt(Integer::intValue).toArray();
if (ncl != null && (Arrays.stream(ncl).sum() != name.length() || ncl.length != clrs.length + (usenc ? 1 : 0))) //+1: Nation color

View file

@ -61,7 +61,7 @@ public class TownyListener implements Listener {
@EventHandler
public void onNationRename(RenameNationEvent event) {
if (!TownColorComponent.getComponent().useNationColors().get()) return;
if (!TownColorComponent.getComponent().useNationColors.get()) return;
val clrs = TownColorComponent.NationColor.remove(event.getOldName().toLowerCase());
if (clrs != null)
TownColorComponent.NationColor.put(event.getNation().getName().toLowerCase(), clrs);
@ -69,25 +69,25 @@ public class TownyListener implements Listener {
@EventHandler //Gets called on town load as well
public void onNationJoin(NationAddTownEvent event) {
if (!TownColorComponent.getComponent().useNationColors().get()) return;
if (!TownColorComponent.getComponent().useNationColors.get()) return;
updateTownMembers(event.getTown());
}
@EventHandler
public void onNationLeave(NationRemoveTownEvent event) {
if (!TownColorComponent.getComponent().useNationColors().get()) return;
if (!TownColorComponent.getComponent().useNationColors.get()) return;
updateTownMembers(event.getTown()); //The town still has it's colours
}
@EventHandler
public void onNationDelete(DeleteNationEvent event) {
if (!TownColorComponent.getComponent().useNationColors().get()) return;
if (!TownColorComponent.getComponent().useNationColors.get()) return;
TownColorComponent.NationColor.remove(event.getNationName().toLowerCase());
}
@EventHandler
public void onNationCreate(NewNationEvent event) {
if (!TownColorComponent.getComponent().useNationColors().get()) return;
if (!TownColorComponent.getComponent().useNationColors.get()) return;
Player p = Bukkit.getPlayer(event.getNation().getCapital().getMayor().getName());
if (p != null)
p.sendMessage("§6Use /u nationcolor to set a color for the nation.");

View file

@ -15,7 +15,7 @@ public class TCCount extends AdminCommandBase {
@Command2.Subcommand
public boolean def(CommandSender sender, byte count) {
val comp = TownColorComponent.getComponent();
comp.colorCount().set(count);
comp.colorCount.set(count);
sender.sendMessage("Color count set to " + count);
return true;
}

View file

@ -61,7 +61,7 @@ public class TownColorCommand extends AdminCommandBase { //TODO: Command path al
clrs[i] = c.get();
}
Color tnc;
boolean usenc = TownColorComponent.getComponent().useNationColors().get();
boolean usenc = TownColorComponent.getComponent().useNationColors.get();
if (usenc) {
try {
tnc = TownColorComponent.NationColor.get(town.getNation().getName().toLowerCase());

View file

@ -52,7 +52,7 @@ public class PlayerJoinLeaveListener implements Listener {
nwithoutformatting = p.getName();
PlayerListener.nicknames.forcePut(nwithoutformatting.toLowerCase(), p.getUniqueId()); //TODO: FormatterComponent
if (PluginMain.Instance.storeChatHistory().get())
if (PluginMain.Instance.storeChatHistory.get())
HistoryCommand.showHistory(e.getPlayer(), null);
}

View file

@ -56,7 +56,7 @@ public class PlayerListener implements Listener {
ChatPlayer cp = e.getPlayer().getAs(ChatPlayer.class);
if (cp == null)
return;
e.addInfo("Minecraft name: " + cp.PlayerName().get());
e.addInfo("Minecraft name: " + cp.PlayerName.get());
if (cp.UserName.get() != null && cp.UserName.get().length() > 0)
e.addInfo("Reddit name: " + cp.UserName.get());
if (ComponentManager.isEnabled(FlairComponent.class)) {
@ -82,7 +82,7 @@ public class PlayerListener implements Listener {
lastError = System.nanoTime(); //I put the whole thing in the if to protect against race conditions
for (Player p : Bukkit.getOnlinePlayers())
if (e.shouldSendTo(p))
p.sendMessage("[" + e.getChannel().DisplayName().get() + "] §cSome features in the message below might be unavailable due to an error.");
p.sendMessage("[" + e.getChannel().DisplayName.get() + "] §cSome features in the message below might be unavailable due to an error.");
}
ChatUtils.sendChatMessage(e);
TBMCCoreAPI.SendException("An error occured while processing a chat message!", ex, PluginMain.Instance);