fixed bugs

This commit is contained in:
MyCraftServerMC 2020-06-02 16:31:44 +02:00 committed by Brianna
parent 11b2d688bf
commit 39735aefa4
7 changed files with 38 additions and 23 deletions

2
.gitignore vendored
View File

@ -36,3 +36,5 @@ hs_err_pid*
# JDT-specific (Eclipse Java Development Tools) # JDT-specific (Eclipse Java Development Tools)
.classpath .classpath
/target/ /target/
*.iml

View File

@ -19,7 +19,7 @@ public class BankManager {
public static BankManager getInstance() {return instance == null ? instance = new BankManager() : instance;} public static BankManager getInstance() {return instance == null ? instance = new BankManager() : instance;}
public HashMap<UUID, List<Transaction>> log; private HashMap<UUID, List<Transaction>> log;
public FileConfiguration lang; public FileConfiguration lang;
@ -35,12 +35,10 @@ public class BankManager {
if (log.containsKey(player.getUniqueId())&&log.get(player.getUniqueId())!=null&&!log.get(player.getUniqueId()).isEmpty()) { if (log.containsKey(player.getUniqueId())&&log.get(player.getUniqueId())!=null&&!log.get(player.getUniqueId()).isEmpty()) {
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();
List<Transaction> transactions = log.get(player.getUniqueId()); List<Transaction> transactions = log.get(player.getUniqueId());
int count = 1; int size = transactions.size()>10 ? 10 : transactions.size();
while (count <= 10) { for (int i = 0;i<size;i++) {
if (transactions.size()-count < 0) { break; } Transaction t = transactions.get((transactions.size()-1)-i);
Transaction t = transactions.get(transactions.size()-count); lore.add("#" + (i+1) + " " + t.timestamp.toString() +" " + t.player.getPlayer().getDisplayName() + " " + t.action.name().toLowerCase() + " " + EconomyManager.formatEconomy(t.ammount));
lore.add("#" + count + " " + t.timestamp.toString() +" " + t.player.getPlayer().getDisplayName() + " " + t.action.name().toLowerCase() + " " + EconomyManager.formatEconomy(t.ammount));
count++;
} }
return lore; return lore;
}else { }else {
@ -53,13 +51,11 @@ public class BankManager {
public void addTransaction(Player p, Transaction transaction) { public void addTransaction(Player p, Transaction transaction) {
if (log.containsKey(p.getUniqueId())) { if (log.containsKey(p.getUniqueId())) {
log.get(p.getUniqueId()).add(transaction); log.get(p.getUniqueId()).add(transaction);
}else { }else {
List<Transaction> t = new ArrayList<>(); List<Transaction> t = new ArrayList<>();
t.add(transaction); t.add(transaction);
log.put(p.getUniqueId(),t); log.put(p.getUniqueId(),t);
} }
SkyBlock.getInstance().getPlayerDataManager().getPlayerData().get(p.getUniqueId()).getTransactions().add(transaction);
} }
private void loadTransactions() { private void loadTransactions() {
@ -70,8 +66,9 @@ public class BankManager {
public List<String> getBalanceLore(Player player) { public List<String> getBalanceLore(Player player) {
List<String> result = new ArrayList<>(); List<String> result = new ArrayList<>();
result.add("Some error occured while loading your balance"); result.add("Some error occurred while loading your balance!");
Island island = SkyBlock.getInstance().getIslandManager().getIslandByPlayer(Bukkit.getOfflinePlayer(player.getUniqueId())); Island island = SkyBlock.getInstance().getIslandManager().getIslandByPlayer(Bukkit.getOfflinePlayer(player.getUniqueId()));
result.add("If this is null then its a easy to fix bug: "+island.toString());
if (island != null) { if (island != null) {
result.clear(); result.clear();
result.add(player.getDisplayName()+"'s balance is "+EconomyManager.formatEconomy(EconomyManager.getBalance(Bukkit.getOfflinePlayer(player.getUniqueId())))); result.add(player.getDisplayName()+"'s balance is "+EconomyManager.formatEconomy(EconomyManager.getBalance(Bukkit.getOfflinePlayer(player.getUniqueId()))));

View File

@ -121,7 +121,7 @@ public class AdminBank extends SubCommand {
@Override @Override
public String getName() { public String getName() {
return "adminbank"; return "bank";
} }
@Override @Override

View File

@ -532,6 +532,7 @@ public class IslandManager {
if ((amt = data.getIslandDeletionCount()) >= highest) return false; if ((amt = data.getIslandDeletionCount()) >= highest) return false;
data.setIslandDeletionCount(amt + 1); data.setIslandDeletionCount(amt + 1);
data.deleteTransactions();
} }
} }
} }

View File

@ -146,7 +146,7 @@ public class Bank {
} }
public void open(Player player) { public void open(Player player) {
Island island = null; Island island;
island = islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(player.getUniqueId())); island = islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(player.getUniqueId()));

View File

@ -229,18 +229,34 @@ public class PlayerData {
this.viewer = viewer; this.viewer = viewer;
} }
public void deleteTransactions() {
Config config = getConfig();
FileConfiguration configLoad = config.getFileConfiguration();
configLoad.set("Bank.Transactions",null);
configLoad.set("Bank.Transactions.Size",0);
try {
configLoad.save(config.getFile());
} catch (IOException e) {
e.printStackTrace();
}
}
public void save() { public void save() {
transactions = BankManager.getInstance().getTransactionList(getPlayer()); transactions = BankManager.getInstance().getTransactionList(getPlayer());
Config config = getConfig(); Config config = getConfig();
FileConfiguration configLoad = config.getFileConfiguration(); FileConfiguration configLoad = config.getFileConfiguration();
configLoad.set("Statistics.Island.Playtime", getPlaytime()); configLoad.set("Statistics.Island.Playtime", getPlaytime());
configLoad.set("Bank.Transactions.Size",transactions.size()); if (transactions != null) {
for (int i = 0;i<transactions.size();i++) { configLoad.set("Bank.Transactions.Size", transactions.size());
Transaction t = transactions.get(i); for (int i = 0; i < transactions.size(); i++) {
configLoad.set("Bank.Transactions."+i+".Action",t.action.name()); Transaction t = transactions.get(i);
configLoad.set("Bank.Transactions."+i+".Amount",t.ammount); configLoad.set("Bank.Transactions." + i + ".Action", t.action.name());
configLoad.set("Bank.Transactions."+i+".Player",t.player.getUniqueId().toString()); configLoad.set("Bank.Transactions." + i + ".Amount", t.ammount);
configLoad.set("Bank.Transactions."+i+".Date",t.timestamp.getTime()); configLoad.set("Bank.Transactions." + i + ".Player", t.player.getUniqueId().toString());
configLoad.set("Bank.Transactions." + i + ".Date", t.timestamp.getTime());
}
}else {
configLoad.set("Bank.Transactions.Size", 0);
} }
try { try {
configLoad.save(config.getFile()); configLoad.save(config.getFile());
@ -251,7 +267,6 @@ public class PlayerData {
private Config getConfig() { private Config getConfig() {
SkyBlock skyblock = SkyBlock.getInstance(); SkyBlock skyblock = SkyBlock.getInstance();
return skyblock.getFileManager().getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"), uuid.toString() + ".yml")); return skyblock.getFileManager().getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"), uuid.toString() + ".yml"));
} }

View File

@ -152,7 +152,7 @@ Command:
Short01: Short01:
Message: '&bSkyBlock &8| &cError&8: &eInvalid: /island admin bank [<Deposit|Withdraw|Balance>]' Message: '&bSkyBlock &8| &cError&8: &eInvalid: /island admin bank [<Deposit|Withdraw|Balance>]'
Short02: Short02:
Message: '&bSkyBlock &8| &cError&8: &eInvalid: /island admin bank [Player] [<Deposit|Withdraw|Balance>]' Message: '&bSkyBlock &8| &cError&8: &eInvalid: /island admin bank [<Deposit|Withdraw|Balance>] [Player]'
NullIsland: NullIsland:
Message: '&bSkyBlock &8| &cError&8: &eYou are not on an island, please specify a Player or move to an island. Or maybe you are on nullisland?' Message: '&bSkyBlock &8| &cError&8: &eYou are not on an island, please specify a Player or move to an island. Or maybe you are on nullisland?'
ByConsole: ByConsole:
@ -160,7 +160,7 @@ Command:
Balance: Balance:
Message: ' %player% have %bal%.' Message: ' %player% have %bal%.'
Info: Info:
Message: '&bSkyBlock &8| &cError&8: /island admin bank [Player] [<Deposit|Withdraw|Balance>]' Message: '&bSkyBlock &8| &cError&8: /island admin bank [<Deposit|Withdraw|Balance>] [Player]'
SuccesWithdraw: SuccesWithdraw:
Message: 'Succesfully removed %ammount% from %player%''s island' Message: 'Succesfully removed %ammount% from %player%''s island'
SuccesDeposit: SuccesDeposit: