Paper/Spigot-Server-Patches/0309-Vanished-players-don-t-have-rights.patch

130 Zeilen
6.5 KiB
Diff

2018-07-31 03:19:41 +02:00
From 26d01acf2550d31956c23abe48f53a3a84c18ce3 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
2018-07-31 03:19:41 +02:00
index 9ab635058..4315804dd 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
2018-07-31 03:19:41 +02:00
@@ -93,7 +93,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 ax;
diff --git a/src/main/java/net/minecraft/server/IBlockData.java b/src/main/java/net/minecraft/server/IBlockData.java
2018-07-29 18:42:07 +02:00
index c8f305e6d..b57f6efb3 100644
--- a/src/main/java/net/minecraft/server/IBlockData.java
+++ b/src/main/java/net/minecraft/server/IBlockData.java
@@ -179,6 +179,7 @@ public interface IBlockData extends IBlockDataHolder<IBlockData> {
return this.getBlock().a(this, iblockaccess, blockposition);
}
+ default VoxelShape getBlockShape(IBlockAccess iblockaccess, BlockPosition blockposition) { return h(iblockaccess, blockposition); } // Paper - OBFHELPER
default VoxelShape h(IBlockAccess iblockaccess, BlockPosition blockposition) {
return this.getBlock().f(this, iblockaccess, blockposition);
}
diff --git a/src/main/java/net/minecraft/server/ItemBlock.java b/src/main/java/net/minecraft/server/ItemBlock.java
2018-07-29 18:42:07 +02:00
index 1cecccef2..afc881d9a 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.getBlockShape(world, blockactioncontext.getClickPosition())); // Paper - Use our entity search
BlockCanBuildEvent event = new BlockCanBuildEvent(CraftBlock.at(blockactioncontext.getWorld(), blockactioncontext.getClickPosition()), CraftBlockData.fromData(iblockdata), defaultReturn);
blockactioncontext.getWorld().getServer().getPluginManager().callEvent(event);
diff --git a/src/main/java/net/minecraft/server/VoxelShape.java b/src/main/java/net/minecraft/server/VoxelShape.java
2018-07-29 18:42:07 +02:00
index 53c9f2188..71e408432 100644
--- a/src/main/java/net/minecraft/server/VoxelShape.java
+++ b/src/main/java/net/minecraft/server/VoxelShape.java
@@ -22,6 +22,7 @@ public abstract class VoxelShape {
return this.a(enumdirection_enumaxis, this.a.b(enumdirection_enumaxis));
}
+ public AxisAlignedBB getBounds() { return a(); } // Paper - OBFHELPER
public AxisAlignedBB a() {
if (this.b()) {
throw new UnsupportedOperationException("No bounds for empty shape.");
@@ -40,6 +41,7 @@ public abstract class VoxelShape {
protected abstract DoubleList a(EnumDirection.EnumAxis enumdirection_enumaxis);
+ public boolean isEmpty() { return b(); } // Paper - OBFHELPER
public boolean b() {
return this.a.a();
}
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
2018-07-31 03:19:41 +02:00
index 47b9f1c47..52cf52ea7 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
2018-07-29 18:42:07 +02:00
@@ -1556,6 +1556,37 @@ public abstract class World implements GeneratorAccess, IIBlockAccess, AutoClose
}
}
+ // 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.b()) {
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-07-29 18:42:07 +02:00
index cf398cd25..140ddae0d 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -804,6 +804,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;
}
--
2018-07-31 03:19:41 +02:00
2.17.1