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.JobsPlayer;
import com.gamingmesh.jobs.container.Title;
import com.gamingmesh.jobs.i18n.Language;
import com.gamingmesh.jobs.stuff.Util;
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) {
if (job == null) {
// job doesn't exist
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
Language.sendMessage(sender, "general.error.job");
return;
}
@ -316,7 +317,7 @@ public class JobsCommands implements CommandExecutor {
PageInfo pi = new PageInfo(15, message.size(), page);
if (page > pi.getTotalPages()) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.invalidPage"));
Language.sendMessage(sender, "general.info.invalidPage");
return;
}

View File

@ -10,6 +10,7 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.RawMessages.RawMessage;
@ -17,43 +18,43 @@ public class archive implements Cmd {
@Override
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
JobsPlayer jPlayer = null;
if (args.length >= 1) {
if (!Jobs.hasPermission(sender, "jobs.command.admin.archive", true)) {
return null;
}
jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
JobsPlayer jPlayer = null;
if (args.length >= 1) {
if (!Jobs.hasPermission(sender, "jobs.command.admin.archive", true)) {
return null;
}
jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
} else if (sender instanceof Player) {
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
}
} else if (sender instanceof Player) {
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
}
if (jPlayer == null) {
if (args.length >= 1)
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0]));
return null;
}
if (jPlayer == null) {
if (args.length >= 1)
Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args[0]);
return null;
}
Set<JobProgression> allJobs = jPlayer.getArchivedJobs().getArchivedJobs();
if (allJobs.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.archive.error.nojob"));
return null;
}
Set<JobProgression> allJobs = jPlayer.getArchivedJobs().getArchivedJobs();
if (allJobs.isEmpty()) {
Language.sendMessage(sender, "command.archive.error.nojob");
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);
}
Language.sendMessage(sender, "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"));
return true;
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.RestrictedArea;
import com.gamingmesh.jobs.hooks.HookManager;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Items.CMIMaterial;
import net.Zrips.CMILib.Locale.LC;
@ -21,150 +22,150 @@ public class area implements Cmd {
@Override
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (!(sender instanceof Player)) {
CMIMessages.sendMessage(sender, LC.info_Ingame);
return false;
}
if (!(sender instanceof Player)) {
CMIMessages.sendMessage(sender, LC.info_Ingame);
return false;
}
Player player = (Player) sender;
Player player = (Player) sender;
if (args.length == 3) {
if (args[0].equalsIgnoreCase("add")) {
if (!Jobs.hasPermission(player, "jobs.area.add", true))
return true;
if (args.length == 3) {
if (args[0].equalsIgnoreCase("add")) {
if (!Jobs.hasPermission(player, "jobs.area.add", true))
return true;
double bonus = 0D;
try {
bonus = Double.parseDouble(args[2]);
} catch (NumberFormatException e) {
return false;
}
double bonus = 0D;
try {
bonus = Double.parseDouble(args[2]);
} catch (NumberFormatException e) {
return false;
}
boolean wg = false;
boolean wg = false;
String name = args[1];
if (name.startsWith("wg:")) {
wg = true;
name = name.substring("wg:".length(), name.length());
}
String name = args[1];
if (name.startsWith("wg:")) {
wg = true;
name = name.substring("wg:".length(), name.length());
}
RestrictedAreaManager ra = Jobs.getRestrictedAreaManager();
RestrictedAreaManager ra = Jobs.getRestrictedAreaManager();
if (ra.isExist(name)) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.exist"));
return true;
}
if (ra.isExist(name)) {
Language.sendMessage(sender, "command.area.output.exist");
return true;
}
if (!wg && !Jobs.getSelectionManager().hasPlacedBoth(player)) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.select",
"%tool%", CMIMaterial.get(Jobs.getGCManager().getSelectionTool()).getName()));
return true;
}
if (wg && HookManager.getWorldGuardManager() != null) {
com.sk89q.worldguard.protection.regions.ProtectedRegion protectedRegion = HookManager.getWorldGuardManager().getProtectedRegionByName(name);
if (!wg && !Jobs.getSelectionManager().hasPlacedBoth(player)) {
Language.sendMessage(sender, "command.area.output.select",
"%tool%", CMIMaterial.get(Jobs.getGCManager().getSelectionTool()).getName());
return true;
}
if (wg && HookManager.getWorldGuardManager() != null) {
com.sk89q.worldguard.protection.regions.ProtectedRegion protectedRegion = HookManager.getWorldGuardManager().getProtectedRegionByName(name);
if (protectedRegion == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.wgDontExist"));
return true;
}
name = protectedRegion.getId();
}
if (protectedRegion == null) {
Language.sendMessage(sender, "command.area.output.wgDontExist");
return true;
}
name = protectedRegion.getId();
}
if (!wg)
ra.addNew(new RestrictedArea(name, Jobs.getSelectionManager().getSelectionCuboid(player), bonus), true);
else
ra.addNew(new RestrictedArea(name, name, bonus), true);
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.addedNew", "%bonus%", bonus));
return true;
}
}
if (!wg)
ra.addNew(new RestrictedArea(name, Jobs.getSelectionManager().getSelectionCuboid(player), bonus), true);
else
ra.addNew(new RestrictedArea(name, name, bonus), true);
Language.sendMessage(sender, "command.area.output.addedNew", "%bonus%", bonus);
return true;
}
}
if (args.length == 2) {
if (args[0].equalsIgnoreCase("remove")) {
if (!Jobs.hasPermission(player, "jobs.area.remove", true))
return true;
if (args.length == 2) {
if (args[0].equalsIgnoreCase("remove")) {
if (!Jobs.hasPermission(player, "jobs.area.remove", true))
return true;
RestrictedAreaManager ra = Jobs.getRestrictedAreaManager();
String name = args[1];
RestrictedAreaManager ra = Jobs.getRestrictedAreaManager();
String name = args[1];
if (!ra.isExist(name)) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.dontExist"));
return true;
}
if (!ra.isExist(name)) {
Language.sendMessage(sender, "command.area.output.dontExist");
return true;
}
ra.remove(name);
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.removed", "%name%", name));
return true;
}
}
ra.remove(name);
Language.sendMessage(sender, "command.area.output.removed", "%name%", name);
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) {
if (!msg.isEmpty())
msg += ", ";
msg += area.getName();
}
for (RestrictedArea area : areas) {
if (!msg.isEmpty())
msg += ", ";
msg += area.getName();
}
if (msg.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.noAreasByLoc"));
return true;
}
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.areaList", "%list%", msg));
return true;
}
if (msg.isEmpty()) {
Language.sendMessage(sender, "command.area.output.noAreasByLoc");
return true;
}
Language.sendMessage(sender, "command.area.output.areaList", "%list%", msg);
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();
if (areas.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.noAreas"));
return true;
}
java.util.Map<String, RestrictedArea> areas = Jobs.getRestrictedAreaManager().getRestrictedAreas();
if (areas.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.noAreas"));
return true;
}
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
int i = 0;
for (Entry<String, RestrictedArea> area : areas.entrySet()) {
i++;
CuboidArea cuboid = area.getValue().getCuboidArea();
if (area.getValue().getWgName() == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.list", "%number%", i,
"%areaname%", area.getKey(),
"%worldname%", cuboid.getWorld().getName(),
"%x1%", cuboid.getLowLoc().getBlockX(),
"%y1%", cuboid.getLowLoc().getBlockY(),
"%z1%", cuboid.getLowLoc().getBlockZ(),
"%x2%", cuboid.getHighLoc().getBlockX(),
"%y2%", cuboid.getHighLoc().getBlockY(),
"%z2%", cuboid.getHighLoc().getBlockZ(),
"%bonus%", area.getValue().getMultiplier()));
} else {
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.wgList", "%number%", i,
"%areaname%", area.getKey(),
"%bonus%", area.getValue().getMultiplier()));
}
}
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
return true;
}
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
int i = 0;
for (Entry<String, RestrictedArea> area : areas.entrySet()) {
i++;
CuboidArea cuboid = area.getValue().getCuboidArea();
if (area.getValue().getWgName() == null) {
Language.sendMessage(sender, "command.area.output.list", "%number%", i,
"%areaname%", area.getKey(),
"%worldname%", cuboid.getWorld().getName(),
"%x1%", cuboid.getLowLoc().getBlockX(),
"%y1%", cuboid.getLowLoc().getBlockY(),
"%z1%", cuboid.getLowLoc().getBlockZ(),
"%x2%", cuboid.getHighLoc().getBlockX(),
"%y2%", cuboid.getHighLoc().getBlockY(),
"%z2%", cuboid.getHighLoc().getBlockZ(),
"%bonus%", area.getValue().getMultiplier());
} else {
Language.sendMessage(sender, "command.area.output.wgList", "%number%", i,
"%areaname%", area.getKey(),
"%bonus%", area.getValue().getMultiplier());
}
}
Language.sendMessage(sender, "general.info.separator");
return true;
}
if (args.length > 0) {
if (args[0].equalsIgnoreCase("add")) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.help.addUsage"));
return true;
}
if (args.length > 0) {
if (args[0].equalsIgnoreCase("add")) {
Language.sendMessage(sender, "command.area.help.addUsage");
return true;
}
if (args[0].equalsIgnoreCase("remove")) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.help.removeUsage"));
return true;
}
}
if (args[0].equalsIgnoreCase("remove")) {
Language.sendMessage(sender, "command.area.help.removeUsage");
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) {
if (!(sender instanceof Player)) {
CMIMessages.sendMessage(sender, LC.info_Ingame);
return false;
}
if (args.length != 0) {
Jobs.getCommandManager().sendUsage(sender, "blockinfo");
return true;
return null;
}
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.JobsPlayer;
import com.gamingmesh.jobs.hooks.HookManager;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Messages.CMIMessages;
@ -22,86 +23,84 @@ public class bonus implements Cmd {
@Override
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (!(sender instanceof Player)) {
CMIMessages.sendMessage(sender, LC.info_Ingame);
return false;
}
if (!(sender instanceof Player)) {
CMIMessages.sendMessage(sender, LC.info_Ingame);
return null;
}
if (args.length != 1) {
Jobs.getCommandManager().sendUsage(sender, "bonus");
return true;
}
if (args.length != 1) {
Jobs.getCommandManager().sendUsage(sender, "bonus");
return true;
}
Player player = (Player) sender;
Job job = Jobs.getJob(args[0]);
if (job == null) {
player.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
Player player = (Player) sender;
Job job = Jobs.getJob(args[0]);
if (job == null) {
Language.sendMessage(sender, "general.error.job");
return true;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
if (jPlayer == null)
return false;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
if (jPlayer == null)
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.Item);
printBoost(sender, boost, BoostOf.Global);
if (Jobs.getGCManager().useDynamicPayment)
printBoost(sender, boost, BoostOf.Dynamic);
printBoost(sender, boost, BoostOf.Area);
if (Jobs.getGCManager().payNearSpawner())
printBoost(sender, boost, BoostOf.NearSpawner);
printBoost(sender, boost, BoostOf.PetPay);
printBoost(sender, boost, BoostOf.Permission);
printBoost(sender, boost, BoostOf.Item);
printBoost(sender, boost, BoostOf.Global);
if (Jobs.getGCManager().useDynamicPayment)
printBoost(sender, boost, BoostOf.Dynamic);
printBoost(sender, boost, BoostOf.Area);
if (Jobs.getGCManager().payNearSpawner())
printBoost(sender, boost, BoostOf.NearSpawner);
printBoost(sender, boost, BoostOf.PetPay);
if (HookManager.getMcMMOManager().mcMMOPresent ||
HookManager.getMcMMOManager().mcMMOOverHaul && boost.get(BoostOf.McMMO, CurrencyType.EXP) != 0D)
printBoost(sender, boost, BoostOf.McMMO);
if (HookManager.getMcMMOManager().mcMMOPresent ||
HookManager.getMcMMOManager().mcMMOOverHaul && boost.get(BoostOf.McMMO, CurrencyType.EXP) != 0D)
printBoost(sender, boost, BoostOf.McMMO);
player.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
Language.sendMessage(sender, "general.info.separator");
RawMessage rm = new RawMessage();
String msg = Jobs.getLanguage().getMessage("command.bonus.output.final",
"%money%", formatText(boost.getFinal(CurrencyType.MONEY, true, true)),
"%points%", formatText(boost.getFinal(CurrencyType.POINTS, true, true)),
"%exp%", formatText(boost.getFinal(CurrencyType.EXP, true, true)));
RawMessage rm = new RawMessage();
String msg = Jobs.getLanguage().getMessage("command.bonus.output.final",
"%money%", formatText(boost.getFinal(CurrencyType.MONEY, true, true)),
"%points%", formatText(boost.getFinal(CurrencyType.POINTS, 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)));
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));
rm.addText(msg).addHover(Arrays.asList(Jobs.getLanguage().getMessage("command.bonus.output.finalExplanation"), msg2));
rm.build();
rm.show(player);
rm.build();
rm.show(player);
return true;
return true;
}
private static void printBoost(CommandSender sender, Boost boost, BoostOf type) {
String prefix = Jobs.getLanguage().getMessage("command.bonus.output.specialPrefix");
if (type != BoostOf.NearSpawner && type != BoostOf.PetPay)
prefix = "";
String prefix = Jobs.getLanguage().getMessage("command.bonus.output.specialPrefix");
if (type != BoostOf.NearSpawner && type != BoostOf.PetPay)
prefix = "";
String msg = Jobs.getLanguage().getMessage("command.bonus.output." + type.name().toLowerCase(),
"%money%", formatText(boost.get(type, CurrencyType.MONEY, true)),
"%points%", formatText(boost.get(type, CurrencyType.POINTS, true)),
"%exp%", formatText(boost.get(type, CurrencyType.EXP, true)));
String msg = Jobs.getLanguage().getMessage("command.bonus.output." + type.name().toLowerCase(),
"%money%", formatText(boost.get(type, CurrencyType.MONEY, true)),
"%points%", formatText(boost.get(type, CurrencyType.POINTS, true)),
"%exp%", formatText(boost.get(type, CurrencyType.EXP, true)));
if ((type == BoostOf.NearSpawner || type == BoostOf.PetPay) && msg.startsWith(" "))
msg = msg.substring(1, msg.length());
if ((type == BoostOf.NearSpawner || type == BoostOf.PetPay) && msg.startsWith(" "))
msg = msg.substring(1, msg.length());
sender.sendMessage(prefix + msg);
CMIMessages.sendMessage(sender, prefix + msg);
}
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.container.CurrencyType;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Logs.CMIDebug;
@ -95,22 +96,22 @@ public class boost implements Cmd {
one.addBoost(curr, 1.0);
}
}
sender.sendMessage(Jobs.getLanguage().getMessage("command.boost.output.allreset"));
Language.sendMessage(sender, "command.boost.output.allreset");
} else {
for (Job one : Jobs.getJobs()) {
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) {
if (type == null) {
for (CurrencyType curr : CurrencyType.values()) {
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 {
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 {
return false;
@ -128,7 +129,7 @@ public class boost implements Cmd {
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 {
if (type == null) {
@ -138,14 +139,13 @@ public class boost implements Cmd {
} else {
job.addBoost(type, rate, timeDuration);
}
CMIDebug.d(timeDuration);
sender.sendMessage(Jobs.getLanguage().getMessage("command.boost.output.boostadded", "%boost%", rate, "%jobname%", job.getName()));
Language.sendMessage(sender, "command.boost.output.boostadded", "%boost%", rate, "%jobname%", job.getName());
}
return true;
}
private void showBoosts(CommandSender sender, Job job) {
private static void showBoosts(CommandSender sender, Job job) {
RawMessage rm = new RawMessage();
String msg = Jobs.getLanguage().getMessage("command.boost.output.boostStats", "%jobname%", job.getDisplayName());
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.container.BlockProtection;
import com.gamingmesh.jobs.container.DBAction;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Items.CMIMaterial;
import net.Zrips.CMILib.Locale.LC;
@ -73,9 +74,9 @@ public class bp implements Cmd {
}
if (changedBlocks.isEmpty())
sender.sendMessage(Jobs.getLanguage().getMessage("command.bp.output.notFound"));
Language.sendMessage(sender, "command.bp.output.notFound");
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() {
@Override

View File

@ -9,9 +9,11 @@ import org.bukkit.entity.Player;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Colors.CMIChatColor;
import net.Zrips.CMILib.Container.PageInfo;
import net.Zrips.CMILib.Messages.CMIMessages;
import net.Zrips.CMILib.RawMessages.RawMessage;
public class browse implements Cmd {
@ -22,7 +24,7 @@ public class browse implements Cmd {
if (Jobs.getGCManager().BrowseUseNewLook) {
if (Jobs.getJobs().isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.error.nojobs"));
Language.sendMessage(sender, "command.browse.error.nojobs");
return true;
}
@ -60,7 +62,7 @@ public class browse implements Cmd {
if (senderIsPlayer) {
if (j == null) {
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) {
if (!pi.isEntryOk())
continue;
@ -116,25 +118,25 @@ public class browse implements Cmd {
pi.autoPagination(sender, "jobs browse", "-p:");
} 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);
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)
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) {
int bonus = (int) (j.getBonus() * 100);
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
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()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.description", "[description]", one));
Language.sendMessage(sender, "command.browse.output.description", "[description]", one);
}
RawMessage rm = new RawMessage();
@ -148,7 +150,7 @@ public class browse implements Cmd {
}
} else {
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) {
String msg = "";
@ -177,14 +179,14 @@ public class browse implements Cmd {
msg += Jobs.getLanguage().getMessage("command.browse.output.console.list", "[jobname]", one.getName());
sender.sendMessage(msg);
CMIMessages.sendMessage(sender, msg);
}
} 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);
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)
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) {
int bonus = (int) (j.getBonus() * 100);
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
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()) {
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()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.error.nojobs"));
Language.sendMessage(sender, "command.browse.error.nojobs");
return true;
}
@ -260,9 +262,9 @@ public class browse implements Cmd {
}
if (Jobs.getGCManager().JobsGUIShowChatBrowse) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.header"));
Language.sendMessage(sender, "command.browse.output.header");
lines.forEach(sender::sendMessage);
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.footer"));
Language.sendMessage(sender, "command.browse.output.footer");
}
}
return true;

View File

@ -11,6 +11,7 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.container.blockOwnerShip.BlockTypes;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Messages.CMIMessages;
@ -47,8 +48,8 @@ public class clearownership implements Cmd {
if (args.length >= 1)
CMIMessages.sendMessage(sender, LC.info_NoInformation);
else
Jobs.getCommandManager().sendUsage(sender, "clearownership");
return true;
return false;
return null;
}
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(
BlockTypes.BREWING_STAND, 0), "[smoker]", amounts.getOrDefault(BlockTypes.SMOKER, 0), "[blast]", amounts.getOrDefault(BlockTypes.BLAST_FURNACE, 0)));
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));
return true;
}
}

View File

@ -21,8 +21,7 @@ public class convert implements Cmd {
}
if (args.length > 0) {
Jobs.getCommandManager().sendUsage(sender, "convert");
return true;
return false;
}
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.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Colors.CMIChatColor;
@ -14,48 +15,46 @@ public class demote implements Cmd {
@Override
public Boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (args.length < 3) {
Jobs.getCommandManager().sendUsage(sender, "demote");
return true;
}
if (args.length < 3) {
return false;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0]));
return true;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) {
Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args[0]);
return true;
}
Job job = Jobs.getJob(args[1]);
if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
Job job = Jobs.getJob(args[1]);
if (job == null) {
Language.sendMessage(sender, "general.error.job");
return true;
}
try {
// check if player already has the job
if (jPlayer.isInJob(job)) {
int levelsLost = 0;
try {
levelsLost = Integer.parseInt(args[2]);
} catch (NumberFormatException ex) {
return true;
}
try {
// check if player already has the job
if (jPlayer.isInJob(job)) {
int levelsLost = 0;
try {
levelsLost = Integer.parseInt(args[2]);
} catch (NumberFormatException ex) {
return true;
}
Jobs.getPlayerManager().demoteJob(jPlayer, job, levelsLost);
Jobs.getPlayerManager().demoteJob(jPlayer, job, levelsLost);
Player player = jPlayer.getPlayer();
if (player != null) {
String message = Jobs.getLanguage().getMessage("command.demote.output.target",
"%jobname%", job.getDisplayName() + CMIChatColor.WHITE,
"%levelslost%", levelsLost);
player.sendMessage(message);
}
Player player = jPlayer.getPlayer();
if (player != null) {
Language.sendMessage(sender, "command.demote.output.target",
"%jobname%", job.getDisplayName() + CMIChatColor.WHITE,
"%levelslost%", levelsLost);
}
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success"));
}
} catch (Throwable e) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.error"));
}
return true;
Language.sendMessage(sender, "general.admin.success");
}
} catch (Throwable e) {
Language.sendMessage(sender, "general.admin.error");
}
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.JobItems;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Colors.CMIChatColor;
import net.Zrips.CMILib.Items.CMIItemStack;
@ -23,37 +24,37 @@ import net.Zrips.CMILib.NBT.CMINBT;
public class edititembonus implements Cmd {
private enum actions {
list, add, remove;
list, add, remove;
public static actions getByname(String name) {
for (actions one : actions.values()) {
if (one.name().equalsIgnoreCase(name))
return one;
}
return null;
}
public static actions getByname(String name) {
for (actions one : actions.values()) {
if (one.name().equalsIgnoreCase(name))
return one;
}
return null;
}
}
@Override
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (!(sender instanceof Player)) {
CMIMessages.sendMessage(sender, LC.info_Ingame);
return false;
}
if (!(sender instanceof Player)) {
CMIMessages.sendMessage(sender, LC.info_Ingame);
return null;
}
if (args.length < 1)
return false;
if (args.length < 1)
return false;
actions action = null;
actions action = null;
// Job job = null;
JobItems jobitem = null;
JobItems jobitem = null;
for (String one : args) {
if (action == null) {
action = actions.getByname(one);
if (action != null)
continue;
}
for (String one : args) {
if (action == null) {
action = actions.getByname(one);
if (action != null)
continue;
}
// if (job == null) {
// job = Jobs.getJob(one);
// if (job != null)
@ -61,68 +62,67 @@ public class edititembonus implements Cmd {
// }
// if (job != null) {
jobitem = ItemBoostManager.getItemByKey(one);
jobitem = ItemBoostManager.getItemByKey(one);
// }
}
}
if (action == null)
return false;
if (action == null)
return false;
Player player = (Player) sender;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
if (jPlayer == null)
return false;
Player player = (Player) sender;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
if (jPlayer == null)
return false;
ItemStack iih = CMIItemStack.getItemInMainHand(player);
if (iih == null || iih.getType() == Material.AIR)
return false;
ItemStack iih = CMIItemStack.getItemInMainHand(player);
if (iih == null || iih.getType() == Material.AIR)
return false;
switch (action) {
case add:
if (jobitem == null)
return false;
iih = (ItemStack) new CMINBT(iih).setString("JobsItemBoost", jobitem.getNode());
CMIItemStack.setItemInMainHand(player, iih);
break;
case list:
break;
case remove:
iih = (ItemStack) new CMINBT(iih).remove("JobsItemBoost");
CMIItemStack.setItemInMainHand(player, iih);
break;
default:
break;
}
switch (action) {
case add:
if (jobitem == null)
return false;
iih = (ItemStack) new CMINBT(iih).setString("JobsItemBoost", jobitem.getNode());
CMIItemStack.setItemInMainHand(player, iih);
break;
case list:
break;
case remove:
iih = (ItemStack) new CMINBT(iih).remove("JobsItemBoost");
CMIItemStack.setItemInMainHand(player, iih);
break;
default:
break;
}
sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.topline"));
Language.sendMessage(sender, "command.bonus.output.topline");
Object key = new CMINBT(iih).getString("JobsItemBoost");
if (key == null)
return true;
Object key = new CMINBT(iih).getString("JobsItemBoost");
if (key == null)
return true;
JobItems item = ItemBoostManager.getItemByKey(key.toString());
if (item == null)
return true;
JobItems item = ItemBoostManager.getItemByKey(key.toString());
if (item == null)
return true;
BoostMultiplier boost = item.getBoost();
BoostMultiplier boost = item.getBoost();
String mc = CMIChatColor.DARK_GREEN.toString(),
pc = CMIChatColor.GOLD.toString(),
ec = CMIChatColor.YELLOW.toString();
String mc = CMIChatColor.DARK_GREEN.toString();
String pc = CMIChatColor.GOLD.toString();
String ec = CMIChatColor.YELLOW.toString();
for (Job one : item.getJobs()) {
String msg = Jobs.getLanguage().getMessage("command.itembonus.output.list",
"[jobname]", one.getName(),
"%money%", mc + formatText((int) (boost.get(CurrencyType.MONEY) * 100)),
"%points%", pc + formatText((int) (boost.get(CurrencyType.POINTS) * 100)),
"%exp%", ec + formatText((int) (boost.get(CurrencyType.EXP) * 100)));
sender.sendMessage(msg);
}
return true;
for (Job one : item.getJobs()) {
Language.sendMessage(sender, "command.itembonus.output.list",
"[jobname]", one.getName(),
"%money%", mc + formatText((int) (boost.get(CurrencyType.MONEY) * 100)),
"%points%", pc + formatText((int) (boost.get(CurrencyType.POINTS) * 100)),
"%exp%", ec + formatText((int) (boost.get(CurrencyType.EXP) * 100)));
}
return true;
}
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.Items.CMIItemStack;
import net.Zrips.CMILib.Items.CMIMaterial;
import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.RawMessages.RawMessage;
import net.Zrips.CMILib.Version.Version;
@ -29,408 +30,413 @@ public class editjobs implements Cmd {
@Override
public Boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (!(sender instanceof Player))
return false;
if (!(sender instanceof Player)) {
LC.info_Ingame.sendMessage(sender);
return false;
}
Player player = (Player) sender;
Player player = (Player) sender;
if (args.length == 0)
args = new String[] { "list" };
if (args.length == 0)
args = new String[] { "list" };
switch (args[0]) {
case "list":
if (args.length == 1) {
showPath(player, null, null, null);
switch (args[0]) {
case "list":
if (args.length == 1) {
showPath(player, null, null, null);
for (Job one : Jobs.getJobs()) {
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.show(sender);
}
for (Job one : Jobs.getJobs()) {
RawMessage rm = new RawMessage();
rm.addText(Jobs.getLanguage().getMessage("command.editjobs.help.list.jobs", "%jobname%", one.getDisplayName()))
.addHover(one.getName())
.addCommand("jobs editjobs list " + one.getName());
rm.show(sender);
}
Util.getJobsEditorMap().remove(player.getUniqueId());
return true;
}
Util.getJobsEditorMap().remove(player.getUniqueId());
return true;
}
if (args.length == 2) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
if (args.length == 2) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
showPath(player, job, null, null);
showPath(player, job, null, null);
for (ActionType oneI : ActionType.values()) {
List<JobInfo> action = job.getJobInfo(oneI);
if (action == null || action.isEmpty())
continue;
for (ActionType oneI : ActionType.values()) {
List<JobInfo> action = job.getJobInfo(oneI);
if (action == null || action.isEmpty())
continue;
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()
+ " 1");
rm.show(sender);
}
RawMessage rm = new RawMessage();
rm.addText(Jobs.getLanguage().getMessage("command.editjobs.help.list.actions", "%actionname%", oneI.getName()))
.addHover(oneI.getName())
.addCommand("jobs editjobs list " + job.getName() + " " + oneI.getName() + " 1");
rm.show(sender);
}
Util.getJobsEditorMap().remove(player.getUniqueId());
return true;
}
Util.getJobsEditorMap().remove(player.getUniqueId());
return true;
}
if (args.length == 4) {
Integer page = null;
try {
page = Integer.parseInt(args[3]);
} catch (NumberFormatException e) {
}
if (args.length == 4) {
Integer page = null;
try {
page = Integer.parseInt(args[3]);
} catch (NumberFormatException e) {
}
if (page != null) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
if (page != null) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
ActionType actionT = ActionType.getByName(args[2]);
if (actionT == null)
return false;
ActionType actionT = ActionType.getByName(args[2]);
if (actionT == null)
return false;
List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty())
return false;
List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty())
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) {
if (!pi.isEntryOk())
continue;
for (JobInfo one : action) {
if (!pi.isEntryOk())
continue;
String materialName = one.getRealisticName();
String materialName = one.getRealisticName();
RawMessage rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.material", "%materialname%", materialName), one.getName(), "jobs editjobs list " + job.getName() + " " + actionT
.getName() + " " + one.getName());
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.materialRemove"), "&cRemove", "jobs editjobs remove " + job.getName() + " " + actionT.getName() + " " + one
.getName());
rm.show(sender);
}
RawMessage rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.material", "%materialname%", materialName), one.getName(), "jobs editjobs list " + job.getName() + " " + actionT
.getName() + " " + one.getName());
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.materialRemove"), "&cRemove", "jobs editjobs remove " + job.getName() + " " + actionT.getName() + " " + one
.getName());
rm.show(sender);
}
RawMessage rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.materialAdd"), "&eAdd new", "jobs editjobs add " + job.getName() + " " + actionT.getName());
rm.show(sender);
Util.getJobsEditorMap().remove(player.getUniqueId());
RawMessage rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.materialAdd"), "&eAdd new", "jobs editjobs add " + job.getName() + " " + actionT.getName());
rm.show(sender);
Util.getJobsEditorMap().remove(player.getUniqueId());
pi.autoPagination(sender, "jobs editjobs list " + job.getName() + " " + actionT.getName());
return true;
}
return true;
}
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
ActionType actionT = ActionType.getByName(args[2]);
if (actionT == null)
return false;
ActionType actionT = ActionType.getByName(args[2]);
if (actionT == null)
return false;
List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty())
return false;
List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty())
return false;
JobInfo jInfo = null;
for (JobInfo one : action) {
if (one.getName().equalsIgnoreCase(args[3])) {
jInfo = one;
break;
}
}
JobInfo jInfo = null;
for (JobInfo one : action) {
if (one.getName().equalsIgnoreCase(args[3])) {
jInfo = one;
break;
}
}
if (jInfo == null)
return false;
if (jInfo == null)
return false;
showPath(player, job, actionT, jInfo);
showPath(player, job, actionT, jInfo);
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() + " "
+ actionT.getName() + " " + jInfo.getName() + " money ");
rm.show(sender);
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() + " "
+ actionT.getName() + " " + jInfo.getName() + " money ");
rm.show(sender);
rm = new RawMessage();
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()
+ " points ");
rm.show(sender);
rm = new RawMessage();
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()
+ " points ");
rm.show(sender);
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
.getName() + " " + jInfo.getName() + " exp ");
rm.show(sender);
Util.getJobsEditorMap().remove(player.getUniqueId());
return true;
}
break;
case "modify":
if (args.length == 5) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
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
.getName() + " " + jInfo.getName() + " exp ");
rm.show(sender);
Util.getJobsEditorMap().remove(player.getUniqueId());
return true;
}
break;
case "modify":
if (args.length == 5) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
ActionType actionT = ActionType.getByName(args[2]);
if (actionT == null)
return false;
ActionType actionT = ActionType.getByName(args[2]);
if (actionT == null)
return false;
List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty())
return false;
List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty())
return false;
JobInfo jInfo = null;
for (JobInfo one : action) {
if (one.getName().equalsIgnoreCase(args[3])) {
jInfo = one;
break;
}
}
JobInfo jInfo = null;
for (JobInfo one : action) {
if (one.getName().equalsIgnoreCase(args[3])) {
jInfo = one;
break;
}
}
if (jInfo == null)
return false;
if (jInfo == null)
return false;
CurrencyType type = CurrencyType.getByName(args[4]);
if (type == null)
return false;
CurrencyType type = CurrencyType.getByName(args[4]);
if (type == null)
return false;
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"));
return true;
}
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"));
return true;
}
if (args.length == 6) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
if (args.length == 6) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
ActionType actionT = ActionType.getByName(args[2]);
if (actionT == null)
return false;
ActionType actionT = ActionType.getByName(args[2]);
if (actionT == null)
return false;
List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty())
return false;
List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty())
return false;
JobInfo jInfo = null;
for (JobInfo one : action) {
if (one.getName().equalsIgnoreCase(args[3])) {
jInfo = one;
break;
}
}
JobInfo jInfo = null;
for (JobInfo one : action) {
if (one.getName().equalsIgnoreCase(args[3])) {
jInfo = one;
break;
}
}
if (jInfo == null)
return false;
if (jInfo == null)
return false;
CurrencyType type = CurrencyType.getByName(args[4]);
if (type == null)
return false;
CurrencyType type = CurrencyType.getByName(args[4]);
if (type == null)
return false;
Double value = null;
try {
value = Double.parseDouble(args[5]);
} catch (Exception e) {
return false;
}
Double value = null;
try {
value = Double.parseDouble(args[5]);
} catch (Exception e) {
return false;
}
String sType = null;
switch (type) {
case EXP:
sType = "experience";
jInfo.setBaseXp(value);
break;
case MONEY:
sType = "income";
jInfo.setBaseIncome(value);
break;
case POINTS:
sType = "points";
jInfo.setBasePoints(value);
break;
default:
break;
}
String sType = null;
switch (type) {
case EXP:
sType = "experience";
jInfo.setBaseXp(value);
break;
case MONEY:
sType = "income";
jInfo.setBaseIncome(value);
break;
case POINTS:
sType = "points";
jInfo.setBasePoints(value);
break;
default:
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;
}
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;
case "remove":
// remove miner break stone:1
break;
case "remove":
// remove miner break stone:1
if (args.length == 4) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
if (args.length == 4) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
ActionType actionT = ActionType.getByName(args[2]);
if (actionT == null)
return false;
ActionType actionT = ActionType.getByName(args[2]);
if (actionT == null)
return false;
List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty())
return false;
List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty())
return false;
JobInfo jInfo = null;
for (JobInfo info : action) {
if (!info.getName().equalsIgnoreCase(args[3]))
continue;
jInfo = info;
break;
}
JobInfo jInfo = null;
for (JobInfo info : action) {
if (!info.getName().equalsIgnoreCase(args[3]))
continue;
jInfo = info;
break;
}
if (jInfo == null) {
return true;
}
if (jInfo == null) {
return true;
}
action.remove(jInfo);
Jobs.getConfigManager().changeJobsSettings(args[1], jInfo.getConfigPath(), null);
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
action.remove(jInfo);
Jobs.getConfigManager().changeJobsSettings(args[1], jInfo.getConfigPath(), null);
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) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
if (args.length == 3) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
ActionType actionT = ActionType.getByName(args[2]);
if (actionT == null)
return false;
ActionType actionT = ActionType.getByName(args[2]);
if (actionT == null)
return false;
List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty())
return false;
List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty())
return false;
RawMessage rm = new RawMessage();
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);
RawMessage rm = new RawMessage();
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);
Util.getJobsEditorMap().put(player.getUniqueId(), "jobs editjobs add " + job.getName() + " " + actionT.getName() + " ");
return true;
}
Util.getJobsEditorMap().put(player.getUniqueId(), "jobs editjobs add " + job.getName() + " " + actionT.getName() + " ");
return true;
}
if (args.length == 4) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
if (args.length == 4) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
ActionType actionT = ActionType.getByName(args[2]);
if (actionT == null)
return false;
ActionType actionT = ActionType.getByName(args[2]);
if (actionT == null)
return false;
List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty())
return false;
List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty())
return false;
String key = args[3];
switch (args[3]) {
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 key = args[3];
switch (args[3]) {
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;
}
KeyValues keyValue = Jobs.getConfigManager().getKeyValue(key, actionT, job.getName());
if (keyValue == null)
return false;
KeyValues keyValue = Jobs.getConfigManager().getKeyValue(key, actionT, job.getName());
if (keyValue == null)
return false;
String type = keyValue.getType(),
subType = keyValue.getSubType(),
meta = keyValue.getMeta();
int id = keyValue.getId();
String type = keyValue.getType(),
subType = keyValue.getSubType(),
meta = keyValue.getMeta();
int id = keyValue.getId();
double income = 0D,
points = 0D,
experience = 0D;
double income = 0D,
points = 0D,
experience = 0D;
int fromlevel = 1;
int untilLevel = -1;
int fromlevel = 1;
int untilLevel = -1;
JobInfo jInfo = new JobInfo(actionT, id, meta, type + subType, income, job.getMoneyEquation(), experience, job.getXpEquation(), job.getPointsEquation(), points, fromlevel,
untilLevel, job.getName() + "/" + actionT.getName() + "/" + (type + subType).replace(":", "-"));
JobInfo jInfo = new JobInfo(actionT, id, meta, type + subType, income, job.getMoneyEquation(), experience, job.getXpEquation(), job.getPointsEquation(), points, fromlevel,
untilLevel, job.getName() + "/" + actionT.getName() + "/" + (type + subType).replace(":", "-"));
for (JobInfo info : job.getJobInfo(actionT)) {
if (info.getName().equalsIgnoreCase(jInfo.getName())) {
player.performCommand("jobs editjobs list " + job.getName() + " " + actionT.getName() + " " + jInfo.getName());
return true;
}
}
for (JobInfo info : job.getJobInfo(actionT)) {
if (info.getName().equalsIgnoreCase(jInfo.getName())) {
player.performCommand("jobs editjobs list " + job.getName() + " " + actionT.getName() + " " + jInfo.getName());
return true;
}
}
action.add(jInfo);
player.performCommand("jobs editjobs list " + job.getName() + " " + actionT.getName() + " " + jInfo.getName());
action.add(jInfo);
player.performCommand("jobs editjobs list " + job.getName() + " " + actionT.getName() + " " + jInfo.getName());
Jobs.getConfigManager().changeJobsSettings(args[1], jInfo.getConfigPath() + "/income", 0);
Jobs.getConfigManager().changeJobsSettings(args[1], jInfo.getConfigPath() + "/points", 0);
Jobs.getConfigManager().changeJobsSettings(args[1], jInfo.getConfigPath() + "/experience", 0);
Jobs.getConfigManager().changeJobsSettings(args[1], jInfo.getConfigPath() + "/income", 0);
Jobs.getConfigManager().changeJobsSettings(args[1], jInfo.getConfigPath() + "/points", 0);
Jobs.getConfigManager().changeJobsSettings(args[1], jInfo.getConfigPath() + "/experience", 0);
Util.getJobsEditorMap().remove(player.getUniqueId());
return true;
}
Util.getJobsEditorMap().remove(player.getUniqueId());
return true;
}
break;
default:
break;
}
break;
default:
break;
}
return true;
return true;
}
private static void showPath(Player player, Job job, ActionType action, JobInfo jInfo) {
RawMessage rm = new RawMessage();
rm.addText(Jobs.getLanguage().getMessage("command.editjobs.help.list.job")).addHover("&eJob list")
.addCommand("jobs editjobs").show(player);
RawMessage rm = new RawMessage();
rm.addText(Jobs.getLanguage().getMessage("command.editjobs.help.list.job")).addHover("&eJob list")
.addCommand("jobs editjobs").show(player);
if (job != null) {
rm = new RawMessage();
rm.addText(Jobs.getLanguage().getMessage("command.editjobs.help.list.jobs", "%jobname%", job.getDisplayName()))
.addHover(job.getName()).addCommand("jobs editjobs list " + job.getName());
rm.show(player);
}
if (job != null) {
rm = new RawMessage();
rm.addText(Jobs.getLanguage().getMessage("command.editjobs.help.list.jobs", "%jobname%", job.getDisplayName()))
.addHover(job.getName()).addCommand("jobs editjobs list " + job.getName());
rm.show(player);
}
if (action != null && job != null) {
rm = new RawMessage();
if (action != null && job != null) {
rm = new RawMessage();
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")
.show(player);
}
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")
.show(player);
}
if (action != null && job != null && jInfo != null) {
rm = new RawMessage();
if (action != null && job != null && jInfo != null) {
rm = new RawMessage();
String materialName = jInfo.getName().toLowerCase().replace('_', ' ');
materialName = Character.toUpperCase(materialName.charAt(0)) + materialName.substring(1);
materialName = Jobs.getNameTranslatorManager().translate(materialName, jInfo);
materialName = CMIChatColor.translate(materialName);
String materialName = jInfo.getName().toLowerCase().replace('_', ' ');
materialName = Character.toUpperCase(materialName.charAt(0)) + materialName.substring(1);
materialName = Jobs.getNameTranslatorManager().translate(materialName, jInfo);
materialName = CMIChatColor.translate(materialName);
rm.addText(Jobs.getLanguage().getMessage("command.editjobs.help.list.material", "%materialname%", jInfo.getName()))
.addHover(jInfo.getName()).addCommand("jobs editjobs list " + job.getName() + " " + action.getName()
+ " " + materialName).show(player);
}
rm.addText(Jobs.getLanguage().getMessage("command.editjobs.help.list.material", "%materialname%", jInfo.getName()))
.addHover(jInfo.getName()).addCommand("jobs editjobs list " + job.getName() + " " + action.getName()
+ " " + materialName).show(player);
}
}
}

View File

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

View File

@ -28,7 +28,6 @@ import net.Zrips.CMILib.Container.CMIText;
import net.Zrips.CMILib.Container.PageInfo;
import net.Zrips.CMILib.FileHandler.ConfigReader;
import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Logs.CMIDebug;
import net.Zrips.CMILib.RawMessages.RawMessage;
import net.Zrips.CMILib.RawMessages.RawMessageCommand;
@ -56,6 +55,7 @@ public class editquests implements Cmd {
Action action = null;
// Only informing here and not canceling command
if (!Jobs.getGCManager().DailyQuestsEnabled) {
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.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
public class employ implements Cmd {
@Override
public Boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (args.length < 2) {
Jobs.getCommandManager().sendUsage(sender, "employ");
return true;
}
if (args.length < 2) {
return false;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0]));
return true;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) {
Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args[0]);
return true;
}
Job job = Jobs.getJob(args[1]);
if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
Job job = Jobs.getJob(args[1]);
if (job == null) {
Language.sendMessage(sender, "general.error.job");
return true;
}
if (jPlayer.isInJob(job)) {
// already in job message
sender.sendMessage(Jobs.getLanguage().getMessage("command.employ.error.alreadyin", "%jobname%", job.getDisplayName()));
return true;
}
if (jPlayer.isInJob(job)) {
// already in job message
Language.sendMessage(sender, "command.employ.error.alreadyin", "%jobname%", job.getDisplayName());
return true;
}
if (job.getMaxSlots() != null && Jobs.getUsedSlots(job) >= job.getMaxSlots()) {
String message = Jobs.getLanguage().getMessage("command.employ.error.fullslots");
message = message.replace("%jobname%", job.getDisplayName());
sender.sendMessage(message);
return true;
}
if (job.getMaxSlots() != null && Jobs.getUsedSlots(job) >= job.getMaxSlots()) {
Language.sendMessage(sender, "command.employ.error.fullslots", "%jobname%", job.getDisplayName());
return true;
}
try {
// check if player already has the job
Jobs.getPlayerManager().joinJob(jPlayer, job);
Player player = jPlayer.getPlayer();
if (player != null)
player.sendMessage(Jobs.getLanguage().getMessage("command.employ.output.target", "%jobname%", job.getDisplayName()));
try {
// check if player already has the job
Jobs.getPlayerManager().joinJob(jPlayer, job);
Player player = jPlayer.getPlayer();
if (player != null)
Language.sendMessage(player, "command.employ.output.target", "%jobname%", job.getDisplayName());
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success"));
} catch (Throwable e) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.error"));
}
return true;
Language.sendMessage(sender, "general.admin.success");
} catch (Throwable e) {
Language.sendMessage(sender, "general.admin.error");
}
return true;
}
}

View File

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

View File

@ -24,8 +24,7 @@ public class exp implements Cmd {
public Boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (args.length < 4) {
Jobs.getCommandManager().sendUsage(sender, "exp");
return true;
return false;
}
boolean silent = false;
@ -120,20 +119,20 @@ public class exp implements Cmd {
Player player = jPlayer.getPlayer();
if (player == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.give.output.notonline"));
Language.sendMessage(sender, "general.give.output.notonline");
return true;
}
if (!silent)
player.sendMessage(Jobs.getLanguage().getMessage("command.exp.output.target", "%jobname%", job.getDisplayName(), "%level%", prog.getLevelFormatted(), "%exp%", prog
.getExperience()));
Language.sendMessage(player, "command.exp.output.target", "%jobname%", job.getDisplayName(), "%level%", prog.getLevelFormatted(), "%exp%", prog
.getExperience());
if (!silentAdmin)
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success"));
Language.sendMessage(sender, "general.admin.success");
} catch (Exception e) {
if (!silentAdmin)
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.error"));
Language.sendMessage(sender, "general.admin.error");
e.printStackTrace();
}
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.ExploreRegion;
import com.gamingmesh.jobs.container.PlayerInfo;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC;
public class explored implements Cmd {
@Override
public Boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (!(sender instanceof Player))
return false;
if (!(sender instanceof Player)) {
LC.info_Ingame.sendMessage(sender);
return null;
}
Player player = (Player) sender;
Map<String, ExploreRegion> exploreRegion = Jobs.getExploreManager().getWorlds().get(player.getWorld().getName());
Player player = (Player) sender;
Map<String, ExploreRegion> exploreRegion = Jobs.getExploreManager().getWorlds().get(player.getWorld().getName());
if (exploreRegion == null) {
player.sendMessage(Jobs.getLanguage().getMessage("command.explored.error.noexplore"));
return true;
}
if (exploreRegion == null) {
Language.sendMessage(sender, "command.explored.error.noexplore");
return true;
}
int RegionX = (int) Math.floor(player.getLocation().getChunk().getX() / 32D);
int RegionZ = (int) Math.floor(player.getLocation().getChunk().getZ() / 32D);
ExploreRegion region = exploreRegion.get(RegionX + ":" + RegionZ);
if (region == null) {
player.sendMessage(Jobs.getLanguage().getMessage("command.explored.error.noexplore"));
return true;
}
int RegionX = (int) Math.floor(player.getLocation().getChunk().getX() / 32D);
int RegionZ = (int) Math.floor(player.getLocation().getChunk().getZ() / 32D);
ExploreRegion region = exploreRegion.get(RegionX + ":" + RegionZ);
if (region == null) {
Language.sendMessage(sender, "command.explored.error.noexplore");
return true;
}
ExploreChunk chunk = region.getChunk(player.getLocation().getChunk());
ExploreChunk chunk = region.getChunk(player.getLocation().getChunk());
if (chunk == null) {
player.sendMessage(Jobs.getLanguage().getMessage("command.explored.error.noexplore"));
return true;
}
if (chunk == null) {
Language.sendMessage(sender, "command.explored.error.noexplore");
return true;
}
if (Jobs.getGCManager().ExploreCompact && chunk.isFullyExplored()) {
player.sendMessage(Jobs.getLanguage().getMessage("command.explored.fullExplore"));
return true;
}
if (Jobs.getGCManager().ExploreCompact && chunk.isFullyExplored()) {
Language.sendMessage(sender, "command.explored.fullExplore");
return true;
}
java.util.List<Integer> players = chunk.getPlayers();
java.util.List<Integer> players = chunk.getPlayers();
for (int i = 0; i < players.size(); i++) {
PlayerInfo ji = Jobs.getPlayerManager().getPlayerInfo(players.get(i));
if (ji != null)
player.sendMessage(Jobs.getLanguage().getMessage("command.explored.list", "%place%", i + 1, "%playername%", ji.getName()));
}
player.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
for (int i = 0; i < players.size(); i++) {
PlayerInfo ji = Jobs.getPlayerManager().getPlayerInfo(players.get(i));
if (ji != null)
Language.sendMessage(sender, "command.explored.list", "%place%", i + 1, "%playername%", ji.getName());
}
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.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
public class fire implements Cmd {
@Override
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length < 2) {
Jobs.getCommandManager().sendUsage(sender, "fire");
return true;
}
if (args.length < 2) {
return false;
}
Job job = Jobs.getJob(args[1]);
if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
Job job = Jobs.getJob(args[1]);
if (job == null) {
Language.sendMessage(sender, "general.error.job");
return true;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0]));
return true;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) {
Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args[0]);
return true;
}
if (!jPlayer.isInJob(job)) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.fire.error.nojob", "%jobname%", job.getDisplayName()));
return true;
}
if (!jPlayer.isInJob(job)) {
Language.sendMessage(sender, "command.fire.error.nojob", "%jobname%", job.getDisplayName());
return true;
}
if (Jobs.getPlayerManager().leaveJob(jPlayer, job)) {
Player player = jPlayer.getPlayer();
if (player != null)
player.sendMessage(Jobs.getLanguage().getMessage("command.fire.output.target", "%jobname%", job.getDisplayName()));
if (Jobs.getPlayerManager().leaveJob(jPlayer, job)) {
Player player = jPlayer.getPlayer();
if (player != null)
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.JobsPlayer;
import com.gamingmesh.jobs.dao.JobsDAO.DBTables;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Messages.CMIMessages;
@ -16,49 +17,48 @@ public class fireall implements Cmd {
@Override
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length < 1) {
Jobs.getCommandManager().sendUsage(sender, "fireall");
return true;
}
if (args.length < 1) {
return false;
}
if (args[0].equalsIgnoreCase("all")) {
if (sender instanceof Player) {
CMIMessages.sendMessage(sender, LC.info_FromConsole);
return true;
}
if (args[0].equalsIgnoreCase("all")) {
if (sender instanceof Player) {
CMIMessages.sendMessage(sender, LC.info_FromConsole);
return true;
}
Jobs.getDBManager().getDB().truncate(DBTables.JobsTable.getTableName());
Jobs.getDBManager().getDB().truncate(DBTables.JobsTable.getTableName());
for (JobsPlayer one : Jobs.getPlayerManager().getPlayersCache().values()) {
for (JobProgression job : one.getJobProgression()) {
Jobs.getJobsDAO().recordToArchive(one, job.getJob());
}
one.leaveAllJobs();
// No need to save as we are clearing database with more efficient method
one.setSaved(true);
}
for (JobsPlayer one : Jobs.getPlayerManager().getPlayersCache().values()) {
for (JobProgression job : one.getJobProgression()) {
Jobs.getJobsDAO().recordToArchive(one, job.getJob());
}
one.leaveAllJobs();
// No need to save as we are clearing database with more efficient method
one.setSaved(true);
}
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success"));
return true;
}
Language.sendMessage(sender, "general.admin.success");
return true;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0]));
return true;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) {
Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args[0]);
return true;
}
if (jPlayer.progression.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.fireall.error.nojobs"));
return true;
}
if (jPlayer.progression.isEmpty()) {
Language.sendMessage(sender, "command.fireall.error.nojobs");
return true;
}
Jobs.getPlayerManager().leaveAllJobs(jPlayer);
Player player = jPlayer.getPlayer();
if (player != null)
player.sendMessage(Jobs.getLanguage().getMessage("command.fireall.output.target"));
Jobs.getPlayerManager().leaveAllJobs(jPlayer);
Player player = jPlayer.getPlayer();
if (player != null)
Language.sendMessage(player, "command.fireall.output.target");
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success"));
return true;
Language.sendMessage(sender, "general.admin.success");
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.JobItems;
import com.gamingmesh.jobs.container.JobLimitedItems;
import com.gamingmesh.jobs.i18n.Language;
import com.gamingmesh.jobs.stuff.GiveItem;
public class give implements Cmd {
private enum actions {
items, limiteditems;
public static actions getByname(String name) {
for (actions one : actions.values()) {
if (one.name().equalsIgnoreCase(name))
return one;
}
return null;
}
items, limiteditems;
public static actions getByname(String name) {
for (actions one : actions.values()) {
if (one.name().equalsIgnoreCase(name))
return one;
}
return null;
}
}
@Override
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
Player player = null;
Job job = null;
actions name = null;
String itemName = null;
Player player = null;
Job job = null;
actions name = null;
String itemName = null;
for (String one : args) {
if (player == null) {
player = Bukkit.getPlayer(one);
if (player != null)
continue;
}
for (String one : args) {
if (player == null) {
player = Bukkit.getPlayer(one);
if (player != null)
continue;
}
if (job == null) {
job = Jobs.getJob(one);
if (job != null)
continue;
}
if (job == null) {
job = Jobs.getJob(one);
if (job != null)
continue;
}
if (name == null) {
name = actions.getByname(one);
if (name != null)
continue;
}
itemName = one;
}
if (name == null) {
name = actions.getByname(one);
if (name != null)
continue;
}
itemName = one;
}
if (player == null && sender instanceof Player)
player = (Player) sender;
if (player == null && sender instanceof Player)
player = (Player) sender;
if (player == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.give.output.notonline"));
return true;
}
if (player == null) {
Language.sendMessage(sender, "command.give.output.notonline");
return null;
}
if (name == null)
name = actions.items;
if (name == null)
name = actions.items;
if (itemName == null) {
Jobs.getCommandManager().sendUsage(sender, "give");
return true;
}
if (itemName == null) {
Jobs.getCommandManager().sendUsage(sender, "give");
return true;
}
switch (name) {
case items:
JobItems jItem = ItemBoostManager.getItemByKey(itemName);
ItemStack item = jItem == null ? null : jItem.getItemStack(player);
switch (name) {
case items:
JobItems jItem = ItemBoostManager.getItemByKey(itemName);
ItemStack item = jItem == null ? null : jItem.getItemStack(player);
if (item == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.give.output.noitem"));
return true;
}
if (item == null) {
Language.sendMessage(sender, "command.give.output.noitem");
return true;
}
GiveItem.giveItemForPlayer(player, item);
break;
case limiteditems:
if (job == null) {
Jobs.getCommandManager().sendUsage(sender, "give");
return true;
}
GiveItem.giveItemForPlayer(player, item);
break;
case limiteditems:
if (job == null) {
Jobs.getCommandManager().sendUsage(sender, "give");
return true;
}
JobLimitedItems jLItem = job.getLimitedItems().get(itemName.toLowerCase());
ItemStack limItem = jLItem == null ? null : jLItem.getItemStack(player);
JobLimitedItems jLItem = job.getLimitedItems().get(itemName.toLowerCase());
ItemStack limItem = jLItem == null ? null : jLItem.getItemStack(player);
if (limItem == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.give.output.noitem"));
return true;
}
if (limItem == null) {
Language.sendMessage(sender, "command.give.output.noitem");
return true;
}
GiveItem.giveItemForPlayer(player, limItem);
break;
default:
break;
}
return true;
GiveItem.giveItemForPlayer(player, limItem);
break;
default:
break;
}
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.LogAmounts;
import com.gamingmesh.jobs.container.PlayerInfo;
import com.gamingmesh.jobs.i18n.Language;
import com.gamingmesh.jobs.stuff.Sorting;
import net.Zrips.CMILib.Time.CMITimeManager;
@ -23,100 +24,99 @@ public class glog implements Cmd {
@Override
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length != 0) {
Jobs.getCommandManager().sendUsage(sender, "glog");
return true;
}
if (args.length != 0) {
return false;
}
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
Map<LogAmounts, Double> unsortMap = new HashMap<>();
int time = CMITimeManager.timeInInt();
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
Map<LogAmounts, Double> unsortMap = new HashMap<>();
int time = CMITimeManager.timeInInt();
for (Integer oneP : Jobs.getJobsDAO().getLognameList(time, time)) {
PlayerInfo info = Jobs.getPlayerManager().getPlayerInfo(oneP);
if (info == null)
continue;
for (Integer oneP : Jobs.getJobsDAO().getLognameList(time, time)) {
PlayerInfo info = Jobs.getPlayerManager().getPlayerInfo(oneP);
if (info == null)
continue;
String name = info.getName();
if (name == null)
continue;
String name = info.getName();
if (name == null)
continue;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(info.getUuid());
if (jPlayer == null)
continue;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(info.getUuid());
if (jPlayer == null)
continue;
Map<String, Log> logList = jPlayer.getLog();
if (logList == null || logList.isEmpty())
continue;
Map<String, Log> logList = jPlayer.getLog();
if (logList == null || logList.isEmpty())
continue;
for (Log l : logList.values()) {
for (LogAmounts amounts : l.getAmountList().values()) {
amounts.setUsername(name);
amounts.setAction(l.getActionType());
unsortMap.put(amounts, amounts.get(CurrencyType.MONEY));
}
}
}
for (Log l : logList.values()) {
for (LogAmounts amounts : l.getAmountList().values()) {
amounts.setUsername(name);
amounts.setAction(l.getActionType());
unsortMap.put(amounts, amounts.get(CurrencyType.MONEY));
}
}
}
unsortMap = Sorting.sortDoubleDESCByLog(unsortMap);
if (unsortMap.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.glog.output.nodata"));
return;
}
unsortMap = Sorting.sortDoubleDESCByLog(unsortMap);
if (unsortMap.isEmpty()) {
Language.sendMessage(sender, "command.glog.output.nodata");
return;
}
int count = 1, max = 10;
int count = 1, max = 10;
double totalMoney = 0,
totalExp = 0,
totalPoints = 0;
double totalMoney = 0,
totalExp = 0,
totalPoints = 0;
sender.sendMessage(Jobs.getLanguage().getMessage("command.glog.output.topline"));
for (LogAmounts info : unsortMap.keySet()) {
double money = info.get(CurrencyType.MONEY);
totalMoney += money;
Language.sendMessage(sender, "command.glog.output.topline");
for (LogAmounts info : unsortMap.keySet()) {
double money = info.get(CurrencyType.MONEY);
totalMoney += money;
String moneyS = "";
if (money != 0D)
moneyS = Jobs.getLanguage().getMessage("command.glog.output.money", "%amount%", money);
String moneyS = "";
if (money != 0D)
moneyS = Jobs.getLanguage().getMessage("command.glog.output.money", "%amount%", money);
double exp = info.get(CurrencyType.EXP);
totalExp += exp;
double exp = info.get(CurrencyType.EXP);
totalExp += exp;
String expS = "";
if (exp != 0D)
expS = Jobs.getLanguage().getMessage("command.glog.output.exp", "%amount%", exp);
String expS = "";
if (exp != 0D)
expS = Jobs.getLanguage().getMessage("command.glog.output.exp", "%amount%", exp);
double points = info.get(CurrencyType.POINTS);
totalPoints += points;
double points = info.get(CurrencyType.POINTS);
totalPoints += points;
String pointsS = "";
if (points != 0D)
pointsS = Jobs.getLanguage().getMessage("command.glog.output.points", "%amount%", points);
String pointsS = "";
if (points != 0D)
pointsS = Jobs.getLanguage().getMessage("command.glog.output.points", "%amount%", points);
sender.sendMessage(Jobs.getLanguage().getMessage("command.glog.output.ls",
"%number%", count,
"%action%", info.getAction(),
"%item%", info.getItemName().replace(":0", "").replace('_', ' ').toLowerCase(),
"%qty%", info.getCount(),
"%money%", moneyS,
"%exp%", expS,
"%points%", pointsS));
Language.sendMessage(sender, "command.glog.output.ls",
"%number%", count,
"%action%", info.getAction(),
"%item%", info.getItemName().replace(":0", "").replace('_', ' ').toLowerCase(),
"%qty%", info.getCount(),
"%money%", moneyS,
"%exp%", expS,
"%points%", pointsS);
count++;
count++;
if (count > max)
break;
}
if (count > max)
break;
}
NumberFormat format = NumberFormat.getInstance(Locale.ENGLISH);
sender.sendMessage(Jobs.getLanguage().getMessage("command.glog.output.totalIncomes", "%money%", format.format(totalMoney),
"%exp%", format.format(totalExp), "%points%", format.format(totalPoints)));
NumberFormat format = NumberFormat.getInstance(Locale.ENGLISH);
Language.sendMessage(sender, "command.glog.output.totalIncomes", "%money%", format.format(totalMoney),
"%exp%", format.format(totalExp), "%points%", format.format(totalPoints));
sender.sendMessage(Jobs.getLanguage().getMessage("command.glog.output.bottomline"));
}
});
return true;
Language.sendMessage(sender, "command.glog.output.bottomline");
}
});
return true;
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -7,6 +7,7 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
import com.gamingmesh.jobs.stuff.Util;
import net.Zrips.CMILib.Locale.LC;
@ -16,50 +17,51 @@ public class leave implements Cmd {
@Override
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (!(sender instanceof Player))
return false;
if (!(sender instanceof Player)) {
LC.info_Ingame.sendMessage(sender);
return null;
}
if (args.length < 1) {
Jobs.getCommandManager().sendUsage(sender, "leave");
return true;
}
if (args.length < 1) {
return false;
}
Player pSender = (Player) sender;
Job job = Jobs.getJob(args[0]);
if (job == null) {
pSender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
Player pSender = (Player) sender;
Job job = Jobs.getJob(args[0]);
if (job == null) {
Language.sendMessage(sender, "general.error.job");
return true;
}
if (Jobs.getGCManager().UsePerPermissionForLeaving && !pSender.hasPermission("jobs.command.leave." + args[0].toLowerCase())) {
CMIMessages.sendMessage(pSender, LC.info_NoPermission);
return true;
}
if (Jobs.getGCManager().UsePerPermissionForLeaving && !pSender.hasPermission("jobs.command.leave." + args[0].toLowerCase())) {
CMIMessages.sendMessage(sender, LC.info_NoPermission);
return true;
}
if (Jobs.getGCManager().EnableConfirmation) {
java.util.UUID uuid = pSender.getUniqueId();
if (Jobs.getGCManager().EnableConfirmation) {
java.util.UUID uuid = pSender.getUniqueId();
if (!Util.LEAVECONFIRM.contains(uuid)) {
Util.LEAVECONFIRM.add(uuid);
if (!Util.LEAVECONFIRM.contains(uuid)) {
Util.LEAVECONFIRM.add(uuid);
plugin.getServer().getScheduler().runTaskLater(plugin, () -> Util.LEAVECONFIRM.remove(uuid),
20 * Jobs.getGCManager().ConfirmExpiryTime);
plugin.getServer().getScheduler().runTaskLater(plugin, () -> Util.LEAVECONFIRM.remove(uuid),
20 * Jobs.getGCManager().ConfirmExpiryTime);
pSender.sendMessage(Jobs.getLanguage().getMessage("command.leave.confirmationNeed", "[jobname]",
job.getDisplayName(), "[time]", Jobs.getGCManager().ConfirmExpiryTime));
return true;
}
Language.sendMessage(sender, "command.leave.confirmationNeed", "[jobname]",
job.getDisplayName(), "[time]", Jobs.getGCManager().ConfirmExpiryTime);
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))
pSender.sendMessage(Jobs.getLanguage().getMessage("command.leave.success", "%jobname%", job.getDisplayName(), "[jobname]", job.getDisplayName()));
else
pSender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
if (Jobs.getPlayerManager().leaveJob(jPlayer, job))
Language.sendMessage(sender, "command.leave.success", "%jobname%", job.getDisplayName(), "[jobname]", job.getDisplayName());
else
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.container.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
import com.gamingmesh.jobs.stuff.Util;
import net.Zrips.CMILib.Locale.LC;
@ -18,39 +19,39 @@ public class leaveall implements Cmd {
@Override
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (!(sender instanceof Player)) {
CMIMessages.sendMessage(sender, LC.info_Ingame);
return false;
}
if (!(sender instanceof Player)) {
CMIMessages.sendMessage(sender, LC.info_Ingame);
return null;
}
Player pSender = (Player) sender;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender);
Player pSender = (Player) sender;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender);
List<JobProgression> jobs = jPlayer.getJobProgression();
if (jobs.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.leaveall.error.nojobs"));
return true;
}
List<JobProgression> jobs = jPlayer.getJobProgression();
if (jobs.isEmpty()) {
Language.sendMessage(sender, "command.leaveall.error.nojobs");
return true;
}
if (Jobs.getGCManager().EnableConfirmation) {
java.util.UUID uuid = pSender.getUniqueId();
if (Jobs.getGCManager().EnableConfirmation) {
java.util.UUID uuid = pSender.getUniqueId();
if (!Util.LEAVECONFIRM.contains(uuid)) {
Util.LEAVECONFIRM.add(uuid);
if (!Util.LEAVECONFIRM.contains(uuid)) {
Util.LEAVECONFIRM.add(uuid);
plugin.getServer().getScheduler().runTaskLater(plugin, () -> Util.LEAVECONFIRM.remove(uuid),
20 * Jobs.getGCManager().ConfirmExpiryTime);
plugin.getServer().getScheduler().runTaskLater(plugin, () -> Util.LEAVECONFIRM.remove(uuid),
20 * Jobs.getGCManager().ConfirmExpiryTime);
pSender.sendMessage(Jobs.getLanguage().getMessage("command.leaveall.confirmationNeed", "[time]",
Jobs.getGCManager().ConfirmExpiryTime));
return true;
}
Language.sendMessage(pSender, "command.leaveall.confirmationNeed", "[time]",
Jobs.getGCManager().ConfirmExpiryTime);
return true;
}
Util.LEAVECONFIRM.remove(uuid);
}
Util.LEAVECONFIRM.remove(uuid);
}
Jobs.getPlayerManager().leaveAllJobs(jPlayer);
sender.sendMessage(Jobs.getLanguage().getMessage("command.leaveall.success"));
return true;
Jobs.getPlayerManager().leaveAllJobs(jPlayer);
Language.sendMessage(sender, "command.leaveall.success");
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.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
public class level implements Cmd {
private enum Action {
Set, Add, Take
Set, Add, Take
}
@Override
public Boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (args.length < 4) {
Jobs.getCommandManager().sendUsage(sender, "level");
return true;
}
if (args.length < 4) {
return false;
}
Action action = Action.Add;
int amount = 0;
String playerName = null;
Job job = null;
Action action = Action.Add;
int amount = 0;
String playerName = null;
Job job = null;
for (String one : args) {
switch (one.toLowerCase()) {
case "set":
action = Action.Set;
continue;
case "add":
action = Action.Add;
continue;
case "take":
action = Action.Take;
continue;
default:
break;
}
for (String one : args) {
switch (one.toLowerCase()) {
case "set":
action = Action.Set;
continue;
case "add":
action = Action.Add;
continue;
case "take":
action = Action.Take;
continue;
default:
break;
}
try {
amount = Integer.parseInt(one);
continue;
} catch (NumberFormatException e) {
}
try {
amount = Integer.parseInt(one);
continue;
} catch (NumberFormatException e) {
}
if (job == null && (job = Jobs.getJob(one)) != null)
continue;
if (job == null && (job = Jobs.getJob(one)) != null)
continue;
playerName = one;
}
playerName = one;
}
if (playerName == null)
return false;
if (playerName == null)
return false;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(playerName);
if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0]));
return true;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(playerName);
if (jPlayer == null) {
Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args[0]);
return true;
}
if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
if (job == null) {
Language.sendMessage(sender, "general.error.job");
return true;
}
try {
// check if player already has the job
if (jPlayer.isInJob(job)) {
JobProgression prog = jPlayer.getJobProgression(job);
int total = 0;
try {
// check if player already has the job
if (jPlayer.isInJob(job)) {
JobProgression prog = jPlayer.getJobProgression(job);
int total = 0;
switch (action) {
case Set:
prog.setLevel(amount);
break;
case Add:
int oldLevel = prog.getLevel();
total = (oldLevel + amount);
switch (action) {
case Set:
prog.setLevel(amount);
break;
case Add:
int oldLevel = prog.getLevel();
total = (oldLevel + amount);
if (prog.setLevel(total)) {
JobsLevelUpEvent levelUpEvent = new JobsLevelUpEvent(jPlayer, job, prog.getLevel(),
Jobs.getTitleManager().getTitle(oldLevel, prog.getJob().getName()),
Jobs.getTitleManager().getTitle(prog.getLevel(), prog.getJob().getName()),
Jobs.getGCManager().SoundLevelupSound,
Jobs.getGCManager().SoundLevelupVolume,
Jobs.getGCManager().SoundLevelupPitch,
Jobs.getGCManager().SoundTitleChangeSound,
Jobs.getGCManager().SoundTitleChangeVolume,
Jobs.getGCManager().SoundTitleChangePitch);
if (prog.setLevel(total)) {
JobsLevelUpEvent levelUpEvent = new JobsLevelUpEvent(jPlayer, job, prog.getLevel(),
Jobs.getTitleManager().getTitle(oldLevel, prog.getJob().getName()),
Jobs.getTitleManager().getTitle(prog.getLevel(), prog.getJob().getName()),
Jobs.getGCManager().SoundLevelupSound,
Jobs.getGCManager().SoundLevelupVolume,
Jobs.getGCManager().SoundLevelupPitch,
Jobs.getGCManager().SoundTitleChangeSound,
Jobs.getGCManager().SoundTitleChangeVolume,
Jobs.getGCManager().SoundTitleChangePitch);
plugin.getServer().getPluginManager().callEvent(levelUpEvent);
plugin.getServer().getPluginManager().callEvent(levelUpEvent);
// If event is cancelled, don't do anything
if (levelUpEvent.isCancelled())
return true;
}
// If event is cancelled, don't do anything
if (levelUpEvent.isCancelled())
return true;
}
break;
case Take:
total = (prog.getLevel() - amount);
prog.setLevel(total);
break;
default:
break;
}
break;
case Take:
total = (prog.getLevel() - amount);
prog.setLevel(total);
break;
default:
break;
}
Player player = jPlayer.getPlayer();
if (player != null)
player.sendMessage(Jobs.getLanguage().getMessage("command.level.output.target", "%jobname%", job.getDisplayName(), "%level%", prog.getLevel(),
"%exp%", String.format(Jobs.getGCManager().getDecimalPlacesExp(), prog.getExperience())));
Player player = jPlayer.getPlayer();
if (player != null)
Language.sendMessage(player, "command.level.output.target", "%jobname%", job.getDisplayName(), "%level%", prog.getLevel(),
"%exp%", String.format(Jobs.getGCManager().getDecimalPlacesExp(), prog.getExperience()));
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success"));
} else
sender.sendMessage(Jobs.getLanguage().getMessage("command.level.error.nojob"));
} catch (Exception e) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.error"));
}
return true;
Language.sendMessage(sender, "general.admin.success");
} else
Language.sendMessage(sender, "command.level.error.nojob");
} catch (Exception e) {
Language.sendMessage(sender, "general.admin.error");
}
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.JobsPlayer;
import com.gamingmesh.jobs.economy.PaymentData;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Logs.CMIDebug;
@ -18,57 +19,56 @@ public class limit implements Cmd {
@Override
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length != 0 && args.length != 1) {
Jobs.getCommandManager().sendUsage(sender, "limit");
return true;
}
if (args.length != 0 && args.length != 1) {
return false;
}
JobsPlayer JPlayer = null;
if (args.length >= 1)
JPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
else if (sender instanceof Player)
JPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
JobsPlayer JPlayer = null;
if (args.length >= 1)
JPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
else if (sender instanceof Player)
JPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
boolean disabled = true;
for (CurrencyType type : CurrencyType.values()) {
if (Jobs.getGCManager().getLimit(type).isEnabled()) {
disabled = false;
break;
}
}
boolean disabled = true;
for (CurrencyType type : CurrencyType.values()) {
if (Jobs.getGCManager().getLimit(type).isEnabled()) {
disabled = false;
break;
}
}
if (disabled) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.limit.output.notenabled"));
return true;
}
if (disabled) {
Language.sendMessage(sender,"command.limit.output.notenabled");
return true;
}
if (JPlayer == null) {
if (args.length >= 1)
CMIMessages.sendMessage(sender, LC.info_NoInformation);
else if (!(sender instanceof Player))
Jobs.getCommandManager().sendUsage(sender, "limit");
return true;
}
if (JPlayer == null) {
if (args.length >= 1)
CMIMessages.sendMessage(sender, LC.info_NoInformation);
else if (!(sender instanceof Player))
Jobs.getCommandManager().sendUsage(sender, "limit");
return true;
}
for (CurrencyType type : CurrencyType.values()) {
if (!Jobs.getGCManager().getLimit(type).isEnabled())
continue;
PaymentData limit = JPlayer.getPaymentLimit();
for (CurrencyType type : CurrencyType.values()) {
if (!Jobs.getGCManager().getLimit(type).isEnabled())
continue;
PaymentData limit = JPlayer.getPaymentLimit();
if (limit.getLeftTime(type) <= 0) {
CMIDebug.d("reset", type);
limit.resetLimits(type);
}
if (limit.getLeftTime(type) <= 0) {
CMIDebug.d("reset", type);
limit.resetLimits(type);
}
if (limit.getLeftTime(type) > 0) {
String typeName = type.getName().toLowerCase();
if (limit.getLeftTime(type) > 0) {
String typeName = type.getName().toLowerCase();
sender.sendMessage(Jobs.getLanguage().getMessage("command.limit.output." + typeName + "time", "%time%", CMITimeManager.to24hourShort(limit.getLeftTime(type))));
sender.sendMessage(Jobs.getLanguage().getMessage("command.limit.output." + typeName + "Limit",
"%current%", (int) (limit.getAmount(type) * 100) / 100D,
"%total%", JPlayer.getLimit(type)));
}
}
return true;
Language.sendMessage(sender, "command.limit.output." + typeName + "time", "%time%", CMITimeManager.to24hourShort(limit.getLeftTime(type)));
Language.sendMessage(sender, "command.limit.output." + typeName + "Limit",
"%current%", (int) (limit.getAmount(type) * 100) / 100D,
"%total%", JPlayer.getLimit(type));
}
}
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.Log;
import com.gamingmesh.jobs.container.LogAmounts;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Container.CMISort;
import net.Zrips.CMILib.Locale.LC;
@ -24,113 +25,112 @@ public class log implements Cmd {
@Override
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (!(sender instanceof Player) && args.length != 1) {
CMIMessages.sendMessage(sender, LC.info_Ingame);
return false;
}
if (!(sender instanceof Player) && args.length != 1) {
CMIMessages.sendMessage(sender, LC.info_Ingame);
return null;
}
if (args.length != 1 && args.length != 0) {
Jobs.getCommandManager().sendUsage(sender, "log");
return true;
}
if (args.length != 1 && args.length != 0) {
return false;
}
JobsPlayer JPlayer = null;
if (args.length == 0)
JPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
else if (args.length == 1) {
if (!Jobs.hasPermission(sender, "jobs.command.log.others", true))
return true;
JobsPlayer JPlayer = null;
if (args.length == 0)
JPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
else if (args.length == 1) {
if (!Jobs.hasPermission(sender, "jobs.command.log.others", true))
return null;
JPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
}
JPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
}
if (JPlayer == null) {
Jobs.getCommandManager().sendUsage(sender, "log");
return true;
}
if (JPlayer == null) {
Jobs.getCommandManager().sendUsage(sender, "log");
return true;
}
Map<String, Log> logList = JPlayer.getLog();
if (logList == null || logList.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.log.output.bottomline"));
sender.sendMessage(Jobs.getLanguage().getMessage("command.log.output.nodata"));
sender.sendMessage(Jobs.getLanguage().getMessage("command.log.output.bottomline"));
return true;
}
Map<String, Log> logList = JPlayer.getLog();
if (logList == null || logList.isEmpty()) {
Language.sendMessage(sender, "command.log.output.bottomline");
Language.sendMessage(sender, "command.log.output.nodata");
Language.sendMessage(sender, "command.log.output.bottomline");
return true;
}
Map<String, Double> unsortMap = new HashMap<>();
Map<String, Double> unsortMap = new HashMap<>();
for (Log l : logList.values()) {
for (Entry<String, LogAmounts> oneMap : l.getAmountList().entrySet()) {
unsortMap.put(oneMap.getKey(), oneMap.getValue().get(CurrencyType.MONEY));
}
}
for (Log l : logList.values()) {
for (Entry<String, LogAmounts> oneMap : l.getAmountList().entrySet()) {
unsortMap.put(oneMap.getKey(), oneMap.getValue().get(CurrencyType.MONEY));
}
}
unsortMap = CMISort.sortDoubleDESC(unsortMap);
if (unsortMap.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.log.output.nodata"));
return true;
}
unsortMap = CMISort.sortDoubleDESC(unsortMap);
if (unsortMap.isEmpty()) {
Language.sendMessage(sender, "command.log.output.nodata");
return true;
}
int count = 0;
int max = 10;
int count = 0;
int max = 10;
sender.sendMessage(Jobs.getLanguage().getMessage("command.log.output.topline", "%playername%", JPlayer.getName(), "%playerdisplayname%", JPlayer.getDisplayName()));
for (Log one : logList.values()) {
double totalMoney = 0, totalExp = 0, totalPoints = 0;
Language.sendMessage(sender, "command.log.output.topline", "%playername%", JPlayer.getName(), "%playerdisplayname%", JPlayer.getDisplayName());
for (Log one : logList.values()) {
double totalMoney = 0, totalExp = 0, totalPoints = 0;
for (String oneSorted : unsortMap.keySet()) {
for (Entry<String, LogAmounts> oneMap : one.getAmountList().entrySet()) {
if (oneMap.getKey().equalsIgnoreCase(oneSorted)) {
count++;
for (String oneSorted : unsortMap.keySet()) {
for (Entry<String, LogAmounts> oneMap : one.getAmountList().entrySet()) {
if (oneMap.getKey().equalsIgnoreCase(oneSorted)) {
count++;
LogAmounts amounts = oneMap.getValue();
LogAmounts amounts = oneMap.getValue();
double money = amounts.get(CurrencyType.MONEY);
totalMoney = totalMoney + money;
double money = amounts.get(CurrencyType.MONEY);
totalMoney = totalMoney + money;
String moneyS = "";
if (money != 0D)
moneyS = Jobs.getLanguage().getMessage("command.log.output.money", "%amount%", money);
String moneyS = "";
if (money != 0D)
moneyS = Jobs.getLanguage().getMessage("command.log.output.money", "%amount%", money);
double exp = amounts.get(CurrencyType.EXP);
totalExp = totalExp + exp;
double exp = amounts.get(CurrencyType.EXP);
totalExp = totalExp + exp;
String expS = "";
if (exp != 0D)
expS = Jobs.getLanguage().getMessage("command.log.output.exp", "%amount%", exp);
String expS = "";
if (exp != 0D)
expS = Jobs.getLanguage().getMessage("command.log.output.exp", "%amount%", exp);
double points = amounts.get(CurrencyType.POINTS);
totalPoints = totalPoints + points;
double points = amounts.get(CurrencyType.POINTS);
totalPoints = totalPoints + points;
String pointsS = "";
if (points != 0D)
pointsS = Jobs.getLanguage().getMessage("command.log.output.points", "%amount%", points);
String pointsS = "";
if (points != 0D)
pointsS = Jobs.getLanguage().getMessage("command.log.output.points", "%amount%", points);
sender.sendMessage(Jobs.getLanguage().getMessage("command.log.output.ls",
"%number%", count,
"%action%", one.getActionType(),
"%item%", amounts.getItemName().replace(":0", "").replace('_', ' ').toLowerCase(),
"%qty%", amounts.getCount(),
"%money%", moneyS,
"%exp%", expS,
"%points%", pointsS));
break;
}
}
Language.sendMessage(sender, "command.log.output.ls",
"%number%", count,
"%action%", one.getActionType(),
"%item%", amounts.getItemName().replace(":0", "").replace('_', ' ').toLowerCase(),
"%qty%", amounts.getCount(),
"%money%", moneyS,
"%exp%", expS,
"%points%", pointsS);
break;
}
}
if (count > max)
break;
}
if (count > max)
break;
}
NumberFormat format = NumberFormat.getInstance(Locale.ENGLISH);
sender.sendMessage(Jobs.getLanguage().getMessage("command.log.output.totalIncomes", "%money%", format.format(totalMoney),
"%exp%", format.format(totalExp), "%points%", format.format(totalPoints)));
NumberFormat format = NumberFormat.getInstance(Locale.ENGLISH);
Language.sendMessage(sender, "command.log.output.totalIncomes", "%money%", format.format(totalMoney),
"%exp%", format.format(totalExp), "%points%", format.format(totalPoints));
if (count > max)
break;
}
if (count > max)
break;
}
sender.sendMessage(Jobs.getLanguage().getMessage("command.log.output.bottomline"));
return true;
Language.sendMessage(sender, "command.log.output.bottomline");
return true;
}
}

View File

@ -27,65 +27,65 @@ public class ownedblocks implements Cmd {
@Override
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
JobsPlayer jPlayer = null;
if (args.length >= 1) {
if (!Jobs.hasPermission(sender, "jobs.command.admin.ownedblocks", true))
return true;
jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
} else if (sender instanceof Player)
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
JobsPlayer jPlayer = null;
if (args.length >= 1) {
if (!Jobs.hasPermission(sender, "jobs.command.admin.ownedblocks", true))
return null;
jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
} else if (sender instanceof Player)
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
if (jPlayer == null) {
if (args.length >= 1)
CMIMessages.sendMessage(sender, LC.info_NoInformation);
else
Jobs.getCommandManager().sendUsage(sender, "ownedblocks");
return true;
}
if (jPlayer == null) {
if (args.length >= 1)
CMIMessages.sendMessage(sender, LC.info_NoInformation);
else
return false;
return null;
}
final JobsPlayer jp = jPlayer;
final JobsPlayer jp = jPlayer;
RawMessage rm = new RawMessage();
RawMessage rm = new RawMessage();
Snd snd = new Snd();
snd.setSender(sender);
snd.setTargetName(jp.getName());
Snd snd = new Snd();
snd.setSender(sender);
snd.setTargetName(jp.getName());
rm.addText(LC.info_PlayerSpliter.getLocale(snd));
rm.addText(LC.info_PlayerSpliter.getLocale(snd));
int i = 0;
for (BlockTypes type : BlockTypes.values()) {
int i = 0;
for (BlockTypes type : BlockTypes.values()) {
Optional<BlockOwnerShip> ownerShip = plugin.getBlockOwnerShip(type);
Optional<BlockOwnerShip> ownerShip = plugin.getBlockOwnerShip(type);
if (!ownerShip.isPresent())
continue;
if (!ownerShip.isPresent())
continue;
HashMap<String, blockLoc> records = ownerShip.get().getBlockOwnerShips().get(jp.getUniqueId());
if (records == null)
continue;
HashMap<String, blockLoc> records = ownerShip.get().getBlockOwnerShips().get(jp.getUniqueId());
if (records == null)
continue;
for (Entry<String, blockLoc> record : records.entrySet()) {
i++;
rm.addText("\n");
for (Entry<String, blockLoc> record : records.entrySet()) {
i++;
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.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());
if (record.getValue().isDisabled()) {
rm.addText(Jobs.getLanguage().getMessage("command.ownedblocks.output.disabled"));
rm.addHover(Jobs.getLanguage().getMessage("command.ownedblocks.output.disabledHover"));
}
}
}
rm.show(sender);
if (i == 0)
LC.info_nothingToShow.sendMessage(sender);
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.addCommand(JobsCommands.LABEL + " " + clearownership.class.getSimpleName() + " " + jp.getName() + " " + record.getKey());
if (record.getValue().isDisabled()) {
rm.addText(Jobs.getLanguage().getMessage("command.ownedblocks.output.disabled"));
rm.addHover(Jobs.getLanguage().getMessage("command.ownedblocks.output.disabledHover"));
}
}
}
rm.show(sender);
if (i == 0)
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.JobsPlaceholderType;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Container.PageInfo;
import net.Zrips.CMILib.Messages.CMIMessages;
@ -42,10 +43,10 @@ public class placeholders implements Cmd {
String placeholder = args[1];
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,
"[source]", type == null ? "Unknown" : type.name(),
"[result]", plugin.getPlaceholderAPIManager().updatePlaceHolders(player, placeholder)));
"[result]", plugin.getPlaceholderAPIManager().updatePlaceHolders(player, placeholder));
return true;
}
@ -72,17 +73,6 @@ public class placeholders implements Cmd {
if (plugin.isPlaceholderAPIEnabled()) {
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)
.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.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
public class playerinfo implements Cmd {
@Override
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length < 2) {
Jobs.getCommandManager().sendUsage(sender, "playerinfo");
Jobs.getCommandManager().sendValidActions(sender);
return true;
}
if (args.length < 2) {
Jobs.getCommandManager().sendValidActions(sender);
return false;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0]));
return true;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) {
Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args[0]);
return true;
}
Job job = Jobs.getJob(args[1]);
if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
Job job = Jobs.getJob(args[1]);
if (job == null) {
Language.sendMessage(sender, "general.error.job");
return true;
}
int page = 1;
String type = "";
if (args.length >= 3) {
try {
page = Integer.parseInt(args[2]);
} catch (NumberFormatException e) {
type = args[2];
}
}
int page = 1;
String type = "";
if (args.length >= 3) {
try {
page = Integer.parseInt(args[2]);
} catch (NumberFormatException e) {
type = args[2];
}
}
Jobs.getCommandManager().jobInfoMessage(sender, jPlayer, job, type, page);
return true;
Jobs.getCommandManager().jobInfoMessage(sender, jPlayer, job, type, page);
return true;
}
}

View File

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

View File

@ -7,62 +7,62 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
public class promote implements Cmd {
@Override
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length < 3) {
Jobs.getCommandManager().sendUsage(sender, "promote");
return true;
}
if (args.length < 3) {
return false;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0]));
return true;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) {
Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args[0]);
return true;
}
Job job = Jobs.getJob(args[1]);
if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
Job job = Jobs.getJob(args[1]);
if (job == null) {
Language.sendMessage(sender, "general.error.job");
return true;
}
// check if player already has the job
if (!jPlayer.isInJob(job))
return false;
// check if player already has the job
if (!jPlayer.isInJob(job))
return false;
try {
try {
int levelsGained = -1;
try {
levelsGained = Integer.parseInt(args[2]);
} catch (NumberFormatException ex) {
return false;
}
int levelsGained = -1;
try {
levelsGained = Integer.parseInt(args[2]);
} catch (NumberFormatException ex) {
return false;
}
boolean commands = false;
for (String one : args) {
if (one.equalsIgnoreCase("-cmd")) {
commands = true;
continue;
}
}
boolean commands = false;
for (String one : args) {
if (one.equalsIgnoreCase("-cmd")) {
commands = true;
continue;
}
}
Jobs.getPlayerManager().promoteJob(jPlayer, job, levelsGained, commands);
Jobs.getPlayerManager().promoteJob(jPlayer, job, levelsGained, commands);
Player player = jPlayer.getPlayer();
if (player != null)
player.sendMessage(Jobs.getLanguage().getMessage("command.promote.output.target",
"%jobname%", job.getDisplayName(),
"%levelsgained%", levelsGained));
Player player = jPlayer.getPlayer();
if (player != null)
Language.sendMessage(player, "command.promote.output.target",
"%jobname%", job.getDisplayName(),
"%levelsgained%", levelsGained);
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success"));
Language.sendMessage(sender, "general.admin.success");
} catch (Throwable e) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.error"));
}
return true;
} catch (Throwable e) {
Language.sendMessage(sender, "general.admin.error");
}
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.QuestObjective;
import com.gamingmesh.jobs.container.QuestProgression;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Messages.CMIMessages;
@ -27,7 +28,7 @@ public class quests implements Cmd {
if (!Jobs.getGCManager().DailyQuestsEnabled) {
LC.info_FeatureNotEnabled.sendMessage(sender);
return true;
return 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 (!Jobs.hasPermission(sender, "jobs.command.admin.quests", true))
return true;
return null;
jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
} else if (isPlayer)
@ -52,7 +53,7 @@ public class quests implements Cmd {
List<QuestProgression> questProgs = jPlayer.getQuestProgressions();
if (questProgs.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.quests.error.noquests"));
Language.sendMessage(sender, "command.quests.error.noquests");
return true;
}
@ -71,13 +72,13 @@ public class quests implements Cmd {
q.getQuest().setStopped(stopped);
}
sender.sendMessage(Jobs.getLanguage().getMessage("command.quests.status.changed", "%status%",
stopped ? Jobs.getLanguage().getMessage("command.quests.status.stopped") : Jobs.getLanguage().getMessage("command.quests.status.started")));
Language.sendMessage(sender, "command.quests.status.changed", "%status%",
stopped ? Jobs.getLanguage().getMessage("command.quests.status.stopped") : Jobs.getLanguage().getMessage("command.quests.status.started"));
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) {
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.commands.Cmd;
import com.gamingmesh.jobs.i18n.Language;
public class reload implements Cmd {
@Override
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
Jobs.reload();
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success"));
return true;
Jobs.reload();
Language.sendMessage(sender, "general.admin.success");
return true;
}
}

View File

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

View File

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

View File

@ -4,36 +4,36 @@ import org.bukkit.command.CommandSender;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
public class resetlimit implements Cmd {
@Override
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length != 1) {
Jobs.getCommandManager().sendUsage(sender, "resetlimit");
return true;
}
if (args.length != 1) {
return false;
}
if (args[0].equalsIgnoreCase("all")) {
for (org.bukkit.entity.Player pl : org.bukkit.Bukkit.getOnlinePlayers()) {
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pl);
if (jPlayer != null) {
jPlayer.resetPaymentLimit();
}
}
if (args[0].equalsIgnoreCase("all")) {
for (org.bukkit.entity.Player pl : org.bukkit.Bukkit.getOnlinePlayers()) {
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pl);
if (jPlayer != null) {
jPlayer.resetPaymentLimit();
}
}
sender.sendMessage(Jobs.getLanguage().getMessage("command.resetlimit.output.reseted", "%playername%", ""));
return true;
}
Language.sendMessage(sender, "command.resetlimit.output.reseted", "%playername%", "");
return true;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0]));
return true;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) {
Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args[0]);
return true;
}
jPlayer.resetPaymentLimit();
sender.sendMessage(Jobs.getLanguage().getMessage("command.resetlimit.output.reseted", "%playername%", jPlayer.getName(), "%playerdisplayname%", jPlayer.getDisplayName()));
return true;
jPlayer.resetPaymentLimit();
Language.sendMessage(sender, "command.resetlimit.output.reseted", "%playername%", jPlayer.getName(), "%playerdisplayname%", jPlayer.getDisplayName());
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.JobsPlayer;
import com.gamingmesh.jobs.container.QuestProgression;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC;
@ -24,8 +25,7 @@ public class resetquest implements Cmd {
}
if (args.length != 0 && args.length != 1 && args.length != 2) {
Jobs.getCommandManager().sendUsage(sender, "resetquest");
return true;
return false;
}
JobsPlayer jPlayer = null;
@ -44,7 +44,7 @@ public class resetquest implements Cmd {
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
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;
}
@ -54,12 +54,12 @@ public class resetquest implements Cmd {
quests = jPlayer.getQuestProgressions(job);
if (quests.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.resetquest.output.noQuests"));
Language.sendMessage(sender, "command.resetquest.output.noQuests");
return true;
}
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;
}
}

View File

@ -10,6 +10,7 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC;
@ -23,8 +24,7 @@ public class resetquesttotal implements Cmd {
}
if (args.length != 0 && args.length != 1) {
Jobs.getCommandManager().sendUsage(sender, "resetquesttotal");
return true;
return false;
}
if (args.length > 0 && args[0].equalsIgnoreCase("all")) {
@ -32,7 +32,7 @@ public class resetquesttotal implements Cmd {
pl.getValue().setDoneQuests(0);
}
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;
}
@ -52,14 +52,14 @@ public class resetquesttotal implements Cmd {
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
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;
}
jPlayer.setDoneQuests(0);
jPlayer.setSaved(false);
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;
}
}

View File

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

View File

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

View File

@ -6,40 +6,43 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.Signs.SignTopType;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC;
public class signupdate implements Cmd {
@Override
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (!Jobs.getGCManager().SignsEnabled)
return true;
if (!Jobs.getGCManager().SignsEnabled) {
LC.info_FeatureNotEnabled.sendMessage(sender);
return null;
}
if (args.length != 1) {
Jobs.getCommandManager().sendUsage(sender, "signupdate");
return true;
}
if (args.length != 1) {
return false;
}
if (args[0].equalsIgnoreCase("all")) {
Jobs.getJobs().forEach(Jobs.getSignUtil()::signUpdate);
return true;
}
if (args[0].equalsIgnoreCase("all")) {
Jobs.getJobs().forEach(Jobs.getSignUtil()::signUpdate);
return true;
}
Job oldjob = Jobs.getJob(args[0]);
if (oldjob == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
Job oldjob = Jobs.getJob(args[0]);
if (oldjob == null) {
Language.sendMessage(sender, "general.error.job");
return null;
}
if (args.length == 2) {
SignTopType type = SignTopType.getType(args[1]);
if (type != null) {
Jobs.getSignUtil().signUpdate(oldjob, type);
}
if (args.length == 2) {
SignTopType type = SignTopType.getType(args[1]);
if (type != null) {
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.QuestProgression;
import com.gamingmesh.jobs.economy.BufferedEconomy;
import com.gamingmesh.jobs.i18n.Language;
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) {
if (!Jobs.getGCManager().DailyQuestsEnabled) {
LC.info_FeatureNotEnabled.sendMessage(sender);
return true;
return null;
}
if (args.length != 2 && args.length != 3) {
Jobs.getCommandManager().sendUsage(sender, "skipquest");
return true;
return false;
}
JobsPlayer jPlayer = null;
@ -53,8 +54,8 @@ public class skipquest implements Cmd {
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args.length > 0 ? args[0] : ""));
return true;
Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args.length > 0 ? args[0] : "");
return null;
}
List<QuestProgression> quests = jPlayer.getQuestProgressions();
@ -63,8 +64,8 @@ public class skipquest implements Cmd {
quests = jPlayer.getQuestProgressions(job);
if (quests == null || quests.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.resetquest.output.noQuests"));
return true;
Language.sendMessage(sender, "command.resetquest.output.noQuests");
return null;
}
Quest old = null;
@ -99,8 +100,8 @@ public class skipquest implements Cmd {
if (amount > 0 && player != null) {
if (!econ.getEconomy().hasMoney(player, amount)) {
sender.sendMessage(Jobs.getLanguage().getMessage("economy.error.nomoney"));
return false;
Language.sendMessage(sender, "economy.error.nomoney");
return null;
}
econ.getEconomy().withdrawPlayer(player, amount);
@ -112,7 +113,7 @@ public class skipquest implements Cmd {
plugin.getServer().dispatchCommand(player, "jobs quests");
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;

View File

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

View File

@ -7,6 +7,7 @@ import org.bukkit.entity.Player;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
import com.gamingmesh.jobs.stuff.ToggleBarHandling;
import net.Zrips.CMILib.Locale.LC;
@ -16,48 +17,47 @@ public class toggle implements Cmd {
@Override
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (!(sender instanceof Player)) {
CMIMessages.sendMessage(sender, LC.info_Ingame);
return false;
}
if (!(sender instanceof Player)) {
CMIMessages.sendMessage(sender, LC.info_Ingame);
return null;
}
boolean isBossbar = false, isActionbar = false;
if (args.length != 1 || (!(isBossbar = args[0].equalsIgnoreCase("bossbar")) && !(isActionbar = args[0].equalsIgnoreCase("actionbar")))) {
Jobs.getCommandManager().sendUsage(sender, "toggle");
return true;
}
boolean isBossbar = false, isActionbar = false;
if (args.length != 1 || (!(isBossbar = args[0].equalsIgnoreCase("bossbar")) && !(isActionbar = args[0].equalsIgnoreCase("actionbar")))) {
return false;
}
Player player = (Player) sender;
String playerUUID = player.getUniqueId().toString();
Player player = (Player) sender;
String playerUUID = player.getUniqueId().toString();
if (isActionbar) {
Boolean ex = ToggleBarHandling.getActionBarToggle().get(playerUUID);
if (isActionbar) {
Boolean ex = ToggleBarHandling.getActionBarToggle().get(playerUUID);
if (ex == null || ex.booleanValue()) {
ToggleBarHandling.getActionBarToggle().put(playerUUID, false);
sender.sendMessage(Jobs.getLanguage().getMessage("command.toggle.output.off"));
} else {
ToggleBarHandling.getActionBarToggle().put(playerUUID, true);
sender.sendMessage(Jobs.getLanguage().getMessage("command.toggle.output.on"));
}
}
if (ex == null || ex.booleanValue()) {
ToggleBarHandling.getActionBarToggle().put(playerUUID, false);
Language.sendMessage(sender, "command.toggle.output.off");
} else {
ToggleBarHandling.getActionBarToggle().put(playerUUID, true);
Language.sendMessage(sender, "command.toggle.output.on");
}
}
if (isBossbar) {
Boolean ex = ToggleBarHandling.getBossBarToggle().get(playerUUID);
if (isBossbar) {
Boolean ex = ToggleBarHandling.getBossBarToggle().get(playerUUID);
if (ex == null || ex.booleanValue()) {
ToggleBarHandling.getBossBarToggle().put(playerUUID, false);
sender.sendMessage(Jobs.getLanguage().getMessage("command.toggle.output.off"));
if (ex == null || ex.booleanValue()) {
ToggleBarHandling.getBossBarToggle().put(playerUUID, false);
Language.sendMessage(sender, "command.toggle.output.off");
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player.getUniqueId());
if (jPlayer != null)
jPlayer.hideBossBars();
} else {
ToggleBarHandling.getBossBarToggle().put(playerUUID, true);
sender.sendMessage(Jobs.getLanguage().getMessage("command.toggle.output.on"));
}
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player.getUniqueId());
if (jPlayer != null)
jPlayer.hideBossBars();
} else {
ToggleBarHandling.getBossBarToggle().put(playerUUID, true);
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) {
if (args.length != 1 && args.length != 2) {
Jobs.getCommandManager().sendUsage(sender, "top");
return false;
}
Player player = sender instanceof Player p ? p : null;
Player player = sender instanceof Player ? (Player) sender : null;
if (args[0].equalsIgnoreCase("clear")) {
if (player != null) {
@ -43,7 +42,7 @@ public class top implements Cmd {
try {
page = Integer.parseInt(args[1]);
} catch (NumberFormatException e) {
return true;
return false;
}
}
if (page < 1)
@ -52,7 +51,7 @@ public class top implements Cmd {
Job job = Jobs.getJob(args[0]);
if (job == null) {
Language.sendMessage(sender, "command.top.error.nojob");
return false;
return null;
}
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.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
public class transfer implements Cmd {
@Override
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length < 3) {
Jobs.getCommandManager().sendUsage(sender, "transfer");
return true;
}
if (args.length < 3) {
return false;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0]));
return true;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) {
Language.sendMessage(sender, "general.error.noinfoByPlayer", "%playername%", args[0]);
return true;
}
Job oldjob = Jobs.getJob(args[1]);
if (oldjob == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
Job oldjob = Jobs.getJob(args[1]);
if (oldjob == null) {
Language.sendMessage(sender, "general.error.job");
return true;
}
Job newjob = Jobs.getJob(args[2]);
if (newjob == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
Job newjob = Jobs.getJob(args[2]);
if (newjob == null) {
Language.sendMessage(sender, "general.error.job");
return true;
}
try {
if (jPlayer.isInJob(oldjob) && !jPlayer.isInJob(newjob)) {
Jobs.getPlayerManager().transferJob(jPlayer, oldjob, newjob);
try {
if (jPlayer.isInJob(oldjob) && !jPlayer.isInJob(newjob)) {
Jobs.getPlayerManager().transferJob(jPlayer, oldjob, newjob);
Player player = jPlayer.getPlayer();
if (player != null) {
player.sendMessage(Jobs.getLanguage().getMessage("command.transfer.output.target",
"%oldjobname%", oldjob.getDisplayName(),
"%newjobname%", newjob.getDisplayName()));
}
Player player = jPlayer.getPlayer();
if (player != null) {
Language.sendMessage(player, "command.transfer.output.target",
"%oldjobname%", oldjob.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"));
}
} catch (Exception e) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.error"));
}
return true;
return true;
}
}