当前位置: 首页>>代码示例>>Java>>正文


Java Sign类代码示例

本文整理汇总了Java中org.bukkit.block.Sign的典型用法代码示例。如果您正苦于以下问题:Java Sign类的具体用法?Java Sign怎么用?Java Sign使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Sign类属于org.bukkit.block包,在下文中一共展示了Sign类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onBlockBreak

import org.bukkit.block.Sign; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onBlockBreak(BlockBreakEvent event) {
    Block block = event.getBlock();
    if (isDeathSign(block)) {
        BlockState state = block.getState();
        Sign sign = (Sign) state;
        ItemStack stack = new ItemStack(Material.SIGN, 1);
        ItemMeta meta = stack.getItemMeta();
        meta.setDisplayName(DEATH_SIGN_ITEM_NAME);
        meta.setLore(Arrays.asList(sign.getLines()));
        stack.setItemMeta(meta);

        Player player = event.getPlayer();
        World world = player.getWorld();
        if (player.getGameMode() != GameMode.CREATIVE && world.isGameRule("doTileDrops")) {
            world.dropItemNaturally(block.getLocation(), stack);
        }

        // Manually handle the dropping
        event.setCancelled(true);
        block.setType(Material.AIR);
        state.update();
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:25,代码来源:DeathSignListener.java

示例2: createSign

import org.bukkit.block.Sign; //导入依赖的package包/类
private @Nullable SignHandle createSign(Sign blockState) {
    String prev = "";
    final List<Navigator.Connector> connectors = new ArrayList<>();

    for(BaseComponent component : blockState.lines()) {
        String line = component.toPlainText();
        if(line.endsWith("\\")) {
            prev += line.substring(0, line.length() - 1);
        } else {
            final Navigator.Connector connector = navigator.parseConnector(prev + line);
            if(connector != null) {
                connectors.add(connector);
            }
        }
    }

    return connectors.isEmpty() ? null : new SignHandle(blockState, navigator.combineConnectors(connectors));
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:19,代码来源:SignUpdater.java

示例3: addSignForMap

import org.bukkit.block.Sign; //导入依赖的package包/类
public void addSignForMap(String map, ChatColor color, String template, RestrictedVersion restrictedVersion, Sign sign)
{
    GameSign gameSign = new GameSign(this.hub, this, map, color, template, restrictedVersion, sign);

    Jedis jedis = SamaGamesAPI.get().getBungeeResource();

    if (jedis != null && jedis.exists("hub:maintenance:" + this.getCodeName() + ":" + template))
        gameSign.setMaintenance(Boolean.valueOf(jedis.get("hub:maintenance:" + this.getCodeName() + ":" + template)));
    if (jedis != null && jedis.exists("hub:soon:" + this.getCodeName() + ":" + template))
        gameSign.setSoon(Boolean.valueOf(jedis.get("hub:soon:" + this.getCodeName() + ":" + template)));

    if (jedis != null)
        jedis.close();

    if (this.signs.containsKey(map))
    {
        this.signs.get(map).add(gameSign);
    }
    else
    {
        List<GameSign> list = new ArrayList<>();
        list.add(gameSign);

        this.signs.put(map, list);
    }
}
 
开发者ID:SamaGames,项目名称:Hub,代码行数:27,代码来源:AbstractGame.java

示例4: GameSign

import org.bukkit.block.Sign; //导入依赖的package包/类
public GameSign(Hub hub, AbstractGame game, String map, ChatColor color, String template, RestrictedVersion restrictedVersion, Sign sign)
{
    this.hub = hub;
    this.game = game;
    this.map = map;
    this.color = color;
    this.template = template;
    this.restrictedVersion = restrictedVersion;
    this.sign = sign;

    this.sign.setMetadata("game", new FixedMetadataValue(hub, game.getCodeName()));
    this.sign.setMetadata("map", new FixedMetadataValue(hub, map));

    hub.getScheduledExecutorService().scheduleAtFixedRate(this::scrollMapName, 500, 500, TimeUnit.MILLISECONDS);

    this.updateTask = hub.getServer().getScheduler().runTaskTimerAsynchronously(hub, this::update, 20L, 20L);
}
 
开发者ID:SamaGames,项目名称:Hub,代码行数:18,代码来源:GameSign.java

示例5: 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();
				}
			}
		}
	}
}
 
开发者ID:smessie,项目名称:SkyWarsReloaded,代码行数:27,代码来源:GameController.java

示例6: SignsConfig

import org.bukkit.block.Sign; //导入依赖的package包/类
public SignsConfig(JavaPlugin plugin) {
    super(plugin, "signs");

    for (String key : config.getKeys(false)) {
        if (Utils.isInt(key)) {
            Set<DonorSign> signs = new HashSet<>();
            for (Location loc : stringsToLocArray(config.getStringList(key))) {
                if (loc != null) {
                    Block block = loc.getWorld().getBlockAt(loc);
                    if (block.getState() instanceof Sign) {
                        signs.add(new DonorSign(Utils.getInt(key), block));
                    }
                }
            }
            donorSigns.put(Utils.getInt(key), signs);
        }
    }
}
 
开发者ID:MinecraftMarket,项目名称:MinecraftMarket-Plugin,代码行数:19,代码来源:SignsConfig.java

示例7: onBlockBreakEvent

import org.bukkit.block.Sign; //导入依赖的package包/类
@EventHandler
public void onBlockBreakEvent(BlockBreakEvent e) {
    if (plugin.getMainConfig().isUseSigns()) {
        if (e.getPlayer().hasPermission("minecraftmarket.signs")) {
            if (plugin.getSignsConfig().getDonorSignFor(e.getBlock()) != null) {
                if (plugin.getSignsConfig().removeDonorSign(e.getBlock())) {
                    e.getPlayer().sendMessage(Colors.color(I18n.tl("prefix") + " " + I18n.tl("sign_removed")));
                    plugin.getSignsTask().updateSigns();
                }
            } else {
                for (BlockFace blockFace : blockFaces) {
                    Block block = e.getBlock().getRelative(blockFace);
                    if (block != null && block.getState() instanceof Sign && Objects.equals(getAttachedBlock(block), e.getBlock())) {
                        if (plugin.getSignsConfig().getDonorSignFor(block) != null) {
                            if (plugin.getSignsConfig().removeDonorSign(block)) {
                                e.getPlayer().sendMessage(Colors.color(I18n.tl("prefix") + " " + I18n.tl("sign_removed")));
                                plugin.getSignsTask().updateSigns();
                            }
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:MinecraftMarket,项目名称:MinecraftMarket-Plugin,代码行数:26,代码来源:SignsListener.java

示例8: 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();
}
 
开发者ID:Shynixn,项目名称:BlockBall,代码行数:25,代码来源:Config.java

示例9: 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();
}
 
开发者ID:Shynixn,项目名称:BlockBall,代码行数:26,代码来源:Config.java

示例10: signAction

import org.bukkit.block.Sign; //导入依赖的package包/类
@Override
public void signAction(String action, Player player, Sign sign) {
    if (!action.equals("Reset Arena"))
        return;

    if (lastReset + (45 * 1000) >= System.currentTimeMillis()) {
        player.sendMessage(ChatColor.RED + "The arena can only be reset once every 45 seconds.");
        return;
    }

    broadcastPlayers("The arena has been reset by " + player.getName() + ".");
    getArena().forEachBlock(l -> {
        if (l.getBlock().getType() == Material.AIR)
            l.getBlock().setType(Material.TNT);
    }, 141);
    lastReset = System.currentTimeMillis();
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:18,代码来源:Splef.java

示例11: updateSigns

import org.bukkit.block.Sign; //导入依赖的package包/类
/**
 * Reload the sign markers.
 */
public void updateSigns() {
    getSigns().clear();
    getScheduler().cancelAll(); // Cancel existing spawn tasks.
    Arrays.asList(getWorld().getLoadedChunks()).forEach(c -> Arrays.stream(c.getTileEntities())
            .filter(te -> te instanceof Sign).map(te -> (Sign) te)
            .filter(s -> s.getLine(0).startsWith("[") && s.getLine(0).endsWith("]"))
            .map(ActionSign::new).forEach(getSigns()::add));

    // Schedule actions:
    scheduleAction("Spawn", sign -> { // Allow spawning mobs based on distance.
        EntityType type = EntityType.valueOf(sign.getLine(1).toUpperCase());
        int radius = Integer.parseInt(sign.getLine(3));
        int amount = Integer.parseInt(sign.getLine(2));
        if (Utils.getNearbyPlayers(sign.getLocation(), radius + 2).isEmpty())
            return; // If there are no players nearby, it's not time to summon anything.

        for (int i = 0; i < amount; i++) // Spawn the entities.
            getWorld().spawnEntity(Utils.findSafe(Utils.scatter(sign.getLocation(), radius, 0, radius)), type);

        sign.disable();
    }, 40L, false); // Activate spawners every minute.
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:26,代码来源:Dungeon.java

示例12: getDataBlockUpdateCommand

import org.bukkit.block.Sign; //导入依赖的package包/类
private String getDataBlockUpdateCommand(Location location, Material material, BlockState blockState) {
    if (material == null || material == Material.AIR) return null;

    int light_level = toWebLighting(material, blockState);
    if (light_level != 0) {
        int x = toWebLocationBlockX(location);
        int y = toWebLocationBlockY(location);
        int z = toWebLocationBlockZ(location);
        return "L,0,0,"+x+","+y+","+z+"," + light_level;
    }

    if (material == Material.WALL_SIGN || material == Material.SIGN_POST) {
        Block block = location.getWorld().getBlockAt(location);
        if (blockState instanceof Sign) {
            Sign sign = (Sign) blockState;

            return getNotifySignChange(block.getLocation(), block.getType(), block.getState(), sign.getLines());
        }
    }

    return null;
}
 
开发者ID:satoshinm,项目名称:WebSandboxMC,代码行数:23,代码来源:BlockBridge.java

示例13: isShopBlockNearby

import org.bukkit.block.Sign; //导入依赖的package包/类
private boolean isShopBlockNearby(Block b) {
	if (b == null) {
		return false;
	}
	Block nearChest = null;
	if (b.getType() == Material.CHEST) {
		nearChest = getBlockNearby(b, Material.CHEST);
	} else if (b.getType() == Material.TRAPPED_CHEST) {
		nearChest = getBlockNearby(b, Material.TRAPPED_CHEST);
	}
	if (nearChest == null) {
		return false;
	}
	for (BlockFace face : BLOCKFACE) {
		Block maybeSign = nearChest.getRelative(face);
		if (maybeSign != null && Material.WALL_SIGN == maybeSign.getType()) {
			Sign sign = (Sign) maybeSign.getState();
			if (sign.getLines().length > 0 && sign.getLines()[0].contains(cm.quickshopSignFlag)) {
				return true;
			}
		}
	}
	return false;
}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:25,代码来源:AntiQuickShopDoubleChest.java

示例14: onBlockBreak

import org.bukkit.block.Sign; //导入依赖的package包/类
@EventHandler(ignoreCancelled = false, priority = EventPriority.MONITOR)
public void onBlockBreak(BlockPlaceEvent event) {
    if (event.isCancelled()) {
        Player player = event.getPlayer();
        if (player.getGameMode() == GameMode.CREATIVE || player.getAllowFlight()) {
            return;
        }

        Block block = event.getBlockPlaced();
        if (block.getType().isSolid() && !(block.getState() instanceof Sign)) {
            int playerY = player.getLocation().getBlockY();
            int blockY = block.getLocation().getBlockY();
            if (playerY > blockY) {
                Vector vector = player.getVelocity();
                vector.setX(-0.1);
                vector.setZ(-0.1);
                player.setVelocity(vector.setY(vector.getY() - 0.41999998688697815D)); // Magic number acquired from EntityLiving#bj()
            }
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:22,代码来源:BlockJumpGlitchFixListener.java

示例15: onBlockBreak

import org.bukkit.block.Sign; //导入依赖的package包/类
@EventHandler(ignoreCancelled=true, priority=EventPriority.HIGHEST)
public void onBlockBreak(BlockBreakEvent event)
{
  Block block = event.getBlock();
  if (isEventSign(block))
  {
    BlockState state = block.getState();
    Sign sign = (Sign)state;
    ItemStack stack = new ItemStack(Material.SIGN, 1);
    ItemMeta meta = stack.getItemMeta();
    meta.setDisplayName(EVENT_SIGN_ITEM_NAME);
    meta.setLore(Arrays.asList(sign.getLines()));
    stack.setItemMeta(meta);
    
    Player player = event.getPlayer();
    World world = player.getWorld();
    Location blockLocation = block.getLocation();
    if ((player.getGameMode() != GameMode.CREATIVE) && (world.isGameRule("doTileDrops"))) {
      world.dropItemNaturally(blockLocation, stack);
    }
    event.setCancelled(true);
    block.setType(Material.AIR);
    state.update();
  }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:26,代码来源:EventSignListener.java


注:本文中的org.bukkit.block.Sign类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。