Skip to content

Commit 5602ba8

Browse files
committed
Merge remote-tracking branch 'origin/feature/thread-friendly-command' into feature/thread-friendly-command
2 parents ef2f258 + 9b89383 commit 5602ba8

File tree

25 files changed

+219
-73
lines changed

25 files changed

+219
-73
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ body:
2727
description: Which server version are you using? If your server version is not listed, it is not supported. Update to a supported version first.
2828
multiple: false
2929
options:
30+
- '1.21.3'
3031
- '1.21.1'
3132
- '1.20.6'
3233
- '1.20.4'

.github/renovate.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
33
"extends": [
4-
"config:base",
4+
"config:recommended",
55
":semanticCommitsDisabled"
66
],
77
"automerge": true,

.github/workflows/label-merge-conflicts.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616
steps:
1717
- name: Label conflicting PRs
18-
uses: eps1lon/actions-label-merge-conflict@v3.0.2
18+
uses: eps1lon/actions-label-merge-conflict@v3.0.3
1919
with:
2020
dirtyLabel: "unresolved-merge-conflict"
2121
repoToken: "${{ secrets.GITHUB_TOKEN }}"

Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,9 @@ public void setGenerator(final @NonNull String worldName) {
11711171
@Override
11721172
public @NonNull String serverNativePackage() {
11731173
final String name = Bukkit.getServer().getClass().getPackage().getName();
1174-
return name.substring(name.lastIndexOf('.') + 1);
1174+
String ver = name.substring(name.lastIndexOf('.') + 1);
1175+
// org.bukkit.craftbukkit is no longer suffixed by a version
1176+
return ver.equals("craftbukkit") ? "" : ver;
11751177
}
11761178

11771179
@Override

Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252

5353
import java.util.ArrayList;
5454
import java.util.Arrays;
55-
import java.util.EnumSet;
55+
import java.util.HashSet;
5656
import java.util.List;
5757
import java.util.Random;
5858
import java.util.Set;
@@ -445,7 +445,7 @@ private final class BukkitPlotBiomeProvider extends BiomeProvider {
445445
private static final List<Biome> BIOMES;
446446

447447
static {
448-
Set<Biome> disabledBiomes = EnumSet.of(Biome.CUSTOM);
448+
Set<Biome> disabledBiomes = new HashSet<>(List.of(Biome.CUSTOM));
449449
if (PlotSquared.platform().serverVersion()[1] <= 19) {
450450
final Biome cherryGrove = Registry.BIOME.get(NamespacedKey.minecraft("cherry_grove"));
451451
if (cherryGrove != null) {

Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntityEventListener.java

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import com.plotsquared.core.plot.flag.implementations.ExplosionFlag;
3838
import com.plotsquared.core.plot.flag.implementations.InvincibleFlag;
3939
import com.plotsquared.core.plot.flag.implementations.ProjectileChangeBlockFlag;
40+
import com.plotsquared.core.plot.flag.implementations.WeavingDeathPlace;
4041
import com.plotsquared.core.plot.world.PlotAreaManager;
4142
import com.plotsquared.core.util.EventDispatcher;
4243
import com.plotsquared.core.util.PlotFlagUtil;
@@ -243,6 +244,29 @@ public void onEntityFall(EntityChangeBlockEvent event) {
243244
}
244245
}
245246

247+
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
248+
public void onWeavingEffect(EntityChangeBlockEvent event) {
249+
if (event.getTo() != Material.COBWEB) {
250+
return;
251+
}
252+
Location location = BukkitUtil.adapt(event.getBlock().getLocation());
253+
PlotArea area = location.getPlotArea();
254+
if (area == null) {
255+
return;
256+
}
257+
Plot plot = location.getOwnedPlot();
258+
if (plot == null) {
259+
if (PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, WeavingDeathPlace.class, false)) {
260+
event.setCancelled(true);
261+
}
262+
return;
263+
}
264+
if (!plot.getFlag(WeavingDeathPlace.class)) {
265+
plot.debug(event.getTo() + " could not spawn because weaving-death-place = false");
266+
event.setCancelled(true);
267+
}
268+
}
269+
246270
@EventHandler(priority = EventPriority.HIGH)
247271
public void onDamage(EntityDamageEvent event) {
248272
if (event.getEntityType() != EntityType.PLAYER) {
@@ -401,7 +425,13 @@ public void onPeskyMobsChangeTheWorldLikeWTFEvent(EntityChangeBlockEvent event)
401425
}
402426

403427
Plot plot = area.getOwnedPlot(location);
404-
if (plot != null && !plot.getFlag(EntityChangeBlockFlag.class)) {
428+
if (plot == null) {
429+
if (PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, EntityChangeBlockFlag.class, false)) {
430+
event.setCancelled(true);
431+
}
432+
return;
433+
}
434+
if (!plot.getFlag(EntityChangeBlockFlag.class)) {
405435
plot.debug(e.getType() + " could not change block because entity-change-block = false");
406436
event.setCancelled(true);
407437
}

Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java

Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import com.plotsquared.core.plot.flag.types.BooleanFlag;
4848
import com.plotsquared.core.plot.world.PlotAreaManager;
4949
import com.plotsquared.core.util.PlotFlagUtil;
50+
import io.papermc.paper.event.entity.EntityMoveEvent;
5051
import net.kyori.adventure.text.Component;
5152
import net.kyori.adventure.text.minimessage.tag.Tag;
5253
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
@@ -58,6 +59,7 @@
5859
import org.bukkit.entity.Player;
5960
import org.bukkit.entity.Projectile;
6061
import org.bukkit.entity.Slime;
62+
import org.bukkit.event.Cancellable;
6163
import org.bukkit.event.EventHandler;
6264
import org.bukkit.event.EventPriority;
6365
import org.bukkit.event.Listener;
@@ -104,33 +106,7 @@ public void onEntityPathfind(EntityPathfindEvent event) {
104106
if (!Settings.Paper_Components.ENTITY_PATHING) {
105107
return;
106108
}
107-
Location toLoc = BukkitUtil.adapt(event.getLoc());
108-
Location fromLoc = BukkitUtil.adapt(event.getEntity().getLocation());
109-
PlotArea tarea = toLoc.getPlotArea();
110-
if (tarea == null) {
111-
return;
112-
}
113-
PlotArea farea = fromLoc.getPlotArea();
114-
if (farea == null) {
115-
return;
116-
}
117-
if (tarea != farea) {
118-
event.setCancelled(true);
119-
return;
120-
}
121-
Plot tplot = toLoc.getPlot();
122-
Plot fplot = fromLoc.getPlot();
123-
if (tplot == null ^ fplot == null) {
124-
event.setCancelled(true);
125-
return;
126-
}
127-
if (tplot == null || tplot.getId().hashCode() == fplot.getId().hashCode()) {
128-
return;
129-
}
130-
if (fplot.isMerged() && fplot.getConnectedPlots().contains(fplot)) {
131-
return;
132-
}
133-
event.setCancelled(true);
109+
handleEntityMovement(event, event.getEntity().getLocation(), event.getLoc());
134110
}
135111

136112
@EventHandler
@@ -145,8 +121,23 @@ public void onEntityPathfind(SlimePathfindEvent event) {
145121
return;
146122
}
147123

148-
Location toLoc = BukkitUtil.adapt(b.getLocation());
149-
Location fromLoc = BukkitUtil.adapt(event.getEntity().getLocation());
124+
handleEntityMovement(event, event.getEntity().getLocation(), b.getLocation());
125+
}
126+
127+
@EventHandler
128+
public void onEntityMove(EntityMoveEvent event) {
129+
if (!Settings.Paper_Components.ENTITY_MOVEMENT) {
130+
return;
131+
}
132+
if (!event.hasExplicitlyChangedBlock()) {
133+
return;
134+
}
135+
handleEntityMovement(event, event.getFrom(), event.getTo());
136+
}
137+
138+
private static void handleEntityMovement(Cancellable event, org.bukkit.Location from, org.bukkit.Location target) {
139+
Location toLoc = BukkitUtil.adapt(target);
140+
Location fromLoc = BukkitUtil.adapt(from);
150141
PlotArea tarea = toLoc.getPlotArea();
151142
if (tarea == null) {
152143
return;
@@ -155,7 +146,6 @@ public void onEntityPathfind(SlimePathfindEvent event) {
155146
if (farea == null) {
156147
return;
157148
}
158-
159149
if (tarea != farea) {
160150
event.setCancelled(true);
161151
return;
@@ -166,10 +156,10 @@ public void onEntityPathfind(SlimePathfindEvent event) {
166156
event.setCancelled(true);
167157
return;
168158
}
169-
if (tplot == null || tplot.getId().hashCode() == fplot.getId().hashCode()) {
159+
if (tplot == null || tplot.getId().equals(fplot.getId())) {
170160
return;
171161
}
172-
if (fplot.isMerged() && fplot.getConnectedPlots().contains(fplot)) {
162+
if (fplot.isMerged() && fplot.getConnectedPlots().contains(tplot)) {
173163
return;
174164
}
175165
event.setCancelled(true);

Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import com.plotsquared.core.plot.flag.implementations.HangingBreakFlag;
5555
import com.plotsquared.core.plot.flag.implementations.HangingPlaceFlag;
5656
import com.plotsquared.core.plot.flag.implementations.HostileInteractFlag;
57+
import com.plotsquared.core.plot.flag.implementations.InteractionInteractFlag;
5758
import com.plotsquared.core.plot.flag.implementations.ItemDropFlag;
5859
import com.plotsquared.core.plot.flag.implementations.KeepInventoryFlag;
5960
import com.plotsquared.core.plot.flag.implementations.LecternReadBookFlag;
@@ -1737,6 +1738,11 @@ public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
17371738
return;
17381739
}
17391740

1741+
if (EntityCategories.INTERACTION.contains(entityType) && flagContainer
1742+
.getFlag(InteractionInteractFlag.class).getValue()) {
1743+
return;
1744+
}
1745+
17401746
if (EntityCategories.VILLAGER.contains(entityType) && flagContainer
17411747
.getFlag(VillagerInteractFlag.class).getValue()) {
17421748
return;

Bukkit/src/main/java/com/plotsquared/bukkit/listener/SingleWorldListener.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,14 @@ public SingleWorldListener() throws Exception {
4949
this.methodGetHandleChunk = classCraftChunk.getMethod("getHandle").getRealMethod();
5050
} catch (NoSuchMethodException ignored) {
5151
try {
52-
ReflectionUtils.RefClass classChunkStatus = getRefClass("net.minecraft.world.level.chunk.ChunkStatus");
52+
String chunkStatus = PlotSquared.platform().serverVersion()[1] < 21
53+
? "net.minecraft.world.level.chunk" + ".ChunkStatus"
54+
: "net.minecraft.world.level.chunk.status.ChunkStatus";
55+
ReflectionUtils.RefClass classChunkStatus = getRefClass(chunkStatus);
5356
this.objChunkStatusFull = classChunkStatus.getRealClass().getField("n").get(null);
54-
this.methodGetHandleChunk = classCraftChunk.getMethod("getHandle", classChunkStatus.getRealClass()).getRealMethod();
57+
this.methodGetHandleChunk = classCraftChunk
58+
.getMethod("getHandle", classChunkStatus.getRealClass())
59+
.getRealMethod();
5560
} catch (NoSuchMethodException ex) {
5661
throw new RuntimeException(ex);
5762
}

Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitQueueCoordinator.java

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,28 @@ public class BukkitQueueCoordinator extends BasicQueueCoordinator {
6262
private static final SideEffectSet EDGE_LIGHTING_SIDE_EFFECT_SET;
6363

6464
static {
65-
NO_SIDE_EFFECT_SET = SideEffectSet.none().with(SideEffect.LIGHTING, SideEffect.State.OFF).with(
66-
SideEffect.NEIGHBORS,
67-
SideEffect.State.OFF
68-
);
69-
EDGE_SIDE_EFFECT_SET = SideEffectSet.none().with(SideEffect.UPDATE, SideEffect.State.ON).with(
70-
SideEffect.NEIGHBORS,
71-
SideEffect.State.ON
72-
);
73-
LIGHTING_SIDE_EFFECT_SET = SideEffectSet.none().with(SideEffect.NEIGHBORS, SideEffect.State.OFF);
74-
EDGE_LIGHTING_SIDE_EFFECT_SET = SideEffectSet.none().with(SideEffect.UPDATE, SideEffect.State.ON).with(
75-
SideEffect.NEIGHBORS,
76-
SideEffect.State.ON
77-
);
65+
NO_SIDE_EFFECT_SET = enableNetworkIfNeeded()
66+
.with(SideEffect.LIGHTING, SideEffect.State.OFF)
67+
.with(SideEffect.NEIGHBORS, SideEffect.State.OFF);
68+
EDGE_SIDE_EFFECT_SET = NO_SIDE_EFFECT_SET
69+
.with(SideEffect.UPDATE, SideEffect.State.ON)
70+
.with(SideEffect.NEIGHBORS, SideEffect.State.ON);
71+
LIGHTING_SIDE_EFFECT_SET = NO_SIDE_EFFECT_SET
72+
.with(SideEffect.NEIGHBORS, SideEffect.State.OFF);
73+
EDGE_LIGHTING_SIDE_EFFECT_SET = NO_SIDE_EFFECT_SET
74+
.with(SideEffect.UPDATE, SideEffect.State.ON)
75+
.with(SideEffect.NEIGHBORS, SideEffect.State.ON);
76+
}
77+
78+
// make sure block changes are sent
79+
private static SideEffectSet enableNetworkIfNeeded() {
80+
SideEffect network;
81+
try {
82+
network = SideEffect.valueOf("NETWORK");
83+
} catch (IllegalArgumentException ignored) {
84+
return SideEffectSet.none();
85+
}
86+
return SideEffectSet.none().with(network, SideEffect.State.ON);
7887
}
7988

8089
private org.bukkit.World bukkitWorld;

0 commit comments

Comments
 (0)