當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。