本文整理汇总了Java中org.spongepowered.api.world.DimensionType类的典型用法代码示例。如果您正苦于以下问题:Java DimensionType类的具体用法?Java DimensionType怎么用?Java DimensionType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DimensionType类属于org.spongepowered.api.world包,在下文中一共展示了DimensionType类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDimensionType
import org.spongepowered.api.world.DimensionType; //导入依赖的package包/类
public Optional<DimensionType> getDimensionType() {
Collection<DimensionType> types = Sponge.getRegistry().getAllOf(DimensionType.class);
return types.stream().filter(t -> t.getId().equalsIgnoreCase(dimension) || t.getName().equalsIgnoreCase(dimension)).findAny();
}
示例2: RestoreNatureProcessingTask
import org.spongepowered.api.world.DimensionType; //导入依赖的package包/类
public RestoreNatureProcessingTask(BlockSnapshot[][][] snapshots, int miny, DimensionType environment, BiomeType biome,
Location<World> lesserBoundaryCorner, Location<World> greaterBoundaryCorner, int seaLevel, boolean aggressiveMode, boolean creativeMode,
Player player) {
this.snapshots = snapshots;
this.miny = miny;
if (this.miny < 0) {
this.miny = 0;
}
this.environment = environment;
this.lesserBoundaryCorner = lesserBoundaryCorner;
this.greaterBoundaryCorner = greaterBoundaryCorner;
this.biome = biome;
this.seaLevel = seaLevel;
this.aggressiveMode = aggressiveMode;
this.player = player;
this.creativeMode = creativeMode;
this.notAllowedToHang = new ArrayList<BlockType>();
this.notAllowedToHang.add(BlockTypes.DIRT);
this.notAllowedToHang.add(BlockTypes.TALLGRASS);
this.notAllowedToHang.add(BlockTypes.SNOW);
this.notAllowedToHang.add(BlockTypes.LOG);
if (this.aggressiveMode) {
this.notAllowedToHang.add(BlockTypes.GRASS);
this.notAllowedToHang.add(BlockTypes.STONE);
}
this.playerBlocks = new ArrayList<BlockType>();
this.playerBlocks.addAll(RestoreNatureProcessingTask.getPlayerBlocks(this.environment, this.biome));
// in aggressive or creative world mode, also treat these blocks as user placed, to be removed
// this is helpful in the few cases where griefers intentionally use natural blocks to grief,
// like a single-block tower of iron ore or a giant penis constructed with melons
if (this.aggressiveMode || this.creativeMode) {
this.playerBlocks.add(BlockTypes.IRON_ORE);
this.playerBlocks.add(BlockTypes.GOLD_ORE);
this.playerBlocks.add(BlockTypes.DIAMOND_ORE);
this.playerBlocks.add(BlockTypes.MELON_BLOCK);
this.playerBlocks.add(BlockTypes.MELON_STEM);
this.playerBlocks.add(BlockTypes.BEDROCK);
this.playerBlocks.add(BlockTypes.COAL_ORE);
this.playerBlocks.add(BlockTypes.PUMPKIN);
this.playerBlocks.add(BlockTypes.PUMPKIN_STEM);
}
if (this.aggressiveMode) {
this.playerBlocks.add(BlockTypes.LEAVES);
this.playerBlocks.add(BlockTypes.LOG);
this.playerBlocks.add(BlockTypes.LOG2);
this.playerBlocks.add(BlockTypes.VINE);
}
}
示例3: dimension
import org.spongepowered.api.world.DimensionType; //导入依赖的package包/类
@Override
public LanternWorldArchetypeBuilder dimension(DimensionType type) {
this.dimensionType = (LanternDimensionType<?>) checkNotNull(type, "type");
return this;
}
示例4: getType
import org.spongepowered.api.world.DimensionType; //导入依赖的package包/类
@Override
public DimensionType getType() {
return this.dimensionType;
}
示例5: execute
import org.spongepowered.api.world.DimensionType; //导入依赖的package包/类
public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException
{
String name = ctx.<String> getOne("name").get();
String dimensionInput = ctx.<String> getOne("dimension").get();
String generatorInput = ctx.<String> getOne("generator").get();
String difficultyInput = ctx.<String> getOne("difficulty").get();
GameMode gamemode = ctx.<GameMode> getOne("gamemode").get();
Difficulty difficulty = null;
DimensionType dimension = null;
GeneratorType generator = null;
if (Sponge.getRegistry().getType(DimensionType.class, dimensionInput).isPresent())
{
dimension = Sponge.getRegistry().getType(DimensionType.class, dimensionInput).get();
}
else
{
src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "Dimension type specified not found."));
return CommandResult.success();
}
if (Sponge.getRegistry().getType(GeneratorType.class, generatorInput).isPresent())
{
generator = Sponge.getRegistry().getType(GeneratorType.class, generatorInput).get();
}
else
{
src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "Generator type specified not found."));
return CommandResult.success();
}
if (Sponge.getRegistry().getType(Difficulty.class, difficultyInput).isPresent())
{
difficulty = Sponge.getRegistry().getType(Difficulty.class, difficultyInput).get();
}
else
{
src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "Difficulty specified not found."));
return CommandResult.success();
}
src.sendMessage(Text.of(TextColors.GREEN, "Success! ", TextColors.YELLOW, "Beginning creation of world."));
WorldArchetype worldSettings = WorldArchetype.builder()
.enabled(true)
.loadsOnStartup(true)
.keepsSpawnLoaded(true)
.dimension(dimension)
.generator(generator)
.gameMode(gamemode)
.build(name.toLowerCase(), name);
try
{
WorldProperties worldProperties = Sponge.getGame().getServer().createWorldProperties(name, worldSettings);
Optional<World> world = Sponge.getGame().getServer().loadWorld(worldProperties);
if (world.isPresent())
{
world.get().getProperties().setDifficulty(difficulty);
src.sendMessage(Text.of(TextColors.GREEN, "Success! ", TextColors.GOLD, "World ", TextColors.GRAY, name, TextColors.GOLD, " has been created."));
}
else
{
src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "The world could not be created."));
}
}
catch (IOException e)
{
src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "The world properties could not be created."));
}
return CommandResult.success();
}
示例6: create
import org.spongepowered.api.world.DimensionType; //导入依赖的package包/类
@Command(desc = "Creates a new world")
public void create(CommandSource context,
String name,
@Default @Named({"dimension", "dim"}) DimensionType dimension,
@Named("seed") String seed,
@Default @Named({"type"}) GeneratorType type,
@Default @Label("generate") @Named({"structure", "struct"}) boolean generateStructures,
@Default @Named({"gamemode", "mode"}) GameMode gamemode,
@Default @Named({"difficulty", "diff"}) Difficulty difficulty,
@org.cubeengine.butler.parametric.Optional @Label("name") @Named({"generator","gen"}) WorldGeneratorModifier generator,
@Flag boolean recreate,
@Flag boolean noload,
@Flag boolean spawnInMemory)
{
Optional<World> world = Sponge.getServer().getWorld(name);
if (world.isPresent())
{
if (recreate)
{
i18n.send(context, NEGATIVE, "You have to unload a world before recreating it!");
return;
}
i18n.send(context, NEGATIVE, "A world named {world} already exists and is loaded!", world.get());
return;
}
Optional<WorldProperties> worldProperties = Sponge.getServer().getWorldProperties(name);
if (worldProperties.isPresent())
{
if (!recreate)
{
i18n.send(context, NEGATIVE, "A world named {name#world} already exists but is not loaded!", name);
return;
}
worldProperties.get().setEnabled(false);
String newName = name + "_" + new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss").format(new Date());
Sponge.getServer().renameWorld(worldProperties.get(), newName);
i18n.send(context, POSITIVE, "Old world moved to {name#folder}", newName);
}
WorldArchetype.Builder builder = WorldArchetype.builder().from(WorldArchetypes.OVERWORLD);
builder.keepsSpawnLoaded(spawnInMemory);
builder.loadsOnStartup(!noload);
if (seed != null)
{
try
{
builder.seed(Long.parseLong(seed));
}
catch (NumberFormatException ignore)
{
builder.seed(seed.hashCode());
}
}
builder.generator(type);
builder.dimension(dimension);
builder.usesMapFeatures(generateStructures);
builder.gameMode(gamemode);
if (generator != null)
{
builder.generatorModifiers(generator);
}
builder.difficulty(difficulty);
try
{
WorldProperties properties = Sponge.getServer().createWorldProperties(name, builder.build("org.cubeengine.customworld:" + UUID.randomUUID().toString(), name));
i18n.send(context, POSITIVE, "World {name} successfully created!", name);
i18n.send(context, NEUTRAL, "This world is not yet loaded! Click {txt#here} to load.",
i18n.translate(context, TextFormat.NONE, "here").toBuilder().onClick(TextActions.runCommand("/worlds load " + name)).build());
}
catch (IOException e)
{
i18n.send(context, NEGATIVE, "Could not create world!");
throw new IllegalStateException(e); // TODO handle exception better
}
}
示例7: getDimensionType
import org.spongepowered.api.world.DimensionType; //导入依赖的package包/类
@Override
public DimensionType getDimensionType() {
return this.dimensionType;
}
示例8: dimension
import org.spongepowered.api.world.DimensionType; //导入依赖的package包/类
@Override
public WorldCreationSettings.Builder dimension(DimensionType type) {
this.dimensionType = type;
return this;
}
示例9: execute
import org.spongepowered.api.world.DimensionType; //导入依赖的package包/类
@Override
public CommandResult execute(CommandSource sender, CommandContext args) throws CommandException {
String name = (String) args.getOne("name").get();
Optional<DimensionType> dimension = args.getOne("dimension");
Optional<GeneratorType> generator = args.getOne("generator");
Collection<WorldGeneratorModifier> wgm = args.getAll("wgm");
Optional<Long> seed = args.getOne("seed");
Optional<GameMode> gm = args.getOne("gamemode");
Optional<Difficulty> diff = args.getOne("difficulty");
boolean nostructures = args.hasAny("n");
boolean load = args.<Boolean>getOne("l").orElse(true);
boolean keepspawnloaded = args.<Boolean>getOne("k").orElse(true);
boolean allowcommands = args.<Boolean>getOne("c").orElse(true);
boolean bonuschest = args.<Boolean>getOne("b").orElse(true);
Path path = Sponge.getGame().getSavesDirectory();
if (Files.exists(path.resolve(name.toLowerCase())) || Files.exists(path.resolve(name)) || Sponge.getServer().getAllWorldProperties().stream().anyMatch(x -> x.getWorldName().equalsIgnoreCase(name))) {
throw new ErrorMessageException(Messages.getFormatted(sender, "world.exists", "%name%", name));
}
Messages.send(sender, "world.command.world.create.starting", "%name%", name);
WorldArchetype.Builder archetype = WorldArchetype.builder().enabled(true);
dimension.ifPresent(archetype::dimension);
generator.ifPresent(archetype::generator);
archetype.generatorModifiers(wgm.toArray(new WorldGeneratorModifier[wgm.size()]));
seed.ifPresent(archetype::seed);
gm.ifPresent(archetype::gameMode);
diff.ifPresent(archetype::difficulty);
archetype.usesMapFeatures(!nostructures);
archetype.loadsOnStartup(load);
archetype.keepsSpawnLoaded(keepspawnloaded);
archetype.commandsAllowed(allowcommands);
archetype.generateBonusChest(bonuschest);
WorldProperties props;
try {
props = Sponge.getServer().createWorldProperties(name.toLowerCase(), archetype.build(name.toLowerCase(), name));
} catch (IOException e) {
throw new ErrorMessageException(Messages.getFormatted(sender, "world.command.world.create.fileerror", "%error%", e.getMessage()));
}
Sponge.getServer().saveWorldProperties(props);
World world = Sponge.getServer().loadWorld(props).orElseThrow(() -> new ErrorMessageException(Messages.getFormatted(sender, "world.command.world.create.loaderror")));
Messages.send(sender, "world.command.world.create.success", "%name%", world.getName());
return CommandResult.success();
}
示例10: of
import org.spongepowered.api.world.DimensionType; //导入依赖的package包/类
public static DimensionType of(World.Environment environment) {
return CONVERTER.convert(environment);
}
示例11: setDimensionType
import org.spongepowered.api.world.DimensionType; //导入依赖的package包/类
/**
* Sets the {@link DimensionType}.
*
* @param dimensionType The dimension type
*/
public void setDimensionType(DimensionType dimensionType) {
this.dimensionType = (LanternDimensionType<?>) checkNotNull(dimensionType, "dimensionType");
}