adjust plugin permissions, vault.update is now for displaying the update

messages, default is OP, all OPs (including console) will now see this
message.  override the permission to false if you don't want console
message, or want to set specific permission on specific players.
vault.admin now controls all commands, not op status.
This commit is contained in:
Nick Minkler 2013-12-24 12:36:51 -08:00
parent 041885e986
commit 7d6d695861
2 changed files with 31 additions and 33 deletions

View File

@ -20,3 +20,6 @@ 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

View File

@ -132,26 +132,26 @@ public class Vault extends JavaPlugin {
getCommand("vault-info").setExecutor(this);
getCommand("vault-convert").setExecutor(this);
getServer().getPluginManager().registerEvents(new VaultListener(), this);
if (getServer().getConsoleSender().hasPermission("vault.update")) {
// 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() {
// 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() {
@Override
public void run() {
try {
newVersion = updateCheck(currentVersion);
if (newVersion > currentVersion) {
log.warning("Vault " + newVersion + " is out! You are running: Vault " + currentVersion);
log.warning("Update Vault at: http://dev.bukkit.org/server-mods/vault");
@Override
public void run() {
try {
newVersion = updateCheck(currentVersion);
if (newVersion > currentVersion) {
log.warning("Vault " + newVersion + " is out! You are running: Vault " + currentVersion);
log.warning("Update Vault at: http://dev.bukkit.org/server-mods/vault");
}
} catch (Exception e) {
// ignore exceptions
}
} catch (Exception e) {
// ignore exceptions
}
}
}, 0, 432000);
}, 0, 432000);
}
// Load up the Plugin metrics
try {
metrics = new Metrics(this);
@ -381,13 +381,8 @@ public class Vault extends JavaPlugin {
@Override
public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {
if (sender instanceof Player) {
// Check if Player
// If so, ignore command if player is not Op
Player p = (Player) sender;
if (!p.isOp()) {
return true;
}
if (!sender.hasPermission("vault.admin")) {
sender.sendMessage("You do not have permission to use that command!");
}
if (command.getName().equalsIgnoreCase("vault-info")) {
@ -554,7 +549,7 @@ public class Vault extends JavaPlugin {
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
if (perms.has(player, "vault.admin")) {
if (perms.has(player, "vault.update")) {
try {
if (newVersion > currentVersion) {
player.sendMessage(newVersion + " is out! You are running " + currentVersion);