本文整理汇总了Java中org.bukkit.World.Environment.getEnvironment方法的典型用法代码示例。如果您正苦于以下问题:Java Environment.getEnvironment方法的具体用法?Java Environment.getEnvironment怎么用?Java Environment.getEnvironment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.World.Environment
的用法示例。
在下文中一共展示了Environment.getEnvironment方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerBukkitEnvironment
import org.bukkit.World.Environment; //导入方法依赖的package包/类
public static Environment registerBukkitEnvironment(int dim, String providerName)
{
Environment env = Environment.getEnvironment(dim);
if (env == null) // Cauldron if environment not found, register one
{
providerName = providerName.replace("WorldProvider", "");
env = EnumHelper.addBukkitEnvironment(dim, providerName.toUpperCase());
Environment.registerEnvironment(env);
}
return env;
}
示例2: initDimension
import org.bukkit.World.Environment; //导入方法依赖的package包/类
public static void initDimension(int dim) {
if (dim == 0) return; // Cauldron - overworld
WorldServer overworld = getWorld(0);
if (overworld == null)
{
throw new RuntimeException("Cannot Hotload Dim: Overworld is not Loaded!");
}
try
{
// Cauldron start - Fixes MultiVerse issue when mods such as Twilight Forest try to hotload their dimension when using its WorldProvider
if(net.minecraftforge.cauldron.CauldronHooks.craftWorldLoading)
{
return;
}
// Cauldron end
DimensionManager.getProviderType(dim);
}
catch (Exception e)
{
System.err.println("Cannot Hotload Dim: " + e.getMessage());
return; // If a provider hasn't been registered then we can't hotload the dim
}
MinecraftServer mcServer = overworld.func_73046_m();
ISaveHandler savehandler = overworld.getSaveHandler();
WorldSettings worldSettings = new WorldSettings(overworld.getWorldInfo());
// Cauldron start - handles hotloading dimensions
String worldType;
String name;
String oldName = "";
Environment env = Environment.getEnvironment(getProviderType(dim));
if (dim >= -1 && dim <= 1)
{
if ((dim == -1 && !mcServer.getAllowNether()) || (dim == 1 && !mcServer.server.getAllowEnd()))
return;
worldType = env.toString().toLowerCase();
name = "DIM" + dim;
}
else
{
WorldProvider provider = WorldProvider.getProviderForDimension(dim);
worldType = provider.getClass().getSimpleName().toLowerCase();
worldType = worldType.replace("worldprovider", "");
oldName = "world_" + worldType;
worldType = worldType.replace("provider", "");
if (Environment.getEnvironment(DimensionManager.getProviderType(dim)) == null)
env = DimensionManager.registerBukkitEnvironment(DimensionManager.getProviderType(provider.getClass()), worldType);
name = provider.getSaveFolder();
if (name == null) name = "DIM0";
}
// add ability to disable dimensions
if (!MinecraftServer.getServer().cauldronConfig.getBoolean("world-environment-settings." + worldType + ".enabled", true))
return;
CauldronUtils.migrateWorlds(worldType, oldName, overworld.getWorldInfo().getWorldName(), name); // Cauldron
ChunkGenerator gen = mcServer.server.getGenerator(name);
if (mcServer instanceof DedicatedServer) {
worldSettings.func_82750_a(((DedicatedServer) mcServer).getStringProperty("generator-settings", ""));
}
WorldServer world = new WorldServerMulti(mcServer, new AnvilSaveHandler(mcServer.server.getWorldContainer(), name, true), name, dim, worldSettings, overworld, mcServer.theProfiler, env, gen);
if (gen != null)
{
world.getWorld().getPopulators().addAll(gen.getDefaultPopulators(world.getWorld()));
}
mcServer.getConfigurationManager().setPlayerManager(mcServer.worlds.toArray(new WorldServer[mcServer.worlds.size()]));
world.addWorldAccess(new WorldManager(mcServer, world));
MinecraftForge.EVENT_BUS.post(new WorldEvent.Load(world));
mcServer.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldLoadEvent(world.getWorld()));
// Cauldron end
if (!mcServer.isSinglePlayer())
{
world.getWorldInfo().setGameType(mcServer.getGameType());
}
mcServer.func_147139_a(mcServer.func_147135_j());
}