mirror of
https://github.com/PurpurMC/Purpur.git
synced 2025-02-17 13:00:04 +08:00
Add new permissions and register some existing ones (#1157)
This commit is contained in:
parent
d2e8d33295
commit
b63fc3b872
@ -31,10 +31,10 @@ index e1a4ddf2c07cdd242fa8054a0152522fe4039e85..8e481e3815f5645ee92f0d229e5ff25c
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/util/permissions/PurpurPermissions.java b/src/main/java/org/bukkit/util/permissions/PurpurPermissions.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..bed91e726faae389536c8725061f23f069ba6b21
|
||||
index 0000000000000000000000000000000000000000..baec4c87d7ea4d54934ca22fd1eb7b46dd69061b
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/bukkit/util/permissions/PurpurPermissions.java
|
||||
@@ -0,0 +1,79 @@
|
||||
@@ -0,0 +1,87 @@
|
||||
+package org.bukkit.util.permissions;
|
||||
+
|
||||
+import org.bukkit.entity.Entity;
|
||||
@ -78,7 +78,15 @@ index 0000000000000000000000000000000000000000..bed91e726faae389536c8725061f23f0
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "drop.spawners", "Allows the user to drop spawner cage when broken with diamond pickaxe with silk touch", PermissionDefault.FALSE, purpur);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "place.spawners", "Allows the user to place spawner cage in the world", PermissionDefault.FALSE, purpur);
|
||||
+
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "anvil.color", "Allows the user to use color codes on anvils", PermissionDefault.FALSE, purpur);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "mending_shift_click", "Allows the user to use shift-right-click to mend items", PermissionDefault.FALSE, purpur);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "inventory_totem", "Uses a totem from anywhere in the user's inventory on death", PermissionDefault.FALSE, purpur);
|
||||
+
|
||||
+ Permission anvil = DefaultPermissions.registerPermission(PREFIX + "anvil", "Allows the user to use all anvil color and format abilities", PermissionDefault.FALSE, purpur);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "anvil.color", "Allows the user to use color codes in an anvil", PermissionDefault.FALSE, anvil);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "anvil.minimessage", "Allows the user to use minimessage tags in an anvil", PermissionDefault.FALSE, anvil);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "anvil.remove_italics", "Allows the user to remove italics in an anvil", PermissionDefault.FALSE, anvil);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "anvil.format", "Allows the user to use format codes in an anvil", PermissionDefault.FALSE, anvil);
|
||||
+ anvil.recalculatePermissibles();
|
||||
+
|
||||
+ Permission book = DefaultPermissions.registerPermission(PREFIX + "book", "Allows the user to use color codes on books", PermissionDefault.FALSE, purpur);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "book.color.edit", "Allows the user to use color codes on books when editing", PermissionDefault.FALSE, book);
|
||||
|
@ -5,16 +5,15 @@ Subject: [PATCH] Totems work in inventory
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 500b702e2d2b6ba4df07d1fb3e85d632feece76c..7d76ccd2a73209565735a2b2efafe7fd60089e52 100644
|
||||
index 500b702e2d2b6ba4df07d1fb3e85d632feece76c..4eb8920a94304dd12ea94850deda96ff841e024a 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -1546,6 +1546,19 @@ public abstract class LivingEntity extends Entity {
|
||||
@@ -1546,6 +1546,18 @@ public abstract class LivingEntity extends Entity {
|
||||
}
|
||||
}
|
||||
|
||||
+ // Purpur start
|
||||
+ if (level.purpurConfig.totemOfUndyingWorksInInventory && this instanceof ServerPlayer && (itemstack == null || itemstack.getItem() != Items.TOTEM_OF_UNDYING)) {
|
||||
+ ServerPlayer player = (ServerPlayer) this;
|
||||
+ if (level.purpurConfig.totemOfUndyingWorksInInventory && this instanceof ServerPlayer player && (itemstack == null || itemstack.getItem() != Items.TOTEM_OF_UNDYING) && player.getBukkitEntity().hasPermission("purpur.inventory_totem")) {
|
||||
+ for (ItemStack item : player.getInventory().items) {
|
||||
+ if (item.getItem() == Items.TOTEM_OF_UNDYING) {
|
||||
+ itemstack1 = item;
|
||||
|
@ -5,24 +5,31 @@ Subject: [PATCH] Allow anvil colors
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/inventory/AnvilMenu.java b/src/main/java/net/minecraft/world/inventory/AnvilMenu.java
|
||||
index 0363d2263b2d6bd6166fa21d7849297e95eddd77..4b706a22859c5be41abeb6255680e1f085f050a2 100644
|
||||
index 0363d2263b2d6bd6166fa21d7849297e95eddd77..3dbef489a0bf27fbef95de599970141f4aa783f3 100644
|
||||
--- a/src/main/java/net/minecraft/world/inventory/AnvilMenu.java
|
||||
+++ b/src/main/java/net/minecraft/world/inventory/AnvilMenu.java
|
||||
@@ -280,6 +280,19 @@ public class AnvilMenu extends ItemCombinerMenu {
|
||||
@@ -280,6 +280,26 @@ public class AnvilMenu extends ItemCombinerMenu {
|
||||
} else if (!this.itemName.equals(itemstack.getHoverName().getString())) {
|
||||
b1 = 1;
|
||||
i += b1;
|
||||
+ // Purpur start
|
||||
+ if (player != null && player.level.purpurConfig.anvilAllowColors && player.getBukkitEntity().hasPermission("purpur.anvil.color")) {
|
||||
+ if (player != null && player.level.purpurConfig.anvilAllowColors) {
|
||||
+ org.bukkit.craftbukkit.entity.CraftHumanEntity bukkitPlayer = player.getBukkitEntity();
|
||||
+ final net.kyori.adventure.text.Component renameTextComponent;
|
||||
+ if (player.level.purpurConfig.anvilColorsUseMiniMessage && player.getBukkitEntity().hasPermission("purpur.anvil.minimessage")) {
|
||||
+ if (player.level.purpurConfig.anvilColorsUseMiniMessage && bukkitPlayer.hasPermission("purpur.anvil.minimessage")) {
|
||||
+ renameTextComponent = net.kyori.adventure.text.minimessage.MiniMessage.miniMessage().deserialize(itemName);
|
||||
+ itemstack1.setHoverName(io.papermc.paper.adventure.PaperAdventure.asVanilla(renameTextComponent));
|
||||
+ } else if (itemName.startsWith("&r") && player.getBukkitEntity().hasPermission("purpur.anvil.remove_italics")) {
|
||||
+ renameTextComponent = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacyAmpersand().deserialize(itemName.substring(2)).decoration(net.kyori.adventure.text.format.TextDecoration.ITALIC, false);
|
||||
+ } else {
|
||||
+ renameTextComponent = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacyAmpersand().deserialize(itemName);
|
||||
+ }
|
||||
+ itemstack1.setHoverName(io.papermc.paper.adventure.PaperAdventure.asVanilla(renameTextComponent));
|
||||
+ } else if (bukkitPlayer.hasPermission("purpur.anvil.color")) {
|
||||
+ renameTextComponent = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacyAmpersand().deserialize(itemName);
|
||||
+ itemstack1.setHoverName(io.papermc.paper.adventure.PaperAdventure.asVanilla(renameTextComponent));
|
||||
+ } else if (player.getBukkitEntity().hasPermission("purpur.anvil.format")){
|
||||
+ itemName = itemName.replaceAll("(?i)&([l-or])", "\u00a7$1");
|
||||
+ renameTextComponent = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(itemName);
|
||||
+ itemstack1.setHoverName(io.papermc.paper.adventure.PaperAdventure.asVanilla(renameTextComponent));
|
||||
+ }
|
||||
+ } else
|
||||
+ // Purpur end
|
||||
itemstack1.setHoverName(Component.literal(this.itemName));
|
||||
|
@ -5,7 +5,7 @@ Subject: [PATCH] Shift right click to use exp for mending
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
||||
index 9f8995c559b500415ec8d214f7c164707046f6ac..194e9e341b9d1a966d0d78af19120422d7b7eb0a 100644
|
||||
index 9f8995c559b500415ec8d214f7c164707046f6ac..4816b5bd54ae6e080af4c19df43d57e852e76146 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
||||
@@ -509,6 +509,7 @@ public class ServerPlayerGameMode {
|
||||
@ -23,7 +23,7 @@ index 9f8995c559b500415ec8d214f7c164707046f6ac..194e9e341b9d1a966d0d78af19120422
|
||||
+
|
||||
+ // Purpur start
|
||||
+ public boolean shiftClickMended(ItemStack itemstack) {
|
||||
+ if (this.player.level.purpurConfig.shiftRightClickRepairsMendingPoints > 0 && this.player.isShiftKeyDown()) {
|
||||
+ if (this.player.level.purpurConfig.shiftRightClickRepairsMendingPoints > 0 && this.player.isShiftKeyDown() && this.player.getBukkitEntity().hasPermission("purpur.mending_shift_click")) {
|
||||
+ int points = Math.min(this.player.totalExperience, this.player.level.purpurConfig.shiftRightClickRepairsMendingPoints);
|
||||
+ if (points > 0 && itemstack.isDamaged() && net.minecraft.world.item.enchantment.EnchantmentHelper.getItemEnchantmentLevel(net.minecraft.world.item.enchantment.Enchantments.MENDING, itemstack) > 0) {
|
||||
+ this.player.giveExperiencePoints(-points);
|
||||
|
Loading…
Reference in New Issue
Block a user