mirror of
https://github.com/Zrips/Jobs.git
synced 2025-01-02 14:29:07 +01:00
Fix for jobs info command with provided action and page
This commit is contained in:
parent
3f9206b389
commit
7320c1a349
@ -25,6 +25,7 @@ import com.gamingmesh.jobs.stuff.Util;
|
|||||||
|
|
||||||
import net.Zrips.CMILib.ActionBar.CMIActionBar;
|
import net.Zrips.CMILib.ActionBar.CMIActionBar;
|
||||||
import net.Zrips.CMILib.Container.PageInfo;
|
import net.Zrips.CMILib.Container.PageInfo;
|
||||||
|
import net.Zrips.CMILib.Logs.CMIDebug;
|
||||||
import net.Zrips.CMILib.RawMessages.RawMessage;
|
import net.Zrips.CMILib.RawMessages.RawMessage;
|
||||||
|
|
||||||
public class JobsCommands implements CommandExecutor {
|
public class JobsCommands implements CommandExecutor {
|
||||||
@ -235,14 +236,6 @@ public class JobsCommands implements CommandExecutor {
|
|||||||
|
|
||||||
List<String> message = new ArrayList<>();
|
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)
|
if (job.getBoost().get(CurrencyType.EXP) != 0D)
|
||||||
message.add(Jobs.getLanguage().getMessage("command.expboost.output.infostats", "%boost%", (job.getBoost().get(CurrencyType.EXP)) + 1));
|
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()) {
|
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);
|
List<JobInfo> info = job.getJobInfo(actionType);
|
||||||
|
|
||||||
if (info != null && !info.isEmpty()) {
|
if (info != null && !info.isEmpty()) {
|
||||||
String m = jobInfoMessage(player, job, actionType);
|
String m = jobInfoMessage(player, job, actionType);
|
||||||
|
|
||||||
if (m.contains("\n"))
|
if (m.contains("\n"))
|
||||||
message.addAll(Arrays.asList(m.split("\n")));
|
message.addAll(Arrays.asList(m.split("\n")));
|
||||||
else
|
else
|
||||||
message.add(m);
|
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);
|
sender.sendMessage(one);
|
||||||
}
|
}
|
||||||
|
|
||||||
String t = type.isEmpty() ? "" : " " + type;
|
|
||||||
|
|
||||||
if (isPlayer) {
|
if (isPlayer) {
|
||||||
|
String t = type.isEmpty() ? "" : " " + type;
|
||||||
String pName = player.getName();
|
String pName = player.getName();
|
||||||
|
|
||||||
if (sender.getName().equalsIgnoreCase(pName))
|
if (sender.getName().equalsIgnoreCase(pName))
|
||||||
|
@ -5,6 +5,7 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import com.gamingmesh.jobs.Jobs;
|
import com.gamingmesh.jobs.Jobs;
|
||||||
import com.gamingmesh.jobs.commands.Cmd;
|
import com.gamingmesh.jobs.commands.Cmd;
|
||||||
|
import com.gamingmesh.jobs.container.ActionType;
|
||||||
import com.gamingmesh.jobs.container.Job;
|
import com.gamingmesh.jobs.container.Job;
|
||||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||||
|
|
||||||
@ -12,6 +13,7 @@ public class info implements Cmd {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
|
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
|
||||||
|
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.ingame"));
|
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.ingame"));
|
||||||
return false;
|
return false;
|
||||||
@ -47,12 +49,20 @@ public class info implements Cmd {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int page = 1;
|
int page = 1;
|
||||||
String type = "";
|
String type = null;
|
||||||
if (args.length >= 2) {
|
|
||||||
|
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 {
|
try {
|
||||||
page = Integer.parseInt(args[1]);
|
page = Integer.parseInt(args[i]);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
type = args[1];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user