mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-09 00:22:08 -07:00
Add WorldDifficultyChangeEvent (#12471)
This commit is contained in:
@@ -1112,7 +1112,7 @@
|
||||
}
|
||||
|
||||
public KeyPair getKeyPair() {
|
||||
@@ -1244,11 +_,14 @@
|
||||
@@ -1244,11 +_,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1121,10 +1121,13 @@
|
||||
- this.worldData.setDifficulty(this.worldData.isHardcore() ? Difficulty.HARD : difficulty);
|
||||
- this.updateMobSpawningFlags();
|
||||
- this.getPlayerList().getPlayers().forEach(this::sendDifficultyUpdate);
|
||||
+ // Paper start - per level difficulty
|
||||
+ public void setDifficulty(ServerLevel level, Difficulty difficulty, boolean forced) {
|
||||
+ // Paper start - per level difficulty, WorldDifficultyChangeEvent
|
||||
+ public void setDifficulty(ServerLevel level, Difficulty difficulty, @Nullable CommandSourceStack source, boolean forced) {
|
||||
+ net.minecraft.world.level.storage.PrimaryLevelData worldData = level.serverLevelData;
|
||||
+ if (forced || !worldData.isDifficultyLocked()) {
|
||||
+ new io.papermc.paper.event.world.WorldDifficultyChangeEvent(
|
||||
+ level.getWorld(), source, org.bukkit.craftbukkit.util.CraftDifficulty.toBukkit(difficulty)
|
||||
+ ).callEvent();
|
||||
+ worldData.setDifficulty(worldData.isHardcore() ? Difficulty.HARD : difficulty);
|
||||
+ level.setSpawnSettings(worldData.getDifficulty() != Difficulty.PEACEFUL && ((net.minecraft.server.dedicated.DedicatedServer) this).settings.getProperties().spawnMonsters);
|
||||
+ // this.getPlayerList().getPlayers().forEach(this::sendDifficultyUpdate);
|
||||
|
Reference in New Issue
Block a user