Added deprecated API class to main.java.com.djrapitops.plan

This commit is contained in:
Rsl1122 2018-01-18 11:59:39 +02:00
parent 1c488d50f8
commit 027db58a0a
2 changed files with 53 additions and 7 deletions

View File

@ -0,0 +1,29 @@
/*
* Licence is provided in the jar as license.yml also here:
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
*/
package main.java.com.djrapitops.plan;
import main.java.com.djrapitops.plan.api.API;
/**
* Older package version of Plan.
*
* @author Rsl1122
* @deprecated Use com.djrapitops.plan.Plan instead.
*/
@Deprecated
public class Plan {
/**
* Old method for getting old API.
*
* @return new instance of the old API object to not break old API.
* @deprecated Use PlanAPI.getInstance() instead as new API.
*/
@Deprecated
public static API getPlanAPI() {
return new API(com.djrapitops.plan.Plan.getInstance());
}
}

View File

@ -1,4 +1,4 @@
package com.djrapitops.plan.api; package main.java.com.djrapitops.plan.api;
import com.djrapitops.plan.Plan; import com.djrapitops.plan.Plan;
import com.djrapitops.plan.api.exceptions.ParseException; import com.djrapitops.plan.api.exceptions.ParseException;
@ -8,6 +8,7 @@ import com.djrapitops.plan.data.plugin.PluginData;
import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.database.databases.Database;
import com.djrapitops.plan.systems.info.BukkitInformationManager; import com.djrapitops.plan.systems.info.BukkitInformationManager;
import com.djrapitops.plan.utilities.uuid.UUIDUtility; import com.djrapitops.plan.utilities.uuid.UUIDUtility;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
@ -24,15 +25,14 @@ import static org.bukkit.Bukkit.getOfflinePlayer;
* Methods can be called from Asynchronous task and are thread safe unless * Methods can be called from Asynchronous task and are thread safe unless
* otherwise stated. * otherwise stated.
* <p> * <p>
* Use Plan.getPlanAPI() to get the API.
* <p>
* More information about API methods can be found on GitHub. * More information about API methods can be found on GitHub.
* *
* @author Rsl1122 * @author Rsl1122
* @see PluginData * @see PluginData
* @see AnalysisType
* @since 4.0.0 * @since 4.0.0
* @deprecated Old version of Plan API, use PlanAPI.getInstance() instead.
*/ */
@Deprecated
public class API { public class API {
private final Plan plugin; private final Plan plugin;
@ -51,6 +51,7 @@ public class API {
* *
* @return true if plugin is enabled correctly. * @return true if plugin is enabled correctly.
*/ */
@Deprecated
public boolean isEnabled() { public boolean isEnabled() {
return plugin.isEnabled(); return plugin.isEnabled();
} }
@ -66,6 +67,7 @@ public class API {
* Analysis and Inspect to manage the data of a plugin correctly. * Analysis and Inspect to manage the data of a plugin correctly.
* @see PluginData * @see PluginData
*/ */
@Deprecated
public void addPluginDataSource(PluginData dataSource) { public void addPluginDataSource(PluginData dataSource) {
if (isEnabled()) { if (isEnabled()) {
plugin.getHookHandler().addPluginDataSource(dataSource); plugin.getHookHandler().addPluginDataSource(dataSource);
@ -84,6 +86,7 @@ public class API {
* @param name Name of the player * @param name Name of the player
* @return {@code ../player/PlayerName} * @return {@code ../player/PlayerName}
*/ */
@Deprecated
public String getPlayerInspectPageLink(String name) { public String getPlayerInspectPageLink(String name) {
if (name == null) { if (name == null) {
return "#"; return "#";
@ -112,6 +115,7 @@ public class API {
* @param uuid UUID of the player. * @param uuid UUID of the player.
* @return true/false * @return true/false
*/ */
@Deprecated
public boolean isPlayerHtmlCached(UUID uuid) { public boolean isPlayerHtmlCached(UUID uuid) {
return plugin.getInfoManager().isCached(uuid); return plugin.getInfoManager().isCached(uuid);
} }
@ -136,6 +140,7 @@ public class API {
* @param uuid UUID of the player. * @param uuid UUID of the player.
* @deprecated use {@code cachePlayerHtml} * @deprecated use {@code cachePlayerHtml}
*/ */
@Deprecated
public void cachePlayerHtml(UUID uuid) { public void cachePlayerHtml(UUID uuid) {
plugin.getInfoManager().cachePlayer(uuid); plugin.getInfoManager().cachePlayer(uuid);
} }
@ -148,6 +153,7 @@ public class API {
* @param uuid UUID of the player. * @param uuid UUID of the player.
* @return player.html with all placeholders replaced. * @return player.html with all placeholders replaced.
*/ */
@Deprecated
public String getPlayerHtmlAsString(UUID uuid) throws ParseException { public String getPlayerHtmlAsString(UUID uuid) throws ParseException {
return plugin.getInfoManager().getPlayerHtml(uuid); return plugin.getInfoManager().getPlayerHtml(uuid);
} }
@ -157,6 +163,7 @@ public class API {
* *
* @return true/false * @return true/false
*/ */
@Deprecated
public boolean isAnalysisCached() { public boolean isAnalysisCached() {
return plugin.getInfoManager().isAnalysisCached(Plan.getServerUUID()); return plugin.getInfoManager().isAnalysisCached(Plan.getServerUUID());
} }
@ -164,6 +171,7 @@ public class API {
/** /**
* Run the analysis. * Run the analysis.
*/ */
@Deprecated
public void updateAnalysisCache() { public void updateAnalysisCache() {
plugin.getInfoManager().refreshAnalysis(plugin.getServerUuid()); plugin.getInfoManager().refreshAnalysis(plugin.getServerUuid());
} }
@ -176,6 +184,7 @@ public class API {
* @return server.html with all placeholders replaced. * @return server.html with all placeholders replaced.
* @throws NullPointerException if AnalysisData has not been cached. * @throws NullPointerException if AnalysisData has not been cached.
*/ */
@Deprecated
public String getAnalysisHtmlAsString() { public String getAnalysisHtmlAsString() {
return plugin.getInfoManager().getAnalysisHtml(); return plugin.getInfoManager().getAnalysisHtml();
} }
@ -188,6 +197,7 @@ public class API {
* @return AnalysisData object. * @return AnalysisData object.
* @see AnalysisData * @see AnalysisData
*/ */
@Deprecated
public AnalysisData getAnalysisDataFromCache() { public AnalysisData getAnalysisDataFromCache() {
return ((BukkitInformationManager) plugin.getInfoManager()).getAnalysisData(); return ((BukkitInformationManager) plugin.getInfoManager()).getAnalysisData();
} }
@ -201,12 +211,17 @@ public class API {
* @throws IllegalArgumentException If uuid is null. * @throws IllegalArgumentException If uuid is null.
* @throws IllegalStateException If the player has not played on the server before. * @throws IllegalStateException If the player has not played on the server before.
*/ */
@Deprecated
public String getPlayerName(UUID uuid) { public String getPlayerName(UUID uuid) {
Verify.nullCheck(uuid); Verify.nullCheck(uuid);
String playerName = plugin.getDB().getUsersTable().getPlayerName(uuid); try {
String playerName = Database.getActive().fetch().getPlayerName(uuid);
if (playerName != null) { if (playerName != null) {
return playerName; return playerName;
} }
} catch (DBException e) {
Log.toLog(API.class, e);
}
OfflinePlayer offlinePlayer = getOfflinePlayer(uuid); OfflinePlayer offlinePlayer = getOfflinePlayer(uuid);
if (offlinePlayer != null) { if (offlinePlayer != null) {
return offlinePlayer.getName(); return offlinePlayer.getName();
@ -234,6 +249,7 @@ public class API {
* @return UUID of the Player * @return UUID of the Player
* @throws IllegalArgumentException if player's name is not registered at Mojang * @throws IllegalArgumentException if player's name is not registered at Mojang
*/ */
@Deprecated
public UUID playerNameToUUID(String playerName) { public UUID playerNameToUUID(String playerName) {
UUID uuid = UUIDUtility.getUUIDOf(playerName); UUID uuid = UUIDUtility.getUUIDOf(playerName);
if (uuid == null) { if (uuid == null) {
@ -251,6 +267,7 @@ public class API {
* @throws SQLException If database error occurs. * @throws SQLException If database error occurs.
* @since 3.4.2 * @since 3.4.2
*/ */
@Deprecated
public Collection<UUID> getSavedUUIDs() { public Collection<UUID> getSavedUUIDs() {
try { try {
return Database.getActive().fetch().getSavedUUIDs(); return Database.getActive().fetch().getSavedUUIDs();