UnlockTowerCommand.java 1.23 KB
Newer Older
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
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"},
        description = "Unlock all levels of tower", permission = "player.tower")
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());

        CommandHandler.sendMessage(sender, translate("commands.tower.unlock_done"));
    }

    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)));
    }
}