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 | ||
| Global PvP on/off. | |||
Spawning |
| Spawning monsters. | ||
| Spawning animals. | |||
Environment |
|
| Whether the time of day is advancing. | |
| Current time in ticks. | |||
Player |
| Default game mode of the world. | ||
System |
| Should the world be loaded when the server starts? | ||
| 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();