Guest User

Rust Plugin - NO BP Frags needed for Lvl2/3 Benches

a guest
Jan 3rd, 2026
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.35 KB | None | 0 0
  1. using System.Collections.Generic;
  2. using Oxide.Core;
  3. using UnityEngine;
  4.  
  5. namespace Oxide.Plugins
  6. {
  7.     [Info("NoBPFrags", "Gattaca", "1.2.1")]
  8.     [Description("Removal of Blueprint Fragments from Workbenches.")]
  9.     public class NoBPFrags : RustPlugin
  10.     {
  11.  
  12.         private readonly List<string> _ingredientsToRemove = new List<string>
  13.         {
  14.             "basicblueprintfragment",
  15.             "advancedblueprintfragment"
  16.         };
  17.  
  18.         private readonly List<string> _targetItems = new List<string>
  19.         {
  20.             "workbench2",
  21.             "workbench3"
  22.         };
  23.  
  24.         #region Oxide Hooks
  25.  
  26.         private void OnServerInitialized()
  27.         {
  28.             // Delay
  29.             timer.Once(5f, () =>
  30.             {
  31.                 ModifyWorkbenchBlueprints();
  32.             });
  33.         }
  34.  
  35.         private void Unload()
  36.         {
  37.             Puts("NoBPFrags unloaded.");
  38.         }
  39.  
  40.         #endregion
  41.  
  42.         #region Core Logic
  43.  
  44.         private void ModifyWorkbenchBlueprints()
  45.         {
  46.             foreach (var targetItemName in _targetItems)
  47.             {
  48.                 var definition = ItemManager.FindItemDefinition(targetItemName);
  49.  
  50.                 // checks
  51.                 if (definition == null) continue;
  52.                 if (definition.Blueprint == null) continue;
  53.                 if (definition.Blueprint.ingredients == null) continue;
  54.  
  55.                 var ingredientsToRemove = new List<ItemAmount>();
  56.  
  57.                 // Find the frags
  58.                 foreach (var ingredient in definition.Blueprint.ingredients)
  59.                 {
  60.                     if (ingredient == null) continue;
  61.                    
  62.                     if (ingredient.itemDef != null && _ingredientsToRemove.Contains(ingredient.itemDef.shortname))
  63.                     {
  64.                         ingredientsToRemove.Add(ingredient);
  65.                     }
  66.                 }
  67.  
  68.                 // Destroy them
  69.                 if (ingredientsToRemove.Count > 0)
  70.                 {
  71.                     foreach (var item in ingredientsToRemove)
  72.                     {
  73.                         definition.Blueprint.ingredients.Remove(item);
  74.                         Puts($"[NoBPFrags] Removed '{item.itemDef.shortname}' from '{targetItemName}'.");
  75.                     }
  76.                 }
  77.             }
  78.         }
  79.  
  80.         #endregion
  81.     }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment