mirror of
https://hub.spigotmc.org/stash/scm/spigot/spigot.git
synced 2025-09-18 21:33:01 +00:00
65 lines
4.8 KiB
Diff
65 lines
4.8 KiB
Diff
From 992687f9d072c4020bcd5127ba9e127fc6f11ed8 Mon Sep 17 00:00:00 2001
|
|
From: md_5 <git@md-5.net>
|
|
Date: Mon, 25 Feb 2019 19:26:56 +1100
|
|
Subject: [PATCH] Add creative mode NBT permissions
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/network/PlayerConnection.java b/src/main/java/net/minecraft/server/network/PlayerConnection.java
|
|
index 0895c60df..c5433a253 100644
|
|
--- a/src/main/java/net/minecraft/server/network/PlayerConnection.java
|
|
+++ b/src/main/java/net/minecraft/server/network/PlayerConnection.java
|
|
@@ -2542,7 +2542,7 @@ public class PlayerConnection implements ServerPlayerConnection, PacketListenerP
|
|
ItemStack itemstack = packetplayinsetcreativeslot.getItemStack();
|
|
NBTTagCompound nbttagcompound = itemstack.b("BlockEntityTag");
|
|
|
|
- if (!itemstack.isEmpty() && nbttagcompound != null && nbttagcompound.hasKey("x") && nbttagcompound.hasKey("y") && nbttagcompound.hasKey("z")) {
|
|
+ if (!itemstack.isEmpty() && nbttagcompound != null && nbttagcompound.hasKey("x") && nbttagcompound.hasKey("y") && nbttagcompound.hasKey("z") && this.player.getBukkitEntity().hasPermission("minecraft.nbt.copy")) { // Spigot
|
|
BlockPosition blockposition = new BlockPosition(nbttagcompound.getInt("x"), nbttagcompound.getInt("y"), nbttagcompound.getInt("z"));
|
|
TileEntity tileentity = this.player.level.getTileEntity(blockposition);
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/item/ItemBlock.java b/src/main/java/net/minecraft/world/item/ItemBlock.java
|
|
index 35f9a7344..5e529502e 100644
|
|
--- a/src/main/java/net/minecraft/world/item/ItemBlock.java
|
|
+++ b/src/main/java/net/minecraft/world/item/ItemBlock.java
|
|
@@ -228,7 +228,7 @@ public class ItemBlock extends Item {
|
|
TileEntity tileentity = world.getTileEntity(blockposition);
|
|
|
|
if (tileentity != null) {
|
|
- if (!world.isClientSide && tileentity.isFilteredNBT() && (entityhuman == null || !entityhuman.isCreativeAndOp())) {
|
|
+ if (!world.isClientSide && tileentity.isFilteredNBT() && (entityhuman == null || !(entityhuman.isCreativeAndOp() || (entityhuman.getAbilities().instabuild && entityhuman.getBukkitEntity().hasPermission("minecraft.nbt.place"))))) { // Spigot - add permission
|
|
return false;
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/item/ItemDebugStick.java b/src/main/java/net/minecraft/world/item/ItemDebugStick.java
|
|
index a43c1c6f3..21e27a99f 100644
|
|
--- a/src/main/java/net/minecraft/world/item/ItemDebugStick.java
|
|
+++ b/src/main/java/net/minecraft/world/item/ItemDebugStick.java
|
|
@@ -59,7 +59,7 @@ public class ItemDebugStick extends Item {
|
|
}
|
|
|
|
private boolean a(EntityHuman entityhuman, IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition, boolean flag, ItemStack itemstack) {
|
|
- if (!entityhuman.isCreativeAndOp()) {
|
|
+ if (!entityhuman.isCreativeAndOp() && !(entityhuman.getAbilities().instabuild && entityhuman.getBukkitEntity().hasPermission("minecraft.debugstick")) && !entityhuman.getBukkitEntity().hasPermission("minecraft.debugstick.always")) { // Spigot
|
|
return false;
|
|
} else {
|
|
Block block = iblockdata.getBlock();
|
|
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 75f8d47a2..525ebf961 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/util/permissions/CraftDefaultPermissions.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/permissions/CraftDefaultPermissions.java
|
|
@@ -11,6 +11,12 @@ public final class CraftDefaultPermissions {
|
|
public static void registerCorePermissions() {
|
|
Permission parent = DefaultPermissions.registerPermission(ROOT, "Gives the user the ability to use all vanilla utilities and commands");
|
|
CommandPermissions.registerPermissions(parent);
|
|
+ // Spigot start
|
|
+ DefaultPermissions.registerPermission(ROOT + ".nbt.place", "Gives the user the ability to place restricted blocks with NBT in creative", org.bukkit.permissions.PermissionDefault.OP, parent);
|
|
+ DefaultPermissions.registerPermission(ROOT + ".nbt.copy", "Gives the user the ability to copy NBT in creative", org.bukkit.permissions.PermissionDefault.TRUE, parent);
|
|
+ DefaultPermissions.registerPermission(ROOT + ".debugstick", "Gives the user the ability to use the debug stick in creative", org.bukkit.permissions.PermissionDefault.OP, parent);
|
|
+ DefaultPermissions.registerPermission(ROOT + ".debugstick.always", "Gives the user the ability to use the debug stick in all game modes", org.bukkit.permissions.PermissionDefault.FALSE, parent);
|
|
+ // Spigot end
|
|
parent.recalculatePermissibles();
|
|
}
|
|
}
|
|
--
|
|
2.25.1
|
|
|