mirror of
https://github.com/barkeser2002/Tenet.git
synced 2026-09-25 01:39:58 +03:00
85 lines
6.0 KiB
Diff
85 lines
6.0 KiB
Diff
From 029ff73e6d907c0f1dfdd6dd61ed2fa956651655 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/level/PlayerInteractManager.java b/src/main/java/net/minecraft/server/level/PlayerInteractManager.java
|
|
index 8d054c4084..e85e929546 100644
|
|
--- a/src/main/java/net/minecraft/server/level/PlayerInteractManager.java
|
|
+++ b/src/main/java/net/minecraft/server/level/PlayerInteractManager.java
|
|
@@ -202,6 +202,14 @@ public class PlayerInteractManager {
|
|
return;
|
|
}
|
|
|
|
+ // Spigot start - handle debug stick left click for non-creative
|
|
+ if (this.player.getMainHandItem().is(net.minecraft.world.item.Items.DEBUG_STICK)
|
|
+ && ((net.minecraft.world.item.ItemDebugStick) net.minecraft.world.item.Items.DEBUG_STICK).handleInteraction(this.player, this.level.getBlockState(blockposition), this.level, blockposition, false, this.player.getMainHandItem())) {
|
|
+ this.player.connection.send(new PacketPlayOutBlockChange(this.level, blockposition));
|
|
+ return;
|
|
+ }
|
|
+ // Spigot end
|
|
+
|
|
if (this.player.blockActionRestricted(this.level, blockposition, this.gameModeForPlayer)) {
|
|
this.player.connection.send(new PacketPlayOutBlockChange(blockposition, this.level.getBlockState(blockposition)));
|
|
this.debugLogging(blockposition, false, j, "block action restricted");
|
|
diff --git a/src/main/java/net/minecraft/server/network/PlayerConnection.java b/src/main/java/net/minecraft/server/network/PlayerConnection.java
|
|
index 3db4ea997b..118ec1a2a3 100644
|
|
--- a/src/main/java/net/minecraft/server/network/PlayerConnection.java
|
|
+++ b/src/main/java/net/minecraft/server/network/PlayerConnection.java
|
|
@@ -2923,7 +2923,7 @@ public class PlayerConnection implements ServerPlayerConnection, TickablePacketL
|
|
|
|
NBTTagCompound nbttagcompound = ItemBlock.getBlockEntityData(itemstack);
|
|
|
|
- if (!itemstack.isEmpty() && nbttagcompound != null && nbttagcompound.contains("x") && nbttagcompound.contains("y") && nbttagcompound.contains("z")) {
|
|
+ if (!itemstack.isEmpty() && nbttagcompound != null && nbttagcompound.contains("x") && nbttagcompound.contains("y") && nbttagcompound.contains("z") && this.player.getBukkitEntity().hasPermission("minecraft.nbt.copy")) { // Spigot
|
|
BlockPosition blockposition = TileEntity.getPosFromTag(nbttagcompound);
|
|
|
|
if (this.player.level().isLoaded(blockposition)) {
|
|
diff --git a/src/main/java/net/minecraft/world/item/ItemBlock.java b/src/main/java/net/minecraft/world/item/ItemBlock.java
|
|
index d740bd14a9..386f22dfb5 100644
|
|
--- a/src/main/java/net/minecraft/world/item/ItemBlock.java
|
|
+++ b/src/main/java/net/minecraft/world/item/ItemBlock.java
|
|
@@ -230,7 +230,7 @@ public class ItemBlock extends Item {
|
|
TileEntity tileentity = world.getBlockEntity(blockposition);
|
|
|
|
if (tileentity != null) {
|
|
- if (!world.isClientSide && tileentity.onlyOpCanSetNbt() && (entityhuman == null || !entityhuman.canUseGameMasterBlocks())) {
|
|
+ if (!world.isClientSide && tileentity.onlyOpCanSetNbt() && (entityhuman == null || !(entityhuman.canUseGameMasterBlocks() || (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 1770955890..fb59e6dfa8 100644
|
|
--- a/src/main/java/net/minecraft/world/item/ItemDebugStick.java
|
|
+++ b/src/main/java/net/minecraft/world/item/ItemDebugStick.java
|
|
@@ -57,7 +57,7 @@ public class ItemDebugStick extends Item {
|
|
}
|
|
|
|
public boolean handleInteraction(EntityHuman entityhuman, IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition, boolean flag, ItemStack itemstack) {
|
|
- if (!entityhuman.canUseGameMasterBlocks()) {
|
|
+ if (!entityhuman.canUseGameMasterBlocks() && !(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 75f8d47a20..525ebf961e 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.41.0
|
|
|