SignListener.java 文件源码

java
阅读 24 收藏 0 点赞 0 评论 0

项目:SkyWarsReloaded 作者:
@EventHandler
  public void signRemoved(BlockBreakEvent event) {
      Location blockLocation = event.getBlock().getLocation();
      World w = blockLocation.getWorld();
    Block b = w.getBlockAt(blockLocation);
if(b.getType() == Material.WALL_SIGN || b.getType() == Material.SIGN_POST){
    Sign sign = (Sign) b.getState();
    String line1 = ChatColor.stripColor(sign.getLine(0));
    if (line1.equalsIgnoreCase(ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', new Messaging.MessageFormatter().format("signJoinSigns.line1"))))) {
             String world = blockLocation.getWorld().getName().toString();
             int x = blockLocation.getBlockX();
             int y = blockLocation.getBlockY();
             int z = blockLocation.getBlockZ();
             File signJoinFile = new File(SkyWarsReloaded.get().getDataFolder(), "signJoinGames.yml");
             if (signJoinFile.exists()) {
                FileConfiguration storage = YamlConfiguration.loadConfiguration(signJoinFile);
                  for (String gameNumber : storage.getConfigurationSection("games.").getKeys(false)) {
                    String world1 = storage.getString("games." + gameNumber + ".world");
                    int x1 = storage.getInt("games." + gameNumber + ".x");
                    int y1 = storage.getInt("games." + gameNumber + ".y");
                    int z1 = storage.getInt("games." + gameNumber + ".z");
                    if (x1 == x && y1 == y && z1 == z && world.equalsIgnoreCase(world1)) {
                        if (event.getPlayer().hasPermission("swr.signs")) {
                                SkyWarsReloaded.getGC().removeSignJoinGame(gameNumber);
                            } else {
                                event.setCancelled(true);
                            event.getPlayer().sendMessage(ChatColor.RED + "YOU DO NOT HAVE PERMISSION TO DESTROY SWR SIGNS");
                        }
                    }
                    } 
             }
           }
}
  }
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号