mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-15 08:25:21 +01:00
Extend give command "skill level" & shortening /talent all (#1865)
* Extend give command "talent" * Update src/main/java/emu/grasscutter/data/excels/AvatarSkillDepotData.java Shorten IntStream for getCombatSkills Co-authored-by: Luke H-W <Birdulon@users.noreply.github.com> * Fix setSkillLevel to work during avatar construction Shortening getCombatSkills * changeSkillLevel now acts as intermediate operation to fetch skillIds * setSkillLevel changes to allow out of range levels to be normalized * Update src/main/java/emu/grasscutter/command/commands/GiveCommand.java Removing recalcStats since it's redundant Co-authored-by: Luke H-W <Birdulon@users.noreply.github.com> * Major changes and cleanup: - AvatarSkillDepotData: removed getCombatSkills since it's unused - TalentCommand: shortened /talent all using getSkillsAndEnergySkill - GiveCommand: changed changeSkillLevel to setSkillLevel - Avatar: delete changeSkillLevel and moved the operation inside setSkillLevel,updated skillId to Integer to catch special cases from GiveCommand * Small cleanup: Removed the special case from Avatar to be handled inside of GiveCommand Co-authored-by: Luke H-W <Birdulon@users.noreply.github.com>
This commit is contained in:
@@ -750,14 +750,16 @@ public class Avatar {
|
||||
if (level < 0 || level > 15) return false;
|
||||
var validLevels = GameData.getAvatarSkillLevels(skillId);
|
||||
if (validLevels != null && !validLevels.contains(level)) return false;
|
||||
|
||||
int oldLevel = this.skillLevelMap.getOrDefault(skillId, 0); // just taking the return value of put would have null concerns
|
||||
this.skillLevelMap.put(skillId, level);
|
||||
this.save();
|
||||
|
||||
// Packet
|
||||
this.getPlayer().sendPacket(new PacketAvatarSkillChangeNotify(this, skillId, oldLevel, level));
|
||||
this.getPlayer().sendPacket(new PacketAvatarSkillUpgradeRsp(this, skillId, oldLevel, level));
|
||||
val player = this.getPlayer();
|
||||
if (player != null) {
|
||||
player.sendPacket(new PacketAvatarSkillChangeNotify(this, skillId, oldLevel, level));
|
||||
player.sendPacket(new PacketAvatarSkillUpgradeRsp(this, skillId, oldLevel, level));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user