本文整理汇总了Java中com.imaginarycode.minecraft.redisbungee.RedisBungee类的典型用法代码示例。如果您正苦于以下问题:Java RedisBungee类的具体用法?Java RedisBungee怎么用?Java RedisBungee使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RedisBungee类属于com.imaginarycode.minecraft.redisbungee包,在下文中一共展示了RedisBungee类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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.");
}
示例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;
}
示例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!");
}
}
示例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());
}
}
示例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;
}
}
示例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);
}
}
示例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);
});
});
}
}
示例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;
}
}
示例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;
}
}
示例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);
}
});
}