mirror of
https://github.com/PaperMC/Paper.git
synced 2025-03-11 01:59:14 +01:00
Add Anti-Xray bypass permission
This is a frequently requested feature. The permission is 'paper.antixray.bypass'.
This commit is contained in:
parent
96fc8c1353
commit
0367dabcb2
4 changed files with 45 additions and 5 deletions
|
@ -28,6 +28,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ public int maxChunkSectionIndex;
|
||||
+ public int updateRadius;
|
||||
+ public boolean lavaObscures;
|
||||
+ public boolean usePermission;
|
||||
+ public List<String> hiddenBlocks;
|
||||
+ public List<String> replacementBlocks;
|
||||
+ private void antiXray() {
|
||||
|
@ -38,6 +39,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ maxChunkSectionIndex = maxChunkSectionIndex > 15 ? 15 : maxChunkSectionIndex;
|
||||
+ updateRadius = getInt("anti-xray.update-radius", 2);
|
||||
+ lavaObscures = getBoolean("anti-xray.lava-obscures", false);
|
||||
+ usePermission = getBoolean("anti-xray.use-permission", false);
|
||||
+ hiddenBlocks = getList("anti-xray.hidden-blocks", Arrays.asList("gold_ore", "iron_ore", "coal_ore", "lapis_ore", "mossy_cobblestone", "obsidian", "chest", "diamond_ore", "redstone_ore", "clay", "emerald_ore", "ender_chest"));
|
||||
+ replacementBlocks = getList("anti-xray.replacement-blocks", Arrays.asList("stone", "oak_planks"));
|
||||
+ if (PaperConfig.version < 19) {
|
||||
|
@ -50,6 +52,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ set("anti-xray.replacement-blocks", replacementBlocks);
|
||||
+ }
|
||||
+ log("Anti-Xray: " + (antiXray ? "enabled" : "disabled") + " / Engine Mode: " + engineMode.getDescription() + " / Up to " + ((maxChunkSectionIndex + 1) * 16) + " blocks / Update Radius: " + updateRadius);
|
||||
+ if (antiXray && usePermission) {
|
||||
+ Bukkit.getLogger().warning("You have enabled permission-based Anti-Xray checking - depending on your permission plugin, this may cause performance issues");
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockController.java b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockController.java
|
||||
|
@ -63,6 +68,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+import net.minecraft.server.BlockPosition;
|
||||
+import net.minecraft.server.Chunk;
|
||||
+import net.minecraft.server.ChunkSection;
|
||||
+import net.minecraft.server.EntityPlayer;
|
||||
+import net.minecraft.server.EnumDirection;
|
||||
+import net.minecraft.server.IBlockData;
|
||||
+import net.minecraft.server.IChunkAccess;
|
||||
|
@ -82,6 +88,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ public boolean shouldModify(EntityPlayer entityPlayer, Chunk chunk, int chunkSectionSelector) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ public ChunkPacketInfo<IBlockData> getChunkPacketInfo(PacketPlayOutMapChunk packetPlayOutMapChunk, Chunk chunk, int chunkSectionSelector) {
|
||||
+ return null;
|
||||
+ }
|
||||
|
@ -127,6 +137,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ private final EngineMode engineMode;
|
||||
+ private final int maxChunkSectionIndex;
|
||||
+ private final int updateRadius;
|
||||
+ private final boolean usePermission;
|
||||
+ private final IBlockData[] predefinedBlockData;
|
||||
+ private final IBlockData[] predefinedBlockDataFull;
|
||||
+ private final IBlockData[] predefinedBlockDataStone;
|
||||
|
@ -146,6 +157,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ engineMode = paperWorldConfig.engineMode;
|
||||
+ maxChunkSectionIndex = paperWorldConfig.maxChunkSectionIndex;
|
||||
+ updateRadius = paperWorldConfig.updateRadius;
|
||||
+ usePermission = paperWorldConfig.usePermission;
|
||||
+
|
||||
+ this.executor = executor;
|
||||
+
|
||||
|
@ -248,6 +260,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean shouldModify(EntityPlayer entityPlayer, Chunk chunk, int chunkSectionSelector) {
|
||||
+ return !usePermission || !entityPlayer.getBukkitEntity().hasPermission("paper.antixray.bypass");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public ChunkPacketInfoAntiXray getChunkPacketInfo(PacketPlayOutMapChunk packetPlayOutMapChunk, Chunk chunk, int chunkSectionSelector) {
|
||||
+ // Return a new instance to collect data and objects in the right state while creating the chunk packet for thread safe access later
|
||||
+ // Note: As of 1.14 this has to be moved later due to the chunk system.
|
||||
|
@ -257,6 +274,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+
|
||||
+ @Override
|
||||
+ public void modifyBlocks(PacketPlayOutMapChunk packetPlayOutMapChunk, ChunkPacketInfo<IBlockData> chunkPacketInfo) {
|
||||
+ if (chunkPacketInfo == null) {
|
||||
+ packetPlayOutMapChunk.setReady(true);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (!Bukkit.isPrimaryThread()) {
|
||||
+ // plugins?
|
||||
+ MinecraftServer.getServer().scheduleOnMain(() -> {
|
||||
|
@ -1237,10 +1259,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
private final java.util.List<Packet> extraPackets = new java.util.ArrayList<>();
|
||||
private static final int TE_LIMIT = Integer.getInteger("Paper.excessiveTELimit", 750);
|
||||
@@ -0,0 +0,0 @@ public class PacketPlayOutMapChunk implements Packet<PacketListenerPlayOut> {
|
||||
return extraPackets;
|
||||
}
|
||||
// Paper end
|
||||
public PacketPlayOutMapChunk(Chunk chunk, int i) {
|
||||
+ ChunkPacketInfo<IBlockData> chunkPacketInfo = chunk.world.chunkPacketBlockController.getChunkPacketInfo(this, chunk, i); // Paper - Anti-Xray - Add chunk packet info
|
||||
- public PacketPlayOutMapChunk(Chunk chunk, int i) {
|
||||
+ // Paper start - Anti-Xray - Add chunk packet info
|
||||
+ @Deprecated public PacketPlayOutMapChunk(Chunk chunk, int i) { this(chunk, i, true); } // Notice for updates: Please make sure this constructor isn't used anywhere
|
||||
+ public PacketPlayOutMapChunk(Chunk chunk, int i, boolean modifyBlocks) {
|
||||
+ ChunkPacketInfo<IBlockData> chunkPacketInfo = modifyBlocks ? chunk.world.chunkPacketBlockController.getChunkPacketInfo(this, chunk, i) : null;
|
||||
+ // Paper end
|
||||
ChunkCoordIntPair chunkcoordintpair = chunk.getPos();
|
||||
|
||||
this.a = chunkcoordintpair.x;
|
||||
|
@ -1315,6 +1342,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
}, this.executor);
|
||||
}
|
||||
|
||||
@@ -0,0 +0,0 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
|
||||
|
||||
}
|
||||
|
||||
+ private final void sendChunk(EntityPlayer entityplayer, Packet<?>[] apacket, Chunk chunk) { this.a(entityplayer, apacket, chunk); } // Paper - OBFHELPER
|
||||
private void a(EntityPlayer entityplayer, Packet<?>[] apacket, Chunk chunk) {
|
||||
if (apacket[0] == null) {
|
||||
- apacket[0] = new PacketPlayOutMapChunk(chunk, 65535);
|
||||
+ apacket[0] = new PacketPlayOutMapChunk(chunk, 65535, chunk.world.chunkPacketBlockController.shouldModify(entityplayer, chunk, 65535)); // Paper - Anti-Xray - Bypass
|
||||
apacket[1] = new PacketPlayOutLightUpdate(chunk.getPos(), this.lightEngine, true);
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerInteractManager.java b/src/main/java/net/minecraft/server/PlayerInteractManager.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerInteractManager.java
|
||||
|
|
|
@ -29,8 +29,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
@@ -0,0 +0,0 @@ public class PaperWorldConfig {
|
||||
Bukkit.getLogger().warning("You have enabled permission-based Anti-Xray checking - depending on your permission plugin, this may cause performance issues");
|
||||
}
|
||||
log("Anti-Xray: " + (antiXray ? "enabled" : "disabled") + " / Engine Mode: " + engineMode.getDescription() + " / Up to " + ((maxChunkSectionIndex + 1) * 16) + " blocks / Update Radius: " + updateRadius);
|
||||
}
|
||||
+
|
||||
+ public boolean disableRelativeProjectileVelocity;
|
||||
|
|
|
@ -562,10 +562,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
|
||||
}
|
||||
|
||||
- private final void sendChunk(EntityPlayer entityplayer, Packet<?>[] apacket, Chunk chunk) { this.a(entityplayer, apacket, chunk); } // Paper - OBFHELPER
|
||||
+ final void sendChunk(EntityPlayer entityplayer, Packet<?>[] apacket, Chunk chunk) { this.a(entityplayer, apacket, chunk); } // Paper - OBFHELPER
|
||||
private void a(EntityPlayer entityplayer, Packet<?>[] apacket, Chunk chunk) {
|
||||
if (apacket[0] == null) {
|
||||
apacket[0] = new PacketPlayOutMapChunk(chunk, 65535);
|
||||
apacket[0] = new PacketPlayOutMapChunk(chunk, 65535, chunk.world.chunkPacketBlockController.shouldModify(entityplayer, chunk, 65535)); // Paper - Anti-Xray - Bypass
|
||||
@@ -0,0 +0,0 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
|
||||
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(this.tracker.chunkX, this.tracker.chunkZ);
|
||||
PlayerChunk playerchunk = PlayerChunkMap.this.getVisibleChunk(chunkcoordintpair.pair());
|
||||
|
|
|
@ -93,7 +93,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ apacket = new Packet[10];
|
||||
+ }
|
||||
+ // Paper end
|
||||
apacket[0] = new PacketPlayOutMapChunk(chunk, 65535);
|
||||
apacket[0] = new PacketPlayOutMapChunk(chunk, 65535, chunk.world.chunkPacketBlockController.shouldModify(entityplayer, chunk, 65535)); // Paper - Anti-Xray - Bypass
|
||||
apacket[1] = new PacketPlayOutLightUpdate(chunk.getPos(), this.lightEngine, true);
|
||||
+
|
||||
+ // Paper start - Fix MC-162253
|
||||
|
|
Loading…
Add table
Reference in a new issue