mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2025-12-26 10:29:16 +00:00
fix bugs
This commit is contained in:
@@ -19,7 +19,6 @@ package net.momirealms.customfishing.adventure;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
@@ -28,7 +27,6 @@ import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import net.kyori.adventure.title.Title;
|
||||
import net.momirealms.customfishing.CustomFishingPluginImpl;
|
||||
import net.momirealms.customfishing.api.CustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.manager.AdventureManager;
|
||||
@@ -42,7 +40,6 @@ import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.time.Duration;
|
||||
|
||||
public class AdventureManagerImpl implements AdventureManager {
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.google.gson.JsonPrimitive;
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import dev.jorel.commandapi.arguments.ArgumentSuggestions;
|
||||
import dev.jorel.commandapi.arguments.StringArgument;
|
||||
import dev.jorel.commandapi.arguments.UUIDArgument;
|
||||
import net.momirealms.customfishing.adventure.AdventureManagerImpl;
|
||||
import net.momirealms.customfishing.api.CustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.data.DataStorageInterface;
|
||||
@@ -58,12 +59,23 @@ public class DataCommand {
|
||||
.withSubcommands(
|
||||
getExportLegacyCommand(),
|
||||
getExportCommand(),
|
||||
getImportCommand()
|
||||
getImportCommand(),
|
||||
getUnlockCommand()
|
||||
);
|
||||
}
|
||||
|
||||
private CommandAPICommand getUnlockCommand() {
|
||||
return new CommandAPICommand("unlock")
|
||||
.withArguments(new UUIDArgument("uuid"))
|
||||
.executes((sender, args) -> {
|
||||
UUID uuid = (UUID) args.get("uuid");
|
||||
CustomFishingPlugin.get().getStorageManager().getDataSource().lockOrUnlockPlayerData(uuid, false);
|
||||
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, "Successfully unlocked.");
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("DuplicatedCode")
|
||||
public CommandAPICommand getExportLegacyCommand() {
|
||||
private CommandAPICommand getExportLegacyCommand() {
|
||||
return new CommandAPICommand("export-legacy")
|
||||
.withArguments(new StringArgument("method")
|
||||
.replaceSuggestions(ArgumentSuggestions.strings("MySQL", "MariaDB", "YAML")))
|
||||
@@ -137,7 +149,7 @@ public class DataCommand {
|
||||
}
|
||||
|
||||
@SuppressWarnings("DuplicatedCode")
|
||||
public CommandAPICommand getExportCommand() {
|
||||
private CommandAPICommand getExportCommand() {
|
||||
return new CommandAPICommand("export")
|
||||
.executesConsole((sender, args) -> {
|
||||
if (Bukkit.getOnlinePlayers().size() != 0) {
|
||||
@@ -151,7 +163,7 @@ public class DataCommand {
|
||||
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, "Starting <aqua>export</aqua>.");
|
||||
DataStorageInterface dataStorageInterface = plugin.getStorageManager().getDataSource();
|
||||
|
||||
Set<UUID> uuids = dataStorageInterface.getUniqueUsers(true);
|
||||
Set<UUID> uuids = dataStorageInterface.getUniqueUsers(false);
|
||||
Set<CompletableFuture<Void>> futures = new HashSet<>();
|
||||
AtomicInteger userCount = new AtomicInteger(0);
|
||||
Map<UUID, String> out = Collections.synchronizedMap(new TreeMap<>());
|
||||
@@ -200,7 +212,7 @@ public class DataCommand {
|
||||
}
|
||||
|
||||
@SuppressWarnings("DuplicatedCode")
|
||||
public CommandAPICommand getImportCommand() {
|
||||
private CommandAPICommand getImportCommand() {
|
||||
return new CommandAPICommand("import")
|
||||
.withArguments(new StringArgument("file"))
|
||||
.executesConsole((sender, args) -> {
|
||||
|
||||
@@ -125,7 +125,7 @@ public class ItemCommand {
|
||||
int amount = (int) args.getOrDefault("amount", 1);
|
||||
ItemStack item = CustomFishingPlugin.get().getItemManager().build(player, namespace, id, new Condition(player).getArgs());
|
||||
if (item != null) {
|
||||
int actual = ItemUtils.putLootsToBag(player, item, amount);
|
||||
int actual = ItemUtils.giveItem(player, item, amount);
|
||||
AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, CFLocale.MSG_Get_Item.replace("{item}", id).replace("{amount}", String.valueOf(actual)));
|
||||
} else {
|
||||
AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, CFLocale.MSG_Item_Not_Exists);
|
||||
@@ -151,7 +151,7 @@ public class ItemCommand {
|
||||
assert players != null;
|
||||
for (Player player : players) {
|
||||
ItemStack item = CustomFishingPlugin.get().getItemManager().build(player, namespace, id, new Condition(player).getArgs());
|
||||
int actual = ItemUtils.putLootsToBag(player, item, amount);
|
||||
int actual = ItemUtils.giveItem(player, item, amount);
|
||||
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CFLocale.MSG_Give_Item.replace("{item}", id).replace("{amount}", String.valueOf(actual)).replace("{player}", player.getName()));
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -42,7 +42,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class IntegrationManagerImpl implements IntegrationManager {
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ package net.momirealms.customfishing.compatibility.item;
|
||||
|
||||
import dev.lone.itemsadder.api.CustomStack;
|
||||
import net.momirealms.customfishing.api.mechanic.item.ItemLibrary;
|
||||
import net.momirealms.customfishing.api.util.LogUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@@ -31,7 +32,12 @@ public class ItemsAdderItemImpl implements ItemLibrary {
|
||||
|
||||
@Override
|
||||
public ItemStack buildItem(Player player, String id) {
|
||||
return CustomStack.getInstance(id).getItemStack();
|
||||
CustomStack stack = CustomStack.getInstance(id);
|
||||
if (stack == null) {
|
||||
LogUtils.severe(id + " doesn't exist in ItemsAdder configs.");
|
||||
return null;
|
||||
}
|
||||
return stack.getItemStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -66,14 +66,13 @@ public class StatisticsPapi extends PlaceholderExpansion {
|
||||
@Override
|
||||
public @Nullable String onRequest(OfflinePlayer player, @NotNull String params) {
|
||||
OnlineUser onlineUser = plugin.getStorageManager().getOnlineUser(player.getUniqueId());
|
||||
if (onlineUser == null) return "";
|
||||
if (onlineUser == null) return "Data not loaded";
|
||||
Statistics statistics = onlineUser.getStatistics();
|
||||
if (params.equals("total")) {
|
||||
return String.valueOf(statistics.getTotalCatchAmount());
|
||||
}
|
||||
|
||||
String[] split = params.split("_", 2);
|
||||
switch (split[0]) {
|
||||
case "total" -> {
|
||||
return String.valueOf(statistics.getTotalCatchAmount());
|
||||
}
|
||||
case "hascaught" -> {
|
||||
if (split.length == 1) return "Invalid format";
|
||||
return String.valueOf(statistics.getLootAmount(split[1]) != 0);
|
||||
|
||||
@@ -626,7 +626,7 @@ public class ActionManagerImpl implements ActionManager {
|
||||
return condition -> {
|
||||
if (Math.random() > chance) return;
|
||||
Player player = condition.getPlayer();
|
||||
ItemUtils.putLootsToBag(player, Objects.requireNonNull(CustomFishingPlugin.get().getItemManager().buildAnyPluginItemByID(player, id)), amount);
|
||||
ItemUtils.giveItem(player, Objects.requireNonNull(CustomFishingPlugin.get().getItemManager().buildAnyPluginItemByID(player, id)), amount);
|
||||
};
|
||||
} else {
|
||||
LogUtils.warn("Illegal value format found at action: give-item");
|
||||
|
||||
@@ -69,18 +69,16 @@ public class BagManagerImpl implements BagManager, Listener {
|
||||
|
||||
public void load() {
|
||||
Bukkit.getPluginManager().registerEvents(this, plugin);
|
||||
if (isEnabled()) {
|
||||
YamlConfiguration config = plugin.getConfig("config.yml");
|
||||
ConfigurationSection bagSection = config.getConfigurationSection("mechanics.fishing-bag");
|
||||
if (bagSection != null) {
|
||||
bagTitle = bagSection.getString("bag-title");
|
||||
bagStoreLoots = bagSection.getBoolean("can-store-loot", false);
|
||||
bagWhiteListItems = bagSection.getStringList("whitelist-items").stream().map(it -> Material.valueOf(it.toUpperCase(Locale.ENGLISH))).toList();
|
||||
if (bagStoreLoots) {
|
||||
collectLootActions = plugin.getActionManager().getActions(bagSection.getConfigurationSection("collect-actions"));
|
||||
bagFullActions = plugin.getActionManager().getActions(bagSection.getConfigurationSection("full-actions"));
|
||||
collectRequirements = plugin.getRequirementManager().getRequirements(bagSection.getConfigurationSection("collect-requirements"), false);
|
||||
}
|
||||
YamlConfiguration config = plugin.getConfig("config.yml");
|
||||
ConfigurationSection bagSection = config.getConfigurationSection("mechanics.fishing-bag");
|
||||
if (bagSection != null) {
|
||||
bagTitle = bagSection.getString("bag-title");
|
||||
bagStoreLoots = bagSection.getBoolean("can-store-loot", false);
|
||||
bagWhiteListItems = bagSection.getStringList("whitelist-items").stream().map(it -> Material.valueOf(it.toUpperCase(Locale.ENGLISH))).toList();
|
||||
if (bagStoreLoots) {
|
||||
collectLootActions = plugin.getActionManager().getActions(bagSection.getConfigurationSection("collect-actions"));
|
||||
bagFullActions = plugin.getActionManager().getActions(bagSection.getConfigurationSection("full-actions"));
|
||||
collectRequirements = plugin.getRequirementManager().getRequirements(bagSection.getConfigurationSection("collect-requirements"), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,7 +322,7 @@ public class HookManagerImpl implements Listener, HookManager {
|
||||
if (cursor.getAmount() == 0) {
|
||||
event.setCursor(previousItemStack);
|
||||
} else {
|
||||
ItemUtils.putLootsToBag(player, previousItemStack, 1);
|
||||
ItemUtils.giveItem(player, previousItemStack, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,8 @@ import net.momirealms.customfishing.api.CustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.common.Key;
|
||||
import net.momirealms.customfishing.api.common.Pair;
|
||||
import net.momirealms.customfishing.api.common.Tuple;
|
||||
import net.momirealms.customfishing.api.event.FishingBagPreCollectEvent;
|
||||
import net.momirealms.customfishing.api.event.FishingLootPreSpawnEvent;
|
||||
import net.momirealms.customfishing.api.event.FishingLootSpawnEvent;
|
||||
import net.momirealms.customfishing.api.manager.ActionManager;
|
||||
import net.momirealms.customfishing.api.manager.ItemManager;
|
||||
@@ -53,7 +55,7 @@ import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -433,6 +435,13 @@ public class ItemManagerImpl implements ItemManager, Listener {
|
||||
|
||||
if (CFConfig.enableFishingBag && plugin.getBagManager().doesBagStoreLoots() && RequirementManager.isRequirementMet(condition, plugin.getBagManager().getCollectRequirements())) {
|
||||
var bag = plugin.getBagManager().getOnlineBagInventory(player.getUniqueId());
|
||||
|
||||
FishingBagPreCollectEvent preCollectEvent = new FishingBagPreCollectEvent(player, item, bag);
|
||||
Bukkit.getPluginManager().callEvent(preCollectEvent);
|
||||
if (preCollectEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int cannotPut = ItemUtils.putLootsToBag(bag, item, item.getAmount());
|
||||
// some are put into bag
|
||||
if (cannotPut != item.getAmount()) {
|
||||
@@ -447,13 +456,20 @@ public class ItemManagerImpl implements ItemManager, Listener {
|
||||
ActionManager.triggerActions(condition, plugin.getBagManager().getBagFullActions());
|
||||
}
|
||||
|
||||
FishingLootSpawnEvent spawnEvent = new FishingLootSpawnEvent(player, hookLocation, item);
|
||||
Bukkit.getPluginManager().callEvent(spawnEvent);
|
||||
if (spawnEvent.isCancelled()) {
|
||||
FishingLootPreSpawnEvent preSpawnEvent = new FishingLootPreSpawnEvent(player, hookLocation, item);
|
||||
Bukkit.getPluginManager().callEvent(preSpawnEvent);
|
||||
if (preSpawnEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Item itemEntity = hookLocation.getWorld().dropItem(hookLocation, item);
|
||||
FishingLootSpawnEvent spawnEvent = new FishingLootSpawnEvent(player, hookLocation, itemEntity);
|
||||
Bukkit.getPluginManager().callEvent(spawnEvent);
|
||||
if (spawnEvent.isCancelled()) {
|
||||
itemEntity.remove();
|
||||
return;
|
||||
}
|
||||
|
||||
Entity itemEntity = hookLocation.getWorld().dropItem(hookLocation, item);
|
||||
Vector vector = playerLocation.subtract(hookLocation).toVector().multiply(0.105);
|
||||
vector = vector.setY((vector.getY() + 0.22) * 1.18);
|
||||
itemEntity.setVelocity(vector);
|
||||
|
||||
@@ -255,7 +255,7 @@ public class MarketGUI {
|
||||
for (int slot : itemElement.getSlots()) {
|
||||
ItemStack itemStack = inventory.getItem(slot);
|
||||
if (itemStack != null && itemStack.getType() != Material.AIR) {
|
||||
ItemUtils.putLootsToBag(owner, itemStack, itemStack.getAmount());
|
||||
ItemUtils.giveItem(owner, itemStack, itemStack.getAmount());
|
||||
inventory.setItem(slot, new ItemStack(Material.AIR));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ import net.momirealms.customfishing.api.scheduler.CancellableTask;
|
||||
import net.momirealms.customfishing.api.util.LogUtils;
|
||||
import net.momirealms.customfishing.compatibility.papi.PlaceholderManagerImpl;
|
||||
import net.momirealms.customfishing.util.ConfigUtils;
|
||||
import net.objecthunter.exp4j.Expression;
|
||||
import net.objecthunter.exp4j.ExpressionBuilder;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
|
||||
@@ -27,7 +27,6 @@ import net.momirealms.customfishing.api.mechanic.action.Action;
|
||||
import net.momirealms.customfishing.api.mechanic.competition.FishingCompetition;
|
||||
import net.momirealms.customfishing.api.mechanic.condition.Condition;
|
||||
import net.momirealms.customfishing.api.mechanic.loot.Loot;
|
||||
import net.momirealms.customfishing.api.mechanic.loot.WeightModifier;
|
||||
import net.momirealms.customfishing.api.mechanic.requirement.Requirement;
|
||||
import net.momirealms.customfishing.api.mechanic.requirement.RequirementExpansion;
|
||||
import net.momirealms.customfishing.api.mechanic.requirement.RequirementFactory;
|
||||
|
||||
@@ -24,11 +24,8 @@ import dev.dejvokep.boostedyaml.settings.general.GeneralSettings;
|
||||
import dev.dejvokep.boostedyaml.settings.loader.LoaderSettings;
|
||||
import dev.dejvokep.boostedyaml.settings.updater.UpdaterSettings;
|
||||
import net.momirealms.customfishing.api.CustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.mechanic.action.Action;
|
||||
import net.momirealms.customfishing.api.util.LogUtils;
|
||||
import net.momirealms.customfishing.api.util.OffsetUtils;
|
||||
import net.momirealms.customfishing.util.ConfigUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
||||
|
||||
@@ -337,16 +337,27 @@ public class StorageManagerImpl implements StorageManager, Listener {
|
||||
public void waitForDataLockRelease(UUID uuid, int times) {
|
||||
plugin.getScheduler().runTaskAsyncLater(() -> {
|
||||
var player = Bukkit.getPlayer(uuid);
|
||||
if (player == null || !player.isOnline() || times > 3)
|
||||
if (player == null || !player.isOnline())
|
||||
return;
|
||||
if (times > 3) {
|
||||
LogUtils.warn("Tried 3 times when getting data for " + uuid + ". Giving up.");
|
||||
return;
|
||||
}
|
||||
this.dataSource.getPlayerData(uuid, CFConfig.lockData).thenAccept(optionalData -> {
|
||||
// Data should not be empty
|
||||
if (optionalData.isEmpty())
|
||||
if (optionalData.isEmpty()) {
|
||||
LogUtils.severe("Unexpected error: Data is null");
|
||||
return;
|
||||
}
|
||||
|
||||
if (optionalData.get().isLocked()) {
|
||||
waitForDataLockRelease(uuid, times + 1);
|
||||
} else {
|
||||
putDataInCache(player, optionalData.get());
|
||||
try {
|
||||
putDataInCache(player, optionalData.get());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}, 1, TimeUnit.SECONDS);
|
||||
@@ -417,7 +428,14 @@ public class StorageManagerImpl implements StorageManager, Listener {
|
||||
@NotNull
|
||||
@Override
|
||||
public PlayerData fromJson(String json) {
|
||||
return gson.fromJson(json, PlayerData.class);
|
||||
try {
|
||||
LogUtils.info("Try parsing Json");
|
||||
return gson.fromJson(json, PlayerData.class);
|
||||
} catch (JsonSyntaxException e) {
|
||||
LogUtils.warn("Failed to get PlayerData from bytes");
|
||||
LogUtils.warn("Data: " + json);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -429,11 +447,7 @@ public class StorageManagerImpl implements StorageManager, Listener {
|
||||
@Override
|
||||
@NotNull
|
||||
public PlayerData fromBytes(byte[] data) {
|
||||
try {
|
||||
return gson.fromJson(new String(data, StandardCharsets.UTF_8), PlayerData.class);
|
||||
} catch (JsonSyntaxException e) {
|
||||
throw new DataSerializationException("Failed to get PlayerData from bytes", e);
|
||||
}
|
||||
return fromJson(new String(data, StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -99,8 +99,6 @@ public class MongoDBImpl extends AbstractStorage {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get the collection name for a specific subcategory of data.
|
||||
*
|
||||
|
||||
@@ -132,16 +132,20 @@ public abstract class AbstractSQLDatabase extends AbstractStorage {
|
||||
statement.setString(1, uuid.toString());
|
||||
ResultSet rs = statement.executeQuery();
|
||||
if (rs.next()) {
|
||||
int lockValue = rs.getInt(2);
|
||||
if (lockValue != 0 && getCurrentSeconds() - CFConfig.dataSaveInterval <= lockValue) {
|
||||
connection.close();
|
||||
future.complete(Optional.of(PlayerData.LOCKED));
|
||||
return;
|
||||
if (lock) {
|
||||
int lockValue = rs.getInt(2);
|
||||
if (lockValue != 0 && getCurrentSeconds() - CFConfig.dataSaveInterval <= lockValue) {
|
||||
connection.close();
|
||||
future.complete(Optional.of(PlayerData.LOCKED));
|
||||
LogUtils.warn("Player " + uuid + "'s data is locked. Retrying...");
|
||||
return;
|
||||
}
|
||||
}
|
||||
final Blob blob = rs.getBlob("data");
|
||||
final byte[] dataByteArray = blob.getBytes(1, (int) blob.length());
|
||||
blob.free();
|
||||
if (lock) lockOrUnlockPlayerData(uuid, true);
|
||||
LogUtils.info(new String(dataByteArray, StandardCharsets.UTF_8));
|
||||
future.complete(Optional.of(plugin.getStorageManager().fromBytes(dataByteArray)));
|
||||
} else if (Bukkit.getPlayer(uuid) != null) {
|
||||
var data = PlayerData.empty();
|
||||
|
||||
@@ -28,7 +28,6 @@ import net.momirealms.customfishing.api.mechanic.bag.FishingBagHolder;
|
||||
import net.momirealms.customfishing.api.mechanic.statistic.Statistics;
|
||||
import net.momirealms.customfishing.api.util.InventoryUtils;
|
||||
import net.momirealms.customfishing.compatibility.papi.PlaceholderManagerImpl;
|
||||
import net.momirealms.customfishing.setting.CFConfig;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -61,24 +60,22 @@ public class OfflineUserImpl implements OfflineUser {
|
||||
this.uuid = uuid;
|
||||
this.holder = new FishingBagHolder(uuid);
|
||||
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(uuid);
|
||||
|
||||
// Set up the inventory for the FishingBagHolder
|
||||
this.holder.setInventory(InventoryUtils.createInventory(this.holder, playerData.getBagData().size,
|
||||
AdventureManagerImpl.getInstance().getComponentFromMiniMessage(
|
||||
PlaceholderManagerImpl.getInstance().parse(
|
||||
offlinePlayer, CustomFishingPlugin.get().getBagManager().getBagTitle(), Map.of("{player}", Optional.ofNullable(offlinePlayer.getName()).orElse(String.valueOf(uuid)))
|
||||
offlinePlayer,
|
||||
CustomFishingPlugin.get().getBagManager().getBagTitle(),
|
||||
Map.of("{player}", Optional.ofNullable(offlinePlayer.getName()).orElse(String.valueOf(uuid)))
|
||||
)
|
||||
)));
|
||||
this.holder.setItems(InventoryUtils.getInventoryItems(playerData.getBagData().serialized));
|
||||
|
||||
this.earningData = playerData.getEarningData();
|
||||
|
||||
int date = CustomFishingPlugin.get().getMarketManager().getDate();
|
||||
if (earningData.date != date) {
|
||||
earningData.date = date;
|
||||
earningData.earnings = 0d;
|
||||
}
|
||||
|
||||
this.statistics = new Statistics(playerData.getStatistics());
|
||||
}
|
||||
|
||||
|
||||
@@ -342,7 +342,7 @@ public class ItemUtils {
|
||||
* @param amount The amount of items to give
|
||||
* @return The actual amount of items given
|
||||
*/
|
||||
public static int putLootsToBag(Player player, ItemStack itemStack, int amount) {
|
||||
public static int giveItem(Player player, ItemStack itemStack, int amount) {
|
||||
PlayerInventory inventory = player.getInventory();
|
||||
ItemMeta meta = itemStack.getItemMeta();
|
||||
int maxStackSize = itemStack.getMaxStackSize();
|
||||
|
||||
@@ -20,7 +20,6 @@ package net.momirealms.customfishing.util;
|
||||
import de.tr7zw.changeme.nbtapi.NBTCompound;
|
||||
import de.tr7zw.changeme.nbtapi.NBTListCompound;
|
||||
import de.tr7zw.changeme.nbtapi.iface.ReadWriteNBT;
|
||||
import net.momirealms.customfishing.api.util.LogUtils;
|
||||
import net.momirealms.customfishing.compatibility.papi.PlaceholderManagerImpl;
|
||||
import org.bukkit.configuration.MemorySection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -20,7 +20,6 @@ package net.momirealms.customfishing.version;
|
||||
import net.momirealms.customfishing.CustomFishingPluginImpl;
|
||||
import net.momirealms.customfishing.api.manager.VersionManager;
|
||||
import net.momirealms.customfishing.api.util.LogUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
|
||||
Reference in New Issue
Block a user