Paper/Spigot-Server-Patches/0302-Vanished-players-don-t-have-rights.patch
Zach Brown a2ad49b22f
Update upstream BD/B/CB/S
Note to other developers: This commit may require you to wipe your
workspace as a result of the changes to BD.

--- work/BuildData
Submodule work/BuildData f527a8ff..d56672db:
  > Mappings Update

--- work/Bukkit
Submodule work/Bukkit 0c1d258bb..db06c80d7:
  > Add list of entities to EntityTransformEvent
  > SPIGOT-4347: Add API to allow storing arbitrary values on ItemStacks

---work/CraftBukkit
Submodule work/CraftBukkit 6a398ac44..068dab5be:
  > Enable optional source JAR shading via profile shadeSourcesJar
  > Use ImmutableList rather than AbstractList for CraftMetaBook
  > Fix setRecipes(List) not setting Knowledge Book recipes.
  > Mappings Update
  > Add list of entities to EntityTransformEvent & move die calls
  > SPIGOT-4347: Add API to allow storing arbitrary values on ItemStacks
  > Add Vanilla help to default permissions

--- work/Spigot
Submodule work/Spigot a1f2566f6..e769fe4d9:
  > Mappings Update
  > Rebuild patches
2018-12-08 05:09:55 -05:00

110 lines
5.6 KiB
Diff

From 96c562f75805dc969a5acdd9e4f9577ab3d55652 Mon Sep 17 00:00:00 2001
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
index 6c427e9aa..f13fa7fff 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -94,7 +94,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
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;
private Entity vehicle;
diff --git a/src/main/java/net/minecraft/server/ItemBlock.java b/src/main/java/net/minecraft/server/ItemBlock.java
index 85d364b8f..ff6c8e2b5 100644
--- 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
+ 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
org.bukkit.entity.Player player = (blockactioncontext.getEntity() instanceof EntityPlayer) ? (org.bukkit.entity.Player) blockactioncontext.getEntity().getBukkitEntity() : null;
BlockCanBuildEvent event = new BlockCanBuildEvent(CraftBlock.at(blockactioncontext.getWorld(), blockactioncontext.getClickPosition()), player, CraftBlockData.fromData(iblockdata), defaultReturn);
diff --git a/src/main/java/net/minecraft/server/VoxelShape.java b/src/main/java/net/minecraft/server/VoxelShape.java
index c6ec1a782..6c61718b2 100644
--- a/src/main/java/net/minecraft/server/VoxelShape.java
+++ b/src/main/java/net/minecraft/server/VoxelShape.java
@@ -24,6 +24,7 @@ public abstract class VoxelShape {
return i <= 0 ? Double.NEGATIVE_INFINITY : this.a(enumdirection$enumaxis, i);
}
+ public AxisAlignedBB getBounds() { return a(); } // Paper - OBFHELPER
public AxisAlignedBB a() {
if (this.isEmpty()) {
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
index 7f23a8e2e..811311e9e 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -1595,6 +1595,37 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
}
}
+ // 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) {
if (voxelshape.isEmpty()) {
return true;
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index b220895c2..672c32858 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -902,6 +902,14 @@ public class CraftEventFactory {
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;
}
--
2.19.2