本文整理匯總了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);
}
}
}
}
}