mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-05 10:20:53 +01:00
f956f185c8
Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 47b9cf30 SPIGOT-4372: LightningStrikeEvent cause API a9ceda75 Include the plugin channel name in the exception message CraftBukkit Changes:a4bdecff
SPIGOT-4372: LightningStrikeEvent cause API34caaf6d
SPIGOT-4371: Trident damaged when event cancelled97315374
SPIGOT-4369: Handle cancelled trident eventbf1c8273
SPIGOT-4370: Remove vehicle if its passenger spawn event was cancelled Spigot Changes: 6b015b4b SPIGOT-4370: Remove vehicle if its passenger spawn event was cancelled
130 lines
6.5 KiB
Diff
130 lines
6.5 KiB
Diff
From 48d202457a79862fe2914f5e765bc8ba91969cc2 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 46399cc9b0..fdc9d96c27 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/IBlockData.java b/src/main/java/net/minecraft/server/IBlockData.java
|
|
index 24ce9137ae..bf06a90312 100644
|
|
--- a/src/main/java/net/minecraft/server/IBlockData.java
|
|
+++ b/src/main/java/net/minecraft/server/IBlockData.java
|
|
@@ -165,6 +165,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
|
|
index 1cecccef23..afc881d9af 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
|
|
index ea8f1c170a..fdfc0d442e 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.b()) {
|
|
throw new UnsupportedOperationException("No bounds for empty shape.");
|
|
@@ -38,6 +39,7 @@ public abstract class VoxelShape {
|
|
|
|
protected abstract DoubleList a(EnumDirection.EnumAxis var1);
|
|
|
|
+ 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
|
|
index a0e1eb3ff1..887dba69ce 100644
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
|
@@ -1588,6 +1588,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.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
|
|
index 063c1b7fa3..f6b7f7a462 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
@@ -819,6 +819,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.0
|
|
|