• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java RedisBungee类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.imaginarycode.minecraft.redisbungee.RedisBungee的典型用法代码示例。如果您正苦于以下问题:Java RedisBungee类的具体用法?Java RedisBungee怎么用?Java RedisBungee使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RedisBungee类属于com.imaginarycode.minecraft.redisbungee包,在下文中一共展示了RedisBungee类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: gKickSQL

import com.imaginarycode.minecraft.redisbungee.RedisBungee; //导入依赖的package包/类
public String gKickSQL(final UUID pUUID, final String staff, final String reason) {
	PreparedStatement statement = null;
	try (Connection conn = BAT.getConnection()) {
		if (DataSourceHandler.isSQLite()) {
			statement = conn.prepareStatement(fr.Alphart.BAT.database.SQLQueries.Kick.SQLite.kickPlayer);
		} else {
			statement = conn.prepareStatement(SQLQueries.Kick.kickPlayer);
		}
		statement.setString(1, pUUID.toString().replace("-", ""));
		statement.setString(2, staff);
		statement.setString(3, reason);
		statement.setString(4, GLOBAL_SERVER);
		statement.executeUpdate();
		statement.close();

		if (BAT.getInstance().getRedis().isRedisEnabled()) {
		    	return _("gKickBroadcast", new String[] { RedisBungee.getApi().getNameFromUuid(pUUID), staff, reason });
		} else {
			return _("gKickBroadcast", new String[] { BAT.getInstance().getProxy().getPlayer(pUUID).getName(), staff, reason });
		}
	} catch (final SQLException e) {
		return DataSourceHandler.handleException(e);
	} finally {
		DataSourceHandler.close(statement);
	}
}
 
开发者ID:alphartdev,项目名称:BungeeAdminTools,代码行数:27,代码来源:Kick.java


示例2: request

import com.imaginarycode.minecraft.redisbungee.RedisBungee; //导入依赖的package包/类
public <T> void request(UUID uuid, DataKey<T> key) {
    try {
        ByteArrayDataOutput data = ByteStreams.newDataOutput();
        DataStreamUtils.writeUUID(data, uuid);
        DataStreamUtils.writeDataKey(data, key);
        RedisBungee.getApi().sendChannelMessage(CHANNEL_DATA_REQUEST, Base64.getEncoder().encodeToString(data.toByteArray()));
        redisBungeeAPIError = false;
    } catch (RuntimeException ex) {
        if (!redisBungeeAPIError) {
            logger.log(Level.WARNING, "Error using RedisBungee API", ex);
            redisBungeeAPIError = true;
        }
    } catch (Throwable th) {
        BungeeTabListPlus.getInstance().getLogger().log(Level.SEVERE, "Failed to request data", th);
    }
}
 
开发者ID:CodeCrafter47,项目名称:BungeeTabListPlus,代码行数:17,代码来源:RedisPlayerManager.java


示例3: updateData

import com.imaginarycode.minecraft.redisbungee.RedisBungee; //导入依赖的package包/类
private <T> void updateData(UUID uuid, DataKey<T> key, T value) {
    try {
        ByteArrayDataOutput data = ByteStreams.newDataOutput();
        DataStreamUtils.writeUUID(data, uuid);
        DataStreamUtils.writeDataKey(data, key);
        data.writeBoolean(value == null);
        if (value != null) {
            typeRegistry.getTypeAdapter(key.getType()).write(data, value);
        }
        RedisBungee.getApi().sendChannelMessage(CHANNEL_DATA_UPDATE, Base64.getEncoder().encodeToString(data.toByteArray()));
    } catch (RuntimeException ex) {
        BungeeTabListPlus.getInstance().getLogger().log(Level.WARNING, "RedisBungee Error", ex);
    } catch (Throwable th) {
        BungeeTabListPlus.getInstance().getLogger().log(Level.SEVERE, "Failed to send data", th);
    }
}
 
开发者ID:CodeCrafter47,项目名称:BungeeTabListPlus,代码行数:17,代码来源:RedisPlayerManager.java


示例4: nameHistoryFromUuid

import com.imaginarycode.minecraft.redisbungee.RedisBungee; //导入依赖的package包/类
public static List<String> nameHistoryFromUuid(UUID uuid) throws IOException {
    String url = "https://api.mojang.com/user/profiles/" + uuid.toString().replace("-", "") + "/names";
    Request request = new Request.Builder().url(url).get().build();
    ResponseBody body = httpClient.newCall(request).execute().body();
    String response = body.string();
    body.close();

    Type listType = new TypeToken<List<Name>>() {
    }.getType();
    List<Name> names = RedisBungee.getGson().fromJson(response, listType);

    List<String> humanNames = new ArrayList<>();
    for (Name name : names) {
        humanNames.add(name.name);
    }
    return humanNames;
}
 
开发者ID:minecrafter,项目名称:RedisBungee,代码行数:18,代码来源:NameFetcher.java


示例5: call

import com.imaginarycode.minecraft.redisbungee.RedisBungee; //导入依赖的package包/类
public Map<String, UUID> call() throws Exception {
    Map<String, UUID> uuidMap = new HashMap<>();
    int requests = (int) Math.ceil(names.size() / PROFILES_PER_REQUEST);
    for (int i = 0; i < requests; i++) {
        String body = RedisBungee.getGson().toJson(names.subList(i * 100, Math.min((i + 1) * 100, names.size())));
        Request request = new Request.Builder().url(PROFILE_URL).post(RequestBody.create(JSON, body)).build();
        ResponseBody responseBody = httpClient.newCall(request).execute().body();
        String response = responseBody.string();
        responseBody.close();
        Profile[] array = RedisBungee.getGson().fromJson(response, Profile[].class);
        for (Profile profile : array) {
            UUID uuid = UUIDFetcher.getUUID(profile.id);
            uuidMap.put(profile.name, uuid);
        }
        if (rateLimiting && i != requests - 1) {
            Thread.sleep(100L);
        }
    }
    return uuidMap;
}
 
开发者ID:minecrafter,项目名称:RedisBungee,代码行数:21,代码来源:UUIDFetcher.java


示例6: loadRedis

import com.imaginarycode.minecraft.redisbungee.RedisBungee; //导入依赖的package包/类
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.");
}
 
开发者ID:LXGaming,项目名称:DiscordBot,代码行数:11,代码来源:DiscordBot.java


示例7: giveApplicableContext

import com.imaginarycode.minecraft.redisbungee.RedisBungee; //导入依赖的package包/类
@Nonnull
@Override
public MutableContextSet giveApplicableContext(@Nonnull MutableContextSet accumulator) {
    RedisBungeeAPI redisBungee = RedisBungee.getApi();
    if (redisBungee != null) {
        accumulator.add(PROXY_KEY, redisBungee.getServerId());
    }
    return accumulator;
}
 
开发者ID:lucko,项目名称:LuckPerms,代码行数:10,代码来源:RedisBungeeCalculator.java


示例8: onEnable

import com.imaginarycode.minecraft.redisbungee.RedisBungee; //导入依赖的package包/类
@Override
public void onEnable() {
    instance = this;
    Universal.get().setup(new BungeeMethods());

    ProxyServer.getInstance().getPluginManager().registerListener(this, new ConnectionListenerBungee());
    ProxyServer.getInstance().getPluginManager().registerListener(this, new ChatListenerBungee());
    ProxyServer.getInstance().getPluginManager().registerListener(this, new InternalListener());
    if (ProxyServer.getInstance().getPluginManager().getPlugin("RedisBungee") != null) {
        Universal.get().useRedis(true);
        ProxyServer.getInstance().getPluginManager().registerListener(this, new PubSubMessageListener());
        RedisBungee.getApi().registerPubSubChannels("AdvancedBan", "AdvancedBanConnection");
        ProxyServer.getInstance().getConsole().sendMessage("§cAdvancedBan §8» §7RedisBungee detected, hooking into it!");
    }
}
 
开发者ID:DevLeoko,项目名称:AdvancedBan,代码行数:16,代码来源:BungeeMain.java


示例9: onConnection

import com.imaginarycode.minecraft.redisbungee.RedisBungee; //导入依赖的package包/类
@EventHandler
public void onConnection(PreLoginEvent event) {
    String result = Universal.get().callConnection(event.getConnection().getName(), event.getConnection().getAddress().getAddress().getHostAddress());
    if (result != null) {
        event.setCancelled(true);
        event.setCancelReason(result);
    }
    if (Universal.get().useRedis()) {
        RedisBungee.getApi().sendChannelMessage("AdvancedBanConnection", event.getConnection().getName() + "," + event.getConnection().getAddress().getAddress().getHostAddress());
    }
}
 
开发者ID:DevLeoko,项目名称:AdvancedBan,代码行数:12,代码来源:ConnectionListenerBungee.java


示例10: isOnline

import com.imaginarycode.minecraft.redisbungee.RedisBungee; //导入依赖的package包/类
@Override
public boolean isOnline(String name) {
    try {
        if (Universal.get().useRedis()) {
            for (String str : RedisBungee.getApi().getHumanPlayersOnline()) {
                if (str.equalsIgnoreCase(name)) {
                    return RedisBungee.getApi().getPlayerIp(RedisBungee.getApi().getUuidFromName(str)) != null;
                }
            }
        }
        return ProxyServer.getInstance().getPlayer(name).getAddress() != null;
    } catch (NullPointerException exc) {
        return false;
    }
}
 
开发者ID:DevLeoko,项目名称:AdvancedBan,代码行数:16,代码来源:BungeeMethods.java


示例11: kickPlayer

import com.imaginarycode.minecraft.redisbungee.RedisBungee; //导入依赖的package包/类
@Override
public void kickPlayer(String player, String reason) {
    if (Universal.get().useRedis()) {
        RedisBungee.getApi().sendChannelMessage("AdvancedBan", "kick " + player + " " + reason);
    } else {
        ProxyServer.getInstance().getPlayer(player).disconnect(reason);
    }
}
 
开发者ID:DevLeoko,项目名称:AdvancedBan,代码行数:9,代码来源:BungeeMethods.java


示例12: notify

import com.imaginarycode.minecraft.redisbungee.RedisBungee; //导入依赖的package包/类
@Override
public void notify(String perm, List<String> notification) {
    if (Universal.get().useRedis()) {
        notification.forEach((str) -> {
            RedisBungee.getApi().sendChannelMessage("AdvancedBan", "notification " + perm + " " + str);
        });
    } else {
        ProxyServer.getInstance().getPlayers().stream().filter((pp) -> (hasPerms(pp, perm))).forEachOrdered((pp) -> {
            notification.forEach((str) -> {
                sendMessage(pp, str);
            });
        });
    }
}
 
开发者ID:DevLeoko,项目名称:AdvancedBan,代码行数:15,代码来源:BungeeMethods.java


示例13: RedisUtils

import com.imaginarycode.minecraft.redisbungee.RedisBungee; //导入依赖的package包/类
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;
	}
}
 
开发者ID:alphartdev,项目名称:BungeeAdminTools,代码行数:16,代码来源:RedisUtils.java


示例14: onPubSubMessage

import com.imaginarycode.minecraft.redisbungee.RedisBungee; //导入依赖的package包/类
@EventHandler
   public void onPubSubMessage(final PubSubMessageEvent e) {
if (!e.getChannel().equals(channel)) return;

String[] message = e.getMessage().split(split);

if (message[0].equalsIgnoreCase(RedisBungee.getApi().getServerId()) || message.length < 3) return;

String messageType = message[1];

switch (messageType) {
case "gkick":
    recieveGKickPlayer(message[2], message[3]);
    break;
case "message":
    recieveMessagePlayer(message[2], message[3]);
    break;
case "broadcast":
    recieveBroadcast(message[2], message[3]);
    break;
case "muteupdate":
	recieveMuteUpdatePlayer(message[2], message[3]);
	break;
case "movedefaultserver":
	recieveMoveDefaultServerPlayer(message[2]);
	break;
default:
    BAT.getInstance().getLogger().warning("Undeclared BungeeAdminTool redis message recieved: " + messageType);
    break;
}
   }
 
开发者ID:alphartdev,项目名称:BungeeAdminTools,代码行数:32,代码来源:RedisUtils.java


示例15: sendMessage

import com.imaginarycode.minecraft.redisbungee.RedisBungee; //导入依赖的package包/类
void sendMessage(String messageType, String messageBody) {
if (!redis) return;

       if (messageBody.trim().length() == 0) return;
       
       final String message = RedisBungee.getApi().getServerId() + split + messageType + split + messageBody;
       
       BAT.getInstance().getProxy().getScheduler().runAsync(BAT.getInstance(), new Runnable() {
           @Override
           public void run() {
               RedisBungee.getApi().sendChannelMessage(channel, message);
           }
       });
   }
 
开发者ID:alphartdev,项目名称:BungeeAdminTools,代码行数:15,代码来源:RedisUtils.java


示例16: banRedisIP

import com.imaginarycode.minecraft.redisbungee.RedisBungee; //导入依赖的package包/类
public String banRedisIP(final UUID pUUID, final String server, final String staff,
		final long expirationTimestamp, final String reason) {
    	if (BAT.getInstance().getRedis().isRedisEnabled() && RedisBungee.getApi().isPlayerOnline(pUUID)) {
    	    	ban(RedisBungee.getApi().getPlayerIp(pUUID).getHostAddress(), server, staff, expirationTimestamp, reason);
		return _("banBroadcast", new String[] { RedisBungee.getApi().getNameFromUuid(pUUID) + "'s IP", staff, server, reason });
    	} else {
    	    	return null;
    	}
    	    
}
 
开发者ID:alphartdev,项目名称:BungeeAdminTools,代码行数:11,代码来源:Ban.java


示例17: getPlayerIP

import com.imaginarycode.minecraft.redisbungee.RedisBungee; //导入依赖的package包/类
public static String getPlayerIP(final String pName) {
        if (BAT.getInstance().getRedis().isRedisEnabled()) {
            try {
            	final UUID pUUID = RedisBungee.getApi().getUuidFromName(pName, true);
            	if (pUUID != null && RedisBungee.getApi().isPlayerOnline(pUUID))
            	    return RedisBungee.getApi().getPlayerIp(pUUID).getHostAddress();
            } catch (Exception exp) {
        	exp.printStackTrace();
            }
        } else {
            	final ProxiedPlayer player = ProxyServer.getInstance().getPlayer(pName);
            	if (player != null) return Utils.getPlayerIP(player);
        }

	PreparedStatement statement = null;
	ResultSet resultSet = null;
	try (Connection conn = BAT.getConnection()) {
		statement = conn.prepareStatement(SQLQueries.Core.getIP);
		statement.setString(1, getUUID(pName));
		resultSet = statement.executeQuery();
		if (resultSet.next()) {
			return resultSet.getString("lastip");
		}
	} catch (final SQLException e) {
		DataSourceHandler.handleException(e);
	} finally {
		DataSourceHandler.close(statement, resultSet);
	}
	return "0.0.0.0";
}
 
开发者ID:alphartdev,项目名称:BungeeAdminTools,代码行数:31,代码来源:Core.java


示例18: LocalPlayerDataAccess

import com.imaginarycode.minecraft.redisbungee.RedisBungee; //导入依赖的package包/类
public LocalPlayerDataAccess(Plugin plugin, Logger logger) {
    super(plugin, logger);

    addProvider(BTLPBungeeDataKeys.DATA_KEY_GAMEMODE, p -> ((UserConnection) p).getGamemode());
    addProvider(BTLPBungeeDataKeys.DATA_KEY_ICON, BungeeTabListPlusAPI::getIconFromPlayer);

    if (ProxyServer.getInstance().getPluginManager().getPlugin("RedisBungee") != null) {
        addProvider(BTLPBungeeDataKeys.DATA_KEY_RedisBungee_ServerId, player -> {
            return RedisBungee.getApi().getServerId();
        });
    }
}
 
开发者ID:CodeCrafter47,项目名称:BungeeTabListPlus,代码行数:13,代码来源:DataManager.java


示例19: RedisPlayerManager

import com.imaginarycode.minecraft.redisbungee.RedisBungee; //导入依赖的package包/类
public RedisPlayerManager(ConnectedPlayerManager connectedPlayerManager, BungeeTabListPlus plugin, Logger logger) {
    this.connectedPlayerManager = connectedPlayerManager;
    this.plugin = plugin;
    this.logger = logger;
    RedisBungee.getApi().registerPubSubChannels(CHANNEL_REQUEST_DATA_OLD, CHANNEL_DATA_OLD);
    RedisBungee.getApi().registerPubSubChannels(CHANNEL_DATA_REQUEST, CHANNEL_DATA_UPDATE);
    ProxyServer.getInstance().getScheduler().schedule(BungeeTabListPlus.getInstance().getPlugin(), this::updatePlayers, 1, 1, TimeUnit.SECONDS);
    ProxyServer.getInstance().getPluginManager().registerListener(BungeeTabListPlus.getInstance().getPlugin(), this);
}
 
开发者ID:CodeCrafter47,项目名称:BungeeTabListPlus,代码行数:10,代码来源:RedisPlayerManager.java


示例20: getServer

import com.imaginarycode.minecraft.redisbungee.RedisBungee; //导入依赖的package包/类
@Override
public Optional<ServerInfo> getServer() {
    try {
        if (server == null || System.currentTimeMillis() - lastServerLookup > 1000) {
            server = RedisBungee.getApi().getServerFor(uuid);
            lastServerLookup = System.currentTimeMillis();
        }
    } catch (RuntimeException ex) {
        BungeeTabListPlus.getInstance().getLogger().log(Level.WARNING, "Error while trying to fetch the server of a player from RedisBungee", ex);
    }
    return Optional.ofNullable(server);
}
 
开发者ID:CodeCrafter47,项目名称:BungeeTabListPlus,代码行数:13,代码来源:RedisPlayer.java



注:本文中的com.imaginarycode.minecraft.redisbungee.RedisBungee类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CreateBeamUrisCallback类代码示例发布时间:2022-05-22
下一篇:
Java BlockTargetPair类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap