Java 类org.bukkit.block.Sign 实例源码

项目:HCFCore    文件:DeathSignListener.java   
@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();
    }
}
项目:ProjectAres    文件:SignUpdater.java   
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));
}
项目:Hub    文件:AbstractGame.java   
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);
    }
}
项目:Hub    文件:GameSign.java   
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);
}
项目:SkyWarsReloaded    文件:GameController.java   
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();
                }
            }
        }
    }
}
项目:MinecraftMarket-Plugin    文件:SignsConfig.java   
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);
        }
    }
}
项目:MinecraftMarket-Plugin    文件:SignsListener.java   
@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();
                            }
                        }
                    }
                }
            }
        }
    }
}
项目:BlockBall    文件:Config.java   
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();
}
项目:BlockBall    文件:Config.java   
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();
}
项目:Kineticraft    文件:Splef.java   
@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();
}
项目:Kineticraft    文件:Dungeon.java   
/**
 * 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.
}
项目:WebSandboxMC    文件:BlockBridge.java   
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;
}
项目:NeverLag    文件:AntiQuickShopDoubleChest.java   
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;
}
项目:HCFCore    文件:BlockJumpGlitchFixListener.java   
@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()
            }
        }
    }
}
项目:HCFCore    文件:EventSignListener.java   
@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();
  }
}
项目:HCFCore    文件:EventSignListener.java   
@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();
    }
  }
}
项目:HCFCore    文件:DeathSignListener.java   
@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);
        }
    }
}
项目:HCFCore    文件:BlockJumpGlitchFixListener.java   
@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()
            }
        }
    }
}
项目:HCFCore    文件:EventSignListener.java   
@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();
  }
}
项目:HCFCore    文件:EventSignListener.java   
@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();
    }
  }
}
项目:HCFCore    文件:DeathSignListener.java   
@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();
    }
}
项目:HCFCore    文件:DeathSignListener.java   
@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);
        }
    }
}
项目:VoxelGamesLibv2    文件:SignButtons.java   
@EventHandler
public void signInteract(@Nonnull PlayerInteractEvent event) {
    if (event.getAction() != Action.RIGHT_CLICK_BLOCK || event.getClickedBlock() == null) {
        return;
    }
    // is block a sign?
    if (event.getClickedBlock().getState() instanceof Sign) {
        User user = userHandler.getUser(event.getPlayer().getUniqueId()).orElseThrow(() -> new UserException(
                "Unknown user " + event.getPlayer().getDisplayName() + "(" + event.getPlayer().getUniqueId() + ")"));
        Sign sign = (Sign) event.getClickedBlock().getState();
        for (int i = 0; i < sign.getLines().length; i++) {
            String line = sign.getLines()[i];
            for (String key : getButtons().keySet()) {
                if (line.contains("[" + key + "]")) {
                    //TODO implement perm check
                    getButtons().get(key).execute(user, event.getClickedBlock());
                }
            }
        }
    }
}
项目:VoxelGamesLibv2    文件:SignPlaceholders.java   
@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()));
        }
    }
}
项目:CapCat    文件:SignDatabase.java   
/**
 * 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;
}
项目:CapCat    文件:SignListener.java   
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBreakBlock(BlockBreakEvent event) {
    Block block = event.getBlock();
    Player player = event.getPlayer();
    if (SignDatabase.isSign(block)) {
        Sign s = (Sign) block.getState();
        SignRegistration sr = plugin.signDB.getSign(s.getLocation());
        if (sr != null) {
            event.setCancelled(true);
            player.sendMessage(I18n.format("user.error.break_no_permission"));
        }
    } else if (SignDatabase.attachedBlocks.containsValue(block)) {
        event.setCancelled(true);
        player.sendMessage(I18n.format("user.error.break_no_permission"));
    }
}
项目:CapCat    文件:SignCommands.java   
/**
 * 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());
}
项目:CapCat    文件:SignCommands.java   
/**
 * Release an acquired teleport sign
 * /cc tp release <new-acquire-price>
 */
@SubCommand(value = "release", permission = "cc.tp.release")
public void releaseSign(CommandSender sender, Arguments args) {
    Sign sign = getSignLookat(sender);
    Player player = asPlayer(sender);
    SignRegistration sr = plugin.signDB.getSign(sign.getLocation());
    if (sr == null || !sr.acquired || !player.getUniqueId().equals(sr.ownerId))
        throw new BadCommandException("user.tp.cannot_release");
    double price = args.nextDouble();
    if (!(price <= plugin.cfg.tpsignAcquireFeeMax && price >= plugin.cfg.tpsignAcquireFeeMin)) {
        throw new BadCommandException("user.error.invalid_price",
                plugin.cfg.tpsignAcquireFeeMin, plugin.cfg.tpsignAcquireFeeMax);
    }
    sr.acquireFee = price;
    sr.acquired = false;
    sr.description = "";
    plugin.signDB.query(SignRegistration.class).whereEq(SignRegistration.N_SIGN_ID, sr.getSignId()).update(sr);
    SignDatabase.updateSignContent(sr);
    logToConsole(sr, "user.log.tpsign_release", player.getName(), price);
}
项目:SignEdit    文件:LineSignEditCommit.java   
@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);
    }
}
项目:SignEdit    文件:SignEditTest.java   
@Before
public void setUp() throws Exception {
    Configuration config = new Configuration(File.createTempFile("SignEdit-", "-config.yml"));
    spyConfig = spy(config);
    listener = new Interact();
    doReturn(false).when(spyConfig).writeFullConfig(new YamlConfiguration());

    uiSignSubcommand = mock(UiSignSubcommand.class);
    whenNew(UiSignSubcommand.class).withAnyArguments().thenReturn(uiSignSubcommand);

    signCommand = new SignCommand(spyConfig, listener);

    player = mock(Player.class);
    command = mock(Command.class);
    sign = mock(Sign.class);
    block = mock(Block.class);
    when(player.hasPermission("SignEdit.use")).thenReturn(true);
    when(block.getState()).thenReturn(sign);

    server = mock(Server.class);
    pluginManager = mock(PluginManager.class);
    mockStatic(Bukkit.class);
    when(Bukkit.getServer()).thenReturn(server);
    when(server.getPluginManager()).thenReturn(pluginManager);
}
项目:factions-top    文件:SignManager.java   
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void unregisterSign(BlockBreakEvent event) {
    // Do nothing if block is not a registered sign.
    BlockPos pos = BlockPos.of(event.getBlock());
    if (!signs.containsValue(pos)) {
        return;
    }

    if (!(event.getBlock().getState() instanceof Sign)) {
        removeSign(pos);
        return;
    }

    if (!event.getPlayer().hasPermission("factionstop.sign.break")) {
        event.getPlayer().sendMessage(plugin.getSettings().getPermissionMessage());
        event.setCancelled(true);
        return;
    }

    removeSign(pos);
}
项目:Murder    文件:GameManager.java   
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();
    }
}
项目:Murder    文件:SignListener.java   
@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); }
                }
            }
        }
    }
}
项目:AthenaGM    文件:HubSign.java   
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();
    }
}
项目:AthenaGM    文件:HubSign.java   
/**
 * 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, "");
        }
    }
}
项目:WildernessTp    文件:SignBreak.java   
@EventHandler
public void BlockBreakEvent(BlockBreakEvent e) {

    String noPerm = wild.getConfig().getString("No-Break");
    if (e.getBlock().getState() instanceof Sign) {
        Sign sign = (Sign) e.getBlock().getState();
        if (sign.getLine(0).equalsIgnoreCase("§4====================") &&
                sign.getLine(1).equalsIgnoreCase("[§1Wild§0]") &&
                sign.getLine(2).equalsIgnoreCase("§4====================")) {
            if (!e.getPlayer().hasPermission("wild.wildtp.break.sign")) {
                e.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes( '&', noPerm));
                e.setCancelled(true);
            } else {
                e.getPlayer().sendMessage(ChatColor.GREEN + "You have broken a wildtp sign");
            }
        }
    }
}
项目:spigot-RandomSpawn    文件:SignListener.java   
@EventHandler
public void onSignInteract(PlayerInteractEvent e) {
    if(e.getAction() == Action.RIGHT_CLICK_BLOCK && e.hasBlock() && (e.getClickedBlock().getState() instanceof Sign)) {
        Sign s = (Sign) e.getClickedBlock().getState();

        if(debug) {
            RandomSpawn.logger.info(e.getPlayer().getName() + " is interacting with a sign...checking to see if it's ours.");
            RandomSpawn.logger.info("The sign's first line is: " + s.getLine(0));
        }

        if(s.getLine(0).equalsIgnoreCase("[Random Spawn]")) {
            if(debug)
                RandomSpawn.logger.info("It's our sign. Let's get moving.");
            TeleportUtils.teleport(e.getPlayer());
        }
    }
}
项目:OldBukkit    文件:Utils.java   
public static boolean isaVenda(World w, BlockVector bvmin, BlockVector bvmax) {
    Location min = new Location(w, bvmin.getX(), bvmin.getY(), bvmin.getZ());
    Location max = new Location(w, bvmax.getX(), bvmax.getY(), bvmax.getZ());

    for (int x = min.getBlockX(); x <= max.getBlockX(); x++) {
        for (int y = min.getBlockY(); y <= max.getBlockY(); y++) {
            for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
                Block b = w.getBlockAt(x, y, z);
                if (b.getType() == Material.SIGN_POST && ((Sign) b.getState()).getLine(0).equals(getMensagem("placa_venda.linha1"))) {
                    return true;
                }
            }
        }
    }
    return false;
}
项目:OldBukkit    文件:TerrenosManager.java   
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)));
}
项目:OldBukkit    文件:Utils.java   
public static boolean isaVenda(World w, BlockVector bvmin, BlockVector bvmax) {
    Location min = new Location(w, bvmin.getX(), bvmin.getY(), bvmin.getZ());
    Location max = new Location(w, bvmax.getX(), bvmax.getY(), bvmax.getZ());

    for (int x = min.getBlockX(); x <= max.getBlockX(); x++) {
        for (int y = min.getBlockY(); y <= max.getBlockY(); y++) {
            for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
                Block b = w.getBlockAt(x, y, z);
                if (b.getType() == Material.SIGN_POST && ((Sign) b.getState()).getLine(0).equals(getMensagem("placa_venda.linha1"))) {
                    return true;
                }
            }
        }
    }
    return false;
}