Allow plugins to enchant normally unenchantable items. Adds BUKKIT-1849
It's currently not possible for a plugin to allow enchanting of an otherwise un-enchantable item using the enchanting table. This commit causes EnchantItemEvent to be called with an empty list of enchantments, allowing a plugin to provide it's own set of enchantments when vanilla Minecraft would not allow any. It also bypasses the unsafe enchantment check since a plugin should be permitted to apply any enchantments they like, and vanilla should not generate unsafe enchantments of its own.
Dieser Commit ist enthalten in:
Ursprung
941650b9b2
Commit
47367210f3
@ -152,6 +152,12 @@ public class ContainerEnchantTable extends Container {
|
||||
if (this.costs[i] > 0 && itemstack != null && (entityhuman.expLevel >= this.costs[i] || entityhuman.abilities.canInstantlyBuild)) {
|
||||
if (!this.world.isStatic) {
|
||||
List list = EnchantmentManager.b(this.l, itemstack, this.costs[i]);
|
||||
// CraftBukkit start - Provide an empty enchantment list
|
||||
if (list == null) {
|
||||
list = new java.util.ArrayList<EnchantmentInstance>();
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
boolean flag = itemstack.getItem() == Items.BOOK;
|
||||
|
||||
if (list != null) {
|
||||
@ -186,7 +192,7 @@ public class ContainerEnchantTable extends Container {
|
||||
EnchantmentInstance enchantment = new EnchantmentInstance(enchantId, entry.getValue());
|
||||
Items.ENCHANTED_BOOK.a(itemstack, enchantment);
|
||||
} else {
|
||||
item.addEnchantment(entry.getKey(), entry.getValue());
|
||||
item.addUnsafeEnchantment(entry.getKey(), entry.getValue());
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
/* Just swallow invalid enchantments */
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren