Package org.bukkit

Examples of org.bukkit.WorldCreator


      if (Current.Plugin.getServer().getWorld(worldName) == null)
      {
        Util.CopyWorld(mapName, worldName, false);
      }

      WorldCreator wc = new WorldCreator(worldName);
      Current.Plugin.getServer().createWorld(wc);

      GameWorlds.add(worldName);
    }
View Full Code Here


        // Verify
        verify(mockCommandSender).sendMessage("Starting creation of world 'newworld'...");
        verify(mockCommandSender).sendMessage("Complete!");

        WorldCreatorMatcher matcher = new WorldCreatorMatcher(new WorldCreator("newworld"));
        verify(mockServer).createWorld(Matchers.argThat(matcher));
    }
View Full Code Here

        // Verify
        verify(mockCommandSender).sendMessage("Starting creation of world 'nullworld'...");
        verify(mockCommandSender).sendMessage("Complete!");

        WorldCreatorMatcher matcher = new WorldCreatorMatcher(new WorldCreator("nullworld"));
        verify(mockServer).createWorld(Matchers.argThat(matcher));
    }
View Full Code Here

      }
    }
    Exception failReason = null;
    for (i = 0; i < retrycount + 1; i++) {
      try {
        WorldCreator c = new WorldCreator(worldname);
        wc.worldmode.apply(c);
        if (seed != 0) {
          c.seed(seed);
        }
        c.generator(cgen);
        w = c.createWorld();
      } catch (Exception ex) {
        failReason = ex;
      }
      if (w != null) break;
    }
View Full Code Here

    // built yet?
    World cityWorldPrime = Bukkit.getServer().getWorld(DEFAULT_WORLD_NAME);
    if (cityWorldPrime == null) {
     
      // if neither then create/build it!
      WorldCreator worldcreator = new WorldCreator(DEFAULT_WORLD_NAME);
      //worldcreator.seed(-7457540200860308014L); // Beta seed
      //worldcreator.seed(5509442565638151977L); // 82,-35
      worldcreator.environment(environment);
      worldcreator.generator(new WorldGenerator(plugin, DEFAULT_WORLD_NAME, style.toString()));
      cityWorldPrime = Bukkit.getServer().createWorld(worldcreator);
    }
    return cityWorldPrime;
  }
View Full Code Here

            when(mockServer.createWorld(Matchers.isA(WorldCreator.class))).thenAnswer(
                    new Answer<World>() {
                        @Override
                        public World answer(InvocationOnMock invocation) throws Throwable {
                            WorldCreator arg;
                            try {
                                arg = (WorldCreator) invocation.getArguments()[0];
                            } catch (Exception e) {
                                return null;
                            }
                            // Add special case for creating null worlds.
                            // Not sure I like doing it this way, but this is a special case
                            if (arg.name().equalsIgnoreCase("nullworld")) {
                                return MockWorldFactory.makeNewNullMockWorld(arg.name(), arg.environment(), arg.type());
                            }
                            return MockWorldFactory.makeNewMockWorld(arg.name(), arg.environment(), arg.type());
                        }
                    });

            when(mockServer.unloadWorld(anyString(), anyBoolean())).thenReturn(true);

            // add mock scheduler
            BukkitScheduler mockScheduler = mock(BukkitScheduler.class);
            when(mockScheduler.scheduleSyncDelayedTask(any(Plugin.class), any(Runnable.class), anyLong())).
            thenAnswer(new Answer<Integer>() {
                @Override
                public Integer answer(InvocationOnMock invocation) throws Throwable {
                    Runnable arg;
                    try {
                        arg = (Runnable) invocation.getArguments()[1];
                    } catch (Exception e) {
                        return null;
                    }
                    arg.run();
                    return null;
                }});
            when(mockScheduler.scheduleSyncDelayedTask(any(Plugin.class), any(Runnable.class))).
            thenAnswer(new Answer<Integer>() {
                @Override
                public Integer answer(InvocationOnMock invocation) throws Throwable {
                    Runnable arg;
                    try {
                        arg = (Runnable) invocation.getArguments()[1];
                    } catch (Exception e) {
                        return null;
                    }
                    arg.run();
                    return null;
                }});
            when(mockServer.getScheduler()).thenReturn(mockScheduler);

            // Set server
View Full Code Here

            e.printStackTrace();
            return false;
        }
        Logging.fine("Kind of copied stuff");

        WorldCreator worldCreator = new WorldCreator(newName);
        Logging.fine("Started to copy settings");
        worldCreator.copy(this.getMVWorld(oldName).getCBWorld());
        Logging.fine("Copied lots of settings");

        boolean useSpawnAdjust = this.getMVWorld(oldName).getAdjustSpawn();
        Logging.fine("Copied more settings");

        Environment environment = worldCreator.environment();
        Logging.fine("Copied most settings");
        if (newWorldFile.exists()) {
            Logging.fine("Succeeded at copying stuff");
            if (this.addWorld(newName, environment, null, null, null, generator, useSpawnAdjust)) {
                // getMVWorld() doesn't actually return an MVWorld
View Full Code Here

     */
    @Override
    public boolean addWorld(String name, Environment env, String seedString, WorldType type, Boolean generateStructures,
                            String generator, boolean useSpawnAdjust) {
        Long seed = null;
        WorldCreator c = new WorldCreator(name);
        if (seedString != null && seedString.length() > 0) {
            try {
                seed = Long.parseLong(seedString);
            } catch (NumberFormatException numberformatexception) {
                seed = (long) seedString.hashCode();
            }
            c.seed(seed);
        }

        // TODO: Use the fancy kind with the commandSender
        if (generator != null && generator.length() != 0) {
            c.generator(generator);
        }
        c.environment(env);
        if (type != null) {
            c.type(type);
        }
        if (generateStructures != null) {
            c.generateStructures(generateStructures);
        }

        // Important: doLoad() needs the MVWorld-object in worldsFromTheConfig
        if (!worldsFromTheConfig.containsKey(name)) {
            WorldProperties props = new WorldProperties(useSpawnAdjust, env);
View Full Code Here

    private boolean doLoad(String name, boolean ignoreExists, WorldType type) {
        if (!worldsFromTheConfig.containsKey(name))
            throw new IllegalArgumentException("That world doesn't exist!");

        final WorldProperties world = worldsFromTheConfig.get(name);
        final WorldCreator creator = WorldCreator.name(name);

        creator.environment(world.getEnvironment()).seed(world.getSeed());
        if (type != null) {
            creator.type(type);
        }

        boolean generatorSuccess = true;
        if ((world.getGenerator() != null) && (!world.getGenerator().equals("null")))
            generatorSuccess = null != plugin.getUnsafeCallWrapper().wrap(new Callable<Object>() {
                @Override
                public Object call() throws Exception {
                    creator.generator(world.getGenerator());
                    return new Object();
                }
            }, "the generator plugin", "Failed to set the generator for world '%s' to '%s': %s", name, world.getGenerator());

        return generatorSuccess && doLoad(creator, ignoreExists);
View Full Code Here

TOP

Related Classes of org.bukkit.WorldCreator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.