Package org.bukkit

Examples of org.bukkit.Location


    job = new TeleportPlayerJob(player, new Location(world, 0, 0, 0));
  }

  @Test
  public void testPlayerMove_noMovement_false() {
    when(player.getLocation()).thenReturn(new Location(world, 0, 0, 0));

    assertFalse(job.hasPlayerMoved());
  }
View Full Code Here


    assertFalse(job.hasPlayerMoved());
  }

  @Test
  public void testPlayerMove_smallMovement_false() {
    when(player.getLocation()).thenReturn(new Location(world, 0.5, 0.5, 0.5));

    assertFalse(job.hasPlayerMoved());
  }
View Full Code Here

    assertFalse(job.hasPlayerMoved());
  }

  @Test
  public void testPlayerMove_largeMovement_true() {
    when(player.getLocation()).thenReturn(new Location(world, 5, 1, 3));

    assertTrue(job.hasPlayerMoved());
  }
View Full Code Here

    this.flagVolume.setCornerTwo(this.warzone.getWorld().getBlockAt(x + 1, y + 3, z + 1));
  }

  public void initializeTeamFlag() {
    // make air (old two-high above floor)
    Volume airGap = new Volume(new Location(this.flagVolume.getWorld(),
        this.flagVolume.getCornerOne().getX(), this.flagVolume
            .getCornerOne().getY() + 1, this.flagVolume
            .getCornerOne().getZ()), new Location(
        this.flagVolume.getWorld(), this.flagVolume.getCornerTwo()
            .getX(), this.flagVolume.getCornerOne().getY() + 2,
        this.flagVolume.getCornerTwo().getZ()));
    airGap.setToMaterial(Material.AIR);
View Full Code Here

        .prepareStatement("INSERT INTO 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

      // teleport
      int teleX = warzoneRootSection.getInt(zoneInfoPrefix + "teleport.x");
      int teleY = warzoneRootSection.getInt(zoneInfoPrefix + "teleport.y");
      int teleZ = warzoneRootSection.getInt(zoneInfoPrefix + "teleport.z");
      int teleYaw = warzoneRootSection.getInt(zoneInfoPrefix + "teleport.yaw");
      warzone.setTeleport(new Location(world, teleX, teleY, teleZ, teleYaw, 0));
     
      // defaultLoadouts
      if (warzoneRootSection.contains("team.default.loadout")) {
        ConfigurationSection loadoutsSection = warzoneRootSection.getConfigurationSection("team.default.loadout");
        warzone.getDefaultInventories().setLoadouts(LoadoutYmlMapper.fromConfigToLoadouts(loadoutsSection, new HashMap<String, HashMap<Integer, ItemStack>>()));
      }

      // defaultReward
      if (warzoneRootSection.contains("team.default.reward")) {
        ConfigurationSection rewardsSection = warzoneRootSection.getConfigurationSection("team.default.reward");
        HashMap<Integer, ItemStack> reward = new HashMap<Integer, ItemStack>();
        LoadoutYmlMapper.fromConfigToLoadout(rewardsSection, reward, "default");
        warzone.getDefaultInventories().setReward(reward);
      }
     
      // Team default settings
      if (warzoneRootSection.contains("team.default.config")) {
        ConfigurationSection teamConfigSection = warzoneRootSection.getConfigurationSection("team.default.config");
        warzone.getTeamDefaultConfig().loadFrom(teamConfigSection);
      }
     
      // Warzone settings
      if (warzoneRootSection.contains("warzone." + warzone.getName() + ".config")) {
        ConfigurationSection warzoneConfigSection = warzoneRootSection.getConfigurationSection("warzone." + warzone.getName() + ".config");
        warzone.getWarzoneConfig().loadFrom(warzoneConfigSection);
      } else if (warzoneRootSection.contains("warzone." + warzone.getName().toLowerCase() + ".config")) {
        // Workaround for broken Bukkit backward-compatibility for non-lowercase Yml nodes
        ConfigurationSection warzoneConfigSection = warzoneRootSection.getConfigurationSection("warzone." + warzone.getName().toLowerCase() + ".config");
        warzone.getWarzoneConfig().loadFrom(warzoneConfigSection);
      }

      // authors
      if (warzoneRootSection.contains(zoneInfoPrefix + "authors")) {
        for(String authorStr : warzoneRootSection.getStringList(zoneInfoPrefix + "authors")) {
          if (!authorStr.equals("")) {
            warzone.addAuthor(authorStr);
          }
        }
      }

      // rallyPoint
      if (warzoneRootSection.contains(zoneInfoPrefix + "rallypoint")) {
        int rpX = warzoneRootSection.getInt(zoneInfoPrefix + "rallypoint.x");
        int rpY = warzoneRootSection.getInt(zoneInfoPrefix + "rallypoint.y");
        int rpZ = warzoneRootSection.getInt(zoneInfoPrefix + "rallypoint.z");
        int rpYaw = warzoneRootSection.getInt(zoneInfoPrefix + "rallypoint.yaw");
        Location rallyPoint = new Location(world, rpX, rpY, rpZ, rpYaw, 0);
        warzone.setRallyPoint(rallyPoint);
      }

      // monuments
      if (warzoneRootSection.contains(zoneInfoPrefix + "monument")) {
        List<String> monunmentNames = warzoneRootSection.getStringList(zoneInfoPrefix + "monument.names");
        for (String monumentName : monunmentNames) {
          if (monumentName != null && !monumentName.equals("")) {
            String monumentPrefix = zoneInfoPrefix + "monument." + monumentName + ".";
            if (!warzoneRootSection.contains(monumentPrefix + "x")) {
              // try lowercase instead
              monumentPrefix = zoneInfoPrefix + "monument." + monumentName.toLowerCase() + ".";
            }
            int monumentX = warzoneRootSection.getInt(monumentPrefix + "x");
            int monumentY = warzoneRootSection.getInt(monumentPrefix + "y");
            int monumentZ = warzoneRootSection.getInt(monumentPrefix + "z");
            int monumentYaw = warzoneRootSection.getInt(monumentPrefix + "yaw");
            Monument monument = new Monument(monumentName, warzone, new Location(world, monumentX, monumentY, monumentZ, monumentYaw, 0));
            warzone.getMonuments().add(monument);
          }
        }
      }
     
      // bombs
      if (warzoneRootSection.contains(zoneInfoPrefix + "bomb")) {
        List<String> bombNames = warzoneRootSection.getStringList(zoneInfoPrefix + "bomb.names");
        for (String bombName : bombNames) {
          if (bombName != null && !bombName.equals("")) {
            String bombPrefix = zoneInfoPrefix + "bomb." + bombName + ".";
            if (!warzoneRootSection.contains(bombPrefix + "x")) {
              // try lowercase instead
              bombPrefix = zoneInfoPrefix + "bomb." + bombName.toLowerCase() + ".";
            }
            int bombX = warzoneRootSection.getInt(bombPrefix + "x");
            int bombY = warzoneRootSection.getInt(bombPrefix + "y");
            int bombZ = warzoneRootSection.getInt(bombPrefix + "z");
            int bombYaw = warzoneRootSection.getInt(bombPrefix + "yaw");
            Bomb bomb = new Bomb(bombName, warzone, new Location(world, bombX, bombY, bombZ, bombYaw, 0));
            warzone.getBombs().add(bomb);
          }
        }
      }
     
      // cakes
      if (warzoneRootSection.contains(zoneInfoPrefix + "cake")) {
        List<String> cakeNames = warzoneRootSection.getStringList(zoneInfoPrefix + "cake.names");
        for (String cakeName : cakeNames) {
          if (cakeName != null && !cakeName.equals("")) {
            String cakePrefix = zoneInfoPrefix + "cake." + cakeName + ".";
            if (!warzoneRootSection.contains(cakePrefix + "x")) {
              // try lowercase instead
              cakePrefix = zoneInfoPrefix + "cake." + cakeName + ".";
            }
            int cakeX = warzoneRootSection.getInt(cakePrefix + "x");
            int cakeY = warzoneRootSection.getInt(cakePrefix + "y");
            int cakeZ = warzoneRootSection.getInt(cakePrefix + "z");
            int cakeYaw = warzoneRootSection.getInt(cakePrefix + "yaw");
            Cake cake = new Cake(cakeName, warzone, new Location(world, cakeX, cakeY, cakeZ, cakeYaw, 0));
            warzone.getCakes().add(cake);
          }
        }
      }
     
      // teams (maybe no teams)
      if (warzoneRootSection.contains("team.names")) {
        List<String> teamsNames = warzoneRootSection.getStringList("team.names");
        for (String teamName : teamsNames) {
          // team info
          String teamInfoPrefix = "team." + teamName + ".info.";
          if (!warzoneRootSection.contains(teamInfoPrefix + "spawn.x")) {
            // try lowercase instead - supports custom team names
            teamInfoPrefix = "team." + teamName.toLowerCase() + ".info.";
          }
          List<Location> teamSpawns = new ArrayList<Location>();
          if (warzoneRootSection.contains(teamInfoPrefix + "spawn")) {
            int teamX = warzoneRootSection.getInt(teamInfoPrefix + "spawn.x");
            int teamY = warzoneRootSection.getInt(teamInfoPrefix + "spawn.y");
            int teamZ = warzoneRootSection.getInt(teamInfoPrefix + "spawn.z");
            int teamYaw = warzoneRootSection.getInt(teamInfoPrefix + "spawn.yaw");
            Location teamLocation = new Location(world, teamX, teamY, teamZ, teamYaw, 0);
            teamSpawns.add(teamLocation);
            File original = new File(War.war.getDataFolder().getPath() + "/dat/warzone-" + name + "/volume-" + teamName + ".dat");
            File modified = new File(War.war.getDataFolder().getPath() + "/dat/warzone-" + name + "/volume-" + teamName + teamSpawns.indexOf(teamLocation) + ".dat");
            File originalSql = new File(War.war.getDataFolder().getPath() + "/dat/warzone-" + name + "/volume-" + teamName + ".sl3");
            File modifiedSql = new File(War.war.getDataFolder().getPath() + "/dat/warzone-" + name + "/volume-" + teamName + teamSpawns.indexOf(teamLocation) + ".sl3");
            try {
              original.renameTo(modified);
            } catch (Exception ignored) {
            }
            try {
              originalSql.renameTo(modifiedSql);
            } catch (Exception ignored) {
            }
          }
          if (warzoneRootSection.contains(teamInfoPrefix + "spawns")) {
            for (Map<?, ?> map : warzoneRootSection.getMapList(teamInfoPrefix + "spawns")) {
              int teamX = (Integer) map.get("x");
              int teamY = (Integer) map.get("y");
              int teamZ = (Integer) map.get("z");
              int teamYaw = (Integer) map.get("yaw");
              Location teamLocation = new Location(world, teamX, teamY, teamZ, teamYaw, 0);
              teamSpawns.add(teamLocation);
            }
          }
 
          Team team = new Team(teamName, TeamKind.teamKindFromString(teamName), teamSpawns, warzone);
          warzone.getTeams().add(team);
         
          if (warzoneRootSection.contains(teamInfoPrefix + "flag")) {
            int flagX = warzoneRootSection.getInt(teamInfoPrefix + "flag.x");
            int flagY = warzoneRootSection.getInt(teamInfoPrefix + "flag.y");
            int flagZ = warzoneRootSection.getInt(teamInfoPrefix + "flag.z");
            int flagYaw = warzoneRootSection.getInt(teamInfoPrefix + "flag.yaw");
            Location flagLocation = new Location(world, flagX, flagY, flagZ, flagYaw, 0);
            team.setTeamFlag(flagLocation);
          }
         
          String teamConfigPrefix = "team." + teamName + ".config";
          if (warzoneRootSection.contains(teamConfigPrefix)) {
View Full Code Here

      }
      teamInfoSection.set("spawns", spawnSerilization);
     
      if (team.getTeamFlag() != null) {
        ConfigurationSection flagSection = teamInfoSection.createSection("flag");
        Location teamFlag = team.getTeamFlag();
        flagSection.set("x", teamFlag.getBlockX());
        flagSection.set("y", teamFlag.getBlockY());
        flagSection.set("z", teamFlag.getBlockZ());
        flagSection.set("yaw", toIntYaw(teamFlag.getYaw()));
      }
    }
    Connection connection = null;
    try {
      connection = ZoneVolumeMapper.getZoneConnection(warzone.getVolume(), warzone.getName(), warzone.getWorld());
View Full Code Here

    @Override
    public void execute(Arena arena, MABoss boss) {
        LivingEntity target = AbilityUtils.getTarget(arena, boss.getEntity(), RANDOM);
        if (target == null) return;
       
        Location loc = target.getLocation();
        loc.setYaw(loc.getYaw() + 45 + AbilityUtils.random.nextInt(270));
        target.teleport(loc);
    }
View Full Code Here

    public void onHangingBreak(HangingBreakEvent event) {
        // If the arena isn't protected, care
        if (!protect) return;

        Location l = event.getEntity().getLocation();
        if (!arena.getRegion().contains(l)) {
            return;
        }
        if (arena.inEditMode()) {
            return;
View Full Code Here

        Player p = event.getPlayer();
        if (!arena.isDead(p)) {
            return false;
        }

        Location loc = arena.getRespawnLocation(p);
        event.setRespawnLocation(loc);

        arena.playerRespawn(p);
        return true;
    }
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.