mirror of
https://github.com/Melledy/LunarCore.git
synced 2025-12-13 13:54:37 +01:00
Update some commands
This commit is contained in:
@@ -35,22 +35,25 @@ public class CommandArgs {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (arg.length() >= 2 && !Character.isDigit(arg.charAt(0)) && Character.isDigit(arg.charAt(arg.length() - 1))) {
|
if (arg.length() >= 2 && !Character.isDigit(arg.charAt(0)) && Character.isDigit(arg.charAt(arg.length() - 1))) {
|
||||||
if (arg.startsWith("@")) {
|
if (arg.startsWith("@")) { // Target UID
|
||||||
this.targetUid = Utils.parseSafeInt(arg.substring(1));
|
this.targetUid = Utils.parseSafeInt(arg.substring(1));
|
||||||
it.remove();
|
it.remove();
|
||||||
} else if (arg.startsWith("x")) {
|
} else if (arg.startsWith("x")) { // Amount
|
||||||
this.amount = Utils.parseSafeInt(arg.substring(1));
|
this.amount = Utils.parseSafeInt(arg.substring(1));
|
||||||
it.remove();
|
it.remove();
|
||||||
} else if (arg.startsWith("lv")) {
|
} else if (arg.startsWith("lv")) { // Level
|
||||||
this.level = Utils.parseSafeInt(arg.substring(2));
|
this.level = Utils.parseSafeInt(arg.substring(2));
|
||||||
it.remove();
|
it.remove();
|
||||||
} else if (arg.startsWith("r")) {
|
} else if (arg.startsWith("r")) { // Rank
|
||||||
this.rank = Utils.parseSafeInt(arg.substring(1));
|
this.rank = Utils.parseSafeInt(arg.substring(1));
|
||||||
it.remove();
|
it.remove();
|
||||||
} else if (arg.startsWith("p")) {
|
} else if (arg.startsWith("e")) { // Eidolons
|
||||||
|
this.rank = Utils.parseSafeInt(arg.substring(1));
|
||||||
|
it.remove();
|
||||||
|
} else if (arg.startsWith("p")) { // Promotion
|
||||||
this.promotion = Utils.parseSafeInt(arg.substring(1));
|
this.promotion = Utils.parseSafeInt(arg.substring(1));
|
||||||
it.remove();
|
it.remove();
|
||||||
} else if (arg.startsWith("s")) {
|
} else if (arg.startsWith("s")) { // Stage or Superimposition
|
||||||
this.stage = Utils.parseSafeInt(arg.substring(1));
|
this.stage = Utils.parseSafeInt(arg.substring(1));
|
||||||
it.remove();
|
it.remove();
|
||||||
}
|
}
|
||||||
@@ -157,6 +160,9 @@ public class CommandArgs {
|
|||||||
if (this.getRank() >= 0) {
|
if (this.getRank() >= 0) {
|
||||||
item.setRank(Math.min(this.getRank(), item.getExcel().getEquipmentExcel().getMaxRank()));
|
item.setRank(Math.min(this.getRank(), item.getExcel().getEquipmentExcel().getMaxRank()));
|
||||||
hasChanged = true;
|
hasChanged = true;
|
||||||
|
} else if (this.getStage() >= 0) {
|
||||||
|
item.setRank(Math.min(this.getStage(), item.getExcel().getEquipmentExcel().getMaxRank()));
|
||||||
|
hasChanged = true;
|
||||||
}
|
}
|
||||||
} else if (item.getExcel().isRelic()) {
|
} else if (item.getExcel().isRelic()) {
|
||||||
// Try to set level
|
// Try to set level
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import java.util.List;
|
|||||||
|
|
||||||
import emu.lunarcore.command.Command;
|
import emu.lunarcore.command.Command;
|
||||||
import emu.lunarcore.command.CommandArgs;
|
import emu.lunarcore.command.CommandArgs;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import emu.lunarcore.command.CommandHandler;
|
import emu.lunarcore.command.CommandHandler;
|
||||||
import emu.lunarcore.data.GameData;
|
import emu.lunarcore.data.GameData;
|
||||||
import emu.lunarcore.data.excel.ItemExcel;
|
import emu.lunarcore.data.excel.ItemExcel;
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
package emu.lunarcore.command.commands;
|
package emu.lunarcore.command.commands;
|
||||||
|
|
||||||
import emu.lunarcore.LunarCore;
|
|
||||||
import emu.lunarcore.command.Command;
|
import emu.lunarcore.command.Command;
|
||||||
import emu.lunarcore.command.CommandArgs;
|
import emu.lunarcore.command.CommandArgs;
|
||||||
import emu.lunarcore.command.CommandHandler;
|
import emu.lunarcore.command.CommandHandler;
|
||||||
import emu.lunarcore.server.packet.send.PacketSyncLineupNotify;
|
|
||||||
import emu.lunarcore.game.player.lineup.LineupManager;
|
|
||||||
import emu.lunarcore.game.player.lineup.PlayerLineup;
|
import emu.lunarcore.game.player.lineup.PlayerLineup;
|
||||||
import emu.lunarcore.game.player.Player;
|
import emu.lunarcore.game.player.Player;
|
||||||
|
|
||||||
@@ -14,21 +11,20 @@ public class HealCommand implements CommandHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(Player sender, CommandArgs args) {
|
public void execute(Player sender, CommandArgs args) {
|
||||||
|
// Check target
|
||||||
|
if (args.getTarget() == null) {
|
||||||
|
this.sendMessage(sender, "Error: Targeted player not found or offline");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
LineupManager lineupManager = sender.getLineupManager();
|
PlayerLineup lineup = args.getTarget().getCurrentLineup();
|
||||||
PlayerLineup lineup = lineupManager.getLineupByIndex(lineupManager.getCurrentIndex());
|
|
||||||
|
|
||||||
lineup.forEachAvatar(avatar -> {
|
lineup.forEachAvatar(avatar -> {
|
||||||
avatar.setCurrentHp(lineup, 10000);
|
avatar.setCurrentHp(lineup, 10000);
|
||||||
avatar.save();
|
avatar.save();
|
||||||
});
|
});
|
||||||
|
lineup.refreshLineup();
|
||||||
|
|
||||||
lineup.save();
|
this.sendMessage(sender, "Healed all avatars for " + args.getTarget().getName());
|
||||||
|
|
||||||
sender.getScene().syncLineup();
|
|
||||||
sender.sendPacket(new PacketSyncLineupNotify(lineup));
|
|
||||||
|
|
||||||
this.sendMessage(sender, "Healed all avatars.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,24 @@
|
|||||||
package emu.lunarcore.command.commands;
|
package emu.lunarcore.command.commands;
|
||||||
|
|
||||||
import emu.lunarcore.LunarCore;
|
|
||||||
import emu.lunarcore.GameConstants;
|
import emu.lunarcore.GameConstants;
|
||||||
import emu.lunarcore.command.Command;
|
import emu.lunarcore.command.Command;
|
||||||
import emu.lunarcore.command.CommandArgs;
|
import emu.lunarcore.command.CommandArgs;
|
||||||
import emu.lunarcore.command.CommandHandler;
|
import emu.lunarcore.command.CommandHandler;
|
||||||
import emu.lunarcore.game.player.Player;
|
import emu.lunarcore.game.player.Player;
|
||||||
import emu.lunarcore.game.player.lineup.PlayerLineup;
|
|
||||||
|
|
||||||
@Command(label = "refill", aliases = {"rf"}, permission = "player.refill", desc = "/refill - refill your skill points in open world.")
|
@Command(label = "refill", aliases = {"rf"}, permission = "player.refill", desc = "/refill - refill your skill points in open world.")
|
||||||
public class RefillMPCommand implements CommandHandler {
|
public class RefillMPCommand implements CommandHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(Player sender, CommandArgs args) {
|
public void execute(Player sender, CommandArgs args) {
|
||||||
PlayerLineup lineup = sender.getCurrentLineup();
|
// Check target
|
||||||
lineup.addMp(GameConstants.MAX_MP);
|
if (args.getTarget() == null) {
|
||||||
this.sendMessage(sender, "Successfully refilled skill points.");
|
this.sendMessage(sender, "Error: Targeted player not found or offline");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.getCurrentLineup().addMp(GameConstants.MAX_MP);
|
||||||
|
this.sendMessage(sender, "Successfully refilled skill points for " + args.getTarget().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
package emu.lunarcore.command.commands;
|
package emu.lunarcore.command.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import emu.lunarcore.command.Command;
|
import emu.lunarcore.command.Command;
|
||||||
import emu.lunarcore.game.avatar.GameAvatar;
|
|
||||||
import emu.lunarcore.game.player.lineup.PlayerLineup;
|
import emu.lunarcore.game.player.lineup.PlayerLineup;
|
||||||
import emu.lunarcore.command.CommandArgs;
|
import emu.lunarcore.command.CommandArgs;
|
||||||
import emu.lunarcore.command.CommandHandler;
|
import emu.lunarcore.command.CommandHandler;
|
||||||
@@ -15,18 +11,20 @@ public class RefillSPCommand implements CommandHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(Player sender, CommandArgs args) {
|
public void execute(Player sender, CommandArgs args) {
|
||||||
|
// Check target
|
||||||
|
if (args.getTarget() == null) {
|
||||||
|
this.sendMessage(sender, "Error: Targeted player not found or offline");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
PlayerLineup lineup = sender.getCurrentLineup();
|
PlayerLineup lineup = args.getTarget().getCurrentLineup();
|
||||||
for (int i = 0; i < lineup.getAvatars().size(); i++) {
|
lineup.forEachAvatar(avatar -> {
|
||||||
GameAvatar avatar = sender.getAvatarById(lineup.getAvatars().get(i));
|
|
||||||
if (avatar == null) continue;
|
|
||||||
avatar.setCurrentSp(lineup, 10000);
|
avatar.setCurrentSp(lineup, 10000);
|
||||||
avatar.save();
|
avatar.save();
|
||||||
}
|
});
|
||||||
lineup.save();
|
|
||||||
|
|
||||||
lineup.refreshLineup();
|
lineup.refreshLineup();
|
||||||
this.sendMessage(sender, "Refilled SP");
|
|
||||||
|
this.sendMessage(sender, "Refilled SP for " + args.getTarget().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,26 @@
|
|||||||
package emu.lunarcore.command.commands;
|
package emu.lunarcore.command.commands;
|
||||||
|
|
||||||
import emu.lunarcore.util.Utils;
|
import emu.lunarcore.util.Utils;
|
||||||
import emu.lunarcore.LunarCore;
|
|
||||||
import emu.lunarcore.GameConstants;
|
|
||||||
import emu.lunarcore.command.Command;
|
import emu.lunarcore.command.Command;
|
||||||
import emu.lunarcore.command.CommandArgs;
|
import emu.lunarcore.command.CommandArgs;
|
||||||
import emu.lunarcore.command.CommandHandler;
|
import emu.lunarcore.command.CommandHandler;
|
||||||
import emu.lunarcore.game.player.Player;
|
import emu.lunarcore.game.player.Player;
|
||||||
|
|
||||||
@Command(label = "setlevel", aliases = {"level"}, permission = "player.setlevel", desc = "/setlevel - Set your Equilibrium level.")
|
@Command(label = "setlevel", aliases = {"level"}, permission = "player.setlevel", desc = "/setlevel [level] - Sets the targeted player's trailblazer level.")
|
||||||
public class SetLevelCommand implements CommandHandler {
|
public class SetLevelCommand implements CommandHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(Player sender, CommandArgs args) {
|
public void execute(Player sender, CommandArgs args) {
|
||||||
|
// Check target
|
||||||
|
if (args.getTarget() == null) {
|
||||||
|
this.sendMessage(sender, "Error: Targeted player not found or offline");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int targetLevel = Utils.parseSafeInt(args.get(0));
|
int targetLevel = Utils.parseSafeInt(args.get(0));
|
||||||
sender.setLevel(targetLevel);
|
args.getTarget().setLevel(targetLevel);
|
||||||
|
|
||||||
this.sendMessage(sender, "Set level to "+args.get(0));
|
this.sendMessage(sender, "Set level to " + targetLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ public class Player {
|
|||||||
@Setter private PlayerGender gender;
|
@Setter private PlayerGender gender;
|
||||||
|
|
||||||
private int level;
|
private int level;
|
||||||
private int exp;
|
private int exp; // Total exp
|
||||||
private int worldLevel;
|
private int worldLevel;
|
||||||
private int scoin; // Credits
|
private int scoin; // Credits
|
||||||
private int hcoin; // Jade
|
private int hcoin; // Jade
|
||||||
@@ -190,11 +190,8 @@ public class Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setLevel(int newLevel) {
|
public void setLevel(int newLevel) {
|
||||||
if (newLevel >= 71) {
|
this.level = Math.max(Math.min(newLevel, GameConstants.MAX_TRAILBLAZER_LEVEL), 1);
|
||||||
newLevel = 70;
|
this.exp = GameData.getPlayerExpRequired(this.level);
|
||||||
}
|
|
||||||
this.level = (newLevel);
|
|
||||||
this.exp = 0;
|
|
||||||
this.sendPacket(new PacketPlayerSyncScNotify(this));
|
this.sendPacket(new PacketPlayerSyncScNotify(this));
|
||||||
this.save();
|
this.save();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user