Skip to main content

4. Flags & Properties

GWorld allows you to change world settings (flags) programmatically. These settings are stored persistently.

Set flags

You can change flags directly on the IManageableWorld object or set them during creation in the builder.

// Example: Disable PvP and change difficulty
world.setAllowPvP(false);
world.setDifficulty(Difficulty.HARD);

// IMPORTANT: Save so that it is retained after restarting! world.saveProperties();

Available settings

Here is an overview of the most important methods in IManageableWorld interface:

Category

Methods (Getter / Setter)

Description

isAllowPvP, setAllowPvP

Global PvP on/off.

Spawning

isMonsterSpawning, setMonsterSpawning

Spawning monsters.


isAnimalSpawning, setAnimalSpawning

Spawning animals.

Environment

isWeatherCycle, setWeatherCycle


isTimeCycle, setTimeCycle

Whether the time of day is advancing.


getTime, setTime

Current time in ticks.

Player

getGameMode, setGameMode

Default game mode of the world.

System

isLoadOnStartup, setLoadOnStartup

Should the world be loaded when the server starts?


isKeepSpawnInMemory, setKeepSpawnInMemory

Keep spawn chunks in RAM.

Use in the Builder

When creating a world, you can also set flags generically via WorldProperty:

import en.gilljan.gworld.data.properties.WorldProperty;manager.createBuilder(„Lobby“)
    .property(WorldProperty.PVP, false)
    .property(WorldProperty.ANIMALS, false) 
    .build();