Fixed a limitation of 128 max stack size.
This commit is contained in:
parent
13a77ab9e0
commit
c6ac33e728
Binary file not shown.
@ -3323,8 +3323,8 @@ public class GenericFunctions {
|
|||||||
ItemUtils.DeleteAllLoreLinesAtAndAfterLineContainingSubstring(item, ChatColor.WHITE+"Contents (");
|
ItemUtils.DeleteAllLoreLinesAtAndAfterLineContainingSubstring(item, ChatColor.WHITE+"Contents (");
|
||||||
ItemUtils.DeleteAllLoreLinesAtAndAfterLineContainingSubstring(item, ChatColor.AQUA+" ");
|
ItemUtils.DeleteAllLoreLinesAtAndAfterLineContainingSubstring(item, ChatColor.AQUA+" ");
|
||||||
ItemUtils.addLore(item, ChatColor.WHITE+"Contents ("+GetItemCubeSpace(id)+"):");
|
ItemUtils.addLore(item, ChatColor.WHITE+"Contents ("+GetItemCubeSpace(id)+"):");
|
||||||
for (ItemStack it : TwosideKeeper.itemcube_updates.get(id)) {
|
for (ItemContainer it : TwosideKeeper.itemcube_updates.get(id)) {
|
||||||
ItemUtils.addLore(item, ChatColor.GRAY+" - "+GenericFunctions.UserFriendlyMaterialName(it)+(it.getAmount()>1?ChatColor.YELLOW+" x"+it.getAmount():""));
|
ItemUtils.addLore(item, ChatColor.GRAY+" - "+GenericFunctions.UserFriendlyMaterialName(it.getItem())+(it.getAmount()>1?ChatColor.YELLOW+" x"+it.getAmount():""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
package sig.plugin.TwosideKeeper.HelperStructures.Common;
|
||||||
|
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
//An Itemstack not bound by the limitation of 128 or more items in a stack.
|
||||||
|
public class ItemContainer {
|
||||||
|
ItemStack item;
|
||||||
|
int amt;
|
||||||
|
|
||||||
|
public ItemContainer(ItemStack item) {
|
||||||
|
this.item=item.clone();
|
||||||
|
this.amt=this.item.getAmount();
|
||||||
|
this.item.setAmount(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAmount(int amt) {
|
||||||
|
this.amt = amt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAmount() {
|
||||||
|
return this.amt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack getItem() {
|
||||||
|
return this.item;
|
||||||
|
}
|
||||||
|
}
|
@ -15,6 +15,7 @@ import sig.plugin.TwosideKeeper.TwosideKeeper;
|
|||||||
import sig.plugin.TwosideKeeper.HelperStructures.CubeType;
|
import sig.plugin.TwosideKeeper.HelperStructures.CubeType;
|
||||||
import sig.plugin.TwosideKeeper.HelperStructures.CustomItem;
|
import sig.plugin.TwosideKeeper.HelperStructures.CustomItem;
|
||||||
import sig.plugin.TwosideKeeper.HelperStructures.ItemCube;
|
import sig.plugin.TwosideKeeper.HelperStructures.ItemCube;
|
||||||
|
import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions;
|
||||||
import sig.plugin.TwosideKeeper.HolidayEvents.Christmas;
|
import sig.plugin.TwosideKeeper.HolidayEvents.Christmas;
|
||||||
|
|
||||||
public class InventoryUtils {
|
public class InventoryUtils {
|
||||||
@ -53,6 +54,7 @@ public class InventoryUtils {
|
|||||||
}*/
|
}*/
|
||||||
remaining = remainingitems.values().toArray(new ItemStack[0]);
|
remaining = remainingitems.values().toArray(new ItemStack[0]);
|
||||||
//TwosideKeeper.log("Remaining items: "+ArrayUtils.toString(remaining), 0);
|
//TwosideKeeper.log("Remaining items: "+ArrayUtils.toString(remaining), 0);
|
||||||
|
GenericFunctions.UpdateItemLore(itemStacks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return remaining;
|
return remaining;
|
||||||
@ -82,6 +84,7 @@ public class InventoryUtils {
|
|||||||
HashMap<Integer,ItemStack> remainingitems = ItemCubeUtils.AttemptingToAddItemToFilterCube(id,virtualinventory,remaining);
|
HashMap<Integer,ItemStack> remainingitems = ItemCubeUtils.AttemptingToAddItemToFilterCube(id,virtualinventory,remaining);
|
||||||
|
|
||||||
remaining = remainingitems.values().toArray(new ItemStack[0]);
|
remaining = remainingitems.values().toArray(new ItemStack[0]);
|
||||||
|
GenericFunctions.UpdateItemLore(itemStacks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return remaining;
|
return remaining;
|
||||||
|
@ -223,6 +223,7 @@ import sig.plugin.TwosideKeeper.HelperStructures.Common.BaublePouch;
|
|||||||
import sig.plugin.TwosideKeeper.HelperStructures.Common.BlockModifyQueue;
|
import sig.plugin.TwosideKeeper.HelperStructures.Common.BlockModifyQueue;
|
||||||
import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions;
|
import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions;
|
||||||
import sig.plugin.TwosideKeeper.HelperStructures.Common.Habitation;
|
import sig.plugin.TwosideKeeper.HelperStructures.Common.Habitation;
|
||||||
|
import sig.plugin.TwosideKeeper.HelperStructures.Common.ItemContainer;
|
||||||
import sig.plugin.TwosideKeeper.HelperStructures.Common.JobRecipe;
|
import sig.plugin.TwosideKeeper.HelperStructures.Common.JobRecipe;
|
||||||
import sig.plugin.TwosideKeeper.HelperStructures.Common.RecipeCategory;
|
import sig.plugin.TwosideKeeper.HelperStructures.Common.RecipeCategory;
|
||||||
import sig.plugin.TwosideKeeper.HelperStructures.Common.RecipeLinker;
|
import sig.plugin.TwosideKeeper.HelperStructures.Common.RecipeLinker;
|
||||||
@ -447,7 +448,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
public static File filesave;
|
public static File filesave;
|
||||||
public static HashMap<UUID,PlayerStructure> playerdata;
|
public static HashMap<UUID,PlayerStructure> playerdata;
|
||||||
public static HashMap<UUID,LivingEntityStructure> livingentitydata;
|
public static HashMap<UUID,LivingEntityStructure> livingentitydata;
|
||||||
public static HashMap<Integer,List<ItemStack>> itemcube_updates;
|
public static HashMap<Integer,List<ItemContainer>> itemcube_updates;
|
||||||
public static SpleefManager TwosideSpleefGames;
|
public static SpleefManager TwosideSpleefGames;
|
||||||
public static WorldShopManager TwosideShops;
|
public static WorldShopManager TwosideShops;
|
||||||
public static MysteriousEssenceLogger EssenceLogger; //The logger for Essences.
|
public static MysteriousEssenceLogger EssenceLogger; //The logger for Essences.
|
||||||
@ -964,7 +965,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
playerdata = new HashMap<UUID,PlayerStructure>();
|
playerdata = new HashMap<UUID,PlayerStructure>();
|
||||||
banksessions = new HashMap<UUID,BankSession>();
|
banksessions = new HashMap<UUID,BankSession>();
|
||||||
livingentitydata = new HashMap<UUID,LivingEntityStructure>();
|
livingentitydata = new HashMap<UUID,LivingEntityStructure>();
|
||||||
itemcube_updates = new HashMap<Integer,List<ItemStack>>();
|
itemcube_updates = new HashMap<Integer,List<ItemContainer>>();
|
||||||
|
|
||||||
validsetitems.add(Material.LEATHER_BOOTS);
|
validsetitems.add(Material.LEATHER_BOOTS);
|
||||||
validsetitems.add(Material.LEATHER_CHESTPLATE);
|
validsetitems.add(Material.LEATHER_CHESTPLATE);
|
||||||
@ -3621,21 +3622,19 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
//Save the Item Cube.
|
//Save the Item Cube.
|
||||||
itemCube_saveConfig(itemcube_id,save_items,cub);
|
itemCube_saveConfig(itemcube_id,save_items,cub);
|
||||||
|
|
||||||
List<ItemStack> itemcube_list = new ArrayList<ItemStack>();
|
List<ItemContainer> itemcube_list = new ArrayList<ItemContainer>();
|
||||||
for (ItemStack item : save_items) {
|
for (ItemStack item : save_items) {
|
||||||
if (ItemUtils.isValidItem(item)) {
|
if (ItemUtils.isValidItem(item)) {
|
||||||
boolean found=false;
|
boolean found=false;
|
||||||
for (int j=0;j<itemcube_list.size();j++) {
|
for (int j=0;j<itemcube_list.size();j++) {
|
||||||
if (itemcube_list.get(j).isSimilar(item)) {
|
if (itemcube_list.get(j).getItem().isSimilar(item)) {
|
||||||
ItemStack newitem = itemcube_list.get(j).clone();
|
itemcube_list.get(j).setAmount(itemcube_list.get(j).getAmount()+item.getAmount());
|
||||||
newitem.setAmount(newitem.getAmount()+item.getAmount());
|
|
||||||
itemcube_list.set(j, newitem);
|
|
||||||
found=true;
|
found=true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found) {
|
if (!found) {
|
||||||
itemcube_list.add(item);
|
itemcube_list.add(new ItemContainer(item));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4455,22 +4454,20 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
HashMap<Integer,ItemStack> remaining = virtualinventory.addItem(items);
|
HashMap<Integer,ItemStack> remaining = virtualinventory.addItem(items);
|
||||||
|
|
||||||
List<ItemStack> savelist = new ArrayList<ItemStack>();
|
List<ItemStack> savelist = new ArrayList<ItemStack>();
|
||||||
List<ItemStack> itemlist = new ArrayList<ItemStack>();
|
List<ItemContainer> itemlist = new ArrayList<ItemContainer>();
|
||||||
for (ItemStack it : virtualinventory.getContents()) {
|
for (ItemStack it : virtualinventory.getContents()) {
|
||||||
if (ItemUtils.isValidItem(it)) {
|
if (ItemUtils.isValidItem(it)) {
|
||||||
savelist.add(it);
|
savelist.add(it);
|
||||||
boolean found=false;
|
boolean found=false;
|
||||||
for (int j=0;j<itemlist.size();j++) {
|
for (int j=0;j<itemlist.size();j++) {
|
||||||
if (itemlist.get(j).isSimilar(it)) {
|
if (itemlist.get(j).getItem().isSimilar(it)) {
|
||||||
ItemStack olditem = itemlist.get(j).clone();
|
itemlist.get(j).setAmount(itemlist.get(j).getAmount()+it.getAmount());
|
||||||
olditem.setAmount(olditem.getAmount()+it.getAmount());
|
|
||||||
itemlist.set(j, olditem);
|
|
||||||
found=true;
|
found=true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found) {
|
if (!found) {
|
||||||
itemlist.add(it);
|
itemlist.add(new ItemContainer(it));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4804,23 +4801,21 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
int id = Integer.parseInt(ev.getInventory().getTitle().split("#")[1]);
|
int id = Integer.parseInt(ev.getInventory().getTitle().split("#")[1]);
|
||||||
|
|
||||||
List<ItemStack> itemcube_contents = new ArrayList<ItemStack>();
|
List<ItemStack> itemcube_contents = new ArrayList<ItemStack>();
|
||||||
List<ItemStack> itemcube_list = new ArrayList<ItemStack>();
|
List<ItemContainer> itemcube_list = new ArrayList<ItemContainer>();
|
||||||
for (int i=0;i<p.getOpenInventory().getTopInventory().getSize();i++) {
|
for (int i=0;i<p.getOpenInventory().getTopInventory().getSize();i++) {
|
||||||
if (p.getOpenInventory().getTopInventory().getItem(i)!=null) {
|
if (p.getOpenInventory().getTopInventory().getItem(i)!=null) {
|
||||||
//p.sendMessage("Saving item "+p.getOpenInventory().getTopInventory().getItem(i).toString()+" in slot "+i);
|
//p.sendMessage("Saving item "+p.getOpenInventory().getTopInventory().getItem(i).toString()+" in slot "+i);
|
||||||
itemcube_contents.add(p.getOpenInventory().getTopInventory().getItem(i));
|
itemcube_contents.add(p.getOpenInventory().getTopInventory().getItem(i));
|
||||||
boolean found=false;
|
boolean found=false;
|
||||||
for (int j=0;j<itemcube_list.size();j++) {
|
for (int j=0;j<itemcube_list.size();j++) {
|
||||||
if (itemcube_list.get(j).isSimilar(p.getOpenInventory().getTopInventory().getItem(i))) {
|
if (itemcube_list.get(j).getItem().isSimilar(p.getOpenInventory().getTopInventory().getItem(i))) {
|
||||||
ItemStack newitem = itemcube_list.get(j).clone();
|
itemcube_list.get(j).setAmount(itemcube_list.get(j).getAmount()+p.getOpenInventory().getTopInventory().getItem(i).getAmount());
|
||||||
newitem.setAmount(newitem.getAmount()+p.getOpenInventory().getTopInventory().getItem(i).getAmount());
|
|
||||||
itemcube_list.set(j, newitem);
|
|
||||||
found=true;
|
found=true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found) {
|
if (!found) {
|
||||||
itemcube_list.add(p.getOpenInventory().getTopInventory().getItem(i));
|
itemcube_list.add(new ItemContainer(p.getOpenInventory().getTopInventory().getItem(i)));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//p.sendMessage("Saving item AIR in slot "+i);
|
//p.sendMessage("Saving item AIR in slot "+i);
|
||||||
@ -5239,21 +5234,19 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
//ItemCubeWindow.removeAllItemCubeWindows((Player)ev.getWhoClicked());
|
//ItemCubeWindow.removeAllItemCubeWindows((Player)ev.getWhoClicked());
|
||||||
Player p = (Player)ev.getWhoClicked();
|
Player p = (Player)ev.getWhoClicked();
|
||||||
pd = PlayerStructure.GetPlayerStructure(p);
|
pd = PlayerStructure.GetPlayerStructure(p);
|
||||||
List<ItemStack> itemcube_list = new ArrayList<ItemStack>();
|
List<ItemContainer> itemcube_list = new ArrayList<ItemContainer>();
|
||||||
for (int i=0;i<ev.getWhoClicked().getOpenInventory().getTopInventory().getSize();i++) {
|
for (int i=0;i<ev.getWhoClicked().getOpenInventory().getTopInventory().getSize();i++) {
|
||||||
if (ItemUtils.isValidItem(ev.getWhoClicked().getOpenInventory().getTopInventory().getItem(i))) {
|
if (ItemUtils.isValidItem(ev.getWhoClicked().getOpenInventory().getTopInventory().getItem(i))) {
|
||||||
boolean found=false;
|
boolean found=false;
|
||||||
for (int j=0;j<itemcube_list.size();j++) {
|
for (int j=0;j<itemcube_list.size();j++) {
|
||||||
if (itemcube_list.get(j).isSimilar(ev.getWhoClicked().getOpenInventory().getTopInventory().getItem(i))) {
|
if (itemcube_list.get(j).getItem().isSimilar(ev.getWhoClicked().getOpenInventory().getTopInventory().getItem(i))) {
|
||||||
ItemStack newitem = itemcube_list.get(j).clone();
|
itemcube_list.get(j).setAmount(itemcube_list.get(j).getAmount()+ev.getWhoClicked().getOpenInventory().getTopInventory().getItem(i).getAmount());
|
||||||
newitem.setAmount(newitem.getAmount()+ev.getWhoClicked().getOpenInventory().getTopInventory().getItem(i).getAmount());
|
|
||||||
itemcube_list.set(j, newitem);
|
|
||||||
found=true;
|
found=true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found) {
|
if (!found) {
|
||||||
itemcube_list.add(ev.getWhoClicked().getOpenInventory().getTopInventory().getItem(i));
|
itemcube_list.add(new ItemContainer(ev.getWhoClicked().getOpenInventory().getTopInventory().getItem(i)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5426,22 +5419,20 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
log("Cursor should be air.",5);
|
log("Cursor should be air.",5);
|
||||||
}
|
}
|
||||||
List<ItemStack> itemslist = new ArrayList<ItemStack>();
|
List<ItemStack> itemslist = new ArrayList<ItemStack>();
|
||||||
List<ItemStack> itemcube_list = new ArrayList<ItemStack>();
|
List<ItemContainer> itemcube_list = new ArrayList<ItemContainer>();
|
||||||
for (int i=0;i<virtualinventory.getSize();i++) {
|
for (int i=0;i<virtualinventory.getSize();i++) {
|
||||||
itemslist.add(virtualinventory.getItem(i));
|
itemslist.add(virtualinventory.getItem(i));
|
||||||
if (ItemUtils.isValidItem(virtualinventory.getItem(i))) {
|
if (ItemUtils.isValidItem(virtualinventory.getItem(i))) {
|
||||||
boolean found=false;
|
boolean found=false;
|
||||||
for (int j=0;j<itemcube_list.size();j++) {
|
for (int j=0;j<itemcube_list.size();j++) {
|
||||||
if (itemcube_list.get(j).isSimilar(virtualinventory.getItem(i))) {
|
if (itemcube_list.get(j).getItem().isSimilar(virtualinventory.getItem(i))) {
|
||||||
ItemStack newitem = itemcube_list.get(j).clone();
|
itemcube_list.get(j).setAmount(itemcube_list.get(j).getAmount()+virtualinventory.getItem(i).getAmount());
|
||||||
newitem.setAmount(newitem.getAmount()+virtualinventory.getItem(i).getAmount());
|
|
||||||
itemcube_list.set(j, newitem);
|
|
||||||
found=true;
|
found=true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found) {
|
if (!found) {
|
||||||
itemcube_list.add(virtualinventory.getItem(i));
|
itemcube_list.add(new ItemContainer(virtualinventory.getItem(i)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5463,22 +5454,20 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
ev.setCursor(new ItemStack(Material.AIR));
|
ev.setCursor(new ItemStack(Material.AIR));
|
||||||
}
|
}
|
||||||
List<ItemStack> itemslist = new ArrayList<ItemStack>();
|
List<ItemStack> itemslist = new ArrayList<ItemStack>();
|
||||||
List<ItemStack> itemcube_list = new ArrayList<ItemStack>();
|
List<ItemContainer> itemcube_list = new ArrayList<ItemContainer>();
|
||||||
for (int i=0;i<ev.getWhoClicked().getOpenInventory().getTopInventory().getSize();i++) {
|
for (int i=0;i<ev.getWhoClicked().getOpenInventory().getTopInventory().getSize();i++) {
|
||||||
itemslist.add(ev.getWhoClicked().getOpenInventory().getTopInventory().getItem(i));
|
itemslist.add(ev.getWhoClicked().getOpenInventory().getTopInventory().getItem(i));
|
||||||
if (ItemUtils.isValidItem(ev.getWhoClicked().getOpenInventory().getTopInventory().getItem(i))) {
|
if (ItemUtils.isValidItem(ev.getWhoClicked().getOpenInventory().getTopInventory().getItem(i))) {
|
||||||
boolean found=false;
|
boolean found=false;
|
||||||
for (int j=0;j<itemcube_list.size();j++) {
|
for (int j=0;j<itemcube_list.size();j++) {
|
||||||
if (itemcube_list.get(j).isSimilar(ev.getWhoClicked().getOpenInventory().getTopInventory().getItem(i))) {
|
if (itemcube_list.get(j).getItem().isSimilar(ev.getWhoClicked().getOpenInventory().getTopInventory().getItem(i))) {
|
||||||
ItemStack newitem = itemcube_list.get(j).clone();
|
itemcube_list.get(j).setAmount(itemcube_list.get(j).getAmount()+ev.getWhoClicked().getOpenInventory().getTopInventory().getItem(i).getAmount());
|
||||||
newitem.setAmount(newitem.getAmount()+ev.getWhoClicked().getOpenInventory().getTopInventory().getItem(i).getAmount());
|
|
||||||
itemcube_list.set(j, newitem);
|
|
||||||
found=true;
|
found=true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found) {
|
if (!found) {
|
||||||
itemcube_list.add(ev.getWhoClicked().getOpenInventory().getTopInventory().getItem(i));
|
itemcube_list.add(new ItemContainer(ev.getWhoClicked().getOpenInventory().getTopInventory().getItem(i)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user