Merge pull request #5 from Cat5TV/master

Merging Cat5TV branch
This commit is contained in:
ChaosWormz 2016-05-17 16:32:27 +03:00
commit 9367eff448
6 changed files with 159 additions and 41 deletions

11
LICENSE.md Normal file

@ -0,0 +1,11 @@
####DO WHAT YOU WANT TO PUBLIC LICENSE (DWYWPL)
December 2nd 2015
License Copyright (C) 2015 Michael Tomaino (PlatinumArts@gmail.com)
[www.sandboxgamemaker.com/DWYWPL/](www.sandboxgamemaker.com/DWYWPL/)
#####DO WHAT YOU WANT TO PUBLIC LICENSE
######TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
1. You are allowed to do whatever you want to with what content is using this license.
2. This content is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this content.

@ -1,2 +1,43 @@
This mod is released under WTFPL.
It adds ability to teleport to other players with their permission by using the /tpr command which requires "interact" privilege and the /tphr command which requires the "interact " privilege.
##*tps_teleport* is a mod for Minetest game servers.
##Description:
[The Pixel Shadow](https://minetest.tv/) Minetest game servers have switched from "teleport" to "teleport request" via the *tps_teleport* mod. This mod makes it so players must send a request to another player in order to teleport to them. Before they will be allowed to do so, the player must accept the request. This prevents malicious users from teleporting to players' private areas without their permission. It also enhances the overall privacy of our services since if denied teleport, a player must instead travel to the area and "use the front door" so to speak... which might be a locked iron door.
##Privileges:
- *interact* Permits use of all tps_teleport commands
- *tp_admin* Admin priv allows admin to teleport anywhere without permission
Players may also teleport to coordinates, however if the area is protected, the teleport will be denied.
##Usage:
``` /tpr [playername] ```
Requests permission to teleport to another player, where [playername] is their exact name.
``` /tphr [playername] ```
Request permission to teleport another player to you.
``` /tpc [x,y,z] ```
Teleport to coordinates. Honors area protection: if the area is protected, it must be owned by you in order to teleport to it.
``` /tpy ```
Accept a user's request to teleport to you or teleport you to them.
``` /tpn ```
Deny a user's request to teleport to youor teleport you to them.
##Contributors:
- [RobbieF](https://minetest.tv)
- [DonBatman](https://github.com/donbatman)
- [NathanS21](http://nathansalapat.com/)
- All those who contributed to the original mod (please see init.lua)
##To Do:
- Make it so if a player attempts to teleport to coordinates within a protected area owned by another player, and that player is online, the owner receives a request to allow or deny the user from teleporting to their area.
- Add limitations to /tpc which only allow a user to teleport X number of blocks. Prevents users from teleporting to the edge of the world.
- Make it so tp_admin priv also overrides need for player to accept /tpr or /tphr
- Assess value in changing all tpr-based chat commands to one global command such as /tp to reduce the chance of confusion between tps_admin and the original mod (and also make it so people don't have to remember so many commands).
- Create a better sound effect for teleport and apply it to all teleport methods (not just /tpc)
- Creation of "evade" command /tpe which spawns the player in several random locations nearby before placing them at a final destination ~20 nodes away. For evading attack.
- Add a handful of coordinates which can be set in config and teleported to by anyone regardless of their protection status (eg., Spawn).
- Add a privilege which is required in order to use all commands. I haven't added such a thing since it hasn't been needed on our servers, but I imagine it would be useful on other servers who desire to grant these features only to specific players.

1
depends.txt Normal file

@ -0,0 +1 @@
areas

143
init.lua

@ -1,18 +1,55 @@
-- Original code by Traxie21 and released with the WTFPL license
-- Originally Teleport Request by Traxie21 and released with the WTFPL license
-- https://forum.minetest.net/viewtopic.php?id=4457
-- Updates by Zeno and ChaosWormz
-- New release by RobbieF under new mod: tps_teleport - http://blog.minetest.tv/teleport-request/
local timeout_delay = 60
-- Set to true to register tpr_admin priv
local regnewpriv = false
local version = "1.1"
local version = "1.3"
local tpr_list = {}
local tphr_list = {}
minetest.register_privilege("tp_admin", {description = "Admin overrides for tps_teleport.", give_to_singleplayer=false,})
local function find_free_position_near(pos)
local tries = {
{x=1,y=0,z=0},
{x=-1,y=0,z=0},
{x=0,y=0,z=1},
{x=0,y=0,z=-1},
}
for _,d in pairs(tries) do
local p = vector.add(pos, d)
if not minetest.registered_nodes[minetest.get_node(p).name].walkable then
return p, true
end
end
return pos, false
end
local function parti(pos)
minetest.add_particlespawner(50, 0.4,
{x=pos.x + 0.5, y=pos.y, z=pos.z + 0.5}, {x=pos.x - 0.5, y=pos.y, z=pos.z - 0.5},
{x=0, y=5, z=0}, {x=0, y=0, z=0},
{x=0, y=5, z=0}, {x=0, y=0, z=0},
3, 5,
3, 5,
false,
"tps_portal_parti.png")
end
local function parti2(pos)
minetest.add_particlespawner(50, 0.4,
{x=pos.x + 0.5, y=pos.y + 10, z=pos.z + 0.5}, {x=pos.x - 0.5, y=pos.y, z=pos.z - 0.5},
{x=0, y=-5, z=0}, {x=0, y=0, z=0},
{x=0, y=-5, z=0}, {x=0, y=0, z=0},
3, 5,
3, 5,
false,
"tps_portal_parti.png")
end
--Teleport Request System
local function tpr_send(sender, receiver)
if receiver == "" then
@ -62,6 +99,53 @@ local function tphr_send(sender, receiver)
end, sender)
end
local function tpc_send(player,coordinates)
local posx,posy,posz = string.match(coordinates, "^(-?%d+),(-?%d+),(-?%d+)$")
local pname = minetest.get_player_by_name(player)
if posx ~= nil or posy ~= nil or posz ~= nil then
posx = tonumber(posx) + 0.0
posy = tonumber(posy) + 0.0
posz = tonumber(posz) + 0.0
end
if posx==nil or posy==nil or posz==nil or string.len(posx) > 6 or string.len(posy) > 6 or string.len(posz) > 6 then
minetest.chat_send_player(player, "Usage: /tpc <x,y,z>")
return nil
end
if posx > 32765 or posx < -32765 or posy > 32765 or posy < -32765 or posz > 32765 or posz < -32765 then
minetest.chat_send_player(player, "Error: Invalid coordinates.")
return nil
end
local target_coords={x=posx, y=posy, z=posz}
-- If the area is protected, reject the user's request to teleport to these coordinates
-- In future release we'll actually query the player who owns the area, if they're online, and ask for their permission.
-- Admin user (priv "tp_admin") overrides all protection
if minetest.check_player_privs(pname, {tp_admin=true}) then
minetest.chat_send_player(player, 'Teleporting to '..posx..','..posy..','..posz)
pname:setpos(find_free_position_near(target_coords))
minetest.sound_play("whoosh", {pos = target_coords, gain = 0.5, max_hear_distance = 10})
parti2(target_coords)
else
local protected = minetest.is_protected(target_coords,pname)
if protected then
if not areas:canInteract(target_coords, player) then
local owners = areas:getNodeOwners(target_coords)
minetest.chat_send_player(player,("Error: %s is protected by %s."):format(minetest.pos_to_string(target_coords),table.concat(owners, ", ")))
return
end
end
minetest.chat_send_player(player, 'Teleporting to '..posx..','..posy..','..posz)
pname:setpos(find_free_position_near(target_coords))
minetest.sound_play("whoosh", {pos = target_coords, gain = 0.5, max_hear_distance = 10})
parti2(target_coords)
end
end
local function tpr_deny(name)
if tpr_list[name] then
minetest.chat_send_player(tpr_list[name], 'Teleport request denied.')
@ -73,31 +157,13 @@ local function tpr_deny(name)
end
end
-- Copied from Celeron-55's /teleport command. Thanks Celeron!
local function find_free_position_near(pos)
local tries = {
{x=1,y=0,z=0},
{x=-1,y=0,z=0},
{x=0,y=0,z=1},
{x=0,y=0,z=-1},
}
for _,d in pairs(tries) do
local p = vector.add(pos, d)
if not minetest.registered_nodes[minetest.get_node(p).name].walkable then
return p, true
end
end
return pos, false
end
--Teleport Accept Systems
local function tpr_accept(name, param)
--Check to prevent constant teleporting.
if not tpr_list[name]
and not tphr_list[name] then
minetest.chat_send_player(name, "Usage: /tpy allows you to accept teleport requests sent to you by other players")
minetest.chat_send_player(name, "Usage: /tpy allows you to accept teleport requests sent to you by other players.")
return
end
@ -127,21 +193,13 @@ local function tpr_accept(name, param)
minetest.chat_send_player(name2, "Request Accepted!")
minetest.chat_send_player(name, chatmsg)
target:setpos(find_free_position_near(source:getpos()))
local target_coords=source:getpos()
target:setpos(find_free_position_near(target_coords))
minetest.sound_play("whoosh", {pos = target_coords, gain = 0.5, max_hear_distance = 10})
parti2(target_coords)
end
--Initalize Permissions.
if regnewpriv then
minetest.register_privilege("tpr_admin", {
description = "Permission to override teleport to other players. UNFINISHED",
give_to_singleplayer = true
})
end
--Initalize Commands.
minetest.register_chatcommand("tpr", {
description = "Request teleport to another player",
params = "<playername> | leave playername empty to see help message",
@ -156,6 +214,13 @@ minetest.register_chatcommand("tphr", {
func = tphr_send
})
minetest.register_chatcommand("tpc", {
description = "Teleport to coordinates",
params = "<coordinates> | leave coordinates empty to see help message",
privs = {interact=true},
func = tpc_send
})
minetest.register_chatcommand("tpy", {
description = "Accept teleport requests from another player",
func = tpr_accept
@ -166,4 +231,4 @@ minetest.register_chatcommand("tpn", {
func = tpr_deny
})
minetest.log("info", "[Teleport Request] Teleport Request v" .. version .. " Loaded.")
minetest.log("info", "[Teleport Request] TPS Teleport v" .. version .. " Loaded.")

BIN
sounds/whoosh.ogg Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 745 B