net.milkbowl.vault.chat.Chat Java Examples

The following examples show how to use net.milkbowl.vault.chat.Chat. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VaultHookManager.java    From LuckPerms with MIT License 6 votes vote down vote up
/**
 * Registers the LuckPerms implementation of {@link Permission} and {@link Chat} with
 * the service manager.
 */
public void hook() {
    try {
        if (this.permission == null) {
            this.permission = new LuckPermsVaultPermission(this.plugin);
        }

        if (this.chat == null) {
            this.chat = new LuckPermsVaultChat(this.plugin, this.permission);
        }

        final ServicesManager sm = this.plugin.getBootstrap().getServer().getServicesManager();
        sm.register(Permission.class, this.permission, this.plugin.getBootstrap(), ServicePriority.High);
        sm.register(Chat.class, this.chat, this.plugin.getBootstrap(), ServicePriority.High);

    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #2
Source File: PluginHooks.java    From TAB with Apache License 2.0 5 votes vote down vote up
public static String Vault_getPrefix(ITabPlayer p) {
	try {
		return ((Chat)Vault_chat).getPlayerPrefix(p.getBukkitEntity());
	} catch (Exception e) {
		return Shared.errorManager.printError("", "Failed to get prefix of " + p.getName() + " using Vault", e);
	}
}
 
Example #3
Source File: PluginHooks.java    From TAB with Apache License 2.0 5 votes vote down vote up
public static String Vault_getSuffix(ITabPlayer p) {
	try {
		return ((Chat)Vault_chat).getPlayerSuffix(p.getBukkitEntity());
	} catch (Exception e) {
		return Shared.errorManager.printError("", "Failed to get suffix of " + p.getName() + " using Vault", e);
	}
}
 
Example #4
Source File: PluginHooks.java    From TAB with Apache License 2.0 5 votes vote down vote up
public static void Vault_loadProviders() {
	RegisteredServiceProvider<Economy> rspEconomy = Bukkit.getServicesManager().getRegistration(Economy.class);
	if (rspEconomy != null) Vault_economy = rspEconomy.getProvider();
	RegisteredServiceProvider<Permission> rspPermission = Bukkit.getServicesManager().getRegistration(Permission.class);
	if (rspPermission != null) Vault_permission = rspPermission.getProvider();
	RegisteredServiceProvider<Chat> rspChat = Bukkit.getServicesManager().getRegistration(Chat.class);
	if (rspChat != null) Vault_chat = rspChat.getProvider();
}
 
Example #5
Source File: VaultInvoker.java    From CloudNet with Apache License 2.0 5 votes vote down vote up
public static void invoke() {
    ServicesManager servicesManager = BukkitBootstrap.getPlugin(BukkitBootstrap.class).getServer().getServicesManager();

    Permission permission = new VaultPermissionImpl();

    servicesManager.register(Permission.class, permission, BukkitBootstrap.getPlugin(BukkitBootstrap.class), ServicePriority.Highest);
    servicesManager.register(Chat.class,
                             new VaultChatImpl(permission),
                             BukkitBootstrap.getPlugin(BukkitBootstrap.class),
                             ServicePriority.Highest);
}
 
Example #6
Source File: VaultHook.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("null")
@Override
protected boolean init() {
	economy = Bukkit.getServicesManager().getRegistration(Economy.class) == null ? null : Bukkit.getServicesManager().getRegistration(Economy.class).getProvider();
	chat = Bukkit.getServicesManager().getRegistration(Chat.class) == null ? null : Bukkit.getServicesManager().getRegistration(Chat.class).getProvider();
	permission = Bukkit.getServicesManager().getRegistration(Permission.class) == null ? null : Bukkit.getServicesManager().getRegistration(Permission.class).getProvider();
	return economy != null || chat != null || permission != null;
}
 
Example #7
Source File: VaultHookManager.java    From LuckPerms with MIT License 5 votes vote down vote up
/**
 * Unregisters the LuckPerms Vault hooks, if present.
 */
public void unhook() {
    final ServicesManager sm = this.plugin.getBootstrap().getServer().getServicesManager();

    if (this.permission != null) {
        sm.unregister(Permission.class, this.permission);
        this.permission = null;
    }

    if (this.chat != null) {
        sm.unregister(Chat.class, this.chat);
        this.chat = null;
    }
}
 
Example #8
Source File: VaultChatBridge.java    From LunaChat with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * vault-chatをロードする
 * @param plugin vaultのプラグインインスタンス
 * @return ロードしたブリッジのインスタンス
 */
public static VaultChatBridge load(Plugin plugin) {

    RegisteredServiceProvider<Chat> chatProvider =
            Bukkit.getServicesManager().getRegistration(Chat.class);
    if ( chatProvider != null ) {
        VaultChatBridge bridge = new VaultChatBridge();
        bridge.chatPlugin = chatProvider.getProvider();
        return bridge;
    }

    return null;
}
 
Example #9
Source File: UChat.java    From UltimateChat with GNU General Public License v3.0 4 votes vote down vote up
public Chat getVaultChat() {
    if (Vault && chat != null) {
        return this.chat;
    }
    return null;
}
 
Example #10
Source File: uChatAPI.java    From UltimateChat with GNU General Public License v3.0 4 votes vote down vote up
public Chat getVaultChat() {
    return UChat.get().getVaultChat();
}
 
Example #11
Source File: VaultUtils.java    From SkyWarsReloaded with GNU General Public License v3.0 4 votes vote down vote up
private boolean setupChat() {
    RegisteredServiceProvider<Chat> rsp = Bukkit.getServer().getServicesManager().getRegistration(Chat.class);
    chat = rsp.getProvider();
    return chat != null;
}
 
Example #12
Source File: VaultUtils.java    From SkyWarsReloaded with GNU General Public License v3.0 4 votes vote down vote up
public Chat getChat() {
	return chat;
}
 
Example #13
Source File: VaultBridge.java    From BungeePerms with GNU General Public License v3.0 4 votes vote down vote up
public void inject(Plugin plugin)
    {
        BungeePerms.getLogger().info("Injection of Bungeeperms into Vault");
        try
        {
            Vault v = (Vault) plugin;

            if (!v.isEnabled())
            {
                return;
            }

            //inject BungeePerms permissions
//            Method m = v.getClass().getDeclaredMethod("hookPermission", String.class, Class.class, ServicePriority.class, String[].class);
//            m.setAccessible(true);
//            m.invoke(v, "BungeePerms", Permission_BungeePerms.class, ServicePriority.Normal, new String[]
//             {
//                 "net.alpenblock.bungeeperms.platform.bukkit.BukkitPlugin"
//            });
//            
//            Field f = v.getClass().getDeclaredField("perms");
//            f.setAccessible(true);
//            f.set(v, Bukkit.getServicesManager().getRegistration(Permission.class).getProvider());
            
            Bukkit.getServer().getServicesManager().register(Permission.class, new Permission_BungeePerms(v), BukkitPlugin.getInstance(), ServicePriority.Highest);

            //inject BungeePerms chat
//            m = v.getClass().getDeclaredMethod("hookChat", String.class, Class.class, ServicePriority.class, String[].class);
//            m.setAccessible(true);
//            m.invoke(v, "BungeePerms", Chat_BungeePerms.class, ServicePriority.Normal, new String[]
//             {
//                 "net.alpenblock.bungeeperms.platform.bukkit.BukkitPlugin"
//            });
            
            Bukkit.getServer().getServicesManager().register(Chat.class, new Chat_BungeePerms(v, new Permission_BungeePerms(v)), BukkitPlugin.getInstance(), ServicePriority.Highest);
        }
        catch (Exception ex)
        {
            BungeePerms.getInstance().getDebug().log(ex);
        }
    }