当前位置: 首页>>代码示例>>Java>>正文


Java World类代码示例

本文整理汇总了Java中org.bukkit.World的典型用法代码示例。如果您正苦于以下问题:Java World类的具体用法?Java World怎么用?Java World使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


World类属于org.bukkit包,在下文中一共展示了World类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: runWarnSystemTask

import org.bukkit.World; //导入依赖的package包/类
public static void runWarnSystemTask(MainClass plugin) {
	
	new BukkitRunnable() {

		public void run() {
			double ticks = Tps.getTPS();
			if (ticks <= 15.0D) {
				onPrevient();
			} else if (ticks <= 5.0D) {
				onCritique();
				Bukkit.getServer().savePlayers();
				for (World world : Bukkit.getWorlds()) {
		            world.save();
				}
			}
			
		}
		
	}.runTaskTimerAsynchronously(plugin, 40L, 60L);
	
}
 
开发者ID:DianoxDragon,项目名称:UltimateSpawn,代码行数:22,代码来源:Warn.java

示例2: matches

import org.bukkit.World; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public boolean matches(CraftingInventory craftingInventory, World world) {
	final List<ChoiceIngredient> ingredients = new ArrayList<>(this.ingredients);
	final List<ItemStack> contents = Arrays.asList(craftingInventory.getMatrix())
			.stream().filter(i -> !InventoryUtils.isEmptyStack(i))
			.collect(Collectors.toList());
	
	for (ItemStack stack : contents) {
		boolean match = false;
		for (int ingredientIndex = 0; ingredientIndex < ingredients.size(); ingredientIndex++) {
			ChoiceIngredient ingredient = ingredients.get(ingredientIndex);
			if (ingredient.isIngredient(stack)) {
				ingredients.remove(ingredientIndex);
				match = true;
				break;
			}
		}
		
		//there was no matching ingredient for the current ItemStack
		if (!match) return false;
	}
	
	//return true if there are no unused ingredients left over
	return ingredients.isEmpty();
}
 
开发者ID:Jannyboy11,项目名称:CustomRecipes,代码行数:29,代码来源:SimpleShapelessRecipe.java

示例3: forEveryoneAround

import org.bukkit.World; //导入依赖的package包/类
private void forEveryoneAround(Location center, double radius, Consumer<Player> action) {
    int chunkRadius = (int) Math.ceil(radius) >> 4;
    double squared = radius * radius;
    final int x = center.getBlockX() >> 4;
    final int z = center.getBlockZ() >> 4;

    int ix = x - chunkRadius;
    int ex = x + chunkRadius;

    int iz = z - chunkRadius;
    int ez = z + chunkRadius;

    final World world = center.getWorld();
    for (int chX = ix; chX <= ex; chX++) {
        for (int chZ = iz; chZ <= ez; chZ++) {
            if(world.isChunkLoaded(chX, chZ)) {
                for (Entity e : world.getChunkAt(chX, chZ).getEntities()) {
                    if (e instanceof Player && e.getLocation().distanceSquared(center) <= squared) {
                        action.accept((Player) e);
                    }
                }
            }
        }
    }
}
 
开发者ID:upperlevel,项目名称:uppercore,代码行数:26,代码来源:ParticlePacket.java

示例4: generateChunkData

import org.bukkit.World; //导入依赖的package包/类
@Override
public ChunkData generateChunkData(World world, Random random, int chunkX, int chunkZ, ChunkGenerator.BiomeGrid biomeGrid) {
    if (world.getEnvironment().equals(World.Environment.NETHER)) {
        return generateNetherChunks(world, random, chunkX, chunkZ, biomeGrid);
    }
    ChunkData result = createChunkData(world);
    if (Settings.seaHeight != 0) {
        for (int x = 0; x < 16; x++) {
            for (int z = 0; z < 16; z++) {
                for (int y = 0; y < Settings.seaHeight; y++) {
                    result.setBlock(x, y, z, Material.STATIONARY_WATER);
                }
            }
        }

    }
    return result;
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:19,代码来源:ChunkGeneratorWorld.java

示例5: getVector

import org.bukkit.World; //导入依赖的package包/类
private Vector getVector(World world, String key, Vector def) {
    try {
        Vector v = ConfigUtils.getVector(config, key, null);
        if(v != null) return v;

        String rule = world.getGameRuleValue(key);
        if(!"".equals(rule)) {
            return Vectors.parseVector(rule);
        }

        return def;
    } catch(RuntimeException ex) {
        logger.log(Level.SEVERE, "Error parsing vector '" + key + "' from lobby config: " + ex.getMessage(), ex);
        throw ex;
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:17,代码来源:LobbyConfig.java

示例6: telegraphDingThread

import org.bukkit.World; //导入依赖的package包/类
public static void telegraphDingThread(final Player player) {
	new Thread() {

		@Override
		public void run() {

			setPriority(Thread.MIN_PRIORITY);

			// taskNum = -1;
			try {
				World cw = player.getWorld();
				Location loc = player.getLocation();
				for (int i = 0; i < 2; i++) {
					sleep(200);
					cw.playSound(loc, Sound.BLOCK_ANVIL_PLACE, 1.0f, 1.9f);

				}
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}.start(); // , 20L);
}
 
开发者ID:Maximuspayne,项目名称:NavyCraft2-Lite,代码行数:24,代码来源:Craft.java

示例7: deserializeLocation

import org.bukkit.World; //导入依赖的package包/类
public static Location deserializeLocation(String s) {
    Location def = SakiCore.plugin.getServer().getWorlds().get(0).getSpawnLocation();
    if (s.length() == 0)
        return def;
    String[] data = s.split(Pattern.quote(LOCATION_DIVIDER));
    if (data.length == 0)
        return def;
    try {
        double x = Double.parseDouble(data[0]);
        double y = Double.parseDouble(data[1]);
        if (y < 1)
            y = 1;
        double z = Double.parseDouble(data[2]);
        float yaw = Float.parseFloat(data[3]);
        float pitch = Float.parseFloat(data[4]);
        World w = SakiCore.plugin.getServer().getWorld(data[5]);
        if (w == null) {
            SakiCore.plugin.getServer().getWorlds().get(0).getSpawnLocation();
        }
        return new Location(w, x, y, z, yaw, pitch);
    } catch (Exception e) {
        e.printStackTrace();
        System.out.println("Corrupted location save: " + s);
    }
    return def;
}
 
开发者ID:edasaki,项目名称:ZentrelaCore,代码行数:27,代码来源:RSerializer.java

示例8: onDragonDeath

import org.bukkit.World; //导入依赖的package包/类
@EventHandler
public void onDragonDeath(EntityDeathEvent event) {
	if (!(event.getEntity() instanceof EnderDragon)) return;
	
	EnderDragon dragon = (EnderDragon) event.getEntity();
	DragonBattle dragonBattle = plugin.getNMSAbstract().getEnderDragonBattleFromDragon(dragon);
	
	World world = event.getEntity().getWorld();
	EndWorldWrapper worldWrapper = plugin.getDEDManager().getWorldWrapper(world);
	
	BattleStateChangeEvent bscEventCrystals = new BattleStateChangeEvent(dragonBattle, dragon, BattleState.BATTLE_COMMENCED, BattleState.BATTLE_END);
	Bukkit.getPluginManager().callEvent(bscEventCrystals);

	new BukkitRunnable() {
		@Override
		public void run() {
			if (plugin.getNMSAbstract().getEnderDragonDeathAnimationTime(dragon) >= 185) { // Dragon is dead at 200
				new DragonDeathRunnable(plugin, worldWrapper, dragon);
				this.cancel();
			}
		}
	}.runTaskTimer(plugin, 0L, 1L);
}
 
开发者ID:2008Choco,项目名称:DragonEggDrop,代码行数:24,代码来源:DragonLifeListeners.java

示例9: flushSaveQueue

import org.bukkit.World; //导入依赖的package包/类
public static void flushSaveQueue(@Nonnull World world) {
    try {
        if (nmsWorldServer == null) {
            nmsWorldServer = getNmsClass("WorldServer");
        }
        if (worldGetHandle == null) {
            worldGetHandle = world.getClass().getMethod("getHandle");
        }
        if (worldServerFlushSave == null) {
            worldServerFlushSave = nmsWorldServer.getMethod("flushSave");
        }

        Object worldServer = worldGetHandle.invoke(world);
        worldServerFlushSave.invoke(worldServer);
    } catch (Exception ex) {
        log.warning("Error while trying to flush the save queue!");
        ex.printStackTrace();
    }
}
 
开发者ID:VoxelGamesLib,项目名称:VoxelGamesLibv2,代码行数:20,代码来源:NMSUtil.java

示例10: canEdit

import org.bukkit.World; //导入依赖的package包/类
public static boolean canEdit(World world, int x, int z, UUID player) {
       if (Bukkit.getPlayer(player).hasPermission("claimchunk.admin"))
           return true;
       ChunkHandler ch = ClaimChunk.getInstance().getChunkHandler();
	PlayerHandler ph = ClaimChunk.getInstance().getPlayerHandler();
	if (!ch.isClaimed(world, x, z)) {
		return true;
	}
	if (ch.isOwner(world, x, z, player)) {
		return true;
	}
	if (ph.hasAccess(ch.getOwner(world, x, z), player)) {
		return true;
	}
	return false;
}
 
开发者ID:cjburkey01,项目名称:ClaimChunk,代码行数:17,代码来源:ChunkHelper.java

示例11: genRegionMap

import org.bukkit.World; //导入依赖的package包/类
public static void genRegionMap(World world) {
    double sizexz = world.getWorldBorder().getSize();
    map = new String[(int)sizexz][(int)sizexz];
    System.out.println("Generating 2d world map, worldborder size: " + sizexz);
    for (double x=0; x < sizexz; x++) {
        for (double z=0; z < sizexz; z++) {
            Block currentBlock = world.getBlockAt(new Location(world, x,lavalevel,z));

            if (currentBlock.getType().equals(Material.LAVA) ||  currentBlock.getType().equals(Material.STATIONARY_LAVA)) {
                // lava block
                map[(int)x][(int)z] = "lava";
            } else {
                // non lava block
                map[(int)x][(int)z] = "unknown";
            }

        }
    }


    System.out.println("Finished generating 2d world map: " + map.toString());
}
 
开发者ID:Warvale,项目名称:Scorch,代码行数:23,代码来源:RegionMapGen.java

示例12: areAjacentBlocksBright

import org.bukkit.World; //导入依赖的package包/类
public static boolean areAjacentBlocksBright(World world, int x, int y, int z, int countdown) {
    if(Orebfuscator.nms.getBlockLightLevel(world, x, y, z) > 0) {
        return true;
    }

    if (countdown == 0)
        return false;

    if (areAjacentBlocksBright(world, x, y + 1, z, countdown - 1))
        return true;
    if (areAjacentBlocksBright(world, x, y - 1, z, countdown - 1))
        return true;
    if (areAjacentBlocksBright(world, x + 1, y, z, countdown - 1))
        return true;
    if (areAjacentBlocksBright(world, x - 1, y, z, countdown - 1))
        return true;
    if (areAjacentBlocksBright(world, x, y, z + 1, countdown - 1))
        return true;
    if (areAjacentBlocksBright(world, x, y, z - 1, countdown - 1))
        return true;

    return false;
}
 
开发者ID:SamaGames,项目名称:AntiCheat,代码行数:24,代码来源:Calculations.java

示例13: onCommand

import org.bukkit.World; //导入依赖的package包/类
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
    if(!(sender instanceof Player)) {
        sender.sendMessage(ChatColor.RED + "This command is only executable by players.");
        return true;
    }
    final Player player = (Player) sender;
    if(player.getWorld().getEnvironment() != World.Environment.NORMAL) {
        sender.sendMessage(ChatColor.RED + "You can only use this command from the overworld.");
        return true;
    }
    if(plugin.getFactionManager().getFactionAt(((Player) sender).getLocation()) instanceof SpawnFaction){
        sender.sendMessage(ChatColor.RED + "You cannot " + label + " " + this.getName() + " inside of Spawn");
        return true;
    }
    final StuckTimer stuckTimer = this.plugin.getTimerManager().getStuckTimer();
    if(!stuckTimer.setCooldown(player, player.getUniqueId())) {
        sender.sendMessage(ChatColor.YELLOW + "Your " + stuckTimer.getDisplayName() + ChatColor.YELLOW + " timer has a remaining " + ChatColor.LIGHT_PURPLE + DurationFormatUtils.formatDurationWords(stuckTimer.getRemaining(player), true, true)+ChatColor.YELLOW + '.');
        return true;
    }
    sender.sendMessage(ChatColor.YELLOW + stuckTimer.getDisplayName() + ChatColor.YELLOW + " timer has started. " + "\nTeleportation will commence in " + ChatColor.LIGHT_PURPLE + DurationFormatter.getRemaining(stuckTimer.getRemaining(player), true, false) + ChatColor.YELLOW + ". " + "\nThis will cancel if you move more than " + 5 + " blocks.");
    return true;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:23,代码来源:FactionStuckArgument.java

示例14: invalidateCachedChunks

import org.bukkit.World; //导入依赖的package包/类
private static void invalidateCachedChunks(World world, Set<ChunkCoord> invalidChunks) {
    if(invalidChunks.isEmpty() || !OrebfuscatorConfig.UseCache) return;

    File cacheFolder = new File(OrebfuscatorConfig.getCacheFolder(), world.getName());

    for(ChunkCoord chunk : invalidChunks) {
        ObfuscatedCachedChunk cache = new ObfuscatedCachedChunk(cacheFolder, chunk.x, chunk.z);
        cache.invalidate();

        //Orebfuscator.log("Chunk x = " + chunk.x + ", z = " + chunk.z + " is invalidated");/*debug*/
    }
}
 
开发者ID:SamaGames,项目名称:AntiCheat,代码行数:13,代码来源:BlockUpdate.java

示例15: closeNether

import org.bukkit.World; //导入依赖的package包/类
/**
 * Close the nether, teleport players to OverWorld
 */
public void closeNether()
{
    this.netherClosed = true;
    World nether = this.plugin.getServer().getWorld("world_nether");
    World overworld = this.plugin.getServer().getWorld("world");
    if (nether == null)
        return ;
    this.plugin.getServer().getOnlinePlayers().forEach(player ->
    {
        Location location = player.getLocation();
        if (location.getWorld().equals(nether))
        {
            Location newLocation = new Location(overworld, location.getX() * 8, 0, location.getZ());
            newLocation.setY(newLocation.getWorld().getHighestBlockYAt(newLocation));
            player.teleport(newLocation);
            player.sendMessage(ChatColor.RED + "Le nether a été fermé, vous avez été téléporté dans le monde normal.");
        }
    });
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:23,代码来源:SurvivalGameLoop.java


注:本文中的org.bukkit.World类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。