@Override public void write(DataOutput output, Icon icon) throws IOException { UUID uuid = icon.getPlayer(); output.writeBoolean(uuid != null); if (uuid != null) { DataStreamUtils.writeUUID(output, uuid); } for (String[] property : icon.getProperties()) { if (property.length == 3 && "textures".equals(property[0])) { output.writeUTF(property[1]); output.writeUTF(property[2]); return; } } output.writeUTF(""); output.writeUTF(""); } }
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); } }
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); } }