Package org.bukkit

Examples of org.bukkit.Location


            (short) floorMaterialSection.getInt("data")));
      }
    }
    World world = War.war.getServer().getWorld(worldName);
    if (world != null) {
      Location hubLocation = new Location(world, hubX, hubY, hubZ);
      WarHub hub = new WarHub(hubLocation, hubOrientation);
      War.war.setWarHub(hub);
      Volume vol;
      try {
        vol = VolumeMapper.loadVolume("warhub", "", world);
View Full Code Here


    } else {
      worldName = "DEFAULT";
      world = War.war.getServer().getWorlds().get(0); // default to first world
    }
    if (world != null) {
      Location hubLocation = new Location(world, hubX, hubY, hubZ);
      WarHub hub = new WarHub(hubLocation, hubOrientation);
      War.war.setWarHub(hub);
      Volume vol;
      try {
        vol = VolumeMapper.loadVolume("warhub", "", world);
View Full Code Here

    } else {
      yaw = 0;
      this.setOrientation(Direction.WEST());
    }

    this.location = new Location(location.getWorld(),
                location.getX(),
                location.getY(),
                location.getZ(),
                yaw, 0);
    this.volume = new Volume("warhub", location.getWorld());
View Full Code Here

      // no such team yet
      this.msg("Place the team spawn first.");
    } else if (team.getFlagVolume() == null) {
      // new team flag
      team.setTeamFlag(player.getLocation());
      Location playerLoc = player.getLocation();
      player.teleport(new Location(playerLoc.getWorld(), playerLoc.getBlockX() + 1, playerLoc.getBlockY(), playerLoc.getBlockZ()));
      this.msg("Team " + team.getName() + " flag added here.");
      WarzoneYmlMapper.save(zone);
      War.war.log(this.getSender().getName() + " created team " + team.getName() + " flag in warzone " + zone.getName(), Level.INFO);
    } else {
      // relocate flag
      team.getFlagVolume().resetBlocks();
      team.setTeamFlag(player.getLocation());
      Location playerLoc = player.getLocation();
      player.teleport(new Location(playerLoc.getWorld(), playerLoc.getBlockX() + 1, playerLoc.getBlockY(), playerLoc.getBlockZ() + 1));
      this.msg("Team " + team.getName() + " flag moved.");
      WarzoneYmlMapper.save(zone);
      War.war.log(this.getSender().getName() + " moved team " + team.getName() + " flag in warzone " + zone.getName(), Level.INFO);
    }
View Full Code Here

        .prepareStatement("INSERT INTO " + prefix + "_blocks VALUES (?, ?, ?, ?, ?)");
    databaseConnection.setAutoCommit(false);
    final int batchSize = 1000;
    int changed = 0;
    for (BlockState block : volume.getBlocks()) {
      final Location relLoc = ZoneVolumeMapper.rebase(
          volume.getCornerOne(), block.getLocation());
      dataStmt.setInt(1, relLoc.getBlockX());
      dataStmt.setInt(2, relLoc.getBlockY());
      dataStmt.setInt(3, relLoc.getBlockZ());
      dataStmt.setString(4, block.getType().toString());
      dataStmt.setShort(5, block.getData().toItemStack().getDurability());
      dataStmt.addBatch();
      if (++changed % batchSize == 0) {
        dataStmt.executeBatch();
View Full Code Here

    War.war.getLogger().log(Level.INFO, "Saved warzone {0} in {1} seconds.", new Object[] {zoneName, seconds});
    return changed;
  }

  public static Location rebase(final Location base, final Location exact) {
    return new Location(base.getWorld(),
        exact.getBlockX() - base.getBlockX(),
        exact.getBlockY() - base.getBlockY(),
        exact.getBlockZ() - base.getBlockZ());
  }
View Full Code Here

        String[] teleportSplit = teleportStr.split(",");
        int teleX = Integer.parseInt(teleportSplit[0]);
        int teleY = Integer.parseInt(teleportSplit[1]);
        int teleZ = Integer.parseInt(teleportSplit[2]);
        int yaw = Integer.parseInt(teleportSplit[3]);
        warzone.setTeleport(new Location(world, teleX, teleY, teleZ, yaw, 0));
     

      // ff
      if (warzoneConfig.containsKey("friendlyFire")) {
        warzone.getWarzoneConfig().put(WarzoneConfig.FRIENDLYFIRE, warzoneConfig.getBoolean("friendlyFire"));
      }

      // loadout
      warzone.getDefaultInventories().clearLoadouts();
     
      String loadoutStr = warzoneConfig.getString("loadout");
      if (loadoutStr != null && !loadoutStr.equals("")) {
        warzone.getDefaultInventories().setLoadout("default", new HashMap<Integer, ItemStack>());
        LoadoutTxtMapper.fromStringToLoadout(loadoutStr, warzone.getDefaultInventories().getLoadout("default"));
      }
     
      // extraLoadouts
      String extraLoadoutStr = warzoneConfig.getString("extraLoadouts");
      String[] extraLoadoutsSplit = extraLoadoutStr.split(",");
     
      for (String nameStr : extraLoadoutsSplit) {
        if (nameStr != null && !nameStr.equals("")) {
          warzone.getDefaultInventories().setLoadout(nameStr, new HashMap<Integer, ItemStack>());
        }
      }
     
      for (String extraName : extraLoadoutsSplit) {
        if (extraName != null && !extraName.equals("")) {
          String loadoutString = warzoneConfig.getString(extraName + "Loadout");
          HashMap<Integer, ItemStack> loadout = warzone.getDefaultInventories().getLoadout(extraName);
          LoadoutTxtMapper.fromStringToLoadout(loadoutString, loadout);
        }
      }

      // authors
      if (warzoneConfig.containsKey("author") && !warzoneConfig.getString("author").equals("")) {
        for(String authorStr : warzoneConfig.getString("author").split(",")) {
          if (!authorStr.equals("")) {
            warzone.addAuthor(authorStr);
          }
        }
      }

      // life pool (always set after teams, so the teams' remaining lives get initialized properly by this setter)
      if (warzoneConfig.containsKey("lifePool")) {
        warzone.getTeamDefaultConfig().put(TeamConfig.LIFEPOOL, warzoneConfig.getInt("lifePool"));
      }

      // monument heal
      if (warzoneConfig.containsKey("monumentHeal")) {
        warzone.getWarzoneConfig().put(WarzoneConfig.MONUMENTHEAL, warzoneConfig.getInt("monumentHeal"));
      }

      // autoAssignOnly
      if (warzoneConfig.containsKey("autoAssignOnly")) {
        warzone.getWarzoneConfig().put(WarzoneConfig.AUTOASSIGN, warzoneConfig.getBoolean("autoAssignOnly"));
      }

      // flagPointsOnly
      if (warzoneConfig.containsKey("flagPointsOnly")) {
        warzone.getTeamDefaultConfig().put(TeamConfig.FLAGPOINTSONLY, warzoneConfig.getBoolean("flagPointsOnly"));
      }
     
      // flagMustBeHome
      if (warzoneConfig.containsKey("flagMustBeHome")) {
        warzone.getTeamDefaultConfig().put(TeamConfig.FLAGMUSTBEHOME, warzoneConfig.getBoolean("flagMustBeHome"));
      }

      // team cap
      if (warzoneConfig.containsKey("teamCap")) {
        warzone.getTeamDefaultConfig().put(TeamConfig.TEAMSIZE, warzoneConfig.getInt("teamCap"));
      }
     
      // score cap
      if (warzoneConfig.containsKey("scoreCap")) {
        warzone.getTeamDefaultConfig().put(TeamConfig.MAXSCORE, warzoneConfig.getInt("scoreCap"));
      }
     
      // respawn timer
      if (warzoneConfig.containsKey("respawnTimer")) {
        warzone.getTeamDefaultConfig().put(TeamConfig.RESPAWNTIMER, warzoneConfig.getInt("respawnTimer"));
      }

      // blockHeads
      if (warzoneConfig.containsKey("blockHeads")) {
        warzone.getWarzoneConfig().put(WarzoneConfig.BLOCKHEADS, warzoneConfig.getBoolean("blockHeads"));
      }

      // spawnStyle
      String spawnStyle = warzoneConfig.getString("spawnStyle");
      if (spawnStyle != null && !spawnStyle.equals("")) {
        warzone.getTeamDefaultConfig().put(TeamConfig.SPAWNSTYLE, TeamSpawnStyle.getStyleFromString(spawnStyle));
      }

      // flagReturn
      String flagReturn = warzoneConfig.getString("flagReturn");
      if (flagReturn != null && !flagReturn.equals("")) {
        warzone.getTeamDefaultConfig().put(TeamConfig.FLAGRETURN, FlagReturn.getFromString(flagReturn));
      }

      // reward
      String rewardStr = warzoneConfig.getString("reward");
      if (rewardStr != null && !rewardStr.equals("")) {
        HashMap<Integer, ItemStack> reward = new HashMap<Integer, ItemStack>();
        LoadoutTxtMapper.fromStringToLoadout(rewardStr, reward);
        warzone.getDefaultInventories().setReward(reward);
      }

      // unbreakableZoneBlocks
      if (warzoneConfig.containsKey("unbreakableZoneBlocks")) {
        warzone.getWarzoneConfig().put(WarzoneConfig.UNBREAKABLE, warzoneConfig.getBoolean("unbreakableZoneBlocks"));
      }

      // disabled
      if (warzoneConfig.containsKey("disabled")) {
        warzone.getWarzoneConfig().put(WarzoneConfig.DISABLED, warzoneConfig.getBoolean("disabled"));
      }

      // noCreatures
      if (warzoneConfig.containsKey("noCreatures")) {
        warzone.getWarzoneConfig().put(WarzoneConfig.NOCREATURES, warzoneConfig.getBoolean("noCreatures"));
      }
     
      // glassWalls
      if (warzoneConfig.containsKey("glassWalls")) {
        warzone.getWarzoneConfig().put(WarzoneConfig.GLASSWALLS, warzoneConfig.getBoolean("glassWalls"));
      }
     
      // pvpInZone
      if (warzoneConfig.containsKey("pvpInZone")) {
        warzone.getWarzoneConfig().put(WarzoneConfig.PVPINZONE, warzoneConfig.getBoolean("pvpInZone"));
      }
     
      // instaBreak
      if (warzoneConfig.containsKey("instaBreak")) {
        warzone.getWarzoneConfig().put(WarzoneConfig.INSTABREAK, warzoneConfig.getBoolean("instaBreak"));
      }
     
      // noDrops
      if (warzoneConfig.containsKey("noDrops")) {
        warzone.getWarzoneConfig().put(WarzoneConfig.NODROPS, warzoneConfig.getBoolean("noDrops"));
      }
     
      // noHunger
      if (warzoneConfig.containsKey("noHunger")) {
        warzone.getTeamDefaultConfig().put(TeamConfig.NOHUNGER, warzoneConfig.getBoolean("noHunger"));
      }
     
      // saturation
      if (warzoneConfig.containsKey("saturation")) {
        warzone.getTeamDefaultConfig().put(TeamConfig.SATURATION, warzoneConfig.getInt("saturation"));
      }
     
      // minPlayers
      if (warzoneConfig.containsKey("minPlayers")) {
        warzone.getWarzoneConfig().put(WarzoneConfig.MINPLAYERS, warzoneConfig.getInt("minPlayers"));
      }
     
      // minTeams
      if (warzoneConfig.containsKey("minTeams")) {
        warzone.getWarzoneConfig().put(WarzoneConfig.MINTEAMS, warzoneConfig.getInt("minTeams"));
      }

      // resetOnEmpty
      if (warzoneConfig.containsKey("resetOnEmpty")) {
        warzone.getWarzoneConfig().put(WarzoneConfig.RESETONEMPTY, warzoneConfig.getBoolean("resetOnEmpty"));
      }

      // resetOnLoad
      if (warzoneConfig.containsKey("resetOnLoad")) {
        warzone.getWarzoneConfig().put(WarzoneConfig.RESETONLOAD, warzoneConfig.getBoolean("resetOnLoad"));
      }

      // resetOnUnload
      if (warzoneConfig.containsKey("resetOnUnload")) {
        warzone.getWarzoneConfig().put(WarzoneConfig.RESETONUNLOAD, warzoneConfig.getBoolean("resetOnUnload"));
      }

      // rallyPoint
      String rallyPointStr = warzoneConfig.getString("rallyPoint");
      if (rallyPointStr != null && !rallyPointStr.equals("")) {
        String[] rallyPointStrSplit = rallyPointStr.split(",");

        int rpX = Integer.parseInt(rallyPointStrSplit[0]);
        int rpY = Integer.parseInt(rallyPointStrSplit[1]);
        int rpZ = Integer.parseInt(rallyPointStrSplit[2]);
        Location rallyPoint = new Location(world, rpX, rpY, rpZ);
        warzone.setRallyPoint(rallyPoint);
      }

      // monuments
      String monumentsStr = warzoneConfig.getString("monuments");
      if (monumentsStr != null && !monumentsStr.equals("")) {
        String[] monumentsSplit = monumentsStr.split(";");
        warzone.getMonuments().clear();
        for (String monumentStr : monumentsSplit) {
          if (monumentStr != null && !monumentStr.equals("")) {
            String[] monumentStrSplit = monumentStr.split(",");
            int monumentX = Integer.parseInt(monumentStrSplit[1]);
            int monumentY = Integer.parseInt(monumentStrSplit[2]);
            int monumentZ = Integer.parseInt(monumentStrSplit[3]);
            Monument monument = new Monument(monumentStrSplit[0], warzone, new Location(world, monumentX, monumentY, monumentZ));
            warzone.getMonuments().add(monument);
          }
        }
      }
     
      // teams
      String teamsStr = warzoneConfig.getString("teams");
      if (teamsStr != null && !teamsStr.equals("")) {
        String[] teamsSplit = teamsStr.split(";");
        warzone.getTeams().clear();
        for (String teamStr : teamsSplit) {
          if (teamStr != null && !teamStr.equals("")) {
            String[] teamStrSplit = teamStr.split(",");
            int teamX = Integer.parseInt(teamStrSplit[1]);
            int teamY = Integer.parseInt(teamStrSplit[2]);
            int teamZ = Integer.parseInt(teamStrSplit[3]);
            Location teamLocation = new Location(world, teamX, teamY, teamZ);
            if (teamStrSplit.length > 4) {
              int yaw = Integer.parseInt(teamStrSplit[4]);
              teamLocation.setYaw(yaw);
            }
            File original = new File(War.war.getDataFolder().getPath() + "/dat/warzone-" + name + "/volume-" + teamStrSplit[0] + ".dat");
            File modified = new File(War.war.getDataFolder().getPath() + "/dat/warzone-" + name + "/volume-" + teamStrSplit[0] + "0.dat");
            try {
              original.renameTo(modified);
            } catch (Exception ignored) {
            }

            Team team = new Team(teamStrSplit[0], TeamKind.teamKindFromString(teamStrSplit[0]), Arrays.asList(teamLocation), warzone);
            team.setRemainingLives(warzone.getTeamDefaultConfig().resolveInt(TeamConfig.LIFEPOOL));
            warzone.getTeams().add(team);
          }
        }
      }

      // teamFlags
      String teamFlagsStr = warzoneConfig.getString("teamFlags");
      if (teamFlagsStr != null && !teamFlagsStr.equals("")) {
        String[] teamFlagsSplit = teamFlagsStr.split(";");
        for (String teamFlagStr : teamFlagsSplit) {
          if (teamFlagStr != null && !teamFlagStr.equals("")) {
            String[] teamFlagStrSplit = teamFlagStr.split(",");
            Team team = warzone.getTeamByKind(TeamKind.teamKindFromString(teamFlagStrSplit[0]));
            if (team != null) {
              int teamFlagX = Integer.parseInt(teamFlagStrSplit[1]);
              int teamFlagY = Integer.parseInt(teamFlagStrSplit[2]);
              int teamFlagZ = Integer.parseInt(teamFlagStrSplit[3]);
              Location teamFlagLocation = new Location(world, teamFlagX, teamFlagY, teamFlagZ);
              if (teamFlagStrSplit.length > 4) {
                int yaw = Integer.parseInt(teamFlagStrSplit[4]);
                teamFlagLocation.setYaw(yaw);
              }
              team.setTeamFlag(teamFlagLocation); // this may screw things up
            }
          }
        }
View Full Code Here

    this.setLocation(location);
  }

  public void addBombBlocks() {
    // make air (old two-high above floor)
    Volume airGap = new Volume(new Location(this.volume.getWorld(),
        this.volume.getCornerOne().getX(), this.volume.getCornerOne()
            .getY() + 1, this.volume.getCornerOne().getZ()),
        new Location(this.volume.getWorld(), this.volume.getCornerTwo()
            .getX(), this.volume.getCornerOne().getY() + 3,
            this.volume.getCornerTwo().getZ()));
    airGap.setToMaterial(Material.AIR);

    int x = this.location.getBlockX();
View Full Code Here

    } else if (this.args.length == 1) {
      if (War.war.getServer().getPluginManager().isPluginEnabled("WorldEdit")) {
        WorldEditPlugin worldEdit = (WorldEditPlugin) War.war.getServer().getPluginManager().getPlugin("WorldEdit");
        Selection selection = worldEdit.getSelection(player);
        if (selection != null && selection instanceof CuboidSelection) {
          Location min = selection.getMinimumPoint();
          Location max = selection.getMaximumPoint();
          ZoneSetter setter = new ZoneSetter(player, this.args[0]);
          setter.placeCorner1(min.getBlock());
          setter.placeCorner2(max.getBlock());
          return true;
        }
      }
      War.war.addWandBearer(player, this.args[0]);
    } else if (this.args.length == 2) {
View Full Code Here

  public void setUp() throws Exception {
    player = mock(Player.class);
    world = mock(World.class);
    when(world.getName()).thenReturn("world");
    when(player.getHealth()).thenReturn(20.0);
    when(player.getLocation()).thenReturn(new Location(world, 0, 0, 0));
    job = new TeleportPlayerJob(player, new Location(world, 0, 0, 0));
  }
View Full Code Here

TOP

Related Classes of org.bukkit.Location

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.