Java Code Examples for org.bukkit.World#getName()
The following examples show how to use
org.bukkit.World#getName() .
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: MatchManagerImpl.java From PGM with GNU Affero General Public License v3.0 | 6 votes |
private void onNonMatchUnload(World world) { final String name = world.getName(); if (name.startsWith("match")) return; try { final Field server = CraftWorld.class.getDeclaredField("world"); server.setAccessible(true); final Field dimension = WorldServer.class.getDeclaredField("dimension"); dimension.setAccessible(true); final Field modifiers = Field.class.getDeclaredField("modifiers"); modifiers.setAccessible(true); modifiers.setInt(dimension, dimension.getModifiers() & ~Modifier.FINAL); dimension.set(server.get(world), 11); } catch (NoSuchFieldException | IllegalAccessException e) { // No-op, newer version of Java have disabled modifying final fields } if (PGM.get().getServer().unloadWorld(name, false)) { logger.info("Unloaded non-match " + name); } }
Example 2
Source File: BukkitSender.java From BungeePerms with GNU General Public License v3.0 | 5 votes |
@Override public String getWorld() { if (sender instanceof Player) { World w = ((Player) sender).getWorld(); return w != null ? w.getName() : null; } else { return null; } }
Example 3
Source File: PerWorldSettingsService.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
private Set<String> loadWorldFromConfig(World world) { String name = world.getName(); Optional<Set<String>> optional = disabledItems.get(world.getUID()); if (optional.isPresent()) { return optional.get(); } else { Set<String> items = new LinkedHashSet<>(); Config config = getConfig(world); config.getConfiguration().options().header("This file is used to disable certain items in a particular world.\nYou can set any item to 'false' to disable it in the world '" + name + "'.\nYou can also disable an entire addon from Slimefun by setting the respective\nvalue of 'enabled' for that Addon.\n\nItems which are disabled in this world will not show up in the Slimefun Guide.\nYou won't be able to use these items either. Using them will result in a warning message."); config.getConfiguration().options().copyHeader(true); config.setDefaultValue("enabled", true); if (config.getBoolean("enabled")) { loadItemsFromWorldConfig(name, config, items); if (SlimefunPlugin.getMinecraftVersion() != MinecraftVersion.UNIT_TEST) { config.save(); } } else { disabledWorlds.add(world.getUID()); } return items; } }
Example 4
Source File: WorldData.java From LagMonitor with MIT License | 5 votes |
public static WorldData fromWorld(World world) { String worldName = world.getName(); int tileEntities = 0; for (Chunk loadedChunk : world.getLoadedChunks()) { tileEntities += loadedChunk.getTileEntities().length; } int entities = world.getEntities().size(); int chunks = world.getLoadedChunks().length; return new WorldData(worldName, chunks, tileEntities, entities); }
Example 5
Source File: GlobalProtection.java From DungeonsXL with GNU General Public License v3.0 | 5 votes |
protected GlobalProtection(DungeonsXL plugin, World world, int id) { this.plugin = plugin; protections = plugin.getGlobalProtectionCache(); config = plugin.getGlobalData().getConfig(); this.world = world.getName(); this.id = id; protections.addProtection(this); }
Example 6
Source File: CustomItem.java From NBTEditor with GNU General Public License v3.0 | 5 votes |
public final boolean isValidWorld(World world) { String wName = world.getName(); if (_allowedWorlds == null) { return _blockedWorlds == null || !_blockedWorlds.contains(wName); } else { return _allowedWorlds.contains(wName); } }
Example 7
Source File: WorldConfig.java From GlobalWarming with GNU Lesser General Public License v3.0 | 5 votes |
public static String getDisplayName(UUID worldId) { String worldName = "UNKNOWN"; if (worldId != null) { World world = Bukkit.getWorld(worldId); if (world != null) { worldName = world.getName(); } } return worldName; }
Example 8
Source File: MatchFinder.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
default Match needMatch(World world) { final Match match = getMatch(world); if(match == null) { throw new IllegalStateException("No match available for world " + world.getName()); } return match; }
Example 9
Source File: ODRFile.java From ObsidianDestroyer with GNU General Public License v3.0 | 5 votes |
/** * Gets the next block in the file * * @param world the world for location creation/reading * @return the entry (a block) or null if EOF has been reached / nothing was read * @throws IOException thrown if something happens */ public Key getNext(World world) throws IOException { int read = channel.read(buffer); if (read <= 0) { return null; } buffer.position(0); int x = buffer.getInt(), y = buffer.getInt(), z = buffer.getInt(); int value = buffer.getInt(); long time = buffer.getLong(); buffer.clear(); return new Key(world.getName(), x, y, z, value, time); }
Example 10
Source File: WorldData.java From LagMonitor with MIT License | 5 votes |
public static WorldData fromWorld(World world) { String worldName = world.getName(); int tileEntities = 0; for (Chunk loadedChunk : world.getLoadedChunks()) { tileEntities += loadedChunk.getTileEntities().length; } int entities = world.getEntities().size(); int chunks = world.getLoadedChunks().length; return new WorldData(worldName, chunks, tileEntities, entities); }
Example 11
Source File: BlockStorage.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
public BlockStorage(World w) { this.world = w; if (world.getName().indexOf('.') != -1) { throw new IllegalArgumentException("Slimefun cannot deal with World names that contain a dot: " + w.getName()); } if (SlimefunPlugin.getRegistry().getWorlds().containsKey(w.getName())) { // Cancel the loading process if the world was already loaded return; } Slimefun.getLogger().log(Level.INFO, "Loading Blocks for World \"{0}\"", w.getName()); Slimefun.getLogger().log(Level.INFO, "This may take a long time..."); File dir = new File(PATH_BLOCKS + w.getName()); if (dir.exists()) { loadBlocks(dir); } else { dir.mkdirs(); } loadChunks(); loadInventories(); SlimefunPlugin.getRegistry().getWorlds().put(world.getName(), this); }
Example 12
Source File: PerWorldSettingsService.java From Slimefun4 with GNU General Public License v3.0 | 4 votes |
private Config getConfig(World world) { return new Config(plugin, "world-settings/" + world.getName() + ".yml"); }
Example 13
Source File: Region.java From BedwarsRel with GNU General Public License v3.0 | 4 votes |
public Region(World w, int x1, int y1, int z1, int x2, int y2, int z2) { this(new Location(w, x1, y1, z1), new Location(w, x2, y2, z2), w.getName()); }
Example 14
Source File: Reward.java From CombatLogX with GNU General Public License v3.0 | 4 votes |
private boolean isWorldAllowed(World world) { String worldName = world.getName(); boolean contains = this.worldNameList.contains(worldName); return (this.worldWhitelist == contains); }
Example 15
Source File: TradeGoodPostGenTask.java From civcraft with GNU General Public License v2.0 | 4 votes |
@Override public void run() { World world = Bukkit.getWorld("world"); BlockCoord bcoord2 = new BlockCoord(); for(int i = 0; i < amount; i++) { TradeGoodPick pick = picksQueue.poll(); if (pick == null) { return; } ChunkCoord coord = pick.chunkCoord; Chunk chunk = world.getChunkAt(coord.getX(), coord.getZ()); int centerX = (chunk.getX() << 4) + 8; int centerZ = (chunk.getZ() << 4) + 8; int centerY = world.getHighestBlockYAt(centerX, centerZ); bcoord2.setWorldname("world"); bcoord2.setX(centerX); bcoord2.setY(centerY - 1); bcoord2.setZ(centerZ); /* try to detect already existing trade goods. */ while(true) { Block top = world.getBlockAt(bcoord2.getX(), bcoord2.getY(), bcoord2.getZ()); if (!top.getChunk().isLoaded()) { top.getChunk().load(); } if (ItemManager.getId(top) == CivData.BEDROCK) { ItemManager.setTypeId(top, CivData.AIR); ItemManager.setData(top, 0, true); bcoord2.setY(bcoord2.getY() - 1); top = top.getRelative(BlockFace.NORTH); if (ItemManager.getId(top) == CivData.WALL_SIGN) { ItemManager.setTypeId(top, CivData.AIR); ItemManager.setData(top, 0, true); } top = top.getRelative(BlockFace.SOUTH); if (ItemManager.getId(top) == CivData.WALL_SIGN) { ItemManager.setTypeId(top, CivData.AIR); ItemManager.setData(top, 0, true); } top = top.getRelative(BlockFace.EAST); if (ItemManager.getId(top) == CivData.WALL_SIGN) { ItemManager.setTypeId(top, CivData.AIR); ItemManager.setData(top, 0, true); } top = top.getRelative(BlockFace.WEST); if (ItemManager.getId(top) == CivData.WALL_SIGN) { ItemManager.setTypeId(top, CivData.AIR); ItemManager.setData(top, 0, true); } } else { break; } } centerY = world.getHighestBlockYAt(centerX, centerZ); // Determine if we should be a water good. ConfigTradeGood good; if (ItemManager.getBlockTypeIdAt(world, centerX, centerY-1, centerZ) == CivData.WATER || ItemManager.getBlockTypeIdAt(world, centerX, centerY-1, centerZ) == CivData.WATER_RUNNING) { good = pick.waterPick; } else { good = pick.landPick; } // Randomly choose a land or water good. if (good == null) { System.out.println("Could not find suitable good type during populate! aborting."); continue; } // Create a copy and save it in the global hash table. BlockCoord bcoord = new BlockCoord(world.getName(), centerX, centerY, centerZ); TradeGoodPopulator.buildTradeGoodie(good, bcoord, world, true); } }
Example 16
Source File: DynmapProvider.java From GriefDefender with MIT License | 4 votes |
private void updateClaimMarker(Claim claim, Map<String, AreaMarker> markerMap) { final World world = Bukkit.getWorld(claim.getWorldUniqueId()); if (world == null) { return; } final String worldName = world.getName(); final String owner = ((GDClaim) claim).getOwnerName(); if (isVisible((GDClaim) claim, owner, worldName)) { final Vector3i lesserPos = claim.getLesserBoundaryCorner(); final Vector3i greaterPos = claim.getGreaterBoundaryCorner(); final double[] x = new double[4]; final double[] z = new double[4]; x[0] = lesserPos.getX(); z[0] = lesserPos.getZ(); x[1] = lesserPos.getX(); z[1] = greaterPos.getZ() + 1.0; x[2] = greaterPos.getX() + 1.0; z[2] = greaterPos.getZ() + 1.0; x[3] = greaterPos.getX() + 1.0; z[3] = lesserPos.getZ(); final UUID id = claim.getUniqueId(); final String markerid = "GD_" + id; AreaMarker marker = this.areaMarkers.remove(markerid); if (marker == null) { marker = this.set.createAreaMarker(markerid, owner, false, worldName, x, z, false); if (marker == null) { return; } } else { marker.setCornerLocations(x, z); marker.setLabel(owner); } if (this.cfg.use3dRegions) { marker.setRangeY(greaterPos.getY() + 1.0, lesserPos.getY()); } addOwnerStyle(owner, worldName, marker, claim); String desc = getWindowInfo(claim, marker); marker.setDescription(desc); markerMap.put(markerid, marker); } }
Example 17
Source File: GDClaimManager.java From GriefDefender with MIT License | 4 votes |
public GDClaimManager(World world) { this.worldUniqueId = world.getUID(); this.worldName = world.getName(); this.playerIndexStorage = new PlayerIndexStorage(world); }
Example 18
Source File: BlockFromToListener.java From IridiumSkyblock with GNU General Public License v2.0 | 4 votes |
@EventHandler public void onBlockFromTo(BlockFromToEvent event) { try { final Block block = event.getBlock(); final Location location = block.getLocation(); final IslandManager islandManager = IridiumSkyblock.getIslandManager(); final Island island = islandManager.getIslandViaLocation(location); if (island == null) return; final Material material = block.getType(); final Block toBlock = event.getToBlock(); final Location toLocation = toBlock.getLocation(); if (material.equals(Material.WATER) || material.equals(Material.LAVA)) { final Island toIsland = islandManager.getIslandViaLocation(toLocation); if (island != toIsland) event.setCancelled(true); } if (!IridiumSkyblock.getUpgrades().oresUpgrade.enabled) return; if (event.getFace() == BlockFace.DOWN) return; if (!isSurroundedByWater(toLocation)) return; final int oreLevel = island.getOreLevel(); final World world = location.getWorld(); if (world == null) return; final String worldName = world.getName(); final Config config = IridiumSkyblock.getConfiguration(); List<String> islandOreUpgrades; if (worldName.equals(config.worldName)) islandOreUpgrades = IridiumSkyblock.oreUpgradeCache.get(oreLevel); else if (worldName.equals(config.netherWorldName)) islandOreUpgrades = IridiumSkyblock.netherOreUpgradeCache.get(oreLevel); else return; Bukkit.getScheduler().runTask(IridiumSkyblock.getInstance(), () -> { final Material toMaterial = toBlock.getType(); if (!(toMaterial.equals(Material.COBBLESTONE) || toMaterial.equals(Material.STONE))) return; final Random random = new Random(); final String oreUpgrade = islandOreUpgrades.get(random.nextInt(islandOreUpgrades.size())); final XMaterial oreUpgradeXmaterial = XMaterial.valueOf(oreUpgrade); final Material oreUpgradeMaterial = oreUpgradeXmaterial.parseMaterial(true); if (oreUpgradeMaterial == null) return; toBlock.setType(oreUpgradeMaterial); final BlockState blockState = toBlock.getState(); blockState.update(true); if (Utils.isBlockValuable(toBlock)) { final XMaterial xmaterial = XMaterial.matchXMaterial(material); island.valuableBlocks.compute(xmaterial.name(), (name, original) -> { if (original == null) return 1; return original + 1; }); if (island.updating) island.tempValues.add(location); island.calculateIslandValue(); } }); } catch (Exception ex) { IridiumSkyblock.getInstance().sendErrorMessage(ex); } }
Example 19
Source File: LocationBuilder.java From AstralEdit with Apache License 2.0 | 2 votes |
/** * Sets the world of the builder * * @param world world * @return builder */ public LocationBuilder setWorld(World world) { this.world = world.getName(); return this; }
Example 20
Source File: ChunkHandler.java From ClaimChunk with MIT License | 2 votes |
/** * Check if the provided player is the owner of the provided chunk * * @param world The world in which this chunk is located. * @param x The x-coordinate (in chunk coordinates) of the chunk. * @param z The z-coordinate (in chunk coordinates) of the chunk. * @param ply The UUID of the player. * @return Whether this player owns this chunk. */ public boolean isOwner(World world, int x, int z, UUID ply) { ChunkPos pos = new ChunkPos(world.getName(), x, z); UUID owner = dataHandler.getChunkOwner(pos); return owner != null && owner.equals(ply); }