1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-25 20:16:13 +01:00

Message handling cleanup

This commit is contained in:
Zrips 2023-05-03 13:38:08 +03:00
parent 9b935c53e9
commit e2b9f370af
54 changed files with 1841 additions and 1838 deletions

View File

@ -24,6 +24,7 @@ import com.gamingmesh.jobs.container.JobInfo;
import com.gamingmesh.jobs.container.JobProgression; import com.gamingmesh.jobs.container.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.container.Title; import com.gamingmesh.jobs.container.Title;
import com.gamingmesh.jobs.i18n.Language;
import com.gamingmesh.jobs.stuff.Util; import com.gamingmesh.jobs.stuff.Util;
import net.Zrips.CMILib.ActionBar.CMIActionBar; import net.Zrips.CMILib.ActionBar.CMIActionBar;
@ -267,7 +268,7 @@ public class JobsCommands implements CommandExecutor {
public void jobInfoMessage(CommandSender sender, JobsPlayer player, Job job, String type, int page) { public void jobInfoMessage(CommandSender sender, JobsPlayer player, Job job, String type, int page) {
if (job == null) { if (job == null) {
// job doesn't exist // job doesn't exist
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job")); Language.sendMessage(sender, "general.error.job");
return; return;
} }
@ -316,7 +317,7 @@ public class JobsCommands implements CommandExecutor {
PageInfo pi = new PageInfo(15, message.size(), page); PageInfo pi = new PageInfo(15, message.size(), page);
if (page > pi.getTotalPages()) { if (page > pi.getTotalPages()) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.invalidPage")); Language.sendMessage(sender, "general.info.invalidPage");
return; return;
} }

View File

@ -10,6 +10,7 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.JobProgression; import com.gamingmesh.jobs.container.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.RawMessages.RawMessage; import net.Zrips.CMILib.RawMessages.RawMessage;
@ -17,43 +18,43 @@ public class archive 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) {
JobsPlayer jPlayer = null; JobsPlayer jPlayer = null;
if (args.length >= 1) { if (args.length >= 1) {
if (!Jobs.hasPermission(sender, "jobs.command.admin.archive", true)) { if (!Jobs.hasPermission(sender, "jobs.command.admin.archive", true)) {
return null; return null;
} }
jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]); jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
} else if (sender instanceof Player) { } else if (sender instanceof Player) {
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender); jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
} }
if (jPlayer == null) { if (jPlayer == null) {
if (args.length >= 1) if (args.length >= 1)
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0])); Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args[0]);
return null; return null;
} }
Set<JobProgression> allJobs = jPlayer.getArchivedJobs().getArchivedJobs(); Set<JobProgression> allJobs = jPlayer.getArchivedJobs().getArchivedJobs();
if (allJobs.isEmpty()) { if (allJobs.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.archive.error.nojob")); Language.sendMessage(sender, "command.archive.error.nojob");
return null; return null;
} }
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.toplineseparator", "%playername%", jPlayer.getName(), "%playerdisplayname%", jPlayer.getDisplayName()));
for (JobProgression jobInfo : allJobs) {
RawMessage rm = new RawMessage();
if (jobInfo.canRejoin())
rm.addText(ChatColor.GREEN + "+" + Jobs.getCommandManager().jobStatsMessageArchive(jPlayer, jobInfo))
.addHover(Jobs.getLanguage().getMessage("command.join.rejoin")).addCommand("jobs join " + jobInfo.getJob().getName());
else
rm.addText(ChatColor.RED + "-" + Jobs.getCommandManager().jobStatsMessageArchive(jPlayer, jobInfo))
.addHover(Jobs.getLanguage().getMessage("command.join.error.rejoin", "[time]", jobInfo
.getRejoinTimeMessage()));
rm.show(sender);
}
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator")); Language.sendMessage(sender, "general.info.toplineseparator", "%playername%", jPlayer.getName(), "%playerdisplayname%", jPlayer.getDisplayName());
return true; for (JobProgression jobInfo : allJobs) {
RawMessage rm = new RawMessage();
if (jobInfo.canRejoin())
rm.addText(ChatColor.GREEN + "+" + Jobs.getCommandManager().jobStatsMessageArchive(jPlayer, jobInfo))
.addHover(Jobs.getLanguage().getMessage("command.join.rejoin")).addCommand("jobs join " + jobInfo.getJob().getName());
else
rm.addText(ChatColor.RED + "-" + Jobs.getCommandManager().jobStatsMessageArchive(jPlayer, jobInfo))
.addHover(Jobs.getLanguage().getMessage("command.join.error.rejoin", "[time]", jobInfo
.getRejoinTimeMessage()));
rm.show(sender);
}
Language.sendMessage(sender, "general.info.separator");
return true;
} }
} }

View File

@ -12,6 +12,7 @@ import com.gamingmesh.jobs.config.RestrictedAreaManager;
import com.gamingmesh.jobs.container.CuboidArea; import com.gamingmesh.jobs.container.CuboidArea;
import com.gamingmesh.jobs.container.RestrictedArea; import com.gamingmesh.jobs.container.RestrictedArea;
import com.gamingmesh.jobs.hooks.HookManager; import com.gamingmesh.jobs.hooks.HookManager;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Items.CMIMaterial; import net.Zrips.CMILib.Items.CMIMaterial;
import net.Zrips.CMILib.Locale.LC; import net.Zrips.CMILib.Locale.LC;
@ -21,150 +22,150 @@ public class area 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)) {
CMIMessages.sendMessage(sender, LC.info_Ingame); CMIMessages.sendMessage(sender, LC.info_Ingame);
return false; return false;
} }
Player player = (Player) sender; Player player = (Player) sender;
if (args.length == 3) { if (args.length == 3) {
if (args[0].equalsIgnoreCase("add")) { if (args[0].equalsIgnoreCase("add")) {
if (!Jobs.hasPermission(player, "jobs.area.add", true)) if (!Jobs.hasPermission(player, "jobs.area.add", true))
return true; return true;
double bonus = 0D; double bonus = 0D;
try { try {
bonus = Double.parseDouble(args[2]); bonus = Double.parseDouble(args[2]);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
return false; return false;
} }
boolean wg = false; boolean wg = false;
String name = args[1]; String name = args[1];
if (name.startsWith("wg:")) { if (name.startsWith("wg:")) {
wg = true; wg = true;
name = name.substring("wg:".length(), name.length()); name = name.substring("wg:".length(), name.length());
} }
RestrictedAreaManager ra = Jobs.getRestrictedAreaManager(); RestrictedAreaManager ra = Jobs.getRestrictedAreaManager();
if (ra.isExist(name)) { if (ra.isExist(name)) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.exist")); Language.sendMessage(sender, "command.area.output.exist");
return true; return true;
} }
if (!wg && !Jobs.getSelectionManager().hasPlacedBoth(player)) { if (!wg && !Jobs.getSelectionManager().hasPlacedBoth(player)) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.select", Language.sendMessage(sender, "command.area.output.select",
"%tool%", CMIMaterial.get(Jobs.getGCManager().getSelectionTool()).getName())); "%tool%", CMIMaterial.get(Jobs.getGCManager().getSelectionTool()).getName());
return true; return true;
} }
if (wg && HookManager.getWorldGuardManager() != null) { if (wg && HookManager.getWorldGuardManager() != null) {
com.sk89q.worldguard.protection.regions.ProtectedRegion protectedRegion = HookManager.getWorldGuardManager().getProtectedRegionByName(name); com.sk89q.worldguard.protection.regions.ProtectedRegion protectedRegion = HookManager.getWorldGuardManager().getProtectedRegionByName(name);
if (protectedRegion == null) { if (protectedRegion == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.wgDontExist")); Language.sendMessage(sender, "command.area.output.wgDontExist");
return true; return true;
} }
name = protectedRegion.getId(); name = protectedRegion.getId();
} }
if (!wg) if (!wg)
ra.addNew(new RestrictedArea(name, Jobs.getSelectionManager().getSelectionCuboid(player), bonus), true); ra.addNew(new RestrictedArea(name, Jobs.getSelectionManager().getSelectionCuboid(player), bonus), true);
else else
ra.addNew(new RestrictedArea(name, name, bonus), true); ra.addNew(new RestrictedArea(name, name, bonus), true);
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.addedNew", "%bonus%", bonus)); Language.sendMessage(sender, "command.area.output.addedNew", "%bonus%", bonus);
return true; return true;
} }
} }
if (args.length == 2) { if (args.length == 2) {
if (args[0].equalsIgnoreCase("remove")) { if (args[0].equalsIgnoreCase("remove")) {
if (!Jobs.hasPermission(player, "jobs.area.remove", true)) if (!Jobs.hasPermission(player, "jobs.area.remove", true))
return true; return true;
RestrictedAreaManager ra = Jobs.getRestrictedAreaManager(); RestrictedAreaManager ra = Jobs.getRestrictedAreaManager();
String name = args[1]; String name = args[1];
if (!ra.isExist(name)) { if (!ra.isExist(name)) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.dontExist")); Language.sendMessage(sender, "command.area.output.dontExist");
return true; return true;
} }
ra.remove(name); ra.remove(name);
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.removed", "%name%", name)); Language.sendMessage(sender, "command.area.output.removed", "%name%", name);
return true; return true;
} }
} }
if (args.length == 1 && args[0].equalsIgnoreCase("info")) { if (args.length == 1 && args[0].equalsIgnoreCase("info")) {
List<RestrictedArea> areas = Jobs.getRestrictedAreaManager().getRestrictedAreasByLoc(player.getLocation()); List<RestrictedArea> areas = Jobs.getRestrictedAreaManager().getRestrictedAreasByLoc(player.getLocation());
String msg = ""; String msg = "";
for (RestrictedArea area : areas) { for (RestrictedArea area : areas) {
if (!msg.isEmpty()) if (!msg.isEmpty())
msg += ", "; msg += ", ";
msg += area.getName(); msg += area.getName();
} }
if (msg.isEmpty()) { if (msg.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.noAreasByLoc")); Language.sendMessage(sender, "command.area.output.noAreasByLoc");
return true; return true;
} }
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.areaList", "%list%", msg)); Language.sendMessage(sender, "command.area.output.areaList", "%list%", msg);
return true; return true;
} }
if (args.length == 1 && args[0].equalsIgnoreCase("list")) { if (args.length == 1 && args[0].equalsIgnoreCase("list")) {
java.util.Map<String, RestrictedArea> areas = Jobs.getRestrictedAreaManager().getRestrictedAreas(); java.util.Map<String, RestrictedArea> areas = Jobs.getRestrictedAreaManager().getRestrictedAreas();
if (areas.isEmpty()) { if (areas.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.noAreas")); sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.noAreas"));
return true; return true;
} }
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator")); sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
int i = 0; int i = 0;
for (Entry<String, RestrictedArea> area : areas.entrySet()) { for (Entry<String, RestrictedArea> area : areas.entrySet()) {
i++; i++;
CuboidArea cuboid = area.getValue().getCuboidArea(); CuboidArea cuboid = area.getValue().getCuboidArea();
if (area.getValue().getWgName() == null) { if (area.getValue().getWgName() == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.list", "%number%", i, Language.sendMessage(sender, "command.area.output.list", "%number%", i,
"%areaname%", area.getKey(), "%areaname%", area.getKey(),
"%worldname%", cuboid.getWorld().getName(), "%worldname%", cuboid.getWorld().getName(),
"%x1%", cuboid.getLowLoc().getBlockX(), "%x1%", cuboid.getLowLoc().getBlockX(),
"%y1%", cuboid.getLowLoc().getBlockY(), "%y1%", cuboid.getLowLoc().getBlockY(),
"%z1%", cuboid.getLowLoc().getBlockZ(), "%z1%", cuboid.getLowLoc().getBlockZ(),
"%x2%", cuboid.getHighLoc().getBlockX(), "%x2%", cuboid.getHighLoc().getBlockX(),
"%y2%", cuboid.getHighLoc().getBlockY(), "%y2%", cuboid.getHighLoc().getBlockY(),
"%z2%", cuboid.getHighLoc().getBlockZ(), "%z2%", cuboid.getHighLoc().getBlockZ(),
"%bonus%", area.getValue().getMultiplier())); "%bonus%", area.getValue().getMultiplier());
} else { } else {
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.wgList", "%number%", i, Language.sendMessage(sender, "command.area.output.wgList", "%number%", i,
"%areaname%", area.getKey(), "%areaname%", area.getKey(),
"%bonus%", area.getValue().getMultiplier())); "%bonus%", area.getValue().getMultiplier());
} }
} }
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator")); Language.sendMessage(sender, "general.info.separator");
return true; return true;
} }
if (args.length > 0) { if (args.length > 0) {
if (args[0].equalsIgnoreCase("add")) { if (args[0].equalsIgnoreCase("add")) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.help.addUsage")); Language.sendMessage(sender, "command.area.help.addUsage");
return true; return true;
} }
if (args[0].equalsIgnoreCase("remove")) { if (args[0].equalsIgnoreCase("remove")) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.help.removeUsage")); Language.sendMessage(sender, "command.area.help.removeUsage");
return true; return true;
} }
} }
return false; return false;
} }
} }

View File

@ -21,12 +21,7 @@ public class blockinfo implements Cmd {
public Boolean perform(Jobs plugin, CommandSender sender, String[] args) { public Boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (!(sender instanceof Player)) { if (!(sender instanceof Player)) {
CMIMessages.sendMessage(sender, LC.info_Ingame); CMIMessages.sendMessage(sender, LC.info_Ingame);
return false; return null;
}
if (args.length != 0) {
Jobs.getCommandManager().sendUsage(sender, "blockinfo");
return true;
} }
Block block = Util.getTargetBlock((Player) sender, 15); Block block = Util.getTargetBlock((Player) sender, 15);

View File

@ -13,6 +13,7 @@ import com.gamingmesh.jobs.container.CurrencyType;
import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.hooks.HookManager; import com.gamingmesh.jobs.hooks.HookManager;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC; import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Messages.CMIMessages; import net.Zrips.CMILib.Messages.CMIMessages;
@ -22,86 +23,84 @@ public class bonus 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)) {
CMIMessages.sendMessage(sender, LC.info_Ingame); CMIMessages.sendMessage(sender, LC.info_Ingame);
return false; return null;
} }
if (args.length != 1) { if (args.length != 1) {
Jobs.getCommandManager().sendUsage(sender, "bonus"); Jobs.getCommandManager().sendUsage(sender, "bonus");
return true; return true;
} }
Player player = (Player) sender; Player player = (Player) sender;
Job job = Jobs.getJob(args[0]); Job job = Jobs.getJob(args[0]);
if (job == null) { if (job == null) {
player.sendMessage(Jobs.getLanguage().getMessage("general.error.job")); Language.sendMessage(sender, "general.error.job");
return true; return true;
} }
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
if (jPlayer == null) if (jPlayer == null)
return false; return false;
Boost boost = Jobs.getPlayerManager().getFinalBonus(jPlayer, job, true, true); Boost boost = Jobs.getPlayerManager().getFinalBonus(jPlayer, job, true, true);
player.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.topline")); Language.sendMessage(sender, "command.bonus.output.topline");
printBoost(sender, boost, BoostOf.Permission); printBoost(sender, boost, BoostOf.Permission);
printBoost(sender, boost, BoostOf.Item); printBoost(sender, boost, BoostOf.Item);
printBoost(sender, boost, BoostOf.Global); printBoost(sender, boost, BoostOf.Global);
if (Jobs.getGCManager().useDynamicPayment) if (Jobs.getGCManager().useDynamicPayment)
printBoost(sender, boost, BoostOf.Dynamic); printBoost(sender, boost, BoostOf.Dynamic);
printBoost(sender, boost, BoostOf.Area); printBoost(sender, boost, BoostOf.Area);
if (Jobs.getGCManager().payNearSpawner()) if (Jobs.getGCManager().payNearSpawner())
printBoost(sender, boost, BoostOf.NearSpawner); printBoost(sender, boost, BoostOf.NearSpawner);
printBoost(sender, boost, BoostOf.PetPay); printBoost(sender, boost, BoostOf.PetPay);
if (HookManager.getMcMMOManager().mcMMOPresent || if (HookManager.getMcMMOManager().mcMMOPresent ||
HookManager.getMcMMOManager().mcMMOOverHaul && boost.get(BoostOf.McMMO, CurrencyType.EXP) != 0D) HookManager.getMcMMOManager().mcMMOOverHaul && boost.get(BoostOf.McMMO, CurrencyType.EXP) != 0D)
printBoost(sender, boost, BoostOf.McMMO); printBoost(sender, boost, BoostOf.McMMO);
player.sendMessage(Jobs.getLanguage().getMessage("general.info.separator")); Language.sendMessage(sender, "general.info.separator");
RawMessage rm = new RawMessage(); RawMessage rm = new RawMessage();
String msg = Jobs.getLanguage().getMessage("command.bonus.output.final", String msg = Jobs.getLanguage().getMessage("command.bonus.output.final",
"%money%", formatText(boost.getFinal(CurrencyType.MONEY, true, true)), "%money%", formatText(boost.getFinal(CurrencyType.MONEY, true, true)),
"%points%", formatText(boost.getFinal(CurrencyType.POINTS, true, true)), "%points%", formatText(boost.getFinal(CurrencyType.POINTS, true, true)),
"%exp%", formatText(boost.getFinal(CurrencyType.EXP, true, true))); "%exp%", formatText(boost.getFinal(CurrencyType.EXP, true, true)));
String msg2 = Jobs.getLanguage().getMessage("command.bonus.output.final",
"%money%", formatText(boost.getFinal(CurrencyType.MONEY, true, false)),
"%points%", formatText(boost.getFinal(CurrencyType.POINTS, true, false)),
"%exp%", formatText(boost.getFinal(CurrencyType.EXP, true, false)));
rm.addText(msg).addHover(Arrays.asList(Jobs.getLanguage().getMessage("command.bonus.output.finalExplanation"), msg2)); String msg2 = Jobs.getLanguage().getMessage("command.bonus.output.final",
"%money%", formatText(boost.getFinal(CurrencyType.MONEY, true, false)),
"%points%", formatText(boost.getFinal(CurrencyType.POINTS, true, false)),
"%exp%", formatText(boost.getFinal(CurrencyType.EXP, true, false)));
rm.build();
rm.show(player);
return true; rm.addText(msg).addHover(Arrays.asList(Jobs.getLanguage().getMessage("command.bonus.output.finalExplanation"), msg2));
rm.build();
rm.show(player);
return true;
} }
private static void printBoost(CommandSender sender, Boost boost, BoostOf type) { private static void printBoost(CommandSender sender, Boost boost, BoostOf type) {
String prefix = Jobs.getLanguage().getMessage("command.bonus.output.specialPrefix"); String prefix = Jobs.getLanguage().getMessage("command.bonus.output.specialPrefix");
if (type != BoostOf.NearSpawner && type != BoostOf.PetPay) if (type != BoostOf.NearSpawner && type != BoostOf.PetPay)
prefix = ""; prefix = "";
String msg = Jobs.getLanguage().getMessage("command.bonus.output." + type.name().toLowerCase(), String msg = Jobs.getLanguage().getMessage("command.bonus.output." + type.name().toLowerCase(),
"%money%", formatText(boost.get(type, CurrencyType.MONEY, true)), "%money%", formatText(boost.get(type, CurrencyType.MONEY, true)),
"%points%", formatText(boost.get(type, CurrencyType.POINTS, true)), "%points%", formatText(boost.get(type, CurrencyType.POINTS, true)),
"%exp%", formatText(boost.get(type, CurrencyType.EXP, true))); "%exp%", formatText(boost.get(type, CurrencyType.EXP, true)));
if ((type == BoostOf.NearSpawner || type == BoostOf.PetPay) && msg.startsWith(" ")) if ((type == BoostOf.NearSpawner || type == BoostOf.PetPay) && msg.startsWith(" "))
msg = msg.substring(1, msg.length()); msg = msg.substring(1, msg.length());
sender.sendMessage(prefix + msg); CMIMessages.sendMessage(sender, prefix + msg);
} }
private static String formatText(double amount) { private static String formatText(double amount) {
return ((amount > 0 ? "+" : "") + amount + "%"); return ((amount > 0 ? "+" : "") + amount + "%");
} }
} }

View File

@ -6,6 +6,7 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.CurrencyType; import com.gamingmesh.jobs.container.CurrencyType;
import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC; import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Logs.CMIDebug; import net.Zrips.CMILib.Logs.CMIDebug;
@ -95,22 +96,22 @@ public class boost implements Cmd {
one.addBoost(curr, 1.0); one.addBoost(curr, 1.0);
} }
} }
sender.sendMessage(Jobs.getLanguage().getMessage("command.boost.output.allreset")); Language.sendMessage(sender, "command.boost.output.allreset");
} else { } else {
for (Job one : Jobs.getJobs()) { for (Job one : Jobs.getJobs()) {
one.addBoost(type, 1.0); one.addBoost(type, 1.0);
} }
sender.sendMessage(Jobs.getLanguage().getMessage("command.boost.output.alltypereset", "%type%", type.getDisplayName())); Language.sendMessage(sender, "command.boost.output.alltypereset", "%type%", type.getDisplayName());
} }
} else if (job != null) { } else if (job != null) {
if (type == null) { if (type == null) {
for (CurrencyType curr : CurrencyType.values()) { for (CurrencyType curr : CurrencyType.values()) {
job.addBoost(curr, 1.0); job.addBoost(curr, 1.0);
} }
sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.jobsboostreset", "%jobname%", job.getName())); Language.sendMessage(sender, "command.moneyboost.output.jobsboostreset", "%jobname%", job.getName());
} else { } else {
job.addBoost(type, 1.0); job.addBoost(type, 1.0);
sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.jobstypeboostreset", "%jobname%", job.getName(), "%type%", type.getDisplayName())); Language.sendMessage(sender, "command.moneyboost.output.jobstypeboostreset", "%jobname%", job.getName(), "%type%", type.getDisplayName());
} }
} else { } else {
return false; return false;
@ -128,7 +129,7 @@ public class boost implements Cmd {
one.addBoost(type, rate, timeDuration); one.addBoost(type, rate, timeDuration);
} }
sender.sendMessage(Jobs.getLanguage().getMessage("command.boost.output.boostadded", "%boost%", rate, "%jobname%", one.getName())); Language.sendMessage(sender, "command.boost.output.boostadded", "%boost%", rate, "%jobname%", one.getName());
} }
} else { } else {
if (type == null) { if (type == null) {
@ -138,14 +139,13 @@ public class boost implements Cmd {
} else { } else {
job.addBoost(type, rate, timeDuration); job.addBoost(type, rate, timeDuration);
} }
CMIDebug.d(timeDuration); Language.sendMessage(sender, "command.boost.output.boostadded", "%boost%", rate, "%jobname%", job.getName());
sender.sendMessage(Jobs.getLanguage().getMessage("command.boost.output.boostadded", "%boost%", rate, "%jobname%", job.getName()));
} }
return true; return true;
} }
private void showBoosts(CommandSender sender, Job job) { private static void showBoosts(CommandSender sender, Job job) {
RawMessage rm = new RawMessage(); RawMessage rm = new RawMessage();
String msg = Jobs.getLanguage().getMessage("command.boost.output.boostStats", "%jobname%", job.getDisplayName()); String msg = Jobs.getLanguage().getMessage("command.boost.output.boostStats", "%jobname%", job.getDisplayName());
String[] split = msg.split("%payments%"); String[] split = msg.split("%payments%");

View File

@ -13,6 +13,7 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.BlockProtection; import com.gamingmesh.jobs.container.BlockProtection;
import com.gamingmesh.jobs.container.DBAction; import com.gamingmesh.jobs.container.DBAction;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Items.CMIMaterial; import net.Zrips.CMILib.Items.CMIMaterial;
import net.Zrips.CMILib.Locale.LC; import net.Zrips.CMILib.Locale.LC;
@ -73,9 +74,9 @@ public class bp implements Cmd {
} }
if (changedBlocks.isEmpty()) if (changedBlocks.isEmpty())
sender.sendMessage(Jobs.getLanguage().getMessage("command.bp.output.notFound")); Language.sendMessage(sender, "command.bp.output.notFound");
else else
sender.sendMessage(Jobs.getLanguage().getMessage("command.bp.output.found", "%amount%", changedBlocks.size())); Language.sendMessage(sender, "command.bp.output.found", "%amount%", changedBlocks.size());
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override @Override

View File

@ -9,9 +9,11 @@ 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.Job; import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Colors.CMIChatColor; import net.Zrips.CMILib.Colors.CMIChatColor;
import net.Zrips.CMILib.Container.PageInfo; import net.Zrips.CMILib.Container.PageInfo;
import net.Zrips.CMILib.Messages.CMIMessages;
import net.Zrips.CMILib.RawMessages.RawMessage; import net.Zrips.CMILib.RawMessages.RawMessage;
public class browse implements Cmd { public class browse implements Cmd {
@ -22,7 +24,7 @@ public class browse implements Cmd {
if (Jobs.getGCManager().BrowseUseNewLook) { if (Jobs.getGCManager().BrowseUseNewLook) {
if (Jobs.getJobs().isEmpty()) { if (Jobs.getJobs().isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.error.nojobs")); Language.sendMessage(sender, "command.browse.error.nojobs");
return true; return true;
} }
@ -60,7 +62,7 @@ public class browse implements Cmd {
if (senderIsPlayer) { if (senderIsPlayer) {
if (j == null) { if (j == null) {
PageInfo pi = new PageInfo(Jobs.getGCManager().getBrowseAmountToShow(), jobList.size(), page); PageInfo pi = new PageInfo(Jobs.getGCManager().getBrowseAmountToShow(), jobList.size(), page);
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.newHeader", "[amount]", jobList.size())); Language.sendMessage(sender, "command.browse.output.newHeader", "[amount]", jobList.size());
for (Job one : jobList) { for (Job one : jobList) {
if (!pi.isEntryOk()) if (!pi.isEntryOk())
continue; continue;
@ -116,25 +118,25 @@ public class browse implements Cmd {
pi.autoPagination(sender, "jobs browse", "-p:"); pi.autoPagination(sender, "jobs browse", "-p:");
} else { } else {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.jobHeader", "[jobname]", j.getName())); Language.sendMessage(sender, "command.browse.output.jobHeader", "[jobname]", j.getName());
int maxLevel = j.getMaxLevel(sender); int maxLevel = j.getMaxLevel(sender);
if (maxLevel > 0) if (maxLevel > 0)
sender.sendMessage(Jobs.getLanguage().getMessage("command.info.help.newMax", "[max]", maxLevel)); Language.sendMessage(sender, "command.info.help.newMax", "[max]", maxLevel);
if (Jobs.getGCManager().ShowTotalWorkers) if (Jobs.getGCManager().ShowTotalWorkers)
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", j.getTotalPlayers())); Language.sendMessage(sender, "command.browse.output.totalWorkers", "[amount]", j.getTotalPlayers());
if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) { if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) {
int bonus = (int) (j.getBonus() * 100); int bonus = (int) (j.getBonus() * 100);
if (bonus < 0) if (bonus < 0)
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", bonus * -1)); Language.sendMessage(sender, "command.browse.output.penalty", "[amount]", bonus * -1);
else else
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", bonus)); Language.sendMessage(sender, "command.browse.output.bonus", "[amount]", bonus);
} }
for (String one : j.getFullDescription()) { for (String one : j.getFullDescription()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.description", "[description]", one)); Language.sendMessage(sender, "command.browse.output.description", "[description]", one);
} }
RawMessage rm = new RawMessage(); RawMessage rm = new RawMessage();
@ -148,7 +150,7 @@ public class browse implements Cmd {
} }
} else { } else {
if (j == null) { if (j == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.console.newHeader", "[amount]", jobList.size(), "\\n", "\n")); Language.sendMessage(sender, "command.browse.output.console.newHeader", "[amount]", jobList.size(), "\\n", "\n");
for (Job one : jobList) { for (Job one : jobList) {
String msg = ""; String msg = "";
@ -177,14 +179,14 @@ public class browse implements Cmd {
msg += Jobs.getLanguage().getMessage("command.browse.output.console.list", "[jobname]", one.getName()); msg += Jobs.getLanguage().getMessage("command.browse.output.console.list", "[jobname]", one.getName());
sender.sendMessage(msg); CMIMessages.sendMessage(sender, msg);
} }
} else { } else {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.jobHeader", "[jobname]", j.getName())); Language.sendMessage(sender, "command.browse.output.jobHeader", "[jobname]", j.getName());
int maxLevel = j.getMaxLevel(sender); int maxLevel = j.getMaxLevel(sender);
if (maxLevel > 0) if (maxLevel > 0)
sender.sendMessage(Jobs.getLanguage().getMessage("command.info.help.newMax", "[max]", maxLevel)); Language.sendMessage(sender, "command.info.help.newMax", "[max]", maxLevel);
if (Jobs.getGCManager().ShowTotalWorkers) if (Jobs.getGCManager().ShowTotalWorkers)
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", j.getTotalPlayers())); sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", j.getTotalPlayers()));
@ -192,13 +194,13 @@ public class browse implements Cmd {
if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) { if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) {
int bonus = (int) (j.getBonus() * 100); int bonus = (int) (j.getBonus() * 100);
if (bonus < 0) if (bonus < 0)
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", bonus * -1)); Language.sendMessage(sender, "command.browse.output.penalty", "[amount]", bonus * -1);
else else
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", bonus)); Language.sendMessage(sender, "command.browse.output.bonus", "[amount]", bonus);
} }
for (String one : j.getFullDescription()) { for (String one : j.getFullDescription()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.description", "[description]", one)); Language.sendMessage(sender, "command.browse.output.description", "[description]", one);
} }
} }
} }
@ -245,7 +247,7 @@ public class browse implements Cmd {
} }
if (lines.isEmpty()) { if (lines.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.error.nojobs")); Language.sendMessage(sender, "command.browse.error.nojobs");
return true; return true;
} }
@ -260,9 +262,9 @@ public class browse implements Cmd {
} }
if (Jobs.getGCManager().JobsGUIShowChatBrowse) { if (Jobs.getGCManager().JobsGUIShowChatBrowse) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.header")); Language.sendMessage(sender, "command.browse.output.header");
lines.forEach(sender::sendMessage); lines.forEach(sender::sendMessage);
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.footer")); Language.sendMessage(sender, "command.browse.output.footer");
} }
} }
return true; return true;

View File

@ -11,6 +11,7 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.container.blockOwnerShip.BlockTypes; import com.gamingmesh.jobs.container.blockOwnerShip.BlockTypes;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC; import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Messages.CMIMessages; import net.Zrips.CMILib.Messages.CMIMessages;
@ -47,8 +48,8 @@ public class clearownership implements Cmd {
if (args.length >= 1) if (args.length >= 1)
CMIMessages.sendMessage(sender, LC.info_NoInformation); CMIMessages.sendMessage(sender, LC.info_NoInformation);
else else
Jobs.getCommandManager().sendUsage(sender, "clearownership"); return false;
return true; return null;
} }
final UUID uuid = jPlayer.getUniqueId(); final UUID uuid = jPlayer.getUniqueId();
@ -64,8 +65,8 @@ public class clearownership implements Cmd {
} }
} }
sender.sendMessage(Jobs.getLanguage().getMessage("command.clearownership.output.cleared", "[furnaces]", amounts.getOrDefault(BlockTypes.FURNACE, 0), "[brewing]", amounts.getOrDefault( Language.sendMessage(sender,"command.clearownership.output.cleared", "[furnaces]", amounts.getOrDefault(BlockTypes.FURNACE, 0), "[brewing]", amounts.getOrDefault(
BlockTypes.BREWING_STAND, 0), "[smoker]", amounts.getOrDefault(BlockTypes.SMOKER, 0), "[blast]", amounts.getOrDefault(BlockTypes.BLAST_FURNACE, 0))); BlockTypes.BREWING_STAND, 0), "[smoker]", amounts.getOrDefault(BlockTypes.SMOKER, 0), "[blast]", amounts.getOrDefault(BlockTypes.BLAST_FURNACE, 0));
return true; return true;
} }
} }

View File

@ -21,8 +21,7 @@ public class convert implements Cmd {
} }
if (args.length > 0) { if (args.length > 0) {
Jobs.getCommandManager().sendUsage(sender, "convert"); return false;
return true;
} }
String from = Jobs.getDBManager().getDbType() == DataBaseType.SqLite ? "SQLite" : "MySQL"; String from = Jobs.getDBManager().getDbType() == DataBaseType.SqLite ? "SQLite" : "MySQL";

View File

@ -7,6 +7,7 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Colors.CMIChatColor; import net.Zrips.CMILib.Colors.CMIChatColor;
@ -14,48 +15,46 @@ public class demote implements Cmd {
@Override @Override
public Boolean perform(Jobs plugin, CommandSender sender, String[] args) { public Boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (args.length < 3) { if (args.length < 3) {
Jobs.getCommandManager().sendUsage(sender, "demote"); return false;
return true; }
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) { if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0])); Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args[0]);
return true; return true;
} }
Job job = Jobs.getJob(args[1]); Job job = Jobs.getJob(args[1]);
if (job == null) { if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job")); Language.sendMessage(sender, "general.error.job");
return true; return true;
} }
try { try {
// check if player already has the job // check if player already has the job
if (jPlayer.isInJob(job)) { if (jPlayer.isInJob(job)) {
int levelsLost = 0; int levelsLost = 0;
try { try {
levelsLost = Integer.parseInt(args[2]); levelsLost = Integer.parseInt(args[2]);
} catch (NumberFormatException ex) { } catch (NumberFormatException ex) {
return true; return true;
} }
Jobs.getPlayerManager().demoteJob(jPlayer, job, levelsLost); Jobs.getPlayerManager().demoteJob(jPlayer, job, levelsLost);
Player player = jPlayer.getPlayer(); Player player = jPlayer.getPlayer();
if (player != null) { if (player != null) {
String message = Jobs.getLanguage().getMessage("command.demote.output.target", Language.sendMessage(sender, "command.demote.output.target",
"%jobname%", job.getDisplayName() + CMIChatColor.WHITE, "%jobname%", job.getDisplayName() + CMIChatColor.WHITE,
"%levelslost%", levelsLost); "%levelslost%", levelsLost);
player.sendMessage(message); }
}
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success")); Language.sendMessage(sender, "general.admin.success");
} }
} catch (Throwable e) { } catch (Throwable e) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.error")); Language.sendMessage(sender, "general.admin.error");
} }
return true; return true;
} }
} }

View File

@ -13,6 +13,7 @@ import com.gamingmesh.jobs.container.CurrencyType;
import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobItems; import com.gamingmesh.jobs.container.JobItems;
import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Colors.CMIChatColor; import net.Zrips.CMILib.Colors.CMIChatColor;
import net.Zrips.CMILib.Items.CMIItemStack; import net.Zrips.CMILib.Items.CMIItemStack;
@ -23,37 +24,37 @@ import net.Zrips.CMILib.NBT.CMINBT;
public class edititembonus implements Cmd { public class edititembonus implements Cmd {
private enum actions { private enum actions {
list, add, remove; list, add, remove;
public static actions getByname(String name) { public static actions getByname(String name) {
for (actions one : actions.values()) { for (actions one : actions.values()) {
if (one.name().equalsIgnoreCase(name)) if (one.name().equalsIgnoreCase(name))
return one; return one;
} }
return null; return null;
} }
} }
@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)) {
CMIMessages.sendMessage(sender, LC.info_Ingame); CMIMessages.sendMessage(sender, LC.info_Ingame);
return false; return null;
} }
if (args.length < 1) if (args.length < 1)
return false; return false;
actions action = null; actions action = null;
// Job job = null; // Job job = null;
JobItems jobitem = null; JobItems jobitem = null;
for (String one : args) { for (String one : args) {
if (action == null) { if (action == null) {
action = actions.getByname(one); action = actions.getByname(one);
if (action != null) if (action != null)
continue; continue;
} }
// if (job == null) { // if (job == null) {
// job = Jobs.getJob(one); // job = Jobs.getJob(one);
// if (job != null) // if (job != null)
@ -61,68 +62,67 @@ public class edititembonus implements Cmd {
// } // }
// if (job != null) { // if (job != null) {
jobitem = ItemBoostManager.getItemByKey(one); jobitem = ItemBoostManager.getItemByKey(one);
// } // }
} }
if (action == null) if (action == null)
return false; return false;
Player player = (Player) sender; Player player = (Player) sender;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
if (jPlayer == null) if (jPlayer == null)
return false; return false;
ItemStack iih = CMIItemStack.getItemInMainHand(player); ItemStack iih = CMIItemStack.getItemInMainHand(player);
if (iih == null || iih.getType() == Material.AIR) if (iih == null || iih.getType() == Material.AIR)
return false; return false;
switch (action) { switch (action) {
case add: case add:
if (jobitem == null) if (jobitem == null)
return false; return false;
iih = (ItemStack) new CMINBT(iih).setString("JobsItemBoost", jobitem.getNode()); iih = (ItemStack) new CMINBT(iih).setString("JobsItemBoost", jobitem.getNode());
CMIItemStack.setItemInMainHand(player, iih); CMIItemStack.setItemInMainHand(player, iih);
break; break;
case list: case list:
break; break;
case remove: case remove:
iih = (ItemStack) new CMINBT(iih).remove("JobsItemBoost"); iih = (ItemStack) new CMINBT(iih).remove("JobsItemBoost");
CMIItemStack.setItemInMainHand(player, iih); CMIItemStack.setItemInMainHand(player, iih);
break; break;
default: default:
break; break;
} }
sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.topline")); Language.sendMessage(sender, "command.bonus.output.topline");
Object key = new CMINBT(iih).getString("JobsItemBoost"); Object key = new CMINBT(iih).getString("JobsItemBoost");
if (key == null) if (key == null)
return true; return true;
JobItems item = ItemBoostManager.getItemByKey(key.toString()); JobItems item = ItemBoostManager.getItemByKey(key.toString());
if (item == null) if (item == null)
return true; return true;
BoostMultiplier boost = item.getBoost(); BoostMultiplier boost = item.getBoost();
String mc = CMIChatColor.DARK_GREEN.toString(), String mc = CMIChatColor.DARK_GREEN.toString();
pc = CMIChatColor.GOLD.toString(), String pc = CMIChatColor.GOLD.toString();
ec = CMIChatColor.YELLOW.toString(); String ec = CMIChatColor.YELLOW.toString();
for (Job one : item.getJobs()) { for (Job one : item.getJobs()) {
String msg = Jobs.getLanguage().getMessage("command.itembonus.output.list", Language.sendMessage(sender, "command.itembonus.output.list",
"[jobname]", one.getName(), "[jobname]", one.getName(),
"%money%", mc + formatText((int) (boost.get(CurrencyType.MONEY) * 100)), "%money%", mc + formatText((int) (boost.get(CurrencyType.MONEY) * 100)),
"%points%", pc + formatText((int) (boost.get(CurrencyType.POINTS) * 100)), "%points%", pc + formatText((int) (boost.get(CurrencyType.POINTS) * 100)),
"%exp%", ec + formatText((int) (boost.get(CurrencyType.EXP) * 100))); "%exp%", ec + formatText((int) (boost.get(CurrencyType.EXP) * 100)));
sender.sendMessage(msg); }
} return true;
return true;
} }
private static String formatText(double amount) { private static String formatText(double amount) {
return ((amount > 0 ? "+" : "") + amount + "%"); return ((amount > 0 ? "+" : "") + amount + "%");
} }
} }

View File

@ -20,6 +20,7 @@ import net.Zrips.CMILib.Colors.CMIChatColor;
import net.Zrips.CMILib.Container.PageInfo; import net.Zrips.CMILib.Container.PageInfo;
import net.Zrips.CMILib.Items.CMIItemStack; import net.Zrips.CMILib.Items.CMIItemStack;
import net.Zrips.CMILib.Items.CMIMaterial; import net.Zrips.CMILib.Items.CMIMaterial;
import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.RawMessages.RawMessage; import net.Zrips.CMILib.RawMessages.RawMessage;
import net.Zrips.CMILib.Version.Version; import net.Zrips.CMILib.Version.Version;
@ -29,408 +30,413 @@ public class editjobs implements Cmd {
@Override @Override
public Boolean perform(Jobs plugin, CommandSender sender, String[] args) { public Boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (!(sender instanceof Player)) if (!(sender instanceof Player)) {
return false; LC.info_Ingame.sendMessage(sender);
return false;
}
Player player = (Player) sender; Player player = (Player) sender;
if (args.length == 0) if (args.length == 0)
args = new String[] { "list" }; args = new String[] { "list" };
switch (args[0]) { switch (args[0]) {
case "list": case "list":
if (args.length == 1) { if (args.length == 1) {
showPath(player, null, null, null); showPath(player, null, null, null);
for (Job one : Jobs.getJobs()) { for (Job one : Jobs.getJobs()) {
RawMessage rm = new RawMessage(); RawMessage rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.jobs", "%jobname%", one.getJobDisplayName()), one.getName(), "jobs editjobs list " + one.getName()); rm.addText(Jobs.getLanguage().getMessage("command.editjobs.help.list.jobs", "%jobname%", one.getDisplayName()))
rm.show(sender); .addHover(one.getName())
} .addCommand("jobs editjobs list " + one.getName());
rm.show(sender);
}
Util.getJobsEditorMap().remove(player.getUniqueId()); Util.getJobsEditorMap().remove(player.getUniqueId());
return true; return true;
} }
if (args.length == 2) { if (args.length == 2) {
Job job = Jobs.getJob(args[1]); Job job = Jobs.getJob(args[1]);
if (job == null) if (job == null)
return false; return false;
showPath(player, job, null, null); showPath(player, job, null, null);
for (ActionType oneI : ActionType.values()) { for (ActionType oneI : ActionType.values()) {
List<JobInfo> action = job.getJobInfo(oneI); List<JobInfo> action = job.getJobInfo(oneI);
if (action == null || action.isEmpty()) if (action == null || action.isEmpty())
continue; continue;
RawMessage rm = new RawMessage(); RawMessage rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.actions", "%actionname%", oneI.getName()), oneI.getName(), "jobs editjobs list " + job.getName() + " " + oneI.getName() rm.addText(Jobs.getLanguage().getMessage("command.editjobs.help.list.actions", "%actionname%", oneI.getName()))
+ " 1"); .addHover(oneI.getName())
rm.show(sender); .addCommand("jobs editjobs list " + job.getName() + " " + oneI.getName() + " 1");
} rm.show(sender);
}
Util.getJobsEditorMap().remove(player.getUniqueId()); Util.getJobsEditorMap().remove(player.getUniqueId());
return true; return true;
} }
if (args.length == 4) { if (args.length == 4) {
Integer page = null; Integer page = null;
try { try {
page = Integer.parseInt(args[3]); page = Integer.parseInt(args[3]);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
} }
if (page != null) { if (page != null) {
Job job = Jobs.getJob(args[1]); Job job = Jobs.getJob(args[1]);
if (job == null) if (job == null)
return false; return false;
ActionType actionT = ActionType.getByName(args[2]); ActionType actionT = ActionType.getByName(args[2]);
if (actionT == null) if (actionT == null)
return false; return false;
List<JobInfo> action = job.getJobInfo(actionT); List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty()) if (action == null || action.isEmpty())
return false; return false;
showPath(player, job, actionT, null); showPath(player, job, actionT, null);
PageInfo pi = new PageInfo(15, action.size(), page); PageInfo pi = new PageInfo(15, action.size(), page);
for (JobInfo one : action) { for (JobInfo one : action) {
if (!pi.isEntryOk()) if (!pi.isEntryOk())
continue; continue;
String materialName = one.getRealisticName(); String materialName = one.getRealisticName();
RawMessage rm = new RawMessage(); RawMessage rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.material", "%materialname%", materialName), one.getName(), "jobs editjobs list " + job.getName() + " " + actionT rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.material", "%materialname%", materialName), one.getName(), "jobs editjobs list " + job.getName() + " " + actionT
.getName() + " " + one.getName()); .getName() + " " + one.getName());
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.materialRemove"), "&cRemove", "jobs editjobs remove " + job.getName() + " " + actionT.getName() + " " + one rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.materialRemove"), "&cRemove", "jobs editjobs remove " + job.getName() + " " + actionT.getName() + " " + one
.getName()); .getName());
rm.show(sender); rm.show(sender);
} }
RawMessage rm = new RawMessage(); RawMessage rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.materialAdd"), "&eAdd new", "jobs editjobs add " + job.getName() + " " + actionT.getName()); rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.materialAdd"), "&eAdd new", "jobs editjobs add " + job.getName() + " " + actionT.getName());
rm.show(sender); rm.show(sender);
Util.getJobsEditorMap().remove(player.getUniqueId()); Util.getJobsEditorMap().remove(player.getUniqueId());
pi.autoPagination(sender, "jobs editjobs list " + job.getName() + " " + actionT.getName()); pi.autoPagination(sender, "jobs editjobs list " + job.getName() + " " + actionT.getName());
return true; return true;
} }
Job job = Jobs.getJob(args[1]); Job job = Jobs.getJob(args[1]);
if (job == null) if (job == null)
return false; return false;
ActionType actionT = ActionType.getByName(args[2]); ActionType actionT = ActionType.getByName(args[2]);
if (actionT == null) if (actionT == null)
return false; return false;
List<JobInfo> action = job.getJobInfo(actionT); List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty()) if (action == null || action.isEmpty())
return false; return false;
JobInfo jInfo = null; JobInfo jInfo = null;
for (JobInfo one : action) { for (JobInfo one : action) {
if (one.getName().equalsIgnoreCase(args[3])) { if (one.getName().equalsIgnoreCase(args[3])) {
jInfo = one; jInfo = one;
break; break;
} }
} }
if (jInfo == null) if (jInfo == null)
return false; return false;
showPath(player, job, actionT, jInfo); showPath(player, job, actionT, jInfo);
RawMessage rm = new RawMessage(); RawMessage rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.money", "%amount%", jInfo.getBaseIncome()), "&e" + jInfo.getBaseIncome(), "jobs editjobs modify " + job.getName() + " " rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.money", "%amount%", jInfo.getBaseIncome()), "&e" + jInfo.getBaseIncome(), "jobs editjobs modify " + job.getName() + " "
+ actionT.getName() + " " + jInfo.getName() + " money "); + actionT.getName() + " " + jInfo.getName() + " money ");
rm.show(sender); rm.show(sender);
rm = new RawMessage(); rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.points", "%amount%", jInfo.getBasePoints()), "&e" + jInfo.getBasePoints(), "jobs editjobs modify " + job.getName() + " " rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.points", "%amount%", jInfo.getBasePoints()), "&e" + jInfo.getBasePoints(), "jobs editjobs modify " + job.getName() + " "
+ actionT.getName() + " " + jInfo.getName() + actionT.getName() + " " + jInfo.getName()
+ " points "); + " points ");
rm.show(sender); rm.show(sender);
rm = new RawMessage(); rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.exp", "%amount%", jInfo.getBaseXp()), "&e" + jInfo.getBaseXp(), "jobs editjobs modify " + job.getName() + " " + actionT rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.exp", "%amount%", jInfo.getBaseXp()), "&e" + jInfo.getBaseXp(), "jobs editjobs modify " + job.getName() + " " + actionT
.getName() + " " + jInfo.getName() + " exp "); .getName() + " " + jInfo.getName() + " exp ");
rm.show(sender); rm.show(sender);
Util.getJobsEditorMap().remove(player.getUniqueId()); Util.getJobsEditorMap().remove(player.getUniqueId());
return true; return true;
} }
break; break;
case "modify": case "modify":
if (args.length == 5) { if (args.length == 5) {
Job job = Jobs.getJob(args[1]); Job job = Jobs.getJob(args[1]);
if (job == null) if (job == null)
return false; return false;
ActionType actionT = ActionType.getByName(args[2]); ActionType actionT = ActionType.getByName(args[2]);
if (actionT == null) if (actionT == null)
return false; return false;
List<JobInfo> action = job.getJobInfo(actionT); List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty()) if (action == null || action.isEmpty())
return false; return false;
JobInfo jInfo = null; JobInfo jInfo = null;
for (JobInfo one : action) { for (JobInfo one : action) {
if (one.getName().equalsIgnoreCase(args[3])) { if (one.getName().equalsIgnoreCase(args[3])) {
jInfo = one; jInfo = one;
break; break;
} }
} }
if (jInfo == null) if (jInfo == null)
return false; return false;
CurrencyType type = CurrencyType.getByName(args[4]); CurrencyType type = CurrencyType.getByName(args[4]);
if (type == null) if (type == null)
return false; return false;
Util.getJobsEditorMap().put(player.getUniqueId(), "jobs editjobs modify " + job.getName() + " " + actionT.getName() + " " + jInfo.getName() + " " + type.getName() + " "); Util.getJobsEditorMap().put(player.getUniqueId(), "jobs editjobs modify " + job.getName() + " " + actionT.getName() + " " + jInfo.getName() + " " + type.getName() + " ");
sender.sendMessage(Jobs.getLanguage().getMessage("command.editjobs.help.modify.newValue")); sender.sendMessage(Jobs.getLanguage().getMessage("command.editjobs.help.modify.newValue"));
return true; return true;
} }
if (args.length == 6) { if (args.length == 6) {
Job job = Jobs.getJob(args[1]); Job job = Jobs.getJob(args[1]);
if (job == null) if (job == null)
return false; return false;
ActionType actionT = ActionType.getByName(args[2]); ActionType actionT = ActionType.getByName(args[2]);
if (actionT == null) if (actionT == null)
return false; return false;
List<JobInfo> action = job.getJobInfo(actionT); List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty()) if (action == null || action.isEmpty())
return false; return false;
JobInfo jInfo = null; JobInfo jInfo = null;
for (JobInfo one : action) { for (JobInfo one : action) {
if (one.getName().equalsIgnoreCase(args[3])) { if (one.getName().equalsIgnoreCase(args[3])) {
jInfo = one; jInfo = one;
break; break;
} }
} }
if (jInfo == null) if (jInfo == null)
return false; return false;
CurrencyType type = CurrencyType.getByName(args[4]); CurrencyType type = CurrencyType.getByName(args[4]);
if (type == null) if (type == null)
return false; return false;
Double value = null; Double value = null;
try { try {
value = Double.parseDouble(args[5]); value = Double.parseDouble(args[5]);
} catch (Exception e) { } catch (Exception e) {
return false; return false;
} }
String sType = null; String sType = null;
switch (type) { switch (type) {
case EXP: case EXP:
sType = "experience"; sType = "experience";
jInfo.setBaseXp(value); jInfo.setBaseXp(value);
break; break;
case MONEY: case MONEY:
sType = "income"; sType = "income";
jInfo.setBaseIncome(value); jInfo.setBaseIncome(value);
break; break;
case POINTS: case POINTS:
sType = "points"; sType = "points";
jInfo.setBasePoints(value); jInfo.setBasePoints(value);
break; break;
default: default:
break; break;
} }
Jobs.getConfigManager().changeJobsSettings(args[1], jInfo.getConfigPath() + "/" + sType, value);
player.performCommand("jobs editjobs list " + job.getName() + " " + actionT.getName() + " " + jInfo.getName());
Util.getJobsEditorMap().remove(player.getUniqueId());
return true;
}
break; Jobs.getConfigManager().changeJobsSettings(args[1], jInfo.getConfigPath() + "/" + sType, value);
case "remove": player.performCommand("jobs editjobs list " + job.getName() + " " + actionT.getName() + " " + jInfo.getName());
// remove miner break stone:1 Util.getJobsEditorMap().remove(player.getUniqueId());
return true;
}
if (args.length == 4) { break;
Job job = Jobs.getJob(args[1]); case "remove":
if (job == null) // remove miner break stone:1
return false;
ActionType actionT = ActionType.getByName(args[2]); if (args.length == 4) {
if (actionT == null) Job job = Jobs.getJob(args[1]);
return false; if (job == null)
return false;
List<JobInfo> action = job.getJobInfo(actionT); ActionType actionT = ActionType.getByName(args[2]);
if (action == null || action.isEmpty()) if (actionT == null)
return false; return false;
JobInfo jInfo = null; List<JobInfo> action = job.getJobInfo(actionT);
for (JobInfo info : action) { if (action == null || action.isEmpty())
if (!info.getName().equalsIgnoreCase(args[3])) return false;
continue;
jInfo = info;
break;
}
if (jInfo == null) { JobInfo jInfo = null;
return true; for (JobInfo info : action) {
} if (!info.getName().equalsIgnoreCase(args[3]))
continue;
jInfo = info;
break;
}
action.remove(jInfo); if (jInfo == null) {
Jobs.getConfigManager().changeJobsSettings(args[1], jInfo.getConfigPath(), null); return true;
player.performCommand("jobs editjobs list " + job.getName() + " " + actionT.getName() + " 1"); }
Util.getJobsEditorMap().remove(player.getUniqueId());
return true;
}
break;
case "add":
// add miner break stone:1
if (args.length == 3) { action.remove(jInfo);
Job job = Jobs.getJob(args[1]); Jobs.getConfigManager().changeJobsSettings(args[1], jInfo.getConfigPath(), null);
if (job == null) player.performCommand("jobs editjobs list " + job.getName() + " " + actionT.getName() + " 1");
return false; Util.getJobsEditorMap().remove(player.getUniqueId());
return true;
}
break;
case "add":
// add miner break stone:1
ActionType actionT = ActionType.getByName(args[2]); if (args.length == 3) {
if (actionT == null) Job job = Jobs.getJob(args[1]);
return false; if (job == null)
return false;
List<JobInfo> action = job.getJobInfo(actionT); ActionType actionT = ActionType.getByName(args[2]);
if (action == null || action.isEmpty()) if (actionT == null)
return false; return false;
RawMessage rm = new RawMessage(); List<JobInfo> action = job.getJobInfo(actionT);
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.modify.enter")); if (action == null || action.isEmpty())
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.modify.hand"), Jobs.getLanguage().getMessage("command.editjobs.help.modify.handHover"), "jobs editjobs add " + job.getName() return false;
+ " " + actionT.getName() + " hand");
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.modify.or"));
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.modify.look"), Jobs.getLanguage().getMessage("command.editjobs.help.modify.lookHover"), "jobs editjobs add " + job.getName()
+ " " + actionT.getName() + " looking");
rm.show(sender);
Util.getJobsEditorMap().put(player.getUniqueId(), "jobs editjobs add " + job.getName() + " " + actionT.getName() + " "); RawMessage rm = new RawMessage();
return true; rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.modify.enter"));
} rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.modify.hand"), Jobs.getLanguage().getMessage("command.editjobs.help.modify.handHover"), "jobs editjobs add " + job.getName()
+ " " + actionT.getName() + " hand");
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.modify.or"));
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.modify.look"), Jobs.getLanguage().getMessage("command.editjobs.help.modify.lookHover"), "jobs editjobs add " + job.getName()
+ " " + actionT.getName() + " looking");
rm.show(sender);
if (args.length == 4) { Util.getJobsEditorMap().put(player.getUniqueId(), "jobs editjobs add " + job.getName() + " " + actionT.getName() + " ");
Job job = Jobs.getJob(args[1]); return true;
if (job == null) }
return false;
ActionType actionT = ActionType.getByName(args[2]); if (args.length == 4) {
if (actionT == null) Job job = Jobs.getJob(args[1]);
return false; if (job == null)
return false;
List<JobInfo> action = job.getJobInfo(actionT); ActionType actionT = ActionType.getByName(args[2]);
if (action == null || action.isEmpty()) if (actionT == null)
return false; return false;
String key = args[3]; List<JobInfo> action = job.getJobInfo(actionT);
switch (args[3]) { if (action == null || action.isEmpty())
case "hand": return false;
ItemStack item = CMIItemStack.getItemInMainHand(player);
key = CMIMaterial.get(item).getName() + (Version.isCurrentEqualOrHigher(Version.v1_13_R1) ? "" : "-" + item.getData().getData());
break;
case "offhand":
item = CMIItemStack.getItemInOffHand(player);
key = CMIMaterial.get(item).getName() + (Version.isCurrentEqualOrHigher(Version.v1_13_R1) ? "" : "-" + item.getData().getData());
break;
case "looking":
case "lookingat":
Block block = Util.getTargetBlock(player, 30);
key = CMIMaterial.get(block).getName() + (Version.isCurrentEqualOrHigher(Version.v1_13_R1) ? "" : "-" + block.getData());
break;
default:
break;
}
KeyValues keyValue = Jobs.getConfigManager().getKeyValue(key, actionT, job.getName()); String key = args[3];
if (keyValue == null) switch (args[3]) {
return false; case "hand":
ItemStack item = CMIItemStack.getItemInMainHand(player);
key = CMIMaterial.get(item).getName() + (Version.isCurrentEqualOrHigher(Version.v1_13_R1) ? "" : "-" + item.getData().getData());
break;
case "offhand":
item = CMIItemStack.getItemInOffHand(player);
key = CMIMaterial.get(item).getName() + (Version.isCurrentEqualOrHigher(Version.v1_13_R1) ? "" : "-" + item.getData().getData());
break;
case "looking":
case "lookingat":
Block block = Util.getTargetBlock(player, 30);
key = CMIMaterial.get(block).getName() + (Version.isCurrentEqualOrHigher(Version.v1_13_R1) ? "" : "-" + block.getData());
break;
default:
break;
}
String type = keyValue.getType(), KeyValues keyValue = Jobs.getConfigManager().getKeyValue(key, actionT, job.getName());
subType = keyValue.getSubType(), if (keyValue == null)
meta = keyValue.getMeta(); return false;
int id = keyValue.getId();
double income = 0D, String type = keyValue.getType(),
points = 0D, subType = keyValue.getSubType(),
experience = 0D; meta = keyValue.getMeta();
int id = keyValue.getId();
int fromlevel = 1; double income = 0D,
int untilLevel = -1; points = 0D,
experience = 0D;
JobInfo jInfo = new JobInfo(actionT, id, meta, type + subType, income, job.getMoneyEquation(), experience, job.getXpEquation(), job.getPointsEquation(), points, fromlevel, int fromlevel = 1;
untilLevel, job.getName() + "/" + actionT.getName() + "/" + (type + subType).replace(":", "-")); int untilLevel = -1;
for (JobInfo info : job.getJobInfo(actionT)) { JobInfo jInfo = new JobInfo(actionT, id, meta, type + subType, income, job.getMoneyEquation(), experience, job.getXpEquation(), job.getPointsEquation(), points, fromlevel,
if (info.getName().equalsIgnoreCase(jInfo.getName())) { untilLevel, job.getName() + "/" + actionT.getName() + "/" + (type + subType).replace(":", "-"));
player.performCommand("jobs editjobs list " + job.getName() + " " + actionT.getName() + " " + jInfo.getName());
return true;
}
}
action.add(jInfo); for (JobInfo info : job.getJobInfo(actionT)) {
player.performCommand("jobs editjobs list " + job.getName() + " " + actionT.getName() + " " + jInfo.getName()); if (info.getName().equalsIgnoreCase(jInfo.getName())) {
player.performCommand("jobs editjobs list " + job.getName() + " " + actionT.getName() + " " + jInfo.getName());
return true;
}
}
Jobs.getConfigManager().changeJobsSettings(args[1], jInfo.getConfigPath() + "/income", 0); action.add(jInfo);
Jobs.getConfigManager().changeJobsSettings(args[1], jInfo.getConfigPath() + "/points", 0); player.performCommand("jobs editjobs list " + job.getName() + " " + actionT.getName() + " " + jInfo.getName());
Jobs.getConfigManager().changeJobsSettings(args[1], jInfo.getConfigPath() + "/experience", 0);
Util.getJobsEditorMap().remove(player.getUniqueId()); Jobs.getConfigManager().changeJobsSettings(args[1], jInfo.getConfigPath() + "/income", 0);
return true; Jobs.getConfigManager().changeJobsSettings(args[1], jInfo.getConfigPath() + "/points", 0);
} Jobs.getConfigManager().changeJobsSettings(args[1], jInfo.getConfigPath() + "/experience", 0);
break; Util.getJobsEditorMap().remove(player.getUniqueId());
default: return true;
break; }
}
return true; break;
default:
break;
}
return true;
} }
private static void showPath(Player player, Job job, ActionType action, JobInfo jInfo) { private static void showPath(Player player, Job job, ActionType action, JobInfo jInfo) {
RawMessage rm = new RawMessage(); RawMessage rm = new RawMessage();
rm.addText(Jobs.getLanguage().getMessage("command.editjobs.help.list.job")).addHover("&eJob list") rm.addText(Jobs.getLanguage().getMessage("command.editjobs.help.list.job")).addHover("&eJob list")
.addCommand("jobs editjobs").show(player); .addCommand("jobs editjobs").show(player);
if (job != null) { if (job != null) {
rm = new RawMessage(); rm = new RawMessage();
rm.addText(Jobs.getLanguage().getMessage("command.editjobs.help.list.jobs", "%jobname%", job.getDisplayName())) rm.addText(Jobs.getLanguage().getMessage("command.editjobs.help.list.jobs", "%jobname%", job.getDisplayName()))
.addHover(job.getName()).addCommand("jobs editjobs list " + job.getName()); .addHover(job.getName()).addCommand("jobs editjobs list " + job.getName());
rm.show(player); rm.show(player);
} }
if (action != null && job != null) { if (action != null && job != null) {
rm = new RawMessage(); rm = new RawMessage();
rm.addText(Jobs.getLanguage().getMessage("command.editjobs.help.list.actions", "%actionname%", action.getName())) rm.addText(Jobs.getLanguage().getMessage("command.editjobs.help.list.actions", "%actionname%", action.getName()))
.addHover(action.getName()).addCommand("jobs editjobs list " + job.getName() + " " + action.getName() + " 1") .addHover(action.getName()).addCommand("jobs editjobs list " + job.getName() + " " + action.getName() + " 1")
.show(player); .show(player);
} }
if (action != null && job != null && jInfo != null) { if (action != null && job != null && jInfo != null) {
rm = new RawMessage(); rm = new RawMessage();
String materialName = jInfo.getName().toLowerCase().replace('_', ' '); String materialName = jInfo.getName().toLowerCase().replace('_', ' ');
materialName = Character.toUpperCase(materialName.charAt(0)) + materialName.substring(1); materialName = Character.toUpperCase(materialName.charAt(0)) + materialName.substring(1);
materialName = Jobs.getNameTranslatorManager().translate(materialName, jInfo); materialName = Jobs.getNameTranslatorManager().translate(materialName, jInfo);
materialName = CMIChatColor.translate(materialName); materialName = CMIChatColor.translate(materialName);
rm.addText(Jobs.getLanguage().getMessage("command.editjobs.help.list.material", "%materialname%", jInfo.getName())) rm.addText(Jobs.getLanguage().getMessage("command.editjobs.help.list.material", "%materialname%", jInfo.getName()))
.addHover(jInfo.getName()).addCommand("jobs editjobs list " + job.getName() + " " + action.getName() .addHover(jInfo.getName()).addCommand("jobs editjobs list " + job.getName() + " " + action.getName()
+ " " + materialName).show(player); + " " + materialName).show(player);
} }
} }
} }

View File

@ -5,6 +5,7 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.container.PlayerPoints; import com.gamingmesh.jobs.container.PlayerPoints;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC; import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Messages.CMIMessages; import net.Zrips.CMILib.Messages.CMIMessages;
@ -13,55 +14,54 @@ public class editpoints implements Cmd {
@Override @Override
public Boolean perform(Jobs plugin, CommandSender sender, String[] args) { public Boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (args.length != 3) { if (args.length != 3) {
Jobs.getCommandManager().sendUsage(sender, "editpoints"); return false;
return true; }
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[1]); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[1]);
if (jPlayer == null) { if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[1])); Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args[1]);
return true; return true;
} }
double amount = 0; double amount = 0;
try { try {
amount = Double.parseDouble(args[2]); amount = Double.parseDouble(args[2]);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
CMIMessages.sendMessage(sender, LC.info_UseInteger); CMIMessages.sendMessage(sender, LC.info_UseInteger);
return true; return false;
} }
PlayerPoints pointInfo = jPlayer.getPointsData(); PlayerPoints pointInfo = jPlayer.getPointsData();
switch (args[0].toLowerCase()) { switch (args[0].toLowerCase()) {
case "take": case "take":
pointInfo.takePoints(amount); pointInfo.takePoints(amount);
sender.sendMessage(Jobs.getLanguage().getMessage("command.editpoints.output.take", Language.sendMessage(sender, "command.editpoints.output.take",
"%playername%", jPlayer.getName(), "%playername%", jPlayer.getName(),
"%playerdisplayname%", jPlayer.getDisplayName(), "%playerdisplayname%", jPlayer.getDisplayName(),
"%amount%", amount, "%amount%", amount,
"%total%", (int) (pointInfo.getCurrentPoints() * 100) / 100D)); "%total%", (int) (pointInfo.getCurrentPoints() * 100) / 100D);
break; break;
case "add": case "add":
pointInfo.addPoints(amount); pointInfo.addPoints(amount);
sender.sendMessage(Jobs.getLanguage().getMessage("command.editpoints.output.add", Language.sendMessage(sender, "command.editpoints.output.add",
"%playername%", jPlayer.getName(), "%playername%", jPlayer.getName(),
"%playerdisplayname%", jPlayer.getDisplayName(), "%playerdisplayname%", jPlayer.getDisplayName(),
"%amount%", amount, "%amount%", amount,
"%total%", (int) (pointInfo.getCurrentPoints() * 100) / 100D)); "%total%", (int) (pointInfo.getCurrentPoints() * 100) / 100D);
break; break;
case "set": case "set":
pointInfo.setPoints(amount); pointInfo.setPoints(amount);
sender.sendMessage(Jobs.getLanguage().getMessage("command.editpoints.output.set", Language.sendMessage(sender, "command.editpoints.output.set",
"%playername%", jPlayer.getName(), "%playername%", jPlayer.getName(),
"%playerdisplayname%", jPlayer.getDisplayName(), "%playerdisplayname%", jPlayer.getDisplayName(),
"%amount%", amount)); "%amount%", amount);
break; break;
default: default:
break; break;
} }
Jobs.getJobsDAO().savePoints(jPlayer); Jobs.getJobsDAO().savePoints(jPlayer);
return true; return true;
} }
} }

View File

@ -28,7 +28,6 @@ import net.Zrips.CMILib.Container.CMIText;
import net.Zrips.CMILib.Container.PageInfo; import net.Zrips.CMILib.Container.PageInfo;
import net.Zrips.CMILib.FileHandler.ConfigReader; import net.Zrips.CMILib.FileHandler.ConfigReader;
import net.Zrips.CMILib.Locale.LC; import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Logs.CMIDebug;
import net.Zrips.CMILib.RawMessages.RawMessage; import net.Zrips.CMILib.RawMessages.RawMessage;
import net.Zrips.CMILib.RawMessages.RawMessageCommand; import net.Zrips.CMILib.RawMessages.RawMessageCommand;
@ -56,6 +55,7 @@ public class editquests implements Cmd {
Action action = null; Action action = null;
// Only informing here and not canceling command
if (!Jobs.getGCManager().DailyQuestsEnabled) { if (!Jobs.getGCManager().DailyQuestsEnabled) {
LC.info_FeatureNotEnabled.sendMessage(sender); LC.info_FeatureNotEnabled.sendMessage(sender);
} }

View File

@ -7,52 +7,50 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
public class employ implements Cmd { public class employ implements Cmd {
@Override @Override
public Boolean perform(Jobs plugin, CommandSender sender, String[] args) { public Boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (args.length < 2) { if (args.length < 2) {
Jobs.getCommandManager().sendUsage(sender, "employ"); return false;
return true; }
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) { if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0])); Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args[0]);
return true; return true;
} }
Job job = Jobs.getJob(args[1]); Job job = Jobs.getJob(args[1]);
if (job == null) { if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job")); Language.sendMessage(sender, "general.error.job");
return true; return true;
} }
if (jPlayer.isInJob(job)) { if (jPlayer.isInJob(job)) {
// already in job message // already in job message
sender.sendMessage(Jobs.getLanguage().getMessage("command.employ.error.alreadyin", "%jobname%", job.getDisplayName())); Language.sendMessage(sender, "command.employ.error.alreadyin", "%jobname%", job.getDisplayName());
return true; return true;
} }
if (job.getMaxSlots() != null && Jobs.getUsedSlots(job) >= job.getMaxSlots()) { if (job.getMaxSlots() != null && Jobs.getUsedSlots(job) >= job.getMaxSlots()) {
String message = Jobs.getLanguage().getMessage("command.employ.error.fullslots"); Language.sendMessage(sender, "command.employ.error.fullslots", "%jobname%", job.getDisplayName());
message = message.replace("%jobname%", job.getDisplayName()); return true;
sender.sendMessage(message); }
return true;
}
try { try {
// check if player already has the job // check if player already has the job
Jobs.getPlayerManager().joinJob(jPlayer, job); Jobs.getPlayerManager().joinJob(jPlayer, job);
Player player = jPlayer.getPlayer(); Player player = jPlayer.getPlayer();
if (player != null) if (player != null)
player.sendMessage(Jobs.getLanguage().getMessage("command.employ.output.target", "%jobname%", job.getDisplayName())); Language.sendMessage(player, "command.employ.output.target", "%jobname%", job.getDisplayName());
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success")); Language.sendMessage(sender, "general.admin.success");
} catch (Throwable e) { } catch (Throwable e) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.error")); Language.sendMessage(sender, "general.admin.error");
} }
return true; return true;
} }
} }

View File

@ -6,43 +6,41 @@ import org.bukkit.entity.EntityType;
import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.Cmd;
import net.Zrips.CMILib.Colors.CMIChatColor; import net.Zrips.CMILib.Container.CMIText;
import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Messages.CMIMessages;
public class entitylist implements Cmd { public class entitylist 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 (args.length != 0) {
Jobs.getCommandManager().sendUsage(sender, "entitylist"); StringBuilder msg = new StringBuilder();
return true; String c1 = "&e";
} String c2 = "&6";
String msg = "", int i = 0;
c1 = "&e", for (EntityType type : EntityType.values()) {
c2 = "&6"; if (!type.isAlive() || !type.isSpawnable())
continue;
int i = 0; i++;
for (EntityType type : EntityType.values()) {
if (!type.isAlive() || !type.isSpawnable())
continue;
i++; if (!msg.isEmpty())
msg.append(LC.info_ListSpliter.getLocale());
if (!msg.isEmpty()) if (i > 1) {
msg += ", "; msg.append(c1);
i = 0;
} else {
msg.append(c2);
}
if (i > 1) { msg.append(CMIText.firstToUpperCase(type.name()));
msg += c1; }
i = 0;
} else {
msg += c2;
}
msg += type.name().toLowerCase(); CMIMessages.sendMessage(sender, msg.toString());
} return true;
sender.sendMessage(CMIChatColor.translate(msg));
return true;
} }
} }

View File

@ -24,8 +24,7 @@ public class exp implements Cmd {
public Boolean perform(Jobs plugin, CommandSender sender, String[] args) { public Boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (args.length < 4) { if (args.length < 4) {
Jobs.getCommandManager().sendUsage(sender, "exp"); return false;
return true;
} }
boolean silent = false; boolean silent = false;
@ -120,20 +119,20 @@ public class exp implements Cmd {
Player player = jPlayer.getPlayer(); Player player = jPlayer.getPlayer();
if (player == null) { if (player == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.give.output.notonline")); Language.sendMessage(sender, "general.give.output.notonline");
return true; return true;
} }
if (!silent) if (!silent)
player.sendMessage(Jobs.getLanguage().getMessage("command.exp.output.target", "%jobname%", job.getDisplayName(), "%level%", prog.getLevelFormatted(), "%exp%", prog Language.sendMessage(player, "command.exp.output.target", "%jobname%", job.getDisplayName(), "%level%", prog.getLevelFormatted(), "%exp%", prog
.getExperience())); .getExperience());
if (!silentAdmin) if (!silentAdmin)
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success")); Language.sendMessage(sender, "general.admin.success");
} catch (Exception e) { } catch (Exception e) {
if (!silentAdmin) if (!silentAdmin)
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.error")); Language.sendMessage(sender, "general.admin.error");
e.printStackTrace(); e.printStackTrace();
} }
return true; return true;

View File

@ -10,51 +10,56 @@ import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.ExploreChunk; import com.gamingmesh.jobs.container.ExploreChunk;
import com.gamingmesh.jobs.container.ExploreRegion; import com.gamingmesh.jobs.container.ExploreRegion;
import com.gamingmesh.jobs.container.PlayerInfo; import com.gamingmesh.jobs.container.PlayerInfo;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC;
public class explored implements Cmd { public class explored implements Cmd {
@Override @Override
public Boolean perform(Jobs plugin, CommandSender sender, String[] args) { public Boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (!(sender instanceof Player)) if (!(sender instanceof Player)) {
return false; LC.info_Ingame.sendMessage(sender);
return null;
}
Player player = (Player) sender; Player player = (Player) sender;
Map<String, ExploreRegion> exploreRegion = Jobs.getExploreManager().getWorlds().get(player.getWorld().getName()); Map<String, ExploreRegion> exploreRegion = Jobs.getExploreManager().getWorlds().get(player.getWorld().getName());
if (exploreRegion == null) { if (exploreRegion == null) {
player.sendMessage(Jobs.getLanguage().getMessage("command.explored.error.noexplore")); Language.sendMessage(sender, "command.explored.error.noexplore");
return true; return true;
} }
int RegionX = (int) Math.floor(player.getLocation().getChunk().getX() / 32D); int RegionX = (int) Math.floor(player.getLocation().getChunk().getX() / 32D);
int RegionZ = (int) Math.floor(player.getLocation().getChunk().getZ() / 32D); int RegionZ = (int) Math.floor(player.getLocation().getChunk().getZ() / 32D);
ExploreRegion region = exploreRegion.get(RegionX + ":" + RegionZ); ExploreRegion region = exploreRegion.get(RegionX + ":" + RegionZ);
if (region == null) { if (region == null) {
player.sendMessage(Jobs.getLanguage().getMessage("command.explored.error.noexplore")); Language.sendMessage(sender, "command.explored.error.noexplore");
return true; return true;
} }
ExploreChunk chunk = region.getChunk(player.getLocation().getChunk()); ExploreChunk chunk = region.getChunk(player.getLocation().getChunk());
if (chunk == null) { if (chunk == null) {
player.sendMessage(Jobs.getLanguage().getMessage("command.explored.error.noexplore")); Language.sendMessage(sender, "command.explored.error.noexplore");
return true; return true;
} }
if (Jobs.getGCManager().ExploreCompact && chunk.isFullyExplored()) { if (Jobs.getGCManager().ExploreCompact && chunk.isFullyExplored()) {
player.sendMessage(Jobs.getLanguage().getMessage("command.explored.fullExplore")); Language.sendMessage(sender, "command.explored.fullExplore");
return true; return true;
} }
java.util.List<Integer> players = chunk.getPlayers(); java.util.List<Integer> players = chunk.getPlayers();
for (int i = 0; i < players.size(); i++) { for (int i = 0; i < players.size(); i++) {
PlayerInfo ji = Jobs.getPlayerManager().getPlayerInfo(players.get(i)); PlayerInfo ji = Jobs.getPlayerManager().getPlayerInfo(players.get(i));
if (ji != null) if (ji != null)
player.sendMessage(Jobs.getLanguage().getMessage("command.explored.list", "%place%", i + 1, "%playername%", ji.getName())); Language.sendMessage(sender, "command.explored.list", "%place%", i + 1, "%playername%", ji.getName());
} }
player.sendMessage(Jobs.getLanguage().getMessage("general.info.separator")); Language.sendMessage(sender, "general.info.separator");
return true; return true;
} }
} }

View File

@ -7,41 +7,41 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
public class fire implements Cmd { public class fire 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 (args.length < 2) { if (args.length < 2) {
Jobs.getCommandManager().sendUsage(sender, "fire"); return false;
return true; }
}
Job job = Jobs.getJob(args[1]); Job job = Jobs.getJob(args[1]);
if (job == null) { if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job")); Language.sendMessage(sender, "general.error.job");
return true; return true;
} }
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) { if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0])); Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args[0]);
return true; return true;
} }
if (!jPlayer.isInJob(job)) { if (!jPlayer.isInJob(job)) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.fire.error.nojob", "%jobname%", job.getDisplayName())); Language.sendMessage(sender, "command.fire.error.nojob", "%jobname%", job.getDisplayName());
return true; return true;
} }
if (Jobs.getPlayerManager().leaveJob(jPlayer, job)) { if (Jobs.getPlayerManager().leaveJob(jPlayer, job)) {
Player player = jPlayer.getPlayer(); Player player = jPlayer.getPlayer();
if (player != null) if (player != null)
player.sendMessage(Jobs.getLanguage().getMessage("command.fire.output.target", "%jobname%", job.getDisplayName())); Language.sendMessage(player, "command.fire.output.target", "%jobname%", job.getDisplayName());
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success")); Language.sendMessage(sender, "general.admin.success");
} }
return true; return true;
} }
} }

View File

@ -8,6 +8,7 @@ import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.JobProgression; import com.gamingmesh.jobs.container.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.dao.JobsDAO.DBTables; import com.gamingmesh.jobs.dao.JobsDAO.DBTables;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC; import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Messages.CMIMessages; import net.Zrips.CMILib.Messages.CMIMessages;
@ -16,49 +17,48 @@ public class fireall 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 (args.length < 1) { if (args.length < 1) {
Jobs.getCommandManager().sendUsage(sender, "fireall"); return false;
return true; }
}
if (args[0].equalsIgnoreCase("all")) { if (args[0].equalsIgnoreCase("all")) {
if (sender instanceof Player) { if (sender instanceof Player) {
CMIMessages.sendMessage(sender, LC.info_FromConsole); CMIMessages.sendMessage(sender, LC.info_FromConsole);
return true; return true;
} }
Jobs.getDBManager().getDB().truncate(DBTables.JobsTable.getTableName()); Jobs.getDBManager().getDB().truncate(DBTables.JobsTable.getTableName());
for (JobsPlayer one : Jobs.getPlayerManager().getPlayersCache().values()) { for (JobsPlayer one : Jobs.getPlayerManager().getPlayersCache().values()) {
for (JobProgression job : one.getJobProgression()) { for (JobProgression job : one.getJobProgression()) {
Jobs.getJobsDAO().recordToArchive(one, job.getJob()); Jobs.getJobsDAO().recordToArchive(one, job.getJob());
} }
one.leaveAllJobs(); one.leaveAllJobs();
// No need to save as we are clearing database with more efficient method // No need to save as we are clearing database with more efficient method
one.setSaved(true); one.setSaved(true);
} }
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success")); Language.sendMessage(sender, "general.admin.success");
return true; return true;
} }
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) { if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0])); Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args[0]);
return true; return true;
} }
if (jPlayer.progression.isEmpty()) { if (jPlayer.progression.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.fireall.error.nojobs")); Language.sendMessage(sender, "command.fireall.error.nojobs");
return true; return true;
} }
Jobs.getPlayerManager().leaveAllJobs(jPlayer); Jobs.getPlayerManager().leaveAllJobs(jPlayer);
Player player = jPlayer.getPlayer(); Player player = jPlayer.getPlayer();
if (player != null) if (player != null)
player.sendMessage(Jobs.getLanguage().getMessage("command.fireall.output.target")); Language.sendMessage(player, "command.fireall.output.target");
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success")); Language.sendMessage(sender, "general.admin.success");
return true; return true;
} }
} }

View File

@ -11,96 +11,98 @@ import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobItems; import com.gamingmesh.jobs.container.JobItems;
import com.gamingmesh.jobs.container.JobLimitedItems; import com.gamingmesh.jobs.container.JobLimitedItems;
import com.gamingmesh.jobs.i18n.Language;
import com.gamingmesh.jobs.stuff.GiveItem; import com.gamingmesh.jobs.stuff.GiveItem;
public class give implements Cmd { public class give implements Cmd {
private enum actions { private enum actions {
items, limiteditems; items, limiteditems;
public static actions getByname(String name) {
for (actions one : actions.values()) { public static actions getByname(String name) {
if (one.name().equalsIgnoreCase(name)) for (actions one : actions.values()) {
return one; if (one.name().equalsIgnoreCase(name))
} return one;
return null; }
} return null;
}
} }
@Override @Override
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) { public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
Player player = null; Player player = null;
Job job = null; Job job = null;
actions name = null; actions name = null;
String itemName = null; String itemName = null;
for (String one : args) { for (String one : args) {
if (player == null) { if (player == null) {
player = Bukkit.getPlayer(one); player = Bukkit.getPlayer(one);
if (player != null) if (player != null)
continue; continue;
} }
if (job == null) { if (job == null) {
job = Jobs.getJob(one); job = Jobs.getJob(one);
if (job != null) if (job != null)
continue; continue;
} }
if (name == null) { if (name == null) {
name = actions.getByname(one); name = actions.getByname(one);
if (name != null) if (name != null)
continue; continue;
} }
itemName = one; itemName = one;
} }
if (player == null && sender instanceof Player) if (player == null && sender instanceof Player)
player = (Player) sender; player = (Player) sender;
if (player == null) { if (player == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.give.output.notonline")); Language.sendMessage(sender, "command.give.output.notonline");
return true; return null;
} }
if (name == null) if (name == null)
name = actions.items; name = actions.items;
if (itemName == null) { if (itemName == null) {
Jobs.getCommandManager().sendUsage(sender, "give"); Jobs.getCommandManager().sendUsage(sender, "give");
return true; return true;
} }
switch (name) { switch (name) {
case items: case items:
JobItems jItem = ItemBoostManager.getItemByKey(itemName); JobItems jItem = ItemBoostManager.getItemByKey(itemName);
ItemStack item = jItem == null ? null : jItem.getItemStack(player); ItemStack item = jItem == null ? null : jItem.getItemStack(player);
if (item == null) { if (item == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.give.output.noitem")); Language.sendMessage(sender, "command.give.output.noitem");
return true; return true;
} }
GiveItem.giveItemForPlayer(player, item); GiveItem.giveItemForPlayer(player, item);
break; break;
case limiteditems: case limiteditems:
if (job == null) { if (job == null) {
Jobs.getCommandManager().sendUsage(sender, "give"); Jobs.getCommandManager().sendUsage(sender, "give");
return true; return true;
} }
JobLimitedItems jLItem = job.getLimitedItems().get(itemName.toLowerCase()); JobLimitedItems jLItem = job.getLimitedItems().get(itemName.toLowerCase());
ItemStack limItem = jLItem == null ? null : jLItem.getItemStack(player); ItemStack limItem = jLItem == null ? null : jLItem.getItemStack(player);
if (limItem == null) { if (limItem == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.give.output.noitem")); Language.sendMessage(sender, "command.give.output.noitem");
return true; return true;
} }
GiveItem.giveItemForPlayer(player, limItem); GiveItem.giveItemForPlayer(player, limItem);
break; break;
default: default:
break; break;
} }
return true; return true;
} }
} }

View File

@ -15,6 +15,7 @@ import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.container.Log; import com.gamingmesh.jobs.container.Log;
import com.gamingmesh.jobs.container.LogAmounts; import com.gamingmesh.jobs.container.LogAmounts;
import com.gamingmesh.jobs.container.PlayerInfo; import com.gamingmesh.jobs.container.PlayerInfo;
import com.gamingmesh.jobs.i18n.Language;
import com.gamingmesh.jobs.stuff.Sorting; import com.gamingmesh.jobs.stuff.Sorting;
import net.Zrips.CMILib.Time.CMITimeManager; import net.Zrips.CMILib.Time.CMITimeManager;
@ -23,100 +24,99 @@ public class glog 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 (args.length != 0) { if (args.length != 0) {
Jobs.getCommandManager().sendUsage(sender, "glog"); return false;
return true; }
}
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() { Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
Map<LogAmounts, Double> unsortMap = new HashMap<>(); Map<LogAmounts, Double> unsortMap = new HashMap<>();
int time = CMITimeManager.timeInInt(); int time = CMITimeManager.timeInInt();
for (Integer oneP : Jobs.getJobsDAO().getLognameList(time, time)) { for (Integer oneP : Jobs.getJobsDAO().getLognameList(time, time)) {
PlayerInfo info = Jobs.getPlayerManager().getPlayerInfo(oneP); PlayerInfo info = Jobs.getPlayerManager().getPlayerInfo(oneP);
if (info == null) if (info == null)
continue; continue;
String name = info.getName(); String name = info.getName();
if (name == null) if (name == null)
continue; continue;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(info.getUuid()); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(info.getUuid());
if (jPlayer == null) if (jPlayer == null)
continue; continue;
Map<String, Log> logList = jPlayer.getLog(); Map<String, Log> logList = jPlayer.getLog();
if (logList == null || logList.isEmpty()) if (logList == null || logList.isEmpty())
continue; continue;
for (Log l : logList.values()) { for (Log l : logList.values()) {
for (LogAmounts amounts : l.getAmountList().values()) { for (LogAmounts amounts : l.getAmountList().values()) {
amounts.setUsername(name); amounts.setUsername(name);
amounts.setAction(l.getActionType()); amounts.setAction(l.getActionType());
unsortMap.put(amounts, amounts.get(CurrencyType.MONEY)); unsortMap.put(amounts, amounts.get(CurrencyType.MONEY));
} }
} }
} }
unsortMap = Sorting.sortDoubleDESCByLog(unsortMap); unsortMap = Sorting.sortDoubleDESCByLog(unsortMap);
if (unsortMap.isEmpty()) { if (unsortMap.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.glog.output.nodata")); Language.sendMessage(sender, "command.glog.output.nodata");
return; return;
} }
int count = 1, max = 10; int count = 1, max = 10;
double totalMoney = 0, double totalMoney = 0,
totalExp = 0, totalExp = 0,
totalPoints = 0; totalPoints = 0;
sender.sendMessage(Jobs.getLanguage().getMessage("command.glog.output.topline")); Language.sendMessage(sender, "command.glog.output.topline");
for (LogAmounts info : unsortMap.keySet()) { for (LogAmounts info : unsortMap.keySet()) {
double money = info.get(CurrencyType.MONEY); double money = info.get(CurrencyType.MONEY);
totalMoney += money; totalMoney += money;
String moneyS = ""; String moneyS = "";
if (money != 0D) if (money != 0D)
moneyS = Jobs.getLanguage().getMessage("command.glog.output.money", "%amount%", money); moneyS = Jobs.getLanguage().getMessage("command.glog.output.money", "%amount%", money);
double exp = info.get(CurrencyType.EXP); double exp = info.get(CurrencyType.EXP);
totalExp += exp; totalExp += exp;
String expS = ""; String expS = "";
if (exp != 0D) if (exp != 0D)
expS = Jobs.getLanguage().getMessage("command.glog.output.exp", "%amount%", exp); expS = Jobs.getLanguage().getMessage("command.glog.output.exp", "%amount%", exp);
double points = info.get(CurrencyType.POINTS); double points = info.get(CurrencyType.POINTS);
totalPoints += points; totalPoints += points;
String pointsS = ""; String pointsS = "";
if (points != 0D) if (points != 0D)
pointsS = Jobs.getLanguage().getMessage("command.glog.output.points", "%amount%", points); pointsS = Jobs.getLanguage().getMessage("command.glog.output.points", "%amount%", points);
sender.sendMessage(Jobs.getLanguage().getMessage("command.glog.output.ls", Language.sendMessage(sender, "command.glog.output.ls",
"%number%", count, "%number%", count,
"%action%", info.getAction(), "%action%", info.getAction(),
"%item%", info.getItemName().replace(":0", "").replace('_', ' ').toLowerCase(), "%item%", info.getItemName().replace(":0", "").replace('_', ' ').toLowerCase(),
"%qty%", info.getCount(), "%qty%", info.getCount(),
"%money%", moneyS, "%money%", moneyS,
"%exp%", expS, "%exp%", expS,
"%points%", pointsS)); "%points%", pointsS);
count++; count++;
if (count > max) if (count > max)
break; break;
} }
NumberFormat format = NumberFormat.getInstance(Locale.ENGLISH); NumberFormat format = NumberFormat.getInstance(Locale.ENGLISH);
sender.sendMessage(Jobs.getLanguage().getMessage("command.glog.output.totalIncomes", "%money%", format.format(totalMoney), Language.sendMessage(sender, "command.glog.output.totalIncomes", "%money%", format.format(totalMoney),
"%exp%", format.format(totalExp), "%points%", format.format(totalPoints))); "%exp%", format.format(totalExp), "%points%", format.format(totalPoints));
sender.sendMessage(Jobs.getLanguage().getMessage("command.glog.output.bottomline")); Language.sendMessage(sender, "command.glog.output.bottomline");
} }
}); });
return true; return true;
} }
} }

View File

@ -8,53 +8,53 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
public class grantxp implements Cmd { public class grantxp 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 (args.length < 3) { if (args.length < 3) {
Jobs.getCommandManager().sendUsage(sender, "grantxp"); return false;
return true; }
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) { if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0])); Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args[0]);
return true; return true;
} }
Job job = Jobs.getJob(args[1]); Job job = Jobs.getJob(args[1]);
if (job == null) { if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job")); Language.sendMessage(sender, "general.error.job");
return true; return true;
} }
double xpGained; double xpGained;
try { try {
xpGained = Double.parseDouble(args[2]); xpGained = Double.parseDouble(args[2]);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.error")); Language.sendMessage(sender, "general.admin.error");
return true; return true;
} }
if (xpGained <= 0) { if (xpGained <= 0) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.error")); Language.sendMessage(sender, "general.admin.error");
return true; return true;
} }
// check if player already has the job // check if player already has the job
if (jPlayer.isInJob(job)) { if (jPlayer.isInJob(job)) {
Jobs.getPlayerManager().addExperience(jPlayer, job, xpGained); Jobs.getPlayerManager().addExperience(jPlayer, job, xpGained);
Player player = jPlayer.getPlayer(); Player player = jPlayer.getPlayer();
if (player != null) { if (player != null) {
String message = Jobs.getLanguage().getMessage("command.grantxp.output.target", String message = Jobs.getLanguage().getMessage("command.grantxp.output.target",
"%jobname%", job.getDisplayName(), "%jobname%", job.getDisplayName(),
"%xpgained%", xpGained); "%xpgained%", xpGained);
player.sendMessage(message); player.sendMessage(message);
} }
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success")); Language.sendMessage(sender, "general.admin.success");
} }
return true; return true;
} }
} }

View File

@ -10,6 +10,7 @@ import org.bukkit.scoreboard.DisplaySlot;
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.TopList; import com.gamingmesh.jobs.container.TopList;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Container.PageInfo; import net.Zrips.CMILib.Container.PageInfo;
import net.Zrips.CMILib.Locale.LC; import net.Zrips.CMILib.Locale.LC;
@ -22,12 +23,11 @@ public class gtop implements Cmd {
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)) {
CMIMessages.sendMessage(sender, LC.info_Ingame); CMIMessages.sendMessage(sender, LC.info_Ingame);
return false; return null;
} }
if (args.length > 1) { if (args.length > 1) {
Jobs.getCommandManager().sendUsage(sender, "gtop"); return false;
return true;
} }
Player player = (Player) sender; Player player = (Player) sender;
@ -54,24 +54,24 @@ public class gtop implements Cmd {
List<TopList> FullList = Jobs.getJobsDAO().getGlobalTopList(pi.getStart()); List<TopList> FullList = Jobs.getJobsDAO().getGlobalTopList(pi.getStart());
if (FullList.isEmpty()) { if (FullList.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.gtop.error.nojob")); Language.sendMessage(sender, "command.gtop.error.nojob");
return true; return true;
} }
if (!Jobs.getGCManager().ShowToplistInScoreboard) { if (!Jobs.getGCManager().ShowToplistInScoreboard) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.gtop.output.topline", "%amount%", amount)); Language.sendMessage(sender, "command.gtop.output.topline", "%amount%", amount);
int i = 0; int i = 0;
for (TopList One : FullList) { for (TopList One : FullList) {
if (i >= amount) if (i >= amount)
break; break;
sender.sendMessage(Jobs.getLanguage().getMessage("command.gtop.output.list", Language.sendMessage(sender, "command.gtop.output.list",
"%number%", pi.getPositionForOutput(i), "%number%", pi.getPositionForOutput(i),
"%playername%", One.getPlayerInfo().getName(), "%playername%", One.getPlayerInfo().getName(),
"%playerdisplayname%", One.getPlayerInfo().getDisplayName(), "%playerdisplayname%", One.getPlayerInfo().getDisplayName(),
"%level%", One.getLevel(), "%level%", One.getLevel(),
"%exp%", One.getExp())); "%exp%", One.getExp());
++i; ++i;
} }
} else { } else {

View File

@ -8,6 +8,7 @@ import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.ActionType; 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;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC; import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Messages.CMIMessages; import net.Zrips.CMILib.Messages.CMIMessages;
@ -17,60 +18,59 @@ 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)) {
CMIMessages.sendMessage(sender, LC.info_Ingame); CMIMessages.sendMessage(sender, LC.info_Ingame);
return false; return null;
} }
if (args.length < 1) { if (args.length < 1) {
Jobs.getCommandManager().sendUsage(sender, "info"); Jobs.getCommandManager().sendValidActions(sender);
Jobs.getCommandManager().sendValidActions(sender); return false;
return true; }
}
Player pSender = (Player) sender; Player pSender = (Player) sender;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender);
if (jPlayer == null) { if (jPlayer == null) {
pSender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", pSender.getName())); Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", pSender.getName());
return true; return true;
} }
Job job = Jobs.getJob(args[0]); Job job = Jobs.getJob(args[0]);
if (job == null) { if (job == null) {
pSender.sendMessage(Jobs.getLanguage().getMessage("general.error.job")); Language.sendMessage(sender, "general.error.job");
return true; return true;
} }
if (Jobs.getGCManager().hideJobsInfoWithoutPermission && !Jobs.getCommandManager().hasJobPermission(pSender, job)) { if (Jobs.getGCManager().hideJobsInfoWithoutPermission && !Jobs.getCommandManager().hasJobPermission(pSender, job)) {
CMIMessages.sendMessage(pSender, LC.info_NoPermission); CMIMessages.sendMessage(pSender, LC.info_NoPermission);
return true; return true;
} }
if (Jobs.getGCManager().jobsInfoOpensBrowse) { if (Jobs.getGCManager().jobsInfoOpensBrowse) {
plugin.getGUIManager().openJobsBrowseGUI(pSender, job, true); plugin.getGUIManager().openJobsBrowseGUI(pSender, job, true);
return true; return true;
} }
int page = 1; int page = 1;
String type = null; String type = null;
for (int i = 1; i < args.length; i++) { for (int i = 1; i < args.length; i++) {
String one = args[i]; String one = args[i];
if (type == null) { if (type == null) {
ActionType t = ActionType.getByName(one); ActionType t = ActionType.getByName(one);
if (t != null) { if (t != null) {
type = t.getName(); type = t.getName();
continue; continue;
} }
} }
try { try {
page = Integer.parseInt(args[i]); page = Integer.parseInt(args[i]);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
} }
} }
Jobs.getCommandManager().jobInfoMessage(pSender, jPlayer, job, type, page); Jobs.getCommandManager().jobInfoMessage(pSender, jPlayer, job, type, page);
return true; return true;
} }
} }

View File

@ -30,7 +30,7 @@ public class itembonus implements Cmd {
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)) {
CMIMessages.sendMessage(sender, LC.info_Ingame); CMIMessages.sendMessage(sender, LC.info_Ingame);
return false; return null;
} }
Player player = (Player) sender; Player player = (Player) sender;

View File

@ -22,12 +22,11 @@ public class iteminfo implements Cmd {
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)) {
CMIMessages.sendMessage(sender, LC.info_Ingame); CMIMessages.sendMessage(sender, LC.info_Ingame);
return false; return null;
} }
if (args.length != 0) { if (args.length != 0) {
Jobs.getCommandManager().sendUsage(sender, "iteminfo"); return false;
return true;
} }
ItemStack iih = CMIItemStack.getItemInMainHand((Player) sender); ItemStack iih = CMIItemStack.getItemInMainHand((Player) sender);

View File

@ -8,6 +8,7 @@ import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobProgression; import com.gamingmesh.jobs.container.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC; import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Messages.CMIMessages; import net.Zrips.CMILib.Messages.CMIMessages;
@ -17,76 +18,75 @@ public class join 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)) {
CMIMessages.sendMessage(sender, LC.info_Ingame); CMIMessages.sendMessage(sender, LC.info_Ingame);
return false; return null;
} }
if (args.length != 1 && args.length != 0 && args.length != 2) { if (args.length != 1 && args.length != 0 && args.length != 2) {
Jobs.getCommandManager().sendUsage(sender, "join"); return false;
return true; }
}
if (args.length == 0) { if (args.length == 0) {
plugin.getServer().dispatchCommand(sender, "jobs browse"); plugin.getServer().dispatchCommand(sender, "jobs browse");
return true; return null;
} }
Job job = Jobs.getJob(args[0]); Job job = Jobs.getJob(args[0]);
if (job == null) { if (job == null) {
// job does not exist // job does not exist
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job")); sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true; return true;
} }
if (!Jobs.getCommandManager().hasJobPermission(sender, job)) { if (!Jobs.getCommandManager().hasJobPermission(sender, job)) {
// The player do not have permission to join the job // The player do not have permission to join the job
CMIMessages.sendMessage(sender, LC.info_NoPermission); CMIMessages.sendMessage(sender, LC.info_NoPermission);
return true; return true;
} }
Player pSender = (Player) sender; Player pSender = (Player) sender;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender);
if (jPlayer == null) { // Load player into cache if (jPlayer == null) { // Load player into cache
Jobs.getPlayerManager().playerJoin(pSender); Jobs.getPlayerManager().playerJoin(pSender);
jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender); jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender);
} }
if (jPlayer == null) { if (jPlayer == null) {
return true; return true;
} }
if (jPlayer.isInJob(job)) { if (jPlayer.isInJob(job)) {
// already in job message // already in job message
pSender.sendMessage(Jobs.getLanguage().getMessage("command.join.error.alreadyin", "%jobname%", job.getDisplayName())); Language.sendMessage(sender, "command.join.error.alreadyin", "%jobname%", job.getDisplayName());
return true; return true;
} }
if (job.getMaxSlots() != null && Jobs.getUsedSlots(job) >= job.getMaxSlots()) { if (job.getMaxSlots() != null && Jobs.getUsedSlots(job) >= job.getMaxSlots()) {
pSender.sendMessage(Jobs.getLanguage().getMessage("command.join.error.fullslots", "%jobname%", job.getDisplayName())); Language.sendMessage(sender, "command.join.error.fullslots", "%jobname%", job.getDisplayName());
return true; return true;
} }
if (!job.isIgnoreMaxJobs() && !Jobs.getPlayerManager().getJobsLimit(jPlayer, (short) jPlayer.progression.size())) { if (!job.isIgnoreMaxJobs() && !Jobs.getPlayerManager().getJobsLimit(jPlayer, (short) jPlayer.progression.size())) {
pSender.sendMessage(Jobs.getLanguage().getMessage("command.join.error.maxjobs")); Language.sendMessage(sender, "command.join.error.maxjobs");
return true; return true;
} }
if (args.length == 2 && args[1].equalsIgnoreCase("-needConfirmation")) { if (args.length == 2 && args[1].equalsIgnoreCase("-needConfirmation")) {
new RawMessage().addText(Jobs.getLanguage().getMessage("command.join.confirm", "[jobname]", job.getName())) new RawMessage().addText(Jobs.getLanguage().getMessage("command.join.confirm", "[jobname]", job.getName()))
.addHover(Jobs.getLanguage().getMessage("command.join.confirm", "[jobname]", job.getName())) .addHover(Jobs.getLanguage().getMessage("command.join.confirm", "[jobname]", job.getName()))
.addCommand("jobs join " + job.getName()).show(pSender); .addCommand("jobs join " + job.getName()).show(pSender);
return true; return true;
} }
JobProgression ajp = jPlayer.getArchivedJobProgression(job); JobProgression ajp = jPlayer.getArchivedJobProgression(job);
if (ajp != null && !ajp.canRejoin()) { if (ajp != null && !ajp.canRejoin()) {
pSender.sendMessage(Jobs.getLanguage().getMessage("command.join.error.rejoin", "[time]", ajp.getRejoinTimeMessage())); Language.sendMessage(sender, "command.join.error.rejoin", "[time]", ajp.getRejoinTimeMessage());
return true; return true;
} }
Jobs.getPlayerManager().joinJob(jPlayer, job); Jobs.getPlayerManager().joinJob(jPlayer, job);
pSender.sendMessage(Jobs.getLanguage().getMessage("command.join.success", "%jobname%", job.getDisplayName())); Language.sendMessage(sender, "command.join.success", "%jobname%", job.getDisplayName());
return true; return true;
} }
} }

View File

@ -7,6 +7,7 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
import com.gamingmesh.jobs.stuff.Util; import com.gamingmesh.jobs.stuff.Util;
import net.Zrips.CMILib.Locale.LC; import net.Zrips.CMILib.Locale.LC;
@ -16,50 +17,51 @@ public class leave 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)) {
return false; LC.info_Ingame.sendMessage(sender);
return null;
}
if (args.length < 1) { if (args.length < 1) {
Jobs.getCommandManager().sendUsage(sender, "leave"); return false;
return true; }
}
Player pSender = (Player) sender; Player pSender = (Player) sender;
Job job = Jobs.getJob(args[0]); Job job = Jobs.getJob(args[0]);
if (job == null) { if (job == null) {
pSender.sendMessage(Jobs.getLanguage().getMessage("general.error.job")); Language.sendMessage(sender, "general.error.job");
return true; return true;
} }
if (Jobs.getGCManager().UsePerPermissionForLeaving && !pSender.hasPermission("jobs.command.leave." + args[0].toLowerCase())) { if (Jobs.getGCManager().UsePerPermissionForLeaving && !pSender.hasPermission("jobs.command.leave." + args[0].toLowerCase())) {
CMIMessages.sendMessage(pSender, LC.info_NoPermission); CMIMessages.sendMessage(sender, LC.info_NoPermission);
return true; return true;
} }
if (Jobs.getGCManager().EnableConfirmation) { if (Jobs.getGCManager().EnableConfirmation) {
java.util.UUID uuid = pSender.getUniqueId(); java.util.UUID uuid = pSender.getUniqueId();
if (!Util.LEAVECONFIRM.contains(uuid)) { if (!Util.LEAVECONFIRM.contains(uuid)) {
Util.LEAVECONFIRM.add(uuid); Util.LEAVECONFIRM.add(uuid);
plugin.getServer().getScheduler().runTaskLater(plugin, () -> Util.LEAVECONFIRM.remove(uuid), plugin.getServer().getScheduler().runTaskLater(plugin, () -> Util.LEAVECONFIRM.remove(uuid),
20 * Jobs.getGCManager().ConfirmExpiryTime); 20 * Jobs.getGCManager().ConfirmExpiryTime);
pSender.sendMessage(Jobs.getLanguage().getMessage("command.leave.confirmationNeed", "[jobname]", Language.sendMessage(sender, "command.leave.confirmationNeed", "[jobname]",
job.getDisplayName(), "[time]", Jobs.getGCManager().ConfirmExpiryTime)); job.getDisplayName(), "[time]", Jobs.getGCManager().ConfirmExpiryTime);
return true; return true;
} }
Util.LEAVECONFIRM.remove(uuid); Util.LEAVECONFIRM.remove(uuid);
} }
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender);
if (Jobs.getPlayerManager().leaveJob(jPlayer, job)) if (Jobs.getPlayerManager().leaveJob(jPlayer, job))
pSender.sendMessage(Jobs.getLanguage().getMessage("command.leave.success", "%jobname%", job.getDisplayName(), "[jobname]", job.getDisplayName())); Language.sendMessage(sender, "command.leave.success", "%jobname%", job.getDisplayName(), "[jobname]", job.getDisplayName());
else else
pSender.sendMessage(Jobs.getLanguage().getMessage("general.error.job")); Language.sendMessage(sender, "general.error.job");
return true; return true;
} }
} }

View File

@ -9,6 +9,7 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.JobProgression; import com.gamingmesh.jobs.container.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
import com.gamingmesh.jobs.stuff.Util; import com.gamingmesh.jobs.stuff.Util;
import net.Zrips.CMILib.Locale.LC; import net.Zrips.CMILib.Locale.LC;
@ -18,39 +19,39 @@ public class leaveall 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)) {
CMIMessages.sendMessage(sender, LC.info_Ingame); CMIMessages.sendMessage(sender, LC.info_Ingame);
return false; return null;
} }
Player pSender = (Player) sender; Player pSender = (Player) sender;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender);
List<JobProgression> jobs = jPlayer.getJobProgression(); List<JobProgression> jobs = jPlayer.getJobProgression();
if (jobs.isEmpty()) { if (jobs.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.leaveall.error.nojobs")); Language.sendMessage(sender, "command.leaveall.error.nojobs");
return true; return true;
} }
if (Jobs.getGCManager().EnableConfirmation) { if (Jobs.getGCManager().EnableConfirmation) {
java.util.UUID uuid = pSender.getUniqueId(); java.util.UUID uuid = pSender.getUniqueId();
if (!Util.LEAVECONFIRM.contains(uuid)) { if (!Util.LEAVECONFIRM.contains(uuid)) {
Util.LEAVECONFIRM.add(uuid); Util.LEAVECONFIRM.add(uuid);
plugin.getServer().getScheduler().runTaskLater(plugin, () -> Util.LEAVECONFIRM.remove(uuid), plugin.getServer().getScheduler().runTaskLater(plugin, () -> Util.LEAVECONFIRM.remove(uuid),
20 * Jobs.getGCManager().ConfirmExpiryTime); 20 * Jobs.getGCManager().ConfirmExpiryTime);
pSender.sendMessage(Jobs.getLanguage().getMessage("command.leaveall.confirmationNeed", "[time]", Language.sendMessage(pSender, "command.leaveall.confirmationNeed", "[time]",
Jobs.getGCManager().ConfirmExpiryTime)); Jobs.getGCManager().ConfirmExpiryTime);
return true; return true;
} }
Util.LEAVECONFIRM.remove(uuid); Util.LEAVECONFIRM.remove(uuid);
} }
Jobs.getPlayerManager().leaveAllJobs(jPlayer); Jobs.getPlayerManager().leaveAllJobs(jPlayer);
sender.sendMessage(Jobs.getLanguage().getMessage("command.leaveall.success")); Language.sendMessage(sender, "command.leaveall.success");
return true; return true;
} }
} }

View File

@ -9,118 +9,118 @@ import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobProgression; import com.gamingmesh.jobs.container.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
public class level implements Cmd { public class level implements Cmd {
private enum Action { private enum Action {
Set, Add, Take Set, Add, Take
} }
@Override @Override
public Boolean perform(Jobs plugin, CommandSender sender, String[] args) { public Boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (args.length < 4) { if (args.length < 4) {
Jobs.getCommandManager().sendUsage(sender, "level"); return false;
return true; }
}
Action action = Action.Add; Action action = Action.Add;
int amount = 0; int amount = 0;
String playerName = null; String playerName = null;
Job job = null; Job job = null;
for (String one : args) { for (String one : args) {
switch (one.toLowerCase()) { switch (one.toLowerCase()) {
case "set": case "set":
action = Action.Set; action = Action.Set;
continue; continue;
case "add": case "add":
action = Action.Add; action = Action.Add;
continue; continue;
case "take": case "take":
action = Action.Take; action = Action.Take;
continue; continue;
default: default:
break; break;
} }
try { try {
amount = Integer.parseInt(one); amount = Integer.parseInt(one);
continue; continue;
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
} }
if (job == null && (job = Jobs.getJob(one)) != null) if (job == null && (job = Jobs.getJob(one)) != null)
continue; continue;
playerName = one; playerName = one;
} }
if (playerName == null) if (playerName == null)
return false; return false;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(playerName); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(playerName);
if (jPlayer == null) { if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0])); Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args[0]);
return true; return true;
} }
if (job == null) { if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job")); Language.sendMessage(sender, "general.error.job");
return true; return true;
} }
try { try {
// check if player already has the job // check if player already has the job
if (jPlayer.isInJob(job)) { if (jPlayer.isInJob(job)) {
JobProgression prog = jPlayer.getJobProgression(job); JobProgression prog = jPlayer.getJobProgression(job);
int total = 0; int total = 0;
switch (action) { switch (action) {
case Set: case Set:
prog.setLevel(amount); prog.setLevel(amount);
break; break;
case Add: case Add:
int oldLevel = prog.getLevel(); int oldLevel = prog.getLevel();
total = (oldLevel + amount); total = (oldLevel + amount);
if (prog.setLevel(total)) { if (prog.setLevel(total)) {
JobsLevelUpEvent levelUpEvent = new JobsLevelUpEvent(jPlayer, job, prog.getLevel(), JobsLevelUpEvent levelUpEvent = new JobsLevelUpEvent(jPlayer, job, prog.getLevel(),
Jobs.getTitleManager().getTitle(oldLevel, prog.getJob().getName()), Jobs.getTitleManager().getTitle(oldLevel, prog.getJob().getName()),
Jobs.getTitleManager().getTitle(prog.getLevel(), prog.getJob().getName()), Jobs.getTitleManager().getTitle(prog.getLevel(), prog.getJob().getName()),
Jobs.getGCManager().SoundLevelupSound, Jobs.getGCManager().SoundLevelupSound,
Jobs.getGCManager().SoundLevelupVolume, Jobs.getGCManager().SoundLevelupVolume,
Jobs.getGCManager().SoundLevelupPitch, Jobs.getGCManager().SoundLevelupPitch,
Jobs.getGCManager().SoundTitleChangeSound, Jobs.getGCManager().SoundTitleChangeSound,
Jobs.getGCManager().SoundTitleChangeVolume, Jobs.getGCManager().SoundTitleChangeVolume,
Jobs.getGCManager().SoundTitleChangePitch); Jobs.getGCManager().SoundTitleChangePitch);
plugin.getServer().getPluginManager().callEvent(levelUpEvent); plugin.getServer().getPluginManager().callEvent(levelUpEvent);
// If event is cancelled, don't do anything // If event is cancelled, don't do anything
if (levelUpEvent.isCancelled()) if (levelUpEvent.isCancelled())
return true; return true;
} }
break; break;
case Take: case Take:
total = (prog.getLevel() - amount); total = (prog.getLevel() - amount);
prog.setLevel(total); prog.setLevel(total);
break; break;
default: default:
break; break;
} }
Player player = jPlayer.getPlayer(); Player player = jPlayer.getPlayer();
if (player != null) if (player != null)
player.sendMessage(Jobs.getLanguage().getMessage("command.level.output.target", "%jobname%", job.getDisplayName(), "%level%", prog.getLevel(), Language.sendMessage(player, "command.level.output.target", "%jobname%", job.getDisplayName(), "%level%", prog.getLevel(),
"%exp%", String.format(Jobs.getGCManager().getDecimalPlacesExp(), prog.getExperience()))); "%exp%", String.format(Jobs.getGCManager().getDecimalPlacesExp(), prog.getExperience()));
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success")); Language.sendMessage(sender, "general.admin.success");
} else } else
sender.sendMessage(Jobs.getLanguage().getMessage("command.level.error.nojob")); Language.sendMessage(sender, "command.level.error.nojob");
} catch (Exception e) { } catch (Exception e) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.error")); Language.sendMessage(sender, "general.admin.error");
} }
return true; return true;
} }
} }

View File

@ -8,6 +8,7 @@ import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.CurrencyType; import com.gamingmesh.jobs.container.CurrencyType;
import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.economy.PaymentData; import com.gamingmesh.jobs.economy.PaymentData;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC; import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Logs.CMIDebug; import net.Zrips.CMILib.Logs.CMIDebug;
@ -18,57 +19,56 @@ public class limit 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 (args.length != 0 && args.length != 1) { if (args.length != 0 && args.length != 1) {
Jobs.getCommandManager().sendUsage(sender, "limit"); return false;
return true; }
}
JobsPlayer JPlayer = null; JobsPlayer JPlayer = null;
if (args.length >= 1) if (args.length >= 1)
JPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]); JPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
else if (sender instanceof Player) else if (sender instanceof Player)
JPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender); JPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
boolean disabled = true; boolean disabled = true;
for (CurrencyType type : CurrencyType.values()) { for (CurrencyType type : CurrencyType.values()) {
if (Jobs.getGCManager().getLimit(type).isEnabled()) { if (Jobs.getGCManager().getLimit(type).isEnabled()) {
disabled = false; disabled = false;
break; break;
} }
} }
if (disabled) { if (disabled) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.limit.output.notenabled")); Language.sendMessage(sender,"command.limit.output.notenabled");
return true; return true;
} }
if (JPlayer == null) { if (JPlayer == null) {
if (args.length >= 1) if (args.length >= 1)
CMIMessages.sendMessage(sender, LC.info_NoInformation); CMIMessages.sendMessage(sender, LC.info_NoInformation);
else if (!(sender instanceof Player)) else if (!(sender instanceof Player))
Jobs.getCommandManager().sendUsage(sender, "limit"); Jobs.getCommandManager().sendUsage(sender, "limit");
return true; return true;
} }
for (CurrencyType type : CurrencyType.values()) { for (CurrencyType type : CurrencyType.values()) {
if (!Jobs.getGCManager().getLimit(type).isEnabled()) if (!Jobs.getGCManager().getLimit(type).isEnabled())
continue; continue;
PaymentData limit = JPlayer.getPaymentLimit(); PaymentData limit = JPlayer.getPaymentLimit();
if (limit.getLeftTime(type) <= 0) { if (limit.getLeftTime(type) <= 0) {
CMIDebug.d("reset", type); CMIDebug.d("reset", type);
limit.resetLimits(type); limit.resetLimits(type);
} }
if (limit.getLeftTime(type) > 0) { if (limit.getLeftTime(type) > 0) {
String typeName = type.getName().toLowerCase(); String typeName = type.getName().toLowerCase();
sender.sendMessage(Jobs.getLanguage().getMessage("command.limit.output." + typeName + "time", "%time%", CMITimeManager.to24hourShort(limit.getLeftTime(type)))); Language.sendMessage(sender, "command.limit.output." + typeName + "time", "%time%", CMITimeManager.to24hourShort(limit.getLeftTime(type)));
sender.sendMessage(Jobs.getLanguage().getMessage("command.limit.output." + typeName + "Limit", Language.sendMessage(sender, "command.limit.output." + typeName + "Limit",
"%current%", (int) (limit.getAmount(type) * 100) / 100D, "%current%", (int) (limit.getAmount(type) * 100) / 100D,
"%total%", JPlayer.getLimit(type))); "%total%", JPlayer.getLimit(type));
} }
} }
return true; return true;
} }
} }

View File

@ -15,6 +15,7 @@ import com.gamingmesh.jobs.container.CurrencyType;
import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.container.Log; import com.gamingmesh.jobs.container.Log;
import com.gamingmesh.jobs.container.LogAmounts; import com.gamingmesh.jobs.container.LogAmounts;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Container.CMISort; import net.Zrips.CMILib.Container.CMISort;
import net.Zrips.CMILib.Locale.LC; import net.Zrips.CMILib.Locale.LC;
@ -24,113 +25,112 @@ public class log 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) && args.length != 1) { if (!(sender instanceof Player) && args.length != 1) {
CMIMessages.sendMessage(sender, LC.info_Ingame); CMIMessages.sendMessage(sender, LC.info_Ingame);
return false; return null;
} }
if (args.length != 1 && args.length != 0) { if (args.length != 1 && args.length != 0) {
Jobs.getCommandManager().sendUsage(sender, "log"); return false;
return true; }
}
JobsPlayer JPlayer = null; JobsPlayer JPlayer = null;
if (args.length == 0) if (args.length == 0)
JPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender); JPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
else if (args.length == 1) { else if (args.length == 1) {
if (!Jobs.hasPermission(sender, "jobs.command.log.others", true)) if (!Jobs.hasPermission(sender, "jobs.command.log.others", true))
return true; return null;
JPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]); JPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
} }
if (JPlayer == null) { if (JPlayer == null) {
Jobs.getCommandManager().sendUsage(sender, "log"); Jobs.getCommandManager().sendUsage(sender, "log");
return true; return true;
} }
Map<String, Log> logList = JPlayer.getLog(); Map<String, Log> logList = JPlayer.getLog();
if (logList == null || logList.isEmpty()) { if (logList == null || logList.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.log.output.bottomline")); Language.sendMessage(sender, "command.log.output.bottomline");
sender.sendMessage(Jobs.getLanguage().getMessage("command.log.output.nodata")); Language.sendMessage(sender, "command.log.output.nodata");
sender.sendMessage(Jobs.getLanguage().getMessage("command.log.output.bottomline")); Language.sendMessage(sender, "command.log.output.bottomline");
return true; return true;
} }
Map<String, Double> unsortMap = new HashMap<>(); Map<String, Double> unsortMap = new HashMap<>();
for (Log l : logList.values()) { for (Log l : logList.values()) {
for (Entry<String, LogAmounts> oneMap : l.getAmountList().entrySet()) { for (Entry<String, LogAmounts> oneMap : l.getAmountList().entrySet()) {
unsortMap.put(oneMap.getKey(), oneMap.getValue().get(CurrencyType.MONEY)); unsortMap.put(oneMap.getKey(), oneMap.getValue().get(CurrencyType.MONEY));
} }
} }
unsortMap = CMISort.sortDoubleDESC(unsortMap); unsortMap = CMISort.sortDoubleDESC(unsortMap);
if (unsortMap.isEmpty()) { if (unsortMap.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.log.output.nodata")); Language.sendMessage(sender, "command.log.output.nodata");
return true; return true;
} }
int count = 0; int count = 0;
int max = 10; int max = 10;
sender.sendMessage(Jobs.getLanguage().getMessage("command.log.output.topline", "%playername%", JPlayer.getName(), "%playerdisplayname%", JPlayer.getDisplayName())); Language.sendMessage(sender, "command.log.output.topline", "%playername%", JPlayer.getName(), "%playerdisplayname%", JPlayer.getDisplayName());
for (Log one : logList.values()) { for (Log one : logList.values()) {
double totalMoney = 0, totalExp = 0, totalPoints = 0; double totalMoney = 0, totalExp = 0, totalPoints = 0;
for (String oneSorted : unsortMap.keySet()) { for (String oneSorted : unsortMap.keySet()) {
for (Entry<String, LogAmounts> oneMap : one.getAmountList().entrySet()) { for (Entry<String, LogAmounts> oneMap : one.getAmountList().entrySet()) {
if (oneMap.getKey().equalsIgnoreCase(oneSorted)) { if (oneMap.getKey().equalsIgnoreCase(oneSorted)) {
count++; count++;
LogAmounts amounts = oneMap.getValue(); LogAmounts amounts = oneMap.getValue();
double money = amounts.get(CurrencyType.MONEY); double money = amounts.get(CurrencyType.MONEY);
totalMoney = totalMoney + money; totalMoney = totalMoney + money;
String moneyS = ""; String moneyS = "";
if (money != 0D) if (money != 0D)
moneyS = Jobs.getLanguage().getMessage("command.log.output.money", "%amount%", money); moneyS = Jobs.getLanguage().getMessage("command.log.output.money", "%amount%", money);
double exp = amounts.get(CurrencyType.EXP); double exp = amounts.get(CurrencyType.EXP);
totalExp = totalExp + exp; totalExp = totalExp + exp;
String expS = ""; String expS = "";
if (exp != 0D) if (exp != 0D)
expS = Jobs.getLanguage().getMessage("command.log.output.exp", "%amount%", exp); expS = Jobs.getLanguage().getMessage("command.log.output.exp", "%amount%", exp);
double points = amounts.get(CurrencyType.POINTS); double points = amounts.get(CurrencyType.POINTS);
totalPoints = totalPoints + points; totalPoints = totalPoints + points;
String pointsS = ""; String pointsS = "";
if (points != 0D) if (points != 0D)
pointsS = Jobs.getLanguage().getMessage("command.log.output.points", "%amount%", points); pointsS = Jobs.getLanguage().getMessage("command.log.output.points", "%amount%", points);
sender.sendMessage(Jobs.getLanguage().getMessage("command.log.output.ls", Language.sendMessage(sender, "command.log.output.ls",
"%number%", count, "%number%", count,
"%action%", one.getActionType(), "%action%", one.getActionType(),
"%item%", amounts.getItemName().replace(":0", "").replace('_', ' ').toLowerCase(), "%item%", amounts.getItemName().replace(":0", "").replace('_', ' ').toLowerCase(),
"%qty%", amounts.getCount(), "%qty%", amounts.getCount(),
"%money%", moneyS, "%money%", moneyS,
"%exp%", expS, "%exp%", expS,
"%points%", pointsS)); "%points%", pointsS);
break; break;
} }
} }
if (count > max) if (count > max)
break; break;
} }
NumberFormat format = NumberFormat.getInstance(Locale.ENGLISH); NumberFormat format = NumberFormat.getInstance(Locale.ENGLISH);
sender.sendMessage(Jobs.getLanguage().getMessage("command.log.output.totalIncomes", "%money%", format.format(totalMoney), Language.sendMessage(sender, "command.log.output.totalIncomes", "%money%", format.format(totalMoney),
"%exp%", format.format(totalExp), "%points%", format.format(totalPoints))); "%exp%", format.format(totalExp), "%points%", format.format(totalPoints));
if (count > max) if (count > max)
break; break;
} }
sender.sendMessage(Jobs.getLanguage().getMessage("command.log.output.bottomline")); Language.sendMessage(sender, "command.log.output.bottomline");
return true; return true;
} }
} }

View File

@ -27,65 +27,65 @@ public class ownedblocks 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) {
JobsPlayer jPlayer = null; JobsPlayer jPlayer = null;
if (args.length >= 1) { if (args.length >= 1) {
if (!Jobs.hasPermission(sender, "jobs.command.admin.ownedblocks", true)) if (!Jobs.hasPermission(sender, "jobs.command.admin.ownedblocks", true))
return true; return null;
jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]); jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
} else if (sender instanceof Player) } else if (sender instanceof Player)
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender); jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
if (jPlayer == null) { if (jPlayer == null) {
if (args.length >= 1) if (args.length >= 1)
CMIMessages.sendMessage(sender, LC.info_NoInformation); CMIMessages.sendMessage(sender, LC.info_NoInformation);
else else
Jobs.getCommandManager().sendUsage(sender, "ownedblocks"); return false;
return true; return null;
} }
final JobsPlayer jp = jPlayer; final JobsPlayer jp = jPlayer;
RawMessage rm = new RawMessage(); RawMessage rm = new RawMessage();
Snd snd = new Snd(); Snd snd = new Snd();
snd.setSender(sender); snd.setSender(sender);
snd.setTargetName(jp.getName()); snd.setTargetName(jp.getName());
rm.addText(LC.info_PlayerSpliter.getLocale(snd)); rm.addText(LC.info_PlayerSpliter.getLocale(snd));
int i = 0; int i = 0;
for (BlockTypes type : BlockTypes.values()) { for (BlockTypes type : BlockTypes.values()) {
Optional<BlockOwnerShip> ownerShip = plugin.getBlockOwnerShip(type); Optional<BlockOwnerShip> ownerShip = plugin.getBlockOwnerShip(type);
if (!ownerShip.isPresent()) if (!ownerShip.isPresent())
continue; continue;
HashMap<String, blockLoc> records = ownerShip.get().getBlockOwnerShips().get(jp.getUniqueId()); HashMap<String, blockLoc> records = ownerShip.get().getBlockOwnerShips().get(jp.getUniqueId());
if (records == null) if (records == null)
continue; continue;
for (Entry<String, blockLoc> record : records.entrySet()) { for (Entry<String, blockLoc> record : records.entrySet()) {
i++; i++;
rm.addText("\n"); rm.addText("\n");
CMIMaterial material = CMIMaterial.get(type.toString()); CMIMaterial material = CMIMaterial.get(type.toString());
CMILocation loc = CMILocation.fromString(record.getKey(), ":"); CMILocation loc = CMILocation.fromString(record.getKey(), ":");
rm.addText(Jobs.getLanguage().getMessage("command.ownedblocks.output.list", "[place]", i, "[type]", material.getName(), "[location]", LC.Location_Full.getLocale((Location) loc))); rm.addText(Jobs.getLanguage().getMessage("command.ownedblocks.output.list", "[place]", i, "[type]", material.getName(), "[location]", LC.Location_Full.getLocale((Location) loc)));
rm.addHover(Jobs.getLanguage().getMessage("command.ownedblocks.output.listHover", "[location]", LC.Location_Full.getLocale((Location) loc))); rm.addHover(Jobs.getLanguage().getMessage("command.ownedblocks.output.listHover", "[location]", LC.Location_Full.getLocale((Location) loc)));
rm.addCommand(JobsCommands.LABEL + " " + clearownership.class.getSimpleName() + " " + jp.getName() + " " + record.getKey()); rm.addCommand(JobsCommands.LABEL + " " + clearownership.class.getSimpleName() + " " + jp.getName() + " " + record.getKey());
if (record.getValue().isDisabled()) { if (record.getValue().isDisabled()) {
rm.addText(Jobs.getLanguage().getMessage("command.ownedblocks.output.disabled")); rm.addText(Jobs.getLanguage().getMessage("command.ownedblocks.output.disabled"));
rm.addHover(Jobs.getLanguage().getMessage("command.ownedblocks.output.disabledHover")); rm.addHover(Jobs.getLanguage().getMessage("command.ownedblocks.output.disabledHover"));
} }
} }
} }
rm.show(sender); rm.show(sender);
if (i == 0) if (i == 0)
LC.info_nothingToShow.sendMessage(sender); LC.info_nothingToShow.sendMessage(sender);
return true; return true;
} }
} }

View File

@ -8,6 +8,7 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.Placeholders.Placeholder.JobsPlaceHolders; import com.gamingmesh.jobs.Placeholders.Placeholder.JobsPlaceHolders;
import com.gamingmesh.jobs.Placeholders.Placeholder.JobsPlaceholderType; import com.gamingmesh.jobs.Placeholders.Placeholder.JobsPlaceholderType;
import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Container.PageInfo; import net.Zrips.CMILib.Container.PageInfo;
import net.Zrips.CMILib.Messages.CMIMessages; import net.Zrips.CMILib.Messages.CMIMessages;
@ -42,10 +43,10 @@ public class placeholders implements Cmd {
String placeholder = args[1]; String placeholder = args[1];
JobsPlaceholderType type = plugin.getPlaceholderAPIManager().getPlaceHolderType(player, placeholder); JobsPlaceholderType type = plugin.getPlaceholderAPIManager().getPlaceHolderType(player, placeholder);
sender.sendMessage(Jobs.getLanguage().getMessage("command.placeholders.output.parse", Language.sendMessage(sender, "command.placeholders.output.parse",
"[placeholder]", placeholder, "[placeholder]", placeholder,
"[source]", type == null ? "Unknown" : type.name(), "[source]", type == null ? "Unknown" : type.name(),
"[result]", plugin.getPlaceholderAPIManager().updatePlaceHolders(player, placeholder))); "[result]", plugin.getPlaceholderAPIManager().updatePlaceHolders(player, placeholder));
return true; return true;
} }
@ -72,17 +73,6 @@ public class placeholders implements Cmd {
if (plugin.isPlaceholderAPIEnabled()) { if (plugin.isPlaceholderAPIEnabled()) {
hover = place = one.getFull(); hover = place = one.getFull();
} }
// For MVdWPlaceholderAPI
// if (plugin.isMVdWPlaceholderAPIEnabled()) {
// if (!plugin.isPlaceholderAPIEnabled()) {
// place = one.getFull().substring(1, one.getFull().length() - 2);
// place = "{" + place + "}";
// }
// if (hover.isEmpty())
// hover = one.getFull();
// else
// hover += "\n" + "{" + one.getFull().substring(1, one.getFull().length() - 2) + "}";
// }
rm.addText(Jobs.getLanguage().getMessage("command.placeholders.output.list", "[place]", pi.getPositionForOutput(), "[placeholder]", place) + extra) rm.addText(Jobs.getLanguage().getMessage("command.placeholders.output.list", "[place]", pi.getPositionForOutput(), "[placeholder]", place) + extra)
.addHover(hover).addSuggestion(one.getFull()).show(sender); .addHover(hover).addSuggestion(one.getFull()).show(sender);
} }

View File

@ -6,40 +6,40 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
public class playerinfo implements Cmd { public class playerinfo 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 (args.length < 2) { if (args.length < 2) {
Jobs.getCommandManager().sendUsage(sender, "playerinfo"); Jobs.getCommandManager().sendValidActions(sender);
Jobs.getCommandManager().sendValidActions(sender); return false;
return true; }
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) { if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0])); Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args[0]);
return true; return true;
} }
Job job = Jobs.getJob(args[1]); Job job = Jobs.getJob(args[1]);
if (job == null) { if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job")); Language.sendMessage(sender, "general.error.job");
return true; return true;
} }
int page = 1; int page = 1;
String type = ""; String type = "";
if (args.length >= 3) { if (args.length >= 3) {
try { try {
page = Integer.parseInt(args[2]); page = Integer.parseInt(args[2]);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
type = args[2]; type = args[2];
} }
} }
Jobs.getCommandManager().jobInfoMessage(sender, jPlayer, job, type, page); Jobs.getCommandManager().jobInfoMessage(sender, jPlayer, job, type, page);
return true; return true;
} }
} }

View File

@ -7,6 +7,7 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.container.PlayerPoints; import com.gamingmesh.jobs.container.PlayerPoints;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC; import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Messages.CMIMessages; import net.Zrips.CMILib.Messages.CMIMessages;
@ -16,35 +17,34 @@ public class points 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 (args.length != 0 && args.length != 1) { if (args.length != 0 && args.length != 1) {
Jobs.getCommandManager().sendUsage(sender, "points"); return false;
return true; }
}
JobsPlayer jPlayer = null; JobsPlayer jPlayer = null;
if (args.length >= 1) { if (args.length >= 1) {
if (!Jobs.hasPermission(sender, "jobs.command.admin.points", true)) { if (!Jobs.hasPermission(sender, "jobs.command.admin.points", true)) {
return true; return true;
} }
jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]); jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
} else if (sender instanceof Player) { } else if (sender instanceof Player) {
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender); jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
} }
if (jPlayer == null) { if (jPlayer == null) {
if (args.length >= 1) if (args.length >= 1)
CMIMessages.sendMessage(sender, LC.info_NoInformation); CMIMessages.sendMessage(sender, LC.info_NoInformation);
else else
Jobs.getCommandManager().sendUsage(sender, "points"); Jobs.getCommandManager().sendUsage(sender, "points");
return true; return true;
} }
PlayerPoints pointInfo = jPlayer.getPointsData(); PlayerPoints pointInfo = jPlayer.getPointsData();
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.toplineseparator", "%playername%", jPlayer.getName(), "%playerdisplayname%", jPlayer.getDisplayName())); Language.sendMessage(sender, "general.info.toplineseparator", "%playername%", jPlayer.getName(), "%playerdisplayname%", jPlayer.getDisplayName());
sender.sendMessage(Jobs.getLanguage().getMessage("command.points.currentpoints", "%currentpoints%", (int) (pointInfo.getCurrentPoints() * 100) / 100D)); Language.sendMessage(sender, "command.points.currentpoints", "%currentpoints%", (int) (pointInfo.getCurrentPoints() * 100) / 100D);
sender.sendMessage(Jobs.getLanguage().getMessage("command.points.totalpoints", "%totalpoints%", (int) (pointInfo.getTotalPoints() * 100) / 100D)); Language.sendMessage(sender, "command.points.totalpoints", "%totalpoints%", (int) (pointInfo.getTotalPoints() * 100) / 100D);
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator")); Language.sendMessage(sender, "general.info.separator");
return true; return true;
} }
} }

View File

@ -7,62 +7,62 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
public class promote implements Cmd { public class promote 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 (args.length < 3) { if (args.length < 3) {
Jobs.getCommandManager().sendUsage(sender, "promote"); return false;
return true; }
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) { if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0])); Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args[0]);
return true; return true;
} }
Job job = Jobs.getJob(args[1]); Job job = Jobs.getJob(args[1]);
if (job == null) { if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job")); Language.sendMessage(sender, "general.error.job");
return true; return true;
} }
// check if player already has the job // check if player already has the job
if (!jPlayer.isInJob(job)) if (!jPlayer.isInJob(job))
return false; return false;
try { try {
int levelsGained = -1; int levelsGained = -1;
try { try {
levelsGained = Integer.parseInt(args[2]); levelsGained = Integer.parseInt(args[2]);
} catch (NumberFormatException ex) { } catch (NumberFormatException ex) {
return false; return false;
} }
boolean commands = false; boolean commands = false;
for (String one : args) { for (String one : args) {
if (one.equalsIgnoreCase("-cmd")) { if (one.equalsIgnoreCase("-cmd")) {
commands = true; commands = true;
continue; continue;
} }
} }
Jobs.getPlayerManager().promoteJob(jPlayer, job, levelsGained, commands); Jobs.getPlayerManager().promoteJob(jPlayer, job, levelsGained, commands);
Player player = jPlayer.getPlayer(); Player player = jPlayer.getPlayer();
if (player != null) if (player != null)
player.sendMessage(Jobs.getLanguage().getMessage("command.promote.output.target", Language.sendMessage(player, "command.promote.output.target",
"%jobname%", job.getDisplayName(), "%jobname%", job.getDisplayName(),
"%levelsgained%", levelsGained)); "%levelsgained%", levelsGained);
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success")); Language.sendMessage(sender, "general.admin.success");
} catch (Throwable e) { } catch (Throwable e) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.error")); Language.sendMessage(sender, "general.admin.error");
} }
return true; return true;
} }
} }

View File

@ -14,6 +14,7 @@ import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.container.Quest; import com.gamingmesh.jobs.container.Quest;
import com.gamingmesh.jobs.container.QuestObjective; import com.gamingmesh.jobs.container.QuestObjective;
import com.gamingmesh.jobs.container.QuestProgression; import com.gamingmesh.jobs.container.QuestProgression;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC; import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Messages.CMIMessages; import net.Zrips.CMILib.Messages.CMIMessages;
@ -27,7 +28,7 @@ public class quests implements Cmd {
if (!Jobs.getGCManager().DailyQuestsEnabled) { if (!Jobs.getGCManager().DailyQuestsEnabled) {
LC.info_FeatureNotEnabled.sendMessage(sender); LC.info_FeatureNotEnabled.sendMessage(sender);
return true; return null;
} }
JobsPlayer jPlayer = null; JobsPlayer jPlayer = null;
@ -35,7 +36,7 @@ public class quests implements Cmd {
if (args.length >= 1 && !args[0].equalsIgnoreCase("stop") && !args[0].equalsIgnoreCase("start")) { if (args.length >= 1 && !args[0].equalsIgnoreCase("stop") && !args[0].equalsIgnoreCase("start")) {
if (!Jobs.hasPermission(sender, "jobs.command.admin.quests", true)) if (!Jobs.hasPermission(sender, "jobs.command.admin.quests", true))
return true; return null;
jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]); jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
} else if (isPlayer) } else if (isPlayer)
@ -52,7 +53,7 @@ public class quests implements Cmd {
List<QuestProgression> questProgs = jPlayer.getQuestProgressions(); List<QuestProgression> questProgs = jPlayer.getQuestProgressions();
if (questProgs.isEmpty()) { if (questProgs.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.quests.error.noquests")); Language.sendMessage(sender, "command.quests.error.noquests");
return true; return true;
} }
@ -71,13 +72,13 @@ public class quests implements Cmd {
q.getQuest().setStopped(stopped); q.getQuest().setStopped(stopped);
} }
sender.sendMessage(Jobs.getLanguage().getMessage("command.quests.status.changed", "%status%", Language.sendMessage(sender, "command.quests.status.changed", "%status%",
stopped ? Jobs.getLanguage().getMessage("command.quests.status.stopped") : Jobs.getLanguage().getMessage("command.quests.status.started"))); stopped ? Jobs.getLanguage().getMessage("command.quests.status.stopped") : Jobs.getLanguage().getMessage("command.quests.status.started"));
return true; return true;
} }
} }
sender.sendMessage(Jobs.getLanguage().getMessage("command.quests.toplineseparator", "[playerName]", jPlayer.getName(), "[questsDone]", jPlayer.getDoneQuests())); Language.sendMessage(sender, "command.quests.toplineseparator", "[playerName]", jPlayer.getName(), "[questsDone]", jPlayer.getDoneQuests());
for (JobProgression jobProg : jPlayer.progression) { for (JobProgression jobProg : jPlayer.progression) {
List<QuestProgression> list = jPlayer.getQuestProgressions(jobProg.getJob()); List<QuestProgression> list = jPlayer.getQuestProgressions(jobProg.getJob());

View File

@ -4,13 +4,14 @@ import org.bukkit.command.CommandSender;
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.i18n.Language;
public class reload implements Cmd { public class reload 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) {
Jobs.reload(); Jobs.reload();
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success")); Language.sendMessage(sender, "general.admin.success");
return true; return true;
} }
} }

View File

@ -7,52 +7,52 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
public class removexp implements Cmd { public class removexp 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 (args.length < 3) { if (args.length < 3) {
Jobs.getCommandManager().sendUsage(sender, "removexp"); return false;
return true; }
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) { if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0])); Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args[0]);
return true; return true;
} }
Job job = Jobs.getJob(args[1]); Job job = Jobs.getJob(args[1]);
if (job == null) { if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job")); Language.sendMessage(sender, "general.error.job");
return true; return null;
} }
double xpLost = 0D; double xpLost = 0D;
try { try {
xpLost = Double.parseDouble(args[2]); xpLost = Double.parseDouble(args[2]);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.error")); Language.sendMessage(sender, "general.admin.error");
return true; return true;
} }
if (xpLost <= 0 || xpLost > Double.MAX_VALUE) { if (xpLost <= 0 || xpLost > Double.MAX_VALUE) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.error")); Language.sendMessage(sender, "general.admin.error");
return true; return true;
} }
// check if player already has the job // check if player already has the job
if (jPlayer.isInJob(job)) { if (jPlayer.isInJob(job)) {
Jobs.getPlayerManager().removeExperience(jPlayer, job, xpLost); Jobs.getPlayerManager().removeExperience(jPlayer, job, xpLost);
Player player = jPlayer.getPlayer(); Player player = jPlayer.getPlayer();
if (player != null) { if (player != null) {
player.sendMessage(Jobs.getLanguage().getMessage("command.removexp.output.target", Language.sendMessage(player, "command.removexp.output.target",
"%jobname%", job.getDisplayName(), "%jobname%", job.getDisplayName(),
"%xplost%", xpLost)); "%xplost%", xpLost);
} }
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success")); Language.sendMessage(sender, "general.admin.success");
} }
return true; return true;
} }
} }

View File

@ -4,6 +4,7 @@ import org.bukkit.command.CommandSender;
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.i18n.Language;
public class resetexploreregion implements Cmd { public class resetexploreregion implements Cmd {
@ -12,24 +13,23 @@ public class resetexploreregion implements Cmd {
@Override @Override
public Boolean perform(Jobs plugin, CommandSender sender, String[] args) { public Boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (args.length != 2 || !WORLD.equals(args[0])) { if (args.length != 2 || !WORLD.equals(args[0])) {
Jobs.getCommandManager().sendUsage(sender, "resetexploreregion"); return false;
return true; }
}
if (!Jobs.getGCManager().resetExploringData) { if (!Jobs.getGCManager().resetExploringData) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.resetexploreregion.output.notenabled")); Language.sendMessage(sender, "command.resetexploreregion.output.notenabled");
return true; return true;
} }
final String worldName = args[1]; final String worldName = args[1];
if (!worldName.matches(REGEX)) { if (!worldName.matches(REGEX)) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.resetexploreregion.output.invalidname")); Language.sendMessage(sender, "command.resetexploreregion.output.invalidname");
return true; return true;
} }
Jobs.getExploreManager().resetRegion(worldName); Jobs.getExploreManager().resetRegion(worldName);
sender.sendMessage(Jobs.getLanguage().getMessage("command.resetexploreregion.output.reseted", "%worldname%", worldName)); Language.sendMessage(sender, "command.resetexploreregion.output.reseted", "%worldname%", worldName);
return true; return true;
} }
} }

View File

@ -4,36 +4,36 @@ import org.bukkit.command.CommandSender;
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.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
public class resetlimit implements Cmd { public class resetlimit 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 (args.length != 1) { if (args.length != 1) {
Jobs.getCommandManager().sendUsage(sender, "resetlimit"); return false;
return true; }
}
if (args[0].equalsIgnoreCase("all")) { if (args[0].equalsIgnoreCase("all")) {
for (org.bukkit.entity.Player pl : org.bukkit.Bukkit.getOnlinePlayers()) { for (org.bukkit.entity.Player pl : org.bukkit.Bukkit.getOnlinePlayers()) {
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pl); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pl);
if (jPlayer != null) { if (jPlayer != null) {
jPlayer.resetPaymentLimit(); jPlayer.resetPaymentLimit();
} }
} }
sender.sendMessage(Jobs.getLanguage().getMessage("command.resetlimit.output.reseted", "%playername%", "")); Language.sendMessage(sender, "command.resetlimit.output.reseted", "%playername%", "");
return true; return true;
} }
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) { if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0])); Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args[0]);
return true; return true;
} }
jPlayer.resetPaymentLimit(); jPlayer.resetPaymentLimit();
sender.sendMessage(Jobs.getLanguage().getMessage("command.resetlimit.output.reseted", "%playername%", jPlayer.getName(), "%playerdisplayname%", jPlayer.getDisplayName())); Language.sendMessage(sender, "command.resetlimit.output.reseted", "%playername%", jPlayer.getName(), "%playerdisplayname%", jPlayer.getDisplayName());
return true; return true;
} }
} }

View File

@ -10,6 +10,7 @@ import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.container.QuestProgression; import com.gamingmesh.jobs.container.QuestProgression;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC; import net.Zrips.CMILib.Locale.LC;
@ -17,15 +18,14 @@ public class resetquest 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 (!Jobs.getGCManager().DailyQuestsEnabled) { if (!Jobs.getGCManager().DailyQuestsEnabled) {
LC.info_FeatureNotEnabled.sendMessage(sender); LC.info_FeatureNotEnabled.sendMessage(sender);
return true; return true;
} }
if (args.length != 0 && args.length != 1 && args.length != 2) { if (args.length != 0 && args.length != 1 && args.length != 2) {
Jobs.getCommandManager().sendUsage(sender, "resetquest"); return false;
return true;
} }
JobsPlayer jPlayer = null; JobsPlayer jPlayer = null;
@ -44,7 +44,7 @@ public class resetquest implements Cmd {
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender); jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
if (jPlayer == null) { if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args.length > 0 ? args[0] : "")); Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args.length > 0 ? args[0] : "");
return true; return true;
} }
@ -54,12 +54,12 @@ public class resetquest implements Cmd {
quests = jPlayer.getQuestProgressions(job); quests = jPlayer.getQuestProgressions(job);
if (quests.isEmpty()) { if (quests.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.resetquest.output.noQuests")); Language.sendMessage(sender, "command.resetquest.output.noQuests");
return true; return true;
} }
jPlayer.resetQuests(quests); jPlayer.resetQuests(quests);
sender.sendMessage(Jobs.getLanguage().getMessage("command.resetquest.output.reseted", "%playername%", jPlayer.getName(), "%playerdisplayname%", jPlayer.getName())); Language.sendMessage(sender, "command.resetquest.output.reseted", "%playername%", jPlayer.getName(), "%playerdisplayname%", jPlayer.getName());
return true; return true;
} }
} }

View File

@ -10,6 +10,7 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC; import net.Zrips.CMILib.Locale.LC;
@ -23,8 +24,7 @@ public class resetquesttotal implements Cmd {
} }
if (args.length != 0 && args.length != 1) { if (args.length != 0 && args.length != 1) {
Jobs.getCommandManager().sendUsage(sender, "resetquesttotal"); return false;
return true;
} }
if (args.length > 0 && args[0].equalsIgnoreCase("all")) { if (args.length > 0 && args[0].equalsIgnoreCase("all")) {
@ -32,7 +32,7 @@ public class resetquesttotal implements Cmd {
pl.getValue().setDoneQuests(0); pl.getValue().setDoneQuests(0);
} }
Jobs.getJobsDAO().resetDoneQuests(); Jobs.getJobsDAO().resetDoneQuests();
sender.sendMessage(Jobs.getLanguage().getMessage("command.resetquesttotal.output.reseted", "%playername%", Jobs.getPlayerManager().getPlayersCache().size())); Language.sendMessage(sender,"command.resetquesttotal.output.reseted", "%playername%", Jobs.getPlayerManager().getPlayersCache().size());
return true; return true;
} }
@ -52,14 +52,14 @@ public class resetquesttotal implements Cmd {
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender); jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
if (jPlayer == null) { if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args.length > 0 ? args[0] : "")); Language.sendMessage(sender,"general.error.noinfoByPlayer", "%playername%", args.length > 0 ? args[0] : "");
return true; return true;
} }
jPlayer.setDoneQuests(0); jPlayer.setDoneQuests(0);
jPlayer.setSaved(false); jPlayer.setSaved(false);
jPlayer.save(); jPlayer.save();
sender.sendMessage(Jobs.getLanguage().getMessage("command.resetquesttotal.output.reseted", "%playername%", jPlayer.getName(), "%playerdisplayname%", jPlayer.getDisplayName())); Language.sendMessage(sender,"command.resetquesttotal.output.reseted", "%playername%", jPlayer.getName(), "%playerdisplayname%", jPlayer.getDisplayName());
return true; return true;
} }
} }

View File

@ -9,6 +9,7 @@ import org.bukkit.configuration.file.FileConfiguration;
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.i18n.Language;
public class schedule implements Cmd { public class schedule implements Cmd {
@ -16,7 +17,7 @@ public class schedule implements Cmd {
public Boolean perform(final Jobs plugin, final CommandSender sender, final String[] args) { public Boolean perform(final Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length < 2) { if (args.length < 2) {
Jobs.getCommandManager().sendUsage(sender, "schedule"); Jobs.getCommandManager().sendUsage(sender, "schedule");
return true; return null;
} }
if (args[0].equalsIgnoreCase("enable")) { if (args[0].equalsIgnoreCase("enable")) {
@ -32,12 +33,12 @@ public class schedule implements Cmd {
ConfigurationSection path = c.getConfigurationSection("Boost." + name); ConfigurationSection path = c.getConfigurationSection("Boost." + name);
if (path == null) { if (path == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.schedule.output.noScheduleFound")); Language.sendMessage(sender,"command.schedule.output.noScheduleFound");
return false; return null;
} }
if (path.getBoolean("Enabled")) { if (path.getBoolean("Enabled")) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.schedule.output.alreadyEnabled")); Language.sendMessage(sender,"command.schedule.output.alreadyEnabled");
return true; return true;
} }
@ -63,7 +64,7 @@ public class schedule implements Cmd {
Jobs.getScheduleManager().load(); Jobs.getScheduleManager().load();
Jobs.getScheduleManager().start(); Jobs.getScheduleManager().start();
sender.sendMessage(Jobs.getLanguage().getMessage("command.schedule.output.enabled", "%until%", until, "%from%", from)); Language.sendMessage(sender,"command.schedule.output.enabled", "%until%", until, "%from%", from);
} }
return true; return true;

View File

@ -15,17 +15,16 @@ public class shop implements Cmd {
if (!Jobs.getGCManager().jobsshopenabled) { if (!Jobs.getGCManager().jobsshopenabled) {
LC.info_FeatureNotEnabled.sendMessage(sender); LC.info_FeatureNotEnabled.sendMessage(sender);
return true; return null;
} }
if (!(sender instanceof Player)) { if (!(sender instanceof Player)) {
LC.info_Ingame.sendMessage(sender); LC.info_Ingame.sendMessage(sender);
return true; return null;
} }
if (args.length != 0 && args.length != 1) { if (args.length != 0 && args.length != 1) {
Jobs.getCommandManager().sendUsage(sender, "shop"); return false;
return true;
} }
int page = 1; int page = 1;

View File

@ -6,40 +6,43 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.Signs.SignTopType; import com.gamingmesh.jobs.Signs.SignTopType;
import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC;
public class signupdate implements Cmd { public class signupdate 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 (!Jobs.getGCManager().SignsEnabled) if (!Jobs.getGCManager().SignsEnabled) {
return true; LC.info_FeatureNotEnabled.sendMessage(sender);
return null;
}
if (args.length != 1) { if (args.length != 1) {
Jobs.getCommandManager().sendUsage(sender, "signupdate"); return false;
return true; }
}
if (args[0].equalsIgnoreCase("all")) { if (args[0].equalsIgnoreCase("all")) {
Jobs.getJobs().forEach(Jobs.getSignUtil()::signUpdate); Jobs.getJobs().forEach(Jobs.getSignUtil()::signUpdate);
return true; return true;
} }
Job oldjob = Jobs.getJob(args[0]); Job oldjob = Jobs.getJob(args[0]);
if (oldjob == null) { if (oldjob == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job")); Language.sendMessage(sender, "general.error.job");
return true; return null;
} }
if (args.length == 2) { if (args.length == 2) {
SignTopType type = SignTopType.getType(args[1]); SignTopType type = SignTopType.getType(args[1]);
if (type != null) { if (type != null) {
Jobs.getSignUtil().signUpdate(oldjob, type); Jobs.getSignUtil().signUpdate(oldjob, type);
} }
return true;
}
return true; Jobs.getSignUtil().signUpdate(oldjob);
} return true;
Jobs.getSignUtil().signUpdate(oldjob);
return true;
} }
} }

View File

@ -12,6 +12,7 @@ import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.container.Quest; import com.gamingmesh.jobs.container.Quest;
import com.gamingmesh.jobs.container.QuestProgression; import com.gamingmesh.jobs.container.QuestProgression;
import com.gamingmesh.jobs.economy.BufferedEconomy; import com.gamingmesh.jobs.economy.BufferedEconomy;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC; import net.Zrips.CMILib.Locale.LC;
@ -21,11 +22,11 @@ public class skipquest implements Cmd {
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) { public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (!Jobs.getGCManager().DailyQuestsEnabled) { if (!Jobs.getGCManager().DailyQuestsEnabled) {
LC.info_FeatureNotEnabled.sendMessage(sender); LC.info_FeatureNotEnabled.sendMessage(sender);
return true; return null;
} }
if (args.length != 2 && args.length != 3) { if (args.length != 2 && args.length != 3) {
Jobs.getCommandManager().sendUsage(sender, "skipquest"); return false;
return true;
} }
JobsPlayer jPlayer = null; JobsPlayer jPlayer = null;
@ -53,8 +54,8 @@ public class skipquest implements Cmd {
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender); jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
if (jPlayer == null) { if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args.length > 0 ? args[0] : "")); Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args.length > 0 ? args[0] : "");
return true; return null;
} }
List<QuestProgression> quests = jPlayer.getQuestProgressions(); List<QuestProgression> quests = jPlayer.getQuestProgressions();
@ -63,8 +64,8 @@ public class skipquest implements Cmd {
quests = jPlayer.getQuestProgressions(job); quests = jPlayer.getQuestProgressions(job);
if (quests == null || quests.isEmpty()) { if (quests == null || quests.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.resetquest.output.noQuests")); Language.sendMessage(sender, "command.resetquest.output.noQuests");
return true; return null;
} }
Quest old = null; Quest old = null;
@ -99,8 +100,8 @@ public class skipquest implements Cmd {
if (amount > 0 && player != null) { if (amount > 0 && player != null) {
if (!econ.getEconomy().hasMoney(player, amount)) { if (!econ.getEconomy().hasMoney(player, amount)) {
sender.sendMessage(Jobs.getLanguage().getMessage("economy.error.nomoney")); Language.sendMessage(sender, "economy.error.nomoney");
return false; return null;
} }
econ.getEconomy().withdrawPlayer(player, amount); econ.getEconomy().withdrawPlayer(player, amount);
@ -112,7 +113,7 @@ public class skipquest implements Cmd {
plugin.getServer().dispatchCommand(player, "jobs quests"); plugin.getServer().dispatchCommand(player, "jobs quests");
if (amount > 0) { if (amount > 0) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.skipquest.output.questSkipForCost", "%amount%", amount)); Language.sendMessage(sender, "command.skipquest.output.questSkipForCost", "%amount%", amount);
} }
return true; return true;

View File

@ -24,8 +24,8 @@ public class stats implements Cmd {
if (!Jobs.hasPermission(sender, "jobs.command.admin.stats", true)) if (!Jobs.hasPermission(sender, "jobs.command.admin.stats", true))
return true; return true;
jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]); jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
} else if (sender instanceof Player p) } else if (sender instanceof Player)
jPlayer = Jobs.getPlayerManager().getJobsPlayer(p); jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
if (jPlayer == null) { if (jPlayer == null) {
if (args.length >= 1) if (args.length >= 1)

View File

@ -7,6 +7,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.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
import com.gamingmesh.jobs.stuff.ToggleBarHandling; import com.gamingmesh.jobs.stuff.ToggleBarHandling;
import net.Zrips.CMILib.Locale.LC; import net.Zrips.CMILib.Locale.LC;
@ -16,48 +17,47 @@ public class toggle 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)) {
CMIMessages.sendMessage(sender, LC.info_Ingame); CMIMessages.sendMessage(sender, LC.info_Ingame);
return false; return null;
} }
boolean isBossbar = false, isActionbar = false; boolean isBossbar = false, isActionbar = false;
if (args.length != 1 || (!(isBossbar = args[0].equalsIgnoreCase("bossbar")) && !(isActionbar = args[0].equalsIgnoreCase("actionbar")))) { if (args.length != 1 || (!(isBossbar = args[0].equalsIgnoreCase("bossbar")) && !(isActionbar = args[0].equalsIgnoreCase("actionbar")))) {
Jobs.getCommandManager().sendUsage(sender, "toggle"); return false;
return true; }
}
Player player = (Player) sender; Player player = (Player) sender;
String playerUUID = player.getUniqueId().toString(); String playerUUID = player.getUniqueId().toString();
if (isActionbar) { if (isActionbar) {
Boolean ex = ToggleBarHandling.getActionBarToggle().get(playerUUID); Boolean ex = ToggleBarHandling.getActionBarToggle().get(playerUUID);
if (ex == null || ex.booleanValue()) { if (ex == null || ex.booleanValue()) {
ToggleBarHandling.getActionBarToggle().put(playerUUID, false); ToggleBarHandling.getActionBarToggle().put(playerUUID, false);
sender.sendMessage(Jobs.getLanguage().getMessage("command.toggle.output.off")); Language.sendMessage(sender, "command.toggle.output.off");
} else { } else {
ToggleBarHandling.getActionBarToggle().put(playerUUID, true); ToggleBarHandling.getActionBarToggle().put(playerUUID, true);
sender.sendMessage(Jobs.getLanguage().getMessage("command.toggle.output.on")); Language.sendMessage(sender, "command.toggle.output.on");
} }
} }
if (isBossbar) { if (isBossbar) {
Boolean ex = ToggleBarHandling.getBossBarToggle().get(playerUUID); Boolean ex = ToggleBarHandling.getBossBarToggle().get(playerUUID);
if (ex == null || ex.booleanValue()) { if (ex == null || ex.booleanValue()) {
ToggleBarHandling.getBossBarToggle().put(playerUUID, false); ToggleBarHandling.getBossBarToggle().put(playerUUID, false);
sender.sendMessage(Jobs.getLanguage().getMessage("command.toggle.output.off")); Language.sendMessage(sender, "command.toggle.output.off");
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player.getUniqueId()); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player.getUniqueId());
if (jPlayer != null) if (jPlayer != null)
jPlayer.hideBossBars(); jPlayer.hideBossBars();
} else { } else {
ToggleBarHandling.getBossBarToggle().put(playerUUID, true); ToggleBarHandling.getBossBarToggle().put(playerUUID, true);
sender.sendMessage(Jobs.getLanguage().getMessage("command.toggle.output.on")); Language.sendMessage(sender, "command.toggle.output.on");
} }
} }
return true; return true;
} }
} }

View File

@ -24,11 +24,10 @@ public class top implements Cmd {
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) { public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length != 1 && args.length != 2) { if (args.length != 1 && args.length != 2) {
Jobs.getCommandManager().sendUsage(sender, "top");
return false; return false;
} }
Player player = sender instanceof Player p ? p : null; Player player = sender instanceof Player ? (Player) sender : null;
if (args[0].equalsIgnoreCase("clear")) { if (args[0].equalsIgnoreCase("clear")) {
if (player != null) { if (player != null) {
@ -43,7 +42,7 @@ public class top implements Cmd {
try { try {
page = Integer.parseInt(args[1]); page = Integer.parseInt(args[1]);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
return true; return false;
} }
} }
if (page < 1) if (page < 1)
@ -52,7 +51,7 @@ public class top implements Cmd {
Job job = Jobs.getJob(args[0]); Job job = Jobs.getJob(args[0]);
if (job == null) { if (job == null) {
Language.sendMessage(sender, "command.top.error.nojob"); Language.sendMessage(sender, "command.top.error.nojob");
return false; return null;
} }
int workingIn = Jobs.getUsedSlots(job); int workingIn = Jobs.getUsedSlots(job);

View File

@ -7,51 +7,50 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
public class transfer implements Cmd { public class transfer 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 (args.length < 3) { if (args.length < 3) {
Jobs.getCommandManager().sendUsage(sender, "transfer"); return false;
return true; }
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) { if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0])); Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args[0]);
return true; return true;
} }
Job oldjob = Jobs.getJob(args[1]); Job oldjob = Jobs.getJob(args[1]);
if (oldjob == null) { if (oldjob == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job")); Language.sendMessage(sender, "general.error.job");
return true; return true;
} }
Job newjob = Jobs.getJob(args[2]); Job newjob = Jobs.getJob(args[2]);
if (newjob == null) { if (newjob == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job")); Language.sendMessage(sender, "general.error.job");
return true; return true;
} }
try { try {
if (jPlayer.isInJob(oldjob) && !jPlayer.isInJob(newjob)) { if (jPlayer.isInJob(oldjob) && !jPlayer.isInJob(newjob)) {
Jobs.getPlayerManager().transferJob(jPlayer, oldjob, newjob); Jobs.getPlayerManager().transferJob(jPlayer, oldjob, newjob);
Player player = jPlayer.getPlayer(); Player player = jPlayer.getPlayer();
if (player != null) { if (player != null) {
player.sendMessage(Jobs.getLanguage().getMessage("command.transfer.output.target", Language.sendMessage(player, "command.transfer.output.target",
"%oldjobname%", oldjob.getDisplayName(), "%oldjobname%", oldjob.getDisplayName(),
"%newjobname%", newjob.getDisplayName())); "%newjobname%", newjob.getDisplayName());
} }
Language.sendMessage(sender, "general.admin.success");
}
} catch (Exception e) {
Language.sendMessage(sender, "general.admin.error");
}
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success")); return true;
}
} catch (Exception e) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.error"));
}
return true;
} }
} }