mirror of
https://github.com/MilkBowl/Vault.git
synced 2024-11-27 04:55:33 +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
@ -20,6 +20,3 @@ permissions:
|
|||||||
vault.admin:
|
vault.admin:
|
||||||
description: Notifies the player when vault is in need of an update.
|
description: Notifies the player when vault is in need of an update.
|
||||||
default: op
|
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.Listener;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.server.PluginEnableEvent;
|
import org.bukkit.event.server.PluginEnableEvent;
|
||||||
|
import org.bukkit.permissions.PermissionDefault;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
import org.bukkit.plugin.ServicePriority;
|
import org.bukkit.plugin.ServicePriority;
|
||||||
@ -115,6 +116,7 @@ public class Vault extends JavaPlugin {
|
|||||||
private String currentVersionTitle = "";
|
private String currentVersionTitle = "";
|
||||||
private ServicesManager sm;
|
private ServicesManager sm;
|
||||||
private Metrics metrics;
|
private Metrics metrics;
|
||||||
|
private Vault plugin;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
@ -125,7 +127,8 @@ public class Vault extends JavaPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
currentVersionTitle = getDescription().getVersion().split("-")[0];
|
plugin = this;
|
||||||
|
currentVersionTitle = getDescription().getVersion().split("-")[0].replace("Vault", "").trim();
|
||||||
currentVersion = Double.valueOf(currentVersionTitle.replaceFirst("\\.", ""));
|
currentVersion = Double.valueOf(currentVersionTitle.replaceFirst("\\.", ""));
|
||||||
sm = getServer().getServicesManager();
|
sm = getServer().getServicesManager();
|
||||||
// Load Vault Addons
|
// Load Vault Addons
|
||||||
@ -138,7 +141,21 @@ public class Vault extends JavaPlugin {
|
|||||||
getServer().getPluginManager().registerEvents(new VaultListener(), this);
|
getServer().getPluginManager().registerEvents(new VaultListener(), this);
|
||||||
// Schedule to check the version every 30 minutes for an update. This is to update the most recent
|
// 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.
|
// 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() {
|
||||||
|
// 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");
|
||||||
|
|
||||||
|
getServer().getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -165,9 +182,12 @@ public class Vault extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}, 0, 432000);
|
}, 0, 432000);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
// Load up the Plugin metrics
|
// Load up the Plugin metrics
|
||||||
try {
|
try {
|
||||||
metrics = new Metrics(this);
|
metrics = new Metrics(this);
|
||||||
|
Loading…
Reference in New Issue
Block a user