本文整理汇总了Java中org.bukkit.block.Sign.setLine方法的典型用法代码示例。如果您正苦于以下问题:Java Sign.setLine方法的具体用法?Java Sign.setLine怎么用?Java Sign.setLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.block.Sign
的用法示例。
在下文中一共展示了Sign.setLine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateSign
import org.bukkit.block.Sign; //导入方法依赖的package包/类
public void updateSign(int gameNumber) {
GameSign gameSign = signJoinGames.get(gameNumber);
if (gameSign != null) {
World world = SkyWarsReloaded.get().getServer().getWorld(gameSign.getWorld());
if (world != null) {
Block b = world.getBlockAt(gameSign.getX(), gameSign.getY(), gameSign.getZ());
if(b.getType() == Material.WALL_SIGN || b.getType() == Material.SIGN_POST) {
Sign s = (Sign) b.getState();
meteSign = (org.bukkit.material.Sign) b.getState().getData();
Block attachedBlock = b.getRelative(meteSign.getAttachedFace());
String state = getStatusName(getGame(gameNumber));
setMaterial(getStatus(getGame(gameNumber)), attachedBlock);
int max = getGame(gameNumber).getNumberOfSpawns();
int count = getGame(gameNumber).getPlayers().size();
if (s != null) {
s.getBlock().getChunk().load();
s.setLine(0, new Messaging.MessageFormatter().format("signJoinSigns.line1"));
s.setLine(1, new Messaging.MessageFormatter().setVariable("mapName", gameSign.getName().toUpperCase()).format("signJoinSigns.line2"));
s.setLine(2, new Messaging.MessageFormatter().setVariable("gameStatus", state).format("signJoinSigns.line3"));
s.setLine(3, new Messaging.MessageFormatter().setVariable("count", "" + count).setVariable("max", "" + max).format("signJoinSigns.line4"));
s.update();
}
}
}
}
}
示例2: updateTeamSignConsideringMinigame
import org.bukkit.block.Sign; //导入方法依赖的package包/类
public void updateTeamSignConsideringMinigame(Sign sign, Game game, Team team, Map<Player, Team> preselection) {
int i = 0;
List<Player> players = null;
for (final String s : new String[]{this.line1, this.line2, this.line3, this.line4}) {
if (team == Team.RED) {
if (game.getRedTeamPlayers().length > this.getAmountFromTeam(Team.RED, preselection).size()) {
players = Arrays.asList(game.getRedTeamPlayers());
} else {
players = this.getAmountFromTeam(Team.RED, preselection);
}
}
if (team == Team.BLUE) {
if (game.getBlueTeamPlayers().length > this.getAmountFromTeam(Team.BLUE, preselection).size()) {
players = Arrays.asList(game.getBlueTeamPlayers());
} else {
players = this.getAmountFromTeam(Team.BLUE, preselection);
}
}
sign.setLine(i, this.replace(s, game.getArena(), team, true).replace("<players>", String.valueOf(players.size()))
.replace("<maxplayers>", String.valueOf(game.getArena().getTeamMeta().getTeamMaxSize())));
i++;
}
sign.update();
}
示例3: updateJoinSignConsideringMaxPlayers
import org.bukkit.block.Sign; //导入方法依赖的package包/类
public void updateJoinSignConsideringMaxPlayers(Sign sign, Game game, List<Player> players) {
int i = 0;
final MiniGame g = (MiniGame) game;
String stage = "unknown";
if (g.getStage() == GameStage.DISABLED)
stage = Language.SIGN_DISABLED;
else if (g.getStage() == GameStage.ENABLED)
stage = Language.SIGN_ENABLED;
else if (g.getStage() == GameStage.RUNNING)
stage = Language.SIGN_RUNNING;
for (final String s : new String[]{this.line1, this.line2, this.line3, this.line4}) {
if (game.getPlayers().size() < players.size()) {
sign.setLine(i, this.replace(s, game.getArena(), null, true).replace("<players>", String.valueOf(players.size()))
.replace("<maxplayers>", String.valueOf(game.getArena().getLobbyMeta().getMaxPlayers() * 2))
.replace("<state>", stage));
} else {
sign.setLine(i, this.replace(s, game.getArena(), null, true).replace("<players>", String.valueOf(game.getPlayers().size()))
.replace("<maxplayers>", String.valueOf(game.getArena().getLobbyMeta().getMaxPlayers() * 2))
.replace("<state>", stage));
}
i++;
}
sign.update();
}
示例4: onBlockPlace
import org.bukkit.block.Sign; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled=true, priority=EventPriority.HIGHEST)
public void onBlockPlace(BlockPlaceEvent event)
{
ItemStack stack = event.getItemInHand();
BlockState state = event.getBlock().getState();
if (((state instanceof Sign)) && (stack.hasItemMeta()))
{
ItemMeta meta = stack.getItemMeta();
if ((meta.hasDisplayName()) && (meta.getDisplayName().equals(EVENT_SIGN_ITEM_NAME)))
{
Sign sign = (Sign)state;
List<String> lore = meta.getLore();
int count = 0;
for (String loreLine : lore)
{
sign.setLine(count++, loreLine);
if (count == 4) {
break;
}
}
sign.update();
}
}
}
示例5: onBlockPlace
import org.bukkit.block.Sign; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onBlockPlace(BlockPlaceEvent event) {
ItemStack stack = event.getItemInHand();
BlockState state = event.getBlock().getState();
if (state instanceof Sign && stack.hasItemMeta()) {
ItemMeta meta = stack.getItemMeta();
if (meta.hasDisplayName() && meta.getDisplayName().equals(DEATH_SIGN_ITEM_NAME)) {
Sign sign = (Sign) state;
List<String> lore = meta.getLore();
int count = 0;
for (String loreLine : lore) {
sign.setLine(count++, loreLine);
if (count == 4)
break;
}
sign.update();
//sign.setEditible(false);
}
}
}
示例6: updateSignContent
import org.bukkit.block.Sign; //导入方法依赖的package包/类
/**
* Update the sign content according to the sign registration
* @param sr
* @return
*/
public static boolean updateSignContent(SignRegistration sr) {
Block b = sr.location.getBlock();
if (b.getType() != Material.SIGN_POST && b.getType() != Material.WALL_SIGN)
return false;
Sign s = (Sign)b.getState();
s.setLine(0, I18n.format("user.tp.sign_title"));
s.setLine(1, sr.description);
if (sr.acquired) {
s.setLine(2, String.format("%.0f %.0f %.0f", sr.targetLocation.getX(), sr.targetLocation.getY(),sr.targetLocation.getZ()));
s.setLine(3, String.format("%.1f", sr.teleportFee));
} else {
s.setLine(2, I18n.format("user.tp.available"));
s.setLine(3, String.format("%.1f", sr.acquireFee));
}
s.update();
return true;
}
示例7: removeSign
import org.bukkit.block.Sign; //导入方法依赖的package包/类
/**
* Remove a teleport sign
* Op only
* /cc tp remove
*/
@SubCommand(value="remove", permission = "cc.tp.remove")
public void removeSign(CommandSender sender, Arguments args) {
Sign signLookAt = getSignLookat(sender);
SignRegistration reg = plugin.signDB.getSign(signLookAt.getLocation());
if (reg == null) {
throw new BadCommandException("user.tp.not_registered");
}
plugin.signDB.query(SignRegistration.class).whereEq(SignRegistration.N_SIGN_ID, reg.getSignId()).delete();
for (int i = 0; i < 4; i++) {
signLookAt.setLine(i, "");
}
signLookAt.update();
SignDatabase.attachedBlocks.remove(reg.location.clone());
logToConsole(reg, "user.log.tpsign_remove", asPlayer(sender).getName());
}
示例8: 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);
}
}
示例9: refreshSigns
import org.bukkit.block.Sign; //导入方法依赖的package包/类
public void refreshSigns(Game game) {
for (Sign sign : plugin.arenaManager.getArenaSigns(game.arena.id)) {
if (game.arena.disabled) {
sign.setLine(plugin.signLineState, Game.MESSAGE_LOADER.getMessage("state.disabled.sign", "state.disabled.sign"));
} else if (game.gameState == GameState.DISPOSE) {
sign.setLine(plugin.signLineState, GameState.WAITING.getSignText());
} else {
sign.setLine(plugin.signLineState, game.gameState.getSignText());
}
if (game.arena.disabled) {
sign.setLine(plugin.signLinePlayers, String.format(plugin.signFormatPlayers, "-", "-"));
} else if (game.gameState == GameState.DISPOSE) {
sign.setLine(plugin.signLinePlayers, String.format(plugin.signFormatPlayers, 0, game.arena.maxPlayers));
} else {
sign.setLine(plugin.signLinePlayers, String.format(plugin.signFormatPlayers, game.players.size(), game.arena.maxPlayers));
}
sign.update();
}
}
示例10: update
import org.bukkit.block.Sign; //导入方法依赖的package包/类
public void update() {
if (hub.getWorld() == null) return;
Block block = vector.toLocation(hub.getWorld()).getBlock();
if (block.getState() instanceof Sign) {
Sign sign = (Sign) block.getState();
if (text != null) {
applyCustomSignText(sign);
} else {
String name = getArena().getName();
int players = getArena().getMatch().getTotalPlayers();
String map = getArena().getMatch().getMap().getName();
sign.setLine(0, String.format("%s%s", ChatColor.BOLD, name));
sign.setLine(1, String.format("%s%d players", ChatColor.DARK_GRAY, players));
sign.setLine(2, "");
sign.setLine(3, map);
}
sign.update();
}
}
示例11: applyCustomSignText
import org.bukkit.block.Sign; //导入方法依赖的package包/类
/**
* Apply custom lines of text to the HubSign
*/
private void applyCustomSignText(Sign sign) {
String text = ChatColor.translateAlternateColorCodes('&', this.text);
text = text.replaceAll("%name%", arena.getName());
text = text.replaceAll("%id%", arena.getId());
text = text.replaceAll("%players%", arena.getPlayerCount().toString());
text = text.replaceAll("%max%", arena.getMaxPlayers().toString());
text = text.replaceAll("%map%", arena.getMatch().getMap().getName());
String[] lines = text.split("\\|");
for (int i=0; i<4; i++) {
if (i < lines.length) {
sign.setLine(i, lines[i]);
} else {
sign.setLine(i, "");
}
}
}
示例12: venderTerreno
import org.bukkit.block.Sign; //导入方法依赖的package包/类
public static void venderTerreno(Player p, int preco) {
ProtectedRegion region = getTerreno(p.getName(), getTerrenoNome(p));
if (Utils.isaVenda(p.getWorld(), region.getMinimumPoint(), region.getMaximumPoint())) {
p.sendMessage(Utils.getMensagem("ja_a_venda"));
return;
}
Block b = p.getLocation().getBlock();
b.setType(Material.SIGN_POST);
Sign s = (Sign) b.getState();
s.setLine(0, Utils.getMensagem("placa_venda.linha1").replaceAll("(?i)<preco>", Integer.toString(preco)));
s.setLine(1, Utils.getMensagem("placa_venda.linha2").replaceAll("(?i)<preco>", Integer.toString(preco)));
s.setLine(2, Utils.getMensagem("placa_venda.linha3").replaceAll("(?i)<preco>", Integer.toString(preco)));
s.setLine(3, Utils.getMensagem("placa_venda.linha4").replaceAll("(?i)<preco>", Integer.toString(preco)));
s.update();
p.sendMessage(Utils.getMensagem("colocado_a_venda").replaceAll("(?i)<terreno>", getTerrenoNome(p)));
}
示例13: placeSignInWorld
import org.bukkit.block.Sign; //导入方法依赖的package包/类
private void placeSignInWorld(AnniSign asign, String[] lore)
{
Location loc = asign.getLocation().toLocation();
Block block = loc.getWorld().getBlockAt(loc);//asign.getLocation().toLocation().getBlock();
if(block.getType() != Material.WALL_SIGN && block.getType() != Material.SIGN_POST)
block.getWorld().getBlockAt(loc).setType(asign.isSignPost() ? Material.SIGN_POST : Material.WALL_SIGN);
Sign sign = (Sign)block.getState();
if(sign != null)
{
for(int x = 0; x < lore.length; x++)
sign.setLine(x, lore[x]);
org.bukkit.material.Sign matSign = new org.bukkit.material.Sign(block.getType());
matSign.setFacingDirection(asign.getFacingDirection());
sign.setData(matSign);
sign.update(true);
}
}
示例14: commandEdit
import org.bukkit.block.Sign; //导入方法依赖的package包/类
@SubCommand(value = "edit", permission = "nu.se.admin")
public void commandEdit(CommandSender sender, Arguments args) {
Player player = asPlayer(sender);
int line = args.nextInt();
if (line >= 0 && line < 4) {
Block block = player.getTargetBlock((Set<Material>)null, 5);
if (block != null && block.getState() instanceof Sign) {
String text = args.nextString();
//checkFormatCodes(text);
text = ChatColor.translateAlternateColorCodes('&', text);
if (ChatColor.stripColor(text).length() > plugin.cfg.signedit_max_length) {
throw new BadCommandException("user.signedit.too_long", plugin.cfg.signedit_max_length);
}
if ("CLEAR".equalsIgnoreCase(text)) {
text = "";
}
Sign sign = (Sign) block.getState();
sign.setLine(line, text);
sign.update();
} else {
msg(sender, "user.signedit.not_sign");
}
} else {
msg(sender, "user.signedit.invalid_line");
}
}
示例15: onClick
import org.bukkit.block.Sign; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onClick(PlayerInteractEvent event) {
Block target = event.getClickedBlock();
Player player = event.getPlayer();
UUID id = player.getUniqueId();
if (target.getState() instanceof Sign &&
player.hasPermission(PERMISSION) &&
player.getItemInHand().getType().equals(MATERIAL) &&
playerSignMap.containsKey(id) &&
playerCountMap.containsKey(id)) {
event.setCancelled(true);
Sign sign = (Sign) target.getState();
int count = 0;
for (String line : playerSignMap.get(id)) {
sign.setLine(count, line.replaceAll("%", playerCountMap.get(id).toString()));
count++;
}
sign.update();
playerCountMap.put(id, playerCountMap.get(id) + 1);
}
}