Package com.onarandombox.MultiverseCore.configuration

Examples of com.onarandombox.MultiverseCore.configuration.SpawnLocation


        assertTrue(mvWorld.getAdjustSpawn());
        assertEquals(GameMode.SURVIVAL, mvWorld.getGameMode());
        assertTrue(mvWorld.isKeepingSpawnInMemory());
        assertTrue(mvWorld.getBedRespawn());
        assertTrue(mvWorld.getAutoLoad());
        assertEquals(new SpawnLocation(0, 64, 0), mvWorld.getSpawnLocation());

        /* ****************************************** *
         *    Call some events and verify behavior
         * ****************************************** */
        createEvents(mvWorld);

        // call both weather change events
        core.getWeatherListener().weatherChange(weatherChangeOffEvent);
        assertFalse(weatherChangeOffEvent.isCancelled());
        core.getWeatherListener().weatherChange(weatherChangeOnEvent);
        assertFalse(weatherChangeOnEvent.isCancelled());

        // call both thunder change events
        core.getWeatherListener().thunderChange(thunderChangeOffEvent);
        assertFalse(thunderChangeOffEvent.isCancelled());
        core.getWeatherListener().thunderChange(thunderChangeOnEvent);
        assertFalse(thunderChangeOnEvent.isCancelled());

        // call player chat event
        core.getMVConfig().setPrefixChat(true);
        ((MVAsyncPlayerChatListener) core.getChatListener()).playerChat(playerChatEvent);
        verify(playerChatEvent).setFormat("[" + mvWorld.getColoredWorldString() + "]" + "format");
        core.getMVConfig().setPrefixChat(false);
        ((MVAsyncPlayerChatListener) core.getChatListener()).playerChat(playerChatEvent);
        verify(playerChatEvent, times(1)).setFormat(anyString()); // only ONE TIME (not the 2nd time!)

        // call player join events
        core.getPlayerListener().playerJoin(playerJoinEvent);
        verify(mockPlayer, never()).teleport(any(Location.class));
        core.getPlayerListener().playerJoin(playerNewJoinEvent);
        verify(mockNewPlayer).teleport(worldManager.getFirstSpawnWorld().getSpawnLocation());

        // call player respawn events
        core.getPlayerListener().playerRespawn(playerRespawnBed);
        // bedrespawn is on so nothing should happen
        verify(playerRespawnBed, never()).setRespawnLocation(any(Location.class));
        core.getPlayerListener().playerRespawn(playerRespawnNormal);
        verify(playerRespawnNormal).setRespawnLocation(mvWorld.getSpawnLocation());

        // call entity regain health event
        core.getEntityListener().entityRegainHealth(entityRegainHealthEvent);
        // autoheal is on so nothing should happen
        verify(entityRegainHealthEvent, never()).setCancelled(true);


        /* ************************ *
         *     Modify & Verify
         * ************************ */
        mvWorld.setHidden(true);
        assertEquals(true, mvWorld.isHidden());
        mvWorld.setAlias("alias");
        assertEquals("alias", mvWorld.getAlias());
        assertTrue(mvWorld.setColor("BLACK"));
        assertFalse(mvWorld.setColor("INVALID COLOR"));
        assertEquals(ChatColor.BLACK, mvWorld.getColor());
        assertEquals(ChatColor.BLACK.toString() + "alias" + ChatColor.WHITE.toString(), mvWorld.getColoredWorldString());
        mvWorld.setPVPMode(false);
        assertEquals(false, mvWorld.isPVPEnabled());
        assertTrue(mvWorld.setScaling(2D));
        assertEquals(2D, mvWorld.getScaling(), 0);
        assertFalse(mvWorld.setRespawnToWorld("INVALID WORLD"));
        assertTrue(mvWorld.setRespawnToWorld("world_nether"));
        assertSame(worldManager.getMVWorld("world_nether").getCBWorld(),
                mvWorld.getRespawnToWorld());
        mvWorld.setEnableWeather(false);
        assertEquals(false, mvWorld.isWeatherEnabled());
        assertTrue(mvWorld.setDifficulty(Difficulty.PEACEFUL));
        assertEquals(Difficulty.PEACEFUL, mvWorld.getDifficulty());
        mvWorld.setAllowAnimalSpawn(false);
        assertEquals(false, mvWorld.canAnimalsSpawn());
        mvWorld.setAllowMonsterSpawn(false);
        assertEquals(false, mvWorld.canMonstersSpawn());
        mvWorld.setCurrency(1);
        assertEquals(1, mvWorld.getCurrency());
        mvWorld.setPrice(1D);
        assertEquals(1D, mvWorld.getPrice(), 0);
        mvWorld.setHunger(false);
        assertEquals(false, mvWorld.getHunger());
        mvWorld.setAutoHeal(false);
        assertEquals(false, mvWorld.getAutoHeal());
        mvWorld.setAdjustSpawn(false);
        assertEquals(false, mvWorld.getAdjustSpawn());
        assertTrue(mvWorld.setGameMode(GameMode.CREATIVE));
        assertEquals(GameMode.CREATIVE, mvWorld.getGameMode());
        mvWorld.setKeepSpawnInMemory(false);
        assertEquals(false, mvWorld.isKeepingSpawnInMemory());
        mvWorld.setBedRespawn(false);
        assertEquals(false, mvWorld.getBedRespawn());
        mvWorld.setAutoLoad(false);
        assertEquals(false, mvWorld.getAutoLoad());
        mvWorld.setSpawnLocation(new Location(mvWorld.getCBWorld(), 1, 1, 1));
        assertEquals(new SpawnLocation(1, 1, 1), mvWorld.getSpawnLocation());


        /* ****************************************** *
         *    Call some events and verify behavior
         * ****************************************** */
        // We have to recreate the events and the mock-objects
        createEvents(mvWorld);

        // call both weather change events
        core.getWeatherListener().weatherChange(weatherChangeOffEvent);
        assertFalse(weatherChangeOffEvent.isCancelled());
        core.getWeatherListener().weatherChange(weatherChangeOnEvent);
        assertTrue(weatherChangeOnEvent.isCancelled());

        // call both thunder change events
        core.getWeatherListener().thunderChange(thunderChangeOffEvent);
        assertFalse(thunderChangeOffEvent.isCancelled());
        core.getWeatherListener().thunderChange(thunderChangeOnEvent);
        assertTrue(thunderChangeOnEvent.isCancelled());

        // call player chat event
        core.getMVConfig().setPrefixChat(true);
        ((MVAsyncPlayerChatListener) core.getChatListener()).playerChat(playerChatEvent);
        // never because it's hidden!
        verify(playerChatEvent, never()).setFormat(
                "[" + mvWorld.getColoredWorldString() + "]" + "format");
        mvWorld.setHidden(false);
        ((MVAsyncPlayerChatListener) core.getChatListener()).playerChat(playerChatEvent);
        verify(playerChatEvent).setFormat("[" + mvWorld.getColoredWorldString() + "]" + "format");
        core.getMVConfig().setPrefixChat(false);
        ((MVAsyncPlayerChatListener) core.getChatListener()).playerChat(playerChatEvent);
        verify(playerChatEvent, times(1)).setFormat(anyString()); // only ONE TIME (not the 2nd time!)
        mvWorld.setHidden(true); // reset hidden-state

        // call player join events
        core.getPlayerListener().playerJoin(playerJoinEvent);
        verify(mockPlayer, never()).teleport(any(Location.class));
        core.getPlayerListener().playerJoin(playerNewJoinEvent);
        verify(mockNewPlayer).teleport(new SpawnLocation(1, 1, 1));

        // call player respawn events
        core.getPlayerListener().playerRespawn(playerRespawnBed);
        // bedrespawn is off so something should happen (and we've set respawn to nether...)
        verify(playerRespawnBed).setRespawnLocation(netherWorld.getSpawnLocation());
        core.getPlayerListener().playerRespawn(playerRespawnNormal);
        verify(playerRespawnNormal).setRespawnLocation(netherWorld.getSpawnLocation());

        // call entity regain health event
        core.getEntityListener().entityRegainHealth(entityRegainHealthEvent);
        // autoheal is off so something should happen
        verify(entityRegainHealthEvent).setCancelled(true);


        /* ****************************************** *
         *           Test saving/loading
         * ****************************************** */
        assertTrue(core.saveMVConfigs());
        // change a value here
        FileConfiguration config = YamlConfiguration.loadConfiguration(new File(core.getDataFolder(), "worlds.yml"));
        WorldProperties worldObj = (WorldProperties) config.get("worlds.world");
        assertTrue(worldObj.setColor("GREEN"));
        config.set("worlds.world", worldObj);
        config.save(new File(core.getDataFolder(), "worlds.yml"));
        // load
        core.loadConfigs();

        mvWorld = worldManager.getMVWorld("world");
        assertEquals(true, mvWorld.isHidden());
        assertEquals("alias", mvWorld.getAlias());
        assertEquals(ChatColor.GREEN, mvWorld.getColor());
        assertEquals(ChatColor.GREEN.toString() + "alias" + ChatColor.WHITE.toString(), mvWorld.getColoredWorldString());
        assertEquals(false, mvWorld.isPVPEnabled());
        assertEquals(2D, mvWorld.getScaling(), 0);
        assertSame(worldManager.getMVWorld("world_nether").getCBWorld(),
                mvWorld.getRespawnToWorld());
        assertEquals(false, mvWorld.isWeatherEnabled());
        assertEquals(Difficulty.PEACEFUL, mvWorld.getDifficulty());
        assertEquals(false, mvWorld.canAnimalsSpawn());
        assertEquals(false, mvWorld.canMonstersSpawn());
        assertEquals(1, mvWorld.getCurrency());
        assertEquals(1D, mvWorld.getPrice(), 0);
        assertEquals(false, mvWorld.getHunger());
        assertEquals(false, mvWorld.getAutoHeal());
        assertEquals(false, mvWorld.getAdjustSpawn());
        assertEquals(GameMode.CREATIVE, mvWorld.getGameMode());
        assertEquals(false, mvWorld.isKeepingSpawnInMemory());
        assertEquals(false, mvWorld.getBedRespawn());
        assertEquals(false, mvWorld.getAutoLoad());
        assertEquals(new SpawnLocation(1, 1, 1), mvWorld.getSpawnLocation());
    }
View Full Code Here


        // Setup spawn separately so we can use the validator with the world spawn value..
        final SpawnLocationPropertyValidator spawnValidator = new SpawnLocationPropertyValidator();
        this.props.setValidator("spawn", spawnValidator);
        this.props.spawnLocation.setWorld(world);
        if (this.props.spawnLocation instanceof NullLocation) {
            final SpawnLocation newLoc = new SpawnLocation(readSpawnFromWorld(world));
            this.props.spawnLocation = newLoc;
            world.setSpawnLocation(newLoc.getBlockX(), newLoc.getBlockY(), newLoc.getBlockZ());
        }

        this.props.environment = world.getEnvironment();
        this.props.seed = world.getSeed();
View Full Code Here

            @Override
            public void set(Location newValue) {
                if (getCBWorld() != null)
                    getCBWorld().setSpawnLocation(newValue.getBlockX(), newValue.getBlockY(), newValue.getBlockZ());

                props.spawnLocation = new SpawnLocation(newValue);
            }

            @Override
            public Location get() {
                props.spawnLocation.setWorld(getCBWorld());
View Full Code Here

TOP

Related Classes of com.onarandombox.MultiverseCore.configuration.SpawnLocation

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.