コード例 #1
0
 public void loadBRBuildings() {
   this.brBuilding = new HashMap<String, BRBuilding>();
   Pattern pattern = Pattern.compile("brbuild_([^.]*)\\.dat");
   File theDir = new File(this.getDataFolder().getPath());
   if (theDir.exists()) {
     File[] files = theDir.listFiles();
     for (int i = 0; i < files.length; i++) {
       if (files[i].isFile()) {
         Matcher matcher = pattern.matcher(files[i].getName());
         if (matcher.find()) {
           BRBuilding brb = BRBuilding.getBuilding(files[i]);
           if (brb != null) {
             this.brBuilding.put(brb.getName(), brb);
           }
         }
       }
     }
   }
   this.log.info("LoadBrBuildings:" + this.brBuilding.size());
 }
コード例 #2
0
  public void createRundomBuild(int buildNum) {
    if (this.brBuilding.isEmpty()) {
      return;
    }

    World w = this.getServer().getWorlds().get(0);
    int hugo = 1;
    Random rand = new Random();
    for (int i = buildNum; i > 0; i--) {
      int x =
          w.getSpawnLocation().getBlockX()
              + ((rand.nextInt(360) + 60) * ((rand.nextInt(10) % 2) == 0 ? -1 : 1));
      int y = 64;
      int z =
          w.getSpawnLocation().getBlockZ()
              + ((rand.nextInt(360) + 60) * ((rand.nextInt(10) % 2) == 0 ? -1 : 1));

      // int bItem = (int)Math.floor(Math.random() * (this.brBuilding.size()-1)) ;
      int bItem = rand.nextInt(this.brBuilding.size());
      int j = 0;
      for (BRBuilding brb : this.brBuilding.values()) {
        if (j++ == bItem) {
          if ("classroom".equals(brb.getName()) || "lastbattle".equals(brb.getName())) {
            buildNum++;
            break;
          }
          y = w.getHighestBlockYAt(x, z);
          brb.create(w, new Location(w, x, y, z), true);
          System.out.println(String.format("%s¤ò×ù˜Ë£¨X:%d Y:%d Z:%d£©", brb.getName(), x, y, z));
          // this.createdBrBuilds.add(ChatColor.AQUA+brb.getName()+" -
          // "+ChatColor.GOLD+"×ù˜Ë(X:"+Integer.toString(x)+" Y:"+Integer.toString(y)+"
          // Z:"+Integer.toString(z)+")");
          this.createdBrBuilds.add(
              String.format("%s,%d,%d,%d", BRUtils.removeSuffixint(brb.getName()), x, y, z));
          break;
        }
      }
      hugo = hugo * -1;
    }
  }