Merge sync main, fix send notify, featured node place of peace

* Merge branch 'main' of https://codeberg.org/minenux/minetest-mod-antipvp
  so merge the featured new node of antipvp protection
* check first if the notifications are enabled before send the message
* improve the mod identification in sync
main
mckaygerhard 2023-01-03 01:03:14 -04:00
commit 8227b61903
4 changed files with 45 additions and 40 deletions

View File

@ -16,8 +16,6 @@ This mod is named `antipvp` and add a priv that give PvP(Player vs Player) invul
This is a pvp invulnerability mod based on most others, mostly the most is
part of the venenux minenux server antimods mod, but in single simplified way.
Main difference are:
* do not hit performance of the server and the source code is more
didactically to learn by some users that wanst to modify (Check license please).
* it feature antipvp block that depending of configuration, on anarchy servers
@ -47,11 +45,12 @@ For more info we use all the tools of Final Minetest by oldcoder http://minetest
You can set those configurations in the mod tab at the gui, or added those option
to the minetest config file at game directory, to the main global config file.
| config option | type | default | description |
| -------------------- | ---- | ------- | ----------- |
| config option | type | default | description |
| ------------------- | ---- | ------- | ----------- |
| antipvp_kill_hitter | bool | false | if enable, players that hit will be killed. |
| antipvp_admin_privs | bool | true | if enable, the admin of the server will be automaticaly with antipvp privilegies. |
| antipvp_send_to_all | bool | true | if enable, when a hitter try to hurt to a invulnerable player, send the message to all players. |
| antipvp_send_notify | bool | true | if enable, permit to send notifications chat messages to involved players, check the next setting for details |
| antipvp_send_to_all | bool | false | if enable, when a hitter try to hurt to a invulnerable player, send the message to all players. |
| antipvp_area_ratio | int | 2 | number in blocks to define peacefull antipvp area around the antipvp block. |
### Nodes
@ -92,3 +91,4 @@ Some portion and first base code were posible thanks to:
License CC-BY-NC-SA-3.0 only . due sources were lost.
Any portion of code of firs 2 commit are under GPLv3

View File

@ -1,24 +1,9 @@
-- Copyright (C) 2021 Sandro Del Toro De Ana
-- Copyright (C) 2022 PICCORO Lenz McKAY
-- This file is part of antipvp Minetest Mod.
-- antipvp is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- any later version.
-- antipvp is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
-- You should have received a copy of the GNU General Public License
-- along with antipvp. If not, see <https://www.gnu.org/licenses/>.
-- This file is part of antimod minenux Minetest Mod.
-- Load support for MT game translation.
-- Check for translation method
@ -48,10 +33,18 @@ local kill_hitter = core.settings:get_bool("antipvp_kill_hitter") or false
local admin_privs = core.settings:get_bool("antipvp_admin_privs") or true
local send_to_all = core.settings:get_bool("antipvp_send_to_all") or true
local send_notify = core.settings:get_bool("antipvp_send_notify") or true
local send_to_all = core.settings:get_bool("antipvp_send_to_all") or false
local area_ratio = tonumber(minetest.setting_get("antipvp_area_ratio") or 3)
if kill_hitter == nil then kill_hitter = false end
if admin_privs == nil then admin_privs = true end
if send_notify == nil then send_notify = true end
if send_to_all == nil then send_to_all = false end
if area_ratio == nil then area_ratio = 3 end
-- compat with irc mod fork
if core.get_modpath("irc") then
if irc.saysec == nil then
@ -70,6 +63,7 @@ core.register_privilege("antipvp", {
give_to_admin = privs_give_to_admin,
})
-- block
core.register_node("antipvp:quiet", {
description = "Anti PVP place",
tiles = {"default_obsidian.png^[colorize:white:36^heart.png"},
@ -81,6 +75,7 @@ core.register_node("antipvp:quiet", {
groups = {choppy=3, level=3}
})
-- craft
minetest.register_craft({
output = "antipvp:quiet",
recipe = {
@ -90,6 +85,7 @@ minetest.register_craft({
}
})
-- action
core.register_on_punchplayer(
function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage)
@ -110,13 +106,15 @@ core.register_on_punchplayer(
hitter:set_hp(0)
end
core.chat_send_player(hitter_name, S("You can not hurt a God") )
core.chat_send_player(player_name, S("@1 try hurt you", hitter_name) )
if core.get_modpath("irc") then
if send_to_all then
irc.saysec(hitter_name.." try hurt to "..player_name)
else
irc.saysec(player_name, hitter_name.." try hurt you")
if send_notify then
core.chat_send_player(hitter_name, S("You can not hurt a God") )
core.chat_send_player(player_name, S("@1 try hurt you", hitter_name) )
if core.get_modpath("irc") then
if send_to_all then
irc.saysec(hitter_name.." try hurt to "..player_name)
else
irc.saysec(player_name, hitter_name.." try hurt you")
end
end
end
minetest.log("action","[antipvp] "..hitter_name.." try hurt to "..player_name)
@ -128,14 +126,17 @@ core.register_on_punchplayer(
end
-- not a invulnerable player.. then check if are over protected place
if core.find_node_near(player_ppos, area_ratio, "antipvp:quiet") then
core.chat_send_player(hitter_name, "is at a peaceful area... ")
if core.get_modpath("irc") then
if send_to_all then
irc.saysec(hitter_name.." try hurt on of the peacefull areas")
else
irc.saysec(hitter_name, "Dont try hurt the peacefull area")
if send_notify then
core.chat_send_player(hitter_name, "is at a peaceful area... ")
if core.get_modpath("irc") then
if send_to_all then
irc.saysec(hitter_name.." try hurt on of the peacefull areas")
else
irc.saysec(hitter_name, "Dont try hurt the peacefull area")
end
end
end
minetest.log("action","[antipvp] "..hitter_name.." try hurt to "..player_name)
return true
end

View File

@ -1,3 +1,4 @@
name = antipvp
title = antipvp
optional_depends = irc
description = ANTI PVP Invulnerability Privilege for players

View File

@ -1,12 +1,15 @@
# if enabled will Kill with one hit only when antipvp are grant
antipvp_kill_hitter (Kill hitter to antipvp privilegies) bool false
antipvp_kill_hitter (Kill hitter if player has antipvp privilegies) bool false
# if enable admin will be pvp invulnerable
antipvp_admin_privs (Give automatically to the admin of server pvp invulnerable privs) bool true
# if enabled send the activity of hurt to invulnerable players to all the chats!
antipvp_send_to_all (Send message to all the players and not only those involved) bool true
# if enabled send the notification of hostile actions agais a player, to hitter player
antipvp_send_notify (Send or not message notifiacion in chat of those involved) bool true
# if enabled send the activity of hurt to invulnerable players to all the chats!
antipvp_area_ratio (Ration in blocks of the peacefull antipvp block) int 3
antipvp_send_to_all (Send message to all the players and not only those involved) bool false
# amoun of bloc around the peacefull block that give protection to player
antipvp_area_ratio (Ratio in blocks of the peacefull antipvp block) int 3