1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-26 12:35:28 +01:00

Fix error in jobs give command

- Fixed error on startup where the Enchantmnt#getKey is null.
This commit is contained in:
montlikadani 2020-03-24 14:08:37 +01:00
parent ac40c2e266
commit e4085da71c
3 changed files with 10 additions and 9 deletions

View File

@ -68,9 +68,12 @@ public enum CMIEnchantment {
break;
}
if (one.getKey().toString().split(":")[1].toLowerCase().replace("_", "").equalsIgnoreCase(temp)) {
enchantment = one;
break;
try {
if (one.getKey().toString().split(":")[1].toLowerCase().replace("_", "").equalsIgnoreCase(temp)) {
enchantment = one;
break;
}
} catch (Exception | Error e) {
}
}

View File

@ -29,7 +29,6 @@ public class give implements Cmd {
@Override
@JobCommand(2500)
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
Player player = null;
Job job = null;
actions name = null;
@ -60,10 +59,10 @@ public class give implements Cmd {
player = (Player) sender;
if (player == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.give.output.notonline", "%playername%", args[0]));
sender.sendMessage(Jobs.getLanguage().getMessage("command.give.output.notonline"));
return true;
}
if (name == null)
name = actions.items;
@ -75,7 +74,6 @@ public class give implements Cmd {
switch (name) {
case items:
JobItems jItem = ItemBoostManager.getItemByKey(itemName);
if (jItem == null || jItem.getItemStack(player) == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.give.output.noitem"));
return true;
@ -88,8 +86,8 @@ public class give implements Cmd {
Jobs.getCommandManager().sendUsage(sender, "give");
return true;
}
JobLimitedItems jLItem = job.getLimitedItems().get(itemName.toLowerCase());
JobLimitedItems jLItem = job.getLimitedItems().get(itemName.toLowerCase());
if (jLItem == null || jLItem.getItemStack(player) == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.give.output.noitem"));
return true;

View File

@ -319,7 +319,7 @@ public class LanguageManager {
c.get("command.give.help.info", "Gives item by jobs name and item category name. Player name is optional");
c.get("command.give.help.args", "[playername] [jobname] [items/limiteditems] [jobitemname]");
Jobs.getGCManager().getCommandArgs().put("give", Arrays.asList("[playername]", "[jobname]%%[jobitemname]", "[jobitemname]"));
c.get("command.give.output.notonline", "&4Player [%playername%] is not online!");
c.get("command.give.output.notonline", "&4Player with that name is not online!");
c.get("command.give.output.noitem", "&4Can't find any item by given name!");
c.get("command.info.help.title", "&2*** &eJobs&2 ***");