mirror of
				https://github.com/IntellectualSites/PlotSquared.git
				synced 2025-10-25 07:33:44 +02:00 
			
		
		
		
	Compare commits
	
		
			29 Commits
		
	
	
		
			7.3.8
			...
			fix/v7/cor
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | 666db41469 | ||
| ![renovate[bot]](/assets/img/avatar_default.png)  | 7f59c03f06 | ||
| ![renovate[bot]](/assets/img/avatar_default.png)  | 480a5925b6 | ||
| ![renovate[bot]](/assets/img/avatar_default.png)  | cee4493723 | ||
| ![renovate[bot]](/assets/img/avatar_default.png)  | b8ac1a22c1 | ||
|   | 67e69e3fc1 | ||
|   | 670f5a802e | ||
| ![renovate[bot]](/assets/img/avatar_default.png)  | c4bd6b6500 | ||
| ![renovate[bot]](/assets/img/avatar_default.png)  | 161e3ffdc7 | ||
|   | be8f07c556 | ||
|   | 215053e364 | ||
| ![renovate[bot]](/assets/img/avatar_default.png)  | 4839a83279 | ||
| ![renovate[bot]](/assets/img/avatar_default.png)  | 0649ef33f0 | ||
| ![renovate[bot]](/assets/img/avatar_default.png)  | 1590a4b6eb | ||
|   | c793b4454a | ||
| ![renovate[bot]](/assets/img/avatar_default.png)  | 7ab1a3eafb | ||
|   | c65c9e7827 | ||
|   | f88ea94bfe | ||
| ![renovate[bot]](/assets/img/avatar_default.png)  | c8e8eb919f | ||
|   | 83fe761fe4 | ||
|   | a7447c9d75 | ||
| ![renovate[bot]](/assets/img/avatar_default.png)  | 5867cc51a7 | ||
| ![renovate[bot]](/assets/img/avatar_default.png)  | 86e21f3e1a | ||
| ![renovate[bot]](/assets/img/avatar_default.png)  | d7d884ad6d | ||
| ![renovate[bot]](/assets/img/avatar_default.png)  | 1c45e01a14 | ||
|   | 6ef1163325 | ||
| ![renovate[bot]](/assets/img/avatar_default.png)  | c57d784df7 | ||
|   | c239908aa3 | ||
|   | a6412581a6 | 
							
								
								
									
										2
									
								
								.github/workflows/label-merge-conflicts.yaml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/label-merge-conflicts.yaml
									
									
									
									
										vendored
									
									
								
							| @@ -15,7 +15,7 @@ jobs: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - name: Label conflicting PRs | ||||
|         uses: eps1lon/actions-label-merge-conflict@v3.0.0 | ||||
|         uses: eps1lon/actions-label-merge-conflict@v3.0.2 | ||||
|         with: | ||||
|           dirtyLabel: "unresolved-merge-conflict" | ||||
|           repoToken: "${{ secrets.GITHUB_TOKEN }}" | ||||
|   | ||||
| @@ -24,7 +24,6 @@ import com.google.inject.Injector; | ||||
| import com.google.inject.Key; | ||||
| import com.google.inject.Singleton; | ||||
| import com.google.inject.Stage; | ||||
| import com.google.inject.TypeLiteral; | ||||
| import com.plotsquared.bukkit.generator.BukkitPlotGenerator; | ||||
| import com.plotsquared.bukkit.inject.BackupModule; | ||||
| import com.plotsquared.bukkit.inject.BukkitModule; | ||||
| @@ -35,6 +34,7 @@ import com.plotsquared.bukkit.listener.BlockEventListener117; | ||||
| import com.plotsquared.bukkit.listener.ChunkListener; | ||||
| import com.plotsquared.bukkit.listener.EntityEventListener; | ||||
| import com.plotsquared.bukkit.listener.EntitySpawnListener; | ||||
| import com.plotsquared.bukkit.listener.HighFreqBlockEventListener; | ||||
| import com.plotsquared.bukkit.listener.PaperListener; | ||||
| import com.plotsquared.bukkit.listener.PlayerEventListener; | ||||
| import com.plotsquared.bukkit.listener.PlayerEventListener1201; | ||||
| @@ -45,7 +45,6 @@ import com.plotsquared.bukkit.listener.SpigotListener; | ||||
| import com.plotsquared.bukkit.listener.WorldEvents; | ||||
| import com.plotsquared.bukkit.placeholder.PAPIPlaceholders; | ||||
| import com.plotsquared.bukkit.placeholder.PlaceholderFormatter; | ||||
| import com.plotsquared.bukkit.player.BukkitPlayer; | ||||
| import com.plotsquared.bukkit.player.BukkitPlayerManager; | ||||
| import com.plotsquared.bukkit.util.BukkitUtil; | ||||
| import com.plotsquared.bukkit.util.BukkitWorld; | ||||
| @@ -364,6 +363,9 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl | ||||
|                 getServer().getPluginManager().registerEvents(injector().getInstance(PlayerEventListener1201.class), this); | ||||
|             } | ||||
|             getServer().getPluginManager().registerEvents(injector().getInstance(BlockEventListener.class), this); | ||||
|             if (Settings.HIGH_FREQUENCY_LISTENER) { | ||||
|                 getServer().getPluginManager().registerEvents(injector().getInstance(HighFreqBlockEventListener.class), this); | ||||
|             } | ||||
|             if (serverVersion()[1] >= 17) { | ||||
|                 getServer().getPluginManager().registerEvents(injector().getInstance(BlockEventListener117.class), this); | ||||
|             } | ||||
| @@ -1271,15 +1273,13 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl | ||||
|  | ||||
|     @Override | ||||
|     public @NonNull PlatformWorldManager<?> worldManager() { | ||||
|         return injector().getInstance(Key.get(new TypeLiteral<PlatformWorldManager<World>>() { | ||||
|         })); | ||||
|         return this.worldManager; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     @NonNull | ||||
|     @SuppressWarnings("unchecked") | ||||
|     public PlayerManager<? extends PlotPlayer<Player>, ? extends Player> playerManager() { | ||||
|         return (PlayerManager<BukkitPlayer, Player>) injector().getInstance(PlayerManager.class); | ||||
|         return this.playerManager; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|   | ||||
| @@ -24,7 +24,6 @@ import com.plotsquared.bukkit.util.BukkitUtil; | ||||
| import com.plotsquared.core.PlotSquared; | ||||
| import com.plotsquared.core.configuration.Settings; | ||||
| import com.plotsquared.core.configuration.caption.TranslatableCaption; | ||||
| import com.plotsquared.core.database.DBFunc; | ||||
| import com.plotsquared.core.location.Location; | ||||
| import com.plotsquared.core.permissions.Permission; | ||||
| import com.plotsquared.core.player.PlotPlayer; | ||||
| @@ -48,7 +47,6 @@ import com.plotsquared.core.plot.flag.implementations.LeafDecayFlag; | ||||
| import com.plotsquared.core.plot.flag.implementations.LiquidFlowFlag; | ||||
| import com.plotsquared.core.plot.flag.implementations.MycelGrowFlag; | ||||
| import com.plotsquared.core.plot.flag.implementations.PlaceFlag; | ||||
| import com.plotsquared.core.plot.flag.implementations.RedstoneFlag; | ||||
| import com.plotsquared.core.plot.flag.implementations.SnowFormFlag; | ||||
| import com.plotsquared.core.plot.flag.implementations.SnowMeltFlag; | ||||
| import com.plotsquared.core.plot.flag.implementations.SoilDryFlag; | ||||
| @@ -62,7 +60,6 @@ import com.plotsquared.core.util.task.TaskTime; | ||||
| import com.sk89q.worldedit.WorldEdit; | ||||
| import com.sk89q.worldedit.bukkit.BukkitAdapter; | ||||
| import com.sk89q.worldedit.world.block.BlockType; | ||||
| import net.kyori.adventure.text.Component; | ||||
| import net.kyori.adventure.text.minimessage.tag.Tag; | ||||
| import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver; | ||||
| import org.bukkit.Bukkit; | ||||
| @@ -92,11 +89,9 @@ import org.bukkit.event.block.BlockFromToEvent; | ||||
| import org.bukkit.event.block.BlockGrowEvent; | ||||
| import org.bukkit.event.block.BlockIgniteEvent; | ||||
| import org.bukkit.event.block.BlockMultiPlaceEvent; | ||||
| import org.bukkit.event.block.BlockPhysicsEvent; | ||||
| import org.bukkit.event.block.BlockPistonExtendEvent; | ||||
| import org.bukkit.event.block.BlockPistonRetractEvent; | ||||
| import org.bukkit.event.block.BlockPlaceEvent; | ||||
| import org.bukkit.event.block.BlockRedstoneEvent; | ||||
| import org.bukkit.event.block.BlockSpreadEvent; | ||||
| import org.bukkit.event.block.CauldronLevelChangeEvent; | ||||
| import org.bukkit.event.block.EntityBlockFormEvent; | ||||
| @@ -112,7 +107,6 @@ import java.util.Iterator; | ||||
| import java.util.List; | ||||
| import java.util.Objects; | ||||
| import java.util.Set; | ||||
| import java.util.UUID; | ||||
| import java.util.stream.Collectors; | ||||
| import java.util.stream.Stream; | ||||
|  | ||||
| @@ -123,14 +117,6 @@ import static org.bukkit.Tag.WALL_CORALS; | ||||
| @SuppressWarnings("unused") | ||||
| public class BlockEventListener implements Listener { | ||||
|  | ||||
|     private static final Set<Material> PISTONS = Set.of( | ||||
|             Material.PISTON, | ||||
|             Material.STICKY_PISTON | ||||
|     ); | ||||
|     private static final Set<Material> PHYSICS_BLOCKS = Set.of( | ||||
|             Material.TURTLE_EGG, | ||||
|             Material.TURTLE_SPAWN_EGG | ||||
|     ); | ||||
|     private static final Set<Material> SNOW = Stream.of(Material.values()) // needed as Tag.SNOW isn't present in 1.16.5 | ||||
|             .filter(material -> material.name().contains("SNOW")) | ||||
|             .filter(Material::isBlock) | ||||
| @@ -164,114 +150,6 @@ public class BlockEventListener implements Listener { | ||||
|         }, TaskTime.ticks(3L)); | ||||
|     } | ||||
|  | ||||
|     @EventHandler | ||||
|     public void onRedstoneEvent(BlockRedstoneEvent event) { | ||||
|         Block block = event.getBlock(); | ||||
|         Location location = BukkitUtil.adapt(block.getLocation()); | ||||
|         PlotArea area = location.getPlotArea(); | ||||
|         if (area == null) { | ||||
|             return; | ||||
|         } | ||||
|         Plot plot = location.getOwnedPlot(); | ||||
|         if (plot == null) { | ||||
|             if (PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, RedstoneFlag.class, false)) { | ||||
|                 event.setNewCurrent(0); | ||||
|             } | ||||
|             return; | ||||
|         } | ||||
|         if (!plot.getFlag(RedstoneFlag.class)) { | ||||
|             event.setNewCurrent(0); | ||||
|             plot.debug("Redstone event was cancelled because redstone = false"); | ||||
|             return; | ||||
|         } | ||||
|         if (Settings.Redstone.DISABLE_OFFLINE) { | ||||
|             boolean disable = false; | ||||
|             if (!DBFunc.SERVER.equals(plot.getOwner())) { | ||||
|                 if (plot.isMerged()) { | ||||
|                     disable = true; | ||||
|                     for (UUID owner : plot.getOwners()) { | ||||
|                         if (PlotSquared.platform().playerManager().getPlayerIfExists(owner) != null) { | ||||
|                             disable = false; | ||||
|                             break; | ||||
|                         } | ||||
|                     } | ||||
|                 } else { | ||||
|                     disable = PlotSquared.platform().playerManager().getPlayerIfExists(plot.getOwnerAbs()) == null; | ||||
|                 } | ||||
|             } | ||||
|             if (disable) { | ||||
|                 for (UUID trusted : plot.getTrusted()) { | ||||
|                     if (PlotSquared.platform().playerManager().getPlayerIfExists(trusted) != null) { | ||||
|                         disable = false; | ||||
|                         break; | ||||
|                     } | ||||
|                 } | ||||
|                 if (disable) { | ||||
|                     event.setNewCurrent(0); | ||||
|                     plot.debug("Redstone event was cancelled because no trusted player was in the plot"); | ||||
|                     return; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         if (Settings.Redstone.DISABLE_UNOCCUPIED) { | ||||
|             for (final PlotPlayer<?> player : PlotSquared.platform().playerManager().getPlayers()) { | ||||
|                 if (plot.equals(player.getCurrentPlot())) { | ||||
|                     return; | ||||
|                 } | ||||
|             } | ||||
|             event.setNewCurrent(0); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) | ||||
|     public void onPhysicsEvent(BlockPhysicsEvent event) { | ||||
|         Block block = event.getBlock(); | ||||
|         Location location = BukkitUtil.adapt(block.getLocation()); | ||||
|         PlotArea area = location.getPlotArea(); | ||||
|         if (area == null) { | ||||
|             return; | ||||
|         } | ||||
|         Plot plot = area.getOwnedPlotAbs(location); | ||||
|         if (plot == null) { | ||||
|             return; | ||||
|         } | ||||
|         if (event.getChangedType().hasGravity() && plot.getFlag(DisablePhysicsFlag.class)) { | ||||
|             event.setCancelled(true); | ||||
|             sendBlockChange(event.getBlock().getLocation(), event.getBlock().getBlockData()); | ||||
|             plot.debug("Prevented block physics and resent block change because disable-physics = true"); | ||||
|             return; | ||||
|         } | ||||
|         if (event.getChangedType() == Material.COMPARATOR) { | ||||
|             if (!plot.getFlag(RedstoneFlag.class)) { | ||||
|                 event.setCancelled(true); | ||||
|                 plot.debug("Prevented comparator update because redstone = false"); | ||||
|             } | ||||
|             return; | ||||
|         } | ||||
|         if (PHYSICS_BLOCKS.contains(event.getChangedType())) { | ||||
|             if (plot.getFlag(DisablePhysicsFlag.class)) { | ||||
|                 event.setCancelled(true); | ||||
|                 plot.debug("Prevented block physics because disable-physics = true"); | ||||
|             } | ||||
|             return; | ||||
|         } | ||||
|         if (Settings.Redstone.DETECT_INVALID_EDGE_PISTONS) { | ||||
|             if (PISTONS.contains(block.getType())) { | ||||
|                 org.bukkit.block.data.Directional piston = (org.bukkit.block.data.Directional) block.getBlockData(); | ||||
|                 final BlockFace facing = piston.getFacing(); | ||||
|                 location = location.add(facing.getModX(), facing.getModY(), facing.getModZ()); | ||||
|                 Plot newPlot = area.getOwnedPlotAbs(location); | ||||
|                 if (plot.equals(newPlot)) { | ||||
|                     return; | ||||
|                 } | ||||
|                 if (!plot.isMerged() || !plot.getConnectedPlots().contains(newPlot)) { | ||||
|                     event.setCancelled(true); | ||||
|                     plot.debug("Prevented piston update because of invalid edge piston detection"); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) | ||||
|     public void blockCreate(BlockPlaceEvent event) { | ||||
|         Location location = BukkitUtil.adapt(event.getBlock().getLocation()); | ||||
| @@ -285,13 +163,6 @@ public class BlockEventListener implements Listener { | ||||
|         if (plot != null) { | ||||
|             if (area.notifyIfOutsideBuildArea(pp, location.getY())) { | ||||
|                 event.setCancelled(true); | ||||
|                 pp.sendMessage( | ||||
|                         TranslatableCaption.of("height.height_limit"), | ||||
|                         TagResolver.builder() | ||||
|                                 .tag("minheight", Tag.inserting(Component.text(area.getMinBuildHeight()))) | ||||
|                                 .tag("maxheight", Tag.inserting(Component.text(area.getMaxBuildHeight()))) | ||||
|                                 .build() | ||||
|                 ); | ||||
|                 return; | ||||
|             } | ||||
|             if (!plot.hasOwner()) { | ||||
| @@ -383,13 +254,6 @@ public class BlockEventListener implements Listener { | ||||
|                 } | ||||
|             } else if (area.notifyIfOutsideBuildArea(plotPlayer, location.getY())) { | ||||
|                 event.setCancelled(true); | ||||
|                 plotPlayer.sendMessage( | ||||
|                         TranslatableCaption.of("height.height_limit"), | ||||
|                         TagResolver.builder() | ||||
|                                 .tag("minheight", Tag.inserting(Component.text(area.getMinBuildHeight()))) | ||||
|                                 .tag("maxheight", Tag.inserting(Component.text(area.getMaxBuildHeight()))) | ||||
|                                 .build() | ||||
|                 ); | ||||
|                 return; | ||||
|             } | ||||
|             if (!plot.hasOwner()) { | ||||
| @@ -1345,20 +1209,11 @@ public class BlockEventListener implements Listener { | ||||
|             if (pp.hasPermission(Permission.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) { | ||||
|                 continue; | ||||
|             } | ||||
|             if (currentLocation.getY() >= area.getMaxBuildHeight() || currentLocation.getY() < area.getMinBuildHeight()) { | ||||
|                 pp.sendMessage( | ||||
|                         TranslatableCaption.of("height.height_limit"), | ||||
|                         TagResolver.builder() | ||||
|                                 .tag("minheight", Tag.inserting(Component.text(area.getMinBuildHeight()))) | ||||
|                                 .tag("maxheight", Tag.inserting(Component.text(area.getMaxBuildHeight()))) | ||||
|                                 .build() | ||||
|                 ); | ||||
|             if (area.notifyIfOutsideBuildArea(pp, currentLocation.getY())) { | ||||
|                 event.setCancelled(true); | ||||
|                 break; | ||||
|             } | ||||
|         } | ||||
|         } | ||||
|  | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -0,0 +1,201 @@ | ||||
| /* | ||||
|  * PlotSquared, a land and world management plugin for Minecraft. | ||||
|  * Copyright (C) IntellectualSites <https://intellectualsites.com> | ||||
|  * Copyright (C) IntellectualSites team and contributors | ||||
|  * | ||||
|  * This program is free software: you can redistribute it and/or modify | ||||
|  * it under the terms of the GNU General Public License as published by | ||||
|  * the Free Software Foundation, either version 3 of the License, or | ||||
|  * (at your option) any later version. | ||||
|  * | ||||
|  * This program is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|  * GNU General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU General Public License | ||||
|  * along with this program.  If not, see <https://www.gnu.org/licenses/>. | ||||
|  */ | ||||
| package com.plotsquared.bukkit.listener; | ||||
|  | ||||
| import com.google.inject.Inject; | ||||
| import com.plotsquared.bukkit.player.BukkitPlayer; | ||||
| import com.plotsquared.bukkit.util.BukkitUtil; | ||||
| import com.plotsquared.core.PlotSquared; | ||||
| import com.plotsquared.core.configuration.Settings; | ||||
| import com.plotsquared.core.database.DBFunc; | ||||
| import com.plotsquared.core.location.Location; | ||||
| import com.plotsquared.core.player.PlotPlayer; | ||||
| import com.plotsquared.core.plot.Plot; | ||||
| import com.plotsquared.core.plot.PlotArea; | ||||
| import com.plotsquared.core.plot.flag.implementations.DisablePhysicsFlag; | ||||
| import com.plotsquared.core.plot.flag.implementations.RedstoneFlag; | ||||
| import com.plotsquared.core.plot.world.PlotAreaManager; | ||||
| import com.plotsquared.core.util.PlotFlagUtil; | ||||
| import com.plotsquared.core.util.task.TaskManager; | ||||
| import com.plotsquared.core.util.task.TaskTime; | ||||
| import com.sk89q.worldedit.WorldEdit; | ||||
| import org.bukkit.Bukkit; | ||||
| import org.bukkit.Material; | ||||
| import org.bukkit.block.Block; | ||||
| import org.bukkit.block.BlockFace; | ||||
| import org.bukkit.block.data.BlockData; | ||||
| import org.bukkit.event.EventHandler; | ||||
| import org.bukkit.event.EventPriority; | ||||
| import org.bukkit.event.Listener; | ||||
| import org.bukkit.event.block.BlockPhysicsEvent; | ||||
| import org.bukkit.event.block.BlockRedstoneEvent; | ||||
| import org.checkerframework.checker.nullness.qual.NonNull; | ||||
|  | ||||
| import java.util.Set; | ||||
| import java.util.UUID; | ||||
|  | ||||
| @SuppressWarnings("unused") | ||||
| public class HighFreqBlockEventListener implements Listener { | ||||
|  | ||||
|     private static final Set<Material> PISTONS = Set.of( | ||||
|             Material.PISTON, | ||||
|             Material.STICKY_PISTON | ||||
|     ); | ||||
|     private static final Set<Material> PHYSICS_BLOCKS = Set.of( | ||||
|             Material.TURTLE_EGG, | ||||
|             Material.TURTLE_SPAWN_EGG | ||||
|     ); | ||||
|  | ||||
|     private final PlotAreaManager plotAreaManager; | ||||
|     private final WorldEdit worldEdit; | ||||
|  | ||||
|     @Inject | ||||
|     public HighFreqBlockEventListener(final @NonNull PlotAreaManager plotAreaManager, final @NonNull WorldEdit worldEdit) { | ||||
|         this.plotAreaManager = plotAreaManager; | ||||
|         this.worldEdit = worldEdit; | ||||
|     } | ||||
|  | ||||
|     public static void sendBlockChange(final org.bukkit.Location bloc, final BlockData data) { | ||||
|         TaskManager.runTaskLater(() -> { | ||||
|             String world = bloc.getWorld().getName(); | ||||
|             int x = bloc.getBlockX(); | ||||
|             int z = bloc.getBlockZ(); | ||||
|             int distance = Bukkit.getViewDistance() * 16; | ||||
|  | ||||
|             for (final PlotPlayer<?> player : PlotSquared.platform().playerManager().getPlayers()) { | ||||
|                 Location location = player.getLocation(); | ||||
|                 if (location.getWorldName().equals(world)) { | ||||
|                     if (16 * Math.abs(location.getX() - x) / 16 > distance || 16 * Math.abs(location.getZ() - z) / 16 > distance) { | ||||
|                         continue; | ||||
|                     } | ||||
|                     ((BukkitPlayer) player).player.sendBlockChange(bloc, data); | ||||
|                 } | ||||
|             } | ||||
|         }, TaskTime.ticks(3L)); | ||||
|     } | ||||
|  | ||||
|     @EventHandler | ||||
|     public void onRedstoneEvent(BlockRedstoneEvent event) { | ||||
|         Block block = event.getBlock(); | ||||
|         Location location = BukkitUtil.adapt(block.getLocation()); | ||||
|         PlotArea area = location.getPlotArea(); | ||||
|         if (area == null) { | ||||
|             return; | ||||
|         } | ||||
|         Plot plot = location.getOwnedPlot(); | ||||
|         if (plot == null) { | ||||
|             if (PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, RedstoneFlag.class, false)) { | ||||
|                 event.setNewCurrent(0); | ||||
|             } | ||||
|             return; | ||||
|         } | ||||
|         if (!plot.getFlag(RedstoneFlag.class)) { | ||||
|             event.setNewCurrent(0); | ||||
|             plot.debug("Redstone event was cancelled because redstone = false"); | ||||
|             return; | ||||
|         } | ||||
|         if (Settings.Redstone.DISABLE_OFFLINE) { | ||||
|             boolean disable = false; | ||||
|             if (!DBFunc.SERVER.equals(plot.getOwner())) { | ||||
|                 if (plot.isMerged()) { | ||||
|                     disable = true; | ||||
|                     for (UUID owner : plot.getOwners()) { | ||||
|                         if (PlotSquared.platform().playerManager().getPlayerIfExists(owner) != null) { | ||||
|                             disable = false; | ||||
|                             break; | ||||
|                         } | ||||
|                     } | ||||
|                 } else { | ||||
|                     disable = PlotSquared.platform().playerManager().getPlayerIfExists(plot.getOwnerAbs()) == null; | ||||
|                 } | ||||
|             } | ||||
|             if (disable) { | ||||
|                 for (UUID trusted : plot.getTrusted()) { | ||||
|                     if (PlotSquared.platform().playerManager().getPlayerIfExists(trusted) != null) { | ||||
|                         disable = false; | ||||
|                         break; | ||||
|                     } | ||||
|                 } | ||||
|                 if (disable) { | ||||
|                     event.setNewCurrent(0); | ||||
|                     plot.debug("Redstone event was cancelled because no trusted player was in the plot"); | ||||
|                     return; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         if (Settings.Redstone.DISABLE_UNOCCUPIED) { | ||||
|             for (final PlotPlayer<?> player : PlotSquared.platform().playerManager().getPlayers()) { | ||||
|                 if (plot.equals(player.getCurrentPlot())) { | ||||
|                     return; | ||||
|                 } | ||||
|             } | ||||
|             event.setNewCurrent(0); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) | ||||
|     public void onPhysicsEvent(BlockPhysicsEvent event) { | ||||
|         Block block = event.getBlock(); | ||||
|         Location location = BukkitUtil.adapt(block.getLocation()); | ||||
|         PlotArea area = location.getPlotArea(); | ||||
|         if (area == null) { | ||||
|             return; | ||||
|         } | ||||
|         Plot plot = area.getOwnedPlotAbs(location); | ||||
|         if (plot == null) { | ||||
|             return; | ||||
|         } | ||||
|         if (event.getChangedType().hasGravity() && plot.getFlag(DisablePhysicsFlag.class)) { | ||||
|             event.setCancelled(true); | ||||
|             sendBlockChange(event.getBlock().getLocation(), event.getBlock().getBlockData()); | ||||
|             plot.debug("Prevented block physics and resent block change because disable-physics = true"); | ||||
|             return; | ||||
|         } | ||||
|         if (event.getChangedType() == Material.COMPARATOR) { | ||||
|             if (!plot.getFlag(RedstoneFlag.class)) { | ||||
|                 event.setCancelled(true); | ||||
|                 plot.debug("Prevented comparator update because redstone = false"); | ||||
|             } | ||||
|             return; | ||||
|         } | ||||
|         if (PHYSICS_BLOCKS.contains(event.getChangedType())) { | ||||
|             if (plot.getFlag(DisablePhysicsFlag.class)) { | ||||
|                 event.setCancelled(true); | ||||
|                 plot.debug("Prevented block physics because disable-physics = true"); | ||||
|             } | ||||
|             return; | ||||
|         } | ||||
|         if (Settings.Redstone.DETECT_INVALID_EDGE_PISTONS) { | ||||
|             if (PISTONS.contains(block.getType())) { | ||||
|                 org.bukkit.block.data.Directional piston = (org.bukkit.block.data.Directional) block.getBlockData(); | ||||
|                 final BlockFace facing = piston.getFacing(); | ||||
|                 location = location.add(facing.getModX(), facing.getModY(), facing.getModZ()); | ||||
|                 Plot newPlot = area.getOwnedPlotAbs(location); | ||||
|                 if (plot.equals(newPlot)) { | ||||
|                     return; | ||||
|                 } | ||||
|                 if (!plot.isMerged() || !plot.getConnectedPlots().contains(newPlot)) { | ||||
|                     event.setCancelled(true); | ||||
|                     plot.debug("Prevented piston update because of invalid edge piston detection"); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -533,9 +533,9 @@ public class PlayerEventListener implements Listener { | ||||
|                     // to is identical to the plot's home location, and untrusted-visit is true | ||||
|                     // i.e. untrusted-visit can override deny-teleport | ||||
|                     // this is acceptable, because otherwise it wouldn't make sense to have both flags set | ||||
|                     if (!result && !(plot.getFlag(UntrustedVisitFlag.class) && plot | ||||
|                             .getHomeSynchronous() | ||||
|                             .equals(BukkitUtil.adaptComplete(to)))) { | ||||
|                     if (result || (plot.getFlag(UntrustedVisitFlag.class) && plot.getHomeSynchronous().equals(BukkitUtil.adaptComplete(to)))) { | ||||
|                         plotListener.plotEntry(pp, plot); | ||||
|                     } else { | ||||
|                         pp.sendMessage( | ||||
|                                 TranslatableCaption.of("deny.no_enter"), | ||||
|                                 TagResolver.resolver("plot", Tag.inserting(Component.text(plot.toString()))) | ||||
| @@ -548,6 +548,19 @@ public class PlayerEventListener implements Listener { | ||||
|         playerMove(event); | ||||
|     } | ||||
|  | ||||
|     @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) | ||||
|     public void onWorldChanged(PlayerChangedWorldEvent event) { | ||||
|         Player player = event.getPlayer(); | ||||
|         BukkitPlayer pp = BukkitUtil.adapt(player); | ||||
|         if (this.worldEdit != null) { | ||||
|             if (!pp.hasPermission(Permission.PERMISSION_WORLDEDIT_BYPASS)) { | ||||
|                 if (pp.getAttribute("worldedit")) { | ||||
|                     pp.removeAttribute("worldedit"); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) | ||||
|     public void vehicleMove(VehicleMoveEvent event) | ||||
|             throws IllegalAccessException { | ||||
| @@ -887,40 +900,6 @@ public class PlayerEventListener implements Listener { | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) | ||||
|     public void onWorldChanged(PlayerChangedWorldEvent event) { | ||||
|         Player player = event.getPlayer(); | ||||
|         BukkitPlayer pp = BukkitUtil.adapt(player); | ||||
|         // Delete last location | ||||
|         Plot plot; | ||||
|         try (final MetaDataAccess<Plot> lastPlotAccess = | ||||
|                      pp.accessTemporaryMetaData(PlayerMetaDataKeys.TEMPORARY_LAST_PLOT)) { | ||||
|             plot = lastPlotAccess.remove(); | ||||
|         } | ||||
|         try (final MetaDataAccess<Location> lastLocationAccess = | ||||
|                      pp.accessTemporaryMetaData(PlayerMetaDataKeys.TEMPORARY_LOCATION)) { | ||||
|             lastLocationAccess.remove(); | ||||
|         } | ||||
|         if (plot != null) { | ||||
|             plotListener.plotExit(pp, plot); | ||||
|         } | ||||
|         if (this.worldEdit != null) { | ||||
|             if (!pp.hasPermission(Permission.PERMISSION_WORLDEDIT_BYPASS)) { | ||||
|                 if (pp.getAttribute("worldedit")) { | ||||
|                     pp.removeAttribute("worldedit"); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         Location location = pp.getLocation(); | ||||
|         PlotArea area = location.getPlotArea(); | ||||
|         if (location.isPlotArea()) { | ||||
|             plot = location.getPlot(); | ||||
|             if (plot != null) { | ||||
|                 plotListener.plotEntry(pp, plot); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @SuppressWarnings("deprecation") | ||||
|     @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) | ||||
|     public void onInventoryClick(InventoryClickEvent event) { | ||||
|   | ||||
| @@ -95,7 +95,8 @@ public class SingleWorldListener implements Listener { | ||||
|  | ||||
|     @EventHandler(priority = EventPriority.LOWEST) | ||||
|     public void onChunkLoad(ChunkLoadEvent event) { | ||||
|         handle(event); | ||||
|         // disable this for now, should address https://github.com/IntellectualSites/PlotSquared/issues/4413 | ||||
|         // handle(event); | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -23,11 +23,15 @@ import com.plotsquared.core.location.World; | ||||
| import org.bukkit.Bukkit; | ||||
| import org.checkerframework.checker.nullness.qual.NonNull; | ||||
|  | ||||
| import java.lang.ref.SoftReference; | ||||
| import java.lang.ref.WeakReference; | ||||
| import java.util.Map; | ||||
|  | ||||
| public class BukkitWorld implements World<org.bukkit.World> { | ||||
|  | ||||
|     private static final Map<String, BukkitWorld> worldMap = Maps.newHashMap(); | ||||
|     // Upon world unload we should probably have the P2 BukkitWorld be GCed relatively eagerly, thus freeing the bukkit world. | ||||
|     //  We also want to avoid circumstances where a bukkit world has been GCed, but a P2 BukkitWorld has not | ||||
|     private static final Map<String, WeakReference<BukkitWorld>> worldMap = Maps.newHashMap(); | ||||
|     private static final boolean HAS_MIN_Y; | ||||
|  | ||||
|     static { | ||||
| @@ -41,10 +45,11 @@ public class BukkitWorld implements World<org.bukkit.World> { | ||||
|         HAS_MIN_Y = temp; | ||||
|     } | ||||
|  | ||||
|     private final org.bukkit.World world; | ||||
|     // We want to allow GC to remove bukkit worlds, but not too eagerly | ||||
|     private final SoftReference<org.bukkit.World> world; | ||||
|  | ||||
|     private BukkitWorld(final org.bukkit.World world) { | ||||
|         this.world = world; | ||||
|         this.world = new SoftReference<>(world); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
| @@ -68,12 +73,13 @@ public class BukkitWorld implements World<org.bukkit.World> { | ||||
|      * @return World instance | ||||
|      */ | ||||
|     public static @NonNull BukkitWorld of(final org.bukkit.World world) { | ||||
|         BukkitWorld bukkitWorld = worldMap.get(world.getName()); | ||||
|         if (bukkitWorld != null && bukkitWorld.getPlatformWorld().equals(world)) { | ||||
|         WeakReference<BukkitWorld> bukkitWorldRef = worldMap.get(world.getName()); | ||||
|         BukkitWorld bukkitWorld; | ||||
|         if (bukkitWorldRef != null && (bukkitWorld = bukkitWorldRef.get()) != null && world.equals(bukkitWorld.world.get())) { | ||||
|             return bukkitWorld; | ||||
|         } | ||||
|         bukkitWorld = new BukkitWorld(world); | ||||
|         worldMap.put(world.getName(), bukkitWorld); | ||||
|         worldMap.put(world.getName(), new WeakReference<>(bukkitWorld)); | ||||
|         return bukkitWorld; | ||||
|     } | ||||
|  | ||||
| @@ -97,22 +103,26 @@ public class BukkitWorld implements World<org.bukkit.World> { | ||||
|  | ||||
|     @Override | ||||
|     public org.bukkit.World getPlatformWorld() { | ||||
|         return this.world; | ||||
|         org.bukkit.World world = this.world.get(); | ||||
|         if (world == null) { | ||||
|             throw new IllegalStateException("Bukkit platform world was unloaded from memory"); | ||||
|         } | ||||
|         return world; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public @NonNull String getName() { | ||||
|         return this.world.getName(); | ||||
|         return this.getPlatformWorld().getName(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public int getMinHeight() { | ||||
|         return getMinWorldHeight(world); | ||||
|         return getMinWorldHeight(getPlatformWorld()); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public int getMaxHeight() { | ||||
|         return getMaxWorldHeight(world) - 1; | ||||
|         return getMaxWorldHeight(getPlatformWorld()) - 1; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|   | ||||
| @@ -43,6 +43,11 @@ public class Settings extends Config { | ||||
|             "Leave it off if you don't need it, it can spam your console."}) | ||||
|     public static boolean DEBUG = true; | ||||
|  | ||||
|     @Comment({"The activity of high-frequency event listener can be deactivated here to improve the server performance. ", | ||||
|             "Affected settings: 'redstone' settings here below. Affected flags: 'disable-physics', 'redstone'. ", | ||||
|             "Only deactivate this setting if you do not need any of the mentioned settings or flags."}) | ||||
|     public static boolean HIGH_FREQUENCY_LISTENER = true; | ||||
|  | ||||
|     @Create // This value will be generated automatically | ||||
|     public static ConfigBlock<Auto_Clear> AUTO_CLEAR = null; | ||||
|     // A ConfigBlock is a section that can have multiple instances e.g. multiple expiry tasks | ||||
|   | ||||
| @@ -24,7 +24,7 @@ import com.plotsquared.core.plot.Plot; | ||||
| public class PlayerEnterPlotEvent extends PlotPlayerEvent { | ||||
|  | ||||
|     /** | ||||
|      * Called when a player leaves a plot. | ||||
|      * PlayerEnterPlotEvent: Called when a player enters a plot | ||||
|      * | ||||
|      * @param player Player that entered the plot | ||||
|      * @param plot   Plot that was entered | ||||
|   | ||||
| @@ -106,6 +106,10 @@ public class PlotListener { | ||||
|                             iterator.remove(); | ||||
|                             continue; | ||||
|                         } | ||||
|                         // Don't attempt to heal dead players - they will get stuck in the abyss (#4406) | ||||
|                         if (PlotSquared.platform().worldUtil().getHealth(player) <= 0) { | ||||
|                             continue; | ||||
|                         } | ||||
|                         double level = PlotSquared.platform().worldUtil().getHealth(player); | ||||
|                         if (level != value.max) { | ||||
|                             PlotSquared.platform().worldUtil().setHealth(player, Math.min(level + value.amount, value.max)); | ||||
|   | ||||
| @@ -643,36 +643,23 @@ public class Plot { | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Gets a immutable set of owner UUIDs for a plot (supports multi-owner mega-plots). | ||||
|      * Gets an immutable set of owner UUIDs for a plot (supports multi-owner mega-plots). | ||||
|      * <p> | ||||
|      * This method cannot be used to add or remove owners from a plot. | ||||
|      * </p> | ||||
|      * | ||||
|      * @return Immutable view of plot owners | ||||
|      * @return Immutable set of plot owners | ||||
|      */ | ||||
|     public @NonNull Set<UUID> getOwners() { | ||||
|         if (this.getOwner() == null) { | ||||
|             return ImmutableSet.of(); | ||||
|         } | ||||
|         if (isMerged()) { | ||||
|             Set<Plot> plots = getConnectedPlots(); | ||||
|             Plot[] array = plots.toArray(new Plot[0]); | ||||
|         ImmutableSet.Builder<UUID> owners = ImmutableSet.builder(); | ||||
|             UUID last = this.getOwner(); | ||||
|             owners.add(this.getOwner()); | ||||
|             for (final Plot current : array) { | ||||
|                 if (current.getOwner() == null) { | ||||
|                     continue; | ||||
|                 } | ||||
|                 if (last == null || current.getOwner().getMostSignificantBits() != last.getMostSignificantBits()) { | ||||
|                     owners.add(current.getOwner()); | ||||
|                     last = current.getOwner(); | ||||
|         for (Plot plot : getConnectedPlots()) { | ||||
|             UUID owner = plot.getOwner(); | ||||
|             if (owner != null) { | ||||
|                 owners.add(owner); | ||||
|             } | ||||
|         } | ||||
|         return owners.build(); | ||||
|     } | ||||
|         return ImmutableSet.of(this.getOwner()); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Checks if the player is either the owner or on the trusted/added list. | ||||
|   | ||||
| @@ -679,10 +679,8 @@ public abstract class PlotArea implements ComponentLike { | ||||
|                     TranslatableCaption.of("height.height_limit"), | ||||
|                     TagResolver.builder() | ||||
|                             .tag("minheight", Tag.inserting(Component.text(minBuildHeight))) | ||||
|                             .tag( | ||||
|                                     "maxheight", | ||||
|                                     Tag.inserting(Component.text(maxBuildHeight)) | ||||
|                             ).build() | ||||
|                             .tag("maxheight", Tag.inserting(Component.text(maxBuildHeight))) | ||||
|                             .build() | ||||
|             ); | ||||
|             // Return true if "failed" as the method will always be inverted otherwise | ||||
|             return true; | ||||
|   | ||||
| @@ -31,6 +31,8 @@ import com.sk89q.worldedit.world.registry.LegacyMapper; | ||||
| import org.checkerframework.checker.nullness.qual.NonNull; | ||||
| import org.checkerframework.checker.nullness.qual.Nullable; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * {@link BlockState} related utility methods | ||||
|  */ | ||||
| @@ -43,7 +45,8 @@ public final class BlockUtil { | ||||
|         PARSER_CONTEXT.setRestricted(false); | ||||
|         PARSER_CONTEXT.setPreferringWildcard(false); | ||||
|         PARSER_CONTEXT.setTryLegacy(true); | ||||
|         PARSER = WorldEdit.getInstance().getBlockFactory().getParsers().get(0); | ||||
|         List<InputParser<BaseBlock>> parsers = WorldEdit.getInstance().getBlockFactory().getParsers(); | ||||
|         PARSER = parsers.get(parsers.size() - 1); // Default parser is always at the end | ||||
|     } | ||||
|  | ||||
|     private BlockUtil() { | ||||
|   | ||||
| @@ -22,7 +22,7 @@ plugins { | ||||
| } | ||||
|  | ||||
| group = "com.intellectualsites.plotsquared" | ||||
| version = "7.3.8" | ||||
| version = "7.3.9-SNAPSHOT" | ||||
|  | ||||
| if (!File("$rootDir/.git").exists()) { | ||||
|     logger.lifecycle(""" | ||||
| @@ -79,8 +79,8 @@ subprojects { | ||||
|  | ||||
|     dependencies { | ||||
|         // Tests | ||||
|         testImplementation("org.junit.jupiter:junit-jupiter:5.10.2") | ||||
|         testRuntimeOnly("org.junit.platform:junit-platform-launcher:1.10.2") | ||||
|         testImplementation("org.junit.jupiter:junit-jupiter:5.10.3") | ||||
|         testRuntimeOnly("org.junit.platform:junit-platform-launcher:1.10.3") | ||||
|     } | ||||
|  | ||||
|     plugins.withId("java") { | ||||
| @@ -94,7 +94,7 @@ subprojects { | ||||
|     } | ||||
|  | ||||
|     configurations.all { | ||||
|         attributes.attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 17) | ||||
|         attributes.attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 21) | ||||
|     } | ||||
|  | ||||
|     spotless { | ||||
|   | ||||
| @@ -2,19 +2,19 @@ | ||||
| # Platform expectations | ||||
| paper = "1.20.2-R0.1-SNAPSHOT" | ||||
| guice = "7.0.0" | ||||
| spotbugs = "4.8.4" | ||||
| checkerqual = "3.42.0" | ||||
| spotbugs = "4.8.6" | ||||
| checkerqual = "3.45.0" | ||||
| gson = "2.10" | ||||
| guava = "31.1-jre" | ||||
| snakeyaml = "2.0" | ||||
| adventure = "4.16.0" | ||||
| adventure-bukkit = "4.3.2" | ||||
| adventure = "4.17.0" | ||||
| adventure-bukkit = "4.3.3" | ||||
| log4j = "2.19.0" | ||||
|  | ||||
| # Plugins | ||||
| worldedit = "7.2.20" | ||||
| fawe = "2.9.2" | ||||
| placeholderapi = "2.11.5" | ||||
| fawe = "2.11.0" | ||||
| placeholderapi = "2.11.6" | ||||
| luckperms = "5.4" | ||||
| essentialsx = "2.20.1" | ||||
| mvdwapi = "3.1.1" | ||||
| @@ -37,7 +37,7 @@ shadow = "8.1.1" | ||||
| grgit = "4.1.1" | ||||
| spotless = "6.25.0" | ||||
| nexus = "2.0.0" | ||||
| runPaper = "2.2.3" | ||||
| runPaper = "2.3.0" | ||||
|  | ||||
| [libraries] | ||||
| # Platform expectations | ||||
|   | ||||
							
								
								
									
										2
									
								
								gradle/wrapper/gradle-wrapper.properties
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								gradle/wrapper/gradle-wrapper.properties
									
									
									
									
										vendored
									
									
								
							| @@ -1,6 +1,6 @@ | ||||
| distributionBase=GRADLE_USER_HOME | ||||
| distributionPath=wrapper/dists | ||||
| distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip | ||||
| distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip | ||||
| networkTimeout=10000 | ||||
| validateDistributionUrl=true | ||||
| zipStoreBase=GRADLE_USER_HOME | ||||
|   | ||||
							
								
								
									
										2
									
								
								gradlew
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								gradlew
									
									
									
									
										vendored
									
									
								
							| @@ -55,7 +55,7 @@ | ||||
| #       Darwin, MinGW, and NonStop. | ||||
| # | ||||
| #   (3) This script is generated from the Groovy template | ||||
| #       https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt | ||||
| #       https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt | ||||
| #       within the Gradle project. | ||||
| # | ||||
| #       You can find Gradle at https://github.com/gradle/gradle/. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user