Push changes for anvil.
This commit is contained in:
parent
0a4bde3866
commit
28255ca10a
@ -10023,6 +10023,8 @@ implements Listener
|
|||||||
} else if (event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("BOW") ||
|
} else if (event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("BOW") ||
|
||||||
event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("FISHING")) {
|
event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("FISHING")) {
|
||||||
Bukkit.getPlayer(event.getWhoClicked().getName()).playSound(Bukkit.getPlayer(event.getWhoClicked().getName()).getLocation(), Sound.ARROW_HIT, 10, 1);
|
Bukkit.getPlayer(event.getWhoClicked().getName()).playSound(Bukkit.getPlayer(event.getWhoClicked().getName()).getLocation(), Sound.ARROW_HIT, 10, 1);
|
||||||
|
} else if (event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("ENCHANTED")) {
|
||||||
|
Bukkit.getPlayer(event.getWhoClicked().getName()).playSound(Bukkit.getPlayer(event.getWhoClicked().getName()).getLocation(), Sound.LEVEL_UP, 10, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
event.getInventory().setItem(OUTPUT, new ItemStack(Material.AIR));
|
event.getInventory().setItem(OUTPUT, new ItemStack(Material.AIR));
|
||||||
@ -10105,8 +10107,11 @@ implements Listener
|
|||||||
} else if (event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("BOW") ||
|
} else if (event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("BOW") ||
|
||||||
event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("FISHING")) {
|
event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("FISHING")) {
|
||||||
Bukkit.getPlayer(event.getWhoClicked().getName()).playSound(Bukkit.getPlayer(event.getWhoClicked().getName()).getLocation(), Sound.ARROW_HIT, 10, 1);
|
Bukkit.getPlayer(event.getWhoClicked().getName()).playSound(Bukkit.getPlayer(event.getWhoClicked().getName()).getLocation(), Sound.ARROW_HIT, 10, 1);
|
||||||
|
} else if (event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("ENCHANTED")) {
|
||||||
|
Bukkit.getPlayer(event.getWhoClicked().getName()).playSound(Bukkit.getPlayer(event.getWhoClicked().getName()).getLocation(), Sound.LEVEL_UP, 10, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
event.getInventory().setItem(OUTPUT, new ItemStack(Material.AIR));
|
event.getInventory().setItem(OUTPUT, new ItemStack(Material.AIR));
|
||||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this.plugin, new updateInventoryTask(event.getWhoClicked().getName()));
|
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this.plugin, new updateInventoryTask(event.getWhoClicked().getName()));
|
||||||
}
|
}
|
||||||
@ -10168,6 +10173,8 @@ implements Listener
|
|||||||
} else if (event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("BOW") ||
|
} else if (event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("BOW") ||
|
||||||
event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("FISHING")) {
|
event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("FISHING")) {
|
||||||
Bukkit.getPlayer(event.getWhoClicked().getName()).playSound(Bukkit.getPlayer(event.getWhoClicked().getName()).getLocation(), Sound.ARROW_HIT, 10, 1);
|
Bukkit.getPlayer(event.getWhoClicked().getName()).playSound(Bukkit.getPlayer(event.getWhoClicked().getName()).getLocation(), Sound.ARROW_HIT, 10, 1);
|
||||||
|
} else if (event.getInventory().getItem(OUTPUT).getType().toString().toUpperCase().contains("ENCHANTED")) {
|
||||||
|
Bukkit.getPlayer(event.getWhoClicked().getName()).playSound(Bukkit.getPlayer(event.getWhoClicked().getName()).getLocation(), Sound.LEVEL_UP, 10, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this.plugin, new updateInventoryTask(event.getWhoClicked().getName()));
|
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this.plugin, new updateInventoryTask(event.getWhoClicked().getName()));
|
||||||
@ -13640,11 +13647,13 @@ class updateInventoryTask implements Runnable {
|
|||||||
boolean isHalloweenItem = false;
|
boolean isHalloweenItem = false;
|
||||||
|
|
||||||
List<String> lore = anvilInv.getItem(INPUT).getItemMeta().getLore();
|
List<String> lore = anvilInv.getItem(INPUT).getItemMeta().getLore();
|
||||||
|
if (lore != null) {
|
||||||
for (int i=0;i<lore.size();i++) {
|
for (int i=0;i<lore.size();i++) {
|
||||||
if (lore.get(i).contains(ChatColor.YELLOW+"[Halloween]")) {
|
if (lore.get(i).contains(ChatColor.YELLOW+"[Halloween]")) {
|
||||||
isHalloweenItem = true;
|
isHalloweenItem = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (anvilInv.getItem(MATERIALS).getType() == Material.WOOD && (anvilInv.getItem(INPUT).getType() == Material.WOOD_AXE ||
|
if (anvilInv.getItem(MATERIALS).getType() == Material.WOOD && (anvilInv.getItem(INPUT).getType() == Material.WOOD_AXE ||
|
||||||
anvilInv.getItem(INPUT).getType() == Material.WOOD_SWORD || anvilInv.getItem(INPUT).getType() == Material.WOOD_HOE ||
|
anvilInv.getItem(INPUT).getType() == Material.WOOD_SWORD || anvilInv.getItem(INPUT).getType() == Material.WOOD_HOE ||
|
||||||
@ -13899,7 +13908,7 @@ class updateInventoryTask implements Runnable {
|
|||||||
if (itemEnchantments.get(e) == null || bookEnchantments.get(e) > itemEnchantments.get(e)) {
|
if (itemEnchantments.get(e) == null || bookEnchantments.get(e) > itemEnchantments.get(e)) {
|
||||||
// Book enchantment is larger in magnitude. Assign it as a possible outcome.
|
// Book enchantment is larger in magnitude. Assign it as a possible outcome.
|
||||||
probableEnchantments.put(e, bookEnchantments.get(e));
|
probableEnchantments.put(e, bookEnchantments.get(e));
|
||||||
} else if (bookEnchantments.get(e) == itemEnchantments.get(e) && bookEnchantments.get(e) <= 10) {
|
} else if (bookEnchantments.get(e) == itemEnchantments.get(e) && bookEnchantments.get(e) < 10) {
|
||||||
// Book enchantment is same in magnitude. Upgrade by one level.
|
// Book enchantment is same in magnitude. Upgrade by one level.
|
||||||
probableEnchantments.put(e, bookEnchantments.get(e) + 1);
|
probableEnchantments.put(e, bookEnchantments.get(e) + 1);
|
||||||
}
|
}
|
||||||
@ -14038,7 +14047,7 @@ class updateInventoryTask implements Runnable {
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cost = 0;
|
int cost = anvilInv.getItem(LEVELS).getAmount();
|
||||||
|
|
||||||
if (itemBonuses.get(appliedEnchant) == null) {
|
if (itemBonuses.get(appliedEnchant) == null) {
|
||||||
// This bonus doesn't exist. Calculate full cost.
|
// This bonus doesn't exist. Calculate full cost.
|
||||||
@ -14083,34 +14092,34 @@ class updateInventoryTask implements Runnable {
|
|||||||
|
|
||||||
// Bukkit.getLogger().info("Bonus enchantment string: " + appliedEnchant);
|
// Bukkit.getLogger().info("Bonus enchantment string: " + appliedEnchant);
|
||||||
if (appliedEnchant.equalsIgnoreCase("Critical Chance")) {
|
if (appliedEnchant.equalsIgnoreCase("Critical Chance")) {
|
||||||
bonusesLore.add(ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Critical Chance");
|
bonusesLore.add(0, ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Critical Chance");
|
||||||
}
|
}
|
||||||
if (appliedEnchant.equalsIgnoreCase("Armor Penetration")) {
|
if (appliedEnchant.equalsIgnoreCase("Armor Penetration")) {
|
||||||
bonusesLore.add(ChatColor.YELLOW+"+"+magnitude+" "+ChatColor.BLUE+"Armor Penetration");
|
bonusesLore.add(0, ChatColor.YELLOW+"+"+magnitude+" "+ChatColor.BLUE+"Armor Penetration");
|
||||||
}
|
}
|
||||||
if (appliedEnchant.equalsIgnoreCase("Life Steal")) {
|
if (appliedEnchant.equalsIgnoreCase("Life Steal")) {
|
||||||
bonusesLore.add(ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Life Steal");
|
bonusesLore.add(0, ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Life Steal");
|
||||||
}
|
}
|
||||||
if (appliedEnchant.equalsIgnoreCase("Attack Speed")) {
|
if (appliedEnchant.equalsIgnoreCase("Attack Speed")) {
|
||||||
bonusesLore.add(ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Attack Speed");
|
bonusesLore.add(0, ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Attack Speed");
|
||||||
}
|
}
|
||||||
if (appliedEnchant.equalsIgnoreCase("Damage")) {
|
if (appliedEnchant.equalsIgnoreCase("Damage")) {
|
||||||
bonusesLore.add(ChatColor.YELLOW+"+"+magnitude+" "+ChatColor.BLUE+"Damage");
|
bonusesLore.add(0, ChatColor.YELLOW+"+"+magnitude+" "+ChatColor.BLUE+"Damage");
|
||||||
}
|
}
|
||||||
if (appliedEnchant.equalsIgnoreCase("Health")) {
|
if (appliedEnchant.equalsIgnoreCase("Health")) {
|
||||||
bonusesLore.add(ChatColor.YELLOW+"+"+magnitude+" "+ChatColor.BLUE+"Health");
|
bonusesLore.add(0, ChatColor.YELLOW+"+"+magnitude+" "+ChatColor.BLUE+"Health");
|
||||||
}
|
}
|
||||||
if (appliedEnchant.equalsIgnoreCase("Damage Reduction")) {
|
if (appliedEnchant.equalsIgnoreCase("Damage Reduction")) {
|
||||||
bonusesLore.add(ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Damage Reduction");
|
bonusesLore.add(0, ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Damage Reduction");
|
||||||
}
|
}
|
||||||
if (appliedEnchant.equalsIgnoreCase("Durability")) {
|
if (appliedEnchant.equalsIgnoreCase("Durability")) {
|
||||||
bonusesLore.add(ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Durability");
|
bonusesLore.add(0, ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Durability");
|
||||||
}
|
}
|
||||||
if (appliedEnchant.equalsIgnoreCase("Block Chance")) {
|
if (appliedEnchant.equalsIgnoreCase("Block Chance")) {
|
||||||
bonusesLore.add(ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Block Chance");
|
bonusesLore.add(0, ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Block Chance");
|
||||||
}
|
}
|
||||||
if (appliedEnchant.equalsIgnoreCase("Speed Boost Chance")) {
|
if (appliedEnchant.equalsIgnoreCase("Speed Boost Chance")) {
|
||||||
bonusesLore.add(ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Speed Boost Chance");
|
bonusesLore.add(0, ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Speed Boost Chance");
|
||||||
}
|
}
|
||||||
|
|
||||||
bonusesMeta.setLore(bonusesLore);
|
bonusesMeta.setLore(bonusesLore);
|
||||||
@ -14119,7 +14128,7 @@ class updateInventoryTask implements Runnable {
|
|||||||
} else {
|
} else {
|
||||||
// This enchantment exists. Calculate incremental cost.
|
// This enchantment exists. Calculate incremental cost.
|
||||||
|
|
||||||
cost += (int)(12 * itemBonuses.get(appliedEnchant) / probableBonuses.get(appliedEnchant)); // Make sure it's at least one level
|
cost += (int)(12d * itemBonuses.get(appliedEnchant) / probableBonuses.get(appliedEnchant)); // Make sure it's at least one level
|
||||||
cost = Math.min(60, cost);
|
cost = Math.min(60, cost);
|
||||||
cost = Math.max(1, cost);
|
cost = Math.max(1, cost);
|
||||||
|
|
||||||
@ -14204,9 +14213,20 @@ class updateInventoryTask implements Runnable {
|
|||||||
} else if (anvilInv.getItem(MAGIC).getType() == Material.BOOK && anvilInv.getItem(INPUT).getType() != Material.ENCHANTED_BOOK) {
|
} else if (anvilInv.getItem(MAGIC).getType() == Material.BOOK && anvilInv.getItem(INPUT).getType() != Material.ENCHANTED_BOOK) {
|
||||||
// Magic slot is a book. Unenchanting logic goes here.
|
// Magic slot is a book. Unenchanting logic goes here.
|
||||||
anvilInv.setItem(OUTPUT, new ItemStack(Material.ENCHANTED_BOOK));
|
anvilInv.setItem(OUTPUT, new ItemStack(Material.ENCHANTED_BOOK));
|
||||||
anvilInv.getItem(OUTPUT).setType(Material.ENCHANTED_BOOK);
|
// anvilInv.getItem(OUTPUT).setType(Material.ENCHANTED_BOOK);
|
||||||
|
|
||||||
|
ItemMeta bookMeta = anvilInv.getItem(OUTPUT).getItemMeta();
|
||||||
|
|
||||||
|
// Grab enchantments and lore. This is necessary due to leather armor meta being a different class.
|
||||||
|
Map<Enchantment, Integer> itemEnchantments = anvilInv.getItem(INPUT).getItemMeta().getEnchants();
|
||||||
|
|
||||||
|
for (Enchantment e : itemEnchantments.keySet()) {
|
||||||
|
bookMeta.addEnchant(e, itemEnchantments.get(e), true); // force-add all enchants
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> bookLore = anvilInv.getItem(INPUT).getItemMeta().getLore(); // add more filtering code after this later
|
||||||
|
bookMeta.setLore(bookLore);
|
||||||
|
|
||||||
ItemMeta bookMeta = anvilInv.getItem(INPUT).getItemMeta();
|
|
||||||
bookMeta.setDisplayName(null);
|
bookMeta.setDisplayName(null);
|
||||||
anvilInv.getItem(OUTPUT).setItemMeta(bookMeta);
|
anvilInv.getItem(OUTPUT).setItemMeta(bookMeta);
|
||||||
|
|
||||||
@ -14224,6 +14244,8 @@ class updateInventoryTask implements Runnable {
|
|||||||
cost += (1 + enchantments.get(e));
|
cost += (1 + enchantments.get(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cost = Math.min(60, cost);
|
||||||
|
|
||||||
ItemStack orbs = new ItemStack(Material.SLIME_BALL);
|
ItemStack orbs = new ItemStack(Material.SLIME_BALL);
|
||||||
|
|
||||||
ItemMeta temp_meta = orbs.getItemMeta();
|
ItemMeta temp_meta = orbs.getItemMeta();
|
||||||
@ -14297,7 +14319,7 @@ class updateInventoryTask implements Runnable {
|
|||||||
public double getEnchantmentNumb(String s) {
|
public double getEnchantmentNumb(String s) {
|
||||||
//Parse the string for spaces.
|
//Parse the string for spaces.
|
||||||
String[] enchant = s.split(" ");
|
String[] enchant = s.split(" ");
|
||||||
if (enchant[0].contains(ChatColor.YELLOW+"")) {
|
if (enchant[0].contains(ChatColor.YELLOW+"") && (enchant.length > 1)) {
|
||||||
String newstring = ((enchant[0].replace(ChatColor.YELLOW.getChar(), ' ')).replace('%', ' ')).replace(Character.toString((char)0x00A7), Character.toString((char)0x0020));
|
String newstring = ((enchant[0].replace(ChatColor.YELLOW.getChar(), ' ')).replace('%', ' ')).replace(Character.toString((char)0x00A7), Character.toString((char)0x0020));
|
||||||
// Bukkit.getLogger().info("Enchant number is "+Double.valueOf(newstring));
|
// Bukkit.getLogger().info("Enchant number is "+Double.valueOf(newstring));
|
||||||
return Double.valueOf(newstring);
|
return Double.valueOf(newstring);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user