Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 12:30:06 +01:00
26734e83b0
* Updated Upstream (Bukkit/CraftBukkit/Spigot) Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 8085edde SPIGOT-6918: Add SpawnCategory API and configurations for Axolotls 04c7e13c PR-719: Add Player Profile API 71564210 SPIGOT-6910: Add BlockDamageAbortEvent CraftBukkit Changes: febaa1c6 SPIGOT-6918: Add SpawnCategory API and configurations for Axolotls 9dafd109 Don't send updates over large distances bdac46b0 SPIGOT-6782: EntityPortalEvent should not destroy entity when setTo() uses same world as getFrom() 8f361ece PR-1002: Add Player Profile API 911875d4 Increase outdated build delay e5f8a767 SPIGOT-6917: Use main scoreboard for /trigger a672a531 Clean up callBlockDamageEvent 8e1bdeef SPIGOT-6910: Add BlockDamageAbortEvent Spigot Changes: 6edb62f3 Rebuild patches 7fbc6a1e Rebuild patches * Updated Upstream (CraftBukkit) Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing CraftBukkit Changes: de951355 SPIGOT-6927: Fix default value of spawn-limits in Worlds
99 Zeilen
5.9 KiB
Diff
99 Zeilen
5.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
|
Date: Sun, 20 Dec 2020 16:41:44 -0800
|
|
Subject: [PATCH] Added WorldGameRuleChangeEvent
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/commands/GameRuleCommand.java b/src/main/java/net/minecraft/server/commands/GameRuleCommand.java
|
|
index f2e53fbb067a3909f386386eb3b89dfe090ee096..6f6292e7945cec1bdc69632dbfb950d6af53df42 100644
|
|
--- a/src/main/java/net/minecraft/server/commands/GameRuleCommand.java
|
|
+++ b/src/main/java/net/minecraft/server/commands/GameRuleCommand.java
|
|
@@ -33,7 +33,7 @@ public class GameRuleCommand {
|
|
CommandSourceStack commandlistenerwrapper = (CommandSourceStack) context.getSource();
|
|
T t0 = commandlistenerwrapper.getLevel().getGameRules().getRule(key); // CraftBukkit
|
|
|
|
- t0.setFromArgument(context, "value");
|
|
+ t0.setFromArgument(context, "value", key); // Paper
|
|
commandlistenerwrapper.sendSuccess(new TranslatableComponent("commands.gamerule.set", new Object[]{key.getId(), t0.toString()}), true);
|
|
return t0.getCommandResult();
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/level/GameRules.java b/src/main/java/net/minecraft/world/level/GameRules.java
|
|
index 888d812118c15c212284687ae5842a94f5715d52..e7ca5d6fb8922e7e8065864f736b06056be080a0 100644
|
|
--- a/src/main/java/net/minecraft/world/level/GameRules.java
|
|
+++ b/src/main/java/net/minecraft/world/level/GameRules.java
|
|
@@ -261,10 +261,10 @@ public class GameRules {
|
|
this.type = type;
|
|
}
|
|
|
|
- protected abstract void updateFromArgument(CommandContext<CommandSourceStack> context, String name);
|
|
+ protected abstract void updateFromArgument(CommandContext<CommandSourceStack> context, String name, GameRules.Key<T> gameRuleKey); // Paper
|
|
|
|
- public void setFromArgument(CommandContext<CommandSourceStack> context, String name) {
|
|
- this.updateFromArgument(context, name);
|
|
+ public void setFromArgument(CommandContext<CommandSourceStack> context, String name, GameRules.Key<T> gameRuleKey) { // Paper
|
|
+ this.updateFromArgument(context, name, gameRuleKey); // Paper
|
|
this.onChanged(((CommandSourceStack) context.getSource()).getServer());
|
|
}
|
|
|
|
@@ -322,8 +322,11 @@ public class GameRules {
|
|
}
|
|
|
|
@Override
|
|
- protected void updateFromArgument(CommandContext<CommandSourceStack> context, String name) {
|
|
- this.value = BoolArgumentType.getBool(context, name);
|
|
+ protected void updateFromArgument(CommandContext<CommandSourceStack> context, String name, GameRules.Key<BooleanValue> gameRuleKey) { // Paper start
|
|
+ io.papermc.paper.event.world.WorldGameRuleChangeEvent event = new io.papermc.paper.event.world.WorldGameRuleChangeEvent(context.getSource().getBukkitWorld(), context.getSource().getBukkitSender(), (org.bukkit.GameRule<Boolean>) org.bukkit.GameRule.getByName(gameRuleKey.toString()), String.valueOf(BoolArgumentType.getBool(context, name)));
|
|
+ if (!event.callEvent()) return;
|
|
+ this.value = Boolean.parseBoolean(event.getValue());
|
|
+ // Paper end
|
|
}
|
|
|
|
public boolean get() {
|
|
@@ -387,8 +390,11 @@ public class GameRules {
|
|
}
|
|
|
|
@Override
|
|
- protected void updateFromArgument(CommandContext<CommandSourceStack> context, String name) {
|
|
- this.value = IntegerArgumentType.getInteger(context, name);
|
|
+ protected void updateFromArgument(CommandContext<CommandSourceStack> context, String name, GameRules.Key<IntegerValue> gameRuleKey) { // Paper start
|
|
+ io.papermc.paper.event.world.WorldGameRuleChangeEvent event = new io.papermc.paper.event.world.WorldGameRuleChangeEvent(context.getSource().getBukkitWorld(), context.getSource().getBukkitSender(), (org.bukkit.GameRule<Integer>) org.bukkit.GameRule.getByName(gameRuleKey.toString()), String.valueOf(IntegerArgumentType.getInteger(context, name)));
|
|
+ if (!event.callEvent()) return;
|
|
+ this.value = Integer.parseInt(event.getValue());
|
|
+ // Paper end
|
|
}
|
|
|
|
public int get() {
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
index f192df45b1522d98f68c7c19301d783938c582e7..706a1c37c81828ab570a7012f96a421d6c9977c1 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
@@ -1787,8 +1787,13 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
|
|
if (!this.isGameRule(rule)) return false;
|
|
|
|
+ // Paper start
|
|
+ GameRule<?> gameRule = GameRule.getByName(rule);
|
|
+ io.papermc.paper.event.world.WorldGameRuleChangeEvent event = new io.papermc.paper.event.world.WorldGameRuleChangeEvent(this, null, gameRule, value);
|
|
+ if (!event.callEvent()) return false;
|
|
+ // Paper end
|
|
GameRules.Value<?> handle = this.getHandle().getGameRules().getRule(CraftWorld.getGameRulesNMS().get(rule));
|
|
- handle.deserialize(value);
|
|
+ handle.deserialize(event.getValue()); // Paper
|
|
handle.onChanged(this.getHandle().getServer());
|
|
return true;
|
|
}
|
|
@@ -1823,8 +1828,12 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
|
|
if (!this.isGameRule(rule.getName())) return false;
|
|
|
|
+ // Paper start
|
|
+ io.papermc.paper.event.world.WorldGameRuleChangeEvent event = new io.papermc.paper.event.world.WorldGameRuleChangeEvent(this, null, rule, String.valueOf(newValue));
|
|
+ if (!event.callEvent()) return false;
|
|
+ // Paper end
|
|
GameRules.Value<?> handle = this.getHandle().getGameRules().getRule(CraftWorld.getGameRulesNMS().get(rule.getName()));
|
|
- handle.deserialize(newValue.toString());
|
|
+ handle.deserialize(event.getValue()); // Paper
|
|
handle.onChanged(this.getHandle().getServer());
|
|
return true;
|
|
}
|