本文整理汇总了Java中org.bukkit.block.Sign.update方法的典型用法代码示例。如果您正苦于以下问题:Java Sign.update方法的具体用法?Java Sign.update怎么用?Java Sign.update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.block.Sign
的用法示例。
在下文中一共展示了Sign.update方法的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: handleInteract
import org.bukkit.block.Sign; //导入方法依赖的package包/类
@EventHandler
public void handleInteract(@Nonnull PlayerInteractEvent event) {
if (event.getAction() == org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK && event.getClickedBlock() != null) {
if (event.getClickedBlock().getState() instanceof Sign) {
Sign sign = (Sign) event.getClickedBlock().getState();
if (sign.hasMetadata("UpdateCooldown")) {
long cooldown = sign.getMetadata("UpdateCooldown").get(0).asLong();
if (cooldown > System.currentTimeMillis() - 1 * 1000) {
return;
}
}
sign.update();
sign.setMetadata("UpdateCooldown", new FixedMetadataValue(voxelGamesLib, System.currentTimeMillis()));
}
}
}
示例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: 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();
}
}
示例9: 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();
}
}
示例10: 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)));
}
示例11: 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);
}
}
示例12: 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");
}
}
示例13: 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);
}
}
示例14: 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);
}
}
}
示例15: open
import org.bukkit.block.Sign; //导入方法依赖的package包/类
/**
* Opens the Door Open at a given sign. The
* door will stay open for 10 seconds, then
* will close once more.
*
* @param plugin the plugin instance
* @param sign the sign that was interacted with
*/
public void open(Plugin plugin, final Sign sign) {
section.clear();
sign.setLine(2, Utils.color("&4&lRUN!"));
sign.update();
if (nukeroom) {
Messages.NUKEROOM_OPEN_FOR.broadcast();
} else {
Messages.DOOR_OPENED.broadcast();
}
new BukkitRunnable() {
@Override
public void run() {
activated = false;
section.restore();
sign.setLine(1, "Timer: " + seconds + "s");
sign.setLine(2, "CLICK TO");
sign.setLine(3, "ACTIVATE");
sign.update();
}
}.runTaskLater(plugin, 20 * 10);
}