1. Never had an issue with this code until last nights update.
    Tested it with the plain example on Docs.oxidemod.org and still does nothing. No errors or compiling issues. Just nothing.

    What has changed? or is this just plain broken?
    Code:
     private object CanCraft(ItemCrafter itemCrafter, ItemBlueprint bp, int amount)
            {
                var player = itemCrafter.GetComponent<BasePlayer>();
                var item = bp.GetComponent<ItemDefinition>();            if (permission.UserHasPermission(player.UserIDString, Perm))
                    return true;            if (configFile.AllowedItems.ContainsKey(item.shortname))
                {
                    if(configFile.AllowedItems[item.shortname])
                      
                    return true;
                }
                if (configFile.HideMessage.SendMessage)
                PrintToChat(player, Lang(Message.CraftingDisabled, player.UserIDString));
                return false;
            }
     
  2. Wulf

    Wulf Community Admin

    No, the hook is not broken, the calling of the correct hook is just broken right now, which CanCraft has two different signatures.
     
  3. oh, so this is fixable or do we have to wait?
     
  4. Wulf

    Wulf Community Admin

    You'll have to wait for a fix in Oxide.
     
  5. Ok, cheers
     
  6. So, the deal is - this hook on call drops NRE, no matter what the code is.
    Even this code below dropes with NRE.
    Code:
    object CanCraft(PlayerBlueprints bps, ItemDefinition itemDef, int skinId) => true;
    Code:
    Failed to call hook 'CanCraft' on plugin 'QuarryCraft v1.0.0' (InvalidCastException: Cannot cast from source type to destination type.)
      at Oxide.Plugins.QuarryCraft.DirectCallHook (System.String name, System.Object& ret, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.CSharpPlugin.InvokeMethod (Oxide.Core.Plugins.HookMethod method, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Core.Plugins.CSPlugin.OnCallHook (System.String name, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Core.Plugins.Plugin.CallHook (System.String hook, System.Object[] args) [0x00000] in <filename unknown>:0
    
     
  7. Wulf

    Wulf Community Admin

    No, either would work.

    We're aware and working on a fix.
     
  8. Thats what i thought also.
     
  9. Wulf

    Wulf Community Admin

    This should be fixed in the latest Oxide build now by the way.
     
  10. Had a major issue leading to players exploiting on our server and just wanted to bring this to the table in case it is of any interest to someone. Below are my quick findings for the two CanCraft methods. I know there are several plugins using the old definition out there and servers using this may be suffering from this.

    Code:
            /**
             * Assuming this definition is the wrong and outdated one (still present in API description).
             * Returning true allows any item to be crafted by double clicking item in inventory standing at workbench as long as player has the blueprint. No resources needed.
             * Since its a hook I'd say it would be a race condition for all plugins with this behaviour so assuming it is not indended to work like this.
             */
            bool CanCraft(ItemCrafter itemCrafter, ItemBlueprint bp, int amount)
            {
                Puts("Original craft");
                return true;
            }        /**
             * This (updated definition as understand it) works, kinda. Returning true allows items to be crafted ONLY if resources and blueprints are met.
             * There is one catch tho. It seem to be executed twice once criteria is met.
             * In my case I'm notifying player with a message but it is not very desired to send two messages just because the method gets executed twice.
             */
            object CanCraft(PlayerBlueprints bps, ItemDefinition itemDef, int skinId)
            {
                Puts("Updated craft");
                return true;
            }
     
  11. Wulf

    Wulf Community Admin

    There aren’t old definitions, they are the same as they have been. The hook has multiple signatures, each for a different purpose.
     
  12. Ah great. Then its good I suppose. Would be great with some additional documentation how these are ment to be used if possible
     
  13. Wulf

    Wulf Community Admin

    Probably, the old docs are a bit bare right now.
     
  14. What is the reason "object CanCraft(PlayerBlueprints bps, ItemDefinition itemDef, int skinId)" is being called twice? if it was executed once I'd have my code working as intended right now. the other definition is not an option at all which is obvious
     
  15. Wulf

    Wulf Community Admin

    If it is called twice, then that is how often that code area is hit in Rust.