Config to allow for unsafe enchants (#235)

This commit is contained in:
Encode42
2021-03-24 20:27:33 -04:00
committed by GitHub
parent b6235af624
commit 96f53607fc

View File

@@ -0,0 +1,48 @@
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 91677ee1dbb983179261bc1f09ccb08f93406aa9..a7f688f5b6a20e5971595fd6c4ee8214af53c2ec 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;