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)
.classpath
/target/
*.iml

View File

@ -19,7 +19,7 @@ public class BankManager {
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;
@ -35,12 +35,10 @@ public class BankManager {
if (log.containsKey(player.getUniqueId())&&log.get(player.getUniqueId())!=null&&!log.get(player.getUniqueId()).isEmpty()) {
List<String> lore = new ArrayList<>();
List<Transaction> transactions = log.get(player.getUniqueId());
int count = 1;
while (count <= 10) {
if (transactions.size()-count < 0) { break; }
Transaction t = transactions.get(transactions.size()-count);
lore.add("#" + count + " " + t.timestamp.toString() +" " + t.player.getPlayer().getDisplayName() + " " + t.action.name().toLowerCase() + " " + EconomyManager.formatEconomy(t.ammount));
count++;
int size = transactions.size()>10 ? 10 : transactions.size();
for (int i = 0;i<size;i++) {
Transaction t = transactions.get((transactions.size()-1)-i);
lore.add("#" + (i+1) + " " + t.timestamp.toString() +" " + t.player.getPlayer().getDisplayName() + " " + t.action.name().toLowerCase() + " " + EconomyManager.formatEconomy(t.ammount));
}
return lore;
}else {
@ -53,13 +51,11 @@ public class BankManager {
public void addTransaction(Player p, Transaction transaction) {
if (log.containsKey(p.getUniqueId())) {
log.get(p.getUniqueId()).add(transaction);
}else {
}else {
List<Transaction> t = new ArrayList<>();
t.add(transaction);
log.put(p.getUniqueId(),t);
}
SkyBlock.getInstance().getPlayerDataManager().getPlayerData().get(p.getUniqueId()).getTransactions().add(transaction);
}
private void loadTransactions() {
@ -70,8 +66,9 @@ public class BankManager {
public List<String> getBalanceLore(Player player) {
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()));
result.add("If this is null then its a easy to fix bug: "+island.toString());
if (island != null) {
result.clear();
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
public String getName() {
return "adminbank";
return "bank";
}
@Override

View File

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

View File

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

View File

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

View File

@ -152,7 +152,7 @@ Command:
Short01:
Message: '&bSkyBlock &8| &cError&8: &eInvalid: /island admin bank [<Deposit|Withdraw|Balance>]'
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:
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:
@ -160,7 +160,7 @@ Command:
Balance:
Message: ' %player% have %bal%.'
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:
Message: 'Succesfully removed %ammount% from %player%''s island'
SuccesDeposit: