From 7ee1c6eef64f8128b5a7800bf210f1e78ab0a3d4 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Thu, 17 Aug 2017 18:03:45 +0300 Subject: [PATCH] Fix sonar issues with PluginBridge --- .../djrapitops/pluginbridge/plan/Bridge.java | 82 ++++--------------- .../pluginbridge/plan/FakeOfflinePlayer.java | 3 +- .../djrapitops/pluginbridge/plan/Hook.java | 5 +- .../AdvancedAchievementsAchievements.java | 2 +- .../AdvancedAchievementsTable.java | 25 +++--- .../plan/askyblock/ASkyBlockIslandLevel.java | 2 +- .../plan/askyblock/ASkyBlockIslandResets.java | 9 +- .../plan/askyblock/ASkyBlockIslands.java | 7 +- .../plan/factions/FactionsTable.java | 24 +++--- .../GriefPreventionClaimArea.java | 2 +- .../GriefPreventionClaimBlocksAvailable.java | 7 +- .../GriefPreventionClaimTable.java | 2 +- .../GriefPreventionClaims.java | 2 +- .../plan/jobs/JobsAnalysisJobTable.java | 9 +- .../plan/jobs/JobsInspectJobTable.java | 2 +- .../plan/litebans/LiteBansBansTable.java | 13 +-- .../litebans/LiteBansDatabaseQueries.java | 48 +++++------ .../plan/litebans/LiteBansHook.java | 6 +- .../litebans/LiteBansInspectBansTable.java | 11 +-- .../plan/mcmmo/McmmoAnalysisSkillTable.java | 18 ++-- .../plan/mcmmo/McmmoInspectSkillTable.java | 12 +-- .../pluginbridge/plan/ontime/OntimeRefer.java | 13 +-- .../plan/ontime/OntimeReferMonth.java | 7 +- .../plan/ontime/OntimeReferWeek.java | 7 +- .../pluginbridge/plan/ontime/OntimeVotes.java | 7 +- .../plan/ontime/OntimeVotesMonth.java | 7 +- .../plan/ontime/OntimeVotesWeek.java | 7 +- .../plan/superbvote/SuperbVoteVotes.java | 7 +- .../pluginbridge/plan/towny/TownyTable.java | 4 +- .../pluginbridge/plan/towny/TownyTown.java | 18 ++-- .../plan/vault/EconomyBalance.java | 16 ++-- .../plan/vault/PermGroupTable.java | 13 ++- .../pluginbridge/plan/vault/VaultHook.java | 13 +-- .../plan/viaversion/Protocol.java | 7 ++ 34 files changed, 201 insertions(+), 216 deletions(-) diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/Bridge.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/Bridge.java index 3b68b94ff..52c070d76 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/Bridge.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/Bridge.java @@ -1,79 +1,31 @@ package com.djrapitops.pluginbridge.plan; -import com.djrapitops.pluginbridge.plan.advancedachievements.AdvancedAchievementsHook; -import com.djrapitops.pluginbridge.plan.askyblock.ASkyBlockHook; -import com.djrapitops.pluginbridge.plan.essentials.EssentialsHook; -import com.djrapitops.pluginbridge.plan.factions.FactionsHook; -import com.djrapitops.pluginbridge.plan.griefprevention.GriefPreventionHook; -import com.djrapitops.pluginbridge.plan.jobs.JobsHook; -import com.djrapitops.pluginbridge.plan.litebans.LiteBansHook; -import com.djrapitops.pluginbridge.plan.mcmmo.McmmoHook; -import com.djrapitops.pluginbridge.plan.ontime.OnTimeHook; -import com.djrapitops.pluginbridge.plan.superbvote.SuperbVoteHook; -import com.djrapitops.pluginbridge.plan.towny.TownyHook; -import com.djrapitops.pluginbridge.plan.vault.VaultHook; -import com.djrapitops.pluginbridge.plan.viaversion.ViaVersionHook; import main.java.com.djrapitops.plan.data.additional.HookHandler; +import main.java.com.djrapitops.plan.data.cache.DataCacheHandler; /** - * * @author Rsl1122 */ @SuppressWarnings("WeakerAccess") public class Bridge { + private Bridge() { + throw new IllegalStateException("Utility class"); + } + public static void hook(HookHandler handler) { - try { - AdvancedAchievementsHook advancedAchievementsHook = new AdvancedAchievementsHook(handler); - } catch (NoClassDefFoundError e) { - } - try { - EssentialsHook essentialsHook = new EssentialsHook(handler); - } catch (NoClassDefFoundError e) { - } - try { - FactionsHook factionsHook = new FactionsHook(handler); - } catch (NoClassDefFoundError e) { - } - try { - McmmoHook mcMmoHook = new McmmoHook(handler); - } catch (NoClassDefFoundError e) { - } - try { - JobsHook jobsHook = new JobsHook(handler); - } catch (NoClassDefFoundError e) { - } - try { - OnTimeHook onTimeHook = new OnTimeHook(handler); - } catch (NoClassDefFoundError e) { - } - try { - TownyHook townyHook = new TownyHook(handler); - } catch (NoClassDefFoundError e) { - } - try { - VaultHook vaultHook = new VaultHook(handler); - } catch (NoClassDefFoundError e) { - } - try { - ASkyBlockHook askyblockHook = new ASkyBlockHook(handler); - } catch (NoClassDefFoundError e) { - } - try { - GriefPreventionHook griefPrevHook = new GriefPreventionHook(handler); - } catch (NoClassDefFoundError e) { - } - try { - LiteBansHook hook = new LiteBansHook(handler); - } catch (NoClassDefFoundError e) { - } - try { - SuperbVoteHook hook = new SuperbVoteHook(handler); - } catch (NoClassDefFoundError e) { - } - try { - ViaVersionHook hook = new ViaVersionHook(handler); - } catch (NoClassDefFoundError e) { + String[] plugins = new String[]{ + "AdvancedAchievements", "Essentials", "Factions", "Mcmmo", + "Jobs", "OnTime", "Towny", "Valut", "ASkyBlock", + "GriefPrevention", "LiteBans", "SuperbVote", "ViaVersion" + }; + for (String pluginName : plugins) { + try { + String className = "com.djrapitops.pluginbridge.plan." + pluginName + "Hook"; + Class clazz = (Class) Hook.class.forName(className); + clazz.getConstructor(DataCacheHandler.class).newInstance(handler); + } catch (Exception | NoClassDefFoundError ignore) { + } } } } diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/FakeOfflinePlayer.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/FakeOfflinePlayer.java index 3673c1bf7..21f199888 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/FakeOfflinePlayer.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/FakeOfflinePlayer.java @@ -15,7 +15,6 @@ import java.util.Map; import java.util.UUID; /** - * * @author Rsl1122 */ public class FakeOfflinePlayer implements OfflinePlayer { @@ -57,6 +56,7 @@ public class FakeOfflinePlayer implements OfflinePlayer { @Override public void setWhitelisted(boolean bln) { + /* Not used */ } @Override @@ -91,6 +91,7 @@ public class FakeOfflinePlayer implements OfflinePlayer { @Override public void setOp(boolean bln) { + /* Not used */ } @Override diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/Hook.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/Hook.java index 99b398e18..e5e224a68 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/Hook.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/Hook.java @@ -1,6 +1,7 @@ package com.djrapitops.pluginbridge.plan; import org.bukkit.plugin.java.JavaPlugin; + import static org.bukkit.plugin.java.JavaPlugin.getPlugin; /** @@ -18,7 +19,7 @@ public abstract class Hook { /** * Class constructor. - * + *

* Checks if the given plugin (class path) is enabled. * * @param plugin Class path string of the plugin's main JavaPlugin class. @@ -29,7 +30,7 @@ public abstract class Hook { Class pluginClass = (Class) givenClass; JavaPlugin hookedPlugin = getPlugin(pluginClass); enabled = hookedPlugin.isEnabled(); - } catch (Throwable e) { + } catch (NoClassDefFoundError | NoSuchFieldError | NoSuchMethodError | Exception e) { enabled = false; } } diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/advancedachievements/AdvancedAchievementsAchievements.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/advancedachievements/AdvancedAchievementsAchievements.java index 6c0483b90..396f60062 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/advancedachievements/AdvancedAchievementsAchievements.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/advancedachievements/AdvancedAchievementsAchievements.java @@ -52,7 +52,7 @@ public class AdvancedAchievementsAchievements extends PluginData { if (total != null) { return parseContainer(modifierPrefix, total + ""); } - return parseContainer(modifierPrefix, 0 + ""); + return parseContainer(modifierPrefix, "0"); } private void refreshTotalAchievements() { diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/advancedachievements/AdvancedAchievementsTable.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/advancedachievements/AdvancedAchievementsTable.java index 469c54ae6..7670a9140 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/advancedachievements/AdvancedAchievementsTable.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/advancedachievements/AdvancedAchievementsTable.java @@ -14,14 +14,14 @@ import java.util.UUID; /** * PluginData class for AdvancedAchievements-plugin. - * + *

* Registered to the plugin by AdvancedAchievementsHook - * + *

* Gives a table of players and achievements achievements. * * @author Rsl1122 - * @since 3.1.0 * @see AdvancedAchievementsHook + * @since 3.1.0 */ public class AdvancedAchievementsTable extends PluginData { @@ -29,7 +29,7 @@ public class AdvancedAchievementsTable extends PluginData { /** * Class Constructor, sets the parameters of the PluginData object. - * + *

* Uses Html to easily parse Html for the table. * * @param aaAPI AdvancedAchievementsAPI given by AdvancedAchievementsHook @@ -60,28 +60,31 @@ public class AdvancedAchievementsTable extends PluginData { } private void appendTableLinesForLessThanV520(Map cachedUserData, StringBuilder html) { - cachedUserData.values().forEach((uData) -> { - String inspectUrl = HtmlUtils.getInspectUrl(uData.getName()); - String achievements = aaAPI.getPlayerTotalAchievements(uData.getUuid()) + ""; + cachedUserData.values().forEach(uData -> { + String inspectUrl = HtmlUtils.getRelativeInspectUrl(uData.getName()); + int achievements = aaAPI.getPlayerTotalAchievements(uData.getUuid()); html.append(Html.TABLELINE_2.parse(Html.LINK.parse(inspectUrl, uData.getName()), achievements)); }); } private void appendTableLinesForV520Plus(Map cachedUserData, StringBuilder html) { Map achievementsMap = aaAPI.getPlayersTotalAchievements(); - for (UUID uuid : achievementsMap.keySet()) { + for (Map.Entry entry : achievementsMap.entrySet()) { + UUID uuid = entry.getKey(); + int achievements = entry.getValue(); + UserData uData = cachedUserData.get(uuid); if (uData == null) { continue; } + String inspectUrl = HtmlUtils.getInspectUrl(uData.getName()); - int achievements = achievementsMap.get(uuid); - html.append(Html.TABLELINE_2.parse(Html.LINK.parse(inspectUrl, uData.getName()), achievements+"")); + html.append(Html.TABLELINE_2.parse(Html.LINK.parse(inspectUrl, uData.getName()), achievements)); } } @Override public Serializable getValue(UUID uuid) { - return ""; + return -1; } } diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/askyblock/ASkyBlockIslandLevel.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/askyblock/ASkyBlockIslandLevel.java index 5c783bcf2..9fda68a6a 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/askyblock/ASkyBlockIslandLevel.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/askyblock/ASkyBlockIslandLevel.java @@ -34,7 +34,7 @@ public class ASkyBlockIslandLevel extends PluginData { public String getHtmlReplaceValue(String modifierPrefix, UUID uuid) { if (api.hasIsland(uuid)) { int level = api.getIslandLevel(uuid); - return parseContainer(modifierPrefix, level + ""); + return parseContainer(modifierPrefix, Integer.toString(level)); } return parseContainer(modifierPrefix, "No Island"); } diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/askyblock/ASkyBlockIslandResets.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/askyblock/ASkyBlockIslandResets.java index e84ef906f..9b2adf366 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/askyblock/ASkyBlockIslandResets.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/askyblock/ASkyBlockIslandResets.java @@ -1,9 +1,10 @@ package com.djrapitops.pluginbridge.plan.askyblock; import com.wasteofplastic.askyblock.ASkyBlockAPI; +import main.java.com.djrapitops.plan.data.additional.PluginData; + import java.io.Serializable; import java.util.UUID; -import main.java.com.djrapitops.plan.data.additional.PluginData; /** * PluginData class for ASkyBlock-plugin. @@ -22,15 +23,15 @@ public class ASkyBlockIslandResets extends PluginData { */ public ASkyBlockIslandResets(ASkyBlockAPI aaAPI) { super("ASkyBlock", "island_resets_left"); - this.api = aaAPI; + this.api = aaAPI; super.setIcon("refresh"); super.setPrefix("Island Resets Left: "); } @Override public String getHtmlReplaceValue(String modifierPrefix, UUID uuid) { - return parseContainer(modifierPrefix, api.getResetsLeft(uuid)+""); - + return parseContainer(modifierPrefix, Integer.toString(api.getResetsLeft(uuid))); + } @Override diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/askyblock/ASkyBlockIslands.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/askyblock/ASkyBlockIslands.java index e53228e0f..224982e07 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/askyblock/ASkyBlockIslands.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/askyblock/ASkyBlockIslands.java @@ -1,11 +1,12 @@ package com.djrapitops.pluginbridge.plan.askyblock; import com.wasteofplastic.askyblock.ASkyBlockAPI; -import java.io.Serializable; -import java.util.UUID; import main.java.com.djrapitops.plan.data.additional.AnalysisType; import main.java.com.djrapitops.plan.data.additional.PluginData; +import java.io.Serializable; +import java.util.UUID; + /** * PluginData class for ASkyBlock-plugin. * @@ -32,7 +33,7 @@ public class ASkyBlockIslands extends PluginData { public String getHtmlReplaceValue(String modifierPrefix, UUID uuid) { int count = api.getIslandCount(); if (count > 0) { - return parseContainer(modifierPrefix, count + ""); + return parseContainer(modifierPrefix, Integer.toString(count)); } return parseContainer(modifierPrefix, "0"); } diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/factions/FactionsTable.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/factions/FactionsTable.java index eee1aaa84..5351bcbfb 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/factions/FactionsTable.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/factions/FactionsTable.java @@ -70,24 +70,20 @@ public class FactionsTable extends PluginData { html.append(Html.TABLELINE_4.parse("No Factions", "", "", "")); } else { for (Faction f : factions) { - String name; - String leader; - String power; - String land; if (f != null) { - name = f.getName(); MPlayer fLeader = f.getLeader(); - leader = fLeader != null ? fLeader.getNameAndSomething("", "") : "No Leader"; - power = FormatUtils.cutDecimals(f.getPower()); - land = f.getLandCount() + ""; + String leader = fLeader != null ? fLeader.getNameAndSomething("", "") : "No Leader"; + String leaderPage = Html.LINK.parse(HtmlUtils.getInspectUrl(leader), leader); + html.append(Html.TABLELINE_4.parse( + f.getName(), + FormatUtils.cutDecimals(f.getPower()), + f.getLandCount(), + leaderPage + )); } else { - name = "Not Found"; - leader = "Not Found"; - power = "Not Found"; - land = "Not Found"; + String notFound = "Not Found"; + html.append(Html.TABLELINE_4.parse(notFound, notFound, notFound, notFound)); } - String leaderPage = Html.LINK.parse(HtmlUtils.getInspectUrl(leader), leader); - html.append(Html.TABLELINE_4.parse(name, power, land, leaderPage)); } } return parseContainer(modifierPrefix, html.toString()); diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/griefprevention/GriefPreventionClaimArea.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/griefprevention/GriefPreventionClaimArea.java index 0874ec825..9be192b86 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/griefprevention/GriefPreventionClaimArea.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/griefprevention/GriefPreventionClaimArea.java @@ -40,7 +40,7 @@ public class GriefPreventionClaimArea extends PluginData { .filter(Objects::nonNull) .filter(claim -> uuid.equals(claim.ownerID)) .map(Claim::getArea).mapToInt(i -> i).sum(); - return parseContainer(modifierPrefix, area + ""); + return parseContainer(modifierPrefix, Integer.toString(area)); } @Override diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/griefprevention/GriefPreventionClaimBlocksAvailable.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/griefprevention/GriefPreventionClaimBlocksAvailable.java index f9b89ae3f..269a876d8 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/griefprevention/GriefPreventionClaimBlocksAvailable.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/griefprevention/GriefPreventionClaimBlocksAvailable.java @@ -1,11 +1,12 @@ package com.djrapitops.pluginbridge.plan.griefprevention; -import java.io.Serializable; -import java.util.UUID; import main.java.com.djrapitops.plan.data.additional.PluginData; import me.ryanhamshire.GriefPrevention.DataStore; import me.ryanhamshire.GriefPrevention.PlayerData; +import java.io.Serializable; +import java.util.UUID; + /** * PluginData class for GriefPrevention-plugin. * @@ -32,7 +33,7 @@ public class GriefPreventionClaimBlocksAvailable extends PluginData { public String getHtmlReplaceValue(String modifierPrefix, UUID uuid) { PlayerData data = dataStore.getPlayerData(uuid); int blocks = data.getAccruedClaimBlocks() + data.getBonusClaimBlocks() + dataStore.getGroupBonusBlocks(uuid); - return parseContainer(modifierPrefix, blocks + ""); + return parseContainer(modifierPrefix, Integer.toString(blocks)); } @Override diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/griefprevention/GriefPreventionClaimTable.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/griefprevention/GriefPreventionClaimTable.java index 9e2279a68..4941e5007 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/griefprevention/GriefPreventionClaimTable.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/griefprevention/GriefPreventionClaimTable.java @@ -53,7 +53,7 @@ public class GriefPreventionClaimTable extends PluginData { .filter(claim -> uuid.equals(claim.ownerID)) .forEach(claim -> { String location = FormattingUtils.formatLocation(claim.getGreaterBoundaryCorner()); - String area = claim.getArea() + ""; + int area = claim.getArea(); html.append(Html.TABLELINE_2.parse(location, area)); }); return html.toString(); diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/griefprevention/GriefPreventionClaims.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/griefprevention/GriefPreventionClaims.java index f318ca9e3..9fccfb83c 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/griefprevention/GriefPreventionClaims.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/griefprevention/GriefPreventionClaims.java @@ -42,7 +42,7 @@ public class GriefPreventionClaims extends PluginData { .filter(Objects::nonNull) .filter(claim -> uuid.equals(claim.ownerID)) .collect(Collectors.toList()); - return parseContainer(modifierPrefix, claims.size()+""); + return parseContainer(modifierPrefix, Integer.toString(claims.size())); } @Override diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/jobs/JobsAnalysisJobTable.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/jobs/JobsAnalysisJobTable.java index e69dc59e5..99f04144d 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/jobs/JobsAnalysisJobTable.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/jobs/JobsAnalysisJobTable.java @@ -63,14 +63,15 @@ public class JobsAnalysisJobTable extends PluginData { } StringBuilder html = new StringBuilder(); - for (String job : workers.keySet()) { - Integer amountOfWorkers = workers.get(job); + for (Map.Entry entry : workers.entrySet()) { + String job = entry.getKey(); + Integer amountOfWorkers = entry.getValue(); Long totalLevel = totals.get(job); html.append(Html.TABLELINE_4.parse( job, - "" + amountOfWorkers, + amountOfWorkers, FormatUtils.cutDecimals(MathUtils.average((int) (long) totalLevel, amountOfWorkers)), - "" + totalLevel) + totalLevel) ); } return parseContainer("", html.toString()); diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/jobs/JobsInspectJobTable.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/jobs/JobsInspectJobTable.java index 63bc3c207..7bdf10720 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/jobs/JobsInspectJobTable.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/jobs/JobsInspectJobTable.java @@ -43,7 +43,7 @@ public class JobsInspectJobTable extends PluginData { } return parseContainer("", html.toString()); } - } catch (NullPointerException e) { + } catch (NullPointerException ignored) { } return parseContainer("", Html.TABLELINE_2.parse("No Jobs.", "")); } diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansBansTable.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansBansTable.java index 1d8014a86..19076e8d0 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansBansTable.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansBansTable.java @@ -1,10 +1,5 @@ package com.djrapitops.pluginbridge.plan.litebans; -import java.io.Serializable; -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import java.util.UUID; import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.data.UserData; import main.java.com.djrapitops.plan.data.additional.AnalysisType; @@ -13,6 +8,12 @@ import main.java.com.djrapitops.plan.ui.html.Html; import main.java.com.djrapitops.plan.utilities.FormatUtils; import main.java.com.djrapitops.plan.utilities.HtmlUtils; +import java.io.Serializable; +import java.sql.SQLException; +import java.util.List; +import java.util.Map; +import java.util.UUID; + /** * PluginData class for LiteBans-plugin. * @@ -68,7 +69,7 @@ public class LiteBansBansTable extends PluginData { .replace("REPLACE0", Html.LINK.parse(HtmlUtils.getInspectUrl(name), name)) .replace("REPLACE1", Html.LINK.parse(HtmlUtils.getInspectUrl(ban.getBannedBy()), ban.getBannedBy())) .replace("REPLACE2", ban.getReason()) - .replace("REPLACE3", expiry <= 0 ? "0" : expiry + "") + .replace("REPLACE3", expiry <= 0 ? "0" : Long.toString(expiry)) .replace("REPLACE4", expires ) ); diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansDatabaseQueries.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansDatabaseQueries.java index 565c78090..0665223ef 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansDatabaseQueries.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansDatabaseQueries.java @@ -1,13 +1,14 @@ package com.djrapitops.pluginbridge.plan.litebans; +import litebans.api.Database; +import main.java.com.djrapitops.plan.database.tables.Table; + import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import java.util.UUID; -import litebans.api.Database; -import main.java.com.djrapitops.plan.database.tables.Table; /** * Class responsible for making queries to LiteBans database. @@ -15,36 +16,41 @@ import main.java.com.djrapitops.plan.database.tables.Table; * @author Rsl1122 * @since 3.5.0 */ -public class LiteBansDatabaseQueries extends Table{ +public class LiteBansDatabaseQueries extends Table { private final Database database; public LiteBansDatabaseQueries() { super("litebans", null, false); database = Database.get(); } - + public List getBans() throws SQLException { PreparedStatement statement = null; ResultSet set = null; try { statement = database.prepareStatement("SELECT uuid, reason, banned_by_name, until FROM litebans_bans"); set = statement.executeQuery(); - List bans = new ArrayList<>(); - while (set.next()) { - String uuidS = set.getString("uuid"); - UUID uuid = UUID.fromString(uuidS); - String reason = set.getString("reason"); - String bannedBy = set.getString("banned_by_name"); - long time = set.getLong("until"); - bans.add(new BanObject(uuid, reason, bannedBy, time)); - } + List bans = getBanObjects(set); return bans; } finally { close(set); close(statement); } } - + + private List getBanObjects(ResultSet set) throws SQLException { + List bans = new ArrayList<>(); + while (set.next()) { + String uuidS = set.getString("uuid"); + UUID uuid = UUID.fromString(uuidS); + String reason = set.getString("reason"); + String bannedBy = set.getString("banned_by_name"); + long time = set.getLong("until"); + bans.add(new BanObject(uuid, reason, bannedBy, time)); + } + return bans; + } + public List getBans(UUID playerUUID) throws SQLException { PreparedStatement statement = null; ResultSet set = null; @@ -52,15 +58,7 @@ public class LiteBansDatabaseQueries extends Table{ statement = database.prepareStatement("SELECT uuid, reason, banned_by_name, until FROM litebans_bans WHERE uuid=?"); statement.setString(1, playerUUID.toString()); set = statement.executeQuery(); - List bans = new ArrayList<>(); - while (set.next()) { - String uuidS = set.getString("uuid"); - UUID uuid = UUID.fromString(uuidS); - String reason = set.getString("reason"); - String bannedBy = set.getString("banned_by_name"); - long time = set.getLong("until"); - bans.add(new BanObject(uuid, reason, bannedBy, time)); - } + List bans = getBanObjects(set); return bans; } finally { close(set); @@ -68,6 +66,10 @@ public class LiteBansDatabaseQueries extends Table{ } } + /** + * @return false + * @deprecated Not in use. + */ @Override @Deprecated public boolean createTable() { diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansHook.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansHook.java index 0439683c1..49f77d0fc 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansHook.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansHook.java @@ -16,12 +16,12 @@ public class LiteBansHook extends Hook { /** * Hooks the plugin and registers it's PluginData objects. - * + *

* API#addPluginDataSource uses the same method from HookHandler. * * @param hookH HookHandler instance for registering the data sources. - * @see API * @throws NoClassDefFoundError when the plugin class can not be found. + * @see API */ @SuppressWarnings("ResultOfMethodCallIgnored") public LiteBansHook(HookHandler hookH) throws NoClassDefFoundError { @@ -29,7 +29,7 @@ public class LiteBansHook extends Hook { try { Database.get(); enabled = true; - } catch (Throwable e) { + } catch (NoSuchFieldError | NoSuchMethodError | Exception e) { enabled = false; } if (enabled) { diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansInspectBansTable.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansInspectBansTable.java index 7d5f1108a..895cd8a79 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansInspectBansTable.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansInspectBansTable.java @@ -1,13 +1,14 @@ package com.djrapitops.pluginbridge.plan.litebans; +import main.java.com.djrapitops.plan.data.additional.PluginData; +import main.java.com.djrapitops.plan.ui.html.Html; +import main.java.com.djrapitops.plan.utilities.FormatUtils; +import main.java.com.djrapitops.plan.utilities.HtmlUtils; + import java.io.Serializable; import java.sql.SQLException; import java.util.List; import java.util.UUID; -import main.java.com.djrapitops.plan.data.additional.PluginData; -import main.java.com.djrapitops.plan.ui.html.Html; -import main.java.com.djrapitops.plan.utilities.FormatUtils; -import main.java.com.djrapitops.plan.utilities.HtmlUtils; /** * PluginData class for LiteBans-plugin. @@ -55,7 +56,7 @@ public class LiteBansInspectBansTable extends PluginData { long expiry = ban.getExpiry(); String expires = expiry <= 0 ? "Never" : FormatUtils.formatTimeStampSecond(expiry); html.append(Html.TABLELINE_3_CUSTOMKEY_1.parse( - expiry <= 0 ? "0" : expiry + "", + expiry <= 0 ? "0" : Long.toString(expiry), expires, Html.LINK.parse(HtmlUtils.getInspectUrl(ban.getBannedBy()), ban.getBannedBy()), ban.getReason()) diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/mcmmo/McmmoAnalysisSkillTable.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/mcmmo/McmmoAnalysisSkillTable.java index ac852b5b6..c1efdbdcd 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/mcmmo/McmmoAnalysisSkillTable.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/mcmmo/McmmoAnalysisSkillTable.java @@ -4,25 +4,27 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.util.player.UserManager; -import java.io.Serializable; -import java.util.*; -import java.util.stream.Collectors; import main.java.com.djrapitops.plan.data.additional.AnalysisType; import main.java.com.djrapitops.plan.data.additional.PluginData; import main.java.com.djrapitops.plan.ui.html.Html; import main.java.com.djrapitops.plan.utilities.FormatUtils; import main.java.com.djrapitops.plan.utilities.analysis.MathUtils; import org.apache.commons.lang.StringUtils; + +import java.io.Serializable; +import java.util.*; +import java.util.stream.Collectors; + import static org.bukkit.Bukkit.getOnlinePlayers; /** * PluginData class for McMMO-plugin. - * + *

* Registered to the plugin by McmmoHook * * @author Rsl1122 - * @since 3.2.1 * @see McmmoHook + * @since 3.2.1 */ public class McmmoAnalysisSkillTable extends PluginData { @@ -57,7 +59,11 @@ public class McmmoAnalysisSkillTable extends PluginData { final StringBuilder html = new StringBuilder(); for (SkillType skill : skills) { long total = MathUtils.sumInt(profiles.stream().map(p -> (Serializable) p.getSkillLevel(skill))); - html.append(Html.TABLELINE_3.parse(StringUtils.capitalize(skill.getName().toLowerCase()), "" + total, FormatUtils.cutDecimals(MathUtils.average((int) total, profiles.size())))); + html.append(Html.TABLELINE_3.parse( + StringUtils.capitalize(skill.getName().toLowerCase()), + Long.toString(total), + FormatUtils.cutDecimals(MathUtils.average((int) total, profiles.size())) + )); } return parseContainer("", html.toString()); } diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/mcmmo/McmmoInspectSkillTable.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/mcmmo/McmmoInspectSkillTable.java index 96bafb88b..ff9ec90d7 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/mcmmo/McmmoInspectSkillTable.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/mcmmo/McmmoInspectSkillTable.java @@ -9,16 +9,18 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.util.player.UserManager; +import main.java.com.djrapitops.plan.Plan; +import main.java.com.djrapitops.plan.data.additional.PluginData; +import main.java.com.djrapitops.plan.ui.html.Html; +import org.apache.commons.lang.StringUtils; + import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.UUID; import java.util.stream.Collectors; -import main.java.com.djrapitops.plan.Plan; -import main.java.com.djrapitops.plan.data.additional.PluginData; -import main.java.com.djrapitops.plan.ui.html.Html; -import org.apache.commons.lang.StringUtils; + import static org.bukkit.Bukkit.getOfflinePlayer; /** @@ -59,7 +61,7 @@ public class McmmoInspectSkillTable extends PluginData { skills.addAll(Arrays.stream(SkillType.values()).distinct().collect(Collectors.toList())); final StringBuilder html = new StringBuilder(); for (SkillType skill : skills) { - html.append(Html.TABLELINE_2.parse(StringUtils.capitalize(skill.getName().toLowerCase()), "" + skillProfile.getSkillLevel(skill))); + html.append(Html.TABLELINE_2.parse(StringUtils.capitalize(skill.getName().toLowerCase()), skillProfile.getSkillLevel(skill))); } return parseContainer("", html.toString()); } diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/ontime/OntimeRefer.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/ontime/OntimeRefer.java index 63ec2d861..2a1f25914 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/ontime/OntimeRefer.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/ontime/OntimeRefer.java @@ -1,23 +1,24 @@ package com.djrapitops.pluginbridge.plan.ontime; -import java.io.Serializable; -import java.util.UUID; import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.data.UserData; import main.java.com.djrapitops.plan.data.additional.AnalysisType; import main.java.com.djrapitops.plan.data.additional.PluginData; import me.edge209.OnTime.OnTimeAPI; +import java.io.Serializable; +import java.util.UUID; + /** * PluginData class for Ontime-plugin. - * + *

* Registered to the plugin by OnTimeHook - * + *

* Gives Total Referral Integer as value. * * @author Rsl1122 - * @since 3.1.0 * @see OnTimeHook + * @since 3.1.0 */ public class OntimeRefer extends PluginData { @@ -42,7 +43,7 @@ public class OntimeRefer extends PluginData { if (referTotal == -1) { return parseContainer(modifierPrefix, "No Referrals."); } - return parseContainer(modifierPrefix, referTotal + ""); + return parseContainer(modifierPrefix, Long.toString(referTotal)); } @Override diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/ontime/OntimeReferMonth.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/ontime/OntimeReferMonth.java index 82b1a07c1..3c50d48a0 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/ontime/OntimeReferMonth.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/ontime/OntimeReferMonth.java @@ -1,13 +1,14 @@ package com.djrapitops.pluginbridge.plan.ontime; -import java.io.Serializable; -import java.util.UUID; import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.data.UserData; import main.java.com.djrapitops.plan.data.additional.AnalysisType; import main.java.com.djrapitops.plan.data.additional.PluginData; import me.edge209.OnTime.OnTimeAPI; +import java.io.Serializable; +import java.util.UUID; + /** * PluginData class for Ontime-plugin. * @@ -42,7 +43,7 @@ public class OntimeReferMonth extends PluginData { if (referTotal == -1) { return parseContainer(modifierPrefix, "No Referrals."); } - return parseContainer(modifierPrefix, referTotal + ""); + return parseContainer(modifierPrefix, Long.toString(referTotal)); } @Override diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/ontime/OntimeReferWeek.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/ontime/OntimeReferWeek.java index 1212fc6af..6b6e1aee0 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/ontime/OntimeReferWeek.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/ontime/OntimeReferWeek.java @@ -1,13 +1,14 @@ package com.djrapitops.pluginbridge.plan.ontime; -import java.io.Serializable; -import java.util.UUID; import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.data.UserData; import main.java.com.djrapitops.plan.data.additional.AnalysisType; import main.java.com.djrapitops.plan.data.additional.PluginData; import me.edge209.OnTime.OnTimeAPI; +import java.io.Serializable; +import java.util.UUID; + /** * PluginData class for Ontime-plugin. * @@ -42,7 +43,7 @@ public class OntimeReferWeek extends PluginData { if (referTotal == -1) { return parseContainer(modifierPrefix, "No Referrals."); } - return parseContainer(modifierPrefix, referTotal + ""); + return parseContainer(modifierPrefix, Long.toString(referTotal)); } @Override diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/ontime/OntimeVotes.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/ontime/OntimeVotes.java index a7849b058..8f18e78e1 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/ontime/OntimeVotes.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/ontime/OntimeVotes.java @@ -1,13 +1,14 @@ package com.djrapitops.pluginbridge.plan.ontime; -import java.io.Serializable; -import java.util.UUID; import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.data.UserData; import main.java.com.djrapitops.plan.data.additional.AnalysisType; import main.java.com.djrapitops.plan.data.additional.PluginData; import me.edge209.OnTime.OnTimeAPI; +import java.io.Serializable; +import java.util.UUID; + /** * PluginData class for Ontime-plugin. * @@ -42,7 +43,7 @@ public class OntimeVotes extends PluginData { if (votesTotal == -1) { return parseContainer(modifierPrefix, "No votes."); } - return parseContainer(modifierPrefix, votesTotal + ""); + return parseContainer(modifierPrefix, Long.toString(votesTotal)); } @Override diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/ontime/OntimeVotesMonth.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/ontime/OntimeVotesMonth.java index 98d6432d0..2c2f9c8d5 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/ontime/OntimeVotesMonth.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/ontime/OntimeVotesMonth.java @@ -1,13 +1,14 @@ package com.djrapitops.pluginbridge.plan.ontime; -import java.io.Serializable; -import java.util.UUID; import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.data.UserData; import main.java.com.djrapitops.plan.data.additional.AnalysisType; import main.java.com.djrapitops.plan.data.additional.PluginData; import me.edge209.OnTime.OnTimeAPI; +import java.io.Serializable; +import java.util.UUID; + /** * PluginData class for Ontime-plugin. * @@ -42,7 +43,7 @@ public class OntimeVotesMonth extends PluginData { if (votesTotal == -1) { return parseContainer(modifierPrefix, "No votes."); } - return parseContainer(modifierPrefix, votesTotal + ""); + return parseContainer(modifierPrefix, Long.toString(votesTotal)); } @Override diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/ontime/OntimeVotesWeek.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/ontime/OntimeVotesWeek.java index 676a8ec28..eb33f8b42 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/ontime/OntimeVotesWeek.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/ontime/OntimeVotesWeek.java @@ -1,13 +1,14 @@ package com.djrapitops.pluginbridge.plan.ontime; -import java.io.Serializable; -import java.util.UUID; import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.data.UserData; import main.java.com.djrapitops.plan.data.additional.AnalysisType; import main.java.com.djrapitops.plan.data.additional.PluginData; import me.edge209.OnTime.OnTimeAPI; +import java.io.Serializable; +import java.util.UUID; + /** * PluginData class for Ontime-plugin. * @@ -42,7 +43,7 @@ public class OntimeVotesWeek extends PluginData { if (votesTotal == -1) { return parseContainer(modifierPrefix, "No votes."); } - return parseContainer(modifierPrefix, votesTotal + ""); + return parseContainer(modifierPrefix, Long.toString(votesTotal)); } @Override diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/superbvote/SuperbVoteVotes.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/superbvote/SuperbVoteVotes.java index 0527749ca..f5b304911 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/superbvote/SuperbVoteVotes.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/superbvote/SuperbVoteVotes.java @@ -1,11 +1,12 @@ package com.djrapitops.pluginbridge.plan.superbvote; import io.minimum.minecraft.superbvote.storage.VoteStorage; -import java.io.Serializable; -import java.util.UUID; import main.java.com.djrapitops.plan.data.additional.AnalysisType; import main.java.com.djrapitops.plan.data.additional.PluginData; +import java.io.Serializable; +import java.util.UUID; + /** * PluginData class for GriefPrevention-plugin. * @@ -32,7 +33,7 @@ public class SuperbVoteVotes extends PluginData { @Override public String getHtmlReplaceValue(String modifierPrefix, UUID uuid) { int votes = store.getVotes(uuid); - return parseContainer(modifierPrefix, votes+""); + return parseContainer(modifierPrefix, Integer.toString(votes)); } @Override diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/towny/TownyTable.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/towny/TownyTable.java index 75852b9a3..7c7c1665e 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/towny/TownyTable.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/towny/TownyTable.java @@ -59,8 +59,8 @@ public class TownyTable extends PluginData { } else { mayor = "None"; } - String residents = t.getNumResidents() + ""; - String land = t.getPurchasedBlocks() + ""; + int residents = t.getNumResidents(); + int land = t.getPurchasedBlocks(); String leaderPage = Html.LINK.parse(HtmlUtils.getInspectUrl(mayor), mayor); html.append(Html.TABLELINE_4.parse(name, residents, land, leaderPage)); } diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/towny/TownyTown.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/towny/TownyTown.java index a1c1f1428..4a95667f5 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/towny/TownyTown.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/towny/TownyTown.java @@ -12,17 +12,19 @@ import java.util.UUID; /** * PluginData class for Towny-plugin. - * + *

* Registered to the plugin by TownyHook - * + *

* Gives Town name as String. * * @author Rsl1122 - * @since 3.1.0 * @see TownyHook + * @since 3.1.0 */ public class TownyTown extends PluginData { + private final String notInTown = "Not in a Town"; + /** * Class Constructor, sets the parameters of the PluginData object. */ @@ -37,7 +39,7 @@ public class TownyTown extends PluginData { public String getHtmlReplaceValue(String modifierPrefix, UUID uuid) { UserData data = Plan.getPlanAPI().getInspectCachedUserDataMap().get(uuid); if (data == null) { - return parseContainer(modifierPrefix, "Not in a Town"); + return parseContainer(modifierPrefix, notInTown); } String name = data.getName(); try { @@ -46,11 +48,11 @@ public class TownyTown extends PluginData { if (res.hasTown()) { town = res.getTown().getName(); } else { - town = "Not in a Town"; + town = notInTown; } return parseContainer("", town); } catch (NotRegisteredException ex) { - return parseContainer(modifierPrefix, "Not in a Town"); + return parseContainer(modifierPrefix, notInTown); } } @@ -58,7 +60,7 @@ public class TownyTown extends PluginData { public Serializable getValue(UUID uuid) { UserData data = Plan.getPlanAPI().getInspectCachedUserDataMap().get(uuid); if (data == null) { - return "Not in a Town"; + return notInTown; } String name = data.getName(); try { @@ -67,7 +69,7 @@ public class TownyTown extends PluginData { if (res.hasTown()) { town = res.getTown().getName(); } else { - town = "Not in a Town"; + town = notInTown; } return town; } catch (NotRegisteredException ex) { diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/vault/EconomyBalance.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/vault/EconomyBalance.java index 258f48cf4..4a903e277 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/vault/EconomyBalance.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/vault/EconomyBalance.java @@ -1,27 +1,29 @@ package com.djrapitops.pluginbridge.plan.vault; import com.djrapitops.pluginbridge.plan.FakeOfflinePlayer; -import java.io.Serializable; -import java.util.UUID; import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.data.UserData; import main.java.com.djrapitops.plan.data.additional.AnalysisType; import main.java.com.djrapitops.plan.data.additional.PluginData; import main.java.com.djrapitops.plan.utilities.FormatUtils; import net.milkbowl.vault.economy.Economy; -import static org.bukkit.Bukkit.getOfflinePlayer; import org.bukkit.OfflinePlayer; +import java.io.Serializable; +import java.util.UUID; + +import static org.bukkit.Bukkit.getOfflinePlayer; + /** * PluginData class for Vault-plugin. - * + *

* Registered to the plugin by VaultHook - * + *

* Gives Total Balance Double as value. * * @author Rsl1122 - * @since 3.1.0 * @see VaultHook + * @since 3.1.0 */ public class EconomyBalance extends PluginData { @@ -49,7 +51,7 @@ public class EconomyBalance extends PluginData { } OfflinePlayer p = new FakeOfflinePlayer(data); if (this.econ.hasAccount(p)) { - return parseContainer(modifierPrefix, this.econ.getBalance(p) + ""); + return parseContainer(modifierPrefix, Double.toString(this.econ.getBalance(p))); } return parseContainer(modifierPrefix, "0"); } diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/vault/PermGroupTable.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/vault/PermGroupTable.java index d65023a15..a91891949 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/vault/PermGroupTable.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/vault/PermGroupTable.java @@ -6,14 +6,12 @@ package com.djrapitops.pluginbridge.plan.vault; import com.djrapitops.plugin.utilities.Format; -import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.pluginbridge.plan.FakeOfflinePlayer; import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.data.additional.AnalysisType; import main.java.com.djrapitops.plan.data.additional.PluginData; import main.java.com.djrapitops.plan.ui.html.Html; import net.milkbowl.vault.permission.Permission; -import org.apache.commons.lang3.StringUtils; import org.bukkit.OfflinePlayer; import java.io.Serializable; @@ -65,12 +63,11 @@ public class PermGroupTable extends PluginData { groups.put(group, groups.get(group) + 1); } StringBuilder html = new StringBuilder(); - for (String group : groups.keySet()) { - if (Verify.notNull(group, groups.get(group))) { - String groupName = Format.create(group).capitalize().toString(); - String groupMembers = groups.get(group) + ""; - html.append(Html.TABLELINE_2.parse(StringUtils.capitalize(group), groups.get(group) + "")); - } + for (Map.Entry entry : groups.entrySet()) { + String group = entry.getKey(); + Integer members = entry.getValue(); + String groupName = Format.create(group).capitalize().toString(); + html.append(Html.TABLELINE_2.parse(groupName, members)); } return html.toString(); } diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/vault/VaultHook.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/vault/VaultHook.java index 680570a07..5ef237b5e 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/vault/VaultHook.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/vault/VaultHook.java @@ -1,10 +1,11 @@ package com.djrapitops.pluginbridge.plan.vault; import com.djrapitops.pluginbridge.plan.Hook; -import main.java.com.djrapitops.plan.data.additional.HookHandler; import main.java.com.djrapitops.plan.api.API; +import main.java.com.djrapitops.plan.data.additional.HookHandler; import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.permission.Permission; + import static org.bukkit.Bukkit.getServer; /** @@ -17,12 +18,12 @@ public class VaultHook extends Hook { /** * Hooks the plugin and registers it's PluginData objects. - * + *

* API#addPluginDataSource uses the same method from HookHandler. * * @param hookH HookHandler instance for registering the data sources. - * @see API * @throws NoClassDefFoundError when the plugin class can not be found. + * @see API */ public VaultHook(HookHandler hookH) throws NoClassDefFoundError { super("net.milkbowl.vault.Vault"); @@ -34,14 +35,14 @@ public class VaultHook extends Hook { Permission permSys = getServer().getServicesManager().getRegistration(Permission.class).getProvider(); hookH.addPluginDataSource(new PermGroup(permSys)); hookH.addPluginDataSource(new PermGroupTable(permSys)); - } catch (Throwable e) { + } catch (NoSuchFieldError | NoSuchMethodError | Exception e) { } - + try { Economy econ = getServer().getServicesManager().getRegistration(Economy.class).getProvider(); hookH.addPluginDataSource(new EconomyBalance(econ)); hookH.addPluginDataSource(new EconomyBalanceTable(econ)); - } catch (Throwable e) { + } catch (NoSuchFieldError | NoSuchMethodError | Exception e) { } } } diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/Protocol.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/Protocol.java index e69866abf..1c488cdf0 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/Protocol.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/Protocol.java @@ -12,6 +12,11 @@ package com.djrapitops.pluginbridge.plan.viaversion; */ public class Protocol { + + private Protocol() { + throw new IllegalStateException("Utility class"); + } + /** * http://wiki.vg/Protocol_version_numbers * @@ -20,6 +25,8 @@ public class Protocol { */ public static String getMCVersion(int protocolVersion) { switch (protocolVersion) { + case 338: + return "1.12.1"; case 335: return "1.12"; case 316: