UnlockTowerCommand.java 1.24 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
package emu.grasscutter.command.commands;

import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.game.tower.TowerLevelRecord;

import java.util.List;

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

@Command(label = "unlocktower", usage = "unlocktower", aliases = {"ut"},
13
        description = "commands.unlocktower.description", permission = "player.tower")
14
15
16
17
18
19
20
21
22
23
public class UnlockTowerCommand implements CommandHandler {

    @Override
    public void execute(Player sender, Player targetPlayer, List<String> args) {
        unlockFloor(sender, sender.getServer().getTowerScheduleManager()
                .getCurrentTowerScheduleData().getEntranceFloorId());

        unlockFloor(sender, sender.getServer().getTowerScheduleManager()
                .getScheduleFloors());

24
        CommandHandler.sendMessage(sender, translate("commands.unlocktower.success"));
25
26
27
28
29
30
31
32
    }

    public void unlockFloor(Player player, List<Integer> floors){
        floors.stream()
                .filter(id -> !player.getTowerManager().getRecordMap().containsKey(id))
                .forEach(id -> player.getTowerManager().getRecordMap().put(id, new TowerLevelRecord(id)));
    }
}