Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Vault support for prefix/suffix

  • Loading branch information...
commit 537e95eb0069eb361a3c17c504a8c1604bbe31b8 1 parent 00f22cc
@mbax mbax authored
Showing with 30 additions and 16 deletions.
  1. +29 −16 com/ensifera/animosity/craftirc/CraftIRC.java
  2. +1 −0  plugin.yml
View
45 com/ensifera/animosity/craftirc/CraftIRC.java
@@ -17,6 +17,8 @@
import java.util.Timer;
import java.util.TimerTask;
+import net.milkbowl.vault.chat.Chat;
+import net.milkbowl.vault.permission.Permission;
import net.minecraft.server.MinecraftServer;
import org.bukkit.ChatColor;
@@ -29,6 +31,7 @@
import org.bukkit.event.Event;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
+import org.bukkit.plugin.RegisteredServiceProvider;
// import org.bukkit.plugin.PluginLoader;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.config.Configuration;
@@ -69,6 +72,7 @@
private HashMap<Integer, ArrayList<ConfigurationNode>> channodes;
private HashMap<Integer, ArrayList<String>> channames;
protected HashMap<DualKey, String> chanTagMap;
+ protected Chat vault;
public void onEnable() {
try {
@@ -142,6 +146,15 @@ public void onEnable() {
// TODO: Not yet supported: Register custom "admins!" command alias
// this.getCommand("admins!").setAliases(Arrays.asList(this.cAdminsCmd()));
+ this.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
+ public void run() {
+ if(CraftIRC.this.getServer().getPluginManager().isPluginEnabled("Vault")){
+ CraftIRC.this.vault=((RegisteredServiceProvider<Chat>)getServer().getServicesManager().getRegistration(Chat.class)).getProvider();
+ }
+ }
+ });
+
+
setDebug(cDebug());
} catch (Exception e) {
e.printStackTrace();
@@ -751,26 +764,26 @@ protected String colorizeName(String name) {
}
protected String getPermPrefix(String world, String pl) {
- if (perms == null)
- return "";
- String group = perms.getGroup(world, pl);
- if (group == null)
- return "";
- String result = perms.getGroupPrefix(world, group);
- if (result == null)
- return "";
+ String result="";
+ if(this.vault!=null){
+ try{
+ result=vault.getPlayerPrefix(world, pl);
+ }catch (Exception e){
+
+ }
+ }
return colorizeName(result.replaceAll("&([0-9a-f])", "§$1"));
}
protected String getPermSuffix(String world, String pl) {
- if (perms == null)
- return "";
- String group = perms.getGroup(world, pl);
- if (group == null)
- return "";
- String result = perms.getGroupSuffix(world, group);
- if (result == null)
- return "";
+ String result="";
+ if(this.vault!=null){
+ try{
+ result=vault.getPlayerSuffix(world, pl);
+ }catch (Exception e){
+
+ }
+ }
return colorizeName(result.replaceAll("&([0-9a-f])", "§$1"));
}
View
1  plugin.yml
@@ -1,6 +1,7 @@
name: CraftIRC
main: com.ensifera.animosity.craftirc.CraftIRC
version: 2.13
+softdepend: [Vault]
commands:
irc:
description: Sends a message to all IRC channels
Please sign in to comment.
Something went wrong with that request. Please try again.