當前位置: 首頁>>代碼示例>>Java>>正文


Java Sign.getWorld方法代碼示例

本文整理匯總了Java中org.bukkit.block.Sign.getWorld方法的典型用法代碼示例。如果您正苦於以下問題:Java Sign.getWorld方法的具體用法?Java Sign.getWorld怎麽用?Java Sign.getWorld使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.block.Sign的用法示例。


在下文中一共展示了Sign.getWorld方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onClickEvent

import org.bukkit.block.Sign; //導入方法依賴的package包/類
/**
 * Gets when a player clicks a sign, and if its a RC sign.
 * @param e The player interact event.
 */
@EventHandler
public void onClickEvent(final PlayerInteractEvent e) {
    double cost = 0;
    String line1 = null;
    if (e.getAction() == Action.LEFT_CLICK_BLOCK || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
        if (e.getClickedBlock().getType() == Material.WALL_SIGN || e.getClickedBlock().getType() == Material.SIGN || e.getClickedBlock().getType() == Material.SIGN_POST) {
            final Sign sign = (Sign) e.getClickedBlock().getState();
            if (sign.getLine(0).equalsIgnoreCase(ChatColor.GREEN + "[RandomCoords]")) {
                if ((RandomCoords.getPlugin().hasPermission(e.getPlayer(), "Random.Admin.*") || RandomCoords.getPlugin().hasPermission(e.getPlayer(), "Random.Admin.Sign") || RandomCoords.getPlugin().hasPermission(e.getPlayer(), "Random.*")) && e.getAction() == Action.LEFT_CLICK_BLOCK) {
                    e.setCancelled(false);
                    return;
                }
                if (RandomCoords.getPlugin().hasPermission(e.getPlayer(), "Random.SignUse") || RandomCoords.getPlugin().hasPermission(e.getPlayer(), "Random.Basic")) {
                    World world = sign.getWorld();
                    if (sign.getLine(1) != null) {
                        line1 = sign.getLine(1).replaceAll("\uF701", "");
                    }
                    if ((line1 != null ? line1.length() : 0) != 0) {
                        if (e.getPlayer().getServer().getWorld(sign.getLine(1).replaceAll("\uF701", "")) == null) {
                            messages.invalidWorld(e.getPlayer(), sign.getLine(1));
                        } else {
                            world = e.getPlayer().getServer().getWorld(sign.getLine(1).replaceAll("\uF701", ""));
                        }


                    }
                    if (sign.getLine(2).replaceAll("\uF701", "").length() != 0 && sign.getLine(2).replaceAll("\uF701", "") != null && !Objects.equals(sign.getLine(2).replaceAll("\uF701", ""), "") && !Objects.equals(sign.getLine(2).replaceAll("\uF701", ""), " ")) {
                        try {
                            cost = Double.valueOf(sign.getLine(2).replaceAll("\uF701", ""));
                        } catch (NumberFormatException Ne) {
                            Bukkit.getServer().getLogger().severe(sign.getLine(2).replaceAll("\uF701", "") + " is not a price!");
                        }

                    }
                    if (coordinates.hasMoney(e.getPlayer(), cost)) {
                        if(!RandomCoords.getPlugin().config.getString("Experimental").equalsIgnoreCase("true")) {
                            coordinates.finalCoordinates(e.getPlayer(), 574272099, 574272099, world, CoordType.SIGN, cost);
                        } else {
                            coordinatesManager.randomlyTeleportPlayer(e.getPlayer(), world, coordinatesManager.key, coordinatesManager.key, CoordType.SIGN, cost);
                        }
                    } else {
                        messages.cost(e.getPlayer(), cost);
                    }

                } else {
                    messages.noPermission(e.getPlayer());
                    e.setCancelled(true);
                }
            }
        }
    }
}
 
開發者ID:jolbol1,項目名稱:RandomCoordinatesV2,代碼行數:57,代碼來源:SignClick.java


注:本文中的org.bukkit.block.Sign.getWorld方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。