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


Java Sign.getLines方法代码示例

本文整理汇总了Java中org.bukkit.block.Sign.getLines方法的典型用法代码示例。如果您正苦于以下问题:Java Sign.getLines方法的具体用法?Java Sign.getLines怎么用?Java Sign.getLines使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.block.Sign的用法示例。


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

示例1: isShopBlockNearby

import org.bukkit.block.Sign; //导入方法依赖的package包/类
private boolean isShopBlockNearby(Block b) {
	if (b == null) {
		return false;
	}
	Block nearChest = null;
	if (b.getType() == Material.CHEST) {
		nearChest = getBlockNearby(b, Material.CHEST);
	} else if (b.getType() == Material.TRAPPED_CHEST) {
		nearChest = getBlockNearby(b, Material.TRAPPED_CHEST);
	}
	if (nearChest == null) {
		return false;
	}
	for (BlockFace face : BLOCKFACE) {
		Block maybeSign = nearChest.getRelative(face);
		if (maybeSign != null && Material.WALL_SIGN == maybeSign.getType()) {
			Sign sign = (Sign) maybeSign.getState();
			if (sign.getLines().length > 0 && sign.getLines()[0].contains(cm.quickshopSignFlag)) {
				return true;
			}
		}
	}
	return false;
}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:25,代码来源:AntiQuickShopDoubleChest.java

示例2: signInteract

import org.bukkit.block.Sign; //导入方法依赖的package包/类
@EventHandler
public void signInteract(@Nonnull PlayerInteractEvent event) {
    if (event.getAction() != Action.RIGHT_CLICK_BLOCK || event.getClickedBlock() == null) {
        return;
    }
    // is block a sign?
    if (event.getClickedBlock().getState() instanceof Sign) {
        User user = userHandler.getUser(event.getPlayer().getUniqueId()).orElseThrow(() -> new UserException(
                "Unknown user " + event.getPlayer().getDisplayName() + "(" + event.getPlayer().getUniqueId() + ")"));
        Sign sign = (Sign) event.getClickedBlock().getState();
        for (int i = 0; i < sign.getLines().length; i++) {
            String line = sign.getLines()[i];
            for (String key : getButtons().keySet()) {
                if (line.contains("[" + key + "]")) {
                    //TODO implement perm check
                    getButtons().get(key).execute(user, event.getClickedBlock());
                }
            }
        }
    }
}
 
开发者ID:VoxelGamesLib,项目名称:VoxelGamesLibv2,代码行数:22,代码来源:SignButtons.java

示例3: clickHandler

import org.bukkit.block.Sign; //导入方法依赖的package包/类
@EventHandler
public void clickHandler(PlayerInteractEvent event) {
	if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
		Block block = event.getClickedBlock();
		
		if (block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN) {
			Sign sign = (Sign) block.getState();
			String[] lines = sign.getLines();
			
			if (lines[0].equals(ChatColor.BLUE + "PaintWar") && lines[1].equals(ChatColor.DARK_GREEN + "join")) {
				if (paintwar.games.keySet().contains(lines[2])) {
					PaintWarGame game = paintwar.games.get(lines[2]);
					Player player = event.getPlayer();
					
					if (game.Join(player)) {
						paintwar.sendMessage(player, ChatColor.GREEN + "PaintWar game with name " + game.GetName() + " joined! You are on the " + game.GetTeam(player) + " team.");
					}
					else {
						paintwar.sendMessage(player, ChatColor.RED + "You are already in a PaintWar game!");
					}
				}
			}
		}
	}
}
 
开发者ID:JFischer00,项目名称:PaintWarPlugin,代码行数:26,代码来源:SignsHandler.java

示例4: updateSigns

import org.bukkit.block.Sign; //导入方法依赖的package包/类
public void updateSigns(String fname){
	if (!RPConfig.getBool("region-settings.enable-flag-sign")){
		return;
	}
	List<Location> locs = RPConfig.getSigns(this.getID());
    if (locs.size() > 0){
		for (Location loc:locs){
			if (loc.getBlock().getState() instanceof Sign){
				Sign s = (Sign) loc.getBlock().getState();
				String[] lines = s.getLines();
				if (lines[0].equalsIgnoreCase("[flag]")){
					if (lines[1].equalsIgnoreCase(fname) && this.name.equalsIgnoreCase(ChatColor.stripColor(lines[2]))){
						s.setLine(3, RPLang.get("region.value")+" "+RPLang.translBool(getFlagString(fname)));
						s.update();
						RPConfig.putSign(this.getID(), loc);
					}
				} else {
    				RPConfig.removeSign(this.getID(), loc);
    			}
			} else {
				RPConfig.removeSign(this.getID(), loc);
			}
		}
	}
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:26,代码来源:Region.java

示例5: fireUpdateEvent

import org.bukkit.block.Sign; //导入方法依赖的package包/类
/**
 * Fires a SignUpdateEvent for the sign at this location
 */
public void fireUpdateEvent() {
    Sign sign = (Sign) block.getState();
    SignChangeEvent event = new SignChangeEvent(block, null, sign.getLines());
    Bukkit.getServer().getPluginManager().callEvent(event);
    for (int i = 0; i < event.getLines().length; i++) {
        sign.setLine(i, event.getLine(i));
    }
    sign.update();
}
 
开发者ID:VoxelGamesLib,项目名称:VoxelGamesLibv2,代码行数:13,代码来源:SignLocation.java

示例6: createSign

import org.bukkit.block.Sign; //导入方法依赖的package包/类
/**
 * Create an acquirable teleport sign
 * Op only
 * /cc tp sign <acquire-price>
 */
@SubCommand(value = "sign", permission = "cc.tp.sign")
public void createSign(CommandSender sender, Arguments args) {
    Sign signLookAt = getSignLookat(sender);
    if (plugin.signDB.getSign(signLookAt.getLocation()) != null) {
        throw new BadCommandException("user.tp.already_registered");
    }
    for (String s : signLookAt.getLines()) {
        if (s.length() > 0) {
            throw new BadCommandException("user.tp.must_empty");
        }
    }
    Player player = asPlayer(sender);
    Double price = args.nextDouble();
    SignRegistration reg = new SignRegistration();
    reg.acquired = false;
    reg.acquireFee = price;
    reg.ownerId = player.getUniqueId();
    reg.signId = UUID.randomUUID();
    reg.location = signLookAt.getLocation().clone();
    reg.teleportFee = 0D;
    reg.targetLocation = signLookAt.getLocation().clone();
    reg.description = args.length() == 4 ? nextDescription(args) : "";
    plugin.signDB.query(SignRegistration.class).insert(reg);
    SignDatabase.updateSignContent(reg);
    SignDatabase.attachedBlocks.put(reg.location.clone(), SignDatabase.getAttachedBlock(reg.location.getBlock()));
    logToConsole(reg, "user.log.tpsign_register", player.getName(), price);
}
 
开发者ID:NyaaCat,项目名称:CapCat,代码行数:33,代码来源:SignCommands.java

示例7: getShopMembers

import org.bukkit.block.Sign; //导入方法依赖的package包/类
/**
 * Returns all the owners of a TradeShop, including the one on the last line of the sign.
 *
 * @param block the inventory holder block
 * @return all the members.
 */
public List<OfflinePlayer> getShopMembers(Block block) {
    BlockState b = block.getState();

    if (!plugin.getAllowedInventories().contains(b.getType())) {
        return null;
    }

    List<OfflinePlayer> members = new ArrayList<>();
    Inventory inv = ((InventoryHolder) b).getInventory();
    String names = inv.getName();
    for (String m : names.split(";")) {
        if (m.startsWith("m:")) {
            members.add(Bukkit.getOfflinePlayer(m.substring(2)));
        }
    }
    Sign s = findShopSign(b.getBlock());
    try {
        if (s.getLines().length != 4 || s.getLine(3).equals("")) {
            if (members.size() > 0) {
                s.setLine(3, members.get(0).getName());
                s.update();
            } else {
                return null;
            }
            return members;
        } else if (getShopOwners(s).size() == 0 || !getShopOwners(s).contains(Bukkit.getOfflinePlayer(s.getLine(3)))) {
            changeInvName(b, readInvName(b), Collections.singletonList(plugin.getServer().getOfflinePlayer(s.getLine(3))), members);
        }
    } catch (NullPointerException npe) {
    }
    return members;
}
 
开发者ID:SparklingComet,项目名称:TradeShop,代码行数:39,代码来源:Utils.java

示例8: getSign

import org.bukkit.block.Sign; //导入方法依赖的package包/类
@Override
public String[] getSign(final Location loc) {
    final Block block = getWorld(loc.getWorld()).getBlockAt(loc.getX(), loc.getY(), loc.getZ());
    if (block != null) {
        if (block.getState() instanceof Sign) {
            final Sign sign = (Sign) block.getState();
            return sign.getLines();
        }
    }
    return null;
}
 
开发者ID:Mayomi,项目名称:PlotSquared-Chinese,代码行数:12,代码来源:BukkitUtil.java

示例9: onPlayerInteract

import org.bukkit.block.Sign; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = false, priority = EventPriority.HIGH)
public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
        Block block = event.getClickedBlock();
        BlockState state = block.getState();
        if (state instanceof Sign) {
            Sign sign = (Sign) state;
            String[] lines = sign.getLines();

            Integer quantity = JavaUtils.tryParseInt(lines[2]);
            if (quantity == null)
                return;

            Integer price = JavaUtils.tryParseInt(ALPHANUMERIC_REMOVER.matcher(lines[3]).replaceAll(""));
            if (price == null)
                return;

            ItemStack stack;
            if (lines[1].equalsIgnoreCase("Crowbar")) {
                stack = new Crowbar().getItemIfPresent();
            } else if ((stack = BasePlugin.getPlugin().getItemDb().getItem(ALPHANUMERIC_REMOVER.matcher(lines[1]).replaceAll(""), quantity)) == null) {
                return;
            }

            // Final handling of shop.
            Player player = event.getPlayer();
            String[] fakeLines = Arrays.copyOf(sign.getLines(), 4);
            if (lines[0].contains("Sell") && lines[0].contains(ChatColor.RED.toString())) {
                int sellQuantity = Math.min(quantity, InventoryUtils.countAmount(player.getInventory(), stack.getType(), stack.getDurability()));
                if (sellQuantity <= 0) {
                    fakeLines[0] = ChatColor.RED + "Not carrying any";
                    fakeLines[2] = ChatColor.RED + "on you.";
                    fakeLines[3] = "";
                } else {
                    // Recalculate the price.
                    int newPrice = (int) (((double) price / (double) quantity) * (double) sellQuantity);
                    fakeLines[0] = ChatColor.GREEN + "Sold " + sellQuantity;
                    fakeLines[3] = ChatColor.GREEN + "for " + EconomyManager.ECONOMY_SYMBOL + newPrice;

                    plugin.getEconomyManager().addBalance(player.getUniqueId(), newPrice);
                    InventoryUtils.removeItem(player.getInventory(), stack.getType(), stack.getData().getData(), sellQuantity);
                    player.updateInventory();
                }
            } else if (lines[0].contains("Buy") && lines[0].contains(ChatColor.GREEN.toString())) {
                if (price > plugin.getEconomyManager().getBalance(player.getUniqueId())) {
                    fakeLines[0] = ChatColor.RED + "Cannot afford";
                } else {
                    fakeLines[0] = ChatColor.GREEN + "Item bought";
                    fakeLines[3] = ChatColor.GREEN + "for " + EconomyManager.ECONOMY_SYMBOL + price;
                    plugin.getEconomyManager().subtractBalance(player.getUniqueId(), price);

                    World world = player.getWorld();
                    Location location = player.getLocation();
                    Map<Integer, ItemStack> excess = player.getInventory().addItem(stack);
                    for (Map.Entry<Integer, ItemStack> excessItemStack : excess.entrySet()) {
                        world.dropItemNaturally(location, excessItemStack.getValue());
                    }

                    player.setItemInHand(player.getItemInHand()); // resend held item packet.
                }
            } else {
                return;
            }

            event.setCancelled(true);
            BasePlugin.getPlugin().getSignHandler().showLines(player, sign, fakeLines, SIGN_TEXT_REVERT_TICKS, true);
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:70,代码来源:ShopSignListener.java

示例10: onSignClick

import org.bukkit.block.Sign; //导入方法依赖的package包/类
@EventHandler
public void onSignClick(PlayerInteractEvent e){
	
	Block block = e.getClickedBlock();
	if (block.getState() instanceof Sign){
		
		//System.out.println("work 1");//debug
		
		Sign sign = (Sign) block.getState();
		String[] line = sign.getLines();
		Player player = e.getPlayer();
		
		if(line[0].contains("FS")){
			
			//System.out.println("work 2");//debug
			
			//join
			if(line[1].equals(ChatColor.GREEN+"Join")){
				
				//System.out.println("work 3");//debug
				
				if(!Teams.getPlayerInWhereArea().containsKey(player)){
					if(plugin.getConfig().getConfigurationSection("area").contains(line[2])){
						Teams.JoinTeam(player, line[2]);
					}else{
						player.sendMessage(ChatColor.RED + "���a���s�b");
					}
				}else{
					player.sendMessage(ChatColor.RED + "You is in game");
				}
			}
			
			if(line[1].equals(ChatColor.RED+"Quit")){
				
				//System.out.println("work 3");//debug
				
				if(Teams.getPlayerInWhereArea().containsKey(player)){
					Teams.QuitTeam(player);
				}else{
					player.sendMessage(ChatColor.RED + "You not in game");
				}
			}
		}
	}
	
}
 
开发者ID:cocomine,项目名称:FastSpawn,代码行数:47,代码来源:ClickEvent.java

示例11: onPlayerRightClickBlock

import org.bukkit.block.Sign; //导入方法依赖的package包/类
@Override
public void onPlayerRightClickBlock(PlayerInteractEvent event, BPPlayer bpPlayer)
{
	Block block = event.getClickedBlock();
	Material mat = block.getType();
	if(mat == Material.STONE_BUTTON)
	{
		Button button = (Button) block.getState().getData();
		Block attBlock = block.getRelative(button.getAttachedFace());
		if(attBlock.getType() == Material.WOOL)
			clickedWoolButton(event, attBlock, bpPlayer);
	}
	else if(mat == Material.WALL_SIGN || mat == Material.SIGN_POST)
	{
		Sign sign = (Sign) block.getState();
		String[] lines = sign.getLines();
		
		if(ChatColor.stripColor(lines[0]).equals(MessageType.CHARACTER_SELECT.getTranslation().getValue()))
		{
			Player player = bpPlayer.getPlayer();
			CTFProperties props = (CTFProperties) bpPlayer.getGameProperties();
			Team team = props.getTeam();
			if(team != null)
			{
				CharacterType selectedCT = props.getCharacterType();
				if(selectedCT == null)
				{
					String rawCharType = ChatColor.stripColor(lines[1]);
					CharacterType charType = null;
					for(CharacterType ct : CharacterType.values())
						if(rawCharType.equalsIgnoreCase(ct.getProperName()))
						{
							charType = ct;
							break;
						}
					if(charType != null)
					{
						String name = charType.getProperName();
						
						if(charType.requiresVIP() && !player.hasPermission("Breakpoint.vip"))
						{
							player.sendMessage(ChatColor.DARK_GRAY + "---");
							player.sendMessage(MessageType.LOBBY_CHARACTER_VIPSONLY.getTranslation().getValue(name));
							player.sendMessage(ChatColor.DARK_GRAY + "---");
							return;
						}
						props.chooseCharacter(charType, true);
						player.sendMessage(MessageType.LOBBY_CHARACTER_SELECTED.getTranslation().getValue(name));
					}
					else
						player.sendMessage(MessageType.LOBBY_CHARACTER_NOTFOUND.getTranslation().getValue(rawCharType));
				}
				else
				{
					String charName = selectedCT.getProperName();
					player.sendMessage(MessageType.LOBBY_CHARACTER_ALREADYSELECTED.getTranslation().getValue(charName));
				}
			}
			else
				player.sendMessage(MessageType.LOBBY_TEAM_WARN.getTranslation().getValue());
		}
	}
}
 
开发者ID:Limeth,项目名称:Breakpoint,代码行数:64,代码来源:CTFListener.java

示例12: onPlayerRightClickBlock

import org.bukkit.block.Sign; //导入方法依赖的package包/类
@Override
public void onPlayerRightClickBlock(PlayerInteractEvent event, BPPlayer bpPlayer)
{
	Block block = event.getClickedBlock();
	Material mat = block.getType();
	if(mat == Material.WALL_SIGN || mat == Material.SIGN_POST)
	{
		Sign sign = (Sign) block.getState();
		String[] lines = sign.getLines();
		
		if(ChatColor.stripColor(lines[0]).equals(MessageType.CHARACTER_SELECT.getTranslation().getValue()))
		{
			Player player = bpPlayer.getPlayer();
			DMProperties props = (DMProperties) bpPlayer.getGameProperties();
			CharacterType selectedCT = props.getCharacterType();
			
			if(selectedCT == null)
			{
				String rawCharType = ChatColor.stripColor(lines[1]);
				CharacterType charType = null;
				
				for(CharacterType ct : CharacterType.values())
					if(rawCharType.equalsIgnoreCase(ct.getProperName()))
					{
						charType = ct;
						break;
					}
				
				if(charType != null)
				{
					String name = charType.getProperName();
					
					if(charType.requiresVIP() && !player.hasPermission("Breakpoint.vip"))
					{
						player.sendMessage(ChatColor.DARK_GRAY + "---");
						player.sendMessage(MessageType.LOBBY_CHARACTER_VIPSONLY.getTranslation().getValue(name));
						player.sendMessage(ChatColor.DARK_GRAY + "---");
						return;
					}
					
					props.chooseCharacter(charType, true);
					player.sendMessage(MessageType.LOBBY_CHARACTER_SELECTED.getTranslation().getValue(name));
				}
				else
					player.sendMessage(MessageType.LOBBY_CHARACTER_NOTFOUND.getTranslation().getValue(rawCharType));
			}
			else
			{
				String charName = selectedCT.getProperName();
				player.sendMessage(MessageType.LOBBY_CHARACTER_ALREADYSELECTED.getTranslation().getValue(charName));
			}
		}
	}
}
 
开发者ID:Limeth,项目名称:Breakpoint,代码行数:55,代码来源:DMListener.java


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