use of com.sk89q.jnbt.CompoundTag in project FastAsyncWorldEdit by IntellectualSites.
the class BrushCache method getTool.
public static BrushTool getTool(Player player, LocalSession session, BaseItem item) {
if (!item.hasNbtData()) {
return null;
}
Object key = getKey(item);
if (key == null) {
return null;
}
BrushTool cached = brushCache.get(key);
if (cached != null) {
return cached;
}
CompoundTag nbt = item.getNbtData();
if (nbt == null) {
return null;
}
StringTag json = (StringTag) nbt.getValue().get("weBrushJson");
/* if (json != null) {
try {
if (RECURSION.get() != null) return null;
RECURSION.set(true);
BrushTool tool = BrushTool.fromString(player, session, json.getValue());
tool.setHolder(item);
brushCache.put(key, tool);
return tool;
} catch (Exception throwable) {
getLogger(BrushCache.class).debug("Invalid brush for " + player + " holding " + item.getType() + ": " + json.getValue(), throwable);
item.setNbtData(null);
brushCache.remove(key);
} finally {
RECURSION.remove();
}
}*/
return null;
}
use of com.sk89q.jnbt.CompoundTag in project FastAsyncWorldEdit by IntellectualSites.
the class BrushCache method setTool.
public static BrushTool setTool(BaseItem item, BrushTool tool) {
if (item.getNativeItem() == null) {
return null;
}
CompoundTag nbt = item.getNbtData();
Map<String, Tag> map;
if (nbt == null) {
if (tool == null) {
item.setNbtData(null);
return tool;
}
nbt = new CompoundTag(map = new HashMap<>());
} else {
map = nbt.getValue();
}
brushCache.remove(getKey(item));
CompoundTag display = (CompoundTag) map.get("display");
Map<String, Tag> displayMap;
return tool;
}
use of com.sk89q.jnbt.CompoundTag in project FastAsyncWorldEdit by IntellectualSites.
the class NbtValued method getNbtReference.
/**
* Get the object's NBT data (tile entity data).
*
* <p>
* This only needs to be used if you don't want to immediately resolve the data.
* Otherwise, you probably want {@link #getNbt()}.
* </p>
*
* @return compound tag, or null
*/
@NonAbstractForCompatibility(delegateName = "getNbtData", delegateParams = {})
@Nullable
default LazyReference<CompoundBinaryTag> getNbtReference() {
DeprecationUtil.checkDelegatingOverride(getClass());
CompoundTag nbtData = getNbtData();
return nbtData == null ? null : LazyReference.from(nbtData::asBinaryTag);
}
use of com.sk89q.jnbt.CompoundTag in project PlotSquared by IntellectualSites.
the class SchematicHandler method writeSchematicData.
private void writeSchematicData(@NonNull final Map<String, Tag> schematic, @NonNull final Map<String, Integer> palette, @NonNull final Map<String, Integer> biomePalette, @NonNull final List<CompoundTag> tileEntities, @NonNull final ByteArrayOutputStream buffer, @NonNull final ByteArrayOutputStream biomeBuffer) {
schematic.put("PaletteMax", new IntTag(palette.size()));
Map<String, Tag> paletteTag = new HashMap<>();
palette.forEach((key, value) -> paletteTag.put(key, new IntTag(value)));
schematic.put("Palette", new CompoundTag(paletteTag));
schematic.put("BlockData", new ByteArrayTag(buffer.toByteArray()));
schematic.put("BlockEntities", new ListTag(CompoundTag.class, tileEntities));
if (biomeBuffer.size() == 0 || biomePalette.size() == 0) {
return;
}
schematic.put("BiomePaletteMax", new IntTag(biomePalette.size()));
Map<String, Tag> biomePaletteTag = new HashMap<>();
biomePalette.forEach((key, value) -> biomePaletteTag.put(key, new IntTag(value)));
schematic.put("BiomePalette", new CompoundTag(biomePaletteTag));
schematic.put("BiomeData", new ByteArrayTag(biomeBuffer.toByteArray()));
}
Aggregations