mirror of
https://github.com/MilkBowl/Vault.git
synced 2024-11-26 20:45:36 +01:00
programmatically set permissions because bukkit doesn't handle load
order startup plugin permissions properly when overriden in permissions.yml
This commit is contained in:
parent
25916757e5
commit
8f408a635b
@ -19,7 +19,4 @@ commands:
|
||||
permissions:
|
||||
vault.admin:
|
||||
description: Notifies the player when vault is in need of an update.
|
||||
default: op
|
||||
vault.update:
|
||||
description: Allows a user or the console to check for updates
|
||||
default: op
|
@ -92,6 +92,7 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.ServicePriority;
|
||||
@ -115,6 +116,7 @@ public class Vault extends JavaPlugin {
|
||||
private String currentVersionTitle = "";
|
||||
private ServicesManager sm;
|
||||
private Metrics metrics;
|
||||
private Vault plugin;
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
@ -125,7 +127,8 @@ public class Vault extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
currentVersionTitle = getDescription().getVersion().split("-")[0];
|
||||
plugin = this;
|
||||
currentVersionTitle = getDescription().getVersion().split("-")[0].replace("Vault", "").trim();
|
||||
currentVersion = Double.valueOf(currentVersionTitle.replaceFirst("\\.", ""));
|
||||
sm = getServer().getServicesManager();
|
||||
// Load Vault Addons
|
||||
@ -138,35 +141,52 @@ public class Vault extends JavaPlugin {
|
||||
getServer().getPluginManager().registerEvents(new VaultListener(), this);
|
||||
// Schedule to check the version every 30 minutes for an update. This is to update the most recent
|
||||
// version so if an admin reconnects they will be warned about newer versions.
|
||||
this.getServer().getScheduler().runTaskTimerAsynchronously(this, new Runnable() {
|
||||
this.getServer().getScheduler().runTask(this, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (getServer().getConsoleSender().hasPermission("vault.update")) {
|
||||
try {
|
||||
newVersion = updateCheck(currentVersion);
|
||||
log.info("***** Vault Version Checker ***** ");
|
||||
if (newVersion > currentVersion) {
|
||||
log.warning("Stable Version: " + newVersionTitle + " is out!");
|
||||
log.warning("Current Version: " + currentVersionTitle);
|
||||
log.warning("Update Vault at: http://dev.bukkit.org/server-mods/vault");
|
||||
} else if (currentVersion > newVersion) {
|
||||
log.info("Stable Version: " + newVersionTitle);
|
||||
log.info("Current Version: " + currentVersionTitle);
|
||||
log.info("You are on a development or experimental build, Happy testing!");
|
||||
} else {
|
||||
log.info("Stable Version: " + newVersionTitle);
|
||||
log.info("Current Version: " + currentVersionTitle);
|
||||
log.info("No new version available");
|
||||
}
|
||||
log.info("**********************************");
|
||||
} catch (Exception e) {
|
||||
// ignore exceptions
|
||||
}
|
||||
// Programmatically set the default permission value cause Bukkit doesn't handle plugin.yml properly for Load order STARTUP plugins
|
||||
org.bukkit.permissions.Permission perm = getServer().getPluginManager().getPermission("vault.update");
|
||||
if (perm == null)
|
||||
{
|
||||
perm = new org.bukkit.permissions.Permission("vault.update");
|
||||
perm.setDefault(PermissionDefault.OP);
|
||||
plugin.getServer().getPluginManager().addPermission(perm);
|
||||
}
|
||||
}
|
||||
perm.setDescription("Allows a user or the console to check for vault updates");
|
||||
|
||||
}, 0, 432000);
|
||||
getServer().getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (getServer().getConsoleSender().hasPermission("vault.update")) {
|
||||
try {
|
||||
newVersion = updateCheck(currentVersion);
|
||||
log.info("***** Vault Version Checker ***** ");
|
||||
if (newVersion > currentVersion) {
|
||||
log.warning("Stable Version: " + newVersionTitle + " is out!");
|
||||
log.warning("Current Version: " + currentVersionTitle);
|
||||
log.warning("Update Vault at: http://dev.bukkit.org/server-mods/vault");
|
||||
} else if (currentVersion > newVersion) {
|
||||
log.info("Stable Version: " + newVersionTitle);
|
||||
log.info("Current Version: " + currentVersionTitle);
|
||||
log.info("You are on a development or experimental build, Happy testing!");
|
||||
} else {
|
||||
log.info("Stable Version: " + newVersionTitle);
|
||||
log.info("Current Version: " + currentVersionTitle);
|
||||
log.info("No new version available");
|
||||
}
|
||||
log.info("**********************************");
|
||||
} catch (Exception e) {
|
||||
// ignore exceptions
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 0, 432000);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Load up the Plugin metrics
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user