code cleanup courtesy of ganom (#428)

This commit is contained in:
OnlyHereToPlayOsrs
2019-05-29 00:04:01 +02:00
committed by Kyleeld
parent 255daf4b68
commit 3acb7ddf75
2 changed files with 24 additions and 19 deletions

View File

@@ -11,8 +11,8 @@ public interface BanListConfig extends Config
@ConfigItem( @ConfigItem(
keyName = "bannedPlayers", keyName = "bannedPlayers",
name = "Banned Players List", name = "Manual Scammer List",
description = "manual entry ", description = "Players you add to this list will be shown when you join a clan.",
position = 0 position = 0
) )
@@ -31,8 +31,8 @@ public interface BanListConfig extends Config
@ConfigItem( @ConfigItem(
position = 1, position = 1,
keyName = "enableWDR", keyName = "enableWDR",
name = "use WDR list", name = "Enable WDR Scammer List",
description = "Incorporate WDR ban list" description = "Incorporate WDR Scammer list"
) )
default boolean enableWDR() default boolean enableWDR()
{ {
@@ -42,8 +42,8 @@ public interface BanListConfig extends Config
@ConfigItem( @ConfigItem(
position = 2, position = 2,
keyName = "enableRuneWatch", keyName = "enableRuneWatch",
name = "use RuneWatch list", name = "Enable RuneWatch Scammer List",
description = "Incorporate RuneWatch Ban list" description = "Incorporate RuneWatch Scammer list"
) )
default boolean enableRuneWatch() default boolean enableRuneWatch()
{ {

View File

@@ -1,5 +1,7 @@
/* /*
* Copyright (c) 2019 xperiaclash <https://github.com/xperiaclash> * Copyright (c) 2019, xperiaclash <https://github.com/xperiaclash>
* Copyright (c) 2019, ganom <https://github.com/Ganom>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -82,9 +84,6 @@ public class BanListPlugin extends Plugin
@Override @Override
protected void startUp() throws Exception protected void startUp() throws Exception
{ {
wdrArrayList = new ArrayList<>();
runeWatchArrayList = new ArrayList<>();
manualBans = new ArrayList<>();
manualBans.addAll(Text.fromCSV(config.getBannedPlayers())); manualBans.addAll(Text.fromCSV(config.getBannedPlayers()));
fetchFromWebsites(); fetchFromWebsites();
} }
@@ -92,9 +91,9 @@ public class BanListPlugin extends Plugin
@Override @Override
protected void shutDown() throws Exception protected void shutDown() throws Exception
{ {
wdrArrayList = null; wdrArrayList.clear();
runeWatchArrayList = null; runeWatchArrayList.clear();
manualBans = null; manualBans.clear();
} }
@Subscribe @Subscribe
@@ -107,11 +106,17 @@ public class BanListPlugin extends Plugin
@Subscribe @Subscribe
public void onConfigChanged(ConfigChanged event) public void onConfigChanged(ConfigChanged event)
{ {
for (String manual : Text.fromCSV(config.getBannedPlayers())) if (event.getGroup().equals("banlist"))
{ {
if (!manualBans.contains(manual)) if (event.getKey().equals("bannedPlayers"))
{ {
manualBans.add(Text.standardize(manual)); for (String manual : Text.fromCSV(config.getBannedPlayers()))
{
if (!manualBans.contains(manual))
{
manualBans.add(Text.standardize(manual));
}
}
} }
} }
} }
@@ -153,7 +158,7 @@ public class BanListPlugin extends Plugin
// on wdr list // on wdr list
final String message = new ChatMessageBuilder() final String message = new ChatMessageBuilder()
.append(ChatColorType.HIGHLIGHT) .append(ChatColorType.HIGHLIGHT)
.append("Warning! " + playerName + " is on WDR ban List") .append("Warning! " + playerName + " is on WDRs' scammer list")
.build(); .build();
chatMessageManager.queue( chatMessageManager.queue(
@@ -167,7 +172,7 @@ public class BanListPlugin extends Plugin
// on runewatch list // on runewatch list
final String message = new ChatMessageBuilder() final String message = new ChatMessageBuilder()
.append(ChatColorType.HIGHLIGHT) .append(ChatColorType.HIGHLIGHT)
.append("Warning! " + playerName + " is on Runewatch ban List") .append("Warning! " + playerName + " is on Runewatchs' scammer list")
.build(); .build();
chatMessageManager.queue( chatMessageManager.queue(
@@ -181,7 +186,7 @@ public class BanListPlugin extends Plugin
// on manual list // on manual list
final String message = new ChatMessageBuilder() final String message = new ChatMessageBuilder()
.append(ChatColorType.HIGHLIGHT) .append(ChatColorType.HIGHLIGHT)
.append("Warning! " + playerName + " is on Your Manual ban List") .append("Warning! " + playerName + " is on your Manual scammer list")
.build(); .build();
chatMessageManager.queue( chatMessageManager.queue(