mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-27 04:55:47 +01:00
SPIGOT-2964: Correct number of shelve sin PrepareEnchantEvent
This commit is contained in:
parent
7c743ff64b
commit
056af8b9c2
@ -71,9 +71,9 @@
|
||||
+ // CraftBukkit start
|
||||
+ CraftItemStack item = CraftItemStack.asCraftMirror(itemstack);
|
||||
+ org.bukkit.enchantments.EnchantmentOffer[] offers = new EnchantmentOffer[3];
|
||||
+ for (i = 0; i < 3; ++i) {
|
||||
+ org.bukkit.enchantments.Enchantment enchantment = (this.h[i] >= 0) ? org.bukkit.enchantments.Enchantment.getById(this.h[i]) : null;
|
||||
+ offers[i] = (enchantment != null) ? new EnchantmentOffer(enchantment, this.i[i], this.costs[i]) : null;
|
||||
+ for (j = 0; j < 3; ++j) {
|
||||
+ org.bukkit.enchantments.Enchantment enchantment = (this.h[j] >= 0) ? org.bukkit.enchantments.Enchantment.getById(this.h[j]) : null;
|
||||
+ offers[j] = (enchantment != null) ? new EnchantmentOffer(enchantment, this.i[j], this.costs[j]) : null;
|
||||
+ }
|
||||
+
|
||||
+ PrepareItemEnchantEvent event = new PrepareItemEnchantEvent(player, this.getBukkitView(), this.world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), item, offers, i);
|
||||
@ -81,24 +81,24 @@
|
||||
+ this.world.getServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ for (i = 0; i < 3; ++i) {
|
||||
+ this.costs[i] = 0;
|
||||
+ this.h[i] = -1;
|
||||
+ this.i[i] = -1;
|
||||
+ for (j = 0; j < 3; ++j) {
|
||||
+ this.costs[j] = 0;
|
||||
+ this.h[j] = -1;
|
||||
+ this.i[j] = -1;
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ for (i = 0; i < 3; i++) {
|
||||
+ EnchantmentOffer offer = event.getOffers()[i];
|
||||
+ for (j = 0; j < 3; j++) {
|
||||
+ EnchantmentOffer offer = event.getOffers()[j];
|
||||
+ if (offer != null) {
|
||||
+ this.costs[i] = offer.getCost();
|
||||
+ this.h[i] = offer.getEnchantment().getId();
|
||||
+ this.i[i] = offer.getEnchantmentLevel();
|
||||
+ this.costs[j] = offer.getCost();
|
||||
+ this.h[j] = offer.getEnchantment().getId();
|
||||
+ this.i[j] = offer.getEnchantmentLevel();
|
||||
+ } else {
|
||||
+ this.costs[i] = 0;
|
||||
+ this.h[i] = -1;
|
||||
+ this.i[i] = -1;
|
||||
+ this.costs[j] = 0;
|
||||
+ this.h[j] = -1;
|
||||
+ this.i[j] = -1;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
Loading…
Reference in New Issue
Block a user