mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2025-12-28 19:39:06 +00:00
1.3.0-beta-5
This commit is contained in:
@@ -4,7 +4,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = 'net.momirealms'
|
||||
version = '1.3.0-beta-4'
|
||||
version = '1.3.0-beta-5'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -42,5 +42,4 @@ public class PlayerSellData {
|
||||
public void setDate(int date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* Copyright (C) <2022> <XiaoMoMi>
|
||||
*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.data;
|
||||
|
||||
import net.momirealms.customfishing.CustomFishing;
|
||||
|
||||
@@ -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<Map.Entry<UUID, Inventory>> set, boolean unlock);
|
||||
PlayerSellData loadSellData(UUID uuid, boolean force);
|
||||
void saveSellData(UUID uuid, PlayerSellData playerSellData, boolean unlock);
|
||||
void saveSellData(Set<Map.Entry<UUID, PlayerSellData>> set, boolean unlock);
|
||||
StorageType getStorageType();
|
||||
void saveStatistics(UUID uuid, PlayerStatisticsData statisticsData, boolean unlock);
|
||||
void saveStatistics(Set<Map.Entry<UUID, PlayerStatisticsData>> set, boolean unlock);
|
||||
PlayerStatisticsData loadStatistics(UUID uuid, boolean force);
|
||||
}
|
||||
|
||||
@@ -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<Map.Entry<UUID, Inventory>> set, boolean unlock) {
|
||||
for (Map.Entry<UUID, Inventory> 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<Map.Entry<UUID, PlayerSellData>> set, boolean unlock) {
|
||||
for (Map.Entry<UUID, PlayerSellData> 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<Map.Entry<UUID, PlayerStatisticsData>> set, boolean unlock) {
|
||||
for (Map.Entry<UUID, PlayerStatisticsData> 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"));
|
||||
|
||||
@@ -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<Map.Entry<UUID, Inventory>> 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<UUID, Inventory> 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<Map.Entry<UUID, PlayerSellData>> 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<UUID, PlayerSellData> 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<Map.Entry<UUID, PlayerStatisticsData>> 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<UUID, PlayerStatisticsData> 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)) {
|
||||
|
||||
@@ -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<UUID, Inventory> 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<UUID, Inventory> 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) {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Player, Inventory> inventoryMap;
|
||||
private final HashMap<UUID, PlayerSellData> sellDataMap;
|
||||
private final ConcurrentHashMap<UUID, PlayerSellData> 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<UUID, PlayerSellData> entry : sellDataMap.entrySet()) {
|
||||
dataStorage.saveSellData(entry.getKey(), entry.getValue(), true);
|
||||
}
|
||||
plugin.getDataManager().getDataStorageInterface().saveSellData(sellDataMap.entrySet(), true);
|
||||
sellDataMap.clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* Copyright (C) <2022> <XiaoMoMi>
|
||||
*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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<UUID, PlayerStatisticsData> entry : statisticsDataMap.entrySet()) {
|
||||
dataManager.getDataStorageInterface().saveStatistics(entry.getKey(), entry.getValue(), true);
|
||||
}
|
||||
saveStatisticsDataForOnlinePlayers(true);
|
||||
statisticsDataMap.clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* Copyright (C) <2022> <XiaoMoMi>
|
||||
*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.object;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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'
|
||||
@@ -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'
|
||||
Reference in New Issue
Block a user