@EventHandler(priority = EventPriority.MONITOR)
 public void onEntityExplode(EntityExplodeEvent event) {
   for (Block block : event.blockList()) {
     for (Player player : Bukkit.getOnlinePlayers()) {
       Location location = block.getLocation();
       location.setY(location.getY() + 1);
       Location playerLoc = player.getLocation();
       if (playerLoc.getBlockX() == location.getBlockX()
           && playerLoc.getBlockY() == location.getBlockY()
           && playerLoc.getBlockZ() == location.getBlockZ()) {
         OfflinePlayer damager =
             (TntTracker.getWhoPlaced(event.getEntity()) != null
                 ? Bukkit.getOfflinePlayer(TntTracker.getWhoPlaced(event.getEntity()))
                 : null);
         Bukkit.getServer()
             .getPluginManager()
             .callEvent(
                 new TrackerSpleefEvent(
                     player,
                     damager,
                     (damager != null && damager.isOnline()
                         ? ((Player) damager).getItemInHand()
                         : null),
                     Type.TNT));
       }
     }
   }
 }
Example #2
0
 public Point(String nam, Location upper, Location lower, Location spawn, CaptureState cs) {
   capturestate = cs;
   name = nam;
   spawnlocation = spawn;
   location.add(upper);
   World world = upper.getWorld();
   if (upper.getBlockX() < lower.getBlockX()) {
     for (int i = upper.getBlockX(); i == lower.getBlockX(); i++) {
       if (upper.getBlockZ() < lower.getBlockZ()) {
         for (int id = upper.getBlockZ(); i == lower.getBlockZ(); id++) {
           location.add(new Location(world, i, upper.getBlockY(), id));
         }
       } else {
         for (int id = upper.getBlockZ(); i == lower.getBlockZ(); id--) {
           location.add(new Location(world, i, upper.getBlockY(), id));
         }
       }
     }
   } else if (upper.getBlockX() > lower.getBlockX()) {
     for (int i = upper.getBlockX(); i == lower.getBlockX(); i--) {
       if (upper.getBlockZ() < lower.getBlockZ()) {
         for (int id = upper.getBlockZ(); i == lower.getBlockZ(); id++) {
           location.add(new Location(world, i, upper.getBlockY(), id));
         }
       } else {
         for (int id = upper.getBlockZ(); i == lower.getBlockZ(); id--) {
           location.add(new Location(world, i, upper.getBlockY(), id));
         }
       }
     }
   }
 }
Example #3
0
 public void createMap(String id, Player p) throws EmptyClipboardException {
   Selection sel = WorldEditUtilities.getWorldEdit().getSelection(p);
   if (sel != null) {
     MapConfiguration.getMaps().reloadMap(id);
     Location b1 =
         new Location(
             p.getWorld(),
             sel.getNativeMinimumPoint().getBlockX(),
             sel.getNativeMinimumPoint().getBlockY(),
             sel.getNativeMinimumPoint().getBlockZ());
     Location b2 =
         new Location(
             p.getWorld(),
             sel.getNativeMaximumPoint().getBlockX(),
             sel.getNativeMaximumPoint().getBlockY(),
             sel.getNativeMaximumPoint().getBlockZ());
     MapConfiguration.getMaps().getMap(id).set("region.p1.w", b1.getWorld().getName());
     MapConfiguration.getMaps().getMap(id).set("region.p1.x", b1.getBlockX());
     MapConfiguration.getMaps().getMap(id).set("region.p1.y", b1.getBlockY());
     MapConfiguration.getMaps().getMap(id).set("region.p1.z", b1.getBlockZ());
     MapConfiguration.getMaps().getMap(id).set("region.p2.w", b2.getWorld().getName());
     MapConfiguration.getMaps().getMap(id).set("region.p2.x", b2.getBlockX());
     MapConfiguration.getMaps().getMap(id).set("region.p2.y", b2.getBlockY());
     MapConfiguration.getMaps().getMap(id).set("region.p2.z", b2.getBlockZ());
     MapConfiguration.getMaps().saveMap(id);
     List<String> enabled =
         DataConfiguration.getData().getDataFile().getStringList("enabled-maps");
     enabled.add(id);
     DataConfiguration.getData().getDataFile().set("enabled-maps", enabled);
     DataConfiguration.getData().saveData();
   } else {
     throw new EmptyClipboardException();
   }
 }
Example #4
0
 public void remShelf(Location loc) {
   Shelf shelf = null;
   for (int i = 0; i < shelves.size(); i++) {
     Location key = (Location) shelves.keySet().toArray()[i];
     if (key.getBlockX() == loc.getBlockX()
         && key.getBlockY() == loc.getBlockY()
         && key.getBlockZ() == loc.getBlockZ()
         && key.getWorld().getName().equals(loc.getWorld().getName())) {
       shelf = shelves.get(key);
       break;
     }
   }
   if (shelf != null) {
     shelves.remove(shelf.getLocation());
     getFile()
         .remove(
             loc.getWorld().getName()
                 + ","
                 + loc.getBlockX()
                 + ","
                 + loc.getBlockY()
                 + ","
                 + loc.getBlockZ());
     saveFile();
   }
 }
 @SuppressWarnings("deprecation")
 public void UpdateBarrier(Barrier barrier) {
   CustomConfig conf = plugin.configManager.getConfig("ArenaConfig");
   if (game.mode == ArenaStatus.DISABLED || game.mode == ArenaStatus.WAITING) {
     boolean same = false;
     for (Barrier b : barriers) {
       if (b.getLocation().equals(b.getLocation())) {
         same = true;
       }
     }
     if (!same) {
       Location loc = barrier.getLocation();
       Location loc2 = barrier.getRepairLoc();
       SpawnPoint sp = barrier.getSpawnPoint();
       int name = barrier.getNum();
       conf.set(game.getName() + ".Barriers." + name + ".x", loc.getBlockX());
       conf.set(game.getName() + ".Barriers." + name + ".y", loc.getBlockY());
       conf.set(game.getName() + ".Barriers." + name + ".z", loc.getBlockZ());
       conf.set(game.getName() + ".Barriers." + name + ".rx", loc2.getBlockX());
       conf.set(game.getName() + ".Barriers." + name + ".ry", loc2.getBlockY());
       conf.set(game.getName() + ".Barriers." + name + ".rz", loc2.getBlockZ());
       conf.set(game.getName() + ".Barriers." + name + ".sp", sp.getNumber());
       conf.set(game.getName() + ".Barriers." + name + ".bb", barrier.getBlock().getTypeId());
       conf.set(game.getName() + ".Barriers." + name + ".reward", barrier.getReward());
       conf.saveConfig();
       barriers.add(barrier);
     }
   }
 }
  @EventHandler(priority = EventPriority.NORMAL)
  public void grapple(ProjectileHitEvent event) {
    Entity proj = event.getEntity();
    Location hit = proj.getLocation();

    if (contains(hit, x1, x2, y1, y2, z1, z2) == true) {

      if (proj instanceof Snowball) {
        Snowball fish = (Snowball) proj;
        Entity shooter = fish.getShooter();

        if (shooter instanceof Player) {
          Player p = (Player) shooter;
          Location loc = p.getLocation();
          ItemStack is = p.getItemInHand();
          Material mat = is.getType();

          if (mat == Material.FISHING_ROD) {

            p.setFallDistance(0);
            p.playSound(loc, Sound.ARROW_HIT, 1, 1);

            int hitx = hit.getBlockX();
            int hity = hit.getBlockY();
            int hitz = hit.getBlockZ();
            int locx = loc.getBlockX();
            int locy = loc.getBlockY();
            int locz = loc.getBlockZ();
            double co[] = new double[3];

            if (hitx > locx) {
              co[0] = 1.2;
            } else if (hitx < locx) {
              co[0] = -1.2;
            } else if (hitx == locx) {
              co[0] = 0;
            }

            if (hity > locy) {
              co[1] = 1.4;
            } else if (hity < locy) {
              co[1] = -0.8;
            } else if (hity == locy) {
              co[1] = 0;
            }

            if (hitz > locz) {
              co[2] = 1.2;
            } else if (hitz < locz) {
              co[2] = -1.2;
            } else if (hitz == locz) {
              co[2] = 0;
            }

            p.setVelocity(new Vector(co[0], co[1], co[2]));
          }
        }
      }
    }
  }
Example #7
0
 private String coordLine(Location coord, Location from) {
   return (coord.getBlockX() - from.getBlockX())
       + " "
       + (coord.getBlockY() - from.getBlockY())
       + " "
       + (coord.getBlockZ() - from.getBlockZ());
 }
Example #8
0
  public void loopThrough(Location loc1, Location loc2, World w) {

    File file = new File("plugins/NerdLocker/blocks.lock");
    if (!(file.exists())) {
      try {
        FileInputStream fstream = new FileInputStream("plugins/NerdLocker/blocks.lock");
        fstream.close();
      } catch (IOException e) {
        e.printStackTrace();
      }
    }

    int minx = Math.min(loc1.getBlockX(), loc2.getBlockX()),
        miny = Math.min(loc1.getBlockY(), loc2.getBlockY()),
        minz = Math.min(loc1.getBlockZ(), loc2.getBlockZ()),
        maxx = Math.max(loc1.getBlockX(), loc2.getBlockX()),
        maxy = Math.max(loc1.getBlockY(), loc2.getBlockY()),
        maxz = Math.max(loc1.getBlockZ(), loc2.getBlockZ());
    for (int x = minx; x <= maxx; x++) {
      for (int y = miny; y <= maxy; y++) {
        for (int z = minz; z <= maxz; z++) {
          Block b = w.getBlockAt(x, y, z);
          if (b.getTypeId() != 0) {
            addBlock(b);
          }
        }
      }
    }
  }
  public void createArenaFromSelection(Player pl, String name) {
    FileConfiguration c = SettingsManager.getInstance().getSystemConfig();
    // SettingsManager s = SettingsManager.getInstance();

    WorldEditPlugin we = p.getWorldEdit();
    Selection sel = we.getSelection(pl);
    if (sel == null) {
      Message.send(pl, ChatColor.RED + "You must make a WorldEdit Selection first!");
      return;
    }
    Location max = sel.getMaximumPoint();
    Location min = sel.getMinimumPoint();

    /* if(max.getWorld()!=SettingsManager.getGameWorld() || min.getWorld()!=SettingsManager.getGameWorld()){
    	Message.send(pl, ChatColor.RED+"Wrong World!");
    	return;
    }*/
    SettingsManager.getInstance().getSpawns().set(("spawns." + name), null);
    c.set("system.arenas." + name + ".world", max.getWorld().getName());
    c.set("system.arenas." + name + ".x1", max.getBlockX());
    c.set("system.arenas." + name + ".y1", max.getBlockY());
    c.set("system.arenas." + name + ".z1", max.getBlockZ());
    c.set("system.arenas." + name + ".x2", min.getBlockX());
    c.set("system.arenas." + name + ".y2", min.getBlockY());
    c.set("system.arenas." + name + ".z2", min.getBlockZ());
    c.set("system.arenas." + name + ".enabled", false);
    c.set("system.arenas." + name + ".min", 3);
    c.set("system.arenas." + name + ".max", 4);
    SettingsManager.getInstance().saveSystemConfig();
    hotAddArena(name);
    Message.send(pl, ChatColor.GREEN + "Arena " + name.toUpperCase() + " succesfully added");
  }
Example #10
0
  @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
  public void BlockBreakEvent(BlockBreakEvent e) {

    if (e.getBlock().hasMetadata("ce.Ice")) e.setCancelled(true);

    CEventHandler.handleEvent(e.getPlayer(), e, blockBroken);
    if (e.getBlock().hasMetadata("ce.mine")) {
      Block b = e.getBlock();
      b.removeMetadata("ce.mine", Main.plugin);
      Block[] blocks = {
        b.getRelative(0, 1, 0),
        b.getRelative(1, 0, 0),
        b.getRelative(-1, 0, 0),
        b.getRelative(0, 0, 1),
        b.getRelative(0, 0, -1)
      };

      for (Block block : blocks) {
        if (block.hasMetadata("ce.mine.secondary")) {
          String[] s = block.getMetadata("ce.mine.secondary").get(0).asString().split(" ");
          Location loc =
              new Location(
                  e.getPlayer().getWorld(),
                  Integer.parseInt(s[0]),
                  Integer.parseInt(s[1]),
                  Integer.parseInt(s[2]));
          Location blockLoc = b.getLocation();
          if (loc.getBlockX() == blockLoc.getBlockX()
              && loc.getBlockY() == blockLoc.getBlockY()
              && loc.getBlockZ() == blockLoc.getBlockZ())
            block.removeMetadata("ce.mine.secondary", Main.plugin);
        }
      }
    }
  }
  @EventHandler(priority = EventPriority.HIGH)
  public void enterSnitchProximity(PlayerMoveEvent event) {
    Location from = event.getFrom();
    Location to = event.getTo();

    if (from.getBlockX() == to.getBlockX()
        && from.getBlockY() == to.getBlockY()
        && from.getBlockZ() == to.getBlockZ()
        && from.getWorld().equals(to.getWorld())) {
      // Player didn't move by at least one block.
      return;
    }
    Player player = event.getPlayer();
    if (vanishNoPacket.isPlayerInvisible(player)) {
      return;
    }
    String playerName = player.getName();
    Location location = player.getLocation();
    World world = location.getWorld();
    Set<Snitch> inList = playersInSnitches.get(playerName);
    if (inList == null) {
      inList = new TreeSet<Snitch>();
      playersInSnitches.put(player.getName(), inList);
    }
    Set<Snitch> snitches = snitchManager.findSnitches(world, location);
    for (Snitch snitch : snitches) {
      if (!isOnSnitch(snitch, playerName) && doesSnitchExist(snitch, true) || isDebugging()) {
        if (!inList.contains(snitch)) {
          inList.add(snitch);
          for (Player remoteplayer : playerManager.getPlayers()) {
            String remoteName = remoteplayer.getName();
            if (isOnSnitch(snitch, remoteName)) {
              remoteplayer.sendMessage(
                  ChatColor.AQUA
                      + " * "
                      + playerName
                      + " entered snitch at "
                      + snitch.getName()
                      + " ["
                      + snitch.getX()
                      + " "
                      + snitch.getY()
                      + " "
                      + snitch.getZ()
                      + "]");
            }
          }
          plugin.getJaLogger().logSnitchEntry(snitch, location, player);
        }
      }
    }
    Set<Snitch> rmList = new TreeSet<Snitch>();
    for (Snitch snitch : inList) {
      if (snitches.contains(snitch)) {
        continue;
      }
      rmList.add(snitch);
    }
    inList.removeAll(rmList);
  }
 public void sendToSpawn(Gamer gamer) {
   final Player p = gamer.getPlayer();
   Location originalSpawn = p.getWorld().getSpawnLocation();
   MainConfig main = HungergamesApi.getConfigManager().getMainConfig();
   int spawnRadius = main.getSpawnRadius();
   int spawnHeight = main.getSpawnHeight();
   if (spawns.size() > 0) {
     if (spawnItel == null || !spawnItel.hasNext()) spawnItel = spawns.keySet().iterator();
     originalSpawn = spawnItel.next();
     spawnRadius = Math.max(1, spawns.get(originalSpawn)[0]);
     spawnHeight = Math.max(1, spawns.get(originalSpawn)[1]);
   }
   Location spawn = originalSpawn.clone();
   int chances = 0;
   if (p.isInsideVehicle()) p.leaveVehicle();
   p.eject();
   while (chances < main.getTimesToCheckForValidSpawnPerPlayer()) {
     chances++;
     Location newLoc =
         new Location(
             p.getWorld(),
             spawn.getX() + returnChance(-spawnRadius, spawnRadius),
             spawn.getY() + new Random().nextInt(spawnHeight),
             spawn.getZ() + returnChance(-spawnRadius, spawnRadius));
     if (nonSolid.contains(newLoc.getBlock().getTypeId())
         && nonSolid.contains(newLoc.getBlock().getRelative(BlockFace.UP).getTypeId())) {
       while (newLoc.getBlockY() >= 1
           && nonSolid.contains(newLoc.getBlock().getRelative(BlockFace.DOWN).getTypeId())) {
         newLoc = newLoc.add(0, -1, 0);
       }
       if (newLoc.getBlockY() <= 1) continue;
       spawn = newLoc;
       break;
     }
   }
   if (spawn.equals(originalSpawn)) {
     spawn =
         new Location(
             p.getWorld(),
             spawn.getX() + returnChance(-spawnRadius, spawnRadius),
             0,
             spawn.getZ() + returnChance(-spawnRadius, spawnRadius));
     spawn.setY(spawn.getWorld().getHighestBlockYAt(spawn));
     if (gamer.isAlive() && spawn.getY() <= 1) {
       spawn.getBlock().setType(Material.GLASS);
       spawn.setY(spawn.getY() + 1);
     }
   }
   final Location destination = spawn.add(0.5, 0.1, 0.5);
   p.teleport(destination);
   Bukkit.getScheduler()
       .scheduleSyncDelayedTask(
           hg,
           new Runnable() {
             public void run() {
               p.teleport(destination);
             }
           });
 }
  private void drawMaze() {
    int xmid = (xmin + xmax) / 2;
    int zmid = (zmin + zmax) / 2;
    int side = xmax - xmin;
    ArrayList<Location> starts = new ArrayList<>();
    starts.add(new Location(w, xmin + 1.0, alt + 1.0, zmin + 1.0));
    starts.add(new Location(w, xmin + 1.0, alt + 1.0, zmid + 0.0));
    starts.add(new Location(w, xmin + 1.0, alt + 1.0, zmax - 1.0, -90, 0));
    starts.add(new Location(w, xmid + 0.0, alt + 1.0, zmax - 1.0, -90, 0));
    starts.add(new Location(w, xmax - 1.0, alt + 1.0, zmax - 1.0, 180, 0));
    starts.add(new Location(w, xmax - 1.0, alt + 1.0, zmid + 0.0, 180, 0));
    starts.add(new Location(w, xmax - 1.0, alt + 1.0, zmin + 1.0, 90, 0));
    starts.add(new Location(w, xmid + 0.0, alt + 1.0, zmin + 1.0, 90, 0));
    starts.add(new Location(w, xmid + 0.0, alt + 1.0, zmid + 0.0));
    ArrayList<Location> tempstarts = new ArrayList<>();
    for (int length = (side) / 4 - 1; length > 0; length -= ((side) / 4) / (side > 80 ? 8 : 4)) {
      for (Location loc : starts) {
        if (Math.random() < SEG_CLEAR_PROB) {
          clearSegment(loc.getBlockX() - length, loc.getBlockZ(), loc.getBlockX(), loc.getBlockZ());
          tempstarts.add(
              new Location(w, loc.getBlockX() - length, loc.getBlockY(), loc.getBlockZ()));
        } else {
          tempstarts.add(loc);
        }

        if (Math.random() < SEG_CLEAR_PROB) {
          clearSegment(loc.getBlockX(), loc.getBlockZ() - length, loc.getBlockX(), loc.getBlockZ());
          tempstarts.add(
              new Location(w, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ() - length));
        } else {
          tempstarts.add(loc);
        }

        if (Math.random() < SEG_CLEAR_PROB) {
          clearSegment(loc.getBlockX(), loc.getBlockZ(), loc.getBlockX() + length, loc.getBlockZ());
          tempstarts.add(
              new Location(w, loc.getBlockX() + length, loc.getBlockY(), loc.getBlockZ()));
        } else {
          tempstarts.add(loc);
        }

        if (Math.random() < SEG_CLEAR_PROB) {
          clearSegment(loc.getBlockX(), loc.getBlockZ(), loc.getBlockX(), loc.getBlockZ() + length);
          tempstarts.add(
              new Location(w, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ() + length));
        } else {
          tempstarts.add(loc);
        }
      }
      starts = tempstarts;
      tempstarts = new ArrayList<>();
    }
    //        for (int y = alt + 1; y <= alt + HEIGHT; y++) {
    //            w.getBlockAt(xmid - 1, y, zmid).setType(a.getWall());
    //            w.getBlockAt(xmid, y, zmid - 1).setType(a.getWall());
    //            w.getBlockAt(xmid + 1, y, zmid).setType(Material.AIR);
    //            w.getBlockAt(xmid, y, zmid + 1).setType(Material.AIR);
    //        }
  }
Example #14
0
  @EventHandler(priority = EventPriority.NORMAL)
  public void grapple(ProjectileHitEvent event) {
    Entity proj = event.getEntity();
    Location hit = proj.getLocation();

    if (!event.getEntity().getWorld().getName().equals(getName())) return;

    if (proj instanceof Snowball) {
      Snowball fish = (Snowball) proj;
      ProjectileSource shooter = (ProjectileSource) fish.getShooter();
      if (shooter instanceof Player) {
        Player player = (Player) shooter;
        Location location = player.getLocation();
        ItemStack itemStack = player.getItemInHand();
        Material material = itemStack.getType();

        if (material == Material.FISHING_ROD) {

          player.setFallDistance(0);
          player.playSound(location, Sound.ARROW_HIT, 1, 1);

          int hitx = hit.getBlockX();
          int hity = hit.getBlockY();
          int hitz = hit.getBlockZ();
          int locx = location.getBlockX();
          int locy = location.getBlockY();
          int locz = location.getBlockZ();
          double co[] = new double[3];

          if (hitx > locx) {
            co[0] = 1.2;
          } else if (hitx < locx) {
            co[0] = -1.2;
          } else if (hitx == locx) {
            co[0] = 0;
          }

          if (hity > locy) {
            co[1] = 1.4;
          } else if (hity < locy) {
            co[1] = -0.8;
          } else if (hity == locy) {
            co[1] = 0;
          }

          if (hitz > locz) {
            co[2] = 1.2;
          } else if (hitz < locz) {
            co[2] = -1.2;
          } else if (hitz == locz) {
            co[2] = 0;
          }

          player.setVelocity(new Vector(co[0], co[1] / 1.25, co[2]));
        }
      }
    }
  }
Example #15
0
 private static int[] area(Location firstPoint, Location secndPoint) {
   return new int[] {
     Math.min(firstPoint.getBlockX(), secndPoint.getBlockX()),
     Math.max(firstPoint.getBlockX(), secndPoint.getBlockX()),
     Math.min(firstPoint.getBlockY(), secndPoint.getBlockY()),
     Math.max(firstPoint.getBlockY(), secndPoint.getBlockY()),
     Math.min(firstPoint.getBlockZ(), secndPoint.getBlockZ()),
     Math.max(firstPoint.getBlockZ(), secndPoint.getBlockZ()),
   };
 }
  public void playNote(Location loc, byte instrument, byte note) {
    if (getHandle().playerNetServerHandler == null) return;

    int id = getHandle().worldObj.getBlockId(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
    getHandle()
        .playerNetServerHandler
        .sendPacketToPlayer(
            new Packet54PlayNoteBlock(
                loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), id, instrument, note));
  }
  private void validateBlockLocation(Player player, Location loc) throws CivException {
    Block b = loc.getBlock();

    if (ItemManager.getId(b) == CivData.CHEST) {
      throw new CivException("Cannot build here, would destroy chest.");
    }

    TownChunk tc = CivGlobal.getTownChunk(b.getLocation());

    if (tc != null
        && !tc.perms.hasPermission(PlotPermissions.Type.DESTROY, CivGlobal.getResident(player))) {
      // Make sure we have permission to destroy any block in this area.
      throw new CivException(
          "Cannot build here, you need DESTROY permissions to the block at "
              + b.getX()
              + ","
              + b.getY()
              + ","
              + b.getZ());
    }

    BlockCoord coord = new BlockCoord(b);
    // not building a trade outpost, prevent protected blocks from being destroyed.
    if (CivGlobal.getProtectedBlock(coord) != null) {
      throw new CivException("Cannot build here, protected blocks in the way.");
    }

    if (CivGlobal.getStructureBlock(coord) != null) {
      throw new CivException("Cannot build here, structure blocks in the way at " + coord);
    }

    if (CivGlobal.getFarmChunk(new ChunkCoord(coord.getLocation())) != null) {
      throw new CivException("Cannot build here, in the same chunk as a farm improvement.");
    }

    if (loc.getBlockY() >= Wall.MAX_HEIGHT) {
      throw new CivException("Cannot build here, wall is too high.");
    }

    if (loc.getBlockY() <= 1) {
      throw new CivException("Cannot build here, too close to bedrock.");
    }

    BlockCoord bcoord = new BlockCoord(loc);
    for (int y = 0; y < 256; y++) {
      bcoord.setY(y);
      StructureBlock sb = CivGlobal.getStructureBlock(bcoord);
      if (sb != null) {
        throw new CivException(
            "Cannot build here, this wall segment overlaps with a structure block belonging to a "
                + sb.getOwner().getName()
                + " structure.");
      }
    }
  }
Example #18
0
 public List<Block> getBlocks() {
   List<Block> blocks = new ArrayList<Block>();
   for (int x = minLoc.getBlockX(); x < maxLoc.getBlockX() + 1; x++) {
     for (int y = minLoc.getBlockY(); y < maxLoc.getBlockY() + 1; y++) {
       for (int z = minLoc.getBlockZ(); z < maxLoc.getBlockZ() + 1; z++) {
         blocks.add(minLoc.getWorld().getBlockAt(new Location(minLoc.getWorld(), x, y, z)));
       }
     }
   }
   return blocks;
 }
Example #19
0
  public void playNote(Location loc, byte instrument, byte note) {
    if (getHandle().field_71135_a == null) return;

    int id =
        getHandle().field_70170_p.func_72798_a(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
    getHandle()
        .field_71135_a
        .func_72567_b(
            new net.minecraft.network.packet.Packet54PlayNoteBlock(
                loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), id, instrument, note));
  }
Example #20
0
  public MonumentBlock getBlock(Location location) {
    for (MonumentBlock block : getBlocks()) {
      Location loc = block.getLocation();
      boolean x = loc.getBlockX() == location.getBlockX();
      boolean y = loc.getBlockY() == location.getBlockY();
      boolean z = loc.getBlockZ() == location.getBlockZ();
      if (x && y && z) return block;
    }

    return null;
  }
 @EventHandler(priority = EventPriority.HIGHEST)
 public void onPlayerJump(PlayerMoveEvent event) {
   Location from = event.getFrom();
   Location to = event.getTo();
   if (to.getBlockY() > from.getBlockY()) {
     Player player = event.getPlayer();
     if (FOPM_TFM_Util.isDoubleJumper(player)) {
       player.setAllowFlight(true);
     }
   }
 }
Example #22
0
 public boolean containsBlock(Location v) {
   if (v.getWorld() != min.getWorld()) return false;
   final double x = v.getX();
   final double y = v.getY();
   final double z = v.getZ();
   return x >= min.getBlockX()
       && x < max.getBlockX() + 1
       && y >= min.getBlockY()
       && y < max.getBlockY() + 1
       && z >= min.getBlockZ()
       && z < max.getBlockZ() + 1;
 }
Example #23
0
 public Shelf getShelf(Location loc) {
   for (int i = 0; i < shelves.size(); i++) {
     Location key = (Location) shelves.keySet().toArray()[i];
     if (key.getBlockX() == loc.getBlockX()
         && key.getBlockY() == loc.getBlockY()
         && key.getBlockZ() == loc.getBlockZ()
         && key.getWorld().getName().equals(loc.getWorld().getName())) {
       return shelves.get(key);
     }
   }
   return null;
 }
Example #24
0
  /**
   * Returns the distance from the given location to the border.
   *
   * <p>If the location is inside the border, or not in the same world, this returns 0.
   *
   * @param location The location to be checked.
   * @param diameter The "diameter" of the squared wall (i.e. the size of a side of the wall).
   * @return the distance from the given location to the border.
   */
  private int getDistanceToSquaredBorder(Location location, int diameter) {
    if (!location.getWorld().equals(Bukkit.getWorlds().get(0))) { // The nether is not limited.
      return 0;
    }
    if (isInsideBorder(location, diameter)) {
      return 0;
    }

    Integer halfMapSize = (int) Math.floor(diameter / 2);
    Integer x = location.getBlockX();
    Integer z = location.getBlockZ();

    Location spawn = Bukkit.getWorlds().get(0).getSpawnLocation();
    Integer limitXInf = spawn.add(-halfMapSize, 0, 0).getBlockX();

    spawn = Bukkit.getWorlds().get(0).getSpawnLocation();
    Integer limitXSup = spawn.add(halfMapSize, 0, 0).getBlockX();

    spawn = Bukkit.getWorlds().get(0).getSpawnLocation();
    Integer limitZInf = spawn.add(0, 0, -halfMapSize).getBlockZ();

    spawn = Bukkit.getWorlds().get(0).getSpawnLocation();
    Integer limitZSup = spawn.add(0, 0, halfMapSize).getBlockZ();

    if (x > limitXSup && z < limitZSup && z > limitZInf) { // East of the border
      return Math.abs(x - limitXSup);
    } else if (x < limitXInf && z < limitZSup && z > limitZInf) { // West of the border
      return Math.abs(x - limitXInf);
    } else if (z > limitZSup && x < limitXSup && x > limitXInf) { // South of the border
      return Math.abs(z - limitZSup);
    } else if (z < limitZInf && x < limitXSup && x > limitXInf) { // North of the border
      return Math.abs(z - limitZInf);
    } else if (x > limitXSup && z < limitZInf) { // N-E
      return (int)
          location.distance(
              new Location(location.getWorld(), limitXSup, location.getBlockY(), limitZInf));
    } else if (x > limitXSup && z > limitZSup) { // S-E
      return (int)
          location.distance(
              new Location(location.getWorld(), limitXSup, location.getBlockY(), limitZSup));
    } else if (x < limitXInf && z > limitZSup) { // S-O
      return (int)
          location.distance(
              new Location(location.getWorld(), limitXInf, location.getBlockY(), limitZSup));
    } else if (x < limitXInf && z < limitZInf) { // N-O
      return (int)
          location.distance(
              new Location(location.getWorld(), limitXInf, location.getBlockY(), limitZInf));
    } else {
      return 0; // Should never happen.
    }
  }
Example #25
0
 public List<Block> getSpawnBlock() {
   List<Block> blocks = new ArrayList<Block>();
   for (int x = minLoc.getBlockX(); x < maxLoc.getBlockX() + 1; x++) {
     for (int y = minLoc.getBlockY(); y < maxLoc.getBlockY() + 1; y++) {
       for (int z = minLoc.getBlockZ(); z < maxLoc.getBlockZ() + 1; z++) {
         if (minLoc.getWorld().getBlockAt(new Location(minLoc.getWorld(), x, y, z)).getType()
             == Material.GOLD_BLOCK)
           blocks.add(minLoc.getWorld().getBlockAt(new Location(minLoc.getWorld(), x, y, z)));
       }
     }
   }
   return blocks;
 }
Example #26
0
  @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
  public void PlayerMoveEvent(PlayerMoveEvent e) {

    Location from = e.getFrom();
    Location to = e.getTo();

    if (from.getBlockX() != to.getBlockX()
        || from.getBlockY() != to.getBlockY()
        || from.getBlockZ() != to.getBlockZ()) {

      CEventHandler.handleEvent(e.getPlayer(), e, move);
      CEventHandler.handleMines(e.getPlayer(), e);
    }
  }
Example #27
0
  @Override
  public final int triggerRenderOfVolume(Location l0, Location l1) {
    int x0 = l0.getBlockX(), y0 = l0.getBlockY(), z0 = l0.getBlockZ();
    int x1 = l1.getBlockX(), y1 = l1.getBlockY(), z1 = l1.getBlockZ();

    return core.triggerRenderOfVolume(
        BukkitWorld.normalizeWorldName(l0.getWorld().getName()),
        Math.min(x0, x1),
        Math.min(y0, y1),
        Math.min(z0, z1),
        Math.max(x0, x1),
        Math.max(y0, y1),
        Math.max(z0, z1));
  }
Example #28
0
 // ############################################################################################
 public void setRegion(String regionName, int respawnTime, Location right, Location left) {
   // Record all the properties
   this.config.set("region." + regionName + ".respawnTime", respawnTime);
   this.config.set("region." + regionName + ".left.X", left.getBlockX());
   this.config.set("region." + regionName + ".left.Y", left.getBlockY());
   this.config.set("region." + regionName + ".left.Z", left.getBlockZ());
   this.config.set("region." + regionName + ".right.X", right.getBlockX());
   this.config.set("region." + regionName + ".right.Y", right.getBlockY());
   this.config.set("region." + regionName + ".right.Z", right.getBlockZ());
   this.config.set("region." + regionName + ".world", right.getWorld().getName());
   this.config.set("region." + regionName + ".feedbackID", 0);
   this.config.set("region." + regionName + ".type", 0);
   // Save the configuration file
   this.save();
 }
Example #29
0
  public static List<Location> getCorners(Location center, int radius) {
    List<Location> locs = new ArrayList<Location>();
    int cX = center.getBlockX();
    int cZ = center.getBlockZ();
    int minX = Math.min(cX + radius, cX - radius);
    int maxX = Math.max(cX + radius, cX - radius);
    int minZ = Math.min(cZ + radius, cZ - radius);
    int maxZ = Math.max(cZ + radius, cZ - radius);

    locs.add(new Location(center.getWorld(), minX, center.getBlockY(), minZ));
    locs.add(new Location(center.getWorld(), maxX, center.getBlockY(), minZ));
    locs.add(new Location(center.getWorld(), minX, center.getBlockY(), maxZ));
    locs.add(new Location(center.getWorld(), maxX, center.getBlockY(), maxZ));
    return locs;
  }
Example #30
0
  private void playOutExplosion(GlowPlayer player, Iterable<BlockVector> blocks) {
    Collection<ExplosionMessage.Record> records = new ArrayList<>();

    Location clientLoc = location.clone();
    clientLoc.setX((int) clientLoc.getX());
    clientLoc.setY((int) clientLoc.getY());
    clientLoc.setZ((int) clientLoc.getZ());

    for (BlockVector block : blocks) {
      byte x = (byte) (block.getBlockX() - clientLoc.getBlockX());
      byte y = (byte) (block.getBlockY() - clientLoc.getBlockY());
      byte z = (byte) (block.getBlockZ() - clientLoc.getBlockZ());
      records.add(new ExplosionMessage.Record(x, y, z));
    }

    Vector velocity = player.getVelocity();
    ExplosionMessage message =
        new ExplosionMessage(
            (float) location.getX(),
            (float) location.getY(),
            (float) location.getZ(),
            5,
            (float) velocity.getX(),
            (float) velocity.getY(),
            (float) velocity.getZ(),
            records);

    player.getSession().send(message);
  }