mirror of
https://github.com/PaperMC/Paper.git
synced 2024-09-12 06:58:11 +02:00
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: 05ae036c PR-746: Add option to use cached map color palette 57849c1b PR-759: Add preview chat option in ServerListPingEvent 0169e65d PR-758: Add missing server properties methods from 1.19 CraftBukkit Changes: 622dbe6c2 SPIGOT-7068: SKULK and SKULK_VEIN BlockSpreadEvents Still do not reference the correct source (SKULK_CATALYST) 6c61b73f3 PR-1052: Add option to use cached map color palette c882f38ea SPIGOT-7066: Fix custom END worlds not generating DragonBattle 6866aab59 SPIGOT-2420: Can't set exp drops for EnderDragon death 9dcd46530 PR-1067: Add preview chat option in ServerListPingEvent 36c2681af PR-1066: Add missing server properties methods from 1.19 031eaadd0 Increase outdated build delay 8fda4b12f SPIGOT-7060: SCULK and SCULK_VEIN BlockSpreadEvents do not reference the correct source
81 lines
4.2 KiB
Diff
81 lines
4.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
|
Date: Sun, 3 Jan 2021 20:03:35 -0800
|
|
Subject: [PATCH] Add GameEvent tags
|
|
|
|
|
|
diff --git a/src/main/java/io/papermc/paper/CraftGameEventTag.java b/src/main/java/io/papermc/paper/CraftGameEventTag.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..cb78a3d4e21376ea24347187478525d5f0c24079
|
|
--- /dev/null
|
|
+++ b/src/main/java/io/papermc/paper/CraftGameEventTag.java
|
|
@@ -0,0 +1,34 @@
|
|
+package io.papermc.paper;
|
|
+
|
|
+import net.minecraft.core.Registry;
|
|
+import net.minecraft.resources.ResourceKey;
|
|
+import net.minecraft.tags.TagKey;
|
|
+import org.bukkit.GameEvent;
|
|
+import org.bukkit.craftbukkit.tag.CraftTag;
|
|
+import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
|
+import org.jetbrains.annotations.NotNull;
|
|
+
|
|
+import java.util.Collections;
|
|
+import java.util.IdentityHashMap;
|
|
+import java.util.Map;
|
|
+import java.util.Objects;
|
|
+import java.util.Set;
|
|
+import java.util.stream.Collectors;
|
|
+
|
|
+public class CraftGameEventTag extends CraftTag<net.minecraft.world.level.gameevent.GameEvent, GameEvent> {
|
|
+
|
|
+ public CraftGameEventTag(net.minecraft.core.Registry<net.minecraft.world.level.gameevent.GameEvent> registry, TagKey<net.minecraft.world.level.gameevent.GameEvent> tag) {
|
|
+ super(registry, tag);
|
|
+ }
|
|
+
|
|
+ private static final Map<GameEvent, ResourceKey<net.minecraft.world.level.gameevent.GameEvent>> KEY_CACHE = Collections.synchronizedMap(new IdentityHashMap<>());
|
|
+ @Override
|
|
+ public boolean isTagged(@NotNull GameEvent gameEvent) {
|
|
+ return registry.getHolderOrThrow(KEY_CACHE.computeIfAbsent(gameEvent, event -> ResourceKey.create(Registry.GAME_EVENT_REGISTRY, CraftNamespacedKey.toMinecraft(event.getKey())))).is(tag);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public @NotNull Set<GameEvent> getValues() {
|
|
+ return getHandle().stream().map((nms) -> Objects.requireNonNull(GameEvent.getByKey(CraftNamespacedKey.fromMinecraft(Registry.GAME_EVENT.getKey(nms.value()))), nms + " is not a recognized game event")).collect(Collectors.toUnmodifiableSet());
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
index 50d617133ef73713ce5329e826c8a97e1d89a023..14c06e1643878b5307c7177f0c05bd5e7b31f0af 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
@@ -2566,6 +2566,15 @@ public final class CraftServer implements Server {
|
|
return (org.bukkit.Tag<T>) new CraftEntityTag(Registry.ENTITY_TYPE, entityTagKey);
|
|
}
|
|
}
|
|
+ // Paper start
|
|
+ case org.bukkit.Tag.REGISTRY_GAME_EVENTS -> {
|
|
+ Preconditions.checkArgument(clazz == org.bukkit.GameEvent.class, "Game Event namespace must have GameEvent type");
|
|
+ TagKey<net.minecraft.world.level.gameevent.GameEvent> gameEventTagKey = TagKey.create(Registry.GAME_EVENT_REGISTRY, key);
|
|
+ if (Registry.GAME_EVENT.isKnownTagName(gameEventTagKey)) {
|
|
+ return (org.bukkit.Tag<T>) new io.papermc.paper.CraftGameEventTag(Registry.GAME_EVENT, gameEventTagKey);
|
|
+ }
|
|
+ }
|
|
+ // Paper end
|
|
default -> throw new IllegalArgumentException();
|
|
}
|
|
|
|
@@ -2598,6 +2607,13 @@ public final class CraftServer implements Server {
|
|
Registry<EntityType<?>> entityTags = Registry.ENTITY_TYPE;
|
|
return entityTags.getTags().map(pair -> (org.bukkit.Tag<T>) new CraftEntityTag(entityTags, pair.getFirst())).collect(ImmutableList.toImmutableList());
|
|
}
|
|
+ // Paper start
|
|
+ case org.bukkit.Tag.REGISTRY_GAME_EVENTS -> {
|
|
+ Preconditions.checkArgument(clazz == org.bukkit.GameEvent.class);
|
|
+ Registry<net.minecraft.world.level.gameevent.GameEvent> gameEvents = Registry.GAME_EVENT;
|
|
+ return gameEvents.getTags().map(pair -> (org.bukkit.Tag<T>) new io.papermc.paper.CraftGameEventTag(gameEvents, pair.getFirst())).collect(ImmutableList.toImmutableList());
|
|
+ // Paper end
|
|
+ }
|
|
default -> throw new IllegalArgumentException();
|
|
}
|
|
}
|