2022-07-23 00:26:00 +08:00
|
|
|
package emu.grasscutter.command.commands;
|
|
|
|
|
|
|
|
import emu.grasscutter.command.Command;
|
|
|
|
import emu.grasscutter.command.CommandHandler;
|
2022-07-24 15:12:07 +08:00
|
|
|
import emu.grasscutter.data.GameData;
|
2022-07-23 00:26:00 +08:00
|
|
|
import emu.grasscutter.game.player.Player;
|
2022-08-10 18:03:47 +08:00
|
|
|
import emu.grasscutter.game.player.PlayerProgressManager;
|
2022-07-23 00:26:00 +08:00
|
|
|
import emu.grasscutter.server.packet.send.PacketOpenStateChangeNotify;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import static emu.grasscutter.utils.Language.translate;
|
|
|
|
|
|
|
|
@Command(label = "unlockall", usage = {""}, permission = "player.unlockall", permissionTargeted = "player.unlockall.others")
|
|
|
|
public final class UnlockAllCommand implements CommandHandler {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void execute(Player sender, Player targetPlayer, List<String> args) {
|
|
|
|
Map<Integer, Integer> changed = new HashMap<>();
|
2022-07-24 15:12:07 +08:00
|
|
|
|
|
|
|
for (var state : GameData.getOpenStateList()) {
|
|
|
|
// Don't unlock blacklisted open states.
|
2022-08-10 18:03:47 +08:00
|
|
|
if (PlayerProgressManager.BLACKLIST_OPEN_STATES.contains(state.getId())) {
|
2022-07-24 15:12:07 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2022-08-10 18:03:47 +08:00
|
|
|
if (targetPlayer.getProgressManager().getOpenState(state.getId()) == 0) {
|
2022-08-21 19:33:54 +08:00
|
|
|
targetPlayer.getOpenStates().put(state.getId(), 1);
|
2022-07-24 15:12:07 +08:00
|
|
|
changed.put(state.getId(), 1);
|
2022-07-23 00:26:00 +08:00
|
|
|
}
|
|
|
|
}
|
2022-08-21 19:33:54 +08:00
|
|
|
|
2022-07-23 00:26:00 +08:00
|
|
|
targetPlayer.sendPacket(new PacketOpenStateChangeNotify(changed));
|
2022-08-21 19:33:54 +08:00
|
|
|
|
2022-07-23 00:26:00 +08:00
|
|
|
CommandHandler.sendMessage(sender, translate(sender, "commands.unlockall.success", targetPlayer.getNickname()));
|
|
|
|
}
|
|
|
|
}
|