From 2fb62f22c061921e205864fd0211b3e8c9200266 Mon Sep 17 00:00:00 2001 From: Ne0n x3r0 Date: Wed, 2 Jan 2013 12:28:44 -0800 Subject: [PATCH] Adding formal permissions support --- .../Ne0nx3r0/BetterAliasPlayerListener.java | 20 ++++++++++++------- plugin.yml | 10 ++++++++-- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/com/gmail/Ne0nx3r0/BetterAliasPlayerListener.java b/com/gmail/Ne0nx3r0/BetterAliasPlayerListener.java index 1aeb971..a3cf069 100644 --- a/com/gmail/Ne0nx3r0/BetterAliasPlayerListener.java +++ b/com/gmail/Ne0nx3r0/BetterAliasPlayerListener.java @@ -3,6 +3,7 @@ package com.gmail.Ne0nx3r0; import com.gmail.Ne0nx3r0.AliasManager.AliasManager; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -22,7 +23,6 @@ class BetterAliasPlayerListener implements Listener{ @EventHandler(priority = EventPriority.LOWEST) public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent e) { - String[] cmd = e.getMessage().substring(1).split(" "); if(aliasManager.isAliased(cmd[0])){ @@ -96,13 +96,19 @@ class BetterAliasPlayerListener implements Listener{ e.setCancelled(true); } } - else if(cmd[0].equalsIgnoreCase("bareload") && (e.getPlayer().isOp() || e.getPlayer().hasPermission("BetterAlias.reload"))) + + if(cmd[0].equalsIgnoreCase("bareload")) { - BetterAlias.aliasManager = new AliasManager(BetterAlias.self); - - e.getPlayer().sendMessage("BetterAlias reloaded!"); - - e.setCancelled(true); + if(e.getPlayer().isOp() || e.getPlayer().hasPermission("BetterAlias.reload")) + { + BetterAlias.aliasManager = new AliasManager(BetterAlias.self); + + e.getPlayer().sendMessage(ChatColor.GOLD+"BetterAlias reloaded!"); + } + else + { + e.getPlayer().sendMessage(ChatColor.RED+"You do not have permission to use /bareload (node: BetterAlias.reload)"); + } } } } \ No newline at end of file diff --git a/plugin.yml b/plugin.yml index 0b8679d..94ff3e8 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,5 +1,11 @@ name: BetterAlias main: com.gmail.Ne0nx3r0.BetterAlias -version: '0.4' +version: '0.4.1' database: false -description: Command alias system \ No newline at end of file +description: Command alias system +commands: + bareload: + description: Reloads the aliases.yml file +permissions: + BetterAlias.reload: + description: Allows reloading BetterAlias \ No newline at end of file