This commit is contained in:
Fuzzlemann 2017-08-17 20:40:25 +02:00
commit b4e1014d59
34 changed files with 201 additions and 216 deletions

View File

@ -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<Hook> clazz = (Class<Hook>) Hook.class.forName(className);
clazz.getConstructor(DataCacheHandler.class).newInstance(handler);
} catch (Exception | NoClassDefFoundError ignore) {
}
}
}
}

View File

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

View File

@ -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.
*
* <p>
* 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<? extends JavaPlugin> pluginClass = (Class<? extends JavaPlugin>) givenClass;
JavaPlugin hookedPlugin = getPlugin(pluginClass);
enabled = hookedPlugin.isEnabled();
} catch (Throwable e) {
} catch (NoClassDefFoundError | NoSuchFieldError | NoSuchMethodError | Exception e) {
enabled = false;
}
}

View File

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

View File

@ -14,14 +14,14 @@ import java.util.UUID;
/**
* PluginData class for AdvancedAchievements-plugin.
*
* <p>
* Registered to the plugin by AdvancedAchievementsHook
*
* <p>
* 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.
*
* <p>
* 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<UUID, UserData> 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<UUID, UserData> cachedUserData, StringBuilder html) {
Map<UUID, Integer> achievementsMap = aaAPI.getPlayersTotalAchievements();
for (UUID uuid : achievementsMap.keySet()) {
for (Map.Entry<UUID, Integer> 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;
}
}

View File

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

View File

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

View File

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

View File

@ -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());

View File

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

View File

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

View File

@ -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();

View File

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

View File

@ -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<String, Integer> 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());

View File

@ -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.", ""));
}

View File

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

View File

@ -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<BanObject> 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<BanObject> 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<BanObject> bans = getBanObjects(set);
return bans;
} finally {
close(set);
close(statement);
}
}
private List<BanObject> getBanObjects(ResultSet set) throws SQLException {
List<BanObject> 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<BanObject> 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<BanObject> 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<BanObject> 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() {

View File

@ -16,12 +16,12 @@ public class LiteBansHook extends Hook {
/**
* Hooks the plugin and registers it's PluginData objects.
*
* <p>
* 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) {

View File

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

View File

@ -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.
*
* <p>
* 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());
}

View File

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

View File

@ -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.
*
* <p>
* Registered to the plugin by OnTimeHook
*
* <p>
* 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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -12,17 +12,19 @@ import java.util.UUID;
/**
* PluginData class for Towny-plugin.
*
* <p>
* Registered to the plugin by TownyHook
*
* <p>
* 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) {

View File

@ -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.
*
* <p>
* Registered to the plugin by VaultHook
*
* <p>
* 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");
}

View File

@ -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<String, Integer> 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();
}

View File

@ -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.
*
* <p>
* 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) {
}
}
}

View File

@ -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: