From 5d3e7b362097322b975f1bd71ee6bccd4bb0722b Mon Sep 17 00:00:00 2001 From: varttist Date: Thu, 5 Nov 2026 20:59:51 +0300 Subject: [PATCH] `adminCommands`: update `/list` command - use `PlayerInventoryUI` --- mods/GAME/adminCommands/init.lua | 39 ++++---------------------------- mods/GAME/adminCommands/mod.conf | 2 +- 2 files changed, 6 insertions(+), 35 deletions(-) diff --git a/mods/GAME/adminCommands/init.lua b/mods/GAME/adminCommands/init.lua index 1ac0320..2db1102 100644 --- a/mods/GAME/adminCommands/init.lua +++ b/mods/GAME/adminCommands/init.lua @@ -1,16 +1,15 @@ local modInfo = Mod.getInfo('smc__core__formspec') local require = modInfo.require ----@type AdminListUI -local AdminListUI = Mod.getInfo('smc__ui__admin_list').require('AdminListUI') +---@type PlayerInventoryUI +local PlayerInventoryUI = Mod.getInfo('smc__ui__player_inventory').require('PlayerInventoryUI') core.register_chatcommand('list', { - privs = {server = true}, + privs = {give = true}, func = function(name, param) - local player = core.get_player_by_name(name) - - AdminListUI:showForm(name) + PlayerInventoryUI:setContex(name, 'left_tab_name', 'admin_list_tab') + PlayerInventoryUI:showForm(name) return true, '' end @@ -35,34 +34,6 @@ core.register_chatcommand('set_param2', { end }) -AdminListUI:registerOnFormFieldActionMatch('%S+::item_button',function(player, fieldName, fieldValue) - ---@type ItemStackString? - local stack = string.match(fieldName, '(%S+)::item_button') - - if stack == nil then - return - end - - local playerName = player:get_player_name() - AdminListUI:setContex(playerName, 'select_item', stack) - - AdminListUI:showForm(playerName) -end) - -AdminListUI:registerOnFormFieldAction('admin_commands:list_add_item', function(player, fieldName, fieldValue) - ---@type InvRef - local inv = player:get_inventory() - - local playerName = player:get_player_name() - local stack = AdminListUI:getContex(playerName, 'select_item') - stack = ItemStack(stack) - stack:set_count(fieldValue) - - if inv:room_for_item('main', stack) then - inv:add_item('main', stack) - end -end) - core.register_on_joinplayer(function(player, last_login) player:set_sky({ sky_color = { diff --git a/mods/GAME/adminCommands/mod.conf b/mods/GAME/adminCommands/mod.conf index b91a9b5..672aee6 100644 --- a/mods/GAME/adminCommands/mod.conf +++ b/mods/GAME/adminCommands/mod.conf @@ -1,2 +1,2 @@ name = smc__game__admin_commands -depends = smc__system__system_loader, smc__ui__admin_list +depends = smc__system__system_loader, smc__ui__player_inventory