Java Code Examples for org.bukkit.World#getUID()

The following examples show how to use org.bukkit.World#getUID() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HookBSkyBlock.java    From CombatLogX with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean doesTeamMatch(Player player1, Player player2) {
    if(player1 == null || player2 == null) return false;

    World world1 = player1.getWorld();
    World world2 = player2.getWorld();
    UUID worldId1 = world1.getUID();
    UUID worldId2 = world2.getUID();
    if(!worldId1.equals(worldId2)) return false;

    UUID uuid1 = player1.getUniqueId();
    UUID uuid2 = player2.getUniqueId();
    if(uuid1.equals(uuid2)) return true;

    Island island = getIslandFor(player1);
    ImmutableSet<UUID> memberSet = island.getMemberSet();
    return memberSet.contains(uuid2);
}
 
Example 2
Source File: ImprovedOfflinePlayer.java    From civcraft with GNU General Public License v2.0 6 votes vote down vote up
public void setLocation(Location location) {
  World w = location.getWorld();
  UUID uuid = w.getUID();
  this.compound.setLong("WorldUUIDMost", uuid.getMostSignificantBits());
  this.compound.setLong("WorldUUIDLeast", uuid.getLeastSignificantBits());
  this.compound.setInt("Dimension", w.getEnvironment().ordinal());
  NBTTagList position = new NBTTagList();
  position.add(new NBTTagDouble(location.getX()));
  position.add(new NBTTagDouble(location.getY()));
  position.add(new NBTTagDouble(location.getZ()));
  this.compound.set("Pos", position);
  NBTTagList rotation = new NBTTagList();
  rotation.add(new NBTTagFloat(location.getYaw()));
  rotation.add(new NBTTagFloat(location.getPitch()));
  this.compound.set("Rotation", rotation);
  if(this.autosave) savePlayerData();
}
 
Example 3
Source File: BukkitPlugin.java    From BlueMap with MIT License 5 votes vote down vote up
private UUID getUUIDForWorldSync (File worldFolder) throws IOException {
	for (World world : getServer().getWorlds()) {
		if (worldFolder.equals(world.getWorldFolder().getCanonicalFile())) return world.getUID();
	}
	
	throw new IOException("There is no world with this folder loaded: " + worldFolder.getPath());
}
 
Example 4
Source File: GDClaimManager.java    From GriefDefender with MIT License 5 votes vote down vote up
public void createWildernessClaim(World world) {
    final Vector3i lesserCorner = new Vector3i(-30000000, 0, -30000000);
    final Vector3i greaterCorner = new Vector3i(29999999, 255, 29999999);
    // Use world UUID as wilderness claim ID
    GDClaim wilderness = new GDClaim(world, lesserCorner, greaterCorner, world.getUID(), ClaimTypes.WILDERNESS, null, false);
    wilderness.setOwnerUniqueId(GriefDefenderPlugin.WORLD_USER_UUID);
    wilderness.initializeClaimData(null);
    wilderness.claimData.save();
    wilderness.claimStorage.save();
    this.theWildernessClaim = wilderness;
    this.claimUniqueIdMap.put(wilderness.getUniqueId(), wilderness);
}
 
Example 5
Source File: ClimateEngine.java    From GlobalWarming with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void loadWorldClimateEngine(World world) {
    if (world == null) return;
    UUID worldId = world.getUID();
    if (!worldClimateEngines.containsKey(worldId)) {
        WorldConfig worldConfig = new WorldConfig(worldId);

        if (!worldConfig.isEnabled()) {
            GlobalWarming.getInstance().getLogger().info(String.format("World: [%s] found, but is disabled", world.getName()));
        } else {
            GlobalWarming.getInstance().getLogger().info(String.format("Loading climate engine for: [%s]", world.getName()));
        }

        //Add the climate engine:
        worldClimateEngines.put(worldId, new WorldClimateEngine(worldConfig));

        //Delayed attempt create the world object if it doesn't currently exist:
        WorldTable worldTable = GlobalWarming.getInstance().getTableManager().getWorldTable();
        GWorld gWorld = worldTable.getWorld(worldId);
        if (gWorld == null) {
            new BukkitRunnable() {
                @Override
                public void run() {
                    GWorld gw = worldTable.getWorld(worldId);
                    if (gw == null) {
                        worldTable.insertNewWorld(worldId);
                    }
                }
            }.runTaskLater(GlobalWarming.getInstance(), 40L);
        }
    }
}
 
Example 6
Source File: GDClaimManager.java    From GriefDefender with MIT License 4 votes vote down vote up
public GDClaimManager(World world) {
    this.worldUniqueId = world.getUID();
    this.worldName = world.getName();
    this.playerIndexStorage = new PlayerIndexStorage(world);
}
 
Example 7
Source File: FileStorage.java    From GriefDefender with MIT License 4 votes vote down vote up
public GDClaim loadClaim(File claimFile, World world, UUID claimId)
        throws Exception {
    GDClaim claim;

    final GDClaimManager claimManager = this.getClaimWorldManager(world.getUID());
    if (claimManager.getWildernessClaim() != null && claimManager.getWildernessClaim().getUniqueId().equals(claimId)) {
        return null;
    }
    boolean isTown = claimFile.toPath().getParent().endsWith("town");
    boolean writeToStorage = false;
    ClaimStorageData claimStorage = null;
    if (isTown) {
        claimStorage = new TownStorageData(claimFile.toPath(), world.getUID());
    } else {
        claimStorage = new ClaimStorageData(claimFile.toPath(), world.getUID());
    }

    final ClaimType type = claimStorage.getConfig().getType();
    final UUID parent = claimStorage.getConfig().getParent().orElse(null);
    final String fileName = claimFile.getName();
    /*final World world = Sponge.getServer().loadWorld(worldProperties).orElse(null);
    if (world == null) {
        throw new Exception("World [Name: " + worldProperties.getWorldName() + "][UUID: " + world.getUID().toString() + "] is not loaded.");
    }*/

    if (claimFile.getParentFile().getName().equalsIgnoreCase("claimdata")) {
        final Path newPath = claimStorage.filePath.getParent().resolve(type.getName().toLowerCase());
        if (Files.notExists(newPath)) {
            Files.createDirectories(newPath);
        }
        Files.move(claimStorage.filePath, newPath.resolve(fileName));
        claimStorage.filePath = newPath.resolve(fileName);
        claimStorage = new ClaimStorageData(claimStorage.filePath, world.getUID());
    }

    // identify world the claim is in
    UUID worldUniqueId = claimStorage.getConfig().getWorldUniqueId();
    if (!world.getUID().equals(worldUniqueId)) {
        GriefDefenderPlugin.getInstance().getLogger().info("Found mismatch world UUID in " + type.getName().toLowerCase() + " claim file " + claimFile + ". Expected " + world.getUID() + ", found " + worldUniqueId + ". Updating file with correct UUID...");
        claimStorage.getConfig().setWorldUniqueId(world.getUID());
        writeToStorage = true;
    }

    // boundaries
    final boolean cuboid = claimStorage.getConfig().isCuboid();
    Vector3i lesserCorner = claimStorage.getConfig().getLesserBoundaryCornerPos();
    Vector3i greaterCorner = claimStorage.getConfig().getGreaterBoundaryCornerPos();
    if (lesserCorner == null || greaterCorner == null) {
        throw new Exception("Claim file '" + claimFile.getName() + "' has corrupted data and cannot be loaded. Skipping...");
    }

    UUID ownerID = claimStorage.getConfig().getOwnerUniqueId();

    claim = new GDClaim(world, lesserCorner, greaterCorner, claimId, claimStorage.getConfig().getType(), ownerID, cuboid);
    claim.setClaimStorage(claimStorage);
    claim.setClaimData(claimStorage.getConfig());
    GDLoadClaimEvent.Pre preEvent = new GDLoadClaimEvent.Pre(claim);
    GriefDefender.getEventManager().post(preEvent);

    // add parent claim first
    if (parent != null) {
        GDClaim parentClaim = null;
        try {
            parentClaim = (GDClaim) claimManager.getClaimByUUID(parent).orElse(null);
        } catch (Throwable t) {
            t.printStackTrace();
        }
        if (parentClaim == null) {
            throw new Exception("Unable to load claim file '" + claimFile.getAbsolutePath() + "'. Required parent claim '" + parent + "' no longer exists. Skipping...");
        }
        claim.parent = parentClaim;
    }

    claimManager.addClaim(claim, writeToStorage);
    this.claimLoadCount++;
    GDLoadClaimEvent.Post postEvent = new GDLoadClaimEvent.Post(claim);
    GriefDefender.getEventManager().post(postEvent);
    return claim;
}
 
Example 8
Source File: ChunkLocation.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
public static ChunkLocation of(World world, ChunkPosition position) {
    return new ChunkLocation(world.getUID(), position);
}