2018-12-17 06:18:06 +01:00
|
|
|
From e5678439f8c0fd79df801804cf2caafe0bd58575 Mon Sep 17 00:00:00 2001
|
2018-07-23 14:31:18 +02:00
|
|
|
From: Hugo Manrique <hugmanrique@gmail.com>
|
|
|
|
Date: Mon, 23 Jul 2018 14:22:26 +0200
|
|
|
|
Subject: [PATCH] Vanished players don't have rights
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
2018-12-17 06:18:06 +01:00
|
|
|
index 07cd5aa28..fe0590dea 100644
|
2018-07-23 14:31:18 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
2018-08-26 20:11:49 +02:00
|
|
|
@@ -94,7 +94,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
2018-07-23 14:31:18 +02:00
|
|
|
private static int entityCount;
|
|
|
|
private final EntityTypes<?> g; public EntityTypes<?> getEntityType() { return g; } // Paper - OBFHELPER
|
|
|
|
private int id;
|
|
|
|
- public boolean j;
|
|
|
|
+ public boolean j; public boolean blocksEntitySpawning() { return j; } // Paper - OBFHELPER
|
|
|
|
public final List<Entity> passengers;
|
|
|
|
protected int k;
|
2018-08-26 20:11:49 +02:00
|
|
|
private Entity vehicle;
|
2018-07-23 14:31:18 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/ItemBlock.java b/src/main/java/net/minecraft/server/ItemBlock.java
|
2018-12-08 11:09:55 +01:00
|
|
|
index 85d364b8f..ff6c8e2b5 100644
|
2018-07-23 14:31:18 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/ItemBlock.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/ItemBlock.java
|
|
|
|
@@ -70,7 +70,8 @@ public class ItemBlock extends Item {
|
|
|
|
|
|
|
|
protected boolean b(BlockActionContext blockactioncontext, IBlockData iblockdata) {
|
|
|
|
// CraftBukkit start - store default return
|
|
|
|
- boolean defaultReturn = iblockdata.canPlace(blockactioncontext.getWorld(), blockactioncontext.getClickPosition()) && blockactioncontext.getWorld().a(iblockdata, blockactioncontext.getClickPosition());
|
|
|
|
+ final World world = blockactioncontext.getWorld(); // Paper
|
2018-10-23 01:16:21 +02:00
|
|
|
+ boolean defaultReturn = iblockdata.canPlace(world, blockactioncontext.getClickPosition()) && world.a(iblockdata, blockactioncontext.getClickPosition()) && world.checkNoVisiblePlayerCollisions(blockactioncontext.getEntity(), iblockdata.getCollisionShape(world, blockactioncontext.getClickPosition())); // Paper - Use our entity search
|
2018-11-18 17:52:49 +01:00
|
|
|
org.bukkit.entity.Player player = (blockactioncontext.getEntity() instanceof EntityPlayer) ? (org.bukkit.entity.Player) blockactioncontext.getEntity().getBukkitEntity() : null;
|
2018-07-23 14:31:18 +02:00
|
|
|
|
2018-11-18 17:52:49 +01:00
|
|
|
BlockCanBuildEvent event = new BlockCanBuildEvent(CraftBlock.at(blockactioncontext.getWorld(), blockactioncontext.getClickPosition()), player, CraftBlockData.fromData(iblockdata), defaultReturn);
|
2018-07-23 14:31:18 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/VoxelShape.java b/src/main/java/net/minecraft/server/VoxelShape.java
|
2018-12-08 11:09:55 +01:00
|
|
|
index c6ec1a782..6c61718b2 100644
|
2018-07-23 14:31:18 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/VoxelShape.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/VoxelShape.java
|
2018-09-01 00:56:57 +02:00
|
|
|
@@ -24,6 +24,7 @@ public abstract class VoxelShape {
|
|
|
|
return i <= 0 ? Double.NEGATIVE_INFINITY : this.a(enumdirection$enumaxis, i);
|
2018-07-23 14:31:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
+ public AxisAlignedBB getBounds() { return a(); } // Paper - OBFHELPER
|
|
|
|
public AxisAlignedBB a() {
|
2018-10-23 01:16:21 +02:00
|
|
|
if (this.isEmpty()) {
|
2018-07-23 14:31:18 +02:00
|
|
|
throw new UnsupportedOperationException("No bounds for empty shape.");
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
2018-12-17 06:18:06 +01:00
|
|
|
index 858cc1b97..78e85aacf 100644
|
2018-07-23 14:31:18 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
2018-12-17 06:18:06 +01:00
|
|
|
@@ -1529,6 +1529,37 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
2018-07-23 14:31:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start - Based on method below
|
|
|
|
+ /**
|
|
|
|
+ * @param entity causing the action ex. block placer
|
|
|
|
+ * @param voxelshape area to search within
|
|
|
|
+ * @return if there are no visible players colliding
|
|
|
|
+ */
|
|
|
|
+ public boolean checkNoVisiblePlayerCollisions(@Nullable Entity entity, VoxelShape voxelshape) {
|
|
|
|
+ if (voxelshape.isEmpty()) {
|
|
|
|
+ return true;
|
|
|
|
+ } else {
|
|
|
|
+ List list = this.getEntities((Entity) null, voxelshape.getBounds());
|
|
|
|
+
|
|
|
|
+ for (int i = 0; i < list.size(); ++i) {
|
|
|
|
+ Entity entity1 = (Entity) list.get(i);
|
|
|
|
+
|
|
|
|
+ if (entity instanceof EntityPlayer && entity1 instanceof EntityPlayer) {
|
|
|
|
+ if (!((EntityPlayer) entity).getBukkitEntity().canSee(((EntityPlayer) entity1).getBukkitEntity())) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!entity1.dead && entity1.blocksEntitySpawning()) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
public boolean a(@Nullable Entity entity, VoxelShape voxelshape) {
|
2018-10-23 01:16:21 +02:00
|
|
|
if (voxelshape.isEmpty()) {
|
2018-07-23 14:31:18 +02:00
|
|
|
return true;
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
2018-12-17 06:18:06 +01:00
|
|
|
index dcd628104..41b05f231 100644
|
2018-07-23 14:31:18 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
2018-12-17 06:18:06 +01:00
|
|
|
@@ -976,6 +976,14 @@ public class CraftEventFactory {
|
2018-07-23 14:31:18 +02:00
|
|
|
Projectile projectile = (Projectile) entity.getBukkitEntity();
|
|
|
|
org.bukkit.entity.Entity collided = position.entity.getBukkitEntity();
|
|
|
|
com.destroystokyo.paper.event.entity.ProjectileCollideEvent event = new com.destroystokyo.paper.event.entity.ProjectileCollideEvent(projectile, collided);
|
|
|
|
+
|
|
|
|
+ if (projectile.getShooter() instanceof Player && collided instanceof Player) {
|
|
|
|
+ if (!((Player) projectile.getShooter()).canSee((Player) collided)) {
|
|
|
|
+ event.setCancelled(true);
|
|
|
|
+ return event;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
Bukkit.getPluginManager().callEvent(event);
|
|
|
|
return event;
|
|
|
|
}
|
|
|
|
--
|
2018-12-15 02:17:27 +01:00
|
|
|
2.20.0
|
2018-07-23 14:31:18 +02:00
|
|
|
|