From 1e2a2473b000c652e42d6327d6a8186e8e9d7dc5 Mon Sep 17 00:00:00 2001 From: montlikadani Date: Tue, 21 Jan 2020 17:30:29 +0100 Subject: [PATCH] Do not ignore deprecated and not used methods For developers are needed if not updating the Jobs --- src/main/java/com/gamingmesh/jobs/Jobs.java | 10 +-- .../jobs/Placeholders/Placeholder.java | 1 - .../gamingmesh/jobs/economy/PointsData.java | 70 +++++++++---------- .../com/gamingmesh/jobs/i18n/Language.java | 4 +- 4 files changed, 43 insertions(+), 42 deletions(-) diff --git a/src/main/java/com/gamingmesh/jobs/Jobs.java b/src/main/java/com/gamingmesh/jobs/Jobs.java index 93af3fba..6ddf80cc 100644 --- a/src/main/java/com/gamingmesh/jobs/Jobs.java +++ b/src/main/java/com/gamingmesh/jobs/Jobs.java @@ -271,10 +271,13 @@ public class Jobs extends JavaPlugin { return DBManager; } - private void setPointsDatabase() { - pointsDatabase = new PointsData(); - } + /** + * Gets the PointsData + * @deprecated Use {@link JobsPlayer#getPointsData()} + * @return {@link PointsData} + */ + @Deprecated public static PointsData getPointsData() { if (pointsDatabase == null) pointsDatabase = new PointsData(); @@ -857,7 +860,6 @@ public class Jobs extends JavaPlugin { setPermissionHandler(new PermissionHandler(this)); setPluginLogger(getLogger()); setJobsClassloader(); - setPointsDatabase(); setDBManager(); setLanguage(); setGUIManager(); diff --git a/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java b/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java index d30e97c1..1b4336ac 100644 --- a/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java +++ b/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java @@ -15,7 +15,6 @@ import com.gamingmesh.jobs.container.CurrencyType; import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.JobProgression; import com.gamingmesh.jobs.container.JobsPlayer; -import com.gamingmesh.jobs.container.PlayerPoints; import com.gamingmesh.jobs.stuff.TimeManage; public class Placeholder { diff --git a/src/main/java/com/gamingmesh/jobs/economy/PointsData.java b/src/main/java/com/gamingmesh/jobs/economy/PointsData.java index d0ea29ca..c04cee02 100644 --- a/src/main/java/com/gamingmesh/jobs/economy/PointsData.java +++ b/src/main/java/com/gamingmesh/jobs/economy/PointsData.java @@ -7,39 +7,39 @@ import com.gamingmesh.jobs.container.PlayerPoints; public class PointsData { -// @Deprecated -// public void addPlayer(UUID uuid) { -// Jobs.getPlayerManager().getJobsPlayer(uuid).getPointsData(); -// } -// -// @Deprecated -// public void addPlayer(UUID uuid, double points) { -// Jobs.getPlayerManager().getJobsPlayer(uuid).addPoints(points); -// } -// -// @Deprecated -// public void addPlayer(UUID uuid, double points, double total) { -// addPlayer(uuid, new PlayerPoints(points, total)); -// -// Jobs.getPlayerManager().getJobsPlayer(uuid).getPointsData().setPoints(points); -// Jobs.getPlayerManager().getJobsPlayer(uuid).getPointsData().setTotalPoints(total); -// } -// -// @Deprecated -// public void addPlayer(UUID uuid, PlayerPoints points) { -// PlayerPoints pi = Jobs.getPlayerManager().getJobsPlayer(uuid).getPointsData(); -// pi.setPoints(points.getCurrentPoints()); -// pi.setTotalPoints(points.getTotalPoints()); -// pi.setNewEntry(points.isNewEntry()); -// } -// -// @Deprecated -// public void addPoints(UUID uuid, Double points) { -// Jobs.getPlayerManager().getJobsPlayer(uuid).addPoints(points); -// } -// -// @Deprecated -// public PlayerPoints getPlayerPointsInfo(UUID uuid) { -// return Jobs.getPlayerManager().getJobsPlayer(uuid).getPointsData(); -// } + @Deprecated + public void addPlayer(UUID uuid) { + Jobs.getPlayerManager().getJobsPlayer(uuid).getPointsData(); + } + + @Deprecated + public void addPlayer(UUID uuid, double points) { + Jobs.getPlayerManager().getJobsPlayer(uuid).addPoints(points); + } + + @Deprecated + public void addPlayer(UUID uuid, double points, double total) { + addPlayer(uuid, new PlayerPoints(points, total)); + + Jobs.getPlayerManager().getJobsPlayer(uuid).getPointsData().setPoints(points); + Jobs.getPlayerManager().getJobsPlayer(uuid).getPointsData().setTotalPoints(total); + } + + @Deprecated + public void addPlayer(UUID uuid, PlayerPoints points) { + PlayerPoints pi = Jobs.getPlayerManager().getJobsPlayer(uuid).getPointsData(); + pi.setPoints(points.getCurrentPoints()); + pi.setTotalPoints(points.getTotalPoints()); + pi.setNewEntry(points.isNewEntry()); + } + + @Deprecated + public void addPoints(UUID uuid, Double points) { + Jobs.getPlayerManager().getJobsPlayer(uuid).addPoints(points); + } + + @Deprecated + public PlayerPoints getPlayerPointsInfo(UUID uuid) { + return Jobs.getPlayerManager().getJobsPlayer(uuid).getPointsData(); + } } diff --git a/src/main/java/com/gamingmesh/jobs/i18n/Language.java b/src/main/java/com/gamingmesh/jobs/i18n/Language.java index 4f2fa7e9..561b3759 100644 --- a/src/main/java/com/gamingmesh/jobs/i18n/Language.java +++ b/src/main/java/com/gamingmesh/jobs/i18n/Language.java @@ -97,7 +97,7 @@ public class Language { } } - if (variables.length > 0) + if (variables != null && variables.length > 0) for (int i = 0; i < variables.length; i++) { if (variables.length >= i + 2) msg = msg.replace(String.valueOf(variables[i]), String.valueOf(variables[i + 1])); @@ -164,7 +164,7 @@ public class Language { * @return the message */ public String getDefaultMessage(String key) { - return enlocale.contains(key) == true ? Colors(enlocale.getString(key)) : "Can't find locale"; + return enlocale.contains(key) ? Colors(enlocale.getString(key)) : "Can't find locale"; } /**