1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-30 21:07:48 +01:00

Fix for jobs info command with provided action and page

This commit is contained in:
Zrips 2021-10-26 16:32:39 +03:00
parent 3f9206b389
commit 7320c1a349
2 changed files with 21 additions and 21 deletions

View File

@ -25,6 +25,7 @@ import com.gamingmesh.jobs.stuff.Util;
import net.Zrips.CMILib.ActionBar.CMIActionBar;
import net.Zrips.CMILib.Container.PageInfo;
import net.Zrips.CMILib.Logs.CMIDebug;
import net.Zrips.CMILib.RawMessages.RawMessage;
public class JobsCommands implements CommandExecutor {
@ -235,14 +236,6 @@ public class JobsCommands implements CommandExecutor {
List<String> message = new ArrayList<>();
int showAllTypes = 1;
for (ActionType actionType : ActionType.values()) {
if (type.startsWith(actionType.getName().toLowerCase())) {
showAllTypes = 0;
break;
}
}
if (job.getBoost().get(CurrencyType.EXP) != 0D)
message.add(Jobs.getLanguage().getMessage("command.expboost.output.infostats", "%boost%", (job.getBoost().get(CurrencyType.EXP)) + 1));
@ -264,21 +257,19 @@ public class JobsCommands implements CommandExecutor {
}
for (ActionType actionType : ActionType.values()) {
if (showAllTypes == 1 || type.startsWith(actionType.getName().toLowerCase())) {
if (!type.isEmpty() && type.startsWith(actionType.getName().toLowerCase())) {
List<JobInfo> info = job.getJobInfo(actionType);
if (info != null && !info.isEmpty()) {
String m = jobInfoMessage(player, job, actionType);
if (m.contains("\n"))
message.addAll(Arrays.asList(m.split("\n")));
else
message.add(m);
} else if (showAllTypes == 0) {
String myMessage = Jobs.getLanguage().getMessage("command.info.output." + actionType.getName().toLowerCase() + ".none");
myMessage = myMessage.replace("%jobname%", job.getJobDisplayName());
message.add(myMessage);
}
} else if (type.isEmpty()) {
String myMessage = Jobs.getLanguage().getMessage("command.info.output." + actionType.getName().toLowerCase() + ".none");
myMessage = myMessage.replace("%jobname%", job.getJobDisplayName());
message.add(myMessage);
}
}
@ -298,9 +289,8 @@ public class JobsCommands implements CommandExecutor {
sender.sendMessage(one);
}
String t = type.isEmpty() ? "" : " " + type;
if (isPlayer) {
String t = type.isEmpty() ? "" : " " + type;
String pName = player.getName();
if (sender.getName().equalsIgnoreCase(pName))

View File

@ -5,6 +5,7 @@ import org.bukkit.entity.Player;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.ActionType;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer;
@ -12,6 +13,7 @@ public class info implements Cmd {
@Override
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.ingame"));
return false;
@ -47,12 +49,20 @@ public class info implements Cmd {
}
int page = 1;
String type = "";
if (args.length >= 2) {
String type = null;
for (int i = 1; i < args.length; i++) {
String one = args[i];
if (type == null) {
ActionType t = ActionType.getByName(one);
if (t != null) {
type = t.getName();
continue;
}
}
try {
page = Integer.parseInt(args[1]);
page = Integer.parseInt(args[i]);
} catch (NumberFormatException e) {
type = args[1];
}
}