From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Encode42 <me@encode42.dev>
Date: Wed, 24 Mar 2021 17:59:54 -0400
Subject: [PATCH] Config to allow for unsafe enchants


diff --git a/src/main/java/net/minecraft/server/commands/CommandEnchant.java b/src/main/java/net/minecraft/server/commands/CommandEnchant.java
index 96991d77cfef2ef0fdada1a831619293ffe37e70..4d85ae98369039bcbb5ed5acb2d281bd65523fad 100644
--- a/src/main/java/net/minecraft/server/commands/CommandEnchant.java
+++ b/src/main/java/net/minecraft/server/commands/CommandEnchant.java
@@ -48,7 +48,7 @@ public class CommandEnchant {
     }
 
     private static int a(CommandListenerWrapper commandlistenerwrapper, Collection<? extends Entity> collection, Enchantment enchantment, int i) throws CommandSyntaxException {
-        if (i > enchantment.getMaxLevel()) {
+        if (!net.pl3x.purpur.PurpurConfig.allowUnsafeEnchants && i > enchantment.getMaxLevel()) { // Purpur
             throw CommandEnchant.d.create(i, enchantment.getMaxLevel());
         } else {
             int j = 0;
@@ -62,7 +62,7 @@ public class CommandEnchant {
                     ItemStack itemstack = entityliving.getItemInMainHand();
 
                     if (!itemstack.isEmpty()) {
-                        if (enchantment.canEnchant(itemstack) && EnchantmentManager.a((Collection) EnchantmentManager.a(itemstack).keySet(), enchantment)) {
+                        if (net.pl3x.purpur.PurpurConfig.allowUnsafeEnchants || (enchantment.canEnchant(itemstack) && EnchantmentManager.a((Collection) EnchantmentManager.a(itemstack).keySet(), enchantment))) { // Purpur
                             itemstack.addEnchantment(enchantment, i);
                             ++j;
                         } else if (collection.size() == 1) {
diff --git a/src/main/java/net/pl3x/purpur/PurpurConfig.java b/src/main/java/net/pl3x/purpur/PurpurConfig.java
index 844f5d7fee4ea06a5761e8fb6d54357d58bff8f5..6355f246809982f6da34671be22066a83cfba42c 100644
--- a/src/main/java/net/pl3x/purpur/PurpurConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurConfig.java
@@ -232,6 +232,7 @@ public class PurpurConfig {
 
     public static boolean allowInfinityMending = false;
     public static boolean allowCrossbowInfinity = false;
+    public static boolean allowUnsafeEnchants = false;
     private static void enchantmentSettings() {
         if (version < 5) {
             boolean oldValue = getBoolean("settings.enchantment.allow-infinite-and-mending-together", false);
@@ -240,6 +241,7 @@ public class PurpurConfig {
         }
         allowInfinityMending = getBoolean("settings.enchantment.allow-infinity-and-mending-together", allowInfinityMending);
         allowCrossbowInfinity = getBoolean("settings.enchantment.allow-infinity-on-crossbow", allowCrossbowInfinity);
+        allowUnsafeEnchants = getBoolean("settings.enchantment.allow-unsafe-enchants", allowUnsafeEnchants);
     }
 
     public static boolean endermanShortHeight = false;
