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 set difficulty to hard
world.setAllowPvP(false);
world.setDifficulty(Difficulty.HARD);

// IMPORTANT: Save changes to disk. Ensures data integrity after a restart.
world.saveProperties();

Available settings

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

Category

Methods (Getter / Setter)

Description

PVP

isAllowPvP, setAllowPvP

Global PvP on/off.

Spawning

isMonsterSpawning, setMonsterSpawning

Spawning monsters.


isAnimalSpawning, setAnimalSpawning

Spawning animals.

Environment

isWeatherCycle, setWeatherCycle

Whether the weather changes.


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?


isAllowPvP, setAllowPvP

Keep spawn chunks in RAM.

Use in the Builder

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

import de.gilljan.gworld.data.properties.WorldProperty;

manager.createBuilder("Lobby")
    .property(WorldProperty.PVP, false)
    .property(WorldProperty.ANIMALS, false) 
    .build();