当前位置: 首页>>代码示例>>Java>>正文


Java StringTag类代码示例

本文整理汇总了Java中cn.nukkit.nbt.tag.StringTag的典型用法代码示例。如果您正苦于以下问题:Java StringTag类的具体用法?Java StringTag怎么用?Java StringTag使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


StringTag类属于cn.nukkit.nbt.tag包,在下文中一共展示了StringTag类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getLore

import cn.nukkit.nbt.tag.StringTag; //导入依赖的package包/类
public String[] getLore() {
    Tag tag = this.getNamedTagEntry("display");
    ArrayList<String> lines = new ArrayList<>();

    if (tag instanceof CompoundTag) {
        CompoundTag nbt = (CompoundTag) tag;
        ListTag<StringTag> lore = nbt.getList("Lore", StringTag.class);

        if (lore.size() > 0) {
            for (StringTag stringTag : lore.getAll()) {
                lines.add(stringTag.data);
            }
        }
    }

    return lines.toArray(new String[0]);
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:18,代码来源:Item.java

示例2: setLore

import cn.nukkit.nbt.tag.StringTag; //导入依赖的package包/类
@Override
public void setLore(List<String> lore) {
	CompoundTag displayTag = tag.getCompound("display");

	if (lore == null || lore.isEmpty()) {
		// Remove the lore
		displayTag.remove("Lore");
	} else {
		// Set the lore
		ListTag<StringTag> loreListTag = new ListTag<>("Lore");
		for (String line : lore) {
			loreListTag.add(new StringTag("", line));
		}
		displayTag.putList(loreListTag);
	}

	setOrRemoveChildTag(tag, "display", displayTag);
}
 
开发者ID:rutgerkok,项目名称:Pokkit,代码行数:19,代码来源:PokkitItemMeta.java

示例3: setLore

import cn.nukkit.nbt.tag.StringTag; //导入依赖的package包/类
public Item setLore(String... lines) {
    CompoundTag tag;
    if (!this.hasCompoundTag()) {
        tag = new CompoundTag();
    } else {
        tag = this.getNamedTag();
    }
    ListTag<StringTag> lore = new ListTag<>("Lore");

    for (String line : lines) {
        lore.add(new StringTag("", line));
    }

    if (!tag.contains("display")) {
        tag.putCompound("display", new CompoundTag("display").putList(lore));
    } else {
        tag.getCompound("display").putList(lore);
    }

    this.setNamedTag(tag);
    return this;
}
 
开发者ID:Nukkit,项目名称:Nukkit,代码行数:23,代码来源:Item.java

示例4: hasCustomName

import cn.nukkit.nbt.tag.StringTag; //导入依赖的package包/类
public boolean hasCustomName() {
    if (!this.hasCompoundTag()) {
        return false;
    }

    CompoundTag tag = this.getNamedTag();
    if (tag.contains("display")) {
        Tag tag1 = tag.get("display");
        if (tag1 instanceof CompoundTag && ((CompoundTag) tag1).contains("Name") && ((CompoundTag) tag1).get("Name") instanceof StringTag) {
            return true;
        }
    }

    return false;
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:16,代码来源:Item.java

示例5: getCustomName

import cn.nukkit.nbt.tag.StringTag; //导入依赖的package包/类
public String getCustomName() {
    if (!this.hasCompoundTag()) {
        return "";
    }

    CompoundTag tag = this.getNamedTag();
    if (tag.contains("display")) {
        Tag tag1 = tag.get("display");
        if (tag1 instanceof CompoundTag && ((CompoundTag) tag1).contains("Name") && ((CompoundTag) tag1).get("Name") instanceof StringTag) {
            return ((CompoundTag) tag1).getString("Name");
        }
    }

    return "";
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:16,代码来源:Item.java

示例6: onActivate

import cn.nukkit.nbt.tag.StringTag; //导入依赖的package包/类
@Override
public boolean onActivate(Item item, Player player) {
    if (player != null) {
        BlockEntity t = getLevel().getBlockEntity(this);
        BlockEntityDispenser dispenser;
        if (t instanceof BlockEntityDispenser) {
            dispenser = (BlockEntityDispenser) t;
        } else {
            CompoundTag nbt = new CompoundTag()
                    .putList(new ListTag<>("Items"))
                    .putString("id", BlockEntity.DISPENSER)
                    .putInt("x", (int) this.x)
                    .putInt("y", (int) this.y)
                    .putInt("z", (int) this.z);
            dispenser = new BlockEntityDispenser(this.getLevel().getChunk((int) (this.x) >> 4, (int) (this.z) >> 4), nbt);
        }

        if (dispenser.namedTag.contains("Lock") && dispenser.namedTag.get("Lock") instanceof StringTag) {
            if (!dispenser.namedTag.getString("Lock").equals(item.getCustomName())) {
                return false;
            }
        }

        player.addWindow(dispenser.getInventory());
    }

    return true;
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:29,代码来源:BlockDispenser.java

示例7: onActivate

import cn.nukkit.nbt.tag.StringTag; //导入依赖的package包/类
@Override
public boolean onActivate(Item item, Player player) {
    if (player != null) {
        Block top = up();
        if (!top.isTransparent()) {
            return true;
        }

        BlockEntity t = this.getLevel().getBlockEntity(this);
        BlockEntityShulkerBox shulkerBox;
        if (t instanceof BlockEntityShulkerBox) {
            shulkerBox = (BlockEntityShulkerBox) t;
        } else {
            CompoundTag nbt = new CompoundTag("")
                    .putString("id", BlockEntity.SHULKER_BOX)
                    .putInt("x", (int) this.x)
                    .putInt("y", (int) this.y)
                    .putInt("z", (int) this.z);
            shulkerBox = new BlockEntityShulkerBox(this.getLevel().getChunk((int) (this.x) >> 4, (int) (this.z) >> 4), nbt);
        }

        if (shulkerBox.namedTag.contains("Lock") && shulkerBox.namedTag.get("Lock") instanceof StringTag) {
            if (!shulkerBox.namedTag.getString("Lock").equals(item.getCustomName())) {
                return true;
            }
        }

        player.addWindow(shulkerBox.getInventory());
    }

    return true;
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:33,代码来源:BlockShulkerBoxUndyed.java

示例8: onActivate

import cn.nukkit.nbt.tag.StringTag; //导入依赖的package包/类
@Override
public boolean onActivate(Item item, Player player) {
    if (player != null) {
        BlockEntity t = getLevel().getBlockEntity(this);
        BlockEntityDropper dropper;
        if (t instanceof BlockEntityDropper) {
            dropper = (BlockEntityDropper) t;
        } else {
            CompoundTag nbt = new CompoundTag()
                    .putList(new ListTag<>("Items"))
                    .putString("id", BlockEntity.DROPPER)
                    .putInt("x", (int) this.x)
                    .putInt("y", (int) this.y)
                    .putInt("z", (int) this.z);
            dropper = new BlockEntityDropper(this.getLevel().getChunk((int) (this.x) >> 4, (int) (this.z) >> 4), nbt);
        }

        if (dropper.namedTag.contains("Lock") && dropper.namedTag.get("Lock") instanceof StringTag) {
            if (!dropper.namedTag.getString("Lock").equals(item.getCustomName())) {
                return false;
            }
        }

        player.addWindow(dropper.getInventory());
    }

    return true;
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:29,代码来源:BlockDropper.java

示例9: testPermission

import cn.nukkit.nbt.tag.StringTag; //导入依赖的package包/类
public boolean testPermission(BlockEntityChest chest,String name) {
    if(chest.namedTag.exist("Owner")) {
        return Objects.equals(chest.namedTag.getString("Owner"), name) || chest.namedTag.getList("Guest",StringTag.class).getAll().contains(new StringTag("", name));
    }else{
        return false;
    }

}
 
开发者ID:zzz1999,项目名称:ChestLocker,代码行数:9,代码来源:ChestLocker.java

示例10: CopyChestInformation

import cn.nukkit.nbt.tag.StringTag; //导入依赖的package包/类
/**
 *
 * @param chest1 xD
 * @param chest2 xD
 * 将chest1的Owner与Guest 信息拷贝到chest2
 */
public void CopyChestInformation(BlockEntityChest chest1,BlockEntityChest chest2){
    if(chest1.namedTag.exist("Owner")){
        String Owner  = chest1.namedTag.getString("Owner");
        chest2.namedTag.putString("Owner",Owner);
    }
    if(chest1.namedTag.exist("Guest")){
        ListTag<StringTag> Guest = chest1.namedTag.getList("Guest",StringTag.class);
        chest2.namedTag.putList(Guest);
    }
}
 
开发者ID:zzz1999,项目名称:ChestLocker,代码行数:17,代码来源:ChestLocker.java

示例11: onUnshareChest

import cn.nukkit.nbt.tag.StringTag; //导入依赖的package包/类
@EventHandler
public void onUnshareChest(PlayerInteractEvent event){
    if(plugin.getUnshareSetting().containsKey(event.getPlayer().getName())){
        event.setCancelled();
        Block block = event.getBlock();
        Player player = event.getPlayer();
        String unshare = this.plugin.getUnshareSetting().get(player.getName());
        if(block.getId()==Block.CHEST){
            BlockEntity chestP = block.getLevel().getBlockEntity(block);
            if(chestP instanceof BlockEntityChest){
                BlockEntityChest chest = (BlockEntityChest) chestP;
                if(Objects.equals(chest.namedTag.getString("Owner"),player.getName())){
                    List<StringTag> list =  chest.namedTag.getList("Guest",StringTag.class).getAll();
                    if(list.contains(new StringTag("",unshare))){
                        //list.remove(new StringTag("",unshare));
                        List<StringTag> tag = chest.namedTag.getList("Guest",StringTag.class).getAll();
                        tag.remove(new StringTag("",unshare));
                        chest.namedTag.getList("Guest",StringTag.class).setAll(tag);
                        player.sendMessage(TextFormat.GOLD+"[ChestLocker] 以将 [ "+unshare+" ] 移除出箱子共享列表中");
                        plugin.getUnshareSetting().remove(unshare);
                        player.sendMessage(TextFormat.AQUA+"以退出取消箱子共享模式");

                    }else{
                        player.sendMessage(TextFormat.GRAY+"[ChestLocker] "+unshare+"  不在这个箱子的共享列表中");
                    }
                }
            }
        }
    }

}
 
开发者ID:zzz1999,项目名称:ChestLocker,代码行数:32,代码来源:EventListener.java

示例12: DemandChest

import cn.nukkit.nbt.tag.StringTag; //导入依赖的package包/类
@EventHandler
public void DemandChest(PlayerInteractEvent event){
    if(ChestLocker.getInstance().getDemandChest().containsKey(event.getPlayer().getName())){
        if(event.getBlock().getId() == Block.CHEST){
            event.setCancelled();
            Block block = event.getBlock();
            if(block.getLevel().getBlockEntity(block) instanceof BlockEntityChest){
                BlockEntityChest chest = (BlockEntityChest) block.getLevel().getBlockEntity(block);
                Player p = event.getPlayer();
                p.sendMessage(TextFormat.LIGHT_PURPLE+"----------------\n["+block.getName()+"]"+" 箱子信息如下:");
                p.sendMessage(TextFormat.LIGHT_PURPLE+"箱子所有者: ["+(chest.namedTag.exist("Owner") ? chest.namedTag.getString("Owner") : "无主")+"]");
                if(chest.namedTag.exist("Guest")) {
                    List<StringTag> list = chest.namedTag.getList("Guest",StringTag.class).getAll();
                    p.sendMessage(TextFormat.LIGHT_PURPLE+"箱子共享者:");
                    for (StringTag aList : list) {
                        p.sendMessage(TextFormat.LIGHT_PURPLE+aList.data);
                    }

                }
                p.sendMessage(TextFormat.LIGHT_PURPLE+"----------------");
                ChestLocker.getInstance().getDemandChest().remove(event.getPlayer().getName());
            }
        }else{
            event.getPlayer().sendPopup(TextFormat.GRAY+"查询失败,点击的不是箱子");
        }
    }
}
 
开发者ID:zzz1999,项目名称:ChestLocker,代码行数:28,代码来源:EventListener.java

示例13: getChestGuestList

import cn.nukkit.nbt.tag.StringTag; //导入依赖的package包/类
public List<StringTag> getChestGuestList(BlockEntityChest chest){
    return chest.namedTag.getList("Guest",StringTag.class).getAll();
}
 
开发者ID:zzz1999,项目名称:ChestLocker,代码行数:4,代码来源:ChestLocker.java

示例14: isChestGuest

import cn.nukkit.nbt.tag.StringTag; //导入依赖的package包/类
public Boolean isChestGuest(BlockEntityChest chest ,String name){
    return chest.namedTag.exist("Guest") && chest.namedTag.getList("Guest",StringTag.class).getAll().contains(new StringTag("", name));
}
 
开发者ID:zzz1999,项目名称:ChestLocker,代码行数:4,代码来源:ChestLocker.java


注:本文中的cn.nukkit.nbt.tag.StringTag类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。