Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 12:30:06 +01:00
4104545b11
"It was from a different time before books were as jank as they are now. As time has gone on they've only proven to be worse and worse."
80 Zeilen
6.8 KiB
Diff
80 Zeilen
6.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Mariell Hoversholm <proximyst@proximyst.com>
|
|
Date: Sat, 16 May 2020 10:05:30 +0200
|
|
Subject: [PATCH] Add permission for command blocks
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
|
index a695e5a0c2e8846333ccb9aea499b5656af35163..c21c5134308a2a83fb50bfe37f05d19c8e96ca7c 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
|
@@ -391,7 +391,7 @@ public class ServerPlayerGameMode {
|
|
BlockEntity tileentity = this.level.getBlockEntity(pos);
|
|
Block block = iblockdata.getBlock();
|
|
|
|
- if (block instanceof GameMasterBlock && !this.player.canUseGameMasterBlocks()) {
|
|
+ if (block instanceof GameMasterBlock && !this.player.canUseGameMasterBlocks() && !(block instanceof net.minecraft.world.level.block.CommandBlock && (this.player.isCreative() && this.player.getBukkitEntity().hasPermission("minecraft.commandblock")))) { // Paper - command block permission
|
|
this.level.sendBlockUpdated(pos, iblockdata, iblockdata, 3);
|
|
return false;
|
|
} else if (this.player.blockActionRestricted((Level) this.level, pos, this.gameModeForPlayer)) {
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
index 03a98771e828696fef2685fbde040293645a3c17..38f2b5ef4f4a96e5cf919eaa22f82a6909d9c909 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
@@ -788,7 +788,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
|
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
|
|
if (!this.server.isCommandBlockEnabled()) {
|
|
this.player.sendMessage(new TranslatableComponent("advMode.notEnabled"), Util.NIL_UUID);
|
|
- } else if (!this.player.canUseGameMasterBlocks()) {
|
|
+ } else if (!this.player.canUseGameMasterBlocks() && !this.player.isCreative() && !this.player.getBukkitEntity().hasPermission("minecraft.commandblock")) { // Paper - command block permission
|
|
this.player.sendMessage(new TranslatableComponent("advMode.notAllowed"), Util.NIL_UUID);
|
|
} else {
|
|
BaseCommandBlock commandblocklistenerabstract = null;
|
|
@@ -855,7 +855,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
|
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
|
|
if (!this.server.isCommandBlockEnabled()) {
|
|
this.player.sendMessage(new TranslatableComponent("advMode.notEnabled"), Util.NIL_UUID);
|
|
- } else if (!this.player.canUseGameMasterBlocks()) {
|
|
+ } else if (!this.player.canUseGameMasterBlocks() && !this.player.isCreative() && !this.player.getBukkitEntity().hasPermission("minecraft.commandblock")) { // Paper - command block permission
|
|
this.player.sendMessage(new TranslatableComponent("advMode.notAllowed"), Util.NIL_UUID);
|
|
} else {
|
|
BaseCommandBlock commandblocklistenerabstract = packet.getCommandBlock(this.player.level);
|
|
diff --git a/src/main/java/net/minecraft/world/level/BaseCommandBlock.java b/src/main/java/net/minecraft/world/level/BaseCommandBlock.java
|
|
index 2e6172930526efc536a214e420e690a5ea42ac3e..c0dd148d08abf064b5f3c261046cf41d0d1bcf06 100644
|
|
--- a/src/main/java/net/minecraft/world/level/BaseCommandBlock.java
|
|
+++ b/src/main/java/net/minecraft/world/level/BaseCommandBlock.java
|
|
@@ -200,7 +200,7 @@ public abstract class BaseCommandBlock implements CommandSource {
|
|
}
|
|
|
|
public InteractionResult usedBy(Player player) {
|
|
- if (!player.canUseGameMasterBlocks()) {
|
|
+ if (!player.canUseGameMasterBlocks() && !player.isCreative() && !player.getBukkitEntity().hasPermission("minecraft.commandblock")) { // Paper - command block permission
|
|
return InteractionResult.PASS;
|
|
} else {
|
|
if (player.getCommandSenderWorld().isClientSide) {
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/CommandBlock.java b/src/main/java/net/minecraft/world/level/block/CommandBlock.java
|
|
index 363ad038e6c2edc675ded828c7800852d1b0668a..fd73e9100feac8c7bf9a5fee21a0ab2d502dc3e0 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/CommandBlock.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/CommandBlock.java
|
|
@@ -129,7 +129,7 @@ public class CommandBlock extends BaseEntityBlock implements GameMasterBlock {
|
|
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
|
BlockEntity tileentity = world.getBlockEntity(pos);
|
|
|
|
- if (tileentity instanceof CommandBlockEntity && player.canUseGameMasterBlocks()) {
|
|
+ if (tileentity instanceof CommandBlockEntity && (player.canUseGameMasterBlocks() || (player.isCreative() && player.getBukkitEntity().hasPermission("minecraft.commandblock")))) { // Paper - command block permission
|
|
player.openCommandBlock((CommandBlockEntity) tileentity);
|
|
return InteractionResult.sidedSuccess(world.isClientSide);
|
|
} else {
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/util/permissions/CraftDefaultPermissions.java b/src/main/java/org/bukkit/craftbukkit/util/permissions/CraftDefaultPermissions.java
|
|
index c93eec7a81ed83dc9190417dd51acb2780d3b60d..cb75827316fe6c22ec900efea800d35d40573380 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/util/permissions/CraftDefaultPermissions.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/permissions/CraftDefaultPermissions.java
|
|
@@ -16,6 +16,7 @@ public final class CraftDefaultPermissions {
|
|
DefaultPermissions.registerPermission(CraftDefaultPermissions.ROOT + ".nbt.copy", "Gives the user the ability to copy NBT in creative", org.bukkit.permissions.PermissionDefault.TRUE, parent);
|
|
DefaultPermissions.registerPermission(CraftDefaultPermissions.ROOT + ".debugstick", "Gives the user the ability to use the debug stick in creative", org.bukkit.permissions.PermissionDefault.OP, parent);
|
|
DefaultPermissions.registerPermission(CraftDefaultPermissions.ROOT + ".debugstick.always", "Gives the user the ability to use the debug stick in all game modes", org.bukkit.permissions.PermissionDefault.FALSE, parent);
|
|
+ DefaultPermissions.registerPermission(CraftDefaultPermissions.ROOT + ".commandblock", "Gives the user the ability to use command blocks.", org.bukkit.permissions.PermissionDefault.OP, parent); // Paper
|
|
// Spigot end
|
|
parent.recalculatePermissibles();
|
|
}
|