SetStats.java 13.3 KB
Newer Older
Jaida Wu's avatar
Jaida Wu committed
1
2
3
4
5
6
7
8
9
10
11
package emu.grasscutter.command.commands;

import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.GenshinPlayer;
import emu.grasscutter.game.entity.EntityAvatar;
import emu.grasscutter.game.props.FightProperty;
import emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify;

import java.util.List;

alt3ri's avatar
alt3ri committed
12
@Command(label = "setstats", usage = "setstats|stats <stat> <value>",
Jaida Wu's avatar
Jaida Wu committed
13
14
15
16
        aliases = {"stats"})
public class SetStats implements CommandHandler {

    @Override
KingRainbow44's avatar
KingRainbow44 committed
17
    public void execute(GenshinPlayer sender, List<String> args) {
Jaida Wu's avatar
Jaida Wu committed
18
19
20
21
22
23
24
25
        if (sender == null) {
            CommandHandler.sendMessage(null, "Run this command in-game.");
            return;
        }

        String stat = args.get(0);
        switch (stat) {
            default:
alt3ri's avatar
alt3ri committed
26
27
                CommandHandler.sendMessage(sender, "Usage: /setstats|stats <hp | def | atk | em | er | crate | cdmg> <value> for basic stats");
                CommandHandler.sendMessage(sender, "Usage: /stats <epyro | ecryo | ehydro | egeo | edend | eelec | ephys> <amount> for elemental bonus");
Jaida Wu's avatar
Jaida Wu committed
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
                return;
            case "hp":
                try {
                    int health = Integer.parseInt(args.get(1));
                    EntityAvatar entity = sender.getTeamManager().getCurrentAvatarEntity();
                    entity.setFightProperty(FightProperty.FIGHT_PROP_CUR_HP, health);
                    entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_CUR_HP));
                    CommandHandler.sendMessage(sender, "HP set to " + health + ".");
                } catch (NumberFormatException ignored) {
                    CommandHandler.sendMessage(sender, "Invalid HP value.");
                    return;
                }
                break;
            case "def":
                try {
                    int def = Integer.parseInt(args.get(1));
                    EntityAvatar entity = sender.getTeamManager().getCurrentAvatarEntity();
                    entity.setFightProperty(FightProperty.FIGHT_PROP_CUR_DEFENSE, def);
                    entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_CUR_DEFENSE));
                    CommandHandler.sendMessage(sender, "DEF set to " + def + ".");
                } catch (NumberFormatException ignored) {
                    CommandHandler.sendMessage(sender, "Invalid DEF value.");
                    return;
                }
                break;
            case "atk":
                try {
                    int atk = Integer.parseInt(args.get(1));
                    EntityAvatar entity = sender.getTeamManager().getCurrentAvatarEntity();
                    entity.setFightProperty(FightProperty.FIGHT_PROP_CUR_ATTACK, atk);
                    entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_CUR_ATTACK));
                    CommandHandler.sendMessage(sender, "ATK set to " + atk + ".");
                } catch (NumberFormatException ignored) {
                    CommandHandler.sendMessage(sender, "Invalid ATK value.");
                    return;
                }
                break;
            case "em":
                try {
                    int em = Integer.parseInt(args.get(1));
                    EntityAvatar entity = sender.getTeamManager().getCurrentAvatarEntity();
                    entity.setFightProperty(FightProperty.FIGHT_PROP_ELEMENT_MASTERY, em);
                    entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_ELEMENT_MASTERY));
                    CommandHandler.sendMessage(sender, "Elemental Mastery set to " + em + ".");
                } catch (NumberFormatException ignored) {
                    CommandHandler.sendMessage(sender, "Invalid EM value.");
                    return;
                }
                break;
            case "er":
                try {
                    float er = Integer.parseInt(args.get(1));
                    EntityAvatar entity = sender.getTeamManager().getCurrentAvatarEntity();
                    float erecharge = er / 10000;
                    entity.setFightProperty(FightProperty.FIGHT_PROP_CHARGE_EFFICIENCY, erecharge);
                    entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_CHARGE_EFFICIENCY));
                    float iger = erecharge * 100;
                    CommandHandler.sendMessage(sender, "Energy recharge set to " + iger + "%.");
                } catch (NumberFormatException ignored) {
                    CommandHandler.sendMessage(sender, "Invalid ER value.");
                    return;
                }
                break;
            case "crate":
                try {
                    float cr = Integer.parseInt(args.get(1));
                    EntityAvatar entity = sender.getTeamManager().getCurrentAvatarEntity();
                    float crate = cr / 10000;
                    entity.setFightProperty(FightProperty.FIGHT_PROP_CRITICAL, crate);
                    entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_CRITICAL));
                    float igcrate = crate * 100;
                    CommandHandler.sendMessage(sender, "Crit Rate set to " + igcrate + "%.");
                } catch (NumberFormatException ignored) {
                    CommandHandler.sendMessage(sender, "Invalid Crit Rate value.");
                    return;
                }
                break;
            case "cdmg":
                try {
                    float cdmg = Integer.parseInt(args.get(1));
                    EntityAvatar entity = sender.getTeamManager().getCurrentAvatarEntity();
                    float cdamage = cdmg / 10000;
                    entity.setFightProperty(FightProperty.FIGHT_PROP_CRITICAL_HURT, cdamage);
                    entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_CRITICAL_HURT));
                    float igcdmg = cdamage * 100;
                    CommandHandler.sendMessage(sender, "Crit DMG set to " + igcdmg + "%");
                } catch (NumberFormatException ignored) {
                    CommandHandler.sendMessage(sender, "Invalid Crit DMG value.");
                    return;
                }
                break;
alt3ri's avatar
alt3ri committed
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
            case "epyro":
                try {
                    float epyro = Integer.parseInt(args.get(1));
                    EntityAvatar entity = sender.getTeamManager().getCurrentAvatarEntity();
                    float pyro = epyro / 10000;
                    entity.setFightProperty(FightProperty.FIGHT_PROP_FIRE_ADD_HURT, pyro);
                    entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_FIRE_ADD_HURT));
                    float igpyro = pyro * 100;
                    CommandHandler.sendMessage(sender, "Pyro DMG Bonus set to " + igpyro + "%");
                } catch (NumberFormatException ignored) {
                    CommandHandler.sendMessage(sender, "Invalid Pyro DMG Bonus value.");
                    return;
                }
                break;
            case "ecryo":
                try {
                    float ecryo = Integer.parseInt(args.get(1));
                    EntityAvatar entity = sender.getTeamManager().getCurrentAvatarEntity();
                    float cryo = ecryo / 10000;
                    entity.setFightProperty(FightProperty.FIGHT_PROP_ICE_ADD_HURT, cryo);
                    entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_ICE_ADD_HURT));
                    float igcyro = cryo * 100;
                    CommandHandler.sendMessage(sender, "Cyro DMG Bonus set to " + igcyro + "%");
                } catch (NumberFormatException ignored) {
                    CommandHandler.sendMessage(sender, "Invalid Cryo DMG Bonus value.");
                    return;
                }
                break;
            case "ehydro":
                try {
                    float ehydro = Integer.parseInt(args.get(1));
                    EntityAvatar entity = sender.getTeamManager().getCurrentAvatarEntity();
                    float hydro = ehydro / 10000;
                    entity.setFightProperty(FightProperty.FIGHT_PROP_WATER_ADD_HURT, hydro);
                    entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_WATER_ADD_HURT));
                    float ighydro = hydro * 100;
                    CommandHandler.sendMessage(sender, "Hydro DMG Bonus set to " + ighydro + "%");
                } catch (NumberFormatException ignored) {
                    CommandHandler.sendMessage(sender, "Invalid Hydro DMG Bonus value.");
                    return;
                }
                break;
            case "eanemo":
                try {
                    float eanemo = Integer.parseInt(args.get(1));
                    EntityAvatar entity = sender.getTeamManager().getCurrentAvatarEntity();
                    float anemo = eanemo / 10000;
                    entity.setFightProperty(FightProperty.FIGHT_PROP_WIND_ADD_HURT, anemo);
                    entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_WIND_ADD_HURT));
                    float iganemo = anemo * 100;
                    CommandHandler.sendMessage(sender, "Anemo DMG Bonus set to " + iganemo + "%");
                } catch (NumberFormatException ignored) {
                    CommandHandler.sendMessage(sender, "Invalid Anemo DMG Bonus value.");
                    return;
                }
                break;
            case "egeo":
                try {
                    float egeo = Integer.parseInt(args.get(1));
                    EntityAvatar entity = sender.getTeamManager().getCurrentAvatarEntity();
                    float geo = egeo / 10000;
                    entity.setFightProperty(FightProperty.FIGHT_PROP_ROCK_ADD_HURT, geo);
                    entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_ROCK_ADD_HURT));
                    float iggeo = geo * 100;
                    CommandHandler.sendMessage(sender, "Geo DMG Bonus set to " + iggeo + "%");
                } catch (NumberFormatException ignored) {
                    CommandHandler.sendMessage(sender, "Invalid Geo DMG Bonus value.");
                    return;
                }
                break;
            case "ethunder":
            case "eelec":
                try {
                    float eelec = Integer.parseInt(args.get(1));
                    EntityAvatar entity = sender.getTeamManager().getCurrentAvatarEntity();
                    float elec = eelec / 10000;
                    entity.setFightProperty(FightProperty.FIGHT_PROP_CRITICAL_HURT, elec);
                    entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_CRITICAL_HURT));
                    float igelec = elec * 100;
                    CommandHandler.sendMessage(sender, "Electro DMG Bonus set to " + igelec + "%");
                } catch (NumberFormatException ignored) {
                    CommandHandler.sendMessage(sender, "Invalid Electro DMG Bonus value.");
                    return;
                }
                break;
            case "ephys":
                try {
                    float ephys = Integer.parseInt(args.get(1));
                    EntityAvatar entity = sender.getTeamManager().getCurrentAvatarEntity();
                    float phys = ephys / 10000;
                    entity.setFightProperty(FightProperty.FIGHT_PROP_PHYSICAL_ADD_HURT, phys);
                    entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_PHYSICAL_ADD_HURT));
                    float igphys = phys * 100;
                    CommandHandler.sendMessage(sender, "Physical DMG Bonus set to " + igphys + "%");
                } catch (NumberFormatException ignored) {
                    CommandHandler.sendMessage(sender, "Invalid Physical DMG Bonus value.");
                    return;
                }
                break;
            case "edend":
                try {
                    float edend = Integer.parseInt(args.get(1));
                    EntityAvatar entity = sender.getTeamManager().getCurrentAvatarEntity();
                    float dend = edend / 10000;
                    entity.setFightProperty(FightProperty.FIGHT_PROP_GRASS_ADD_HURT, dend);
                    entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_GRASS_ADD_HURT));
                    float igdend = dend * 100;
                    CommandHandler.sendMessage(sender, "Dendro DMG Bonus set to " + igdend + "%");
                } catch (NumberFormatException ignored) {
                    CommandHandler.sendMessage(sender, "Invalid Dendro DMG Bonus value.");
                    return;
                }
                break;
Jaida Wu's avatar
Jaida Wu committed
232
233
234
        }
    }
}