Skip to content

Commit f780862

Browse files
authored
Merge pull request #9 from AnExiledDev/pookins_test
2 parents 2341f2a + 84e8915 commit f780862

1 file changed

Lines changed: 48 additions & 22 deletions

File tree

StackSizeController.cs

Lines changed: 48 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace Oxide.Plugins
99
{
10-
[Info("Stack Size Controller", "AnExiledGod", "3.3.0")]
10+
[Info("Stack Size Controller", "AnExiledGod", "3.3.1")]
1111
[Description("Allows configuration of most items max stack size.")]
1212
class StackSizeController : CovalencePlugin
1313
{
@@ -18,7 +18,10 @@ class StackSizeController : CovalencePlugin
1818
private readonly List<string> _ignoreList = new List<string>
1919
{
2020
"water",
21-
"water.salt"
21+
"water.salt",
22+
"cardtable",
23+
"hat.bunnyhat",
24+
"rustige_egg_e"
2225
};
2326

2427
private void Init()
@@ -260,7 +263,7 @@ private void UpdateIndividualItemStackMultiplier(string shortname, float multipl
260263

261264
private void UpdateIndividualItemHardLimit(int itemId, int stackLimit)
262265
{
263-
if (_config.IndividualItemStackMultipliers.ContainsKey(itemId.ToString()))
266+
if (_config.IndividualItemStackHardLimits.ContainsKey(itemId.ToString()))
264267
{
265268
_config.IndividualItemStackHardLimits[itemId.ToString()] = stackLimit;
266269

@@ -276,7 +279,7 @@ private void UpdateIndividualItemHardLimit(int itemId, int stackLimit)
276279

277280
private void UpdateIndividualItemHardLimit(string shortname, int stackLimit)
278281
{
279-
if (_config.IndividualItemStackMultipliers.ContainsKey(shortname))
282+
if (_config.IndividualItemStackHardLimits.ContainsKey(shortname))
280283
{
281284
_config.IndividualItemStackHardLimits[shortname] = stackLimit;
282285

@@ -351,6 +354,8 @@ private void CreateItemIndex()
351354
// Create categories
352355
foreach (string category in Enum.GetNames(typeof(ItemCategory)))
353356
{
357+
if (category == "All") { continue; }
358+
354359
_data.ItemCategories.Add(category, new List<ItemInfo>());
355360
}
356361

@@ -490,7 +495,7 @@ private void SetStackCommand(IPlayer player, string command, string[] args)
490495

491496
ItemDefinition itemDefinition = ItemManager.FindItemDefinition(args[0]);
492497
string stackSizeString = args[1];
493-
498+
494499
if (itemDefinition == null)
495500
{
496501
player.Reply(GetMessage("InvalidItemShortnameOrId", player.Id));
@@ -633,6 +638,40 @@ private void ListCategoryItemsCommand(IPlayer player, string command, string[] a
633638

634639
#region Hooks
635640

641+
// TODO: Investigate merging CanStackItem into CanMoveItem and potential performance issues
642+
object CanMoveItem(Item item, PlayerInventory playerLoot, uint targetContainer, int targetSlot, int amount)
643+
{
644+
if (_config.DisableDupeFixAndLeaveWeaponMagsAlone)
645+
{
646+
return null;
647+
}
648+
649+
if (item.contents?.itemList.Count > 0)
650+
{
651+
foreach (Item containedItem in item.contents.itemList)
652+
{
653+
item.parent.AddItem(containedItem.info, containedItem.amount, containedItem.skin);
654+
}
655+
656+
item.contents.Clear();
657+
}
658+
659+
Item targetItem = item.parent.GetSlot(targetSlot);
660+
661+
// Return contents
662+
if (targetItem?.contents?.itemList.Count > 0)
663+
{
664+
foreach (Item containedItem in targetItem.contents.itemList)
665+
{
666+
targetItem.parent.AddItem(containedItem.info, containedItem.amount, containedItem.skin);
667+
}
668+
669+
targetItem.contents.Clear();
670+
}
671+
672+
return null;
673+
}
674+
636675
private object CanStackItem(Item item, Item targetItem)
637676
{
638677
if (_config.DisableDupeFixAndLeaveWeaponMagsAlone ||
@@ -665,17 +704,7 @@ private object CanStackItem(Item item, Item targetItem)
665704
return false;
666705
}
667706
}
668-
669-
// Return contents
670-
if (targetItem.contents?.itemList.Count > 0)
671-
{
672-
foreach (Item containedItem in targetItem.contents.itemList)
673-
{
674-
item.parent.playerOwner.GiveItem(ItemManager.CreateByItemID(containedItem.info.itemid,
675-
containedItem.amount));
676-
}
677-
}
678-
707+
679708
BaseProjectile.Magazine itemMag =
680709
targetItem.GetHeldEntity()?.GetComponent<BaseProjectile>()?.primaryMagazine;
681710

@@ -684,8 +713,7 @@ private object CanStackItem(Item item, Item targetItem)
684713
{
685714
if (itemMag.contents > 0)
686715
{
687-
item.GetOwnerPlayer().GiveItem(ItemManager.CreateByItemID(itemMag.ammoType.itemid,
688-
itemMag.contents));
716+
item.parent.AddItem(itemMag.ammoType, itemMag.contents);
689717

690718
itemMag.contents = 0;
691719
}
@@ -697,8 +725,7 @@ private object CanStackItem(Item item, Item targetItem)
697725

698726
if (flameThrower.ammo > 0)
699727
{
700-
item.GetOwnerPlayer().GiveItem(ItemManager.CreateByItemID(flameThrower.fuelType.itemid,
701-
flameThrower.ammo));
728+
item.parent.AddItem(flameThrower.fuelType, flameThrower.ammo);
702729

703730
flameThrower.ammo = 0;
704731
}
@@ -710,8 +737,7 @@ private object CanStackItem(Item item, Item targetItem)
710737

711738
if (chainsaw.ammo > 0)
712739
{
713-
item.GetOwnerPlayer().GiveItem(ItemManager.CreateByItemID(chainsaw.fuelType.itemid,
714-
chainsaw.ammo));
740+
item.parent.AddItem(chainsaw.fuelType, chainsaw.ammo);
715741

716742
chainsaw.ammo = 0;
717743
}

0 commit comments

Comments
 (0)