Java Code Examples for com.imaginarycode.minecraft.redisbungee.RedisBungee#getApi()

The following examples show how to use com.imaginarycode.minecraft.redisbungee.RedisBungee#getApi() . 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: RedisPlayersOnlineSupplier.java    From Plan with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public int getAsInt() {
    RedisBungeeAPI api = RedisBungee.getApi();
    try {
        return api != null ? api.getPlayerCount() : -1;
    } catch (NullPointerException e) {
        return -1;
    }
}
 
Example 2
Source File: DiscordBot.java    From DiscordBot with Apache License 2.0 5 votes vote down vote up
private void loadRedis() {
	if (!DiscordBotCore.getInstance().getConfiguration().isRedisEnabled()) {
		return;
	}
	
	redisBungee = RedisBungee.getApi();
	redisBungee.registerPubSubChannels("DiscordBot");
	getProxy().getPluginManager().registerListener(this, new RedisListener());
	getLogger().info("Redis Enabled.");
}
 
Example 3
Source File: RedisBungeeCalculator.java    From LuckPerms with MIT License 5 votes vote down vote up
@Override
public void calculate(@NonNull ContextConsumer consumer) {
    RedisBungeeAPI redisBungee = RedisBungee.getApi();
    if (redisBungee != null) {
        consumer.accept(PROXY_KEY, redisBungee.getServerId());
    }
}
 
Example 4
Source File: RedisBungeeCalculator.java    From LuckPerms with MIT License 5 votes vote down vote up
@Override
public ContextSet estimatePotentialContexts() {
    RedisBungeeAPI redisBungee = RedisBungee.getApi();
    if (redisBungee == null) {
        return ImmutableContextSetImpl.EMPTY;
    }

    ImmutableContextSet.Builder builder = new ImmutableContextSetImpl.BuilderImpl();
    for (String server : redisBungee.getAllServers()) {
        builder.add(PROXY_KEY, server);
    }
    return builder.build();
}
 
Example 5
Source File: RedisUtils.java    From BungeeAdminTools with GNU General Public License v3.0 5 votes vote down vote up
public RedisUtils(final boolean enable) {
	if(enable){
		if (BAT.getInstance().getProxy().getPluginManager().getPlugin("RedisBungee") != null && RedisBungee.getApi() != null) {
		    BAT.getInstance().getLogger().info("Detected RedisBungee.  Enabling experimental RedisBungee support.  This currently only supports RedisBungee 0.3.3 or higher (but not 0.4).");
			BAT.getInstance().getProxy().getPluginManager()
				.registerListener(BAT.getInstance(), this);
		    	RedisBungee.getApi().registerPubSubChannels(channel);
		    	redis = true;
		} else {
		    redis = false;
		}
	}else{
		redis = false;
	}
}
 
Example 6
Source File: RedisBungeeMessenger.java    From LuckPerms with MIT License 4 votes vote down vote up
public void init() {
    this.redisBungee = RedisBungee.getApi();
    this.redisBungee.registerPubSubChannels(CHANNEL);

    this.plugin.getBootstrap().getProxy().getPluginManager().registerListener(this.plugin.getBootstrap(), this);
}