本文整理匯總了Java中net.canarymod.api.nbt.StringTag類的典型用法代碼示例。如果您正苦於以下問題:Java StringTag類的具體用法?Java StringTag怎麽用?Java StringTag使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
StringTag類屬於net.canarymod.api.nbt包,在下文中一共展示了StringTag類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getNBTValue
import net.canarymod.api.nbt.StringTag; //導入依賴的package包/類
private Object getNBTValue(BaseTag<?> v) {
Object val = null;
switch(v.getTypeId()) {
case 1: // Byte
val = Byte.valueOf(((ByteTag)v).getByteValue());
break;
case 2: // Short
val = Short.valueOf(((ShortTag)v).getShortValue());
break;
case 3: // Int
val = Integer.valueOf(((IntTag)v).getIntValue());
break;
case 4: // Long
val = Long.valueOf(((LongTag)v).getLongValue());
break;
case 5: // Float
val = Float.valueOf(((FloatTag)v).getFloatValue());
break;
case 6: // Double
val = Double.valueOf(((DoubleTag)v).getDoubleValue());
break;
case 7: // Byte[]
val = ((ByteArrayTag)v).getValue();
break;
case 8: // String
val = ((StringTag)v).getValue();
break;
case 9: // List
ListTag<BaseTag<?>> tl = (ListTag<BaseTag<?>>) v;
ArrayList<Object> vlist = new ArrayList<Object>();
int type = tl.getTypeId();
for (int i = 0; i < tl.size(); i++) {
BaseTag<?> bt = tl.get(i);
switch (type) {
case 5:
float fv = ((FloatTag)bt).getFloatValue();
vlist.add(fv);
break;
case 6:
double dv = ((DoubleTag)bt).getDoubleValue();
vlist.add(dv);
break;
case 8:
String sv = ((StringTag)bt).getValue();
vlist.add(sv);
break;
case 10:
vlist.add(getNBTValue(bt));
break;
case 11:
int[] ia = ((IntArrayTag)bt).getValue();
vlist.add(ia);
break;
}
}
val = vlist;
break;
case 10: // Map
CompoundTag tc = (CompoundTag) v;
HashMap<String, Object> vmap = new HashMap<String, Object>();
for (String t : tc.keySet()) {
BaseTag<?> tg = tc.get(t);
vmap.put(t, getNBTValue(tg));
}
val = vmap;
break;
case 11: // Int[]
val = ((IntArrayTag)v).getValue();
break;
}
return val;
}
示例2: newStringTag
import net.canarymod.api.nbt.StringTag; //導入依賴的package包/類
@Override
public StringTag newStringTag(String value) {
return (StringTag) new NBTTagString(value);
}