Files
prestonbane/src/engine/devcmd/cmds/SetPromotionClassCmd.java
T

73 lines
2.3 KiB
Java
Raw Normal View History

2022-04-30 09:41:17 -04:00
package engine.devcmd.cmds;
import engine.Enum.DispatchChannel;
import engine.InterestManagement.InterestManager;
import engine.devcmd.AbstractDevCmd;
import engine.gameManager.ChatManager;
import engine.net.DispatchMessage;
import engine.net.client.msg.ApplyRuneMsg;
import engine.objects.AbstractGameObject;
import engine.objects.PlayerCharacter;
import engine.objects.PromotionClass;
import engine.server.MBServerStatics;
public class SetPromotionClassCmd extends AbstractDevCmd {
2023-07-15 09:23:48 -04:00
public SetPromotionClassCmd() {
2022-04-30 09:41:17 -04:00
super("setPromotionClass");
}
2023-07-15 09:23:48 -04:00
@Override
protected void _doCmd(PlayerCharacter pc, String[] words,
AbstractGameObject target) {
// Arg Count Check
if (words.length != 1) {
this.sendUsage(pc);
return;
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
int classID = 0;
try {
classID = Integer.parseInt(words[0]);
} catch (Exception e) {
throwbackError(pc,
"Invalid setPromotionClass Command. must specify an ID between 2504 and 2526.");
return;
}
if (classID < 2504 || classID > 2526 || classID == 2522) {
throwbackError(pc,
"Invalid setPromotionClass Command. must specify an ID between 2504 and 2526.");
return;
}
pc.setPromotionClass(classID);
ChatManager.chatSayInfo(pc,
"PromotionClass changed to " + classID);
InterestManager.reloadCharacter(pc);
this.setTarget(pc); //for logging
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
// recalculate all bonuses/formulas/skills/powers
pc.recalculate();
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
// send the rune application to the clients
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
PromotionClass promo = pc.getPromotionClass();
if (promo != null) {
ApplyRuneMsg arm = new ApplyRuneMsg(pc.getObjectType().ordinal(), pc.getObjectUUID(), promo.getObjectUUID(), promo.getObjectType().ordinal(), promo.getObjectUUID(), true);
DispatchMessage.dispatchMsgToInterestArea(pc, arm, DispatchChannel.SECONDARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
@Override
protected String _getHelpString() {
return "Sets your character's PromotionClass to 'ID'";
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
@Override
protected String _getUsageString() {
return "' /setPromotionClass id'";
}
2022-04-30 09:41:17 -04:00
}