[1.15.2.a.8] Added auto-transfer from vanilla ender storage
This commit is contained in:
parent
f4b43fc915
commit
df24c692d2
@ -1,6 +1,6 @@
|
||||
name: "EnderBank"
|
||||
author: TheTealViper
|
||||
version: "1.15.2.a.7"
|
||||
version: "1.15.2.a.8"
|
||||
api-version: 1.13
|
||||
description: "Bank system from popular RPG's."
|
||||
main: me.TheTealViper.enderbank.EnderBank
|
||||
|
||||
@ -50,20 +50,36 @@ public class BankStorage {
|
||||
return false;
|
||||
}
|
||||
|
||||
//This method REQUIRES the player to be online to initialize their bank.
|
||||
//This should be run the first time the player tries opening their ender inv
|
||||
//and the enderbank is created.
|
||||
public static void initiateBank(Player p) {
|
||||
PluginFile pf = new PluginFile(plugin, "banks/banks." + p.getUniqueId().toString() + ".yml");
|
||||
|
||||
//Set default items
|
||||
for(int i = 0;i < 42;i++) {
|
||||
pf.set("inventory." + i, new ItemStack(Material.AIR));
|
||||
}
|
||||
|
||||
//Carry over vanilla ender items
|
||||
int index = 0;
|
||||
for(ItemStack i : p.getEnderChest().getContents()) {
|
||||
if(i != null && !i.getType().equals(Material.AIR)) {
|
||||
pf.set("inventory." + index, i);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
//Set other default values
|
||||
pf.set("unlockedPages", 1);
|
||||
pf.save();
|
||||
}
|
||||
|
||||
public BankStorage(UUID bankOwnerUUID) {
|
||||
bankDatabase.put(bankOwnerUUID, this);
|
||||
this.bankOwnerUUID = bankOwnerUUID;
|
||||
pf = new PluginFile(plugin, "banks/banks." + bankOwnerUUID.toString() + ".yml");
|
||||
|
||||
//Load in defaults if not saved yet
|
||||
if(!pf.contains("unlockedPages")) {
|
||||
for(int i = 0;i < 42;i++) {
|
||||
pf.set("inventory." + i, new ItemStack(Material.AIR));
|
||||
}
|
||||
pf.set("unlockedPages", 1);
|
||||
pf.save();
|
||||
}
|
||||
|
||||
//Load in items
|
||||
items = new ArrayList<ItemStack>();
|
||||
ConfigurationSection sec = pf.getConfigurationSection("inventory");
|
||||
|
||||
@ -324,6 +324,8 @@ public class EnderBank extends JavaPlugin implements Listener {
|
||||
if(e.getAction().equals(Action.RIGHT_CLICK_BLOCK) && e.getClickedBlock().getType().equals(Material.ENDER_CHEST) && !disabledWorlds.contains(e.getPlayer().getWorld().getName())) {
|
||||
e.setCancelled(true);
|
||||
Player p = (Player) e.getPlayer();
|
||||
if(!BankStorage.hasBank(p.getUniqueId()))
|
||||
BankStorage.initiateBank(p);
|
||||
openEnderBank(p);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user