本文整理汇总了Java中org.bukkit.block.Sign.getLine方法的典型用法代码示例。如果您正苦于以下问题:Java Sign.getLine方法的具体用法?Java Sign.getLine怎么用?Java Sign.getLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.block.Sign
的用法示例。
在下文中一共展示了Sign.getLine方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: commit
import org.bukkit.block.Sign; //导入方法依赖的package包/类
@Override
public void commit(Player player, Sign sign) {
String before = sign.getLine(lineNumber);
sign.setLine(lineNumber, text);
sign.update();
int lineRelative = lineNumber + lineOffset;
if (text.isEmpty())
player.sendMessage(CHAT_PREFIX + "§cLine §e" + lineRelative + "§c blanked");
else if (text.equals(before))
player.sendMessage(CHAT_PREFIX + "§cLine §e" + lineRelative + "§c unchanged");
else {
player.sendMessage(CHAT_PREFIX + "§cLine §e" + lineRelative + "§c changed");
player.sendMessage(CHAT_PREFIX + "§c§lBefore: §r" + before);
player.sendMessage(CHAT_PREFIX + "§c §l After: §r" + text);
}
}
示例2: on
import org.bukkit.block.Sign; //导入方法依赖的package包/类
@EventHandler
public void on(PlayerInteractEvent event) {
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
Block block = event.getClickedBlock();
if (block != null) {
if (block.getState() instanceof Sign) {
Sign sign = (Sign) block.getState();
if (plugin.signTitle.equals(sign.getLine(plugin.signLineTitle))) {
event.setCancelled(true);
if (sign.getLine(plugin.signLineLeave) != null) {
if (sign.getLine(plugin.signLineLeave).toLowerCase().contains(plugin.signKeyLeave)) {
event.getPlayer().chat("/murderLeave");
return;
}
}
event.getPlayer().chat("/murderJoin " + sign.getLine(plugin.signLineArena));
Arena arena = plugin.arenaManager.getArenaByName(sign.getLine(plugin.signLineArena));
if (arena != null) { plugin.arenaManager.addArenaSign(arena.id, sign); }
}
}
}
}
}
示例3: onBlockBreak
import org.bukkit.block.Sign; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockBreak(BlockBreakEvent e) {
if (player == null) {
return;
}
Block block = e.getBlock();
if (e.getPlayer().equals(player)) {
if (block.getState() instanceof Sign) {
Sign sign = (Sign) block.getState();
String arenaName = sign.getLine(0);
MapManager.Arena arena = plugin.mapMan.getArena(arenaName);
if (arena == null) {
e.getPlayer().sendMessage(ChatColor.RED + "Incorrect arena name");
} else {
sign.setLine(0, arenaName);
sign.setLine(1, "- " + arena.minPlayers + " equipos -");
sign.setLine(2, "0/" + arena.maxPlayers + " jugadores");
sign.setLine(3, ChatColor.GREEN + "[Lista]");
sign.update();
signList.put(signList.size(), block.getLocation());
}
e.setCancelled(true);
}
}
}
示例4: getGameFromSign
import org.bukkit.block.Sign; //导入方法依赖的package包/类
private Game getGameFromSign(Sign sign) {
try {
final String line = sign.getLine(Config.getInstance().getTeamSign().getGameLine());
for (final Game game : this.controller.games) {
if (String.valueOf(game.getArena().getId()).equals(line) || (game.getArena().getAlias() != null && ChatColor.stripColor(game.getArena().getAlias()).equals(ChatColor.stripColor(line)))) {
return game;
}
}
return null;
} catch (final Exception ex) {
return null;
}
}
示例5: onSignElevator
import org.bukkit.block.Sign; //导入方法依赖的package包/类
@EventHandler
public void onSignElevator(PlayerInteractEvent e) {
if (e.getClickedBlock() == null) {
return;
}
Block block = e.getClickedBlock();
BlockState state = block.getState();
if (state instanceof Sign) {
if(e.getAction() == Action.RIGHT_CLICK_BLOCK) {
Sign sign = (Sign)state;
double zdif = Math.abs(e.getPlayer().getLocation().getZ() - block.getLocation().getZ());
double xdif = Math.abs(e.getPlayer().getLocation().getX() - block.getLocation().getX());
String lineZero = sign.getLine(0);
String lineOne = sign.getLine(1);
if(ChatColor.stripColor(lineZero).equalsIgnoreCase("[Elevator]")) {
if(zdif < 1.5D && xdif < 1.5D ) {
if (ChatColor.stripColor(lineOne).equalsIgnoreCase("Up")) {
e.getPlayer().teleport(this.teleportSpotUp(block.getLocation(), block.getLocation().getBlockY(), 254));
}
if (ChatColor.stripColor(lineOne).equalsIgnoreCase("Down")) {
e.getPlayer().teleport(this.teleportSpotDown(block.getLocation(), block.getLocation().getBlockY(), 1));
}
} else {
e.getPlayer().sendMessage(ChatColor.RED + "You must be standing next to the sign!");
}
}
e.setCancelled(true);
return;
}
}
}
示例6:
import org.bukkit.block.Sign; //导入方法依赖的package包/类
@EventHandler
/* */ public void onClick(PlayerInteractEvent event)
/* */ {
/* 44 */ if ((event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) &&
/* 45 */ (event.getClickedBlock() != null)) {
/* 46 */ Block b = event.getClickedBlock();
/* 47 */ if ((b.getType().equals(Material.SIGN_POST)) || (b.getType().equals(Material.WALL_SIGN))) {
/* 48 */ Sign s = (Sign)event.getClickedBlock().getState();
/* 49 */ if (s.getLine(0).toLowerCase().endsWith(this.plugin.getSignText().toLowerCase()))
/* */ {
/* */
/* 52 */ if (!event.getPlayer().hasPermission("CommandRank.useSign")) {
/* 53 */ this.plugin.getMessager().sendMessage("Main.NoPermissions", event.getPlayer());
/* 54 */ this.plugin.playerFailedPermission(NoPermissionsCause.CommandRank_UseSign, event.getPlayer());
/* 55 */ return;
/* */ }
/* 57 */ if (event.getPlayer().hasPermission("CommandRank.exclude.sign")) {
/* 58 */ this.plugin.getMessager().sendMessage("Main.Excluded", event.getPlayer());
/* 59 */ return;
/* */ }
/* */
/* */
/* */
/* 64 */ String rankup = s.getLine(1);
/* 65 */ if (rankup != null) {
/* 66 */ RankUpHelper.rankUp(event.getPlayer(), rankup, RankUpHelper.RankUpType.Sign);
/* */ }
/* */ }
/* */ }
/* */ }
/* */ }
示例7: onPlayerInteract
import org.bukkit.block.Sign; //导入方法依赖的package包/类
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
if (e.getAction() != Action.RIGHT_CLICK_BLOCK) {
return;
}
if (e.getClickedBlock().getState() instanceof Sign) {
CheckPerms perms = new CheckPerms(wild);
Sign sign = (Sign) e.getClickedBlock().getState();
if (sign.getLine(1).equalsIgnoreCase("[§1Wild§0]") && sign.getLine(0).equalsIgnoreCase("§4====================")) {
if (!Wild.cancel.contains(e.getPlayer().getUniqueId())) {
if(sign.getLine(3)!=null){
try{
for(World world : Bukkit.getWorlds()){
if(world.getName().toLowerCase().equals(sign.getLine(3).toLowerCase())){
perms.check(e.getPlayer(),world.getName());
return;
}
}
Biome biome = Biome.valueOf(sign.getLine(3).toUpperCase());
wild.biome.put(e.getPlayer().getUniqueId(),biome);
}catch(IllegalArgumentException ex){
Location loc = e.getClickedBlock().getLocation();
Bukkit.getLogger().severe("Biome wild sign at " +loc.getWorld().getName()+","+loc.getBlockX()
+","+loc.getBlockY()+ "," + loc.getBlockZ() +" has a biome or a world that is incorrect please fix");
}
}
perms.check(e.getPlayer());
}
}
}
}
示例8: createRecordForIndex
import org.bukkit.block.Sign; //导入方法依赖的package包/类
public Record createRecordForIndex(int idx)
{
Shop shop = shops.get(idx);
Record rec = new Record();
OfflinePlayer player = Bukkit.getOfflinePlayer(shop.getOwner());
Location loc = shop.getLocation();
Sign state = shop.getSigns().get(0);
rec.locWorld = loc.getWorld().getName();
rec.locX = loc.getBlockX();
rec.locY = loc.getBlockY();
rec.locZ = loc.getBlockZ();
rec.id = rec.hashCode();
rec.ownerName = player.getName();
rec.ownerUuid = player.getUniqueId().toString();
rec.signType = shop.isSelling() ? "buy" : "sell";
rec.signPrice = shop.getPrice();
rec.signText = new String[] { state.getLine(1), state.getLine(2) };
// This is necessary as the event's items are sometimes CraftItemStack type. That type does
// not populate its private fields, thus it is useless to Gson's serializer.
ItemStack oldStack = shop.getItem();
ItemStack newStack = new ItemStack(
oldStack.getType(), oldStack.getAmount(), oldStack.getDurability());
newStack.setData(oldStack.getData());
newStack.setItemMeta(oldStack.getItemMeta());
rec.invItems = new ItemStack[] { newStack };
if ( shop.isSelling() )
rec.invInStock = shop.getRemainingStock() > 0;
else
rec.invInStock = shop.getRemainingSpace() > 0;
return rec;
}
示例9: createRecordForIndex
import org.bukkit.block.Sign; //导入方法依赖的package包/类
/** Creates a record from a SignShop "seller", using SignShop's utility functions for data */
public Record createRecordForIndex(int idx)
{
Seller seller = signs[idx];
Record rec = new Record();
Location loc = seller.getSignLocation();
Sign sign = (Sign) seller.getSign().getState();
rec.locWorld = loc.getWorld().getName();
rec.locX = loc.getBlockX();
rec.locY = loc.getBlockY();
rec.locZ = loc.getBlockZ();
rec.id = rec.hashCode();
rec.ownerName = seller.getOwner().getName();
rec.ownerUuid = seller.getOwner().GetIdentifier().getStringIdentifier();
rec.signType = seller.getOperation();
rec.signPrice = economyUtil.parsePrice(sign.getLine(3));
rec.signText = new String[] { sign.getLine(1), sign.getLine(2) };
rec.invItems = processStacks( seller.getItems() );
switch(rec.signType)
{
case "buy":
case "ibuy":
rec.invInStock = checkStock(seller, true, 0);
break;
case "sell":
case "isell":
rec.invInStock = checkStock(seller, false, rec.signPrice);
break;
default:
rec.invInStock = true;
break;
}
return rec;
}
示例10: onSignRightclick
import org.bukkit.block.Sign; //导入方法依赖的package包/类
@EventHandler
public void onSignRightclick(PlayerInteractEvent event){
if(event.getAction() != Action.RIGHT_CLICK_BLOCK)
return;
Block block = event.getClickedBlock();
BlockState state = block.getState();
if(state == null)
return;
if(state instanceof Sign){
Sign sign = (Sign) state;
Player player = event.getPlayer();
if(!sign.getLine(0).equalsIgnoreCase(SIGN_HEADER)){
return;
}
String type = sign.getLine(1);
if(type.equals(SIGN_CREATE)){
// CREATE A LOBBY
if(!ArenaManager.hasFreeWorld()){
ChatManager.info().write("&cThere's no free world left!", player);
return;
}
BukkitLibrary.callEvent(new GameSignInteractEvent(player, GameSign.Type.CREATE_GAME));
}
else if(type.equals(SIGN_JOIN)){
// JOIN A LOBBY
if(GameManager.getRunningGames().size() == 0){
ChatManager.info().write("&cThere's no game running at the moment!", player);
return;
}
BukkitLibrary.callEvent(new GameSignInteractEvent(player, GameSign.Type.JOIN_GAME));
}
}
}
示例11: 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);
}
}
}
}
}
示例12: onSignClick
import org.bukkit.block.Sign; //导入方法依赖的package包/类
/**
* Handles using signs in the lobby to join games
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onSignClick(final PlayerInteractEvent event) {
// We are only interested in hitting signs
if (!event.hasBlock()) {
//getLogger().info("DEBUG: no block");
return;
}
//getLogger().info("DEBUG: action = " + event.getAction());
if (!event.getAction().equals(Action.LEFT_CLICK_BLOCK)) {
return;
}
//getLogger().info("DEBUG: block material = " + event.getClickedBlock().getType());
if (!event.getClickedBlock().getType().equals(Material.SIGN) && !event.getClickedBlock().getType().equals(Material.WALL_SIGN)
&& !event.getClickedBlock().getType().equals(Material.SIGN_POST)) {
return;
}
// Check world
if (!event.getClickedBlock().getWorld().equals(getBeaconzWorld())) {
return;
}
//getLogger().info("DEBUG: click sign");
if (getGameMgr().getLobby().isPlayerInRegion(event.getPlayer())) {
// Check for accidental creative mode hitting
if (event.getPlayer().getGameMode().equals(GameMode.CREATIVE)) {
event.getPlayer().sendMessage(ChatColor.RED + Lang.adminUseSurvival);
event.setCancelled(true);
}
Sign sign = (Sign) event.getClickedBlock().getState();
if (sign.getLine(0).toLowerCase().contains(Lang.adminSignKeyword)) {
for (int i = 1; i < 4; i++) {
String gamename = sign.getLine(i);
//getLogger().info("DEBUG: gamename = " + gamename);
if (getGameMgr().getGame(gamename) != null) {
if (getGameMgr().getGame(gamename).isOver()) {
event.getPlayer().sendMessage(ChatColor.RED + Lang.scoreGameOver);
} else {
getGameMgr().getGame(gamename).join(event.getPlayer());
}
return;
}
}
event.getPlayer().sendMessage(ChatColor.RED + Lang.errorNotReady);
event.getPlayer().sendMessage(ChatColor.RED + Lang.errorNoSuchGame);
}
}
}
示例13: updateSign
import org.bukkit.block.Sign; //导入方法依赖的package包/类
private void updateSign(Sign sign) {
String roomName = sign.getLine(1);
if (plugin.rm.exists(roomName)) {
if (plugin.rm.isEnabled(roomName)) {
String mapName = plugin.rm.getCurrentMap(roomName);
if (mapName != null && plugin.mm.exists(mapName)) {
sign.setLine(3, mapName);
int maxPlayers = plugin.mm.getMaxPlayers(mapName);
int currentPlayers = plugin.gm.getPlayersIn(roomName);
String nowPlaying;
if (currentPlayers < maxPlayers) {
nowPlaying = ChatColor.GREEN + "" + currentPlayers;
} else {
nowPlaying = ChatColor.RED + "" + currentPlayers;
}
nowPlaying = nowPlaying + ChatColor.BLACK + " / "
+ ChatColor.AQUA + maxPlayers;
sign.setLine(2, nowPlaying);
_signs_mutex.lock();
try {
signs.put(roomName, sign.getLocation());
} finally {
_signs_mutex.unlock();
}
} else {
sign.setLine(0, ChatColor.translateAlternateColorCodes('&', plugin.cf.getTextForInvalidMaps()));
}
} else {
sign.setLine(2, ChatColor.translateAlternateColorCodes('&', plugin.cf.getTextForDisabledMaps()));
_signs_mutex.lock();
try {
signs.put(roomName, sign.getLocation());
} finally {
_signs_mutex.unlock();
}
}
} else {
sign.setLine(0, ChatColor.translateAlternateColorCodes('&', plugin.cf.getTextForInvalidRooms()));
}
sign.update();
}
示例14: changeAllCheck
import org.bukkit.block.Sign; //导入方法依赖的package包/类
/**
* Change all sign(s) text to given text array checking a single line
*
* @param location the location surrounded by signs
* @param line the specific line to check
* @param extract the extract of text to check
* @param cs to check the case sensitivity
* @param text a string array of sign line text to change
*/
public void changeAllCheck(final Location location, int line, String extract, boolean cs, String[] text) {
HashMap<String, Boolean> signMap = signFaceMap(location);
for (Map.Entry<String, Boolean> sign : signMap.entrySet()) {
if (sign.getValue()) {
Sign signText = (Sign) location.getBlock().getRelative(BlockFace.valueOf(sign.getKey())).getState();
String signLine = signText.getLine(line);
if (!cs) {
signLine = signLine.toLowerCase();
extract = extract.toLowerCase();
}
if (signLine.equals(extract)) {
for (int i = 0; i < text.length; ++i) if (i != line) signText.setLine(i, text[i]);
signText.update();
}
}
}
}