From 5e8b585e138d2787b347ef42d08e85f06423427a Mon Sep 17 00:00:00 2001 From: BlackImpostor <106878493+SkyBuilder1717@users.noreply.github.com> Date: Tue, 3 Oct 2023 18:46:18 +0300 Subject: [PATCH] 0.0.1 --- ui/about.lua | 30 ++++++++++++++++++++++ ui/ban_menu.lua | 43 +++++++++++++++++++++++++++++++ ui/kick_menu.lua | 43 +++++++++++++++++++++++++++++++ ui/mute_menu.lua | 66 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 182 insertions(+) create mode 100644 ui/about.lua create mode 100644 ui/ban_menu.lua create mode 100644 ui/kick_menu.lua create mode 100644 ui/mute_menu.lua diff --git a/ui/about.lua b/ui/about.lua new file mode 100644 index 0000000..6849540 --- /dev/null +++ b/ui/about.lua @@ -0,0 +1,30 @@ +local FORMNAME = "essentials:about" + +-- ban menu +function show_about(name) + local formspec = [[ + formspec_version[6] + size[8.6,9.9] + image[1.6,0.1;5.6,5.6;essentials_logo.png] + label[3.3,6;ESSENTIALS] + label[0.1,8.5;Builder Mods STUDIO™ — a studio that develops great] + label[0.1,8.9;mods and games for Minetest ContentDB.] + label[0.1,9.3;A studio that will always be topical\, a studio that will] + label[0.1,9.7;create comfort in the game.] + label[2.2,6.4;By Builder Mods STUDIO™] + image[0.1,6.9;1,1;skybuilder.png] + label[1.2,7.2;Builder Mods STUDIO™] + label[1.2,7.6;By -SkyBuilder-] + ]] + + minetest.show_formspec(name, FORMNAME, formspec) +end + +minetest.register_on_player_receive_fields(function(player, formname, fields) + local name = player:get_player_name() + if formname ~= FORMNAME then + return + end + return +end) +-- end \ No newline at end of file diff --git a/ui/ban_menu.lua b/ui/ban_menu.lua new file mode 100644 index 0000000..a78efb4 --- /dev/null +++ b/ui/ban_menu.lua @@ -0,0 +1,43 @@ +local FORMNAME = "essentials:ban_menu" + +-- ban menu +function show_ban_menu(name) + local formspec = [[ + formspec_version[6] + size[12.5,4.5] + field[4.5,0.6;6.8,1;player;Player name;] + field[4.5,2.1;6.8,1;reason;Reason of ban;] + button[4.5,3.3;6.8,1.1;ban_btn;Ban the player] + image[0.2,0.2;4.2,4.2;ban_user.png] + image_button_exit[11.4,0.1;1,1;close_btn.png;close_btn;] + ]] + + minetest.show_formspec(name, FORMNAME, formspec) +end + +minetest.register_on_player_receive_fields(function(player, formname, fields) + local name = player:get_player_name() + if formname ~= FORMNAME then + return + end + + if fields.ban_btn then + local player_ban = minetest.get_player_by_name(fields.player) + local player_banned = fields.player + local reason_ban = fields.reason + + if core.is_singleplayer() then + minetest.chat_send_player(name, core.colorize("red", "You cannot ban in single mode!")) + elseif not player_ban then + minetest.chat_send_player(name, core.colorize("red", "Player not found!")) + elseif reason_ban == "" then + core.ban_player(fields.player) + core.chat_send_all("Banned ".. player_banned ..".") + else + core.ban_player(fields.player) + core.chat_send_all("Banned ".. player_banned .." for ".. reason_ban ..".") + end + end + return +end) +-- end \ No newline at end of file diff --git a/ui/kick_menu.lua b/ui/kick_menu.lua new file mode 100644 index 0000000..086561e --- /dev/null +++ b/ui/kick_menu.lua @@ -0,0 +1,43 @@ +local FORMNAME = "essentials:kick_menu" + +-- ban menu +function show_kick_menu(name) + local formspec = [[ + formspec_version[6] + size[12.5,4.5] + field[1.2,0.6;6.8,1;player;Player name;] + field[1.2,2.1;6.8,1;reason;Reason of kick;] + button[1.2,3.3;6.8,1.1;kick_btn;Kick the player] + image[8.2,0.2;4.2,4.2;kick_user.png] + image_button_exit[0.1,0.1;1,1;close_btn.png;close_btn;] + ]] + + minetest.show_formspec(name, FORMNAME, formspec) +end + +minetest.register_on_player_receive_fields(function(player, formname, fields) + local name = player:get_player_name() + if formname ~= FORMNAME then + return + end + + if fields.kick_btn then + local player_kick = minetest.get_player_by_name(fields.player) + local player_kicked = fields.player + local reason_kick = fields.reason + + if core.is_singleplayer() then + minetest.chat_send_player(name, core.colorize("red", "You cannot kick in single mode!")) + elseif not player_kick then + minetest.chat_send_player(name, core.colorize("red", "Player not found!")) + elseif reason_kick == "" then + core.kick_player(fields.player, fields.reason) + core.chat_send_all("Kicked ".. player_kicked ..".") + else + core.kick_player(fields.player, fields.reason) + core.chat_send_all("Kicked ".. player_kicked .." for ".. reason_kick ..".") + end + end + return +end) +-- end \ No newline at end of file diff --git a/ui/mute_menu.lua b/ui/mute_menu.lua new file mode 100644 index 0000000..9be8551 --- /dev/null +++ b/ui/mute_menu.lua @@ -0,0 +1,66 @@ +local FORMNAME = "essentials:ban_menu" + +-- ban menu +function show_mute_menu(name) + local formspec = [[ + formspec_version[6] + size[4.5,9.6] + field[0.1,4.9;4.3,1.1;player;Player for mute;] + button[0.1,6.1;4.3,1.1;mute_btn;Mute the player] + image[0.1,0.1;4.3,4.3;mute_user.png] + image_button_exit[3.4,8.5;1,1;close_btn.png;close_btn;] + button[0.1,7.3;4.3,1.1;unmute_btn;Unmute the player] + ]] + + minetest.show_formspec(name, FORMNAME, formspec) +end + +minetest.register_on_player_receive_fields(function(player, formname, fields) + if formname ~= FORMNAME then + return + end + + if fields.unmute_btn then + local admin = player:get_player_name() + local player_mutted = fields.player + local player = minetest.get_player_by_name(fields.player) + + if core.is_singleplayer() then + minetest.chat_send_player(admin, core.colorize("red", "You cannot mute in single mode!")) + elseif player_mutted == "" then + minetest.chat_send_player(admin, core.colorize("red", "Player name cannot be empty!")) + elseif not player then + minetest.chat_send_player(admin, core.colorize("red", "Player not found!")) + elseif privs.shout == true then + minetest.chat_send_player(admin, core.colorize("red", "Player already unmuted!")) + else + local privs = minetest.get_player_privs(fields.player) + minetest.chat_send_all(player_mutted .. " has been unmuted.") + privs = {shout = true} + minetest.set_player_privs(player, privs) + end + end + + if fields.mute_btn then + local admin = player:get_player_name() + local player_mutted = fields.player + local player = minetest.get_player_by_name(fields.player) + + if core.is_singleplayer() then + minetest.chat_send_player(admin, core.colorize("red", "You cannot mute in single mode!")) + elseif player_mutted == "" then + minetest.chat_send_player(admin, core.colorize("red", "Player name cannot be empty!")) + elseif not player then + minetest.chat_send_player(admin, core.colorize("red", "Player not found!")) + elseif privs.shout == true then + minetest.chat_send_player(admin, core.colorize("red", "Player already muted!")) + else + local privs = minetest.get_player_privs(fields.player) + minetest.chat_send_all(player_mutted .. " has been muted.") + privs = {shout = true} + minetest.set_player_privs(player, privs) + end + end + return +end) +-- end \ No newline at end of file