3
0
Mirror von https://github.com/Moulberry/AxiomPaperPlugin.git synchronisiert 2024-09-29 07:50:05 +02:00

Weather world properties

Dieser Commit ist enthalten in:
Moulberry 2023-09-21 18:44:07 +08:00
Ursprung 8b107c3a9a
Commit 1cead96565
3 geänderte Dateien mit 6 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -172,7 +172,7 @@ public class AxiomPaper extends JavaPlugin implements Listener {
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()));
}
}
}

Datei anzeigen

@ -7,6 +7,7 @@ import net.minecraft.network.FriendlyByteBuf;
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;
@ -58,7 +59,6 @@ public class ServerWorldPropertiesRegistry {
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);
@ -76,8 +76,8 @@ public class ServerWorldPropertiesRegistry {
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;
});

Datei anzeigen

@ -50,10 +50,8 @@ public class ServerWorldProperty<T> {
}
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) {