@Override public String apply(String template, SkinModel skin) { if (template == null) { return null; } int rowId = skin.getRowId(); UUID ownerId = skin.getProfileId(); String ownerName = skin.getProfileName(); long timeFetched = skin.getTimestamp(); Map<TextureType, TextureModel> textures = skin.getTextures(); Optional<TextureModel> skinTexture = Optional.ofNullable(textures.get(TextureType.SKIN)); Optional<TextureModel> capeTexture = Optional.ofNullable(textures.get(TextureType.CAPE)); String skinUrl = skinTexture.map(TextureModel::getShortUrl).orElse(""); String slimModel = skinTexture.map(TextureModel::isSlim).map(slim -> "Alex").orElse("Steve"); String capeUrl = capeTexture.map(TextureModel::getShortUrl).orElse(" - "); String timeFormat = timeFormatter.format(Instant.ofEpochMilli(timeFetched)); return template.replace("{0}", Integer.toString(rowId)) .replace("{1}", ownerId.toString()) .replace("{2}", ownerName) .replace("{3}", timeFormat) .replace("{4}", skinUrl) .replace("{5}", slimModel) .replace("{6}", capeUrl); } }
try (PreparedStatement stmt = con.prepareStatement("UPDATE " + USER_TABLE + " SET TargetSkin=? WHERE UserID=?")) { stmt.setInt(1, targetSkin.getRowId()); stmt.setInt(2, preferences.getRowId()); stmt.executeUpdate(); stmt.setInt(2, targetSkin.getRowId()); stmt.setBoolean(3, preferences.isKeepSkin());
@Override public void writeTo(ByteArrayDataOutput out) { out.writeBoolean(allowed); out.writeInt(skin.getRowId()); out.writeUTF(skin.getEncodedValue()); out.writeUTF(skin.getSignature()); out.writeUTF(receiverUUID.toString()); }
@Override public void writeTo(ByteArrayDataOutput out) { out.writeInt(targetSkin.getRowId()); out.writeUTF(targetSkin.getEncodedValue()); out.writeUTF(targetSkin.getSignature()); out.writeUTF(receiverUUD.toString()); out.writeBoolean(skinPerm); out.writeBoolean(isOp); }
@Override public void run() { UUID uuid = owner.getProfile().getId(); UUID accessToken = UUIDTypeAdapter.parseId(owner.getAccessToken()); core.getAuthApi().changeSkin(uuid, accessToken, url, false); //this could properly cause issues for uuid resolving to this database entry core.getSkinApi().downloadSkin(uuid).ifPresent(skinData -> { core.getStorage().save(skinData); String localeMessage = core.getMessage("skin-uploaded") .replace("{0}", owner.getProfile().getName()) .replace("{1}", "Skin-" + skinData.getRowId()); sendMessageInvoker(localeMessage); //revert to the old skin core.getAuthApi().changeSkin(uuid, accessToken, oldSkinUrl, false); }); }