Skip to content
RustPluginGenerator

CanBeRecycled

CanBeRecycled is called when a Recycler checks whether a specific item is allowed to be broken down, before the game applies its own blueprint and item-type rules.

Signature
object CanBeRecycled(Item item, Recycler recycler)

Parameters

Hook parameters
ParameterTypeDescription
itemItemThe Item instance the recycler is evaluating. Check item.info (shortname, category, itemid) to decide whether the item may be recycled.
recyclerRecyclerThe Recycler entity performing the check. Use it to scope rules per location, e.g. read its transform.position or OwnerID.

Return value

Return null to let the game decide using its normal rules. Return true to force the item to be accepted, or false to force it to be rejected; either bool replaces the vanilla result.

How it works

Oxide fires this hook inside Recycler.CanBeRecycled(Item item) each time the recycler evaluates an item — typically when a player places or moves items into the recycler's input slots and the server decides what can enter the recycling queue. The method runs once per item per check, so it can fire repeatedly for the same item as the UI refreshes.

item is the candidate Item; item.info exposes the shortname, itemid and category, and item.amount tells you the stack size. recycler is the actual Recycler entity, so you can vary the result by location, owner or zone. Returning a bool overrides the vanilla decision; the game's own logic (blueprint check, recyclable flags, category restrictions) never runs for that call.

Declaring a more specific parameter type is only useful for recycler: use Recycler or a base entity type to narrow the call. Declaring a subtype for item does nothing useful since items are plain Item objects. Keep the method fast — it can run many times per session per player.

Example plugin: Block recycling of selected items

RecyclerItemBlocker.cs
using System.Linq;
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Core;

namespace Oxide.Plugins
{
    [Info("Recycler Item Blocker", "RustPluginGenerator", "1.0.0")]
    [Description("Prevents configured items from being placed in recyclers.")]
    public class RecyclerItemBlocker : RustPlugin
    {
        private class PluginConfig
        {
            [JsonProperty("Blocked item shortnames")]
            public List<string> BlockedItems = new List<string>
            {
                "rifle.ak",
                "rifle.bolt",
                "lmg.m249",
                "explosive.timed",
                "rocket.launcher"
            };
        }

        private PluginConfig config;
        private HashSet<string> blocked;

        protected override void LoadDefaultConfig() => config = new PluginConfig();

        protected override void LoadConfig()
        {
            base.LoadConfig();
            try
            {
                config = Config.ReadObject<PluginConfig>();
                if (config == null) throw new Exception();
            }
            catch
            {
                PrintWarning("Configuration file is invalid, using defaults");
                LoadDefaultConfig();
            }
            SaveConfig();
            RebuildSet();
        }

        protected override void SaveConfig() => Config.WriteObject(config);

        private void RebuildSet()
        {
            blocked = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
            if (config?.BlockedItems == null) return;
            foreach (var shortname in config.BlockedItems)
            {
                if (!string.IsNullOrEmpty(shortname))
                    blocked.Add(shortname);
            }
        }

        private object CanBeRecycled(Item item, Recycler recycler)
        {
            if (item?.info == null || recycler == null) return null;
            if (blocked == null) return null;
            return blocked.Contains(item.info.shortname) ? (object)false : null;
        }
    }
}

The plugin reads a config list of item shortnames that should never be recycled. LoadDefaultConfig seeds the list with high-value items so the plugin works out of the box. CanBeRecycled looks up item.info.shortname in that set and returns false when it matches, which stops the recycler from accepting the item. Because Oxide calls the hook before the vanilla blueprint and category checks, an entry here always wins. The set is rebuilt whenever the config method runs, so admins can edit oxide/config/RecyclerItemBlocker.json and reload the plugin.

Common use cases

  • Protect event loot

    Reject recycling of raid-only or event items so players cannot convert them into scrap.

  • Location-restricted recyclers

    Only allow certain items at recyclers inside a monument by checking recycler.transform.position against a radius.

  • Economy balancing

    Force specific components to be recyclable even though the vanilla rules would block them, tightening or loosening scrap flow.

Pitfalls

  • Fires repeatedly

    The recycler re-evaluates items as the UI updates, so this hook can run many times per second per player. Keep lookups O(1) and never print or log inside it.

  • Bool is authoritative

    A returned false blocks the item outright; the player gets no feedback about why. Pair the rule with a chat notice elsewhere if you need to explain it.

  • No item-type narrowing

    Items are always plain Item instances, so declaring a subclass for the first parameter will not filter calls — only the recycler parameter benefits from type narrowing.

Build a plugin with CanBeRecycled

Describe what should happen and get a compiled plugin that uses this hook.

Prompt: Protect event loot using the CanBeRecycled hook, with a config file and a permission
Generate this plugin

Edit the prompt on the next screen. 2 free plugins a month, no card.

Last updated Oct 26, 2026. Found a mistake? Email support@rustplugingenerator.com.

Build a plugin with CanBeRecycled

Generate