OnItemRecycle hook conflict with HomeRecycler pluginSolved

Calling hook OnItemRecycle resulted in a conflict between the following plugins: HomeRecycler - True (Boolean), RecycleManager (False (Boolean))

How can I fix this issue?

This indicates that both plugins are overriding how a particular item is recycled. I could just make RecycleManager return True here since the exact return value for this hook doesn't matter, but the fact would remain that the item is being basically double recycled, processed by both plugins which is a problem.

For next steps, we need to determine when this happens. For which recyclers, and which items. According to the Home Recycler documentation, it only affects recyclers players have at home, but unclear whether it overrides recycling for all items, or if it is somehow intelligent and will ignore items that haven't been adjusted in that plugin's config. If you can do some testing to determine when this happens, that will help.

Once we understand when this happens, we can try to make a judgment about which plugin should be deferring to the other. For example, if Home Recycler needs control for a specific item or recycler, it can be updated to call Recycle Manager hooks to gain that control.

So I allow recycyling of all items and it happens to any item from any item category that can be recycled I get the console spam. I'll include my config for that plugin.

I can confirm that the spam issue only happens with HomeRecyclers and it doesn't happen with recyclers found at monuments like Outpost and Airfield etc.

 

{
"chatCommand": "rec",
"craftCommand": "craftrecycler",
"useUIForCrafting": true,
"recyclerItemName": "research.table",
"recyclerShortPrefabName": "researchtable_deployed",
"allowDamage": true,
"allowRepair": true,
"prefabToCloneDamage": "assets/prefabs/deployable/research table/researchtable_deployed.prefab",
"health": 500.0,
"canChangePublicRecyclerParams": false,
"restrictUseByCupboard": true,
"adminSpawnsPublicRecycler": false,
"useSpawning": true,
"useCrafting": false,
"useSpawnCooldown": true,
"useCraftCooldown": true,
"useSpawnLimit": true,
"useCraftLimit": false,
"allowDeployOnGround": true,
"allowPickupByHammerHit": true,
"pickupOnlyOwnerFriends": true,
"spawnInLoot": false,
"trackStacking": false,
"dropRecyclerItemWhenFloorDestroyed": false,
"DefaultRates": {
"Priority": 1,
"spawnCooldown": 86400.0,
"craftCooldown": 86400.0,
"craftLimit": 3,
"spawnLimit": 3,
"Ratio": 0.5,
"RatioScrap": 1.0,
"Speed": 5.0,
"percentOfMaxStackToTake": 0.1
},
"blackList": [],
"itemsNeededToCraft": {
"scrap": 750,
"gears": 25,
"metalspring": 25
},
"PermissionsRates": {
"viptest2": {
"Priority": 2,
"spawnCooldown": 86400.0,
"craftCooldown": 86400.0,
"craftLimit": 1,
"spawnLimit": 1,
"Ratio": 0.7,
"RatioScrap": 1.0,
"Speed": 3.0,
"percentOfMaxStackToTake": 0.1
},
"viptest": {
"Priority": 1,
"spawnCooldown": 86400.0,
"craftCooldown": 86400.0,
"craftLimit": 1,
"spawnLimit": 1,
"Ratio": 0.5,
"RatioScrap": 1.0,
"Speed": 5.0,
"percentOfMaxStackToTake": 0.1
}
},
"Loot": [],
"Version": {
"Major": 2,
"Minor": 0,
"Patch": 6
}
}

I suppose the question is, which plugin do you want to control how items are recycled in home recyclers? Does the answer depend on which item is to be recycled? Do you want both plugins to somehow stack in terms of how the item is recycled?

If you just want to use the HomeRecycler plugin to allow players to have recyclers at home, but allow Recycle Manager to control how items are recycled, then the best solution would be for k1lly0u to add a config option that determines whether his plugin tries to alter recycling, which you could use to disable that aspect.

NKXTQs24ExGTuL8.jpg WhiteThunder

I suppose the question is, which plugin do you want to control how items are recycled in home recyclers? Does the answer depend on which item is to be recycled? Do you want both plugins to somehow stack in terms of how the item is recycled?

If you just want to use the HomeRecycler plugin to allow players to have recyclers at home, but allow Recycle Manager to control how items are recycled, then the best solution would be for k1lly0u to add a config option that determines whether his plugin tries to alter recycling, which you could use to disable that aspect.

I use HomeRecyler 100% only for placing a Recycler in a players bases and NOTHING else. I use RecyclerManager only for Instant Recycler permission and Recycle speed permisions and thats it. I want RecycleManager to control the Recycling of items and HomeReycler to just control the placement of HomeRecyclers. Hope this makes sense :)

That makes sense. According to your use case, I suggest you ask k1lly0u to add a config option to HomeRecycler that allows you to prevent that plugin from affecting how items are recycled (basically don't use the OnItemRecycle hook if the feature is disabled). Alternatively, k1lly0u could make the code more careful by only attempting to override how an item is recycled--as well as the speed of the recycler--if the circumstances call for it, such as if the player has permission for a non-vanilla ratio/speed.

Given that you don't use Recycle Manager to change/override recycler output, there's an opportunity for me to add a way to disable that feature which would be one way to resolve the conflict, but that idea is a bit strange given that it is the main function of the plugin (proclaimed on the video thumbnail).


Merged post

On second thought, I've gone ahead and made a change to Recycle Manager to make it avoid overriding how the item is recycled (i.e., return null in OnItemRecycle) if all of the following criteria are met.

  • The percentage of max stack size to be recycled is vanilla
  • The output multipliers for all of the ingredients match vanilla
  • The item has no output override

You can download it here:
https://raw.githubusercontent.com/WheteThunger/RecycleManager/master/RecycleManager.cs

NKXTQs24ExGTuL8.jpg WhiteThunder

That makes sense. According to your use case, I suggest you ask k1lly0u to add a config option to HomeRecycler that allows you to prevent that plugin from affecting how items are recycled (basically don't use the OnItemRecycle hook if the feature is disabled). Alternatively, k1lly0u could make the code more careful by only attempting to override how an item is recycled--as well as the speed of the recycler--if the circumstances call for it, such as if the player has permission for a non-vanilla ratio/speed.

Given that you don't use Recycle Manager to change/override recycler output, there's an opportunity for me to add a way to disable that feature which would be one way to resolve the conflict, but that idea is a bit strange given that it is the main function of the plugin (proclaimed on the video thumbnail).


Merged post

On second thought, I've gone ahead and made a change to Recycle Manager to make it avoid overriding how the item is recycled (i.e., return null in OnItemRecycle) if all of the following criteria are met.

  • The percentage of max stack size to be recycled is vanilla
  • The output multipliers for all of the ingredients match vanilla
  • The item has no output override

You can download it here:
https://raw.githubusercontent.com/WheteThunger/RecycleManager/master/RecycleManager.cs

So I just realized I could use HomeRecycler for the same thing I use RecycleManager for, it has a permission where i can set that permission to have instant recycler. Then it has a config option to effect all Recyclers.

I realized I can just add this config option to "HomeRecycler" to apply the HomeRecycler options to all recyclers to only those who have HomeRecycler permissions, which is exactly what I needed. It was turned off before. So my problem is all fixed! I don't need to also use Recycler Manager plugin for InstantRecycle, I just need to use Two permissions of HomeRecycler. One for my HomeRecycler VIP Perk, and one for my Instant Recycle VIP perk.

 

"canChangePublicRecyclerParams": true,

I set speed to 1.0 for Instant.

 

"viptest": {
"Priority": 1,
"spawnCooldown": 86400.0,
"craftCooldown": 86400.0,
"craftLimit": 0,
"spawnLimit": 0,
"Ratio": 0.5,
"RatioScrap": 1.0,
"Speed": 1.0,
"percentOfMaxStackToTake": 0.1

Locked automatically