Skip to content

Commit

Permalink
Weather world properties
Browse files Browse the repository at this point in the history
  • Loading branch information
Moulberry committed Sep 21, 2023
1 parent 8b107c3 commit 1cead96
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/moulberry/axiom/AxiomPaper.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public void onGameRuleChanged(WorldGameRuleChangeEvent event) {
if (properties != null) {
ServerWorldProperty<?> property = properties.getById(new ResourceLocation("axiom:pause_weather"));
if (property != null) {
((ServerWorldProperty<Boolean>)property).setValue(event.getWorld(), Boolean.valueOf(event.getValue()));
((ServerWorldProperty<Boolean>)property).setValue(event.getWorld(), !Boolean.parseBoolean(event.getValue()));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.GameRules;
import org.bukkit.GameRule;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_20_R1.CraftWorld;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -58,7 +59,6 @@ public void registerFor(Plugin plugin, Player bukkitPlayer) {

public void registerDefault(World world) {
ServerLevel serverLevel = ((CraftWorld)world).getHandle();
GameRules gameRules = serverLevel.getGameRules();

// Time
WorldPropertyCategory timeCategory = new WorldPropertyCategory("axiom.editorui.window.world_properties.time", true);
Expand All @@ -76,8 +76,8 @@ public void registerDefault(World world) {

ServerWorldProperty<Boolean> pauseWeather = new ServerWorldProperty<>(new ResourceLocation("axiom:pause_weather"),
"axiom.editorui.window.world_properties.pause_weather",
true, WorldPropertyWidgetType.CHECKBOX, !gameRules.getRule(GameRules.RULE_WEATHER_CYCLE).get(), bool -> {
gameRules.getRule(GameRules.RULE_WEATHER_CYCLE).set(!bool, serverLevel);
true, WorldPropertyWidgetType.CHECKBOX, !world.getGameRuleValue(GameRule.DO_WEATHER_CYCLE), bool -> {
world.setGameRule(GameRule.DO_WEATHER_CYCLE, !bool);
return false;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,8 @@ public void setValueWithoutSyncing(T value) {
}

public void setValue(World world, T value) {
if (!value.equals(this.value)) {
this.value = value;
this.sync(world);
}
this.value = value;
this.sync(world);
}

public void sync(World world) {
Expand Down

0 comments on commit 1cead96

Please sign in to comment.