From a4a633d660f95bf04e9213bacb2e6b064a062e60 Mon Sep 17 00:00:00 2001 From: BuckarooBanzay Date: Mon, 29 Mar 2021 19:29:41 +0200 Subject: [PATCH] initial commit --- .luacheckrc | 14 +++++++ init.lua | 69 ++++++++++++++++++++++++++++++++++ mod.conf | 3 ++ readme.md | 10 +++++ textures/instaban_texture.png | Bin 0 -> 144 bytes 5 files changed, 96 insertions(+) create mode 100644 .luacheckrc create mode 100644 init.lua create mode 100644 mod.conf create mode 100644 readme.md create mode 100644 textures/instaban_texture.png diff --git a/.luacheckrc b/.luacheckrc new file mode 100644 index 0000000..af0b604 --- /dev/null +++ b/.luacheckrc @@ -0,0 +1,14 @@ + +read_globals = { + -- Stdlib + string = {fields = {"split"}}, + table = {fields = {"copy", "getn"}}, + + -- Minetest + "vector", "ItemStack", + "dump", "VoxelArea", + + -- deps + "minetest", + "xban" +} diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..1ddca6d --- /dev/null +++ b/init.lua @@ -0,0 +1,69 @@ +local has_xban_mod = minetest.get_modpath("xban2") + +minetest.register_node("ban_blocks:ban", { + description = "Ban block", + walkable = false, + pointable = false, + diggable = false, + buildable_to = true, + drawtype = "glasslike", + drowning = 1, + post_effect_color = {a = 20, r = 250, g = 20, b = 20}, + tiles = {"instaban_texture.png^[colorize:#F0505033"}, + alpha = 0.1, + groups = {}, + paramtype = "light", + drop = {}, + sunlight_propagates = true +}) + +minetest.register_node("ban_blocks:kick", { + description = "Kick block", + walkable = false, + pointable = false, + diggable = false, + buildable_to = true, + drawtype = "glasslike", + drowning = 1, + post_effect_color = {a = 20, r = 20, g = 250, b = 20}, + tiles = {"instaban_texture.png^[colorize:#50F05033"}, + alpha = 0.1, + groups = {}, + paramtype = "light", + drop = {}, + sunlight_propagates = true +}) + +local function check_player(player) + local has_noclip = minetest.check_player_privs(player, "noclip") + if has_noclip then + -- player with noclip priv, skip check + return + end + + local playername = player:get_player_name() + local node = minetest.get_node(player:get_pos()) + if node.name == "ban_blocks:kick" then + minetest.log("action", "player " .. playername .. " entered a kick-block") + minetest.kick_player(playername) + + elseif node.name == "ban_blocks:ban" and has_xban_mod then + minetest.log("action", "player " .. playername .. " entered a ban-block") + xban.ban_player(playername, "ban_blocks", nil, "ban_blocks:ban") + + end +end + +-- check for player-block positions every second +local timer = 0 +minetest.register_globalstep(function(dtime) + timer = timer + dtime + if timer < 1 then + return + end + timer = 0 + + for _, player in pairs(minetest.get_connected_players()) do + check_player(player) + end +end) diff --git a/mod.conf b/mod.conf new file mode 100644 index 0000000..e49106d --- /dev/null +++ b/mod.conf @@ -0,0 +1,3 @@ +name = ban_blocks +optional_depends = xban2 +description = Adds blocks that instaban if entered diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..880f191 --- /dev/null +++ b/readme.md @@ -0,0 +1,10 @@ + +`ban_blocks` a mod for minetest + +# Overview + +Adds blocks that ban or kick if entered + +# License + +MIT diff --git a/textures/instaban_texture.png b/textures/instaban_texture.png new file mode 100644 index 0000000000000000000000000000000000000000..89bdbb80fe9c3ddaa154ca03e407d4d0eb927caa GIT binary patch literal 144 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=DinK$vl=HlH+5kiEpy*OmPNBcGtS(3_8!Er3F@o-U3d7N?VIK0b2gV`gpWY;-cn hI