ResetConstCommand.java 1.45 KB
Newer Older
KingRainbow44's avatar
KingRainbow44 committed
1
2
3
4
package emu.grasscutter.command.commands;

import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler;
5
import emu.grasscutter.game.avatar.Avatar;
KingRainbow44's avatar
KingRainbow44 committed
6
import emu.grasscutter.game.entity.EntityAvatar;
Melledy's avatar
Melledy committed
7
import emu.grasscutter.game.player.Player;
KingRainbow44's avatar
KingRainbow44 committed
8
9
10

import java.util.List;

11
12
import static emu.grasscutter.utils.Language.translate;

13
14
15
16
17
18
@Command(
    label = "resetConst",
    aliases = {"resetconstellation"},
    usage = "[all]",
    permission = "player.resetconstellation",
    permissionTargeted = "player.resetconstellation.others")
KingRainbow44's avatar
KingRainbow44 committed
19
20
21
public final class ResetConstCommand implements CommandHandler {

    @Override
AnimeGitB's avatar
AnimeGitB committed
22
    public void execute(Player sender, Player targetPlayer, List<String> args) {
KingRainbow44's avatar
KingRainbow44 committed
23
        if (args.size() > 0 && args.get(0).equalsIgnoreCase("all")) {
AnimeGitB's avatar
AnimeGitB committed
24
            targetPlayer.getAvatars().forEach(this::resetConstellation);
Secretboy's avatar
Secretboy committed
25
            CommandHandler.sendMessage(sender, translate(sender, "commands.resetConst.reset_all"));
KingRainbow44's avatar
KingRainbow44 committed
26
        } else {
AnimeGitB's avatar
AnimeGitB committed
27
            EntityAvatar entity = targetPlayer.getTeamManager().getCurrentAvatarEntity();
KingRainbow44's avatar
KingRainbow44 committed
28
29
30
31
            if (entity == null) {
                return;
            }

32
            Avatar avatar = entity.getAvatar();
KingRainbow44's avatar
KingRainbow44 committed
33
34
            this.resetConstellation(avatar);

Secretboy's avatar
Secretboy committed
35
            CommandHandler.sendMessage(sender, translate(sender, "commands.resetConst.success", avatar.getAvatarData().getName()));
KingRainbow44's avatar
KingRainbow44 committed
36
37
38
        }
    }

39
    private void resetConstellation(Avatar avatar) {
40
        avatar.forceConstellationLevel(-1);
KingRainbow44's avatar
KingRainbow44 committed
41
    }
Secretboy's avatar
Secretboy committed
42
}