mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-02-13 19:01:52 +01:00
Fix #35, implement prefix and suffix methods for VaultHandler
This commit is contained in:
parent
fa43f39015
commit
fe5de8a854
@ -1,6 +1,7 @@
|
||||
package com.earth2me.essentials.perm;
|
||||
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
@ -12,6 +13,7 @@ public class VaultHandler extends SuperpermsHandler {
|
||||
|
||||
private Essentials plugin;
|
||||
private static Permission perms = null;
|
||||
private static Chat chat = null;
|
||||
|
||||
public VaultHandler(Essentials plugin) {
|
||||
this.plugin = plugin;
|
||||
@ -24,9 +26,11 @@ public class VaultHandler extends SuperpermsHandler {
|
||||
return false;
|
||||
}
|
||||
|
||||
RegisteredServiceProvider<Permission> rsp = plugin.getServer().getServicesManager().getRegistration(Permission.class);
|
||||
perms = rsp.getProvider();
|
||||
return perms != null;
|
||||
RegisteredServiceProvider<Permission> permsProvider = plugin.getServer().getServicesManager().getRegistration(Permission.class);
|
||||
perms = permsProvider.getProvider();
|
||||
RegisteredServiceProvider<Chat> chatProvider = plugin.getServer().getServicesManager().getRegistration(Chat.class);
|
||||
chat = chatProvider.getProvider();
|
||||
return perms != null && chat != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -48,4 +52,26 @@ public class VaultHandler extends SuperpermsHandler {
|
||||
public boolean hasPermission(final Player base, String node) {
|
||||
return base.hasPermission(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrefix(final Player base) {
|
||||
String playerPrefix = chat.getPlayerPrefix(base);
|
||||
if (playerPrefix == null) {
|
||||
String playerGroup = perms.getPrimaryGroup(base);
|
||||
return chat.getGroupPrefix((String) null, playerGroup);
|
||||
} else {
|
||||
return playerPrefix;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSuffix(final Player base) {
|
||||
String playerSuffix = chat.getPlayerSuffix(base);
|
||||
if (playerSuffix == null) {
|
||||
String playerGroup = perms.getPrimaryGroup(base);
|
||||
return chat.getGroupSuffix((String) null, playerGroup);
|
||||
} else {
|
||||
return playerSuffix;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user