generated from srnyx/plugin-template
-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
AnnoyingDependency.java
60 lines (53 loc) · 2.07 KB
/
AnnoyingDependency.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package xyz.srnyx.annoyingapi.dependency;
import org.bukkit.Bukkit;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.util.Map;
/**
* Represents a downloadable dependency
*/
public class AnnoyingDependency {
/**
* The name of the dependency (from it's {@code plugin.yml})
*/
@NotNull public final String name;
/**
* The platforms the dependency can be downloaded from
*/
@NotNull public final Map<AnnoyingDownload.Platform, String> platforms;
/**
* Whether the dependency is required to be installed
*/
public final boolean required;
/**
* Whether to attempt to enable the dependency after it has been downloaded
*/
public final boolean enableAfterDownload;
/**
* The new file of the dependency ({@link #name}{@code .jar})
*/
@NotNull public final File file;
/**
* Creates a new dependency instance
*
* @param name the name of the dependency (from it's {@code plugin.yml})
* @param platforms the platforms the dependency can be downloaded from
* @param required whether the dependency is required to be installed
* @param enableAfterDownload whether to attempt to enable the dependency after it has been downloaded
*/
public AnnoyingDependency(@NotNull String name, @NotNull Map<AnnoyingDownload.Platform, String> platforms, boolean required, boolean enableAfterDownload) {
this.name = name;
this.platforms = platforms;
this.required = required;
this.enableAfterDownload = enableAfterDownload;
this.file = new File(Bukkit.getUpdateFolderFile().getParentFile(), name + ".jar");
}
/**
* This uses {@link Bukkit#getPluginManager()} to check if the dependency isn't installed. So it's vital that {@link #name} is from the plugin's {@code plugin.yml}
*
* @return whether the dependency isn't currently installed
*/
public boolean isNotInstalled() {
return Bukkit.getPluginManager().getPlugin(name) == null;
}
}