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 |
| Global PvP on/off. |
Spawning |
| Spawning monsters. |
| Spawning animals. | |
Environment |
| Whether the weather changes. |
| 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 de.gilljan.gworld.data.properties.WorldProperty;
manager.createBuilder("Lobby")
.property(WorldProperty.PVP, false)
.property(WorldProperty.ANIMALS, false)
.build();
No comments to display
No comments to display