Add difficulty game rule; resolves #621

This commit is contained in:
Daniel Saukel 2020-04-04 01:11:22 +02:00
parent 38700a3c62
commit 12408d1e62
2 changed files with 8 additions and 2 deletions

View File

@ -33,6 +33,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.bukkit.Difficulty;
import org.bukkit.GameMode;
import org.bukkit.configuration.ConfigurationSection;
@ -69,9 +70,13 @@ public class GameRule<V> {
*/
public static final GameRule<GameGoal> GAME_GOAL = new GameRule<>(GameGoal.class, "gameGoal", GameGoal.END);
/**
* The game mode.
* The Vanilla game mode.
*/
public static final GameRule<GameMode> GAME_MODE = new GameRule<>(GameMode.class, "gameMode", GameMode.SURVIVAL);
/**
* The Vanilla difficulty.
*/
public static final GameRule<Difficulty> DIFFICULTY = new GameRule<>(Difficulty.class, "difficulty", Difficulty.NORMAL);
/**
* If players may fly.
*/

View File

@ -405,11 +405,12 @@ public class DGameWorld extends DInstanceWorld implements GameWorld {
public void startGame() {
GameWorldStartGameEvent event = new GameWorldStartGameEvent(this, (DGame) getGame());
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
world.setDifficulty(getRules().getState(GameRule.DIFFICULTY));
isPlaying = true;
for (DungeonSign sign : getDungeonSigns()) {