Files
Purpur/purpur-server/minecraft-patches/unapplied-sources/net/minecraft/server/commands/EnchantCommand.java.patch
2025-11-25 21:27:28 -08:00

29 lines
2.0 KiB
Diff

From 73b67b6fc4ab1a46cb7c1113a4648915bf072f56 Mon Sep 17 00:00:00 2001
From: File <noreply+automated@papermc.io>
Date: Sun, 20 Apr 1997 05:37:42 -0800
Subject: [PATCH] purpur File Patches
diff --git a/net/minecraft/server/commands/EnchantCommand.java b/net/minecraft/server/commands/EnchantCommand.java
index 6f4fcee9fdba2248227708fcced1ce0f40aff6af..13f1dbd0d09428e9e0a42f99d0553283e0065f6f 100644
--- a/net/minecraft/server/commands/EnchantCommand.java
+++ b/net/minecraft/server/commands/EnchantCommand.java
@@ -70,7 +70,7 @@ public class EnchantCommand {
private static int enchant(CommandSourceStack source, Collection<? extends Entity> targets, Holder<Enchantment> enchantment, int level) throws CommandSyntaxException {
Enchantment enchantment1 = enchantment.value();
- if (level > enchantment1.getMaxLevel()) {
+ if (!org.purpurmc.purpur.PurpurConfig.allowUnsafeEnchantCommand && level > enchantment1.getMaxLevel()) { // Purpur - Config to allow unsafe enchants
throw ERROR_LEVEL_TOO_HIGH.create(level, enchantment1.getMaxLevel());
} else {
int i = 0;
@@ -80,7 +80,7 @@ public class EnchantCommand {
ItemStack mainHandItem = livingEntity.getMainHandItem();
if (!mainHandItem.isEmpty()) {
if (enchantment1.canEnchant(mainHandItem)
- && EnchantmentHelper.isEnchantmentCompatible(EnchantmentHelper.getEnchantmentsForCrafting(mainHandItem).keySet(), enchantment)) {
+ && EnchantmentHelper.isEnchantmentCompatible(EnchantmentHelper.getEnchantmentsForCrafting(mainHandItem).keySet(), enchantment) || (org.purpurmc.purpur.PurpurConfig.allowUnsafeEnchantCommand && !mainHandItem.hasEnchantment(enchantment))) { // Purpur - Config to allow unsafe enchants
mainHandItem.enchant(enchantment, level);
i++;
} else if (targets.size() == 1) {