Skip to content

Commit 94b2ffc

Browse files
committed
Clean up
1 parent 5fb5e47 commit 94b2ffc

28 files changed

+174
-239
lines changed

src/main/java/org/maxgamer/quickshop/QuickShop.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -543,8 +543,6 @@ public void reloadConfig() {
543543
this.priceChangeRequiresFee = this.getConfig().getBoolean("shop.price-change-requires-fee");
544544
this.displayItemCheckTicks = this.getConfig().getInt("shop.display-items-check-ticks");
545545
this.allowStack = this.getConfig().getBoolean("shop.allow-stacks");
546-
// this.quickChatType = QuickChatType.fromID(this.getConfig().getInt("chat-type"));
547-
// this.quickChat = QuickChatType.createByType(this.quickChatType);
548546
this.currency = this.getConfig().getString("currency");
549547
if (StringUtils.isEmpty(this.currency)) {
550548
this.currency = null;
@@ -785,7 +783,6 @@ public final void onEnable() {
785783
getLogger().info("Developers: " + Util.list2String(this.getDescription().getAuthors()));
786784
getLogger().info("Original author: Netherfoam, Timtower, KaiNoMood");
787785
getLogger().info("Let's start loading the plugin");
788-
//getLogger().info("Chat processor selected: " + this.quickChatType.name());
789786
getLogger().info("Chat processor selected: Hardcoded BungeeChat Lib");
790787
/* Process Metrics and Sentry error reporter. */
791788
metrics = new Metrics(this, 3320);

src/main/java/org/maxgamer/quickshop/command/subcommand/SubCommand_Reload.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ public class SubCommand_Reload implements CommandHandler<CommandSender> {
3232

3333
@Override
3434
public void onCommand(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] cmdArg) {
35-
//MsgUtil.sendMessage(sender, "server-crash-warning");
3635
plugin.text().of(sender, "command.reloading").send();
3736
plugin.reloadConfig();
3837
}

src/main/java/org/maxgamer/quickshop/database/DatabaseTask.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
@ToString()
3131
public class DatabaseTask {
3232

33-
private final static Task emptyTask = ps -> {
33+
private final static Task EMPTY_TASK = ps -> {
3434
};
3535
private final String statement;
3636
private final Task task;
@@ -42,7 +42,7 @@ public DatabaseTask(String statement, Task task) {
4242

4343
public DatabaseTask(String statement) {
4444
this.statement = statement;
45-
this.task = emptyTask;
45+
this.task = EMPTY_TASK;
4646
}
4747

4848

src/main/java/org/maxgamer/quickshop/economy/Economy_Vault.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
public class Economy_Vault implements EconomyCore, Listener {
4545

46-
private static final String errorMsg =
46+
private static final String ERROR_MESSAGE =
4747
"QuickShop received an error when processing Economy response, THIS NOT A QUICKSHOP FAULT, you might need ask help with your Economy Provider plugin (%s) author.";
4848
private final QuickShop plugin;
4949
private boolean allowLoan;
@@ -139,7 +139,7 @@ public boolean deposit(@NotNull OfflinePlayer trader, double amount, @NotNull Wo
139139
plugin.getLogger().warning("Deposit failed and player name is NULL, Player uuid: " + trader.getUniqueId() + ". Provider (" + getProviderName() + ")");
140140
return false;
141141
}
142-
plugin.getLogger().log(Level.WARNING, String.format(errorMsg, getProviderName()), t);
142+
plugin.getLogger().log(Level.WARNING, String.format(ERROR_MESSAGE, getProviderName()), t);
143143
return false;
144144
}
145145
}
@@ -191,7 +191,7 @@ public double getBalance(@NotNull OfflinePlayer player, @NotNull World world, @N
191191
return Objects.requireNonNull(this.vault).getBalance(player);
192192
} catch (Exception t) {
193193
plugin.getSentryErrorReporter().ignoreThrow();
194-
plugin.getLogger().log(Level.WARNING, String.format(errorMsg, getProviderName()), t);
194+
plugin.getLogger().log(Level.WARNING, String.format(ERROR_MESSAGE, getProviderName()), t);
195195
return 0.0;
196196
}
197197
}
@@ -220,7 +220,7 @@ public boolean withdraw(@NotNull OfflinePlayer trader, double amount, @NotNull W
220220
plugin.getLogger().warning("Withdraw failed and player name is NULL, Player uuid: " + trader.getUniqueId() + ", Provider: " + getProviderName());
221221
return false;
222222
}
223-
plugin.getLogger().log(Level.WARNING, String.format(errorMsg, getProviderName()), t);
223+
plugin.getLogger().log(Level.WARNING, String.format(ERROR_MESSAGE, getProviderName()), t);
224224
return false;
225225
}
226226
}

src/main/java/org/maxgamer/quickshop/integration/IntegrationHelper.java

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
package org.maxgamer.quickshop.integration;
2121

22-
import lombok.Getter;
2322
import org.bukkit.Location;
2423
import org.bukkit.entity.Player;
2524
import org.bukkit.plugin.PluginManager;
@@ -45,21 +44,20 @@
4544

4645

4746
public class IntegrationHelper extends QuickShopInstanceHolder {
48-
@Getter
49-
private static final Map<String, Class<? extends IntegratedPlugin>> integratedPluginNameMap = new HashMap<>(7);
47+
private static final Map<String, Class<? extends IntegratedPlugin>> INTEGRATION_MAPPING = new HashMap<>(7);
5048

5149
static {
52-
integratedPluginNameMap.put("Factions", FactionsUUIDIntegration.class);
53-
integratedPluginNameMap.put("GriefPrevention", GriefPreventionIntegration.class);
54-
integratedPluginNameMap.put("Lands", LandsIntegration.class);
55-
integratedPluginNameMap.put("PlotSquared", PlotSquaredIntegrationProxy.class);
56-
integratedPluginNameMap.put("Residence", ResidenceIntegration.class);
57-
integratedPluginNameMap.put("Towny", TownyIntegration.class);
58-
integratedPluginNameMap.put("WorldGuard", WorldGuardIntegration.class);
59-
//integratedPluginNameMap.put("FabledSkyblock", FabledIntegration.class);
60-
integratedPluginNameMap.put("IridiumSkyblock", IridiumSkyblockIntegration.class);
61-
integratedPluginNameMap.put("SuperiorSkyblock", SuperiorSkyblock2Integration.class);
62-
integratedPluginNameMap.put("AdvancedRegionMarket", AdvancedShopRegionMarketIntegration.class);
50+
INTEGRATION_MAPPING.put("Factions", FactionsUUIDIntegration.class);
51+
INTEGRATION_MAPPING.put("GriefPrevention", GriefPreventionIntegration.class);
52+
INTEGRATION_MAPPING.put("Lands", LandsIntegration.class);
53+
INTEGRATION_MAPPING.put("PlotSquared", PlotSquaredIntegrationProxy.class);
54+
INTEGRATION_MAPPING.put("Residence", ResidenceIntegration.class);
55+
INTEGRATION_MAPPING.put("Towny", TownyIntegration.class);
56+
INTEGRATION_MAPPING.put("WorldGuard", WorldGuardIntegration.class);
57+
//INTEGRATION_MAPPING.put("FabledSkyblock", FabledIntegration.class);
58+
INTEGRATION_MAPPING.put("IridiumSkyblock", IridiumSkyblockIntegration.class);
59+
INTEGRATION_MAPPING.put("SuperiorSkyblock", SuperiorSkyblock2Integration.class);
60+
INTEGRATION_MAPPING.put("AdvancedRegionMarket", AdvancedShopRegionMarketIntegration.class);
6361
}
6462

6563
private final Map<String, IntegratedPlugin> integrations = new HashMap<>(7);
@@ -76,9 +74,13 @@ public List<IntegratedPlugin> getIntegrations() {
7674
return Collections.unmodifiableList(new ArrayList<>(integrations.values()));
7775
}
7876

77+
public static Map<String, Class<? extends IntegratedPlugin>> getIntegrationMapping() {
78+
return INTEGRATION_MAPPING;
79+
}
80+
7981
public void searchAndRegisterPlugins() {
8082
PluginManager pluginManager = plugin.getServer().getPluginManager();
81-
for (Map.Entry<String, Class<? extends IntegratedPlugin>> entry : integratedPluginNameMap.entrySet()) {
83+
for (Map.Entry<String, Class<? extends IntegratedPlugin>> entry : INTEGRATION_MAPPING.entrySet()) {
8284
String pluginName = entry.getKey();
8385
if (pluginManager.isPluginEnabled(pluginName) && plugin.getConfig().getBoolean("integration." + pluginName.toLowerCase() + ".enable")) {
8486
try {
@@ -127,7 +129,7 @@ public void register(@NotNull Class<? extends IntegratedPlugin> integratedPlugin
127129
* @param integratedPluginName custom integrated module name
128130
*/
129131
public void register(@NotNull String integratedPluginName) {
130-
Class<? extends IntegratedPlugin> integratedPluginClass = integratedPluginNameMap.get(integratedPluginName);
132+
Class<? extends IntegratedPlugin> integratedPluginClass = INTEGRATION_MAPPING.get(integratedPluginName);
131133
if (integratedPluginClass != null) {
132134
register(integratedPluginClass);
133135
} else {

src/main/java/org/maxgamer/quickshop/integration/residence/ResidenceIntegration.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
@SuppressWarnings("DuplicatedCode")
4040
@IntegrationStage(loadStage = IntegrateStage.onEnableAfter)
4141
public class ResidenceIntegration extends QSIntegratedPlugin {
42-
private static final String createFlag = "quickshop-create";
43-
private static final String tradeFlag = "quickshop-trade";
42+
private static final String CREATE_FLAG = "quickshop-create";
43+
private static final String TRADE_FLAG = "quickshop-trade";
4444
private List<String> createLimits;
4545
private List<String> tradeLimits;
4646
private boolean whiteList;
@@ -87,13 +87,13 @@ public boolean canCreateShopHere(@NotNull Player player, @NotNull Location locat
8787
if (!playerHas(Residence.getInstance()
8888
.getWorldFlags()
8989
.getPerms(location.getWorld().getName())
90-
, player, createFlag, !whiteList)) {
90+
, player, CREATE_FLAG, !whiteList)) {
9191
return false;
9292
}
9393
} else {
9494
if (!playerHas(residence
9595
.getPermissions()
96-
, player, createFlag, false)) {
96+
, player, CREATE_FLAG, false)) {
9797
return false;
9898
}
9999
}
@@ -127,13 +127,13 @@ public boolean canTradeShopHere(@NotNull Player player, @NotNull Location locati
127127
if (!playerHas(Residence.getInstance()
128128
.getWorldFlags()
129129
.getPerms(location.getWorld().getName())
130-
, player, tradeFlag, !whiteList)) {
130+
, player, TRADE_FLAG, !whiteList)) {
131131
return false;
132132
}
133133
} else {
134134
if (!playerHas(residence
135135
.getPermissions()
136-
, player, tradeFlag, true)) {
136+
, player, TRADE_FLAG, true)) {
137137
return false;
138138
}
139139
}
@@ -158,8 +158,8 @@ public boolean canTradeShopHere(@NotNull Player player, @NotNull Location locati
158158

159159
@Override
160160
public void load() {
161-
FlagPermissions.addFlag(createFlag);
162-
FlagPermissions.addFlag(tradeFlag);
161+
FlagPermissions.addFlag(CREATE_FLAG);
162+
FlagPermissions.addFlag(TRADE_FLAG);
163163
}
164164

165165
@Override

src/main/java/org/maxgamer/quickshop/listener/PluginListener.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535

3636
public class PluginListener extends QSListener {
3737

38-
private static final Set<String> pluginCompatibilityModuleList = CompatibilityManager.getCompatibilityModuleNameMap().keySet();
39-
private static final Set<String> pluginIntegrationList = IntegrationHelper.getIntegratedPluginNameMap().keySet();
38+
private static final Set<String> COMPATIBILITY_MODULE_LIST = CompatibilityManager.getModuleMapping().keySet();
39+
private static final Set<String> PLUGIN_INTEGRATION_LIST = IntegrationHelper.getIntegrationMapping().keySet();
4040
private IntegrationHelper integrationHelper;
4141
private CompatibilityManager compatibilityManager;
4242

@@ -54,31 +54,31 @@ private void init() {
5454
@EventHandler(priority = EventPriority.MONITOR)
5555
public void onPluginDisabled(PluginDisableEvent event) {
5656
String pluginName = event.getPlugin().getName();
57-
if (pluginIntegrationList.contains(pluginName) && plugin.getConfig().getBoolean("integration." + pluginName.toLowerCase() + ".enable")) {
57+
if (PLUGIN_INTEGRATION_LIST.contains(pluginName) && plugin.getConfig().getBoolean("integration." + pluginName.toLowerCase() + ".enable")) {
5858
IntegratedPlugin integratedPlugin = integrationHelper.getIntegrationMap().get(pluginName);
5959
if (integratedPlugin != null) {
6060
Util.debugLog("[Hot Load] Calling for unloading " + integratedPlugin.getName());
6161
integratedPlugin.unload();
6262
integrationHelper.unregister(integratedPlugin);
6363
}
6464
}
65-
if (pluginCompatibilityModuleList.contains(pluginName)) {
65+
if (COMPATIBILITY_MODULE_LIST.contains(pluginName)) {
6666
compatibilityManager.unregister(pluginName);
6767
}
6868
}
6969

7070
@EventHandler(priority = EventPriority.MONITOR)
7171
public void onPluginEnabled(PluginEnableEvent event) {
7272
String pluginName = event.getPlugin().getName();
73-
if (pluginIntegrationList.contains(pluginName) && plugin.getConfig().getBoolean("integration." + pluginName.toLowerCase() + ".enable")) {
73+
if (PLUGIN_INTEGRATION_LIST.contains(pluginName) && plugin.getConfig().getBoolean("integration." + pluginName.toLowerCase() + ".enable")) {
7474
integrationHelper.register(pluginName);
7575
IntegratedPlugin integratedPlugin = integrationHelper.getIntegrationMap().get(pluginName);
7676
if (integratedPlugin != null) {
7777
Util.debugLog("[Hot Load] Calling for loading " + integratedPlugin.getName());
7878
integratedPlugin.load();
7979
}
8080
}
81-
if (pluginCompatibilityModuleList.contains(pluginName)) {
81+
if (COMPATIBILITY_MODULE_LIST.contains(pluginName)) {
8282
compatibilityManager.register(pluginName);
8383
}
8484
}

src/main/java/org/maxgamer/quickshop/permission/PermissionManager.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,6 @@ public boolean hasPermission(@NotNull CommandSender sender, @NotNull String perm
5959
try {
6060
PermissionInformationContainer container = provider.getDebugInfo(sender, permission);
6161
Util.debugLog("Node: [" + container.getPermission() + "]; Result: [" + result + "]; Sender: [" + container.getSender().getName() + "]");
62-
// Util.debugLog("Result: " + result);
63-
// Util.debugLog("Sender: " + container.getSender().getName());
64-
// Util.debugLog("Permission Node: " + container.getPermission());
65-
// // Util.debugLog("Primary Group: " + container.getGroupName());
66-
// // Util.debugLog("Other infos: " + container.getOtherInfos());
6762
} catch (Exception th) {
6863
Util.debugLog("Exception threw when getting debug messages.");
6964
MsgUtil.debugStackTrace(th.getStackTrace());

src/main/java/org/maxgamer/quickshop/shop/ContainerShop.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@
6262
public class ContainerShop implements Shop {
6363
@JsonUtil.Hidden
6464
@EqualsAndHashCode.Exclude
65-
private static final String shopSignPrefix = "§d§o §r";
65+
private static final String SHOP_SIGN_PREFIX = "§d§o §r";
6666
@EqualsAndHashCode.Exclude
6767
@JsonUtil.Hidden
68-
private static final String shopSignPattern = "§d§o ";
68+
private static final String SHOP_SIGN_PATTERN = "§d§o ";
6969
@NotNull
7070
private final Location location;
7171
private final YamlConfiguration extra;
@@ -739,7 +739,7 @@ public List<ComponentPackge> getSignText(@NotNull String locale) {
739739
default:
740740
line2 =plugin.text().of(tradingStringKey, Integer.toString(shopRemaining)).forLocale(locale);
741741
}
742-
lines.add(new ComponentPackge(TextComponent.fromLegacyText(shopSignPrefix+line2+" ")));
742+
lines.add(new ComponentPackge(TextComponent.fromLegacyText(SHOP_SIGN_PREFIX+line2+" ")));
743743

744744
//line 3
745745
if(this.getItem().hasItemMeta() && this.getItem().getItemMeta().hasDisplayName()){
@@ -1131,7 +1131,7 @@ public void setShopType(@NotNull ShopType newShopType) {
11311131
continue;
11321132
}
11331133

1134-
if (lines[1].startsWith(shopSignPattern)) {
1134+
if (lines[1].startsWith(SHOP_SIGN_PATTERN)) {
11351135
signs.add(sign);
11361136
} else {
11371137
String header = lines[0];

0 commit comments

Comments
 (0)