-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstartup.lua
More file actions
70 lines (57 loc) · 1.65 KB
/
startup.lua
File metadata and controls
70 lines (57 loc) · 1.65 KB
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
-- claiming-heads/startup.lua
--[[
Events.on("claiming-heads.StartupEvent"):call(function(event)
local data = event.data
data.claimingWidth = 28
end)
Events.on("claiming-heads.ClaimEvent"):call(function(event)
local pos = event.data.pos
-- local isCloseToVillage = spell.world:getNearestVillage(pos, 10)
--event.data.canceled = not isCloseToVillage
--event.canceled = not isCloseToVillage -- TODO fix this in WoL
event.data.canceled = false
end)
Events.on("claiming-heads.MayBuildEvent"):call(function(event)
local item = event.data.player.mainhand
if item then
local nbt = item.nbt
if nbt and nbt.tag and nbt.tag.CanDestroy then
for _,name in pairs(nbt.tag.CanDestroy) do
if name == event.data.block.name then
event.data.result = true
break
end
end
end
end
end)
]]--
local module = ...
local start
local initialize
local DEFAULTS = {
claimingWidth = 21 ,
claimingFrequency = 20 ,
restictCreativePlayer = false ,
enableCommands = true
}
local STARTUP_EVENT = 'claiming-heads.StartupEvent'
function initialize(target, defaults)
target = target or {}
for k,v in pairs(defaults) do
if not target[k] then
target[k] = v
end
end
return target
end
local options = DEFAULTS
Events.fire(STARTUP_EVENT,options)
require('claiming-heads.give-head').enable(options.enableCommands)
require('claiming-heads.show-claim').enable(options.enableCommands)
require('claiming-heads.claiming').start(
{ width = options.claimingWidth,
frequency = options.claimingFrequency,
creativeBuildAllowed = not options.restictCreativePlayer
}
)