4
4
import com .google .gson .JsonElement ;
5
5
import com .google .gson .JsonObject ;
6
6
7
- import org .bukkit .plugin .java .JavaPlugin ;
7
+ import org .bukkit .plugin .PluginBase ;
8
+ import org .bukkit .plugin .PluginDescriptionFile ;
8
9
9
10
import org .jetbrains .annotations .NotNull ;
10
11
import org .jetbrains .annotations .Nullable ;
@@ -32,9 +33,9 @@ public class AnnoyingUpdate extends Stringable implements Annoyable {
32
33
*/
33
34
@ NotNull private final AnnoyingPlugin annoyingPlugin ;
34
35
/**
35
- * The {@link JavaPlugin plugin} to check for updates
36
+ * The name of the plugin to check for updates
36
37
*/
37
- @ NotNull private final JavaPlugin plugin ;
38
+ @ NotNull private final String pluginName ;
38
39
/**
39
40
* The current version of the plugin
40
41
*/
@@ -55,14 +56,14 @@ public class AnnoyingUpdate extends Stringable implements Annoyable {
55
56
/**
56
57
* Creates a new {@link AnnoyingUpdate} object
57
58
*
58
- * @param annoyingPlugin {@link #annoyingPlugin}
59
- * @param plugin {@link #plugin }
60
- * @param platforms {@link #platforms}
59
+ * @param annoyingPlugin {@link #annoyingPlugin}
60
+ * @param pluginDescription {@link #pluginName} and {@link #currentVersion }
61
+ * @param platforms {@link #platforms}
61
62
*/
62
- public AnnoyingUpdate (@ NotNull AnnoyingPlugin annoyingPlugin , @ NotNull JavaPlugin plugin , @ NotNull PluginPlatform .Multi platforms ) {
63
+ public AnnoyingUpdate (@ NotNull AnnoyingPlugin annoyingPlugin , @ NotNull PluginDescriptionFile pluginDescription , @ NotNull PluginPlatform .Multi platforms ) {
63
64
this .annoyingPlugin = annoyingPlugin ;
64
- this .plugin = plugin ;
65
- this .currentVersion = new SemanticVersion (plugin . getDescription () .getVersion ());
65
+ this .pluginName = pluginDescription . getName () ;
66
+ this .currentVersion = new SemanticVersion (pluginDescription .getVersion ());
66
67
this .userAgent = annoyingPlugin .getName () + "/" + annoyingPlugin .getDescription ().getVersion () + " via Annoying API (update)" ;
67
68
this .platforms = platforms ;
68
69
final String latestVersionString = getLatestVersion ();
@@ -72,7 +73,18 @@ public AnnoyingUpdate(@NotNull AnnoyingPlugin annoyingPlugin, @NotNull JavaPlugi
72
73
/**
73
74
* Creates a new {@link AnnoyingUpdate} object
74
75
*
75
- * @param plugin {@link #annoyingPlugin} and {@link #plugin}
76
+ * @param annoyingPlugin {@link #annoyingPlugin}
77
+ * @param plugin {@link #pluginName} and {@link #currentVersion}
78
+ * @param platforms {@link #platforms}
79
+ */
80
+ public AnnoyingUpdate (@ NotNull AnnoyingPlugin annoyingPlugin , @ NotNull PluginBase plugin , @ NotNull PluginPlatform .Multi platforms ) {
81
+ this (annoyingPlugin , plugin .getDescription (), platforms );
82
+ }
83
+
84
+ /**
85
+ * Creates a new {@link AnnoyingUpdate} object
86
+ *
87
+ * @param plugin {@link #annoyingPlugin}, {@link #pluginName}, and {@link #currentVersion}
76
88
* @param platforms {@link #platforms}
77
89
*/
78
90
public AnnoyingUpdate (@ NotNull AnnoyingPlugin plugin , @ NotNull PluginPlatform .Multi platforms ) {
@@ -93,7 +105,7 @@ public AnnoyingPlugin getAnnoyingPlugin() {
93
105
public boolean checkUpdate () {
94
106
final boolean update = isUpdateAvailable ();
95
107
if (update && latestVersion != null ) new AnnoyingMessage (annoyingPlugin , annoyingPlugin .options .messagesOptions .keys .updateAvailable )
96
- .replace ("%plugin%" , plugin . getName () )
108
+ .replace ("%plugin%" , pluginName )
97
109
.replace ("%current%" , currentVersion .version )
98
110
.replace ("%new%" , latestVersion .version )
99
111
.log (Level .WARNING );
0 commit comments