1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 11:45:51 +00:00
This commit is contained in:
TheBusyBiscuit 2019-08-26 19:13:56 +02:00
parent 65975ae094
commit 7aff9a7fe4
4 changed files with 17 additions and 6 deletions

View File

@ -15,6 +15,7 @@ import org.bukkit.inventory.ItemStack;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
import me.mrCookieSlime.Slimefun.Objects.Research;
import me.mrCookieSlime.Slimefun.api.inventory.BackpackInventory;
/**
* A class that can store a Player's Research Profile for caching
@ -43,7 +44,7 @@ public class PlayerProfile {
}
}
protected Config getConfig() {
public Config getConfig() {
return cfg;
}

View File

@ -1,10 +1,11 @@
package me.mrCookieSlime.Slimefun.api;
package me.mrCookieSlime.Slimefun.api.inventory;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
import me.mrCookieSlime.Slimefun.api.PlayerProfile;
public class BackpackInventory {
@ -17,7 +18,7 @@ public class BackpackInventory {
/**
* This constructor loads an existing Backpack
*/
protected BackpackInventory(PlayerProfile profile, int id) {
public BackpackInventory(PlayerProfile profile, int id) {
this(profile, id, profile.getConfig().getInt("backpacks." + id + ".size"));
for (int i = 0; i < size; i++) {
@ -28,7 +29,7 @@ public class BackpackInventory {
/**
* This constructor creates a new Backpack
*/
protected BackpackInventory(PlayerProfile profile, int id, int size) {
public BackpackInventory(PlayerProfile profile, int id, int size) {
this.profile = profile;
this.id = id;
this.cfg = profile.getConfig();
@ -61,6 +62,15 @@ public class BackpackInventory {
public void setSize(int size) {
this.size = size;
cfg.setValue("backpacks." + id + ".size", size);
Inventory inventory = Bukkit.createInventory(null, size, "Backpack [" + size + " Slots]");
for (int slot = 0; slot < this.inventory.getSize(); slot++) {
inventory.setItem(slot, this.inventory.getItem(slot));
}
this.inventory = inventory;
markDirty();
}

View File

@ -25,9 +25,9 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunBackpack;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.Setup.Messages;
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
import me.mrCookieSlime.Slimefun.api.BackpackInventory;
import me.mrCookieSlime.Slimefun.api.PlayerProfile;
import me.mrCookieSlime.Slimefun.api.Slimefun;
import me.mrCookieSlime.Slimefun.api.inventory.BackpackInventory;
public class BackpackListener implements Listener {

View File

@ -14,8 +14,8 @@ import org.bukkit.potion.PotionEffect;
import me.mrCookieSlime.Slimefun.SlimefunStartup;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
import me.mrCookieSlime.Slimefun.api.BackpackInventory;
import me.mrCookieSlime.Slimefun.api.PlayerProfile;
import me.mrCookieSlime.Slimefun.api.inventory.BackpackInventory;
public class CoolerListener implements Listener {