当前位置: 首页>>代码示例>>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;未经允许,请勿转载。