2022-05-08 17:11:02 +08:00
|
|
|
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"},
|
2022-05-09 19:05:03 +08:00
|
|
|
description = "commands.unlocktower.description", permission = "player.tower")
|
2022-05-08 17:11:02 +08:00
|
|
|
public class UnlockTowerCommand implements CommandHandler {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void execute(Player sender, Player targetPlayer, List<String> args) {
|
2022-05-22 16:02:11 +08:00
|
|
|
unlockFloor(targetPlayer, targetPlayer.getServer().getTowerScheduleManager()
|
2022-05-08 17:11:02 +08:00
|
|
|
.getCurrentTowerScheduleData().getEntranceFloorId());
|
|
|
|
|
2022-05-22 16:02:11 +08:00
|
|
|
unlockFloor(targetPlayer, targetPlayer.getServer().getTowerScheduleManager()
|
2022-05-08 17:11:02 +08:00
|
|
|
.getScheduleFloors());
|
|
|
|
|
2022-05-10 20:33:45 +08:00
|
|
|
CommandHandler.sendMessage(sender, translate(sender, "commands.unlocktower.success"));
|
2022-05-08 17:11:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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)));
|
|
|
|
}
|
|
|
|
}
|