forked from mtcontrib/factions
Fixed tons of bugs
This commit is contained in:
parent
f67406cd65
commit
c678fd55e2
@ -29,14 +29,16 @@ factions.register_command = function(cmd_name, cmd)
|
|||||||
infaction = true,
|
infaction = true,
|
||||||
description = "This command has no description.",
|
description = "This command has no description.",
|
||||||
run = function(self, player, argv)
|
run = function(self, player, argv)
|
||||||
--[[ check global privileges
|
|
||||||
if self.global_privileges then
|
if self.global_privileges then
|
||||||
local bool, missing_privs = minetest.check_player_privs(player, self.global_privileges)
|
local tmp = {}
|
||||||
if not bool then
|
for i in ipairs(self.global_privileges) do
|
||||||
send_error(player, "Missing global privileges: "..table.concat(missing_privs, ", "))
|
tmp[self.global_privileges[i]] = true
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
end]]
|
local bool, missing_privs = minetest.check_player_privs(player, tmp)
|
||||||
|
if not bool then
|
||||||
|
send_error(player, "Unauthorized.")
|
||||||
|
end
|
||||||
|
end
|
||||||
-- checks argument formats
|
-- checks argument formats
|
||||||
local args = {
|
local args = {
|
||||||
factions = {},
|
factions = {},
|
||||||
@ -62,7 +64,7 @@ factions.register_command = function(cmd_name, cmd)
|
|||||||
elseif argtype == "player" then
|
elseif argtype == "player" then
|
||||||
local pl = minetest.get_player_by_name(arg)
|
local pl = minetest.get_player_by_name(arg)
|
||||||
if not pl then
|
if not pl then
|
||||||
send_error(player, "Player is not invited.")
|
send_error(player, "Player is not online.")
|
||||||
--TODO: track existing players for offsync invites and the like
|
--TODO: track existing players for offsync invites and the like
|
||||||
return false
|
return false
|
||||||
else
|
else
|
||||||
@ -87,7 +89,7 @@ factions.register_command = function(cmd_name, cmd)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
player_faction = factions.factions[player_faction]
|
player_faction = factions.factions[player_faction]
|
||||||
if faction_permissions then
|
if self.faction_permissions then
|
||||||
for i in ipairs(self.faction_permissions) do
|
for i in ipairs(self.faction_permissions) do
|
||||||
if not player_faction:has_permission(player, self.faction_permissions[i]) then
|
if not player_faction:has_permission(player, self.faction_permissions[i]) then
|
||||||
send_error(player, "You don't have permissions to do that.")
|
send_error(player, "You don't have permissions to do that.")
|
||||||
@ -240,7 +242,7 @@ factions.register_command("leave", {
|
|||||||
})
|
})
|
||||||
|
|
||||||
factions.register_command("kick", {
|
factions.register_command("kick", {
|
||||||
faction_permissions = {"playerlist"},
|
faction_permissions = {"playerslist"},
|
||||||
format = {"player"},
|
format = {"player"},
|
||||||
description = "Kick a player from your faction.",
|
description = "Kick a player from your faction.",
|
||||||
on_success = function(player, faction, pos, chunkpos, args)
|
on_success = function(player, faction, pos, chunkpos, args)
|
||||||
@ -251,7 +253,7 @@ factions.register_command("kick", {
|
|||||||
--TODO: message?
|
--TODO: message?
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
--TODO: error (player is leader or in faction)
|
send_error(player, "Cannot kick player "..victim.name)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -332,7 +334,7 @@ factions.register_command("description", {
|
|||||||
faction_permissions = {"description"},
|
faction_permissions = {"description"},
|
||||||
description = "Set your faction's description",
|
description = "Set your faction's description",
|
||||||
on_success = function(player, faction, pos, chunkpos, args)
|
on_success = function(player, faction, pos, chunkpos, args)
|
||||||
faction:set_description(args.other.concat(" "))
|
faction:set_description(table.concat(args.other," "))
|
||||||
--TODO: message
|
--TODO: message
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@ -375,10 +377,6 @@ factions.register_command("delete", {
|
|||||||
factions.register_command("ranks", {
|
factions.register_command("ranks", {
|
||||||
description = "List ranks within your faction",
|
description = "List ranks within your faction",
|
||||||
on_success = function(player, faction, pos, chunkpos, args)
|
on_success = function(player, faction, pos, chunkpos, args)
|
||||||
if not faction then
|
|
||||||
--TODO: error message
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
for rank, permissions in pairs(faction.ranks) do
|
for rank, permissions in pairs(faction.ranks) do
|
||||||
minetest.chat_send_player(player, rank..": "..table.concat(permissions, " "))
|
minetest.chat_send_player(player, rank..": "..table.concat(permissions, " "))
|
||||||
end
|
end
|
||||||
|
17
factions.lua
17
factions.lua
@ -48,21 +48,6 @@ end
|
|||||||
|
|
||||||
|
|
||||||
factions.Faction = {
|
factions.Faction = {
|
||||||
power = 0.,
|
|
||||||
players = {},
|
|
||||||
ranks = {["leader"] = {"disband", "claim", "playerlist", "build", "edit", "ranks"},
|
|
||||||
["member"] = {"build"}
|
|
||||||
},
|
|
||||||
leader = nil,
|
|
||||||
default_rank = "member",
|
|
||||||
default_leader_rank = "leader",
|
|
||||||
description = "Default faction description.",
|
|
||||||
invited_players = {},
|
|
||||||
land = {},
|
|
||||||
allies = {},
|
|
||||||
enemies = {},
|
|
||||||
join_free = false,
|
|
||||||
spawn = nil,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
factions.Faction.__index = factions.Faction
|
factions.Faction.__index = factions.Faction
|
||||||
@ -71,7 +56,7 @@ function factions.Faction:new(faction)
|
|||||||
faction = {
|
faction = {
|
||||||
power = 0.,
|
power = 0.,
|
||||||
players = {},
|
players = {},
|
||||||
ranks = {["leader"] = {"disband", "claim", "playerlist", "build", "edit", "ranks"},
|
ranks = {["leader"] = {"disband", "claim", "playerslist", "build", "edit", "ranks"},
|
||||||
["member"] = {"build"}
|
["member"] = {"build"}
|
||||||
},
|
},
|
||||||
leader = nil,
|
leader = nil,
|
||||||
|
Loading…
Reference in New Issue
Block a user