插件介绍
允许玩家使用外部来源的物品进行建造、制作、重新加载等
If you install this plugin by itself, it will allow players to build/craft/etc. using resources from their equipped vanilla backpack. This capability does not require any permissions or configuration.
This plugin becomes more useful when you have other plugins that are compatible with it, including the following examples.
In addition to explicit Item Suppliers and Container Suppliers, some items may implicitly function as Item Suppliers, including vanilla backpacks, and bags managed by the Bag of Holding plugin.
Any plugin which reduces the player inventory space to less than 24 is not compatible. For example, Clothing Slots.
主要用途
主要用于item、containers、制作、建筑等服务端功能。 本插件由 WhiteThunder 发布,当前目录记录版本为 v0.7.7,uMod 累计下载 21,450 次。
适用场景
- 需要调整建造、物品、制作或采集体验的服务器
- 希望改善玩家交互与日常体验的社区服务器
功能分类
查看 uMod 官方英文简介
Allows players to build, craft, reload and more using items from external sources
相关依赖
- Instant Craft
- Backpacks
- Custom Vending Setup
- Virtual Items
官方配置示例
Dictionary<string, object> API_GetApi()[PluginReference]
private readonly Plugin ItemRetriever;
private ItemRetrieverApi _itemRetrieverApi;
private Dictionary<string, object> _itemQuery;
// (Hook) When all plugins load, call ItemRetriever to cache its API.
private void OnServerInitialized()
{
if (ItemRetriever != null)
{
CacheItemRetrieverApi();
}
}
// (Hook) In case ItemRetriever reloads or loads late, refresh its API.
private void OnPluginLoaded(Plugin plugin)
{
if (plugin.Name == nameof(ItemRetriever))
{
CacheItemRetrieverApi();
}
}
// (Helper method) Call ItemRetriever via Oxide to get its API.
private void CacheItemRetrieverApi()
{
_itemRetrieverApi = new ItemRetrieverApi(ItemRetriever.Call("API_GetApi") as Dictionary<string, object>);
}
// (Helper class) This abstraction allows you to call ItemRetriever API methods with low CPU/memory overhead.
private class ItemRetrieverApi
{
// All available API methods are defined here, but you can shorten this list for brevity if you only use select APIs.
public Action<Plugin, Dictionary<string, object>> AddSupplier { get; }
public Action<Plugin> RemoveSupplier { get; }
public Func<BasePlayer, ItemContainer, bool> HasContainer { get; }
public Action<Plugin, BasePlayer, IItemContainerEntity, ItemContainer, Func<Plugin, BasePlayer, ItemContainer, bool>> AddContainer { get; }
public Action<Plugin, BasePlayer, ItemContainer> RemoveContainer { get; }
public Action<Plugin, BasePlayer> RemoveAllContainersForPlayer { get; }
public Action<Plugin> RemoveAllContainersForPlugin { get; }
public Action<BasePlayer, Dictionary<string, object>, List<Item>> FindPlayerItems { get; }
public Func<BasePlayer, Dictionary<string, object>, int> SumPlayerItems { get; }
public Func<BasePlayer, Dictionary<string, object>, int, List<Item>, int> TakePlayerItems { get; }
public Action<BasePlayer, AmmoTypes, List<Item>> FindPlayerAmmo { get; }
public ItemRetrieverApi(Dictionary<string, object> apiDict)
{
AddSupplier = apiDict[nameof(AddSupplier)] as Action<Plugin, Dictionary<string, object>>;
RemoveSupplier = apiDict[nameof(RemoveSupplier)] as Action<Plugin>;
HasContainer = apiDict[nameof(HasContainer)] as Func<BasePlayer, ItemContainer, bool>;
AddContainer = apiDict[nameof(AddContainer)] as Action<Plugin, BasePlayer, IItemContainerEntity, ItemContainer, Func<Plugin, BasePlayer, ItemContainer, bool>;
RemoveContainer = apiDict[nameof(RemoveContainer)] as Action<Plugin, BasePlayer, ItemContainer>;
RemoveAllContainersForPlayer = apiDict[nameof(RemoveAllContainersForPlayer)] as Action<Plugin, BasePlayer>;
RemoveAllContainersForPlugin = apiDict[nameof(RemoveAllContainersForPlugin)] as Action<Plugin>;
FindPlayerItems = apiDict[nameof(FindPlayerItems)] as Action<BasePlayer, Dictionary<string, object>, List<Item>>;
SumPlayerItems = apiDict[nameof(SumPlayerItems)] as Func<BasePlayer, Dictionary<string, object>, int>;
TakePlayerItems = apiDict[nameof(TakePlayerItems)] as Func<BasePlayer, Dictionary<string, object>, int, List<Item>, int>;
FindPlayerAmmo = apiDict[nameof(FindPlayerAmmo)] as Action<BasePlayer, AmmoTypes, List<Item>>;
}
}
// (Helper method) When ItemRetriever's API is not available, you'll need a method to find items in the player inventory.
// If you only need to find items by id (don't need to check skin, blueprint, etc.), then you can use a vanilla method.
private int SumContainerItems(ItemContainer container, int itemId, ulong skinId = 0)
{
var sum = 0;
foreach (var item in container.itemList)
{
if (item.info.itemid != itemId)
continue;
if (skinId != 0 && item.skin != skinId)
continue;
sum = item.amount;
}
return sum;
}
// (Helper method) Create or update your item query. Reuses the dictionary to reduce garbage generation.
// Recommended to also use an object cache for item ids and skin ids to avoid generating garbage when assigning them to the item query dictionary.
private Dictionary<string, object> SetupItemQuery(int itemId, ulong skinId = 0)
{
if (_itemQuery == null)
{
_itemQuery = new Dictionary<string, object>();
}
_itemQuery.Clear();
_itemQuery["ItemId"] = itemId;
if (skinId != 0)
{
_itemQuery["SkinId"] = skinId;
}
return _itemQuery;
}
// (Helper method) Example business logic.
private int GetPlayerEpicScrapAmount(BasePlayer player)
{
var itemId = -932201673;
var skinId = 1234567890uL;
// If ItemRetriever is available, call it, else simply find items in the player inventory.
return _itemRetrieverApi?.SumPlayerItems?.Invoke(player, SetupItemQuery(itemId, skinId))
?? SumContainerItems(player.inventory.containerMain, itemId, skinId)
SumContainerItems(player.inventory.containerBelt, itemId, skinId);
}更新日志
本站记录 uMod 官方插件信息。完整的历史更新日志请参阅 uMod 官方页面。
安装方法
- 确认服务器已安装 Oxide / uMod 或兼容的 Carbon 框架。
- 登录本站后点击"下载",由 uMod 官方地址获取作者发布的文件。
- 将 .cs 文件放入服务器的
oxide/plugins目录。 - 观察服务端控制台,确认插件编译并成功加载。
- 具体配置、权限、指令和依赖请查看原作者的 uMod 页面。
使用前注意
- Rust 更新后,请先确认插件是否仍兼容当前服务端版本。
- 修改配置前建议备份原配置文件,并在测试服验证后再部署到正式服。
- 若插件依赖其他扩展或库,以 uMod 原作者页面的最新说明为准。
- 本站中文内容用于辅助理解,遇到版本差异时以官方英文文档和源码为准。
中文介绍由 uMod 官方简介翻译整理。插件著作权、许可证、完整文档和最新发布状态均以原作者及 uMod 官方页面为准。