Back to scripts
JS

heal_command.js

JavaScript · 31 lines · 887 B

scripts/heal_command.js
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
/**
 * Команда /heal - Восстановление здоровья
 */

Commands.register('heal', function(sender, args) {
    if (!sender.isPlayer()) {
        sender.sendMessage('§cТолько для игроков!');
        return;
    }
    
    var player = sender;
    
    // Восстановить здоровье
    player.setHealth(player.getMaxHealth());
    
    // Восстановить голод
    player.setFoodLevel(20);
    player.setSaturation(20.0);
    
    // Убрать эффекты
    player.getActivePotionEffects().forEach(function(effect) {
        player.removePotionEffect(effect.getType());
    });
    
    player.sendMessage('§a✓ Вы полностью исцелены!');
    Console.log(player.getName() + ' used /heal');
    
}, 'scriptslab.heal');

Console.log('Команда /heal зарегистрирована');