mirror of
https://github.com/minetest-mods/i3.git
synced 2024-12-26 19:00:39 +01:00
Outdated clients are now kicked ruthlessly without fallback
This commit is contained in:
parent
970220c561
commit
1c4ae1df28
41
init.lua
41
init.lua
@ -25,8 +25,6 @@ local item_compression = core.settings:get_bool("i3_item_compression", true)
|
|||||||
local damage_enabled = core.settings:get_bool "enable_damage"
|
local damage_enabled = core.settings:get_bool "enable_damage"
|
||||||
|
|
||||||
local __3darmor, __skinsdb, __awards
|
local __3darmor, __skinsdb, __awards
|
||||||
local __sfinv, old_sfinv_fn
|
|
||||||
local __unified_inventory, old_unified_inventory_fn
|
|
||||||
|
|
||||||
local http = core.request_http_api()
|
local http = core.request_http_api()
|
||||||
local singleplayer = core.is_singleplayer()
|
local singleplayer = core.is_singleplayer()
|
||||||
@ -107,11 +105,11 @@ local function get_formspec_version(info)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function outdated(name)
|
local function outdated(name)
|
||||||
local fs = sprintf("size[5.8,1.3]image[0,0;1,1;%s]label[1,0;%s]button_exit[2.4,0.8;1,1;;OK]",
|
local fs = sprintf("size[6.3,1.3]image[0,0;1,1;%s]label[1,0;%s]button_exit[2.6,0.8;1,1;;OK]",
|
||||||
PNG.book,
|
PNG.book,
|
||||||
"Your Minetest client is outdated.\nGet the latest version on minetest.net to use i3")
|
"Your Minetest client is outdated.\nGet the latest version on minetest.net to play the game.")
|
||||||
|
|
||||||
core.show_formspec(name, "i3", fs)
|
core.show_formspec(name, "i3_outdated", fs)
|
||||||
end
|
end
|
||||||
|
|
||||||
local old_is_creative_enabled = core.is_creative_enabled
|
local old_is_creative_enabled = core.is_creative_enabled
|
||||||
@ -2518,7 +2516,7 @@ local function get_inventory_fs(player, data, fs)
|
|||||||
fs("scroll_container_end[]")
|
fs("scroll_container_end[]")
|
||||||
|
|
||||||
local btn = {
|
local btn = {
|
||||||
{"trash", ES"Trash all items"},
|
{"trash", ES"Clear inventory"},
|
||||||
{"sort_az", ES"Sort items (A-Z)"},
|
{"sort_az", ES"Sort items (A-Z)"},
|
||||||
{"sort_za", ES"Sort items (Z-A)"},
|
{"sort_za", ES"Sort items (Z-A)"},
|
||||||
{"compress", ES"Compress items"},
|
{"compress", ES"Compress items"},
|
||||||
@ -2887,18 +2885,12 @@ end
|
|||||||
core.register_on_mods_loaded(function()
|
core.register_on_mods_loaded(function()
|
||||||
get_init_items()
|
get_init_items()
|
||||||
|
|
||||||
__sfinv = rawget(_G, "sfinv")
|
if rawget(_G, "sfinv") then
|
||||||
|
|
||||||
if __sfinv then
|
|
||||||
old_sfinv_fn = sfinv.set_player_inventory_formspec
|
|
||||||
function sfinv.set_player_inventory_formspec() return end
|
function sfinv.set_player_inventory_formspec() return end
|
||||||
sfinv.enabled = false
|
sfinv.enabled = false
|
||||||
end
|
end
|
||||||
|
|
||||||
__unified_inventory = rawget(_G, "unified_inventory")
|
if rawget(_G, "unified_inventory") then
|
||||||
|
|
||||||
if __unified_inventory then
|
|
||||||
old_unified_inventory_fn = unified_inventory.set_inventory_formspec
|
|
||||||
function unified_inventory.set_inventory_formspec() return end
|
function unified_inventory.set_inventory_formspec() return end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
@ -2978,21 +2970,7 @@ core.register_on_joinplayer(function(player)
|
|||||||
local info = core.get_player_information and core.get_player_information(name)
|
local info = core.get_player_information and core.get_player_information(name)
|
||||||
|
|
||||||
if not info or get_formspec_version(info) < MIN_FORMSPEC_VERSION then
|
if not info or get_formspec_version(info) < MIN_FORMSPEC_VERSION then
|
||||||
if __sfinv then
|
|
||||||
sfinv.set_player_inventory_formspec = old_sfinv_fn
|
|
||||||
sfinv.enabled = true
|
|
||||||
end
|
|
||||||
|
|
||||||
if __unified_inventory then
|
|
||||||
unified_inventory.set_inventory_formspec = old_unified_inventory_fn
|
|
||||||
|
|
||||||
if __sfinv then
|
|
||||||
sfinv.enabled = false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
pdata[name] = nil
|
pdata[name] = nil
|
||||||
|
|
||||||
return outdated(name)
|
return outdated(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -3061,11 +3039,14 @@ end
|
|||||||
after(SAVE_INTERVAL, routine)
|
after(SAVE_INTERVAL, routine)
|
||||||
|
|
||||||
core.register_on_player_receive_fields(function(player, formname, fields)
|
core.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
if formname ~= "" then
|
local name = player:get_player_name()
|
||||||
|
|
||||||
|
if formname == "i3_outdated" then
|
||||||
|
return false, core.kick_player(name, "Come back when your client is up-to-date.")
|
||||||
|
elseif formname ~= "" then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local name = player:get_player_name()
|
|
||||||
local data = pdata[name]
|
local data = pdata[name]
|
||||||
if not data then return end
|
if not data then return end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user