mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2025-12-29 03:49:07 +00:00
回收商店
This commit is contained in:
@@ -20,7 +20,9 @@ package net.momirealms.customfishing;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.ProtocolManager;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
import net.momirealms.customfishing.commands.FishingBagCommand;
|
||||
import net.momirealms.customfishing.commands.PluginCommand;
|
||||
import net.momirealms.customfishing.commands.SellFishCommand;
|
||||
import net.momirealms.customfishing.helper.LibraryLoader;
|
||||
import net.momirealms.customfishing.manager.*;
|
||||
import net.momirealms.customfishing.util.AdventureUtil;
|
||||
@@ -43,6 +45,7 @@ public final class CustomFishing extends JavaPlugin {
|
||||
private LayoutManager layoutManager;
|
||||
private DataManager dataManager;
|
||||
private TotemManager totemManager;
|
||||
private SellManager sellManager;
|
||||
|
||||
// _ooOoo_
|
||||
// o8888888o
|
||||
@@ -71,6 +74,7 @@ public final class CustomFishing extends JavaPlugin {
|
||||
LibraryLoader.load("org.apache.commons","commons-pool2","2.11.1","https://repo.maven.apache.org/maven2/");
|
||||
LibraryLoader.load("dev.dejvokep","boosted-yaml","1.3","https://repo.maven.apache.org/maven2/");
|
||||
LibraryLoader.load("com.zaxxer","HikariCP","5.0.1","https://repo.maven.apache.org/maven2/");
|
||||
LibraryLoader.load("net.objecthunter","exp4j","0.4.8","https://repo.maven.apache.org/maven2/");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -85,23 +89,43 @@ public final class CustomFishing extends JavaPlugin {
|
||||
this.layoutManager = new LayoutManager();
|
||||
this.dataManager = new DataManager();
|
||||
this.totemManager = new TotemManager();
|
||||
this.sellManager = new SellManager();
|
||||
ConfigUtil.reload();
|
||||
registerCommands();
|
||||
|
||||
PluginCommand pluginCommand = new PluginCommand();
|
||||
Bukkit.getPluginCommand("customfishing").setExecutor(pluginCommand);
|
||||
Bukkit.getPluginCommand("customfishing").setTabCompleter(pluginCommand);
|
||||
AdventureUtil.consoleMessage("[CustomFishing] Plugin Enabled!");
|
||||
new Metrics(this, 16648);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
this.fishingManager.unload();
|
||||
this.integrationManager.unload();
|
||||
this.competitionManager.unload();
|
||||
this.bonusManager.unload();
|
||||
this.lootManager.unload();
|
||||
this.layoutManager.unload();
|
||||
this.dataManager.unload();
|
||||
this.totemManager.unload();
|
||||
this.sellManager.unload();
|
||||
if (adventure != null) {
|
||||
adventure.close();
|
||||
adventure = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void registerCommands() {
|
||||
PluginCommand pluginCommand = new PluginCommand();
|
||||
Bukkit.getPluginCommand("customfishing").setExecutor(pluginCommand);
|
||||
Bukkit.getPluginCommand("customfishing").setTabCompleter(pluginCommand);
|
||||
FishingBagCommand fishingBagCommand = new FishingBagCommand();
|
||||
Bukkit.getPluginCommand("fishingbag").setExecutor(fishingBagCommand);
|
||||
Bukkit.getPluginCommand("fishingbag").setTabCompleter(fishingBagCommand);
|
||||
SellFishCommand sellFishCommand = new SellFishCommand();
|
||||
Bukkit.getPluginCommand("sellfish").setExecutor(sellFishCommand);
|
||||
Bukkit.getPluginCommand("sellfish").setTabCompleter(sellFishCommand);
|
||||
}
|
||||
|
||||
public IntegrationManager getIntegrationManager() {
|
||||
return integrationManager;
|
||||
}
|
||||
@@ -133,4 +157,8 @@ public final class CustomFishing extends JavaPlugin {
|
||||
public TotemManager getTotemManager() {
|
||||
return totemManager;
|
||||
}
|
||||
|
||||
public SellManager getSellManager() {
|
||||
return sellManager;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
package net.momirealms.customfishing.commands;
|
||||
|
||||
import net.momirealms.customfishing.commands.subcmd.OpenCommand;
|
||||
import net.momirealms.customfishing.manager.MessageManager;
|
||||
import net.momirealms.customfishing.util.AdventureUtil;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class FishingBagCommand implements TabExecutor {
|
||||
|
||||
private final Map<String, SubCommand> subCommandMap;
|
||||
|
||||
public FishingBagCommand() {
|
||||
subCommandMap = new ConcurrentHashMap<>();
|
||||
regDefaultSubCommands();
|
||||
}
|
||||
|
||||
private void regDefaultSubCommands() {
|
||||
regSubCommand(OpenCommand.INSTANCE);
|
||||
}
|
||||
|
||||
public void regSubCommand(SubCommand executor) {
|
||||
subCommandMap.put(executor.getSubCommand(), executor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
List<String> argList = Arrays.asList(args);
|
||||
if (argList.size() < 1) {
|
||||
AdventureUtil.sendMessage(sender, MessageManager.prefix + MessageManager.nonArgs);
|
||||
return true;
|
||||
}
|
||||
SubCommand subCommand = subCommandMap.get(argList.get(0));
|
||||
if (subCommand != null)
|
||||
return subCommand.onCommand(sender, argList.subList(1, argList.size()));
|
||||
else {
|
||||
AdventureUtil.sendMessage(sender, MessageManager.prefix + MessageManager.unavailableArgs);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||
List<String> argList = Arrays.asList(args);
|
||||
if (argList.size() <= 1) {
|
||||
List<String> returnList = new ArrayList<>(subCommandMap.keySet());
|
||||
returnList.removeIf(str -> !str.startsWith(args[0]));
|
||||
return returnList;
|
||||
}
|
||||
SubCommand subCommand = subCommandMap.get(argList.get(0));
|
||||
if (subCommand != null)
|
||||
return subCommand.onTabComplete(sender, argList.subList(1, argList.size()));
|
||||
else
|
||||
return Collections.singletonList("");
|
||||
}
|
||||
|
||||
public Map<String, SubCommand> getSubCommandMap() {
|
||||
return subCommandMap;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package net.momirealms.customfishing.commands;
|
||||
|
||||
import net.momirealms.customfishing.CustomFishing;
|
||||
import net.momirealms.customfishing.manager.MessageManager;
|
||||
import net.momirealms.customfishing.util.AdventureUtil;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SellFishCommand implements TabExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player player)) {
|
||||
AdventureUtil.sendMessage(sender, MessageManager.prefix + MessageManager.noConsole);
|
||||
return true;
|
||||
}
|
||||
CustomFishing.plugin.getSellManager().openGuiForPlayer(player);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package net.momirealms.customfishing.commands.subcmd;
|
||||
|
||||
import net.momirealms.customfishing.commands.AbstractSubCommand;
|
||||
import net.momirealms.customfishing.commands.SubCommand;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class OpenCommand extends AbstractSubCommand {
|
||||
|
||||
public static final SubCommand INSTANCE = new OpenCommand();
|
||||
|
||||
private OpenCommand() {
|
||||
super("open", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, List<String> args) {
|
||||
if (args.size() < 1) {
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package net.momirealms.customfishing.data;
|
||||
|
||||
public class PlayerData {
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package net.momirealms.customfishing.integration;
|
||||
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.momirealms.customfishing.CustomFishing;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
public class VaultHook {
|
||||
|
||||
public static Economy economy;
|
||||
|
||||
public static boolean initialize() {
|
||||
RegisteredServiceProvider<Economy> rsp = CustomFishing.plugin.getServer().getServicesManager().getRegistration(Economy.class);
|
||||
if (rsp == null) {
|
||||
return false;
|
||||
}
|
||||
economy = rsp.getProvider();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import net.momirealms.customfishing.util.ConfigUtil;
|
||||
import net.momirealms.customfishing.util.ItemStackUtil;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -184,7 +185,7 @@ public class BonusManager extends Function {
|
||||
AdventureUtil.consoleMessage("[CustomFishing] Loaded <green>" + RODITEMS.size() + " <gray>rods");
|
||||
}
|
||||
|
||||
public static void setItemProperties(YamlConfiguration config, String key, Item item) {
|
||||
public static void setItemProperties(ConfigurationSection config, String key, Item item) {
|
||||
item.setUnbreakable(config.getBoolean(key + ".unbreakable", false));
|
||||
if (config.contains(key + ".display.lore")) item.setLore(config.getStringList(key + ".display.lore"));
|
||||
if (config.contains(key + ".display.name")) item.setName(config.getString(key + ".display.name"));
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package net.momirealms.customfishing.manager;
|
||||
|
||||
import net.momirealms.customfishing.integration.VaultHook;
|
||||
import net.momirealms.customfishing.util.AdventureUtil;
|
||||
import net.momirealms.customfishing.util.ConfigUtil;
|
||||
import net.momirealms.customfishing.util.JedisUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -25,7 +27,6 @@ public class ConfigManager {
|
||||
public static boolean needRodForLoots;
|
||||
public static boolean needRodToFish;
|
||||
public static boolean rodLoseDurability;
|
||||
public static int fishFinderCoolDown;
|
||||
public static boolean enableCompetition;
|
||||
public static boolean disableJobsXp;
|
||||
public static boolean convertMMOItems;
|
||||
@@ -47,6 +48,9 @@ public class ConfigManager {
|
||||
public static boolean useRedis;
|
||||
public static int lavaMaxTime;
|
||||
public static int lavaMinTime;
|
||||
public static boolean addTagToFish;
|
||||
public static boolean logEarning;
|
||||
public static boolean vaultHook;
|
||||
|
||||
public static void load() {
|
||||
ConfigUtil.update("config.yml");
|
||||
@@ -79,13 +83,14 @@ public class ConfigManager {
|
||||
needRodForLoots = config.getBoolean("mechanics.need-special-rod.for-loots", false);
|
||||
needRodToFish = config.getBoolean("mechanics.need-special-rod.to-fish", false);
|
||||
rodLoseDurability = config.getBoolean("mechanics.rod-lose-durability", true);
|
||||
fishFinderCoolDown = config.getInt("mechanics.fishfinder-cooldown", 3000);
|
||||
enableCompetition = config.getBoolean("mechanics.fishing-competition.enable", true);
|
||||
|
||||
priority = config.getString("other-settings.event-priority", "NORMAL").toUpperCase();
|
||||
disableJobsXp = config.getBoolean("other-settings.disable-JobsReborn-fishing-exp", false);
|
||||
preventPickUp = config.getBoolean("other-settings.prevent-other-players-pick-up-loot", false);
|
||||
convertMMOItems = config.getBoolean("other-settings.convert-MMOItems-rods", false);
|
||||
logEarning = config.getBoolean("other-settings.log-earnings", true);
|
||||
vaultHook = config.getBoolean("integration.Vault", true);
|
||||
|
||||
successTitle = config.getStringList("titles.success.title").toArray(new String[0]);
|
||||
successSubTitle = config.getStringList("titles.success.subtitle").toArray(new String[0]);
|
||||
@@ -99,8 +104,10 @@ public class ConfigManager {
|
||||
failureFadeStay = config.getInt("titles.failure.fade.stay", 30) * 50;
|
||||
failureFadeOut = config.getInt("titles.failure.fade.out", 10) * 50;
|
||||
|
||||
lavaMinTime = config.getInt("mechanics.lava-fishing.min-time", 100);
|
||||
lavaMaxTime = config.getInt("mechanics.lava-fishing.max-time", 600) - lavaMinTime;
|
||||
lavaMinTime = config.getInt("mechanics.lava-fishing.min-wait-time", 100);
|
||||
lavaMaxTime = config.getInt("mechanics.lava-fishing.max-wait-time", 600) - lavaMinTime;
|
||||
|
||||
addTagToFish = config.getBoolean("mechanics.fishing-bag.can-store-fish", false);
|
||||
|
||||
useRedis = false;
|
||||
if (enableCompetition && config.getBoolean("mechanics.fishing-competition.redis", false)) {
|
||||
@@ -108,6 +115,13 @@ public class ConfigManager {
|
||||
JedisUtil.initializeRedis(configuration);
|
||||
useRedis = true;
|
||||
}
|
||||
|
||||
if (vaultHook) {
|
||||
if (!VaultHook.initialize()) {
|
||||
vaultHook = false;
|
||||
AdventureUtil.consoleMessage("<red>[CustomFishing] Failed to hook into Vault!");
|
||||
}
|
||||
}
|
||||
}
|
||||
public static List<World> getWorldsList() {
|
||||
if (whiteOrBlack) {
|
||||
|
||||
@@ -18,7 +18,6 @@ import net.momirealms.customfishing.object.Function;
|
||||
import net.momirealms.customfishing.object.action.ActionInterface;
|
||||
import net.momirealms.customfishing.object.fishing.*;
|
||||
import net.momirealms.customfishing.object.loot.DroppedItem;
|
||||
import net.momirealms.customfishing.object.fishing.BobberCheckTask;
|
||||
import net.momirealms.customfishing.object.loot.Loot;
|
||||
import net.momirealms.customfishing.object.loot.Mob;
|
||||
import net.momirealms.customfishing.object.requirements.RequirementInterface;
|
||||
@@ -395,6 +394,9 @@ public class FishingManager extends Function {
|
||||
Competition.currentCompetition.getBossBarManager().tryJoin(player);
|
||||
}
|
||||
|
||||
ItemStackUtil.addExtraMeta(drop, droppedItem);
|
||||
if (ConfigManager.addTagToFish) ItemStackUtil.addIdentifier(drop, "loot", droppedItem.getKey());
|
||||
|
||||
dropItem(player, location, fishResultEvent.isDouble(), drop);
|
||||
for (ActionInterface action : droppedItem.getSuccessActions())
|
||||
action.doOn(player, null);
|
||||
@@ -753,7 +755,7 @@ public class FishingManager extends Function {
|
||||
}
|
||||
|
||||
private void useFinder(Player player) {
|
||||
if (isCoolDown(player, ConfigManager.fishFinderCoolDown)) return;
|
||||
if (isCoolDown(player, 1000)) return;
|
||||
List<Loot> possibleLoots = getPossibleWaterLootList(new FishingCondition(player.getLocation(), player), true);
|
||||
|
||||
FishFinderEvent fishFinderEvent = new FishFinderEvent(player, possibleLoots);
|
||||
|
||||
@@ -127,6 +127,18 @@ public class LootManager extends Function {
|
||||
if (config.contains(key + ".nick")) loot.setNick(config.getString(key + ".nick"));
|
||||
else loot.setNick(ChatColor.stripColor(config.getString(key + ".display.name", key)));
|
||||
loot.setRandomDurability(config.getBoolean(key + ".random-durability", false));
|
||||
if (config.contains(key + ".size")) {
|
||||
String[] size = StringUtils.split(config.getString(key + ".size", "1~10"), "~");
|
||||
if (size.length != 2) {
|
||||
AdventureUtil.consoleMessage("<red>[CustomFishing] Wrong size found at " + key);
|
||||
continue;
|
||||
}
|
||||
loot.setSize(size);
|
||||
}
|
||||
if (config.contains(key + ".price")) {
|
||||
loot.setBasicPrice((float) config.getDouble(key + ".price.basic", 0));
|
||||
loot.setSizeBonus((float) config.getDouble(key + ".price.bonus", 0));
|
||||
}
|
||||
if (config.contains(key + ".random-enchantments")){
|
||||
List<LeveledEnchantment> randomEnchants = new ArrayList<>();
|
||||
config.getConfigurationSection(key + ".random-enchantments").getValues(false).forEach((order, enchant) -> {
|
||||
|
||||
@@ -1,4 +1,304 @@
|
||||
package net.momirealms.customfishing.manager;
|
||||
|
||||
public class SellManager {
|
||||
import de.tr7zw.changeme.nbtapi.NBTCompound;
|
||||
import de.tr7zw.changeme.nbtapi.NBTItem;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
import net.momirealms.customfishing.CustomFishing;
|
||||
import net.momirealms.customfishing.integration.VaultHook;
|
||||
import net.momirealms.customfishing.object.Function;
|
||||
import net.momirealms.customfishing.object.loot.Item;
|
||||
import net.momirealms.customfishing.object.sell.ContainerPacketListener;
|
||||
import net.momirealms.customfishing.object.sell.InventoryListener;
|
||||
import net.momirealms.customfishing.util.AdventureUtil;
|
||||
import net.momirealms.customfishing.util.ConfigUtil;
|
||||
import net.momirealms.customfishing.util.ItemStackUtil;
|
||||
import net.objecthunter.exp4j.Expression;
|
||||
import net.objecthunter.exp4j.ExpressionBuilder;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.inventory.*;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class SellManager extends Function {
|
||||
|
||||
private final ContainerPacketListener containerPacketListener;
|
||||
private final InventoryListener inventoryListener;
|
||||
public static String formula;
|
||||
public static String title;
|
||||
public static int guiSize;
|
||||
public static String msgNotification;
|
||||
public static String actionbarNotification;
|
||||
public static String titleNotification;
|
||||
public static String subtitleNotification;
|
||||
public static int titleIn;
|
||||
public static int titleStay;
|
||||
public static int titleOut;
|
||||
public static String[] commands;
|
||||
public static Item sellIcon;
|
||||
public static Item denyIcon;
|
||||
public static Key closeKey;
|
||||
public static Key openKey;
|
||||
public static Key successKey;
|
||||
public static Key denyKey;
|
||||
public static Sound.Source soundSource;
|
||||
public static HashMap<Integer, ItemStack> guiItems;
|
||||
public static HashSet<Integer> functionIconSlots;
|
||||
public static HashMap<Material, Float> vanillaPrices = new HashMap<>();
|
||||
private final HashMap<Player, Inventory> inventoryCache;
|
||||
private final HashMap<Player, Long> coolDown;
|
||||
|
||||
public SellManager() {
|
||||
this.containerPacketListener = new ContainerPacketListener();
|
||||
this.inventoryListener = new InventoryListener(this);
|
||||
this.inventoryCache = new HashMap<>();
|
||||
this.coolDown = new HashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
loadConfig();
|
||||
CustomFishing.protocolManager.addPacketListener(containerPacketListener);
|
||||
Bukkit.getPluginManager().registerEvents(inventoryListener, CustomFishing.plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unload() {
|
||||
for (Player player : this.inventoryCache.keySet()) {
|
||||
player.closeInventory();
|
||||
}
|
||||
this.inventoryCache.clear();
|
||||
CustomFishing.protocolManager.removePacketListener(containerPacketListener);
|
||||
HandlerList.unregisterAll(inventoryListener);
|
||||
}
|
||||
|
||||
private void loadConfig() {
|
||||
functionIconSlots = new HashSet<>();
|
||||
guiItems = new HashMap<>();
|
||||
vanillaPrices = new HashMap<>();
|
||||
YamlConfiguration config = ConfigUtil.getConfig("sell-fish.yml");
|
||||
formula = config.getString("price-formula", "{base} + {bonus} * {size}");
|
||||
title = config.getString("container-title");
|
||||
guiSize = config.getInt("rows") * 9;
|
||||
openKey = config.contains("sounds.open") ? Key.key(config.getString("sounds.open")) : null;
|
||||
closeKey = config.contains("sounds.close") ? Key.key(config.getString("sounds.close")) : null;
|
||||
successKey = config.contains("sounds.success") ? Key.key(config.getString("sounds.success")) : null;
|
||||
denyKey = config.contains("sounds.deny") ? Key.key(config.getString("sounds.deny")) : null;
|
||||
soundSource = Sound.Source.valueOf(config.getString("sounds.type","player").toUpperCase());
|
||||
if (config.contains("decorative-icons")){
|
||||
config.getConfigurationSection("decorative-icons").getKeys(false).forEach(key -> {
|
||||
Item item = new Item(Material.valueOf(config.getString("decorative-icons." + key + ".material", "PAPER").toUpperCase()));
|
||||
if (config.contains("decorative-icons." + key + ".display.name")) item.setName(config.getString("decorative-icons." + key + ".display.name"));
|
||||
if (config.contains("decorative-icons." + key + ".display.lore")) item.setLore(config.getStringList("decorative-icons." + key + ".display.lore"));
|
||||
if (config.contains("decorative-icons." + key + ".custom-model-data")) item.setCustomModelData(config.getInt("decorative-icons." + key + ".custom-model-data"));
|
||||
ItemStack itemStack = ItemStackUtil.getFromItem(item);
|
||||
for (int slot : config.getIntegerList("decorative-icons." + key + ".slot")) {
|
||||
guiItems.put(slot - 1, itemStack);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
sellIcon = new Item(Material.valueOf(config.getString("functional-icons.sell.material", "PAPER").toUpperCase()));
|
||||
if (config.contains("functional-icons.sell.display.name")) sellIcon.setName(config.getString("functional-icons.sell.display.name"));
|
||||
if (config.contains("functional-icons.sell.display.lore")) sellIcon.setLore(config.getStringList("functional-icons.sell.display.lore"));
|
||||
if (config.contains("functional-icons.sell.custom-model-data")) sellIcon.setCustomModelData(config.getInt("functional-icons.sell.custom-model-data"));
|
||||
denyIcon = new Item(Material.valueOf(config.getString("functional-icons.deny.material", "PAPER").toUpperCase()));
|
||||
if (config.contains("functional-icons.deny.display.name")) denyIcon.setName(config.getString("functional-icons.deny.display.name"));
|
||||
if (config.contains("functional-icons.deny.display.lore")) denyIcon.setLore(config.getStringList("functional-icons.deny.display.lore"));
|
||||
if (config.contains("functional-icons.deny.custom-model-data")) denyIcon.setCustomModelData(config.getInt("functional-icons.deny.custom-model-data"));
|
||||
|
||||
for (int slot : config.getIntegerList("functional-icons.slots")) {
|
||||
guiItems.put(slot - 1, ItemStackUtil.getFromItem(sellIcon));
|
||||
functionIconSlots.add(slot - 1);
|
||||
}
|
||||
|
||||
if (config.getBoolean("actions.message.enable", false)) {
|
||||
msgNotification = config.getString("actions.message.text");
|
||||
} else msgNotification = null;
|
||||
if (config.getBoolean("actions.actionbar.enable", false)) {
|
||||
actionbarNotification = config.getString("actions.actionbar.text");
|
||||
} else actionbarNotification = null;
|
||||
if (config.getBoolean("actions.title.enable", false)) {
|
||||
titleNotification = config.getString("actions.title.title");
|
||||
subtitleNotification = config.getString("actions.title.subtitle");
|
||||
titleIn = config.getInt("actions.title.in");
|
||||
titleStay = config.getInt("actions.title.stay");
|
||||
titleOut = config.getInt("actions.title.out");
|
||||
} else actionbarNotification = null;
|
||||
if (config.getBoolean("actions.commands.enable")) {
|
||||
commands = config.getStringList("actions.commands.value").toArray(new String[0]);
|
||||
} else commands = null;
|
||||
|
||||
ConfigurationSection configurationSection = config.getConfigurationSection("vanilla-item-price");
|
||||
if (configurationSection != null) {
|
||||
for (String vanilla : configurationSection.getKeys(false)) {
|
||||
vanillaPrices.put(Material.valueOf(vanilla.toUpperCase()), (float) configurationSection.getDouble(vanilla));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void openGuiForPlayer(Player player) {
|
||||
player.closeInventory();
|
||||
Inventory inventory = Bukkit.createInventory(player, guiSize, "{CustomFishing}");
|
||||
for (Map.Entry<Integer, ItemStack> entry : guiItems.entrySet()) {
|
||||
inventory.setItem(entry.getKey(), entry.getValue());
|
||||
}
|
||||
inventoryCache.put(player, inventory);
|
||||
player.openInventory(inventory);
|
||||
if (openKey != null) AdventureUtil.playerSound(player, soundSource, openKey, 1, 1);
|
||||
}
|
||||
|
||||
public void onOpen(InventoryOpenEvent event) {
|
||||
final Player player = (Player) event.getPlayer();
|
||||
Inventory inventory = inventoryCache.get(player);
|
||||
if (inventory == null) return;
|
||||
if (inventory == event.getInventory()) {
|
||||
for (int slot : functionIconSlots) {
|
||||
inventory.setItem(slot, ItemStackUtil.getFromItem(sellIcon.cloneWithPrice(getTotalPrice(getPlayerItems(inventory)))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onClick(InventoryClickEvent event) {
|
||||
final Player player = (Player) event.getView().getPlayer();
|
||||
Inventory inventory = inventoryCache.get(player);
|
||||
if (inventory == null) return;
|
||||
boolean update = true;
|
||||
if (inventory == event.getClickedInventory()) {
|
||||
int clickedSlot = event.getSlot();
|
||||
if (guiItems.containsKey(clickedSlot)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
if (functionIconSlots.contains(clickedSlot)) {
|
||||
List<ItemStack> playerItems = getPlayerItems(inventory);
|
||||
float totalPrice = getTotalPrice(playerItems);
|
||||
if (totalPrice > 0) {
|
||||
for (ItemStack playerItem : playerItems) {
|
||||
if (playerItem == null || playerItem.getType() == Material.AIR) continue;
|
||||
if (getSingleItemPrice(playerItem) == 0) continue;
|
||||
playerItem.setAmount(0);
|
||||
}
|
||||
doActions(player, totalPrice);
|
||||
inventory.close();
|
||||
}
|
||||
else {
|
||||
for (int slot : functionIconSlots) {
|
||||
inventory.setItem(slot, ItemStackUtil.getFromItem(denyIcon));
|
||||
}
|
||||
update = false;
|
||||
if (denyKey != null) AdventureUtil.playerSound(player, soundSource, denyKey, 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (update && !isCoolDown(player, 1000)) {
|
||||
Bukkit.getScheduler().runTaskLater(CustomFishing.plugin, () -> {
|
||||
ItemStack icon = ItemStackUtil.getFromItem(sellIcon.cloneWithPrice(getTotalPrice(getPlayerItems(inventory))));
|
||||
for (int slot : functionIconSlots) {
|
||||
inventory.setItem(slot, icon);
|
||||
}
|
||||
}, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isCoolDown(Player player, long delay) {
|
||||
long time = System.currentTimeMillis();
|
||||
if (time - (coolDown.getOrDefault(player, time - delay)) < delay) return true;
|
||||
coolDown.put(player, time);
|
||||
return false;
|
||||
}
|
||||
|
||||
public void onClose(InventoryCloseEvent event) {
|
||||
final Player player = (Player) event.getPlayer();
|
||||
Inventory inventory = inventoryCache.remove(player);
|
||||
if (inventory == null) return;
|
||||
coolDown.remove(player);
|
||||
if (event.getInventory() == inventory) {
|
||||
returnItems(getPlayerItems(event.getInventory()), player);
|
||||
if (closeKey != null) AdventureUtil.playerSound(player, soundSource, closeKey, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
private List<ItemStack> getPlayerItems(Inventory inventory) {
|
||||
List<ItemStack> items = new ArrayList<>();
|
||||
for (int i = 0; i < guiSize; i++) {
|
||||
if (guiItems.containsKey(i)) continue;
|
||||
items.add(inventory.getItem(i));
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
private void returnItems(List<ItemStack> itemStacks, Player player){
|
||||
Inventory inventory = player.getInventory();
|
||||
for (ItemStack stack : itemStacks) {
|
||||
if (stack == null || stack.getType() == Material.AIR) continue;
|
||||
inventory.addItem(stack);
|
||||
}
|
||||
}
|
||||
|
||||
private float getTotalPrice(List<ItemStack> itemStacks){
|
||||
float totalPrice = 0;
|
||||
for (ItemStack stack : itemStacks) {
|
||||
if (stack == null || stack.getType() == Material.AIR) continue;
|
||||
float price = getSingleItemPrice(stack);
|
||||
price *= stack.getAmount();
|
||||
totalPrice += price;
|
||||
}
|
||||
return totalPrice;
|
||||
}
|
||||
|
||||
private float getSingleItemPrice(ItemStack itemStack) {
|
||||
NBTItem nbtItem = new NBTItem(itemStack);
|
||||
NBTCompound fishMeta = nbtItem.getCompound("FishMeta");
|
||||
float price = 0;
|
||||
if (fishMeta != null) {
|
||||
float base = fishMeta.getFloat("base");
|
||||
float bonus = fishMeta.getFloat("bonus");
|
||||
float size = fishMeta.getFloat("size");
|
||||
Expression expression = new ExpressionBuilder(formula)
|
||||
.variables("base", "bonus","size")
|
||||
.build()
|
||||
.setVariable("base", base)
|
||||
.setVariable("bonus", bonus)
|
||||
.setVariable("size", size);
|
||||
price = (float) expression.evaluate();
|
||||
}
|
||||
if (price == 0) {
|
||||
price = Optional.ofNullable(vanillaPrices.get(itemStack.getType())).orElse(0f);
|
||||
}
|
||||
return price;
|
||||
}
|
||||
|
||||
private void doActions(Player player, float earnings) {
|
||||
if (titleNotification != null) AdventureUtil.playerTitle(
|
||||
player,
|
||||
titleNotification.replace("{money}", String.format("%.2f", earnings)),
|
||||
subtitleNotification.replace("{money}", String.format("%.2f", earnings)),
|
||||
titleIn * 50,
|
||||
titleStay * 50,
|
||||
titleOut * 50
|
||||
);
|
||||
if (msgNotification != null) {
|
||||
AdventureUtil.playerMessage(player, msgNotification.replace("{money}", String.format("%.2f", earnings)));
|
||||
}
|
||||
if (actionbarNotification != null) {
|
||||
AdventureUtil.playerActionbar(player, actionbarNotification.replace("{money}", String.format("%.2f", earnings)));
|
||||
}
|
||||
if (commands != null) {
|
||||
for (String cmd : commands) {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), cmd.replace("{player}", player.getName()).replace("{money}", String.format("%.2f", earnings)));
|
||||
}
|
||||
}
|
||||
if (ConfigManager.logEarning) {
|
||||
AdventureUtil.consoleMessage("[CustomFishing] Log: " + player.getName() + " earns " + String.format("%.2f", earnings) + " from selling fish");
|
||||
}
|
||||
if (successKey != null) AdventureUtil.playerSound(player, soundSource, successKey, 1, 1);
|
||||
if (ConfigManager.vaultHook) VaultHook.economy.depositPlayer(player, earnings);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package net.momirealms.customfishing.object.fishing;
|
||||
|
||||
import com.plotsquared.core.plot.PlotId;
|
||||
import net.momirealms.customfishing.CustomFishing;
|
||||
import net.momirealms.customfishing.manager.ConfigManager;
|
||||
import net.momirealms.customfishing.manager.FishingManager;
|
||||
@@ -71,8 +70,10 @@ public class BobberCheckTask extends BukkitRunnable {
|
||||
return;
|
||||
}
|
||||
if (fishHook.isInWater()) {
|
||||
List<Loot> possibleLoots = fishingManager.getPossibleWaterLootList(new FishingCondition(fishHook.getLocation(), player), false);
|
||||
fishingManager.getNextLoot(player, bonus, possibleLoots);
|
||||
Bukkit.getScheduler().runTaskAsynchronously(CustomFishing.plugin, () -> {
|
||||
List<Loot> possibleLoots = fishingManager.getPossibleWaterLootList(new FishingCondition(fishHook.getLocation(), player), false);
|
||||
fishingManager.getNextLoot(player, bonus, possibleLoots);
|
||||
});
|
||||
stop();
|
||||
return;
|
||||
}
|
||||
@@ -106,8 +107,10 @@ public class BobberCheckTask extends BukkitRunnable {
|
||||
}
|
||||
|
||||
private void randomTime() {
|
||||
List<Loot> possibleLoots = fishingManager.getPossibleLavaLootList(new FishingCondition(fishHook.getLocation(), player), false);
|
||||
fishingManager.getNextLoot(player, bonus, possibleLoots);
|
||||
Bukkit.getScheduler().runTaskAsynchronously(CustomFishing.plugin, () -> {
|
||||
List<Loot> possibleLoots = fishingManager.getPossibleLavaLootList(new FishingCondition(fishHook.getLocation(), player), false);
|
||||
fishingManager.getNextLoot(player, bonus, possibleLoots);
|
||||
});
|
||||
cancelTask();
|
||||
int random = new Random().nextInt(ConfigManager.lavaMaxTime) + ConfigManager.lavaMinTime;
|
||||
random -= lureLevel * 100;
|
||||
|
||||
@@ -8,6 +8,9 @@ public class DroppedItem extends Loot{
|
||||
private boolean randomDurability;
|
||||
private LeveledEnchantment[] randomEnchants;
|
||||
private final String material;
|
||||
private String[] size;
|
||||
private float basicPrice;
|
||||
private float sizeBonus;
|
||||
|
||||
public DroppedItem(String key, Difficulty difficulty, int time, int weight, String material) {
|
||||
super(key, difficulty, time, weight);
|
||||
@@ -34,4 +37,28 @@ public class DroppedItem extends Loot{
|
||||
public String getMaterial() {
|
||||
return material;
|
||||
}
|
||||
|
||||
public String[] getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(String[] size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public float getBasicPrice() {
|
||||
return basicPrice;
|
||||
}
|
||||
|
||||
public void setBasicPrice(float basicPrice) {
|
||||
this.basicPrice = basicPrice;
|
||||
}
|
||||
|
||||
public float getSizeBonus() {
|
||||
return sizeBonus;
|
||||
}
|
||||
|
||||
public void setSizeBonus(float sizeBonus) {
|
||||
this.sizeBonus = sizeBonus;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.momirealms.customfishing.object.loot;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -80,4 +81,20 @@ public class Item {
|
||||
public void setNbt(Map<String, Object> nbt) {
|
||||
this.nbt = nbt;
|
||||
}
|
||||
|
||||
public Item cloneWithPrice(double price){
|
||||
Item newItem = new Item(this.material);
|
||||
if (this.lore != null){
|
||||
List<String> lore = new ArrayList<>();
|
||||
for (String text : this.lore) {
|
||||
lore.add(text.replace("{money}", String.format("%.2f", price)));
|
||||
}
|
||||
newItem.setLore(lore);
|
||||
}
|
||||
if (this.name != null){
|
||||
newItem.setName(this.name.replace("{money}", String.format("%.2f", price)));
|
||||
}
|
||||
newItem.setCustomModelData(this.customModelData);
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package net.momirealms.customfishing.object.sell;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.comphenix.protocol.reflect.StructureModifier;
|
||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.momirealms.customfishing.CustomFishing;
|
||||
import net.momirealms.customfishing.integration.papi.PlaceholderManager;
|
||||
import net.momirealms.customfishing.manager.SellManager;
|
||||
import net.momirealms.customfishing.util.ItemStackUtil;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ContainerPacketListener extends PacketAdapter {
|
||||
|
||||
public ContainerPacketListener() {
|
||||
super(CustomFishing.plugin, PacketType.Play.Server.OPEN_WINDOW);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketSending(PacketEvent event) {
|
||||
PacketContainer packet = event.getPacket();
|
||||
StructureModifier<WrappedChatComponent> wrappedChatComponentStructureModifier = packet.getChatComponents();
|
||||
WrappedChatComponent component = wrappedChatComponentStructureModifier.getValues().get(0);
|
||||
if (component.getJson().equals("{\"text\":\"{CustomFishing}\"}")) {
|
||||
PlaceholderManager placeholderManager = CustomFishing.plugin.getIntegrationManager().getPlaceholderManager();
|
||||
Player player = event.getPlayer();
|
||||
String text = SellManager.title.replace("{player}", player.getName());
|
||||
if (placeholderManager != null) placeholderManager.parse(player, text);
|
||||
wrappedChatComponentStructureModifier.write(0,
|
||||
WrappedChatComponent.fromJson(
|
||||
GsonComponentSerializer.gson().serialize(
|
||||
MiniMessage.miniMessage().deserialize(
|
||||
ItemStackUtil.replaceLegacy(text)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package net.momirealms.customfishing.object.sell;
|
||||
|
||||
import net.momirealms.customfishing.manager.SellManager;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.*;
|
||||
|
||||
public class InventoryListener implements Listener {
|
||||
|
||||
private final SellManager sellManager;
|
||||
|
||||
public InventoryListener(SellManager sellManager) {
|
||||
this.sellManager = sellManager;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onOpen(InventoryOpenEvent event){
|
||||
sellManager.onOpen(event);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onClick(InventoryClickEvent event) {
|
||||
sellManager.onClick(event);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onClose(InventoryCloseEvent event){
|
||||
sellManager.onClose(event);
|
||||
}
|
||||
}
|
||||
@@ -40,14 +40,14 @@ public class AdventureUtil {
|
||||
public static void consoleMessage(String s) {
|
||||
Audience au = CustomFishing.adventure.sender(Bukkit.getConsoleSender());
|
||||
MiniMessage mm = MiniMessage.miniMessage();
|
||||
Component parsed = mm.deserialize(s);
|
||||
Component parsed = mm.deserialize(ItemStackUtil.replaceLegacy(s));
|
||||
au.sendMessage(parsed);
|
||||
}
|
||||
|
||||
public static void playerMessage(Player player, String s) {
|
||||
Audience au = CustomFishing.adventure.player(player);
|
||||
MiniMessage mm = MiniMessage.miniMessage();
|
||||
Component parsed = mm.deserialize(s);
|
||||
Component parsed = mm.deserialize(ItemStackUtil.replaceLegacy(s));
|
||||
au.sendMessage(parsed);
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public class AdventureUtil {
|
||||
Audience au = CustomFishing.adventure.player(player);
|
||||
MiniMessage mm = MiniMessage.miniMessage();
|
||||
Title.Times times = Title.Times.times(Duration.ofMillis(in), Duration.ofMillis(duration), Duration.ofMillis(out));
|
||||
Title title = Title.title(mm.deserialize(s1), mm.deserialize(s2), times);
|
||||
Title title = Title.title(mm.deserialize(ItemStackUtil.replaceLegacy(s1)), mm.deserialize(ItemStackUtil.replaceLegacy(s2)), times);
|
||||
au.showTitle(title);
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public class AdventureUtil {
|
||||
public static void playerActionbar(Player player, String s) {
|
||||
Audience au = CustomFishing.adventure.player(player);
|
||||
MiniMessage mm = MiniMessage.miniMessage();
|
||||
au.sendActionBar(mm.deserialize(s));
|
||||
au.sendActionBar(mm.deserialize(ItemStackUtil.replaceLegacy(s)));
|
||||
}
|
||||
|
||||
public static void playerSound(Player player, Sound.Source source, Key key, float volume, float pitch) {
|
||||
|
||||
@@ -40,6 +40,8 @@ public class ConfigUtil {
|
||||
CustomFishing.plugin.getTotemManager().load();
|
||||
CustomFishing.plugin.getIntegrationManager().unload();
|
||||
CustomFishing.plugin.getIntegrationManager().load();
|
||||
CustomFishing.plugin.getSellManager().unload();
|
||||
CustomFishing.plugin.getSellManager().load();
|
||||
try {
|
||||
Reflection.load();
|
||||
}
|
||||
|
||||
@@ -51,7 +51,6 @@ public class ItemStackUtil {
|
||||
NBTCompound display = nbtItem.addCompound("display");
|
||||
String name = item.getName();
|
||||
if (name.contains("&") || name.contains("§")){
|
||||
name = name.replaceAll("&","§");
|
||||
name = replaceLegacy(name);
|
||||
}
|
||||
display.setString("Name", GsonComponentSerializer.gson().serialize(MiniMessage.miniMessage().deserialize("<!i>" + name)));
|
||||
@@ -61,7 +60,6 @@ public class ItemStackUtil {
|
||||
List<String> lore = display.getStringList("Lore");
|
||||
item.getLore().forEach(line -> {
|
||||
if (line.contains("&") || line.contains("§")){
|
||||
line = line.replaceAll("&","§");
|
||||
line = replaceLegacy(line);
|
||||
}
|
||||
lore.add(GsonComponentSerializer.gson().serialize(MiniMessage.miniMessage().deserialize("<!i>" + line)));
|
||||
@@ -200,6 +198,40 @@ public class ItemStackUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void addExtraMeta(ItemStack itemStack, DroppedItem droppedItem) {
|
||||
NBTItem nbtItem = new NBTItem(itemStack);
|
||||
boolean changed = replaceSizeLore(droppedItem.getSize(), nbtItem);
|
||||
if (droppedItem.getBasicPrice() != 0) {
|
||||
NBTCompound fishMetaCompound = nbtItem.addCompound("FishMeta");
|
||||
fishMetaCompound.setFloat("base", droppedItem.getBasicPrice());
|
||||
changed = true;
|
||||
}
|
||||
if (droppedItem.getSizeBonus() != 0) {
|
||||
NBTCompound fishMetaCompound = nbtItem.addCompound("FishMeta");
|
||||
fishMetaCompound.setFloat("bonus", droppedItem.getSizeBonus());
|
||||
changed = true;
|
||||
}
|
||||
if (changed) {
|
||||
itemStack.setItemMeta(nbtItem.getItem().getItemMeta());
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean replaceSizeLore(String[] sizes, NBTItem nbtItem) {
|
||||
if (sizes == null) return false;
|
||||
float min = Float.parseFloat(sizes[0]);
|
||||
float max = Float.parseFloat(sizes[1]);
|
||||
if (max - min < 0) return false;
|
||||
float size = (float) (min + Math.random() * (max - min));
|
||||
String sizeText = String.format("%.1f", size);
|
||||
NBTCompound nbtCompound = nbtItem.getCompound("display");
|
||||
if (nbtCompound == null || !nbtCompound.hasKey("Lore")) return false;
|
||||
List<String> lore = nbtCompound.getStringList("Lore");
|
||||
lore.replaceAll(s -> s.replace("{size}", sizeText));
|
||||
NBTCompound fishMetaCompound = nbtItem.addCompound("FishMeta");
|
||||
fishMetaCompound.setFloat("size", size);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static Map<String, Object> compoundToMap(NBTCompound nbtCompound){
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
nbtCompound.getKeys().forEach(key -> {
|
||||
@@ -243,7 +275,7 @@ public class ItemStackUtil {
|
||||
|
||||
public static String replaceLegacy(String s) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
char[] chars = s.toCharArray();
|
||||
char[] chars = s.replaceAll("&","§").toCharArray();
|
||||
for (int i = 0; i < chars.length; i++) {
|
||||
if (chars[i] == '§') {
|
||||
if (i + 1 < chars.length) {
|
||||
|
||||
Reference in New Issue
Block a user