-
Notifications
You must be signed in to change notification settings - Fork 11
/
main.lua
93 lines (81 loc) · 3.04 KB
/
main.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
--Global variables
PortalTimer = {}
Warps = {}
Jails = {}
BackCoords = {}
BackWorld = {}
TpRequestTimeLimit = 0
TeleportRequests = {}
Jailed = {}
Muted = {}
SocialSpyList = {}
GodModeList = {}
--Initialize the plugin
function Initialize(Plugin)
Plugin:SetName(g_PluginInfo.Name)
Plugin:SetVersion(g_PluginInfo.Version)
--Register hooks
cPluginManager:AddHook(cPluginManager.HOOK_TAKE_DAMAGE, OnTakeDamage)
cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_RIGHT_CLICK, OnPlayerRightClick)
cPluginManager.AddHook(cPluginManager.HOOK_UPDATING_SIGN, OnUpdatingSign)
cPluginManager:AddHook(cPluginManager.HOOK_CHAT, OnChat)
cPluginManager:AddHook(cPluginManager.HOOK_EXECUTE_COMMAND, OnExecuteCommand)
cPluginManager:AddHook(cPluginManager.HOOK_PLAYER_BREAKING_BLOCK, OnPlayerBreakingBlock)
cPluginManager:AddHook(cPluginManager.HOOK_PLAYER_PLACING_BLOCK, OnPlayerPlacingBlock)
cPluginManager:AddHook(cPluginManager.HOOK_WORLD_TICK, OnWorldTick)
cPluginManager:AddHook(cPluginManager.HOOK_ENTITY_TELEPORT, OnEntityTeleport)
cPluginManager:AddHook(cPluginManager.HOOK_KILLED, OnKilled)
cPluginManager:AddHook(cPluginManager.HOOK_PLAYER_JOINED, OnPlayerJoined)
cPluginManager:AddHook(cPluginManager.HOOK_ENTITY_CHANGING_WORLD, OnEntityChangingWorld)
dofile(cPluginManager:GetPluginsPath() .. "/InfoReg.lua")
RegisterPluginInfoCommands()
RegisterPluginInfoConsoleCommands()
--Set folders which will be used later on
HomesFolder = Plugin:GetLocalFolder().."/homes"
--If there's no home folder, the plugin will create it
if not cFile:IsFolder(HomesFolder) then
cFile:CreateFolder(HomesFolder)
end
--Read warps from the warps.ini file
WarpsINI = cIniFile()
if WarpsINI:ReadFile("warps.ini") then
local WarpNum = WarpsINI:GetNumKeys() - 1
for i=0, WarpNum do
local Tag = WarpsINI:GetKeyName(i)
Warps[Tag] = {}
Warps[Tag]["w"] = WarpsINI:GetValue(Tag , "w")
Warps[Tag]["x"] = WarpsINI:GetValueI(Tag , "x")
Warps[Tag]["y"] = WarpsINI:GetValueI(Tag , "y")
Warps[Tag]["z"] = WarpsINI:GetValueI(Tag , "z")
end
end
--Read jails from the jails.ini file
JailsINI = cIniFile()
if JailsINI:ReadFile("jails.ini") then
local JailNum = JailsINI:GetNumKeys() - 1
for i=0, JailNum do
local Tag = JailsINI:GetKeyName(i)
Jails[Tag] = {}
Jails[Tag]["w"] = JailsINI:GetValue(Tag , "w")
Jails[Tag]["x"] = JailsINI:GetValueI(Tag , "x")
Jails[Tag]["y"] = JailsINI:GetValueI(Tag , "y")
Jails[Tag]["z"] = JailsINI:GetValueI(Tag , "z")
end
end
UsersINI = cIniFile()
UsersINI:ReadFile("users.ini")
--Read tpa timeout config
local SettingsINI = cIniFile()
SettingsINI:ReadFile("settings.ini")
TpRequestTimeLimit = SettingsINI:GetValueSetI("Teleport", "RequestTimeLimit", 0)
if SettingsINI:GetNumKeyComments("Teleport") == 0 then
SettingsINI:AddKeyComment("Teleport", "RequestTimeLimit: Time in seconds after which tpa/tpahere will timeout, 0 - disabled")
end
SettingsINI:WriteFile("settings.ini")
cRoot:Get():ForEachPlayer(CheckPlayer)
LOG("Initialised v." .. Plugin:GetVersion())
return true
end
function OnDisable()
LOG("Disabling...")
end