mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-04-25 07:59:44 +00:00
Fix #35, implement prefix and suffix methods for VaultHandler
This commit is contained in:
parent
fa43f39015
commit
fe5de8a854
1 changed files with 29 additions and 3 deletions
|
@ -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 a new issue