/** * Not really a test. */ @Test public void checkStoredChunks() throws Exception { Jedis jedis = new Jedis("localhost"); Set<String> keys = jedis.keys("world:*"); for (String key : keys) { byte[] bytes = jedis.get(key.getBytes(UTF_8)); DataInputStream dataStream = new DataInputStream(new InflaterInputStream(new ByteArrayInputStream(bytes))); try { NBTTagCompound a = NBTCompressedStreamTools.a(dataStream); } catch (Exception e) { System.out.println("bad chunk at " + key + " (" + bytes.length + " bytes) : " + e); } } }
@Overridden ImmutableMap.Builder<String, Object> serialize(ImmutableMap.Builder<String, Object> builder) { if (hasDisplayName()) { builder.put(NAME.BUKKIT, displayName); } if (hasLore()) { builder.put(LORE.BUKKIT, ImmutableList.copyOf(lore)); } serializeEnchantments(enchantments, builder, ENCHANTMENTS); if (hasRepairCost()) { builder.put(REPAIR.BUKKIT, repairCost); } Set<String> hideFlags = new HashSet<String>(); for (ItemFlag hideFlagEnum : getItemFlags()) { hideFlags.add(hideFlagEnum.name()); } if (!hideFlags.isEmpty()) { builder.put(HIDEFLAGS.BUKKIT, hideFlags); } final Map<String, NBTBase> internalTags = new HashMap<String, NBTBase>(unhandledTags); serializeInternal(internalTags); if (!internalTags.isEmpty()) { NBTTagCompound internal = new NBTTagCompound(); for (Map.Entry<String, NBTBase> e : internalTags.entrySet()) { internal.set(e.getKey(), e.getValue()); } try { ByteArrayOutputStream buf = new ByteArrayOutputStream(); NBTCompressedStreamTools.a(internal, buf); builder.put("internal", Base64.encodeBase64String(buf.toByteArray())); } catch (IOException ex) { Logger.getLogger(CraftMetaItem.class.getName()).log(Level.SEVERE, null, ex); } } return builder; }
@Overridden ImmutableMap.Builder<String, Object> serialize(ImmutableMap.Builder<String, Object> builder) { if (hasDisplayName()) { builder.put(NAME.BUKKIT, displayName); } if (hasLore()) { builder.put(LORE.BUKKIT, ImmutableList.copyOf(lore)); } serializeEnchantments(enchantments, builder, ENCHANTMENTS); if (hasRepairCost()) { builder.put(REPAIR.BUKKIT, repairCost); } // Spigot start if ( spigot.isUnbreakable() ) { builder.put( UNBREAKABLE.BUKKIT, true ); } // Spigot end Set<String> hideFlags = new HashSet<String>(); for (ItemFlag hideFlagEnum : getItemFlags()) { hideFlags.add(hideFlagEnum.name()); } if (!hideFlags.isEmpty()) { builder.put(HIDEFLAGS.BUKKIT, hideFlags); } final Map<String, NBTBase> internalTags = new HashMap<String, NBTBase>(unhandledTags); serializeInternal(internalTags); if (!internalTags.isEmpty()) { NBTTagCompound internal = new NBTTagCompound(); for (Map.Entry<String, NBTBase> e : internalTags.entrySet()) { internal.set(e.getKey(), e.getValue()); } try { ByteArrayOutputStream buf = new ByteArrayOutputStream(); NBTCompressedStreamTools.a(internal, buf); builder.put("internal", Base64.encodeBase64String(buf.toByteArray())); } catch (IOException ex) { Logger.getLogger(CraftMetaItem.class.getName()).log(Level.SEVERE, null, ex); } } return builder; }