SPIGOT-7350: Add methods to get hints from EnchantItemEvent
This commit is contained in:
parent
9a784ee889
commit
c0f1ad4b9b
@ -108,7 +108,7 @@
|
|||||||
this.broadcastChanges();
|
this.broadcastChanges();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -167,9 +231,24 @@
|
@@ -167,9 +231,26 @@
|
||||||
ItemStack itemstack2 = itemstack;
|
ItemStack itemstack2 = itemstack;
|
||||||
List<WeightedRandomEnchant> list = this.getEnchantmentList(itemstack, i, this.costs[i]);
|
List<WeightedRandomEnchant> list = this.getEnchantmentList(itemstack, i, this.costs[i]);
|
||||||
|
|
||||||
@ -125,7 +125,9 @@
|
|||||||
+ }
|
+ }
|
||||||
+ CraftItemStack item = CraftItemStack.asCraftMirror(itemstack2);
|
+ CraftItemStack item = CraftItemStack.asCraftMirror(itemstack2);
|
||||||
+
|
+
|
||||||
+ EnchantItemEvent event = new EnchantItemEvent((Player) entityhuman.getBukkitEntity(), this.getBukkitView(), access.getLocation().getBlock(), item, this.costs[i], enchants, i);
|
+ org.bukkit.enchantments.Enchantment hintedEnchantment = org.bukkit.enchantments.Enchantment.getByKey(CraftNamespacedKey.fromMinecraft(BuiltInRegistries.ENCHANTMENT.getKey(Enchantment.byId(enchantClue[i]))));
|
||||||
|
+ int hintedEnchantmentLevel = levelClue[i];
|
||||||
|
+ EnchantItemEvent event = new EnchantItemEvent((Player) entityhuman.getBukkitEntity(), this.getBukkitView(), access.getLocation().getBlock(), item, this.costs[i], enchants, hintedEnchantment, hintedEnchantmentLevel, i);
|
||||||
+ world.getCraftServer().getPluginManager().callEvent(event);
|
+ world.getCraftServer().getPluginManager().callEvent(event);
|
||||||
+
|
+
|
||||||
+ int level = event.getExpLevelCost();
|
+ int level = event.getExpLevelCost();
|
||||||
@ -135,7 +137,7 @@
|
|||||||
|
|
||||||
if (flag) {
|
if (flag) {
|
||||||
itemstack2 = new ItemStack(Items.ENCHANTED_BOOK);
|
itemstack2 = new ItemStack(Items.ENCHANTED_BOOK);
|
||||||
@@ -182,16 +261,29 @@
|
@@ -182,16 +263,29 @@
|
||||||
this.enchantSlots.setItem(0, itemstack2);
|
this.enchantSlots.setItem(0, itemstack2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,7 +174,7 @@
|
|||||||
if (!entityhuman.getAbilities().instabuild) {
|
if (!entityhuman.getAbilities().instabuild) {
|
||||||
itemstack1.shrink(j);
|
itemstack1.shrink(j);
|
||||||
if (itemstack1.isEmpty()) {
|
if (itemstack1.isEmpty()) {
|
||||||
@@ -254,6 +346,7 @@
|
@@ -254,6 +348,7 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean stillValid(EntityHuman entityhuman) {
|
public boolean stillValid(EntityHuman entityhuman) {
|
||||||
@ -180,7 +182,7 @@
|
|||||||
return stillValid(this.access, entityhuman, Blocks.ENCHANTING_TABLE);
|
return stillValid(this.access, entityhuman, Blocks.ENCHANTING_TABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -304,4 +397,17 @@
|
@@ -304,4 +399,17 @@
|
||||||
|
|
||||||
return itemstack;
|
return itemstack;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user