• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SignData类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



SignData类属于org.spongepowered.api.data.manipulator.mutable.tileentity包,在下文中一共展示了SignData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: generateWarpSignData

import org.spongepowered.api.data.manipulator.mutable.tileentity.SignData; //导入依赖的package包/类
/**
 * @param warp the warp to represent on the SignData
 * @return the formatted SignData indicating a valid warp sign
 */
public static SignData generateWarpSignData(Warp warp) {
    Optional<DataManipulatorBuilder<SignData, ImmutableSignData>> builder =
            Sponge.getDataManager().getManipulatorBuilder(SignData.class);
    SignData signData = builder.get().create();
    ListValue<Text> lines = signData.lines();

    lines.set(0, Text.of());
    lines.set(1, Text.of(TextColors.DARK_BLUE, Constants.WARP_SIGN_PREFIX));
    lines.set(2, Text.of(TextColors.GOLD, warp.getName()));
    lines.set(3, Text.of());

    signData.set(lines);

    return signData;

}
 
开发者ID:RobertHerhold,项目名称:BLWarps,代码行数:21,代码来源:Util.java


示例2: getSign

import org.spongepowered.api.data.manipulator.mutable.tileentity.SignData; //导入依赖的package包/类
@Override
public String[] getSign(Location location) {
    World world = SpongeUtil.getWorld(location.getWorld());
    Optional<TileEntity> block = world.getTileEntity(location.getX(), location.getY(), location.getZ());
    if (!block.isPresent()) {
        return null;
    }
    TileEntity tile = block.get();
    if (!(tile instanceof Sign)) {
        return null;
    }
    Sign sign = (Sign) tile;
    Optional<SignData> optional = sign.get(SignData.class);
    if (!optional.isPresent()) {
        return null;
    }
    String[] result = new String[4];
    ListValue<Text> lines = optional.get().lines();
    for (int i = 0; i < 4; i++) {
        result[i] = lines.get(i).toString();
    }
    return result;
}
 
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:24,代码来源:SpongeUtil.java


示例3: setFirstLineColor

import org.spongepowered.api.data.manipulator.mutable.tileentity.SignData; //导入依赖的package包/类
private final void setFirstLineColor(TextColor color) {
	Optional<TileEntity> sign = location.getTileEntity();
	if (sign.isPresent() && sign.get().supports(SignData.class)) {
		Optional<SignData> data = sign.get().getOrCreate(SignData.class);
		if (data.isPresent()) {
			SignData signData = data.get();
			signData.set(signData.lines().set(0, Text.of(color, signData.lines().get(0).toPlain())));
			sign.get().offer(signData);
		}
	}
}
 
开发者ID:TheoKah,项目名称:CarrotShop,代码行数:12,代码来源:Shop.java


示例4: getPrice

import org.spongepowered.api.data.manipulator.mutable.tileentity.SignData; //导入依赖的package包/类
static protected final int getPrice(Location<World> location) {
	Optional<TileEntity> sign = location.getTileEntity();
	if (sign.isPresent() && sign.get().supports(SignData.class)) {
		Optional<SignData> data = sign.get().get(SignData.class);
		if (data.isPresent()) {
			String priceLine = data.get().lines().get(3).toPlain().replaceAll("[^\\d]", "");
			if (priceLine.length() == 0)
				return 0;
			return Integer.parseInt(priceLine);
		}
	}
	return -1;
}
 
开发者ID:TheoKah,项目名称:CarrotShop,代码行数:14,代码来源:Shop.java


示例5: onSignChange

import org.spongepowered.api.data.manipulator.mutable.tileentity.SignData; //导入依赖的package包/类
@Listener
public void onSignChange(ChangeSignEvent event, @First Player player)
{
	SignData signData = event.getText();

	if (signData.getValue(Keys.SIGN_LINES).isPresent())
	{
		String line0 = signData.getValue(Keys.SIGN_LINES).get().get(0).toPlain();
		String line1 = signData.getValue(Keys.SIGN_LINES).get().get(1).toPlain();
		String line2 = signData.getValue(Keys.SIGN_LINES).get().get(2).toPlain();
		String line3 = signData.getValue(Keys.SIGN_LINES).get().get(3).toPlain();

		if (line0.equals("[Warp]"))
		{
			if (Utils.getWarps().contains(line1))
			{
				signData = signData.set(signData.getValue(Keys.SIGN_LINES).get().set(0, Text.of(TextColors.DARK_BLUE, "[Warp]")));
			}
			else
			{
				signData = signData.set(signData.getValue(Keys.SIGN_LINES).get().set(0, Text.of(TextColors.DARK_RED, "[Warp]")));
			}
		}
		else if (player != null && player.hasPermission("essentialcmds.color.sign.use"))
		{
			signData = signData.set(signData.getValue(Keys.SIGN_LINES).get().set(0, TextSerializers.formattingCode('&').deserialize(line0)));
			signData = signData.set(signData.getValue(Keys.SIGN_LINES).get().set(1, TextSerializers.formattingCode('&').deserialize(line1)));
			signData = signData.set(signData.getValue(Keys.SIGN_LINES).get().set(2, TextSerializers.formattingCode('&').deserialize(line2)));
			signData = signData.set(signData.getValue(Keys.SIGN_LINES).get().set(3, TextSerializers.formattingCode('&').deserialize(line3)));
		}
	}
}
 
开发者ID:hsyyid,项目名称:EssentialCmds,代码行数:33,代码来源:SignChangeListener.java


示例6: onSignChange

import org.spongepowered.api.data.manipulator.mutable.tileentity.SignData; //导入依赖的package包/类
@Listener
public void onSignChange(ChangeSignEvent event, @First Player player) {
    Sign signTile = event.getTargetTile();
    if (!signTile.get(LiteKeys.JOB_NAME).isPresent() && player.hasPermission("jobs.admin.sign.create")) {
        SignData data = event.getText();
        try {
            if (data.getValue(Keys.SIGN_LINES).get().get(0).toPlain().equals("[JobsLite]")) {
                String signJob = data.getValue(Keys.SIGN_LINES).get().get(1).toPlain();
                if (jobManager.jobExists(signJob)) {
                    signTile.offer(data.set(data.getValue(Keys.SIGN_LINES).get().set(0, Text.of("[Job]"))));
                    SignJobDataManipulatorBuilder builder =
                            (SignJobDataManipulatorBuilder) Sponge.getDataManager().getManipulatorBuilder(SignJobData.class).get();
                    SignJobData signJobData = builder.setSignInfo(signJob).create();
                    signTile.offer(signJobData);
                    player.sendMessage(messageStorage.getMessage("sign.success"));
                    return;
                } else {
                    player.sendMessage(messageStorage.getMessage("sign.nojob"));
                    return;
                }
            }
        } catch (IndexOutOfBoundsException | NoSuchElementException e) {
            player.sendMessage(messageStorage.getMessage("sign.invalid"));
            return;
        }
    } else if (signTile.get(LiteKeys.JOB_NAME).isPresent() && !player.hasPermission("jobs.admin.sign.delete")) {
        player.sendMessage(messageStorage.getMessage("sign.nopermission"));
        event.setCancelled(true);
    }
}
 
开发者ID:Flibio,项目名称:JobsLite,代码行数:31,代码来源:SignListeners.java


示例7: log

import org.spongepowered.api.data.manipulator.mutable.tileentity.SignData; //导入依赖的package包/类
public static void log(UUID shopOwnerUUID, Player player, String type, Location<World> location, Optional<Integer> price, Optional<Currency> currency, Optional<Inventory> itemsA, Optional<Inventory> itemsB) {

		String shopOwner = shopOwnerUUID != null ? shopOwnerUUID.toString() : "server";

		if (shopOwnerUUID != null) {
			Optional<Player> seller = Sponge.getServer().getPlayer(shopOwnerUUID);
			if (!seller.isPresent()) {
				ShopsData.soldSomethingOffline(shopOwnerUUID);
			}
		}

		JsonObject newNode = new JsonObject();
		newNode.addProperty("player", player.getName());
		newNode.addProperty("playerID", player.getUniqueId().toString());
		newNode.addProperty("time", System.currentTimeMillis());

		JsonObject locationNode = new JsonObject();
		locationNode.addProperty("world", location.getExtent().getName());
		locationNode.addProperty("worldID", location.getExtent().getUniqueId().toString());
		locationNode.addProperty("X", location.getBlockX());
		locationNode.addProperty("Y", location.getBlockY());
		locationNode.addProperty("Z", location.getBlockZ());

		Optional<TileEntity> sign = location.getTileEntity();
		if (sign.isPresent() && sign.get().supports(SignData.class)) {
			Optional<SignData> data = sign.get().getOrCreate(SignData.class);
			if (data.isPresent()) {
				locationNode.addProperty("line0", data.get().lines().get(0).toPlain());
				locationNode.addProperty("line1", data.get().lines().get(1).toPlain());
				locationNode.addProperty("line2", data.get().lines().get(2).toPlain());
				locationNode.addProperty("line3", data.get().lines().get(3).toPlain());
			}
		}

		newNode.add("sign", locationNode);

		if (ShopsData.hasMultipleCurrencies() && currency.isPresent()) {
			JsonObject currencyNode = new JsonObject();
			currencyNode.addProperty("currencySymbol", TextSerializers.FORMATTING_CODE.serialize(currency.get().getSymbol()));
			currencyNode.addProperty("currencySymbolplain", currency.get().getSymbol().toPlain());
			currencyNode.addProperty("currencyName", currency.get().getName());
			currencyNode.addProperty("currencyDName", TextSerializers.FORMATTING_CODE.serialize(currency.get().getDisplayName()));
			currencyNode.addProperty("currencyPDName", TextSerializers.FORMATTING_CODE.serialize(currency.get().getPluralDisplayName()));
			newNode.add("currency", currencyNode);
		}

		if (price.isPresent())
			newNode.addProperty("price", price.get());

		if (itemsA.isPresent())
			newNode.add("items", invToArray(itemsA.get()));

		if (itemsB.isPresent())
			newNode.add("items2", invToArray(itemsB.get()));

		try {
			File file = new File(carrotLogsFolder, shopOwner + "." + type);

			if (!file.exists()) {
				file.createNewFile();
				JsonObject firstNode = new JsonObject();
				firstNode.addProperty("init", true);
				firstNode.addProperty("time", System.currentTimeMillis());

				Files.write(file.toPath(), firstNode.toString().getBytes(), StandardOpenOption.APPEND);
			}
			Files.write(file.toPath(), ",".getBytes(), StandardOpenOption.APPEND);
			Files.write(file.toPath(), newNode.toString().getBytes(), StandardOpenOption.APPEND);

		} catch (IOException e) {
			CarrotShop.getLogger().error("Unable to store logs for shop " + shopOwner + " triggered by " + player.getName() + ": " + e.getMessage());
		}
	}
 
开发者ID:TheoKah,项目名称:CarrotShop,代码行数:74,代码来源:ShopsLogs.java


示例8: Shop

import org.spongepowered.api.data.manipulator.mutable.tileentity.SignData; //导入依赖的package包/类
public Shop(Location<World> loc) {
	Optional<TileEntity> tile = loc.getTileEntity();
	if (!tile.isPresent() || !tile.get().supports(SignData.class))
		throw new ExceptionInInitializerError("Improbable error: managed to trigger a shop creation event from something other than a sign");
	location = loc;
}
 
开发者ID:TheoKah,项目名称:CarrotShop,代码行数:7,代码来源:Shop.java


示例9: create

import org.spongepowered.api.data.manipulator.mutable.tileentity.SignData; //导入依赖的package包/类
@Override
public boolean create(EPlayer player, Location<World> location, SignData data) {
	EEMessages.SIGN_BALANCE_CREATE.sendTo(player);
	return true;
}
 
开发者ID:EverCraft,项目名称:EverEconomy,代码行数:6,代码来源:BalanceSign.java


示例10: onPlayerInteractBlock

import org.spongepowered.api.data.manipulator.mutable.tileentity.SignData; //导入依赖的package包/类
@Listener
public void onPlayerInteractBlock(InteractBlockEvent event, @Root Player player)
{
	if (EssentialCmds.frozenPlayers.contains(player.getUniqueId()))
	{
		player.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "You cannot interact while frozen."));
		event.setCancelled(true);
		return;
	}

	if (EssentialCmds.jailedPlayers.contains(player.getUniqueId()))
	{
		player.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "You cannot interact while jailed."));
		event.setCancelled(true);
		return;
	}

	Optional<Location<World>> optLocation = event.getTargetBlock().getLocation();

	if (optLocation.isPresent() && optLocation.get().getTileEntity().isPresent())
	{
		Location<World> location = optLocation.get();
		TileEntity clickedEntity = location.getTileEntity().get();

		if (event.getTargetBlock().getState().getType().equals(BlockTypes.STANDING_SIGN) || event.getTargetBlock().getState().getType().equals(BlockTypes.WALL_SIGN))
		{
			Optional<SignData> signData = clickedEntity.getOrCreate(SignData.class);

			if (signData.isPresent())
			{
				SignData data = signData.get();
				CommandManager cmdService = Sponge.getGame().getCommandManager();
				String line0 = data.getValue(Keys.SIGN_LINES).get().get(0).toPlain();
				String line1 = data.getValue(Keys.SIGN_LINES).get().get(1).toPlain();
				String command = "warp " + line1;

				if (line0.equals("[Warp]"))
				{
					if (player.hasPermission("essentialcmds.warps.use.sign"))
					{
						cmdService.process(player, command);
					}
					else
					{
						player.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "You do not have permission to use Warp Signs!"));
					}
				}
			}
		}
	}
}
 
开发者ID:hsyyid,项目名称:EssentialCmds,代码行数:52,代码来源:PlayerInteractListener.java


示例11: setErrorSign

import org.spongepowered.api.data.manipulator.mutable.tileentity.SignData; //导入依赖的package包/类
protected void setErrorSign(ChangeSignEvent e, String error) {
	SignData sign = e.getText();
	sign = sign.set(sign.getValue(Keys.SIGN_LINES).get().set(0, RPUtil.toText(RPLang.get("regionbuilder.signerror"))));
    this.setError(e.getCause().first(Player.class).get(), error);
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:6,代码来源:RegionBuilder.java


示例12: run

import org.spongepowered.api.data.manipulator.mutable.tileentity.SignData; //导入依赖的package包/类
@Override
public void run() {
    for (SavedBuyNowSign sign : plugin.getBuyNowSignStorage().getSigns()) {
        Package p = plugin.getListingUpdateTask().getPackageById(sign.getPackageId());
        if (p == null) {
            plugin.getLogger().error(String.format("Sign at %d, %d, %d in world %s does not have a valid package assigned to it.",
                    sign.getLocation().getX(), sign.getLocation().getY(), sign.getLocation().getZ(), sign.getLocation().getWorld()));
            continue;
        }

        Location location = SpongeSerializedBlockLocation.toSponge(sign.getLocation());

        BlockState b = location.getBlock();

        if (!(b.getType().equals(BlockTypes.WALL_SIGN) || b.getType().equals(BlockTypes.STANDING_SIGN))) {
            plugin.getLogger().error(String.format("Sign at %d, %d, %d in world %s is not a sign in the world!",
                    sign.getLocation().getX(), sign.getLocation().getY(), sign.getLocation().getZ(), sign.getLocation().getWorld()));
            continue;
        }

        Optional<TileEntity> entity = location.getTileEntity();

        Currency currency = Currency.getInstance(plugin.getServerInformation().getAccount().getCurrency().getIso4217());

        List<String> signLines = plugin.getBuyNowSignLayout().format(currency, p);

        if (entity.isPresent() && entity.get().supports(SignData.class)) {
            SignData signData = entity.get().getOrCreate(SignData.class).get();
            ListValue<Text> lines = signData.lines();

            for (int i = 0; i < 4; i++) {
                if (i >= signLines.size()) {
                    lines.set(i, Text.EMPTY);
                } else {
                    lines.set(i, Text.builder(signLines.get(i).replace("&", "§")).build());
                }

            }

            entity.get().offer(lines);
        }

    }
}
 
开发者ID:BuycraftPlugin,项目名称:BuycraftX,代码行数:45,代码来源:BuyNowSignUpdater.java


示例13: run

import org.spongepowered.api.data.manipulator.mutable.tileentity.SignData; //导入依赖的package包/类
@Override
public void run() {
    for (Map.Entry<RecentPurchaseSignPosition, RecentPayment> entry : paymentMap.entrySet()) {
        Location<World> location = SpongeSerializedBlockLocation.toSponge(entry.getKey().getLocation());

        Optional<TileEntity> entity = location.getTileEntity();
        if (entity.isPresent() && entity.get().supports(SignData.class)) {
            SignData signData = entity.get().getOrCreate(SignData.class).get();
            ListValue<Text> lines = signData.lines();

            if (entry.getValue() != null) {
                lines.set(0, Text.EMPTY);
                lines.set(1, Text.of(entry.getValue().getPlayer().getName()));

                NumberFormat format = NumberFormat.getCurrencyInstance(Locale.US);
                format.setCurrency(Currency.getInstance(entry.getValue().getCurrency().getIso4217()));

                lines.set(2, Text.of(format.format(entry.getValue().getAmount())));
                lines.set(3, Text.EMPTY);
            } else {
                for (int i = 0; i < 4; i++) {
                    lines.set(i, Text.EMPTY);
                }
            }

            entity.get().offer(lines);

            Location<World> supportedBy = location.getRelative(Direction.UP);

            Optional<Skull> skullOptional = findSkull(supportedBy);
            if (skullOptional.isPresent()) {
                Skull skull = skullOptional.get();
                if (!skull.supports(Keys.REPRESENTED_PLAYER)) {
                    skull.offer(Keys.SKULL_TYPE, SkullTypes.PLAYER);
                }
                GameProfile profile = entry.getValue() != null ?
                        resolvedProfiles.getOrDefault(entry.getValue().getPlayer().getName(), resolvedProfiles.get("MHF_Question")) :
                        resolvedProfiles.get("MHF_Question");
                if (profile != null) {
                    skull.offer(Keys.REPRESENTED_PLAYER, profile);
                }
            }
        } else {
            plugin.getLogger().error("Location " + entry.getKey() + " doesn't have a tile entity! (Sign missing?)");
        }
    }
}
 
开发者ID:BuycraftPlugin,项目名称:BuycraftX,代码行数:48,代码来源:SignUpdateApplication.java


示例14: executeTryBreak

import org.spongepowered.api.data.manipulator.mutable.tileentity.SignData; //导入依赖的package包/类
public boolean executeTryBreak(MarketSignData data, Player player, Location<World> at)
{
    if (data.isOwner(player.getUniqueId()))
    {
        if (!player.hasPermission(module.perms().EDIT_PLAYER_SELF.getId())) {
            i18n.send(player, NEGATIVE, "You are not allowed to break your own market signs!");
            return false;
        }
    }
    else if (data.isAdminOwner())
    {
        if (!player.hasPermission(module.perms().EDIT_ADMIN.getId()))
        {
            i18n.send(player, NEGATIVE, "You are not allowed to break admin market signs!");
            return false;
        }
    }
    else if (!player.hasPermission(module.perms().EDIT_PLAYER_OTHER.getId()))
    {
        i18n.send(player, NEGATIVE, "You are not allowed to break others market signs!");
        return false;
    }

    boolean isDoubleClick = breakingSign.containsKey(player.getUniqueId()) && System.currentTimeMillis() - breakingSign.get(player.getUniqueId()) <= 500;

    if (player.gameMode().get() != GameModes.CREATIVE)
    {
        // When valid ; not Admin ; has stock
        if (isValidSign(data, null) && !data.getOwner().equals(ADMIN_SIGN) && data.getStock() > 0)
        {
            if (!isDoubleClick)
            {
                breakingSign.put(player.getUniqueId(), System.currentTimeMillis());
                i18n.send(player, NEUTRAL, "Double click to empty and break the sign!");
                return false;
            }
            // empty the sign first
            Sponge.getCauseStackManager().pushCause(player);
            takeItem(data, at, player); // TODO spawnType DISPENSE?
            if (data.getStock() == 0)
            {
                breakingSign.remove(player.getUniqueId()); // double click again to actually break the sign
            }
            return false;
        }
    }

    if (player.getItemInHand(HandTypes.MAIN_HAND).isPresent())
    {
        i18n.send(ACTION_BAR, player, NEGATIVE, "Use your bare hands to break the sign!");
        return false;
    }

    // Sign is Empty or Create -> Now Break it (maybe)
    if (isDoubleClick) // 0.5 sec
    {
        Sponge.getCauseStackManager().pushCause(player);
        if (data.getStock() != null && data.getStock() == 1337)  //pssst i am not here
        {
            Entity lightning = at.getExtent().createEntity(EntityTypes.LIGHTNING, at.getPosition());
            at.getExtent().spawnEntity(lightning);
        }

        dropContents(data, at);
        at.remove(MarketSignData.class);
        at.remove(SignData.class);
        at.setBlock(BlockTypes.AIR.getDefaultState()); // TODO break particles + sound?
        if (player.gameMode().get() != GameModes.CREATIVE)
        {
            spawn(at, ItemStack.builder().itemType(ItemTypes.SIGN).quantity(1).build());
        }
        i18n.send(player, POSITIVE, "MarketSign destroyed!");
        return true;
    }
    breakingSign.put(player.getUniqueId(), System.currentTimeMillis());
    i18n.send(ACTION_BAR, player, NEUTRAL, "Double click to break the sign!");
    return false;
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:79,代码来源:MarketSignManager.java


示例15: create

import org.spongepowered.api.data.manipulator.mutable.tileentity.SignData; //导入依赖的package包/类
public boolean create(EPlayer player, Location<World> location, SignData data); 
开发者ID:EverCraft,项目名称:EverAPI,代码行数:2,代码来源:SignSubject.java



注:本文中的org.spongepowered.api.data.manipulator.mutable.tileentity.SignData类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BitUtil类代码示例发布时间:2022-05-22
下一篇:
Java RxHelper类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap