mirror of
				https://github.com/IntellectualSites/PlotSquared.git
				synced 2025-10-31 01:23:44 +01:00 
			
		
		
		
	Compare commits
	
		
			1 Commits
		
	
	
		
			fix/1.21.4
			...
			feature/en
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | ee21f77068 | 
| @@ -47,6 +47,7 @@ import com.plotsquared.core.plot.flag.implementations.TileDropFlag; | |||||||
| import com.plotsquared.core.plot.flag.types.BooleanFlag; | import com.plotsquared.core.plot.flag.types.BooleanFlag; | ||||||
| import com.plotsquared.core.plot.world.PlotAreaManager; | import com.plotsquared.core.plot.world.PlotAreaManager; | ||||||
| import com.plotsquared.core.util.PlotFlagUtil; | import com.plotsquared.core.util.PlotFlagUtil; | ||||||
|  | import io.papermc.paper.event.entity.EntityMoveEvent; | ||||||
| import net.kyori.adventure.text.Component; | import net.kyori.adventure.text.Component; | ||||||
| import net.kyori.adventure.text.minimessage.tag.Tag; | import net.kyori.adventure.text.minimessage.tag.Tag; | ||||||
| import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver; | import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver; | ||||||
| @@ -58,6 +59,7 @@ import org.bukkit.entity.EntityType; | |||||||
| import org.bukkit.entity.Player; | import org.bukkit.entity.Player; | ||||||
| import org.bukkit.entity.Projectile; | import org.bukkit.entity.Projectile; | ||||||
| import org.bukkit.entity.Slime; | import org.bukkit.entity.Slime; | ||||||
|  | import org.bukkit.event.Cancellable; | ||||||
| import org.bukkit.event.EventHandler; | import org.bukkit.event.EventHandler; | ||||||
| import org.bukkit.event.EventPriority; | import org.bukkit.event.EventPriority; | ||||||
| import org.bukkit.event.Listener; | import org.bukkit.event.Listener; | ||||||
| @@ -104,33 +106,7 @@ public class PaperListener implements Listener { | |||||||
|         if (!Settings.Paper_Components.ENTITY_PATHING) { |         if (!Settings.Paper_Components.ENTITY_PATHING) { | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|         Location toLoc = BukkitUtil.adapt(event.getLoc()); |         handleEntityMovement(event, event.getEntity().getLocation(), event.getLoc()); | ||||||
|         Location fromLoc = BukkitUtil.adapt(event.getEntity().getLocation()); |  | ||||||
|         PlotArea tarea = toLoc.getPlotArea(); |  | ||||||
|         if (tarea == null) { |  | ||||||
|             return; |  | ||||||
|         } |  | ||||||
|         PlotArea farea = fromLoc.getPlotArea(); |  | ||||||
|         if (farea == null) { |  | ||||||
|             return; |  | ||||||
|         } |  | ||||||
|         if (tarea != farea) { |  | ||||||
|             event.setCancelled(true); |  | ||||||
|             return; |  | ||||||
|         } |  | ||||||
|         Plot tplot = toLoc.getPlot(); |  | ||||||
|         Plot fplot = fromLoc.getPlot(); |  | ||||||
|         if (tplot == null ^ fplot == null) { |  | ||||||
|             event.setCancelled(true); |  | ||||||
|             return; |  | ||||||
|         } |  | ||||||
|         if (tplot == null || tplot.getId().hashCode() == fplot.getId().hashCode()) { |  | ||||||
|             return; |  | ||||||
|         } |  | ||||||
|         if (fplot.isMerged() && fplot.getConnectedPlots().contains(fplot)) { |  | ||||||
|             return; |  | ||||||
|         } |  | ||||||
|         event.setCancelled(true); |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @EventHandler |     @EventHandler | ||||||
| @@ -145,8 +121,23 @@ public class PaperListener implements Listener { | |||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         Location toLoc = BukkitUtil.adapt(b.getLocation()); |         handleEntityMovement(event, event.getEntity().getLocation(),  b.getLocation()); | ||||||
|         Location fromLoc = BukkitUtil.adapt(event.getEntity().getLocation()); |     } | ||||||
|  |  | ||||||
|  |     @EventHandler | ||||||
|  |     public void onEntityMove(EntityMoveEvent event) { | ||||||
|  |         if (!Settings.Paper_Components.ENTITY_MOVEMENT) { | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |         if (!event.hasExplicitlyChangedBlock()) { | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |         handleEntityMovement(event, event.getFrom(), event.getTo()); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private static void handleEntityMovement(Cancellable event, org.bukkit.Location from, org.bukkit.Location target) { | ||||||
|  |         Location toLoc = BukkitUtil.adapt(target); | ||||||
|  |         Location fromLoc = BukkitUtil.adapt(from); | ||||||
|         PlotArea tarea = toLoc.getPlotArea(); |         PlotArea tarea = toLoc.getPlotArea(); | ||||||
|         if (tarea == null) { |         if (tarea == null) { | ||||||
|             return; |             return; | ||||||
| @@ -155,7 +146,6 @@ public class PaperListener implements Listener { | |||||||
|         if (farea == null) { |         if (farea == null) { | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (tarea != farea) { |         if (tarea != farea) { | ||||||
|             event.setCancelled(true); |             event.setCancelled(true); | ||||||
|             return; |             return; | ||||||
| @@ -166,10 +156,10 @@ public class PaperListener implements Listener { | |||||||
|             event.setCancelled(true); |             event.setCancelled(true); | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|         if (tplot == null || tplot.getId().hashCode() == fplot.getId().hashCode()) { |         if (tplot == null || tplot.getId().equals(fplot.getId())) { | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|         if (fplot.isMerged() && fplot.getConnectedPlots().contains(fplot)) { |         if (fplot.isMerged() && fplot.getConnectedPlots().contains(tplot)) { | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|         event.setCancelled(true); |         event.setCancelled(true); | ||||||
|   | |||||||
| @@ -26,6 +26,7 @@ import org.apache.logging.log4j.Logger; | |||||||
|  |  | ||||||
| import java.io.File; | import java.io.File; | ||||||
| import java.io.PrintWriter; | import java.io.PrintWriter; | ||||||
|  | import java.lang.annotation.Documented; | ||||||
| import java.lang.annotation.ElementType; | import java.lang.annotation.ElementType; | ||||||
| import java.lang.annotation.Retention; | import java.lang.annotation.Retention; | ||||||
| import java.lang.annotation.RetentionPolicy; | import java.lang.annotation.RetentionPolicy; | ||||||
| @@ -372,6 +373,7 @@ public class Config { | |||||||
|      */ |      */ | ||||||
|     @Retention(RetentionPolicy.RUNTIME) |     @Retention(RetentionPolicy.RUNTIME) | ||||||
|     @Target({ElementType.FIELD, ElementType.TYPE}) |     @Target({ElementType.FIELD, ElementType.TYPE}) | ||||||
|  |     @Documented | ||||||
|     public @interface Comment { |     public @interface Comment { | ||||||
|  |  | ||||||
|         String[] value(); |         String[] value(); | ||||||
|   | |||||||
| @@ -651,6 +651,8 @@ public class Settings extends Config { | |||||||
|         public static boolean PAPER_LISTENERS = true; |         public static boolean PAPER_LISTENERS = true; | ||||||
|         @Comment("Prevent entities from leaving plots") |         @Comment("Prevent entities from leaving plots") | ||||||
|         public static boolean ENTITY_PATHING = true; |         public static boolean ENTITY_PATHING = true; | ||||||
|  |         @Comment("Prevent entities from leaving plots, even by pushing or pulling") | ||||||
|  |         public static boolean ENTITY_MOVEMENT = false; | ||||||
|         @Comment( |         @Comment( | ||||||
|                 "Cancel entity spawns when the chunk is loaded if the PlotArea's mob spawning is off") |                 "Cancel entity spawns when the chunk is loaded if the PlotArea's mob spawning is off") | ||||||
|         public static boolean CANCEL_CHUNK_SPAWN = true; |         public static boolean CANCEL_CHUNK_SPAWN = true; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user