diff --git a/build.gradle b/build.gradle index a89a98b1..f33c2265 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { } group = 'net.momirealms' -version = '1.3.0-beta-4' +version = '1.3.0-beta-5' repositories { mavenCentral() diff --git a/src/main/java/net/momirealms/customfishing/commands/subcmd/BaitCommand.java b/src/main/java/net/momirealms/customfishing/commands/subcmd/BaitCommand.java index c6f99c8e..9656e2f8 100644 --- a/src/main/java/net/momirealms/customfishing/commands/subcmd/BaitCommand.java +++ b/src/main/java/net/momirealms/customfishing/commands/subcmd/BaitCommand.java @@ -29,7 +29,6 @@ import org.bukkit.entity.Player; import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; public class BaitCommand extends AbstractSubCommand { diff --git a/src/main/java/net/momirealms/customfishing/commands/subcmd/LootCommand.java b/src/main/java/net/momirealms/customfishing/commands/subcmd/LootCommand.java index e21ff22e..f2b0d900 100644 --- a/src/main/java/net/momirealms/customfishing/commands/subcmd/LootCommand.java +++ b/src/main/java/net/momirealms/customfishing/commands/subcmd/LootCommand.java @@ -30,7 +30,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Map; diff --git a/src/main/java/net/momirealms/customfishing/commands/subcmd/OpenBagCommand.java b/src/main/java/net/momirealms/customfishing/commands/subcmd/OpenBagCommand.java index 397e384f..6c015dcf 100644 --- a/src/main/java/net/momirealms/customfishing/commands/subcmd/OpenBagCommand.java +++ b/src/main/java/net/momirealms/customfishing/commands/subcmd/OpenBagCommand.java @@ -10,7 +10,6 @@ import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import java.util.ArrayList; import java.util.List; public class OpenBagCommand extends AbstractSubCommand { diff --git a/src/main/java/net/momirealms/customfishing/commands/subcmd/UtilCommand.java b/src/main/java/net/momirealms/customfishing/commands/subcmd/UtilCommand.java index caa50eb2..3bfbd42a 100644 --- a/src/main/java/net/momirealms/customfishing/commands/subcmd/UtilCommand.java +++ b/src/main/java/net/momirealms/customfishing/commands/subcmd/UtilCommand.java @@ -29,7 +29,6 @@ import org.bukkit.entity.Player; import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; public class UtilCommand extends AbstractSubCommand { diff --git a/src/main/java/net/momirealms/customfishing/data/PlayerSellData.java b/src/main/java/net/momirealms/customfishing/data/PlayerSellData.java index ff616b09..33aed72d 100644 --- a/src/main/java/net/momirealms/customfishing/data/PlayerSellData.java +++ b/src/main/java/net/momirealms/customfishing/data/PlayerSellData.java @@ -42,5 +42,4 @@ public class PlayerSellData { public void setDate(int date) { this.date = date; } - } diff --git a/src/main/java/net/momirealms/customfishing/data/PlayerStatisticsData.java b/src/main/java/net/momirealms/customfishing/data/PlayerStatisticsData.java index b6ae4a78..8c6e4b0a 100644 --- a/src/main/java/net/momirealms/customfishing/data/PlayerStatisticsData.java +++ b/src/main/java/net/momirealms/customfishing/data/PlayerStatisticsData.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customfishing.data; import net.momirealms.customfishing.CustomFishing; diff --git a/src/main/java/net/momirealms/customfishing/data/storage/DataStorageInterface.java b/src/main/java/net/momirealms/customfishing/data/storage/DataStorageInterface.java index ac7e323e..b6564f7e 100644 --- a/src/main/java/net/momirealms/customfishing/data/storage/DataStorageInterface.java +++ b/src/main/java/net/momirealms/customfishing/data/storage/DataStorageInterface.java @@ -21,6 +21,8 @@ import net.momirealms.customfishing.data.PlayerSellData; import net.momirealms.customfishing.data.PlayerStatisticsData; import org.bukkit.inventory.Inventory; +import java.util.Map; +import java.util.Set; import java.util.UUID; public interface DataStorageInterface { @@ -29,9 +31,12 @@ public interface DataStorageInterface { void disable(); Inventory loadBagData(UUID uuid, boolean force); void saveBagData(UUID uuid, Inventory inventory, boolean unlock); + void saveBagData(Set> set, boolean unlock); PlayerSellData loadSellData(UUID uuid, boolean force); void saveSellData(UUID uuid, PlayerSellData playerSellData, boolean unlock); + void saveSellData(Set> set, boolean unlock); StorageType getStorageType(); void saveStatistics(UUID uuid, PlayerStatisticsData statisticsData, boolean unlock); + void saveStatistics(Set> set, boolean unlock); PlayerStatisticsData loadStatistics(UUID uuid, boolean force); } diff --git a/src/main/java/net/momirealms/customfishing/data/storage/FileStorageImpl.java b/src/main/java/net/momirealms/customfishing/data/storage/FileStorageImpl.java index 83f847ef..8f150f0f 100644 --- a/src/main/java/net/momirealms/customfishing/data/storage/FileStorageImpl.java +++ b/src/main/java/net/momirealms/customfishing/data/storage/FileStorageImpl.java @@ -31,6 +31,7 @@ import org.bukkit.inventory.ItemStack; import java.io.File; import java.io.IOException; import java.util.Map; +import java.util.Set; import java.util.UUID; public class FileStorageImpl implements DataStorageInterface { @@ -77,6 +78,14 @@ public class FileStorageImpl implements DataStorageInterface { } } + @Override + public void saveBagData(Set> set, boolean unlock) { + for (Map.Entry entry : set) { + saveBagData(entry.getKey(), entry.getValue(), unlock); + } + } + + @Override public PlayerSellData loadSellData(UUID uuid, boolean force) { YamlConfiguration data = ConfigUtil.readData(new File(plugin.getDataFolder(), "sell_data" + File.separator + uuid + ".yml")); @@ -98,6 +107,13 @@ public class FileStorageImpl implements DataStorageInterface { } } + @Override + public void saveSellData(Set> set, boolean unlock) { + for (Map.Entry entry : set) { + saveSellData(entry.getKey(), entry.getValue(), unlock); + } + } + @Override public StorageType getStorageType() { return StorageType.YAML; @@ -117,6 +133,13 @@ public class FileStorageImpl implements DataStorageInterface { } } + @Override + public void saveStatistics(Set> set, boolean unlock) { + for (Map.Entry entry : set) { + saveStatistics(entry.getKey(), entry.getValue(), unlock); + } + } + @Override public PlayerStatisticsData loadStatistics(UUID uuid, boolean force) { YamlConfiguration data = ConfigUtil.readData(new File(plugin.getDataFolder(), "statistics_data" + File.separator + uuid + ".yml")); diff --git a/src/main/java/net/momirealms/customfishing/data/storage/MySQLStorageImpl.java b/src/main/java/net/momirealms/customfishing/data/storage/MySQLStorageImpl.java index 2f85fdc9..41b9adc2 100644 --- a/src/main/java/net/momirealms/customfishing/data/storage/MySQLStorageImpl.java +++ b/src/main/java/net/momirealms/customfishing/data/storage/MySQLStorageImpl.java @@ -34,6 +34,8 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Calendar; +import java.util.Map; +import java.util.Set; import java.util.UUID; public class MySQLStorageImpl implements DataStorageInterface { @@ -49,9 +51,9 @@ public class MySQLStorageImpl implements DataStorageInterface { @Override public void initialize() { sqlConnection.createNewHikariConfiguration(); - if (ConfigManager.enableFishingBag) createTableIfNotExist(sqlConnection.getTablePrefix() + "_" + "fishingbag", SqlConstants.SQL_CREATE_BAG_TABLE); - if (SellManager.sellLimitation) createTableIfNotExist(sqlConnection.getTablePrefix() + "_" + "selldata", SqlConstants.SQL_CREATE_SELL_TABLE); - if (ConfigManager.enableStatistics) createTableIfNotExist(sqlConnection.getTablePrefix() + "_" + "statistics", SqlConstants.SQL_CREATE_STATS_TABLE); + createTableIfNotExist(sqlConnection.getTablePrefix() + "_" + "fishingbag", SqlConstants.SQL_CREATE_BAG_TABLE); + createTableIfNotExist(sqlConnection.getTablePrefix() + "_" + "selldata", SqlConstants.SQL_CREATE_SELL_TABLE); + createTableIfNotExist(sqlConnection.getTablePrefix() + "_" + "statistics", SqlConstants.SQL_CREATE_STATS_TABLE); } @Override @@ -98,8 +100,32 @@ public class MySQLStorageImpl implements DataStorageInterface { @Override public void saveBagData(UUID uuid, Inventory inventory, boolean unlock) { - String contents = InventoryUtil.toBase64(inventory.getContents()); - updateBagData(uuid, inventory.getSize(), contents, unlock); + updateBagData(uuid, inventory.getSize(), InventoryUtil.toBase64(inventory.getContents()), unlock); + } + + @Override + public void saveBagData(Set> set, boolean unlock) { + String sql = String.format(SqlConstants.SQL_UPDATE_BAG_BY_UUID, sqlConnection.getTablePrefix() + "_" + "fishingbag"); + try (Connection connection = sqlConnection.getConnectionAndCheck()) { + connection.setAutoCommit(false); + try (PreparedStatement statement = connection.prepareStatement(sql)) { + for (Map.Entry entry : set) { + statement.setInt(1, unlock ? 0 : 1); + statement.setInt(2, entry.getValue().getSize()); + statement.setString(3, InventoryUtil.toBase64(entry.getValue().getContents())); + statement.setString(4, entry.getKey().toString()); + statement.addBatch(); + } + statement.executeBatch(); + connection.commit(); + } + catch (SQLException ex) { + connection.rollback(); + AdventureUtil.consoleMessage("[CustomFishing] Failed to update bag data for online players"); + } + } catch (SQLException ex) { + AdventureUtil.consoleMessage("[CustomFishing] Failed to get connection"); + } } @Override @@ -137,6 +163,31 @@ public class MySQLStorageImpl implements DataStorageInterface { updateSellData(uuid, playerSellData.getDate(), (int) playerSellData.getMoney(), unlock); } + @Override + public void saveSellData(Set> set, boolean unlock) { + String sql = String.format(SqlConstants.SQL_UPDATE_SELL_BY_UUID, sqlConnection.getTablePrefix() + "_" + "selldata"); + try (Connection connection = sqlConnection.getConnectionAndCheck()) { + connection.setAutoCommit(false); + try (PreparedStatement statement = connection.prepareStatement(sql)) { + for (Map.Entry entry : set) { + statement.setInt(1, unlock ? 0 : 1); + statement.setInt(2, entry.getValue().getDate()); + statement.setInt(3, (int) entry.getValue().getMoney()); + statement.setString(4, entry.getKey().toString()); + statement.addBatch(); + } + statement.executeBatch(); + connection.commit(); + } + catch (SQLException ex) { + connection.rollback(); + AdventureUtil.consoleMessage("[CustomFishing] Failed to update sell data for all the players"); + } + } catch (SQLException ex) { + AdventureUtil.consoleMessage("[CustomFishing] Failed to get connection"); + } + } + @Override public PlayerStatisticsData loadStatistics(UUID uuid, boolean force) { PlayerStatisticsData playerStatisticsData = null; @@ -170,6 +221,30 @@ public class MySQLStorageImpl implements DataStorageInterface { updateStatisticsData(uuid, statisticsData.getLongText(), unlock); } + @Override + public void saveStatistics(Set> set, boolean unlock) { + String sql = String.format(SqlConstants.SQL_UPDATE_STATS_BY_UUID, sqlConnection.getTablePrefix() + "_" + "statistics"); + try (Connection connection = sqlConnection.getConnectionAndCheck()) { + connection.setAutoCommit(false); + try (PreparedStatement statement = connection.prepareStatement(sql)) { + for (Map.Entry entry : set) { + statement.setInt(1, unlock ? 0 : 1); + statement.setString(2, entry.getValue().getLongText()); + statement.setString(3, entry.getKey().toString()); + statement.addBatch(); + } + statement.executeBatch(); + connection.commit(); + } + catch (SQLException ex) { + connection.rollback(); + AdventureUtil.consoleMessage("[CustomFishing] Failed to update statistics data for online players"); + } + } catch (SQLException ex) { + AdventureUtil.consoleMessage("[CustomFishing] Failed to get connection"); + } + } + private void createTableIfNotExist(String table, String sqlStat) { String sql = String.format(sqlStat, table); try (Connection connection = sqlConnection.getConnectionAndCheck(); PreparedStatement statement = connection.prepareStatement(sql)) { diff --git a/src/main/java/net/momirealms/customfishing/manager/BagDataManager.java b/src/main/java/net/momirealms/customfishing/manager/BagDataManager.java index 41cf1732..af8116fd 100644 --- a/src/main/java/net/momirealms/customfishing/manager/BagDataManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/BagDataManager.java @@ -33,14 +33,12 @@ import net.momirealms.customfishing.util.AdventureUtil; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.OfflinePlayer; -import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; -import org.bukkit.scheduler.BukkitTask; import java.util.HashMap; import java.util.Map; @@ -54,7 +52,6 @@ public class BagDataManager extends DataFunction { private final InventoryListener inventoryListener; private final WindowPacketListener windowPacketListener; private final JoinQuitListener joinQuitListener; - private final BukkitTask timerSave; private final CustomFishing plugin; public BagDataManager(CustomFishing plugin) { @@ -66,15 +63,10 @@ public class BagDataManager extends DataFunction { this.inventoryListener = new InventoryListener(this); this.windowPacketListener = new WindowPacketListener(this); this.joinQuitListener = new JoinQuitListener(this); + } - this.timerSave = Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, () -> { - AdventureUtil.consoleMessage("[CustomFishing] Saving Fishing bag data..."); - DataManager dataManager = plugin.getDataManager(); - for (Map.Entry entry : dataMap.entrySet()) { - dataManager.getDataStorageInterface().saveBagData(entry.getKey(), entry.getValue(), false); - } - AdventureUtil.consoleMessage("[CustomFishing] Fishing bag data saved for " + dataMap.size() + " online players."); - }, 12000, 12000); + public void saveBagDataForOnlinePlayers(boolean unlock) { + plugin.getDataManager().getDataStorageInterface().saveBagData(dataMap.entrySet(), unlock); } @Override @@ -94,16 +86,9 @@ public class BagDataManager extends DataFunction { public void disable() { unload(); - DataManager dataManager = plugin.getDataManager(); - for (Map.Entry entry : dataMap.entrySet()) { - for (HumanEntity humanEntity : entry.getValue().getViewers()) { - humanEntity.closeInventory(); - } - dataManager.getDataStorageInterface().saveBagData(entry.getKey(), entry.getValue(), true); - } + saveBagDataForOnlinePlayers(true); dataMap.clear(); tempData.clear(); - timerSave.cancel(); } public Inventory getPlayerBagData(UUID uuid) { diff --git a/src/main/java/net/momirealms/customfishing/manager/DataManager.java b/src/main/java/net/momirealms/customfishing/manager/DataManager.java index 91b933cc..b2fa38a2 100644 --- a/src/main/java/net/momirealms/customfishing/manager/DataManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/DataManager.java @@ -23,18 +23,21 @@ import net.momirealms.customfishing.data.storage.FileStorageImpl; import net.momirealms.customfishing.data.storage.MySQLStorageImpl; import net.momirealms.customfishing.data.storage.StorageType; import net.momirealms.customfishing.object.Function; +import net.momirealms.customfishing.util.AdventureUtil; import net.momirealms.customfishing.util.ConfigUtil; +import org.bukkit.Bukkit; import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.scheduler.BukkitTask; public class DataManager extends Function { private DataStorageInterface dataStorageInterface; private final CustomFishing plugin; private StorageType storageType; + private BukkitTask timerSave; public DataManager(CustomFishing plugin) { this.plugin = plugin; - load(); } public DataStorageInterface getDataStorageInterface() { @@ -62,10 +65,24 @@ public class DataManager extends Function { @Override public void load() { if (loadStorageMode()) this.dataStorageInterface.initialize(); + this.timerSave = Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, () -> { + //long time1 = System.currentTimeMillis(); + if (ConfigManager.enableFishingBag) { + AdventureUtil.consoleMessage("[CustomFishing] Saving fishing bag data..."); + plugin.getBagDataManager().saveBagDataForOnlinePlayers(false); + } + if (ConfigManager.enableStatistics) { + AdventureUtil.consoleMessage("[CustomFishing] Saving statistics data..."); + plugin.getStatisticsManager().saveStatisticsDataForOnlinePlayers(false); + } + //AdventureUtil.consoleMessage("[CustomFishing] Data saved for all online players. Took " + (System.currentTimeMillis() - time1) + " ms."); + AdventureUtil.consoleMessage("[CustomFishing] Data saved for all online players."); + }, 24000, 24000); } @Override public void unload() { + if (timerSave != null) timerSave.cancel(); YamlConfiguration config = ConfigUtil.getConfig("database.yml"); StorageType st = config.getString("data-storage-method","YAML").equalsIgnoreCase("YAML") ? StorageType.YAML : StorageType.SQL; if (this.dataStorageInterface != null && dataStorageInterface.getStorageType() != st) this.dataStorageInterface.disable(); @@ -75,5 +92,8 @@ public class DataManager extends Function { if (this.dataStorageInterface != null) { this.dataStorageInterface.disable(); } + if (timerSave != null) { + timerSave.cancel(); + } } } diff --git a/src/main/java/net/momirealms/customfishing/manager/SellManager.java b/src/main/java/net/momirealms/customfishing/manager/SellManager.java index 60f22f28..e0936bf3 100644 --- a/src/main/java/net/momirealms/customfishing/manager/SellManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/SellManager.java @@ -29,7 +29,6 @@ import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import net.momirealms.customfishing.CustomFishing; import net.momirealms.customfishing.api.event.SellFishEvent; import net.momirealms.customfishing.data.PlayerSellData; -import net.momirealms.customfishing.data.storage.DataStorageInterface; import net.momirealms.customfishing.fishing.loot.Item; import net.momirealms.customfishing.integration.papi.PlaceholderManager; import net.momirealms.customfishing.listener.InventoryListener; @@ -56,6 +55,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; import java.util.*; +import java.util.concurrent.ConcurrentHashMap; public class SellManager extends DataFunction { @@ -87,7 +87,7 @@ public class SellManager extends DataFunction { public static boolean sellLimitation; public static int upperLimit; private final HashMap inventoryMap; - private final HashMap sellDataMap; + private final ConcurrentHashMap sellDataMap; public SellManager(CustomFishing plugin) { super(); @@ -95,7 +95,7 @@ public class SellManager extends DataFunction { this.windowPacketListener = new WindowPacketListener(this); this.inventoryListener = new InventoryListener(this); this.joinQuitListener = new JoinQuitListener(this); - this.sellDataMap = new HashMap<>(); + this.sellDataMap = new ConcurrentHashMap<>(); this.inventoryMap = new HashMap<>(); } @@ -123,10 +123,7 @@ public class SellManager extends DataFunction { public void disable() { unload(); - DataStorageInterface dataStorage = plugin.getDataManager().getDataStorageInterface(); - for (Map.Entry entry : sellDataMap.entrySet()) { - dataStorage.saveSellData(entry.getKey(), entry.getValue(), true); - } + plugin.getDataManager().getDataStorageInterface().saveSellData(sellDataMap.entrySet(), true); sellDataMap.clear(); } diff --git a/src/main/java/net/momirealms/customfishing/manager/StatisticsManager.java b/src/main/java/net/momirealms/customfishing/manager/StatisticsManager.java index 55b55dac..44d5ca2c 100644 --- a/src/main/java/net/momirealms/customfishing/manager/StatisticsManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/StatisticsManager.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customfishing.manager; import net.momirealms.customfishing.CustomFishing; @@ -9,7 +26,6 @@ import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; -import java.util.Map; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; @@ -37,12 +53,13 @@ public class StatisticsManager extends DataFunction { HandlerList.unregisterAll(joinQuitListener); } + public void saveStatisticsDataForOnlinePlayers(boolean unlock) { + plugin.getDataManager().getDataStorageInterface().saveStatistics(statisticsDataMap.entrySet(), unlock); + } + public void disable() { unload(); - DataManager dataManager = plugin.getDataManager(); - for (Map.Entry entry : statisticsDataMap.entrySet()) { - dataManager.getDataStorageInterface().saveStatistics(entry.getKey(), entry.getValue(), true); - } + saveStatisticsDataForOnlinePlayers(true); statisticsDataMap.clear(); } diff --git a/src/main/java/net/momirealms/customfishing/object/DataFunction.java b/src/main/java/net/momirealms/customfishing/object/DataFunction.java index 4515c8e6..d1ef83a5 100644 --- a/src/main/java/net/momirealms/customfishing/object/DataFunction.java +++ b/src/main/java/net/momirealms/customfishing/object/DataFunction.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customfishing.object; import java.util.HashMap; diff --git a/src/main/java/net/momirealms/customfishing/util/InventoryUtil.java b/src/main/java/net/momirealms/customfishing/util/InventoryUtil.java index 1f2b0bbe..0aa06ef9 100644 --- a/src/main/java/net/momirealms/customfishing/util/InventoryUtil.java +++ b/src/main/java/net/momirealms/customfishing/util/InventoryUtil.java @@ -27,6 +27,7 @@ import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.io.ObjectOutputStream; public class InventoryUtil { @@ -53,6 +54,7 @@ public class InventoryUtil { } dataOutput.close(); byte[] byteArr = outputStream.toByteArray(); + outputStream.close(); return Base64Coder.encodeLines(byteArr); } catch (IOException e) { throw new RuntimeException("[CustomFishing] Data save error", e); diff --git a/src/main/resources/messages/messages_english.yml b/src/main/resources/messages/messages_english.yml index 46c43f64..1f62ef34 100644 --- a/src/main/resources/messages/messages_english.yml +++ b/src/main/resources/messages/messages_english.yml @@ -30,7 +30,7 @@ messages: no-rod: 'You have to obtain a special rod to get loots!' no-player: 'No player' no-score: 'No score' - set-statistics: 'Successfully set {Player}''s {Loot} catch amount to {Amount}' + set-statistics: 'Successfully set {Player}''s {Loot} statistics to {Amount}' reset-statistics: 'Successfully reset {Player}''s statistics' negative-statistics: 'Amount should be a value no lower than zero' statistics-not-exist: 'That statistics does not exist' \ No newline at end of file diff --git a/src/main/resources/messages/messages_spanish.yml b/src/main/resources/messages/messages_spanish.yml index f9f2e760..2d656668 100644 --- a/src/main/resources/messages/messages_spanish.yml +++ b/src/main/resources/messages/messages_spanish.yml @@ -30,7 +30,7 @@ messages: no-rod: 'Hay que obtener una vara especial para conseguir botines' no-player: 'Ningún jugador' no-score: 'Sin puntuación' - set-statistics: 'Successfully set {Player}''s {Loot} catch amount to {Amount}' + set-statistics: 'Successfully set {Player}''s {Loot} statistics to {Amount}' reset-statistics: 'Successfully reset {Player}''s statistics' negative-statistics: 'Amount should be a value no lower than zero' statistics-not-exist: 'That statistics does not exist' \ No newline at end of file