mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2026-05-18 05:39:56 +08:00
ecf028d0c6
* Fix the following issues: 1. HashMap non-thread-safe issus 2. Fix the same problem in pr621, but use a better implementation Add the following functions: 1. There is now a language cache inside getLanguage to prepare for different languages corresponding to different time zones where the accounts in the server are located * add /language command,each account has their own Locate
47 lines
1.7 KiB
Java
47 lines
1.7 KiB
Java
package emu.grasscutter.command.commands;
|
|
|
|
import emu.grasscutter.command.Command;
|
|
import emu.grasscutter.command.CommandHandler;
|
|
import emu.grasscutter.game.avatar.Avatar;
|
|
import emu.grasscutter.game.entity.EntityAvatar;
|
|
import emu.grasscutter.game.player.Player;
|
|
|
|
import java.util.List;
|
|
|
|
import static emu.grasscutter.utils.Language.translate;
|
|
|
|
@Command(label = "resetconst", usage = "resetconst [all]",
|
|
aliases = {"resetconstellation"}, permission = "player.resetconstellation", permissionTargeted = "player.resetconstellation.others", description = "commands.resetConst.description")
|
|
public final class ResetConstCommand implements CommandHandler {
|
|
|
|
@Override
|
|
public void execute(Player sender, Player targetPlayer, List<String> args) {
|
|
if (targetPlayer == null) {
|
|
CommandHandler.sendMessage(sender, translate(sender, "commands.execution.need_target"));
|
|
return;
|
|
}
|
|
|
|
if (args.size() > 0 && args.get(0).equalsIgnoreCase("all")) {
|
|
targetPlayer.getAvatars().forEach(this::resetConstellation);
|
|
CommandHandler.sendMessage(sender, translate(sender, "commands.resetConst.reset_all"));
|
|
} else {
|
|
EntityAvatar entity = targetPlayer.getTeamManager().getCurrentAvatarEntity();
|
|
if (entity == null) {
|
|
return;
|
|
}
|
|
|
|
Avatar avatar = entity.getAvatar();
|
|
this.resetConstellation(avatar);
|
|
|
|
CommandHandler.sendMessage(sender, translate(sender, "commands.resetConst.success", avatar.getAvatarData().getName()));
|
|
}
|
|
}
|
|
|
|
private void resetConstellation(Avatar avatar) {
|
|
avatar.getTalentIdList().clear();
|
|
avatar.setCoreProudSkillLevel(0);
|
|
avatar.recalcStats();
|
|
avatar.save();
|
|
}
|
|
}
|