本文整理汇总了Java中com.sk89q.jnbt.LongTag类的典型用法代码示例。如果您正苦于以下问题:Java LongTag类的具体用法?Java LongTag怎么用?Java LongTag使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LongTag类属于com.sk89q.jnbt包,在下文中一共展示了LongTag类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fromNative
import com.sk89q.jnbt.LongTag; //导入依赖的package包/类
private static Tag fromNative(cn.nukkit.nbt.tag.Tag other) {
if (other instanceof cn.nukkit.nbt.tag.IntArrayTag) {
return fromNative((cn.nukkit.nbt.tag.IntArrayTag) other);
} else if (other instanceof cn.nukkit.nbt.tag.ListTag) {
return fromNative((cn.nukkit.nbt.tag.ListTag) other);
} else if (other instanceof cn.nukkit.nbt.tag.EndTag) {
return fromNative((cn.nukkit.nbt.tag.EndTag) other);
} else if (other instanceof cn.nukkit.nbt.tag.LongTag) {
return fromNative((cn.nukkit.nbt.tag.LongTag) other);
} else if (other instanceof cn.nukkit.nbt.tag.StringTag) {
return fromNative((cn.nukkit.nbt.tag.StringTag) other);
} else if (other instanceof cn.nukkit.nbt.tag.IntTag) {
return fromNative((cn.nukkit.nbt.tag.IntTag) other);
} else if (other instanceof cn.nukkit.nbt.tag.ByteTag) {
return fromNative((cn.nukkit.nbt.tag.ByteTag) other);
} else if (other instanceof cn.nukkit.nbt.tag.ByteArrayTag) {
return fromNative((cn.nukkit.nbt.tag.ByteArrayTag) other);
} else if (other instanceof cn.nukkit.nbt.tag.CompoundTag) {
return fromNative((cn.nukkit.nbt.tag.CompoundTag) other);
} else if (other instanceof cn.nukkit.nbt.tag.FloatTag) {
return fromNative((cn.nukkit.nbt.tag.FloatTag) other);
} else if (other instanceof cn.nukkit.nbt.tag.ShortTag) {
return fromNative((cn.nukkit.nbt.tag.ShortTag) other);
} else if (other instanceof cn.nukkit.nbt.tag.DoubleTag) {
return fromNative((cn.nukkit.nbt.tag.DoubleTag) other);
} else {
throw new IllegalArgumentException("Can't convert other of type " + other.getClass().getCanonicalName());
}
}
示例2: delete
import com.sk89q.jnbt.LongTag; //导入依赖的package包/类
public void delete(UndoContext context) {
Extent extent = context.getExtent();
ExtentTraverser<FastWorldEditExtent> find = new ExtentTraverser(extent).find(FastWorldEditExtent.class);
if (find != null) {
FastWorldEditExtent fwee = find.get();
Map<String, Tag> map = tag.getValue();
long most;
long least;
if (map.containsKey("UUIDMost")) {
most = ((LongTag) map.get("UUIDMost")).getValue();
least = ((LongTag) map.get("UUIDLeast")).getValue();
} else if (map.containsKey("PersistentIDMSB")) {
most = ((LongTag) map.get("PersistentIDMSB")).getValue();
least = ((LongTag) map.get("PersistentIDLSB")).getValue();
} else {
Fawe.debug("Skipping entity without uuid.");
return;
}
List<DoubleTag> pos = (List<DoubleTag>) map.get("Pos").getValue();
int x = MathMan.roundInt(pos.get(0).getValue());
int y = MathMan.roundInt(pos.get(1).getValue());
int z = MathMan.roundInt(pos.get(2).getValue());
UUID uuid = new UUID(most, least);
fwee.getQueue().removeEntity(x, y, z, uuid);
} else {
Fawe.debug("FAWE doesn't support: " + context + " for " + getClass() + " (bug Empire92)");
}
}
示例3: toNative
import com.sk89q.jnbt.LongTag; //导入依赖的package包/类
private Tag toNative(NBTBase foreign)
{
if (foreign == null) {
return null;
}
if ((foreign instanceof NBTTagCompound))
{
Map<String, Tag> values = new HashMap();
Set<String> foreignKeys = ((NBTTagCompound)foreign).c();
for (String str : foreignKeys)
{
NBTBase base = ((NBTTagCompound)foreign).get(str);
values.put(str, toNative(base));
}
return new CompoundTag(values);
}
if ((foreign instanceof NBTTagByte)) {
return new ByteTag(((NBTTagByte)foreign).f());
}
if ((foreign instanceof NBTTagByteArray)) {
return new ByteArrayTag(((NBTTagByteArray)foreign).c());
}
if ((foreign instanceof NBTTagDouble)) {
return new DoubleTag(((NBTTagDouble)foreign).g());
}
if ((foreign instanceof NBTTagFloat)) {
return new FloatTag(((NBTTagFloat)foreign).h());
}
if ((foreign instanceof NBTTagInt)) {
return new IntTag(((NBTTagInt)foreign).d());
}
if ((foreign instanceof NBTTagIntArray)) {
return new IntArrayTag(((NBTTagIntArray)foreign).c());
}
if ((foreign instanceof NBTTagList)) {
try
{
return toNativeList((NBTTagList)foreign);
}
catch (Throwable e)
{
this.logger.log(Level.WARNING, "Failed to convert NBTTagList", e);
return new ListTag(ByteTag.class, new ArrayList());
}
}
if ((foreign instanceof NBTTagLong)) {
return new LongTag(((NBTTagLong)foreign).c());
}
if ((foreign instanceof NBTTagShort)) {
return new ShortTag(((NBTTagShort)foreign).e());
}
if ((foreign instanceof NBTTagString)) {
return new StringTag(((NBTTagString)foreign).a_());
}
if ((foreign instanceof NBTTagEnd)) {
return new EndTag();
}
throw new IllegalArgumentException("Don't know how to make native " + foreign.getClass().getCanonicalName());
}
示例4: asTag
import com.sk89q.jnbt.LongTag; //导入依赖的package包/类
public static LongTag asTag(long value) {
return new LongTag(value);
}
示例5: parse
import com.sk89q.jnbt.LongTag; //导入依赖的package包/类
public Tag parse() throws NBTException {
try {
if (DOUBLE.matcher(this.jsonValue).matches()) {
return new DoubleTag(Double.parseDouble(this.jsonValue.substring(0, this.jsonValue.length() - 1)));
}
if (FLOAT.matcher(this.jsonValue).matches()) {
return new FloatTag(Float.parseFloat(this.jsonValue.substring(0, this.jsonValue.length() - 1)));
}
if (BYTE.matcher(this.jsonValue).matches()) {
return new ByteTag(Byte.parseByte(this.jsonValue.substring(0, this.jsonValue.length() - 1)));
}
if (LONG.matcher(this.jsonValue).matches()) {
return new LongTag(Long.parseLong(this.jsonValue.substring(0, this.jsonValue.length() - 1)));
}
if (SHORT.matcher(this.jsonValue).matches()) {
return new ShortTag(Short.parseShort(this.jsonValue.substring(0, this.jsonValue.length() - 1)));
}
if (INTEGER.matcher(this.jsonValue).matches()) {
return new IntTag(Integer.parseInt(this.jsonValue));
}
if (DOUBLE_UNTYPED.matcher(this.jsonValue).matches()) {
return new DoubleTag(Double.parseDouble(this.jsonValue));
}
if ("true".equalsIgnoreCase(this.jsonValue) || "false".equalsIgnoreCase(this.jsonValue)) {
return new ByteTag((byte) (Boolean.parseBoolean(this.jsonValue) ? 1 : 0));
}
} catch (NumberFormatException var6) {
this.jsonValue = this.jsonValue.replaceAll("\\\\\"", "\"");
return new StringTag(this.jsonValue);
}
if (this.jsonValue.startsWith("[") && this.jsonValue.endsWith("]")) {
String var7 = this.jsonValue.substring(1, this.jsonValue.length() - 1);
String[] var8 = (String[]) ((String[]) Iterables.toArray(SPLITTER.split(var7), String.class));
try {
int[] var5 = new int[var8.length];
for (int j = 0; j < var8.length; ++j) {
var5[j] = Integer.parseInt(var8[j].trim());
}
return new IntArrayTag(var5);
} catch (NumberFormatException var51) {
return new StringTag(this.jsonValue);
}
} else {
if (this.jsonValue.startsWith("\"") && this.jsonValue.endsWith("\"")) {
this.jsonValue = this.jsonValue.substring(1, this.jsonValue.length() - 1);
}
this.jsonValue = this.jsonValue.replaceAll("\\\\\"", "\"");
StringBuilder stringbuilder = new StringBuilder();
for (int i = 0; i < this.jsonValue.length(); ++i) {
if (i < this.jsonValue.length() - 1 && this.jsonValue.charAt(i) == 92 && this.jsonValue.charAt(i + 1) == 92) {
stringbuilder.append('\\');
++i;
} else {
stringbuilder.append(this.jsonValue.charAt(i));
}
}
return new StringTag(stringbuilder.toString());
}
}
示例6: toNative
import com.sk89q.jnbt.LongTag; //导入依赖的package包/类
/**
* Converts from a non-native NMS NBT structure to a native WorldEdit NBT
* structure.
*
* @param foreign non-native NMS NBT structure
* @return native WorldEdit NBT structure
*/
@SuppressWarnings("unchecked")
private Tag toNative(NBTBase foreign) {
if (foreign == null) {
return null;
}
if (foreign instanceof NBTTagCompound) {
Map<String, Tag> values = new HashMap<String, Tag>();
Set<String> foreignKeys = ((NBTTagCompound) foreign).c();
for (String str : foreignKeys) {
NBTBase base = ((NBTTagCompound) foreign).get(str);
values.put(str, toNative(base));
}
return new CompoundTag(values);
} else if (foreign instanceof NBTTagByte) {
return new ByteTag(((NBTTagByte) foreign).f()); // getByte
} else if (foreign instanceof NBTTagByteArray) {
return new ByteArrayTag(((NBTTagByteArray) foreign).c()); // data
} else if (foreign instanceof NBTTagDouble) {
return new DoubleTag(((NBTTagDouble) foreign).g()); // getDouble
} else if (foreign instanceof NBTTagFloat) {
return new FloatTag(((NBTTagFloat) foreign).h()); // getFloat
} else if (foreign instanceof NBTTagInt) {
return new IntTag(((NBTTagInt) foreign).d()); // getInt
} else if (foreign instanceof NBTTagIntArray) {
return new IntArrayTag(((NBTTagIntArray) foreign).c()); // data
} else if (foreign instanceof NBTTagList) {
try {
return toNativeList((NBTTagList) foreign);
} catch (Throwable e) {
logger.log(Level.WARNING, "Failed to convert NBTTagList", e);
return new ListTag(ByteTag.class, new ArrayList<ByteTag>());
}
} else if (foreign instanceof NBTTagLong) {
return new LongTag(((NBTTagLong) foreign).c()); // getLong
} else if (foreign instanceof NBTTagShort) {
return new ShortTag(((NBTTagShort) foreign).e()); // getShort
} else if (foreign instanceof NBTTagString) {
return new StringTag(((NBTTagString) foreign).a_()); // data
} else if (foreign instanceof NBTTagEnd) {
return new EndTag();
} else {
throw new IllegalArgumentException("Don't know how to make native " + foreign.getClass().getCanonicalName());
}
}
示例7: toNative
import com.sk89q.jnbt.LongTag; //导入依赖的package包/类
/**
* Converts from a non-native NMS NBT structure to a native WorldEdit NBT
* structure.
*
* @param foreign non-native NMS NBT structure
* @return native WorldEdit NBT structure
*/
@SuppressWarnings("unchecked")
private Tag toNative(NBTBase foreign) {
if (foreign == null) {
return null;
}
if (foreign instanceof NBTTagCompound) {
Map<String, Tag> values = new HashMap<String, Tag>();
Collection<Object> foreignKeys = ((NBTTagCompound) foreign).c();
for (Object obj : foreignKeys) {
String key = (String) obj;
NBTBase base = ((NBTTagCompound) foreign).get(key);
values.put(key, toNative(base));
}
return new CompoundTag(values);
} else if (foreign instanceof NBTTagByte) {
return new ByteTag(((NBTTagByte) foreign).f()); // getByte
} else if (foreign instanceof NBTTagByteArray) {
return new ByteArrayTag(((NBTTagByteArray) foreign).c()); // data
} else if (foreign instanceof NBTTagDouble) {
return new DoubleTag(((NBTTagDouble) foreign).g()); // getDouble
} else if (foreign instanceof NBTTagFloat) {
return new FloatTag(((NBTTagFloat) foreign).h()); // getFloat
} else if (foreign instanceof NBTTagInt) {
return new IntTag(((NBTTagInt) foreign).d()); // getInt
} else if (foreign instanceof NBTTagIntArray) {
return new IntArrayTag(((NBTTagIntArray) foreign).c()); // data
} else if (foreign instanceof NBTTagList) {
try {
return toNativeList((NBTTagList) foreign);
} catch (Throwable e) {
logger.log(Level.WARNING, "Failed to convert NBTTagList", e);
return new ListTag(ByteTag.class, new ArrayList<ByteTag>());
}
} else if (foreign instanceof NBTTagLong) {
return new LongTag(((NBTTagLong) foreign).c()); // getLong
} else if (foreign instanceof NBTTagShort) {
return new ShortTag(((NBTTagShort) foreign).e()); // getShort
} else if (foreign instanceof NBTTagString) {
return new StringTag(((NBTTagString) foreign).a_()); // data
} else if (foreign instanceof NBTTagEnd) {
return new EndTag();
} else {
throw new IllegalArgumentException("Don't know how to make native " + foreign.getClass().getCanonicalName());
}
}
示例8: toNative
import com.sk89q.jnbt.LongTag; //导入依赖的package包/类
/**
* Converts from a non-native NMS NBT structure to a native WorldEdit NBT
* structure.
*
* @param foreign non-native NMS NBT structure
* @param name name for the tag, if it has one
* @return native WorldEdit NBT structure
*/
@SuppressWarnings("unchecked")
private Tag toNative(String name, NBTBase foreign) {
if (foreign == null) {
return null;
}
if (foreign instanceof NBTTagCompound) {
Map<String, Tag> values = new HashMap<String, Tag>();
Collection<Object> foreignKeys = ((NBTTagCompound) foreign).c();
for (Object obj : foreignKeys) {
String key = (String) obj;
NBTBase base = ((NBTTagCompound) foreign).get(key);
values.put(key, toNative(key, base));
}
return new CompoundTag(values);
} else if (foreign instanceof NBTTagByte) {
return new ByteTag(((NBTTagByte) foreign).data); // getByte
} else if (foreign instanceof NBTTagByteArray) {
return new ByteArrayTag(((NBTTagByteArray) foreign).data); // data
} else if (foreign instanceof NBTTagDouble) {
return new DoubleTag(((NBTTagDouble) foreign).data); // getDouble
} else if (foreign instanceof NBTTagFloat) {
return new FloatTag(((NBTTagFloat) foreign).data); // getFloat
} else if (foreign instanceof NBTTagInt) {
return new IntTag(((NBTTagInt) foreign).data); // getInt
} else if (foreign instanceof NBTTagIntArray) {
return new IntArrayTag(((NBTTagIntArray) foreign).data); // data
} else if (foreign instanceof NBTTagList) {
try {
return toNative((NBTTagList) foreign);
} catch (Throwable e) {
logger.log(Level.WARNING, "Failed to convert NBTTagList", e);
return new ListTag(ByteTag.class, new ArrayList<ByteTag>());
}
} else if (foreign instanceof NBTTagLong) {
return new LongTag(((NBTTagLong) foreign).data); // getLong
} else if (foreign instanceof NBTTagShort) {
return new ShortTag(((NBTTagShort) foreign).data); // getShort
} else if (foreign instanceof NBTTagString) {
return new StringTag(((NBTTagString) foreign).data); // data
} else if (foreign instanceof NBTTagEnd) {
return new EndTag();
} else {
throw new IllegalArgumentException("Don't know how to make native " + foreign.getClass().getCanonicalName());
}
}