diff --git a/mods/pclasses/admin.lua b/mods/pclasses/admin.lua new file mode 100755 index 00000000..44795e7b --- /dev/null +++ b/mods/pclasses/admin.lua @@ -0,0 +1,24 @@ +----------------- +-- Admin class -- +----------------- + +-- +-- https://github.com/MinetestForFun/minetest-minetestforfun-server/issues/139 +-- + +pclasses.api.register_class("admin", { + determination = function(player) + return minetest.get_player_privs(player:get_player_name()).server + end, + on_assigned = function(pname) + minetest.chat_send_player(pname, "Hello admin.") + end +}) + +pclasses.api.reserve_item("admin", "3d_armor:helmet_admin") +pclasses.api.reserve_item("admin", "3d_armor:chestplate_admin") +pclasses.api.reserve_item("admin", "3d_armor:leggings_admin") +pclasses.api.reserve_item("admin", "3d_armor:boots_admin") +pclasses.api.reserve_item("admin", "shields:shields_admin") +pclasses.api.reserve_item("admin", "maptools:pick_admin") +pclasses.api.reserve_item("admin", "maptools:pick_admin_with_drops") diff --git a/mods/pclasses/api.lua b/mods/pclasses/api.lua index 9b6889a6..5ab461cb 100755 --- a/mods/pclasses/api.lua +++ b/mods/pclasses/api.lua @@ -82,7 +82,17 @@ function pclasses.api.assign_class(player) -- Starting from the most important class to the less one local pname = player:get_player_name() - if pclasses.classes["hunter"].determination(player) then + + if pclasses.classes["admin"].determination(player) then + if pclasses.api.get_player_class(pname) ~= "admin" then + if pclasses.classes[pclasses.api.get_player_class(pname)].on_unassigned then + pclasses.api.get_class_by_name(pclasses.api.get_player_class(pname)).on_unassigned(pname) + end + pclasses.api.set_player_class(pname, "admin") + pclasses.api.get_class_by_name("admin").on_assigned(pname) + end + + elseif pclasses.classes["hunter"].determination(player) then if pclasses.api.get_player_class(pname) ~= "hunter" then if pclasses.api.get_class_by_name(pclasses.api.get_player_class(pname)).on_unassigned then pclasses.api.get_class_by_name(pclasses.api.get_player_class(pname)).on_unassigned(pname) @@ -122,13 +132,6 @@ function pclasses.api.reserve_item(cname, itemstring) table.insert(pclasses.datas.reserved_items[itemstring], 1, cname) end -pclasses.api.reserve_item("warrior", "moreores:sword_mithril") -pclasses.api.reserve_item("warrior", "default:dungeon_master_s_blood_sword") - -pclasses.api.reserve_item("hunter", "throwing:bow_minotaur_horn") -pclasses.api.reserve_item("hunter", "throwing:bow_minotaur_horn_improved") - - minetest.register_globalstep(function(dtime) for id, ref in ipairs(minetest.get_connected_players()) do local name = ref:get_player_name() diff --git a/mods/pclasses/hunter.lua b/mods/pclasses/hunter.lua index 425e9015..11fc3295 100755 --- a/mods/pclasses/hunter.lua +++ b/mods/pclasses/hunter.lua @@ -26,3 +26,7 @@ pclasses.api.register_class("hunter", { sprint.set_default_maxstamina(pname) end, }) + + +pclasses.api.reserve_item("hunter", "throwing:bow_minotaur_horn") +pclasses.api.reserve_item("hunter", "throwing:bow_minotaur_horn_improved") diff --git a/mods/pclasses/init.lua b/mods/pclasses/init.lua index 1a110620..a1f3607c 100755 --- a/mods/pclasses/init.lua +++ b/mods/pclasses/init.lua @@ -89,4 +89,5 @@ end dofile(minetest.get_modpath("pclasses") .. "/warrior.lua") dofile(minetest.get_modpath("pclasses") .. "/hunter.lua") +dofile(minetest.get_modpath("pclasses") .. "/admin.lua") diff --git a/mods/pclasses/warrior.lua b/mods/pclasses/warrior.lua index 227d322e..76a79300 100755 --- a/mods/pclasses/warrior.lua +++ b/mods/pclasses/warrior.lua @@ -20,3 +20,6 @@ pclasses.api.register_class("warrior", { sprint.set_default_maxstamina(pname) end, }) + +pclasses.api.reserve_item("warrior", "moreores:sword_mithril") +pclasses.api.reserve_item("warrior", "default:dungeon_master_s_blood_sword")