2021-06-14 20:50:22 +02:00
|
|
|
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
|
2024-01-19 22:13:42 +01:00
|
|
|
Subject: [PATCH] Add WorldGameRuleChangeEvent
|
2021-06-14 20:50:22 +02:00
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/commands/GameRuleCommand.java b/src/main/java/net/minecraft/server/commands/GameRuleCommand.java
|
2024-01-19 22:13:42 +01:00
|
|
|
index c8c358531dbc167e249bac2af246c5e34fbdd4df..10c1790226e25da3b9b599c9a40de57d5727ddc4 100644
|
2021-06-14 20:50:22 +02:00
|
|
|
--- 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");
|
2024-01-19 22:13:42 +01:00
|
|
|
+ t0.setFromArgument(context, "value", key); // Paper - Add WorldGameRuleChangeEvent
|
2023-06-08 01:56:33 +02:00
|
|
|
commandlistenerwrapper.sendSuccess(() -> {
|
|
|
|
return Component.translatable("commands.gamerule.set", key.getId(), t0.toString());
|
|
|
|
}, true);
|
2021-06-14 20:50:22 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/GameRules.java b/src/main/java/net/minecraft/world/level/GameRules.java
|
2024-04-24 15:46:45 +02:00
|
|
|
index 0b46ad360be919e4aeb0ffc0eebae9fe712fb861..51e560d7856f230c5aa2dc32706c3a4996720aa5 100644
|
2021-06-14 20:50:22 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/level/GameRules.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/GameRules.java
|
2024-04-24 15:46:45 +02:00
|
|
|
@@ -293,10 +293,10 @@ public class GameRules {
|
2021-06-14 20:50:22 +02:00
|
|
|
this.type = type;
|
|
|
|
}
|
|
|
|
|
|
|
|
- protected abstract void updateFromArgument(CommandContext<CommandSourceStack> context, String name);
|
2024-01-19 22:13:42 +01:00
|
|
|
+ protected abstract void updateFromArgument(CommandContext<CommandSourceStack> context, String name, GameRules.Key<T> gameRuleKey); // Paper - Add WorldGameRuleChangeEvent
|
2021-06-14 20:50:22 +02:00
|
|
|
|
|
|
|
- public void setFromArgument(CommandContext<CommandSourceStack> context, String name) {
|
|
|
|
- this.updateFromArgument(context, name);
|
2024-01-19 22:13:42 +01:00
|
|
|
+ public void setFromArgument(CommandContext<CommandSourceStack> context, String name, GameRules.Key<T> gameRuleKey) { // Paper - Add WorldGameRuleChangeEvent
|
|
|
|
+ this.updateFromArgument(context, name, gameRuleKey); // Paper - Add WorldGameRuleChangeEvent
|
Updated Upstream (Bukkit/CraftBukkit) (#10242)
* Updated Upstream (Bukkit/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
Bukkit Changes:
a6a9d2a4 Remove some old ApiStatus.Experimental annotations
be72314c SPIGOT-7300, PR-829: Add new DamageSource API providing enhanced information about entity damage
b252cf05 SPIGOT-7576, PR-970: Add methods in MushroomCow to change stew effects
b1c689bd PR-902: Add Server#isLoggingIPs to get log-ips configuration
08f86d1c PR-971: Add Player methods for client-side potion effects
2e3024a9 PR-963: Add API for in-world structures
a23292a7 SPIGOT-7530, PR-948: Improve Resource Pack API with new 1.20.3 functionality
1851857b SPIGOT-3071, PR-969: Add entity spawn method with spawn reason
cde4c52a SPIGOT-5553, PR-964: Add EntityKnockbackEvent
CraftBukkit Changes:
38fd4bd50 Fix accidentally renamed internal damage method
80f0ce4be SPIGOT-7300, PR-1180: Add new DamageSource API providing enhanced information about entity damage
7e43f3b16 SPIGOT-7581: Fix typo in BlockMushroom
ea14b7d90 SPIGOT-7576, PR-1347: Add methods in MushroomCow to change stew effects
4c687f243 PR-1259: Add Server#isLoggingIPs to get log-ips configuration
22a541a29 Improve support for per-world game rules
cb7dccce2 PR-1348: Add Player methods for client-side potion effects
b8d6109f0 PR-1335: Add API for in-world structures
4398a1b5b SPIGOT-7577: Make CraftWindCharge#explode discard the entity
e74107678 Fix Crafter maximum stack size
0bb0f4f6a SPIGOT-7530, PR-1314: Improve Resource Pack API with new 1.20.3 functionality
4949f556d SPIGOT-3071, PR-1345: Add entity spawn method with spawn reason
20ac73ca2 PR-1353: Fix Structure#place not working as documented with 0 palette
3c1b77871 SPIGOT-6911, PR-1349: Change max book length in CraftMetaBook
333701839 SPIGOT-7572: Bee nests generated without bees
f48f4174c SPIGOT-5553, PR-1336: Add EntityKnockbackEvent
2024-02-11 22:28:00 +01:00
|
|
|
this.onChanged(((CommandSourceStack) context.getSource()).getLevel()); // CraftBukkit - per-world
|
2021-06-14 20:50:22 +02:00
|
|
|
}
|
|
|
|
|
2024-04-24 15:46:45 +02:00
|
|
|
@@ -354,8 +354,11 @@ public class GameRules {
|
2021-06-14 20:50:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
- protected void updateFromArgument(CommandContext<CommandSourceStack> context, String name) {
|
|
|
|
- this.value = BoolArgumentType.getBool(context, name);
|
2024-01-19 22:13:42 +01:00
|
|
|
+ protected void updateFromArgument(CommandContext<CommandSourceStack> context, String name, GameRules.Key<BooleanValue> gameRuleKey) { // Paper start - Add WorldGameRuleChangeEvent
|
2021-06-14 20:50:22 +02:00
|
|
|
+ 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());
|
2024-01-19 22:13:42 +01:00
|
|
|
+ // Paper end - Add WorldGameRuleChangeEvent
|
2021-06-14 20:50:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean get() {
|
2024-04-24 15:46:45 +02:00
|
|
|
@@ -427,8 +430,11 @@ public class GameRules {
|
2021-06-14 20:50:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
- protected void updateFromArgument(CommandContext<CommandSourceStack> context, String name) {
|
|
|
|
- this.value = IntegerArgumentType.getInteger(context, name);
|
2024-01-19 22:13:42 +01:00
|
|
|
+ protected void updateFromArgument(CommandContext<CommandSourceStack> context, String name, GameRules.Key<IntegerValue> gameRuleKey) { // Paper start - Add WorldGameRuleChangeEvent
|
2021-06-14 20:50:22 +02:00
|
|
|
+ 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());
|
2024-01-19 22:13:42 +01:00
|
|
|
+ // Paper end - Add WorldGameRuleChangeEvent
|
2021-06-14 20:50:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public int get() {
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
2024-06-13 16:45:27 +02:00
|
|
|
index a493c8d12935336bb3049aa6d00eb1a4f2194c25..a78922dc4a1f0719753d7349fc6abd473fd96eed 100644
|
2021-06-14 20:50:22 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
2024-06-13 16:45:27 +02:00
|
|
|
@@ -1908,8 +1908,13 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
2021-06-14 20:50:22 +02:00
|
|
|
|
|
|
|
if (!this.isGameRule(rule)) return false;
|
|
|
|
|
2024-01-19 22:13:42 +01:00
|
|
|
+ // Paper start - Add WorldGameRuleChangeEvent
|
2021-06-14 20:50:22 +02:00
|
|
|
+ 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;
|
2024-01-19 22:13:42 +01:00
|
|
|
+ // Paper end - Add WorldGameRuleChangeEvent
|
2021-06-14 20:50:22 +02:00
|
|
|
GameRules.Value<?> handle = this.getHandle().getGameRules().getRule(CraftWorld.getGameRulesNMS().get(rule));
|
|
|
|
- handle.deserialize(value);
|
2024-01-19 22:13:42 +01:00
|
|
|
+ handle.deserialize(event.getValue()); // Paper - Add WorldGameRuleChangeEvent
|
Updated Upstream (Bukkit/CraftBukkit) (#10242)
* Updated Upstream (Bukkit/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
Bukkit Changes:
a6a9d2a4 Remove some old ApiStatus.Experimental annotations
be72314c SPIGOT-7300, PR-829: Add new DamageSource API providing enhanced information about entity damage
b252cf05 SPIGOT-7576, PR-970: Add methods in MushroomCow to change stew effects
b1c689bd PR-902: Add Server#isLoggingIPs to get log-ips configuration
08f86d1c PR-971: Add Player methods for client-side potion effects
2e3024a9 PR-963: Add API for in-world structures
a23292a7 SPIGOT-7530, PR-948: Improve Resource Pack API with new 1.20.3 functionality
1851857b SPIGOT-3071, PR-969: Add entity spawn method with spawn reason
cde4c52a SPIGOT-5553, PR-964: Add EntityKnockbackEvent
CraftBukkit Changes:
38fd4bd50 Fix accidentally renamed internal damage method
80f0ce4be SPIGOT-7300, PR-1180: Add new DamageSource API providing enhanced information about entity damage
7e43f3b16 SPIGOT-7581: Fix typo in BlockMushroom
ea14b7d90 SPIGOT-7576, PR-1347: Add methods in MushroomCow to change stew effects
4c687f243 PR-1259: Add Server#isLoggingIPs to get log-ips configuration
22a541a29 Improve support for per-world game rules
cb7dccce2 PR-1348: Add Player methods for client-side potion effects
b8d6109f0 PR-1335: Add API for in-world structures
4398a1b5b SPIGOT-7577: Make CraftWindCharge#explode discard the entity
e74107678 Fix Crafter maximum stack size
0bb0f4f6a SPIGOT-7530, PR-1314: Improve Resource Pack API with new 1.20.3 functionality
4949f556d SPIGOT-3071, PR-1345: Add entity spawn method with spawn reason
20ac73ca2 PR-1353: Fix Structure#place not working as documented with 0 palette
3c1b77871 SPIGOT-6911, PR-1349: Change max book length in CraftMetaBook
333701839 SPIGOT-7572: Bee nests generated without bees
f48f4174c SPIGOT-5553, PR-1336: Add EntityKnockbackEvent
2024-02-11 22:28:00 +01:00
|
|
|
handle.onChanged(this.getHandle());
|
2021-06-14 20:50:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
2024-06-13 16:45:27 +02:00
|
|
|
@@ -1945,8 +1950,12 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
2021-06-14 20:50:22 +02:00
|
|
|
|
|
|
|
if (!this.isGameRule(rule.getName())) return false;
|
|
|
|
|
2024-01-19 22:13:42 +01:00
|
|
|
+ // Paper start - Add WorldGameRuleChangeEvent
|
2021-06-14 20:50:22 +02:00
|
|
|
+ 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;
|
2024-01-19 22:13:42 +01:00
|
|
|
+ // Paper end - Add WorldGameRuleChangeEvent
|
2021-06-14 20:50:22 +02:00
|
|
|
GameRules.Value<?> handle = this.getHandle().getGameRules().getRule(CraftWorld.getGameRulesNMS().get(rule.getName()));
|
|
|
|
- handle.deserialize(newValue.toString());
|
2024-01-19 22:13:42 +01:00
|
|
|
+ handle.deserialize(event.getValue()); // Paper - Add WorldGameRuleChangeEvent
|
Updated Upstream (Bukkit/CraftBukkit) (#10242)
* Updated Upstream (Bukkit/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
Bukkit Changes:
a6a9d2a4 Remove some old ApiStatus.Experimental annotations
be72314c SPIGOT-7300, PR-829: Add new DamageSource API providing enhanced information about entity damage
b252cf05 SPIGOT-7576, PR-970: Add methods in MushroomCow to change stew effects
b1c689bd PR-902: Add Server#isLoggingIPs to get log-ips configuration
08f86d1c PR-971: Add Player methods for client-side potion effects
2e3024a9 PR-963: Add API for in-world structures
a23292a7 SPIGOT-7530, PR-948: Improve Resource Pack API with new 1.20.3 functionality
1851857b SPIGOT-3071, PR-969: Add entity spawn method with spawn reason
cde4c52a SPIGOT-5553, PR-964: Add EntityKnockbackEvent
CraftBukkit Changes:
38fd4bd50 Fix accidentally renamed internal damage method
80f0ce4be SPIGOT-7300, PR-1180: Add new DamageSource API providing enhanced information about entity damage
7e43f3b16 SPIGOT-7581: Fix typo in BlockMushroom
ea14b7d90 SPIGOT-7576, PR-1347: Add methods in MushroomCow to change stew effects
4c687f243 PR-1259: Add Server#isLoggingIPs to get log-ips configuration
22a541a29 Improve support for per-world game rules
cb7dccce2 PR-1348: Add Player methods for client-side potion effects
b8d6109f0 PR-1335: Add API for in-world structures
4398a1b5b SPIGOT-7577: Make CraftWindCharge#explode discard the entity
e74107678 Fix Crafter maximum stack size
0bb0f4f6a SPIGOT-7530, PR-1314: Improve Resource Pack API with new 1.20.3 functionality
4949f556d SPIGOT-3071, PR-1345: Add entity spawn method with spawn reason
20ac73ca2 PR-1353: Fix Structure#place not working as documented with 0 palette
3c1b77871 SPIGOT-6911, PR-1349: Change max book length in CraftMetaBook
333701839 SPIGOT-7572: Bee nests generated without bees
f48f4174c SPIGOT-5553, PR-1336: Add EntityKnockbackEvent
2024-02-11 22:28:00 +01:00
|
|
|
handle.onChanged(this.getHandle());
|
2021-06-14 20:50:22 +02:00
|
|
|
return true;
|
|
|
|
}
|