Removed ThemePark dependency
This commit is contained in:
parent
6e4b8f6326
commit
d0f3045c34
4 changed files with 39 additions and 22 deletions
|
@ -8,6 +8,7 @@ import nl.sbdeveloper.themeparkplus.listeners.*;
|
|||
import nl.sbdeveloper.themeparkplus.managers.DBManager;
|
||||
import nl.sbdeveloper.themeparkplus.sbutils.UpdateManager;
|
||||
import nl.sbdeveloper.themeparkplus.sbutils.YamlFile;
|
||||
import nl.sbdeveloper.themeparkplus.util.ConfigUtil;
|
||||
import nl.sbdeveloper.themeparkplus.util.License;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -37,6 +38,8 @@ public final class ThemeParkPlus extends JavaPlugin {
|
|||
|
||||
private final int configVersion = 3;
|
||||
|
||||
private static boolean hasTPHook = false;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
|
@ -85,12 +88,6 @@ public final class ThemeParkPlus extends JavaPlugin {
|
|||
|
||||
new License(this, "TP", license);
|
||||
|
||||
if (Bukkit.getPluginManager().getPlugin("ThemePark") == null) {
|
||||
Bukkit.getLogger().severe("[ThemeParkPlus] Missing ThemePark! Please install it first.");
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Bukkit.getPluginManager().getPlugin("WorldEdit") == null) {
|
||||
Bukkit.getLogger().severe("[ThemeParkPlus] Missing WorldEdit! Please install it first.");
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
|
@ -115,24 +112,33 @@ public final class ThemeParkPlus extends JavaPlugin {
|
|||
|
||||
Bukkit.getLogger().info("[ThemeParkPlus] Loading listeners...");
|
||||
Bukkit.getPluginManager().registerEvents(new DirectionalGateListener(), this);
|
||||
Bukkit.getPluginManager().registerEvents(new FastpassListeners(), this); //TODO Detect if ThemePark is found.
|
||||
Bukkit.getPluginManager().registerEvents(new SignListeners(), this);
|
||||
Bukkit.getPluginManager().registerEvents(new MalfunctionListener(), this); //TODO Detect if ThemePark is found.
|
||||
Bukkit.getPluginManager().registerEvents(new WaitingTimeListener(), this);
|
||||
if (getSConfig().getFile().getBoolean("AntiFreerun.Enabled")) {
|
||||
Bukkit.getPluginManager().registerEvents(new AntiFreerunListener(), this);
|
||||
}
|
||||
|
||||
//TODO Detect if ThemePark is found.
|
||||
if (getSConfig().getFile().getBoolean("DiscordWebhook.Enabled")) {
|
||||
String URL = getSConfig().getFile().getString("DiscordWebhook.WebhookURL");
|
||||
if (URL != null) {
|
||||
Bukkit.getPluginManager().registerEvents(new StatusChangeListener(), this);
|
||||
if (Bukkit.getPluginManager().getPlugin("ThemePark") == null) {
|
||||
Bukkit.getLogger().severe("[ThemeParkPlus] Missing ThemePark! Some functions will not work without it!");
|
||||
} else {
|
||||
Bukkit.getLogger().severe("[ThemeParkPlus] Enabling ThemePark hook...");
|
||||
hasTPHook = true;
|
||||
}
|
||||
|
||||
Bukkit.getLogger().info("[ThemeParkPlus] Loading Discord webhook...");
|
||||
webhookURL = URL;
|
||||
} else {
|
||||
Bukkit.getLogger().severe("[ThemeParkPlus] Couldn't load the webhook builder! The URL is null.");
|
||||
if (hasTPHook) {
|
||||
Bukkit.getPluginManager().registerEvents(new FastpassListeners(), this);
|
||||
Bukkit.getPluginManager().registerEvents(new MalfunctionListener(), this);
|
||||
|
||||
if (getSConfig().getFile().getBoolean("DiscordWebhook.Enabled")) {
|
||||
String URL = getSConfig().getFile().getString("DiscordWebhook.WebhookURL");
|
||||
if (URL != null) {
|
||||
Bukkit.getPluginManager().registerEvents(new StatusChangeListener(), this);
|
||||
|
||||
Bukkit.getLogger().info("[ThemeParkPlus] Loading Discord webhook...");
|
||||
webhookURL = URL;
|
||||
} else {
|
||||
Bukkit.getLogger().severe("[ThemeParkPlus] Couldn't load the webhook builder! The URL is null.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -231,6 +237,10 @@ public final class ThemeParkPlus extends JavaPlugin {
|
|||
return spiGUI;
|
||||
}
|
||||
|
||||
public static boolean hasTPHook() {
|
||||
return hasTPHook;
|
||||
}
|
||||
|
||||
private boolean setupEconomy() {
|
||||
if (getServer().getPluginManager().getPlugin("Vault") == null) {
|
||||
return false;
|
||||
|
|
|
@ -194,7 +194,10 @@ public class TPPCMD implements CommandExecutor {
|
|||
}
|
||||
|
||||
private boolean giveFPTicketCommand(CommandSender sender, String[] args) {
|
||||
//TODO Detect if ThemePark is found.
|
||||
if (!ThemeParkPlus.hasTPHook()) {
|
||||
sender.sendMessage(ConfigUtil.getMessage("General.RequiresThemePark"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length == 2 && !(sender instanceof Player)) {
|
||||
sender.sendMessage(ConfigUtil.getMessage("General.NoPlayer"));
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package nl.sbdeveloper.themeparkplus.listeners;
|
||||
|
||||
import nl.iobyte.themepark.api.API;
|
||||
import nl.sbdeveloper.themeparkplus.ThemeParkPlus;
|
||||
import nl.sbdeveloper.themeparkplus.api.PlusAPI;
|
||||
import nl.sbdeveloper.themeparkplus.api.objects.WaitingRow;
|
||||
|
@ -36,13 +35,17 @@ public class SignListeners implements Listener {
|
|||
//Only check themeparkplus signs!
|
||||
if (!lines[0].equalsIgnoreCase("[ThemeParkPlus]")) return;
|
||||
|
||||
if (!ThemeParkPlus.hasTPHook()) {
|
||||
p.sendMessage(ConfigUtil.getMessage("General.RequiresThemePark"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!p.hasPermission("tpp.fastpass.create")) {
|
||||
p.sendMessage(ConfigUtil.getMessage("General.NoPermission"));
|
||||
return;
|
||||
}
|
||||
|
||||
//TODO Detect if ThemePark is found.
|
||||
if (!API.isAttraction(lines[2])) {
|
||||
if (!nl.iobyte.themepark.api.API.isAttraction(lines[2])) {
|
||||
p.sendMessage(ConfigUtil.getMessage("Fastpass.UnknownRide", Collections.singletonMap("ridename", e.getLine(2))));
|
||||
return;
|
||||
}
|
||||
|
@ -77,7 +80,7 @@ public class SignListeners implements Listener {
|
|||
|
||||
e.setLine(0, wrLineOne);
|
||||
e.setLine(1, wrLineTwo);
|
||||
e.setLine(2, ConfigUtil.makecolored(API.getAttraction(lines[2]).getName()));
|
||||
e.setLine(2, ConfigUtil.makecolored(nl.iobyte.themepark.api.API.getAttraction(lines[2]).getName()));
|
||||
e.setLine(3, "0 min.");
|
||||
|
||||
p.sendMessage(ConfigUtil.getMessage("WaitingRow.SignCreated"));
|
||||
|
|
|
@ -3,6 +3,7 @@ General:
|
|||
NoPlayer: '&cYou have to be a player to do this.'
|
||||
IncorrectAmount: '&cThis amount is incorrect.'
|
||||
IncorrectSign: '&cThis sign is incorrect. Please read the wiki for more information.'
|
||||
RequiresThemePark: '&cThis function requires ThemePark to work. Install it to use this function.'
|
||||
Gates:
|
||||
WrongDir: '&cYou can''t walk through this gate in that direction.'
|
||||
UnknownDir: '&cThis direction is unknown. Choose between: NORTH, SOUTH, EAST, WEST'
|
||||
|
|
Reference in a new issue