-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommands.lua
674 lines (651 loc) · 28.6 KB
/
commands.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
local enable_damage = core.settings:get_bool("enable_damage")
local speeds = {}
local function containsValue(table, value)
for _, v in ipairs(table) do
if v == value then
return true
end
end
return false
end
minetest.register_chatcommand("ip", {
params = "<name>",
description = "Show the IP of a player.",
privs = {server = true},
func = function(name, param)
if not containsValue(essentials.trusted_ip_users, name) then
minetest.chat_send_player(name, core.colorize("red", "You are not of trusted administrator!"))
minetest.sound_play("error", name)
show_ip_info(name)
return
end
if param == "" then
minetest.chat_send_player(name, "Your IP address is ".. minetest.get_player_ip(name))
return
end
if minetest.get_player_by_name(param) == nil then
minetest.chat_send_player(name, core.colorize("red", "Player ".. param .." not found!"))
minetest.sound_play("error", name)
return
end
minetest.chat_send_player(name, "IP address of ".. param .." is ".. minetest.get_player_ip(param))
end,
})
if essentials.add_privs then
minetest.register_chatcommand("broadcast", {
params = "<message>",
description = "Send GLOBAL message in chat.",
privs = {broadcast = true},
func = function(name, param)
if param == "" then
core.chat_send_player(name, core.colorize("red", "Message cannot be empty!"))
minetest.sound_play("error", name)
return
end
if minetest.check_player_privs(name, {server=true}) then
core.chat_send_all(core.colorize("#0006FF", "[Announcement] ")..core.colorize("#00FFC6", param))
else
core.chat_send_all(core.colorize("#0006FF", "[Announcement] ")..core.colorize("#00FFC6", param).." "..core.colorize("#82909D", string.format("(Announced by %s)", name)))
end
for _, player in ipairs(minetest.get_connected_players()) do
minetest.sound_play("broadcast", player:get_player_name())
end
end,
})
else
minetest.register_chatcommand("broadcast", {
params = "<message>",
description = "Send GLOBAL message in chat.",
privs = {bring = true},
func = function(name, param)
if param == "" then
core.chat_send_player(name, core.colorize("red", "Message cannot be empty!"))
minetest.sound_play("error", name)
return
end
if minetest.check_player_privs(name, {server=true}) then
core.chat_send_all(core.colorize("#0006FF", "[Announcement] ")..core.colorize("#00FFC6", param))
else
core.chat_send_all(core.colorize("#0006FF", "[Announcement] ")..core.colorize("#00FFC6", param).." "..core.colorize("#82909D", string.format("(Announced by %s)", name)))
end
for _, player in ipairs(minetest.get_connected_players()) do
minetest.sound_play("broadcast", player:get_player_name())
end
end,
})
end
local function isNumber(num)
local value = tonumber(num)
return (type(value) == "number" and math.floor(value) ~= value) or (type(value) == "number" and math.floor(value) == value)
end
if essentials.add_privs then
minetest.register_chatcommand("speed", {
params = "<speed> [<player>]",
description = "Sets a speed for an any player. (Standart speed is 1)",
privs = {speed = true},
func = function(name, param)
local speed = string.match(param, "([^ ]+)")
local oname = string.match(param, speed.." (.+)")
--core.chat_send_all(dump(speed).." "..dump(oname))
if speed == nil then
core.chat_send_player(name, string.format("Your speed now is %s.", 1))
minetest.sound_play("done", name)
minetest.get_player_by_name(name):set_physics_override({
speed = 1
})
return
end
if oname == nil then
core.chat_send_player(name, string.format("Your speed now is %s.", speed))
minetest.sound_play("done", name)
minetest.get_player_by_name(name):set_physics_override({
speed = tonumber(speed)
})
else
if minetest.get_player_by_name(oname) == nil then
core.chat_send_player(name, core.colorize("red", "Please, specify an online player."))
minetest.sound_play("error", name)
return
end
core.chat_send_player(name, string.format("Speed of player %s now is %s.", oname, speed))
minetest.sound_play("done", name)
minetest.sound_play("done", oname)
if essentials.changed_by then
minetest.chat_send_player(oname, string.format("Now your speed is %s from player %s.", speed, name))
end
minetest.get_player_by_name(oname):set_physics_override({
speed = tonumber(speed)
})
end
end,
})
else
minetest.register_chatcommand("speed", {
params = "<speed> [<player>]",
description = "Sets a speed for an any player. (Standart speed is 1)",
privs = {rollback = true},
func = function(name, param)
local speed = string.match(param, "([^ ]+)")
local oname = string.match(param, speed.." (.+)")
--core.chat_send_all(dump(speed).." "..dump(oname))
if speed == nil then
core.chat_send_player(name, string.format("Your speed now is %s.", 1))
minetest.sound_play("done", name)
minetest.get_player_by_name(name):set_physics_override({
speed = 1
})
return
end
if oname == nil then
core.chat_send_player(name, string.format("Your speed now is %s.", speed))
minetest.sound_play("done", name)
minetest.get_player_by_name(name):set_physics_override({
speed = tonumber(speed)
})
else
if minetest.get_player_by_name(oname) == nil then
core.chat_send_player(name, core.colorize("red", "Please, specify an online player."))
minetest.sound_play("error", name)
return
end
core.chat_send_player(name, string.format("Speed of player %s now is %s.", oname, speed))
minetest.sound_play("done", name)
minetest.sound_play("done", oname)
if essentials.changed_by then
minetest.chat_send_player(oname, string.format("Now your speed is %s from player %s.", speed, name))
end
minetest.get_player_by_name(oname):set_physics_override({
speed = tonumber(speed)
})
end
end,
})
end
if essentials.add_privs then
if essentials.biome then
minetest.register_chatcommand("biome", {
params = "[<info_name>]",
description = "Shows the current biome information you are in.",
func = function(name, param)
local pos = minetest.get_player_by_name(name):get_pos()
if not minetest.has_feature("object_use_texture_alpha") then
core.chat_send_player(name, core.colorize("red", "Biome info cannot retrieve, server engine does not support the command!"))
minetest.sound_play("error", name)
minetest.log("error","[essentials] server mineitest engine too old, biome data not supported!, upgrade server")
end
local biomeinfo = minetest.get_biome_data(pos)
local biome = minetest.get_biome_name(biomeinfo.biome)
if param == "" then
core.chat_send_player(name, "Biome: \"".. biome .."\"")
else
if minetest.check_player_privs(name, {server=true}) then
if param == "heat" then
core.chat_send_player(name, "\"".. biome .."\": ".. biomeinfo.heat)
elseif param == "humidity" then
core.chat_send_player(name, "\"".. biome .."\": ".. biomeinfo.humidity)
else
core.chat_send_player(name, core.colorize("red", "You specialized wrong information name!"))
minetest.sound_play("error", name)
end
else
core.chat_send_player(name, core.colorize("red", "You cant check more information without privelege!"))
minetest.sound_play("error", name)
end
end
end,
})
else
minetest.register_chatcommand("biome", {
params = "<info_name>",
privs = {biome = true},
description = "Shows the current biome information you are in.",
func = function(name, param)
local pos = minetest.get_player_by_name(name):get_pos()
local biomeinfo = minetest.get_biome_data(pos)
local biome = minetest.get_biome_name(biomeinfo.biome)
if param == "" then
core.chat_send_player(name, "Biome: \"".. biome .."\"")
else
if minetest.check_player_privs(name, {server=true}) then
if param == "heat" then
core.chat_send_player(name, "\"".. biome .."\": ".. biomeinfo.heat)
elseif param == "humidity" then
core.chat_send_player(name, "\"".. biome .."\": ".. biomeinfo.humidity)
else
core.chat_send_player(name, core.colorize("red", "You specialized wrong information name!"))
minetest.sound_play("error", name)
end
else
core.chat_send_player(name, core.colorize("red", "You cant check more information without privelege!"))
minetest.sound_play("error", name)
end
end
end,
})
end
else
minetest.register_chatcommand("biome", {
params = "[<info_name>]",
privs = {},
description = "Shows the current biome information you are in.",
func = function(name, param)
local pos = minetest.get_player_by_name(name):get_pos()
local biomeinfo = minetest.get_biome_data(pos)
local biome = minetest.get_biome_name(biomeinfo.biome)
if param == "" then
core.chat_send_player(name, "Biome: \"".. biome .."\"")
else
if minetest.check_player_privs(name, {server=true}) then
if param == "heat" then
core.chat_send_player(name, "\"".. biome .."\": ".. biomeinfo.heat)
elseif param == "humidity" then
core.chat_send_player(name, "\"".. biome .."\": ".. biomeinfo.humidity)
else
core.chat_send_player(name, core.colorize("red", "You specialized wrong information name!"))
minetest.sound_play("error", name)
end
else
core.chat_send_player(name, core.colorize("red", "You cant check more information without privelege!"))
minetest.sound_play("error", name)
end
end
end,
})
end
--minetest.get_mapgen_object
if essentials.add_privs then
if essentials.seed then
minetest.register_chatcommand("seed", {
description = "Shows the seed of mapgen.",
func = function(name, param)
core.chat_send_player(name, "Seed: ["..core.colorize("#00ff00", minetest.get_mapgen_setting("seed")).."]")
end,
})
else
minetest.register_chatcommand("seed", {
privs = {seed = true},
description = "Shows the seed of mapgen.",
func = function(name, param)
core.chat_send_player(name, "Seed: ["..core.colorize("#00ff00", minetest.get_mapgen_setting("seed")).."]")
end,
})
end
else
if essentials.seed then
minetest.register_chatcommand("seed", {
description = "Shows the seed of mapgen.",
func = function(name, param)
core.chat_send_player(name, "Seed: ["..core.colorize("#00ff00", minetest.get_mapgen_setting("seed")).."]")
end,
})
else
minetest.register_chatcommand("seed", {
privs = {rollback = true},
description = "Shows the seed of mapgen.",
func = function(name, param)
core.chat_send_player(name, "Seed: ["..core.colorize("#00ff00", minetest.get_mapgen_setting("seed")).."]")
end,
})
end
end
-- god mode
function god_mode_switch(name, param)
if enable_damage then
local player
if param == "" then
player = minetest.get_player_by_name(name)
else
player = minetest.get_player_by_name(param)
end
if player == nil then
core.chat_send_player(name, core.colorize("red", string.format("Player %s not found.", param)))
minetest.sound_play("error", name)
return
end
local ag = player:get_armor_groups()
if not ag["immortal"] then
ag["immortal"] = 1
if param == "" then
core.chat_send_player(name, core.colorize("yellow", "God mode enabled"))
minetest.sound_play("god_enabled", name)
else
core.chat_send_player(name, string.format("God mode enabled for %s.", param))
core.chat_send_player(param, string.format("For you enabled god mode from %s.", name))
minetest.sound_play("god_enabled", param)
minetest.sound_play("done", name)
end
else
ag["immortal"] = nil
if param == "" then
core.chat_send_player(name, core.colorize("yellow", "God mode disabled"))
minetest.sound_play("god_disabled", name)
else
core.chat_send_player(name, string.format("God mode disabled for %s.", param))
core.chat_send_player(param, string.format("For you god mode has been disabled by %s", name))
minetest.sound_play("god_disabled", param)
minetest.sound_play("done", name)
end
end
player:set_armor_groups(ag)
else
core.chat_send_player(name, core.colorize("red", "\"enable_damage\" is disabled!"))
minetest.sound_play("error", name)
end
end
if essentials.add_privs then
minetest.register_chatcommand("god", {
params = "[<name>]",
description = "Enable/Disabe the god mode.",
privs = {god_mode = true},
func = god_mode_switch
})
else
minetest.register_chatcommand("god", {
params = "[<name>]",
description = "Enable/Disabe the god mode.",
privs = {noclip = true},
func = god_mode_switch
})
end
-- end
minetest.register_chatcommand("ban_menu", {
description = "Open the ban menu.",
privs = {ban = true},
func = function(name, param)
if core.is_singleplayer() then
minetest.chat_send_player(name, core.colorize("red", "You cannot ban in single mode!"))
minetest.sound_play("error", name)
return
end
show_ban_menu(name)
end
})
minetest.register_chatcommand("kick_menu", {
description = "Open the kick menu.",
privs = {kick = true},
func = function(name, param)
if core.is_singleplayer() then
minetest.chat_send_player(name, core.colorize("red", "You cannot kick in single mode!"))
minetest.sound_play("error", name)
return
end
show_kick_menu(name)
end
})
--[[
minetest.register_chatcommand("mute_menu", {
description = "Open the mute menu.",
privs = {mute = true},
func = function(name, param)
if core.is_singleplayer() then
minetest.chat_send_player(name, core.colorize("red", "You cannot mute in single mode!"))
else
show_mute_menu(name)
end
end
})
if essentials.add_privs then
minetest.register_chatcommand("rename_me", {
description = "Shows the rename menu.",
privs = {rename_player = true},
func = function(name, param)
show_rename_menu(name)
end
})
else
minetest.register_chatcommand("rename_me", {
description = "Shows the rename menu.",
privs = {kick = true},
func = function(name, param)
show_rename_menu(name)
end
})
end
]]--
if essentials.add_privs then
minetest.register_chatcommand("getpos", {
params = "<name>",
description = "Allows the player to find out the position of another player.",
privs = {get_pos = true},
func = function(name, param)
local player = minetest.get_player_by_name(param);
if param == "" then
minetest.chat_send_player(name, core.colorize("red", "Player name cannot be empty!"))
minetest.sound_play("error", name)
return
elseif minetest.get_player_by_name(param) == nil then
minetest.chat_send_player(name, core.colorize("red", "Player ".. param .." not found!"))
minetest.sound_play("error", name)
return
end
local pos = player:get_pos();
local round_pos = vector.round(pos);
minetest.chat_send_player(name, "Position of ".. param .." is ".. round_pos.x .." ".. round_pos.y .." ".. round_pos.z)
minetest.sound_play("done", name)
end,
})
else
minetest.register_chatcommand("getpos", {
params = "<name>",
description = "Allows the player to find out the position of another player.",
privs = {teleport = true},
func = function(name, param)
local player = minetest.get_player_by_name(param);
if param == "" then
minetest.chat_send_player(name, core.colorize("red", "Player name cannot be empty!"))
minetest.sound_play("error", name)
return
elseif minetest.get_player_by_name(param) == nil then
minetest.chat_send_player(name, core.colorize("red", "Player ".. param .." not found!"))
minetest.sound_play("error", name)
return
end
local pos = player:get_pos();
local round_pos = vector.round(pos);
minetest.chat_send_player(name, "Position of ".. param .." is ".. round_pos.x .." ".. round_pos.y .." ".. round_pos.z)
minetest.sound_play("done", name)
end,
})
end
if essentials.add_privs then
minetest.register_chatcommand("rename_item", {
description = "Hold item in hand and open this menu for renaming it.",
privs = {rename_item = true},
func = function(name, param)
show_renameitem_menu(name)
end
})
else
minetest.register_chatcommand("rename_item", {
description = "Hold item in hand and open this menu for renaming it.",
privs = {basic_privs = true},
func = function(name, param)
show_renameitem_menu(name)
end
})
end
if essentials.add_privs then
minetest.register_chatcommand("color", {
description = "Shows menu for coloring nickname.",
privs = {colored_nickname = true},
func = function(name, param)
show_color_menu(name)
end
})
else
minetest.register_chatcommand("color", {
description = "Shows menu for coloring nickname.",
privs = {kick = true},
func = function(name, param)
show_color_menu(name)
end
})
end
if essentials.add_privs then
minetest.register_chatcommand("kill", {
params = "[<name>]",
description = ("Kill anyone with command."),
privs = {kill = true},
func = function(name, param)
if minetest.settings:get_bool("enable_damage") then
if param == "" or param == nil then
minetest.get_player_by_name(name):set_hp(0)
else
if minetest.get_player_by_name(param) == nil then
core.chat_send_player(name, core.colorize("red", "Player ".. param .." not found!"))
minetest.sound_play("error", name)
return
end
minetest.get_player_by_name(param):set_hp(0)
core.chat_send_player(name, "You killed "..param..".")
if essentials.killed_by then
core.chat_send_player(param, string.format("You has been killed by %s.", name))
end
end
else
local player = minetest.get_player_by_name(name)
if param then
player = minetest.get_player_by_name(param)
if minetest.get_player_by_name(param) == nil then
core.chat_send_player(name, core.colorize("red", "Player ".. param .." not found!"))
minetest.sound_play("error", name)
return
end
if essentials.killed_by then
core.chat_send_player(param, string.format("You has been respawned by %s.", name))
end
end
for _, callback in pairs(minetest.registered_on_respawnplayers) do
if callback(player) then
return true
end
end
return false, "No static_spawnpoint defined"
end
end,
})
else
minetest.register_chatcommand("kill", {
params = "[<name>]",
description = ("Kill anyone with command."),
privs = {protection_bypass = true},
func = function(name, param)
if minetest.settings:get_bool("enable_damage") then
if param == "" or param == nil then
minetest.get_player_by_name(name):set_hp(0)
else
if minetest.get_player_by_name(param) == nil then
core.chat_send_player(name, core.colorize("red", "Player ".. param .." not found!"))
minetest.sound_play("error", name)
return
end
minetest.get_player_by_name(param):set_hp(0)
core.chat_send_player(name, "You killed "..param..".")
if essentials.killed_by then
core.chat_send_player(param, string.format("You has been killed by %s.", name))
end
end
else
local player = minetest.get_player_by_name(name)
if param then
player = minetest.get_player_by_name(param)
if minetest.get_player_by_name(param) == nil then
core.chat_send_player(name, core.colorize("red", "Player ".. param .." not found!"))
minetest.sound_play("error", name)
return
end
if essentials.killed_by then
core.chat_send_player(param, string.format("You has been respawned by %s.", name))
end
end
for _, callback in pairs(minetest.registered_on_respawnplayers) do
if callback(player) then
return true
end
end
return false, "No static_spawnpoint defined"
end
end,
})
end
if essentials.add_privs then
minetest.register_chatcommand("heal", {
params = "[<name>]",
description = ("Heals full health for a player."),
privs = {heal = true},
func = function(name, param)
if param == "" or param == nil then
minetest.get_player_by_name(name):set_hp(minetest.PLAYER_MAX_HP_DEFAULT)
core.chat_send_player(name, "Healed to the possible max health.")
else
if minetest.get_player_by_name(param) == nil then
core.chat_send_player(name, core.colorize("red", "Player ".. param .." not found!"))
minetest.sound_play("error", name)
return
end
minetest.get_player_by_name(param):set_hp(minetest.PLAYER_MAX_HP_DEFAULT)
core.chat_send_player(name, string.format("Player %s healed to the %s health.", param, minetest.get_player_by_name(param):get_hp()))
if essentials.changed_by then
core.chat_send_player(param, string.format("You has been fully healed by %s.", name))
end
end
end,
})
else
minetest.register_chatcommand("heal", {
params = "[<name>]",
description = ("Heals full health for a player."),
privs = {rollback = true},
func = function(name, param)
if param == "" or param == nil then
minetest.get_player_by_name(name):set_hp(minetest.PLAYER_MAX_HP_DEFAULT)
core.chat_send_player(name, "Healed to the possible max health.")
else
if minetest.get_player_by_name(param) == nil then
core.chat_send_player(name, core.colorize("red", "Player ".. param .." not found!"))
minetest.sound_play("error", name)
return
end
minetest.get_player_by_name(param):set_hp(minetest.PLAYER_MAX_HP_DEFAULT)
core.chat_send_player(name, string.format("Player %s healed to the %s health.", param, minetest.get_player_by_name(param):get_hp()))
if essentials.changed_by then
core.chat_send_player(param, string.format("You has been fully healed by %s.", name))
end
end
end,
})
end
--[[
minetest.register_chatcommand("v", {
params = "<name>",
description = "Make player invisible",
privs = {server = true},
func = function(name, param)
local player = minetest.get_player_by_name(param)
if param == "" then
if invisibility[name] then
invisible(name, false)
minetest.chat_send_player(name, "Now you are visible!")
elseif not invisibility[name] then
invisible(name, true)
minetest.chat_send_player(name, core.colorize("#AAAAAA", "Now you are invisible!"))
end
elseif not player then
minetest.chat_send_player(name, core.colorize("red", "Player ".. param .." not found!"))
minetest.sound_play("error", name)
else
if invisibility[param] then
invisible(param, false)
minetest.chat_send_player(name, "Now player ".. param .." are visible!")
minetest.chat_send_player(player, "Now you visible from ".. name .."!")
minetest.sound_play("done", player)
elseif not invisibility[param] then
invisible(param, true)
minetest.chat_send_player(name, core.colorize("#AAAAAA", "Now player ".. param .." are invisible!"))
minetest.chat_send_player(name, core.colorize("#AAAAAA", "Now you are invisible from ".. name .."!"))
minetest.sound_play("done", player)
end
end
end
})
]]--