mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-23 11:06:29 +01:00
ef0e5a642d
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: 9ae3f10f SPIGOT-3842: Add Player#fireworkBoost() and expand Firework API 48c0c547 PR-786: Add methods to get sounds from entities CraftBukkit Changes: 5cc9c022a SPIGOT-7152: Handle hand item changing during air interact event 4ffa1acf6 SPIGOT-7154: Players get kicked when interacting with a conversation 4daa21123 SPIGOT-3842: Add Player#fireworkBoost() and expand Firework API e5d6a9bbf PR-1100: Add methods to get sounds from entities b7e9f1c8b SPIGOT-7146: Reduce use of Material switch in ItemMeta Spigot Changes: 4c157bb4 Rebuild patches
182 lines
12 KiB
Diff
182 lines
12 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
|
|
Date: Sun, 27 Mar 2022 13:51:09 -0400
|
|
Subject: [PATCH] Pass ServerLevel for gamerule callbacks
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
index 20670bc075c387ee0422eb1014207e26105efccd..bdd6560fe85950b0a857a949cb38c044da44ca6b 100644
|
|
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
@@ -309,7 +309,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
|
|
|
//DedicatedServer.LOGGER.info("Done ({})! For help, type \"help\"", s); // Paper moved to after init
|
|
if (dedicatedserverproperties.announcePlayerAchievements != null) {
|
|
- ((GameRules.BooleanValue) this.getGameRules().getRule(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)).set(dedicatedserverproperties.announcePlayerAchievements, this);
|
|
+ ((GameRules.BooleanValue) this.getGameRules().getRule(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)).set(dedicatedserverproperties.announcePlayerAchievements, null); // Paper
|
|
}
|
|
|
|
if (dedicatedserverproperties.enableQuery) {
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
index cea81ea8afa1cedc2be997357db2a920a9e3499b..15694736c7ee8836355409e0046e221ebdb7e524 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
@@ -3007,7 +3007,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
|
this.player = this.server.getPlayerList().respawn(this.player, false);
|
|
if (this.server.isHardcore()) {
|
|
this.player.setGameMode(GameType.SPECTATOR, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.HARDCORE_DEATH, null); // Paper
|
|
- ((GameRules.BooleanValue) this.player.getLevel().getGameRules().getRule(GameRules.RULE_SPECTATORSGENERATECHUNKS)).set(false, this.server);
|
|
+ ((GameRules.BooleanValue) this.player.getLevel().getGameRules().getRule(GameRules.RULE_SPECTATORSGENERATECHUNKS)).set(false, this.player.getLevel()); // Paper
|
|
}
|
|
}
|
|
break;
|
|
diff --git a/src/main/java/net/minecraft/world/level/GameRules.java b/src/main/java/net/minecraft/world/level/GameRules.java
|
|
index 3c93bfeb94168f832904a8462ae23b06e81e080d..468c635d31cfa8051666bbefce8df4b448e9ed93 100644
|
|
--- a/src/main/java/net/minecraft/world/level/GameRules.java
|
|
+++ b/src/main/java/net/minecraft/world/level/GameRules.java
|
|
@@ -51,7 +51,7 @@ public class GameRules {
|
|
public static final GameRules.Key<GameRules.BooleanValue> RULE_SENDCOMMANDFEEDBACK = GameRules.register("sendCommandFeedback", GameRules.Category.CHAT, GameRules.BooleanValue.create(true));
|
|
public static final GameRules.Key<GameRules.BooleanValue> RULE_REDUCEDDEBUGINFO = GameRules.register("reducedDebugInfo", GameRules.Category.MISC, GameRules.BooleanValue.create(false, (minecraftserver, gamerules_gameruleboolean) -> {
|
|
int i = gamerules_gameruleboolean.get() ? 22 : 23;
|
|
- Iterator iterator = minecraftserver.getPlayerList().getPlayers().iterator();
|
|
+ Iterator iterator = minecraftserver.players().iterator(); // Paper
|
|
|
|
while (iterator.hasNext()) {
|
|
ServerPlayer entityplayer = (ServerPlayer) iterator.next();
|
|
@@ -71,7 +71,7 @@ public class GameRules {
|
|
public static final GameRules.Key<GameRules.BooleanValue> RULE_DISABLE_RAIDS = GameRules.register("disableRaids", GameRules.Category.MOBS, GameRules.BooleanValue.create(false));
|
|
public static final GameRules.Key<GameRules.BooleanValue> RULE_DOINSOMNIA = GameRules.register("doInsomnia", GameRules.Category.SPAWNING, GameRules.BooleanValue.create(true));
|
|
public static final GameRules.Key<GameRules.BooleanValue> RULE_DO_IMMEDIATE_RESPAWN = GameRules.register("doImmediateRespawn", GameRules.Category.PLAYER, GameRules.BooleanValue.create(false, (minecraftserver, gamerules_gameruleboolean) -> {
|
|
- Iterator iterator = minecraftserver.getPlayerList().getPlayers().iterator();
|
|
+ Iterator iterator = minecraftserver.players().iterator(); // Paper
|
|
|
|
while (iterator.hasNext()) {
|
|
ServerPlayer entityplayer = (ServerPlayer) iterator.next();
|
|
@@ -157,13 +157,13 @@ public class GameRules {
|
|
((GameRules.Type<T>) type).callVisitor(consumer, (GameRules.Key<T>) key); // CraftBukkit - decompile error
|
|
}
|
|
|
|
- public void assignFrom(GameRules rules, @Nullable MinecraftServer server) {
|
|
+ public void assignFrom(GameRules rules, @Nullable net.minecraft.server.level.ServerLevel server) { // Paper
|
|
rules.rules.keySet().forEach((gamerules_gamerulekey) -> {
|
|
this.assignCap(gamerules_gamerulekey, rules, server);
|
|
});
|
|
}
|
|
|
|
- private <T extends GameRules.Value<T>> void assignCap(GameRules.Key<T> key, GameRules rules, @Nullable MinecraftServer server) {
|
|
+ private <T extends GameRules.Value<T>> void assignCap(GameRules.Key<T> key, GameRules rules, @Nullable net.minecraft.server.level.ServerLevel server) { // Paper
|
|
T t0 = rules.getRule(key);
|
|
|
|
this.getRule(key).setFrom(t0, server);
|
|
@@ -231,10 +231,10 @@ public class GameRules {
|
|
|
|
private final Supplier<ArgumentType<?>> argument;
|
|
private final Function<GameRules.Type<T>, T> constructor;
|
|
- final BiConsumer<MinecraftServer, T> callback;
|
|
+ final BiConsumer<net.minecraft.server.level.ServerLevel, T> callback; // Paper
|
|
private final GameRules.VisitorCaller<T> visitorCaller;
|
|
|
|
- Type(Supplier<ArgumentType<?>> argumentType, Function<GameRules.Type<T>, T> ruleFactory, BiConsumer<MinecraftServer, T> changeCallback, GameRules.VisitorCaller<T> ruleAcceptor) {
|
|
+ Type(Supplier<ArgumentType<?>> argumentType, Function<GameRules.Type<T>, T> ruleFactory, BiConsumer<net.minecraft.server.level.ServerLevel, T> changeCallback, GameRules.VisitorCaller<T> ruleAcceptor) { // Paper
|
|
this.argument = argumentType;
|
|
this.constructor = ruleFactory;
|
|
this.callback = changeCallback;
|
|
@@ -266,10 +266,10 @@ public class GameRules {
|
|
|
|
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());
|
|
+ this.onChanged(((CommandSourceStack) context.getSource()).getLevel()); // Paper
|
|
}
|
|
|
|
- public void onChanged(@Nullable MinecraftServer server) {
|
|
+ public void onChanged(@Nullable net.minecraft.server.level.ServerLevel server) { // Paper
|
|
if (server != null) {
|
|
this.type.callback.accept(server, this.getSelf());
|
|
}
|
|
@@ -290,7 +290,7 @@ public class GameRules {
|
|
|
|
protected abstract T copy();
|
|
|
|
- public abstract void setFrom(T rule, @Nullable MinecraftServer server);
|
|
+ public abstract void setFrom(T rule, @Nullable net.minecraft.server.level.ServerLevel level); // Paper
|
|
}
|
|
|
|
public interface GameRuleTypeVisitor {
|
|
@@ -306,7 +306,7 @@ public class GameRules {
|
|
|
|
private boolean value;
|
|
|
|
- static GameRules.Type<GameRules.BooleanValue> create(boolean initialValue, BiConsumer<MinecraftServer, GameRules.BooleanValue> changeCallback) {
|
|
+ static GameRules.Type<GameRules.BooleanValue> create(boolean initialValue, BiConsumer<net.minecraft.server.level.ServerLevel, GameRules.BooleanValue> changeCallback) { // Paper
|
|
return new GameRules.Type<>(BoolArgumentType::bool, (gamerules_gameruledefinition) -> {
|
|
return new GameRules.BooleanValue(gamerules_gameruledefinition, initialValue);
|
|
}, changeCallback, GameRules.GameRuleTypeVisitor::visitBoolean);
|
|
@@ -334,7 +334,7 @@ public class GameRules {
|
|
return this.value;
|
|
}
|
|
|
|
- public void set(boolean value, @Nullable MinecraftServer server) {
|
|
+ public void set(boolean value, @Nullable net.minecraft.server.level.ServerLevel server) { // Paper
|
|
this.value = value;
|
|
this.onChanged(server);
|
|
}
|
|
@@ -364,7 +364,7 @@ public class GameRules {
|
|
return new GameRules.BooleanValue(this.type, this.value);
|
|
}
|
|
|
|
- public void setFrom(GameRules.BooleanValue rule, @Nullable MinecraftServer server) {
|
|
+ public void setFrom(GameRules.BooleanValue rule, @Nullable net.minecraft.server.level.ServerLevel server) { // Paper
|
|
this.value = rule.value;
|
|
this.onChanged(server);
|
|
}
|
|
@@ -374,7 +374,7 @@ public class GameRules {
|
|
|
|
private int value;
|
|
|
|
- private static GameRules.Type<GameRules.IntegerValue> create(int initialValue, BiConsumer<MinecraftServer, GameRules.IntegerValue> changeCallback) {
|
|
+ private static GameRules.Type<GameRules.IntegerValue> create(int initialValue, BiConsumer<net.minecraft.server.level.ServerLevel, GameRules.IntegerValue> changeCallback) { // Paper
|
|
return new GameRules.Type<>(IntegerArgumentType::integer, (gamerules_gameruledefinition) -> {
|
|
return new GameRules.IntegerValue(gamerules_gameruledefinition, initialValue);
|
|
}, changeCallback, GameRules.GameRuleTypeVisitor::visitInteger);
|
|
@@ -402,7 +402,7 @@ public class GameRules {
|
|
return this.value;
|
|
}
|
|
|
|
- public void set(int value, @Nullable MinecraftServer server) {
|
|
+ public void set(int value, @Nullable net.minecraft.server.level.ServerLevel server) { // Paper
|
|
this.value = value;
|
|
this.onChanged(server);
|
|
}
|
|
@@ -453,7 +453,7 @@ public class GameRules {
|
|
return new GameRules.IntegerValue(this.type, this.value);
|
|
}
|
|
|
|
- public void setFrom(GameRules.IntegerValue rule, @Nullable MinecraftServer server) {
|
|
+ public void setFrom(GameRules.IntegerValue rule, @Nullable net.minecraft.server.level.ServerLevel server) { // Paper
|
|
this.value = rule.value;
|
|
this.onChanged(server);
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
index 23c68b6cd26fbd05685ebcfbb5e81db4c8dedb29..9d27b093922f3dee9b459f8a9cdfa96f12f2e654 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
@@ -1912,7 +1912,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
// Paper end
|
|
GameRules.Value<?> handle = this.getHandle().getGameRules().getRule(CraftWorld.getGameRulesNMS().get(rule));
|
|
handle.deserialize(event.getValue()); // Paper
|
|
- handle.onChanged(this.getHandle().getServer());
|
|
+ handle.onChanged(this.getHandle()); // Paper
|
|
return true;
|
|
}
|
|
|
|
@@ -1952,7 +1952,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
// Paper end
|
|
GameRules.Value<?> handle = this.getHandle().getGameRules().getRule(CraftWorld.getGameRulesNMS().get(rule.getName()));
|
|
handle.deserialize(event.getValue()); // Paper
|
|
- handle.onChanged(this.getHandle().getServer());
|
|
+ handle.onChanged(this.getHandle()); // Paper
|
|
return true;
|
|
}
|
|
|