コード例 #1
0
  private void progress() {
    if (!hasEmptyWaterBottle()) {
      remove();
      return;
    }

    if (player.isDead() || !player.isOnline()) {
      remove();
      return;
    }

    if (player.getWorld() != location.getWorld()) {
      remove();
      return;
    }

    if (System.currentTimeMillis() < time + interval) return;

    time = System.currentTimeMillis();

    Vector direction = Methods.getDirection(location, player.getEyeLocation()).normalize();
    location = location.clone().add(direction);

    if (location == null || block == null) {
      remove();
      return;
    }

    if (location.getBlock().equals(block.getLocation().getBlock())) return;

    if (Methods.isRegionProtectedFromBuild(player, "WaterManipulation", location)) {
      remove();
      return;
    }

    if (location.distance(player.getEyeLocation())
        > Methods.waterbendingNightAugment(range, player.getWorld())) {
      remove();
      return;
    }

    if (location.distance(player.getEyeLocation()) <= 1.5) {
      fillBottle();
      return;
    }

    Block newblock = location.getBlock();
    if (Methods.isTransparentToEarthbending(player, newblock) && !newblock.isLiquid()) {
      block.revertBlock();
      block = new TempBlock(newblock, Material.WATER, full);
    } else {
      remove();
      return;
    }
  }
コード例 #2
0
 public WaterReturn(Player player, Block block) {
   if (instances.containsKey(player)) return;
   this.player = player;
   location = block.getLocation();
   if (Methods.canBend(player.getName(), "WaterManipulation")) {
     if (!Methods.isRegionProtectedFromBuild(player, "WaterManipulation", location)
         && Methods.canBend(player.getName(), "WaterManipulation")) {
       if (Methods.isTransparentToEarthbending(player, block) && !block.isLiquid())
         this.block = new TempBlock(block, Material.WATER, full);
     }
   }
   // if (ID >= Integer.MAX_VALUE) {
   // ID = Integer.MIN_VALUE;
   // }
   // id = ID++;
   instances.put(player, this);
 }