因此所有replace
行都出错并说:
String类型中的方法
replace(char, char)
不适用于参数(String,int)
我已经尝试了一切,但我无法摆脱错误。
package com.duckcraftpvp.enchants.Events.soul;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import com.duckcraftpvp.enchants.Events.SuccessAndDestroySystem;
import com.duckcraftpvp.enchants.RandomPackage;
import com.duckcraftpvp.enchants.RandomPackageAPI;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.material.MaterialData;
import org.bukkit.scheduler.BukkitScheduler;
public class soulEvents
implements Listener
{
public static ArrayList<Player> soulMode = new ArrayList();
private ArrayList<Player> spam = new ArrayList();
private static HashMap<Player, Integer> soulGemSoulAmount = new HashMap();
private static ItemStack soulModeItem = new ItemStack(Material.EMERALD, 1, (short)0);
private static ItemStack item = new ItemStack(Material.ACACIA_STAIRS, 1);
private static ItemMeta itemMeta = item.getItemMeta();
private static ArrayList<String> lore = new ArrayList();
private String type = null;
private String typ3;
@EventHandler
private void soulGemDropSoulModeRemove(PlayerDropItemEvent event)
{
if ((event.getItemDrop().getItemStack().getType().equals(Material.getMaterial(RandomPackage.getSoulConfig().getString("SoulGem.item").toUpperCase()))) && (event.getItemDrop().getItemStack().getData().getData() == RandomPackage.getSoulConfig().getInt("SoulGem.item-data")) &&
(event.getItemDrop().getItemStack().hasItemMeta()) && (event.getItemDrop().getItemStack().getItemMeta().hasDisplayName()) && (event.getItemDrop().getItemStack().getItemMeta().hasLore()) &&
(event.getItemDrop().getItemStack().getItemMeta().getLore().toString().equalsIgnoreCase(ChatColor.translateAlternateColorCodes('&', RandomPackage.getSoulConfig().getStringList("SoulGem.lore").toString()))) &&
(soulMode.contains(event.getPlayer())))
{
soulMode.remove(event.getPlayer());
for (int i = 0; i < RandomPackage.getMessagesConfig().getStringList("SoulMode.deactivate").size(); i++) {
event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', (String)RandomPackage.getMessagesConfig().getStringList("SoulMode.deactivate").get(i)));
}
return;
}
}
@EventHandler
private void soulTrackerApply(InventoryClickEvent event)
{
if ((event.getCurrentItem() == null) || (event.getCurrentItem().getType().equals(Material.AIR)) || (event.getCursor() == null) || (event.getCursor().getType().equals(Material.AIR)) || (!event.getCursor().getType().equals(Material.getMaterial(RandomPackage.getGivedpItemsConfig().getString("SoulTrackers.item").toUpperCase()))) ||
(!event.getCursor().hasItemMeta()) || (!event.getCursor().getItemMeta().hasDisplayName()) || (!event.getCursor().getItemMeta().hasLore()) ||
(event.getCurrentItem().getType().name().endsWith("HELMET")) || (event.getCurrentItem().getType().name().endsWith("CHESTPLATE")) || (event.getCurrentItem().getType().name().endsWith("LEGGINGS")) ||
(event.getCurrentItem().getType().name().endsWith("BOOTS")) || (event.getCurrentItem().getType().name().endsWith("HOE")) || (event.getCurrentItem().getType().name().endsWith("SPADE")) ||
(!SuccessAndDestroySystem.enchantableItems.contains(event.getCurrentItem().getType()))) {
return;
}
for (int i = 1; i <= 5; i++)
{
if (i == 1) {
this.type = "legendary";
} else if (i == 2) {
this.type = "ultimate";
} else if (i == 3) {
this.type = "elite";
} else if (i == 4) {
this.type = "unique";
} else if (i == 5) {
this.type = "simple";
}
if (event.getCursor().getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.translateAlternateColorCodes('&', RandomPackage.getGivedpItemsConfig().getString("SoulTrackers." + this.type + ".name"))))
{
item = event.getCurrentItem();
itemMeta = item.getItemMeta();
if ((item.hasItemMeta()) && (item.getItemMeta().hasLore()))
{
lore.addAll(item.getItemMeta().getLore());
for (int j = 1; j <= 5; j++)
{
if (j == 1) {
this.typ3 = "legendary";
} else if (j == 2) {
this.typ3 = "ultimate";
} else if (j == 3) {
this.typ3 = "elite";
} else if (j == 4) {
this.typ3 = "unique";
} else if (j == 5) {
this.typ3 = "simple";
}
for (int o = 0; o < lore.size(); o++) {
if (((String)lore.get(o)).startsWith(ChatColor.translateAlternateColorCodes('&', RandomPackage.getGivedpItemsConfig().getString("SoulTrackers." + this.typ3 + ".tracked-lore").replace("%souls%", ""))))
{
if (lore.contains(RandomPackageAPI.whitescroll_apply_lore))
{
lore.remove(RandomPackageAPI.whitescroll_apply_lore);lore.add(RandomPackageAPI.whitescroll_apply_lore);
}
lore.set(o, ChatColor.translateAlternateColorCodes('&', RandomPackage.getGivedpItemsConfig().getString("SoulTrackers." + this.type + ".tracked-lore").replace("%souls%", "0")));
event.getWhoClicked().sendMessage(ChatColor.translateAlternateColorCodes('&', RandomPackage.getMessagesConfig().getString("SoulTrackers.apply-" + this.type)).replace("%item%", event.getCurrentItem().getType().name().replace("_", " ")));
finish(event);
return;
}
}
}
}
if (lore.contains(RandomPackageAPI.whitescroll_apply_lore))
{
lore.remove(RandomPackageAPI.whitescroll_apply_lore);lore.add(RandomPackageAPI.whitescroll_apply_lore);
}
lore.add(ChatColor.translateAlternateColorCodes('&', RandomPackage.getGivedpItemsConfig().getString("SoulTrackers." + this.type + ".tracked-lore").replace("%souls%", "0")));
event.getWhoClicked().sendMessage(ChatColor.translateAlternateColorCodes('&', RandomPackage.getMessagesConfig().getString("SoulTrackers.apply-" + this.type)).replace("%item%", event.getCurrentItem().getType().name().replace("_", " ")));
finish(event);
return;
}
}
}
@EventHandler
private void soulGemCombine(InventoryClickEvent event)
{
if ((event.getCurrentItem() == null) || (event.getCurrentItem().getType().equals(Material.AIR)) || (event.getCursor() == null) || (event.getCursor().getType().equals(Material.AIR)) ||
(!event.getCursor().hasItemMeta()) || (!event.getCursor().getItemMeta().hasDisplayName()) || (!event.getCursor().getItemMeta().hasLore()) || (!event.getCurrentItem().hasItemMeta()) || (!event.getCurrentItem().getItemMeta().hasDisplayName()) || (!event.getCurrentItem().getItemMeta().hasLore()) ||
(!event.getCurrentItem().getType().equals(Material.getMaterial(RandomPackage.getSoulConfig().getString("SoulGem.item").toUpperCase()))) ||
(event.getCurrentItem().getData().getData() != RandomPackage.getSoulConfig().getInt("SoulGem.item-data")) ||
(!event.getCursor().getType().equals(Material.getMaterial(RandomPackage.getSoulConfig().getString("SoulGem.item").toUpperCase()))) ||
(event.getCursor().getData().getData() != RandomPackage.getSoulConfig().getInt("SoulGem.item-data"))) {
return;
}
Player player = (Player)event.getWhoClicked();
if ((event.getCurrentItem().getItemMeta().getLore().toString().equals(ChatColor.translateAlternateColorCodes('&', RandomPackage.getSoulConfig().getStringList("SoulGem.lore").toString()))) &&
(event.getCursor().getItemMeta().getLore().toString().equals(ChatColor.translateAlternateColorCodes('&', RandomPackage.getSoulConfig().getStringList("SoulGem.lore").toString()))))
{
item = event.getCurrentItem();
itemMeta = event.getCurrentItem().getItemMeta();
int soul1 = Integer.parseInt(ChatColor.stripColor(event.getCurrentItem().getItemMeta().getDisplayName()).toLowerCase().replace("a", "").replace("b", "").replace("c", "").replace("d", "").replace("e", "").replace("f", "").replace("g", "").replace("h", "").replace("i", "").replace("j", "").replace("k", "").replace("l", "").replace("m", "")
.replace("n", "").replace("o", "").replace("p", "").replace("q", "").replace("r", "").replace("s", "").replace("t", "").replace("u", "").replace("v", "").replace("w", "").replace("x", "").replace("y", "").replace("z", "").replace("`", "").replace("~", "").replace("!", "").replace("@", "").replace("#", "").replace("$", "").replace("%", "").replace("^", "").replace("&", "").replace("*", "").replace("(", "").replace(")", "").replace("-", "").replace("_", "")
.replace("=", "").replace("+", "").replace("[", "").replace("{", "").replace("]", "").replace("}", "").replace("\\", "").replace("|", "").replace(";", "").replace(":", "").replace("'", "").replace("\"", "").replace(",", "").replace("<", "").replace(".", "").replace(">", "").replace("/", "").replace("?", "").replace(" ", ""));
int soul2 = Integer.parseInt(ChatColor.stripColor(event.getCursor().getItemMeta().getDisplayName()).toLowerCase().replace("a", "").replace("b", "").replace("c", "").replace("d", "").replace("e", "").replace("f", "").replace("g", "").replace("h", "").replace("i", "").replace("j", "").replace("k", "").replace("l", "").replace("m", "")
.replace("n", "").replace("o", "").replace("p", "").replace("q", "").replace("r", "").replace("s", "").replace("t", "").replace("u", "").replace("v", "").replace("w", "").replace("x", "").replace("y", "").replace("z", "").replace("`", "").replace("~", "").replace("!", "").replace("@", "").replace("#", "").replace("$", "").replace("%", "").replace("^", "").replace("&", "").replace("*", "").replace("(", "").replace(")", "").replace("-", "").replace("_", "")
.replace("=", "").replace("+", "").replace("[", "").replace("{", "").replace("]", "").replace("}", "").replace("\\", "").replace("|", "").replace(";", "").replace(":", "").replace("'", "").replace("\"", "").replace(",", "").replace("<", "").replace(".", "").replace(">", "").replace("/", "").replace("?", "").replace(" ", ""));
String color = null;
for (int i = 100; i <= RandomPackageAPI.getAvailableMaxSoulGemSoulsHarvested; i += 100) {
if ((Math.addExact(soul1, soul2) >= i) && (Math.addExact(soul1, soul2) < i + 100)) {
color = ChatColor.translateAlternateColorCodes('&', RandomPackage.getPlaceholderConfig().getString("soul-gem." + i));
}
}
if (Math.addExact(soul1, soul2) > RandomPackage.getPlaceholderConfig().getInt("max-soul-gem-souls-harvested"))
{
player.sendMessage(ChatColor.translateAlternateColorCodes('&', RandomPackage.getMessagesConfig().getString("SoulGem.cannot-combine-above-max").replace("{MAX_SOULS}", RandomPackage.getPlaceholderConfig().getInt("max-soul-gem-souls-harvested")).replace("{PREFIX}", ChatColor.translateAlternateColorCodes('&', RandomPackage.getMessagesConfig().getString("prefix")))));
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1.0F, 2.0F);
}
else
{
itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', RandomPackage.getSoulConfig().getString("SoulGem.name").replace("%souls%", color + Math.addExact(soul1, soul2))));
lore.addAll(event.getCurrentItem().getItemMeta().getLore());
finish(event);
for (int i = 1; i <= 25; i++) {
player.getWorld().playEffect(player.getEyeLocation(), Effect.SPELL, 1);
}
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1.0F, 2.0F);
}
return;
}
}
@EventHandler
private void soulAdd(PlayerDeathEvent event)
{
if ((event.getEntity().getKiller() instanceof Player))
{
Player killer = event.getEntity().getKiller();
if ((killer.getInventory().getItemInMainHand() != null) && (!killer.getInventory().getItemInMainHand().getType().equals(Material.AIR)) && (killer.getInventory().getItemInMainHand().hasItemMeta()) && (killer.getInventory().getItemInMainHand().getItemMeta().hasLore()))
{
for (int i = 1; i <= 5; i++)
{
if (i == 1) {
this.type = "legendary";
} else if (i == 2) {
this.type = "ultimate";
} else if (i == 3) {
this.type = "elite";
} else if (i == 4) {
this.type = "unique";
} else if (i == 5) {
this.type = "simple";
}
for (int o = 0; o <= RandomPackageAPI.getAvailableMaxSoulGemSoulsHarvested; o++) {
if (killer.getInventory().getItemInMainHand().getItemMeta().getLore().contains(ChatColor.translateAlternateColorCodes('&', RandomPackage.getGivedpItemsConfig().getString("SoulTrackers." + this.type + ".tracked-lore").replace("%souls%", o))))
{
item = killer.getInventory().getItemInMainHand();
if (item.getItemMeta().getDisplayName() != null) {
itemMeta.setDisplayName(item.getItemMeta().getDisplayName());
}
lore.addAll(item.getItemMeta().getLore());
lore.remove(ChatColor.translateAlternateColorCodes('&', RandomPackage.getGivedpItemsConfig().getString("SoulTrackers." + this.type + ".tracked-lore").replace("%souls%", o)));
lore.add(ChatColor.translateAlternateColorCodes('&', RandomPackage.getGivedpItemsConfig().getString("SoulTrackers." + this.type + ".tracked-lore").replace("%souls%", Math.addExact(o, 1))));
if (lore.contains(RandomPackageAPI.whitescroll_apply_lore))
{
lore.remove(RandomPackageAPI.whitescroll_apply_lore);lore.add(RandomPackageAPI.whitescroll_apply_lore);
}
itemMeta.setLore(lore);
item.setItemMeta(itemMeta);
lore.clear();
killer.getInventory().setItemInMainHand(item);
killer.updateInventory();
return;
}
}
}
return;
}
return;
}
}
@EventHandler
private void soulMode(final PlayerInteractEvent event)
{
if ((event.getPlayer().getInventory().getItemInMainHand() != null) && (!event.getPlayer().getInventory().getItemInMainHand().getType().equals(Material.AIR)) && (event.getAction() != Action.LEFT_CLICK_AIR) && (event.getAction() != Action.LEFT_CLICK_BLOCK) && (event.getAction() != Action.PHYSICAL) &&
(event.getPlayer().getInventory().getItemInMainHand().hasItemMeta()) && (event.getPlayer().getInventory().getItemInMainHand().getItemMeta().hasDisplayName()) && (event.getPlayer().getInventory().getItemInMainHand().getItemMeta().hasLore()) && (event.getPlayer().getInventory().getItemInMainHand().getData().getData() == RandomPackage.getSoulConfig().getInt("SoulGem.item-data")))
{
int test = -1;
for (int i = 1; i <= RandomPackageAPI.getAvailableMaxSoulGemSoulsHarvested; i++)
{
if (ChatColor.stripColor(event.getPlayer().getInventory().getItemInMainHand().getItemMeta().getDisplayName()).equalsIgnoreCase(ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', RandomPackage.getSoulConfig().getString("SoulGem.name").replace("%souls%", i))))) {
test = i;
}
if ((test == -1) && (i == RandomPackageAPI.getAvailableMaxSoulGemSoulsHarvested)) {
return;
}
}
if (Material.getMaterial(RandomPackage.getSoulConfig().getString("SoulGem.item").toUpperCase()) == null)
{
event.getPlayer().sendMessage(RandomPackage.prefix + ChatColor.YELLOW + "Invalid material for Soul Gem. '" + ChatColor.RED + RandomPackage.getSoulConfig().getString("SoulGem.item") + ChatColor.YELLOW + "'");
event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.ENTITY_VILLAGER_NO, 1.0F, 2.0F);
return;
}
if (!soulMode.contains(event.getPlayer()))
{
if (event.getPlayer().getInventory().getItemInMainHand().getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.translateAlternateColorCodes('&', RandomPackage.getSoulConfig().getString("SoulGem.name").replace("%souls%", "0"))))
{
if (!this.spam.contains(event.getPlayer()))
{
this.spam.add(event.getPlayer());
event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.ENTITY_VILLAGER_NO, 1.0F, 1.0F);
for (int i = 0; i < RandomPackage.getMessagesConfig().getStringList("SoulMode.need-souls").size(); i++) {
event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', ((String)RandomPackage.getMessagesConfig().getStringList("SoulMode.need-souls").get(i)).replace("%prefix%", ChatColor.translateAlternateColorCodes('&', RandomPackage.getMessagesConfig().getString("prefix")))));
}
Bukkit.getScheduler().scheduleSyncDelayedTask(RandomPackage.getPlugin(), new Runnable()
{
public void run()
{
soulEvents.this.spam.remove(event.getPlayer());
}
}, 20L);
return;
}
return;
}
soulMode.add(event.getPlayer());
for (int i = 0; i < RandomPackage.getMessagesConfig().getStringList("SoulMode.activate").size(); i++) {
event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', ((String)RandomPackage.getMessagesConfig().getStringList("SoulMode.activate").get(i)).replace("%prefix%", ChatColor.translateAlternateColorCodes('&', RandomPackage.getMessagesConfig().getString("prefix")))));
}
}
else
{
soulMode.remove(event.getPlayer());
for (int i = 0; i < RandomPackage.getMessagesConfig().getStringList("SoulMode.deactivate").size(); i++) {
event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', ((String)RandomPackage.getMessagesConfig().getStringList("SoulMode.deactivate").get(i)).replace("%prefix%", ChatColor.translateAlternateColorCodes('&', RandomPackage.getMessagesConfig().getString("prefix")))));
}
}
return;
}
}
@EventHandler
private void soulModeTimings(PluginEnableEvent event)
{
if (Material.getMaterial(RandomPackage.getSoulConfig().getString("SoulGem.item").toUpperCase()) != null)
{
int data = 0;
if (RandomPackage.getSoulConfig().get("SoulGem.item-data") != null) {
data = RandomPackage.getSoulConfig().getInt("SoulGem.item-data");
} else {
data = 0;
}
soulModeItem = new ItemStack(Material.getMaterial(RandomPackage.getSoulConfig().getString("SoulGem.item").toUpperCase()), 1, (byte)data);
}
Bukkit.getScheduler().scheduleSyncRepeatingTask(RandomPackage.getPlugin(), new Runnable()
{
public void run()
{
for (int i = 0; i < soulEvents.soulMode.size(); i++)
{
if (!Bukkit.getPlayer(((Player)soulEvents.soulMode.get(i)).getName()).getWorld().getGameRuleValue("sendCommandFeedback").equals(Boolean.valueOf(true))) {
Bukkit.getPlayer(((Player)soulEvents.soulMode.get(i)).getName()).getWorld().setGameRuleValue("sendCommandFeedback", "false");
}
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "execute " + Bukkit.getPlayer(((Player)soulEvents.soulMode.get(i)).getName()).getName() + " ~ ~ ~ particle enchantmenttable " + Bukkit.getPlayer(((Player)soulEvents.soulMode.get(i)).getName()).getLocation().getX() + " " + Bukkit.getPlayer(((Player)soulEvents.soulMode.get(i)).getName()).getLocation().getY() + " " + Bukkit.getPlayer(((Player)soulEvents.soulMode.get(i)).getName()).getLocation().getZ() + " .5 .5 .5 1 100 1");
}
}
}, 0L, 5L);
Bukkit.getScheduler().scheduleSyncRepeatingTask(RandomPackage.getPlugin(), new Runnable()
{
public void run()
{
for (int i = 0; i < soulEvents.soulMode.size(); i++) {
for (int o = 0; o < Bukkit.getPlayer(((Player)soulEvents.soulMode.get(i)).getName()).getInventory().getSize(); o++) {
if ((Bukkit.getPlayer(((Player)soulEvents.soulMode.get(i)).getName()).getInventory().getItem(o) != null) && (!Bukkit.getPlayer(((Player)soulEvents.soulMode.get(i)).getName()).getInventory().getItem(o).getType().equals(Material.AIR)) &&
(Bukkit.getPlayer(((Player)soulEvents.soulMode.get(i)).getName()).getInventory().getItem(o).hasItemMeta()) && (Bukkit.getPlayer(((Player)soulEvents.soulMode.get(i)).getName()).getInventory().getItem(o).getItemMeta().hasDisplayName()) &&
(Bukkit.getPlayer(((Player)soulEvents.soulMode.get(i)).getName()).getInventory().getItem(o).getType().equals(soulEvents.soulModeItem.getType())) &&
(Bukkit.getPlayer(((Player)soulEvents.soulMode.get(i)).getName()).getInventory().getItem(o).getData().equals(soulEvents.soulModeItem.getData())))
{
if (ChatColor.stripColor(Bukkit.getPlayer(((Player)soulEvents.soulMode.get(i)).getName()).getInventory().getItem(o).getItemMeta().getDisplayName()).equalsIgnoreCase(ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', RandomPackage.getSoulConfig().getString("SoulGem.name").replace("%souls%", "0")))))
{
for (int p = 0; p < RandomPackage.getMessagesConfig().getStringList("SoulMode.out-of-souls").size(); p++) {
Bukkit.getPlayer(((Player)soulEvents.soulMode.get(i)).getName()).sendMessage(ChatColor.translateAlternateColorCodes('&', ((String)RandomPackage.getMessagesConfig().getStringList("SoulMode.out-of-souls").get(p)).replace("%prefix%", ChatColor.translateAlternateColorCodes('&', RandomPackage.getMessagesConfig().getString("prefix")))));
}
soulEvents.soulMode.remove(i);
return;
}
for (int p = 1; p <= RandomPackageAPI.getAvailableMaxSoulGemSoulsHarvested; p++) {
if (ChatColor.stripColor(Bukkit.getPlayer(((Player)soulEvents.soulMode.get(i)).getName()).getInventory().getItem(o).getItemMeta().getDisplayName()).equalsIgnoreCase(ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', RandomPackage.getSoulConfig().getString("SoulGem.name").replace("%souls%", p)))))
{
soulEvents.item = Bukkit.getPlayer(((Player)soulEvents.soulMode.get(i)).getName()).getInventory().getItem(o);
String color = "";
for (int z = 100; z <= RandomPackageAPI.getAvailableMaxSoulGemSoulsHarvested; z += 100) {
if ((Math.subtractExact(p, 1) >= z) && (Math.subtractExact(p, 1) < z + 100)) {
color = RandomPackage.getPlaceholderConfig().getString("soul-gem." + z);
}
}
soulEvents.itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', RandomPackage.getSoulConfig().getString("SoulGem.name").replace("%souls%", color + Math.subtractExact(p, 1))));
if (soulEvents.item.getItemMeta().hasLore()) {
soulEvents.lore.addAll(soulEvents.item.getItemMeta().getLore());
}
soulEvents.itemMeta.setLore(soulEvents.lore);
soulEvents.item.setItemMeta(soulEvents.itemMeta);
soulEvents.lore.clear();
soulEvents.soulGemSoulAmount.remove(Bukkit.getPlayer(((Player)soulEvents.soulMode.get(i)).getName()));
soulEvents.soulGemSoulAmount.put(Bukkit.getPlayer(((Player)soulEvents.soulMode.get(i)).getName()), Integer.valueOf(p));
Bukkit.getPlayer(((Player)soulEvents.soulMode.get(i)).getName()).getInventory().setItem(o, soulEvents.item);
if ((RandomPackage.getMessagesConfig().getBoolean("SoulMode.soul-drain-message")) && (
(Integer.toString(Math.subtractExact(p, 1)).endsWith("00")) || (Integer.toString(Math.subtractExact(p, 1)).endsWith("10")) || (Integer.toString(Math.subtractExact(p, 1)).endsWith("20")) ||
(Integer.toString(Math.subtractExact(p, 1)).endsWith("40")) || (Integer.toString(Math.subtractExact(p, 1)).endsWith("60")) || (Integer.toString(Math.subtractExact(p, 1)).endsWith("80")))) {
for (int q = 0; q < RandomPackage.getMessagesConfig().getStringList("SoulMode.soul-drain-update").size(); q++) {
Bukkit.getPlayer(((Player)soulEvents.soulMode.get(i)).getName()).sendMessage(ChatColor.translateAlternateColorCodes('&', ((String)RandomPackage.getMessagesConfig().getStringList("SoulMode.soul-drain-update").get(q)).replace("%souls%", Math.subtractExact(p, 1)).replace("%prefix%", ChatColor.translateAlternateColorCodes('&', RandomPackage.getMessagesConfig().getString("prefix")))));
}
}
return;
}
}
return;
}
}
}
}
}, 0L, 20L);
}
public static void finish(InventoryClickEvent event)
{
for (int i = 1; i <= 15; i++) {
if ((item.hasItemMeta()) && (item.getItemMeta().hasDisplayName()) && (item.getItemMeta().getDisplayName().contains(RandomPackageAPI.transmog.replace("%loreCount%", i)))) {
itemMeta.setDisplayName(item.getItemMeta().getDisplayName().replace(RandomPackageAPI.transmog.replace("%loreCount%", i), Math.addExact(i, 1)));
}
}
itemMeta.setLore(lore);
item.setItemMeta(itemMeta);
event.setCurrentItem(item);
if (event.getCursor().getAmount() > 1) {
event.getCursor().setAmount(event.getCursor().getAmount() - 1);
} else {
event.setCursor(new ItemStack(Material.AIR));
}
event.setCancelled(true);
((Player)event.getWhoClicked()).updateInventory();
lore.clear();
}
}
答案 0 :(得分:-1)
要解决您的错误,您可以执行以下操作:
replace方法只接受(charSequence toReplace,charSequence replacement)作为参数。您可以轻松地在方法中添加要替换的int,执行以下操作:
int i = 0;
String iString = String.valueOf(i);
String.valueOf(int i)将int i转换为String形式,使其成为CharSequence。这样你就可以将replacemethod与你的整数一起使用。