Skip to content

Commit 79c574e

Browse files
committed
Implement triggers for the new ScoreboardTagsChangeEvent
1 parent c3e62c8 commit 79c574e

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: tmpod <[email protected]>
3+
Date: Fri, 19 Sep 2025 17:36:10 +0100
4+
Subject: [PATCH] Implement calling ScoreboardTagsChangeEvent
5+
6+
This is a new event added in commit c3e62c81 of Paper's API.
7+
8+
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
9+
index 9a102b2c58446bd0aac5bd7f00e647f0270e7983..670e964d78b899f9a3ce2154106a03ac49884ab3 100644
10+
--- a/net/minecraft/world/entity/Entity.java
11+
+++ b/net/minecraft/world/entity/Entity.java
12+
@@ -2,7 +2,6 @@ package net.minecraft.world.entity;
13+
14+
import com.google.common.collect.ImmutableList;
15+
import com.google.common.collect.Lists;
16+
-import com.google.common.collect.Sets;
17+
import com.google.common.collect.ImmutableList.Builder;
18+
import com.mojang.logging.LogUtils;
19+
import com.mojang.serialization.Codec;
20+
@@ -627,11 +626,23 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
21+
}
22+
23+
public boolean addTag(String tag) {
24+
- return this.tags.add(tag); // Paper - fully limit tag size - replace set impl
25+
+ // Paper start - add ScoreboardTagsChangeEvent
26+
+ final var event = org.bukkit.craftbukkit.event.CraftEventFactory.callScoreboardTagsChangeEvent(this, tag, io.papermc.paper.event.entity.ScoreboardTagsChangeEvent.Change.ADD);
27+
+ if (!event.isCancelled()) {
28+
+ return this.tags.add(tag); // Paper - fully limit tag size - replace set impl
29+
+ }
30+
+ return false;
31+
+ // Paper end - add ScoreboardTagsChangeEvent
32+
}
33+
34+
public boolean removeTag(String tag) {
35+
- return this.tags.remove(tag);
36+
+ // Paper start - add ScoreboardTagsChangeEvent
37+
+ final var event = org.bukkit.craftbukkit.event.CraftEventFactory.callScoreboardTagsChangeEvent(this, tag, io.papermc.paper.event.entity.ScoreboardTagsChangeEvent.Change.REMOVE);
38+
+ if (!event.isCancelled()) {
39+
+ return this.tags.remove(tag);
40+
+ }
41+
+ return false;
42+
+ // Paper end - add ScoreboardTagsChangeEvent
43+
}
44+
45+
public void kill(ServerLevel level) {
46+
@@ -2644,7 +2655,13 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
47+
// Paper end
48+
this.customData = input.read("data", CustomData.CODEC).orElse(CustomData.EMPTY);
49+
this.tags.clear();
50+
- input.read("Tags", TAG_LIST_CODEC).ifPresent(this.tags::addAll);
51+
+ // Paper start - add ScoreboardTagsChangeEvent
52+
+ input.read("Tags", TAG_LIST_CODEC).ifPresent( tags -> {
53+
+ final var event = org.bukkit.craftbukkit.event.CraftEventFactory.callScoreboardTagsChangeEvent(this, tags, io.papermc.paper.event.entity.ScoreboardTagsChangeEvent.Change.SET);
54+
+ if (!event.isCancelled())
55+
+ this.tags.addAll(tags);
56+
+ });
57+
+ // Paper end - add ScoreboardTagsChangeEvent
58+
this.readAdditionalSaveData(input);
59+
if (this.repositionEntityAfterLoad()) {
60+
this.reapplyPosition();

0 commit comments

Comments
 (0)