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

Lets check NPE

This commit is contained in:
Zrips 2019-09-22 11:19:54 +03:00
parent f02902fb1e
commit b568195624

View File

@ -37,123 +37,60 @@ public class editquests implements Cmd {
@JobCommand(721)
public boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (sender instanceof Player) {
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, null);
for (Job one : Jobs.getJobs()) {
RawMessage rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.editquests.help.list.jobs", "%jobname%", one.getChatColor()
+ one.getName()), one.getName(), "jobs editquests list " + one.getName());
rm.show(sender);
}
Util.getQuestsEditorMap().remove(player.getUniqueId());
return true;
}
switch (args[0]) {
case "list":
if (args.length == 1) {
showPath(player, null, null, null, null);
if (args.length == 2) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
for (Job one : Jobs.getJobs()) {
RawMessage rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.editquests.help.list.jobs", "%jobname%", one.getChatColor()
+ one.getName()), one.getName(), "jobs editquests list " + one.getName());
rm.show(sender);
showPath(player, job, null, null, null);
for (ActionType oneI : ActionType.values()) {
List<JobInfo> action = job.getJobInfo(oneI);
if (action == null || action.isEmpty())
continue;
RawMessage rm = new RawMessage();
for (Quest one : job.getQuests()) {
rm.add(Jobs.getLanguage().getMessage("command.editquests.help.list.actions", "%actionname%", oneI.getName()),
oneI.getName(), "jobs editquests list " + job.getName() + " " + oneI.getName() + " " + one.getConfigName() + " 1");
}
Util.getQuestsEditorMap().remove(player.getUniqueId());
return true;
rm.show(sender);
}
if (args.length == 2) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
Util.getQuestsEditorMap().remove(player.getUniqueId());
return true;
}
showPath(player, job, null, null, null);
for (ActionType oneI : ActionType.values()) {
List<JobInfo> action = job.getJobInfo(oneI);
if (action == null || action.isEmpty())
continue;
RawMessage rm = new RawMessage();
for (Quest one : job.getQuests()) {
rm.add(Jobs.getLanguage().getMessage("command.editquests.help.list.actions", "%actionname%", oneI.getName()),
oneI.getName(), "jobs editquests list " + job.getName() + " " + oneI.getName() + " " + one.getConfigName() + " 1");
}
rm.show(sender);
}
Util.getQuestsEditorMap().remove(player.getUniqueId());
return true;
if (args.length == 5) {
Integer page = null;
try {
page = Integer.parseInt(args[4]);
} catch (NumberFormatException e) {
}
if (args.length == 5) {
Integer page = null;
try {
page = Integer.parseInt(args[4]);
} catch (NumberFormatException e) {
}
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;
List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty())
return false;
showPath(player, job, actionT, null, null);
Quest quest = job.getQuest(args[3]);
if (quest == null) {
return false;
}
HashMap<String, QuestObjective> obj = quest.getObjectives();
if (obj == null || obj.isEmpty())
return false;
QuestObjective o = null;
PageInfo pi = new PageInfo(15, obj.size(), page);
for (Entry<String, QuestObjective> one : obj.entrySet()) {
if (!pi.isEntryOk())
continue;
o = one.getValue();
String target = o == null ? "STONE" : o.getTargetName();
String objName = target.toLowerCase().replace('_', ' ');
objName = Character.toUpperCase(objName.charAt(0)) + objName.substring(1);
objName = Jobs.getNameTranslatorManager().Translate(objName, o.getAction(), o.getTargetId(),
o.getTargetMeta(), target);
objName = org.bukkit.ChatColor.translateAlternateColorCodes('&', objName);
RawMessage rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.editquests.help.list.objectives", "%objectivename%", objName),
target, "jobs editquests list " + job.getName() + " " + actionT.getName() + " " + quest.getConfigName() + " " + target);
rm.add(Jobs.getLanguage().getMessage("command.editquests.help.list.objectiveRemove"),
"&cRemove", "jobs editquests remove " + job.getName() + " " + actionT.getName()
+ " " + quest.getConfigName() + " " + target);
rm.show(sender);
}
RawMessage rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.editquests.help.list.objectiveAdd"),
"&eAdd new", "jobs editquests add " + job.getName() + " " + quest.getConfigName()
+ " " + (o == null ? "Unknown" : o.getAction().getName()));
rm.show(sender);
Util.getQuestsEditorMap().remove(player.getUniqueId());
Jobs.getInstance().ShowPagination(sender, pi.getTotalPages(), page,
"jobs editquests list " + job.getName() + " " + quest.getConfigName() + " " + 0);
return true;
}
}
if (args.length == 4) {
if (page != null) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
@ -177,248 +114,312 @@ public class editquests implements Cmd {
if (obj == null || obj.isEmpty())
return false;
player.performCommand("jobs editquests list " + job.getName() + " " + actionT.getName() + " "
+ quest.getConfigName() + " 1");
return true;
}
break;
case "remove":
if (args.length == 5) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
QuestObjective o = null;
PageInfo pi = new PageInfo(15, obj.size(), page);
ActionType actionT = ActionType.getByName(args[2]);
if (actionT == null)
return false;
for (Entry<String, QuestObjective> one : obj.entrySet()) {
if (!pi.isEntryOk())
continue;
List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty())
return false;
o = one.getValue();
String target = o == null ? "STONE" : o.getTargetName();
List<Quest> quests = job.getQuests();
if (quests == null || quests.isEmpty())
return false;
String objName = target.toLowerCase().replace('_', ' ');
objName = Character.toUpperCase(objName.charAt(0)) + objName.substring(1);
if (o != null)
objName = Jobs.getNameTranslatorManager().Translate(objName, o.getAction(), o.getTargetId(),
o.getTargetMeta(), target);
objName = org.bukkit.ChatColor.translateAlternateColorCodes('&', objName);
Quest q = job.getQuest(args[3]);
if (q == null) {
return false;
}
String target = args[4];
if (target == null) {
return true;
}
quests.remove(q);
Jobs.getConfigManager().changeJobsSettings(q.getCurrentPath(), null);
player.performCommand("jobs editquests list " + job.getName() + " " + q.getConfigName() + " 1");
Util.getQuestsEditorMap().remove(player.getUniqueId());
return true;
}
break;
case "add":
if (args.length >= 4 && args.length <= 5) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
Quest q = job.getQuest(args[2]);
if (q == null) {
return true;
}
ActionType actionT = ActionType.getByName(args[3]);
if (actionT == null)
return false;
int amount = 0;
if (args.length == 5) {
try {
amount = Integer.parseInt(args[4]);
} catch (NumberFormatException e) {
}
}
if (amount < 1) {
amount = 3;
RawMessage rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.editquests.help.list.objectives", "%objectivename%", objName),
target, "jobs editquests list " + job.getName() + " " + actionT.getName() + " " + quest.getConfigName() + " " + target);
rm.add(Jobs.getLanguage().getMessage("command.editquests.help.list.objectiveRemove"),
"&cRemove", "jobs editquests remove " + job.getName() + " " + actionT.getName()
+ " " + quest.getConfigName() + " " + target);
rm.show(sender);
}
RawMessage rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.editquests.help.modify.enter"));
rm.add(Jobs.getLanguage().getMessage("command.editquests.help.modify.hand"),
Jobs.getLanguage().getMessage("command.editquests.help.modify.handHover"), "jobs editquests add " + job.getName()
+ " " + q.getConfigName() + " " + actionT.getName() + " hand " + amount);
rm.add(Jobs.getLanguage().getMessage("command.editquests.help.modify.or"));
rm.add(Jobs.getLanguage().getMessage("command.editquests.help.modify.look"),
Jobs.getLanguage().getMessage("command.editquests.help.modify.lookHover"), "jobs editquests add " + job.getName()
+ " " + q.getConfigName() + " " + actionT.getName() + " looking " + amount);
rm.add(Jobs.getLanguage().getMessage("command.editquests.help.list.objectiveAdd"),
"&eAdd new", "jobs editquests add " + job.getName() + " " + quest.getConfigName()
+ " " + (o == null ? "Unknown" : o.getAction().getName()));
rm.show(sender);
Util.getQuestsEditorMap().put(player.getUniqueId(), "jobs editquests add " + job.getName() +
" " + q.getConfigName() + " " + actionT.getName() + " " + amount);
Util.getQuestsEditorMap().remove(player.getUniqueId());
Jobs.getInstance().ShowPagination(sender, pi.getTotalPages(), page,
"jobs editquests list " + job.getName() + " " + quest.getConfigName() + " " + 0);
return true;
}
}
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;
List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty())
return false;
showPath(player, job, actionT, null, null);
Quest quest = job.getQuest(args[3]);
if (quest == null) {
return false;
}
HashMap<String, QuestObjective> obj = quest.getObjectives();
if (obj == null || obj.isEmpty())
return false;
player.performCommand("jobs editquests list " + job.getName() + " " + actionT.getName() + " "
+ quest.getConfigName() + " 1");
return true;
}
break;
case "remove":
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;
List<JobInfo> action = job.getJobInfo(actionT);
if (action == null || action.isEmpty())
return false;
List<Quest> quests = job.getQuests();
if (quests == null || quests.isEmpty())
return false;
Quest q = job.getQuest(args[3]);
if (q == null) {
return false;
}
String target = args[4];
if (target == null) {
return true;
}
if (args.length >= 5 && args.length <= 6) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
quests.remove(q);
Quest q = job.getQuest(args[2]);
if (q == null) {
return true;
Jobs.getConfigManager().changeJobsSettings(q.getCurrentPath(), null);
player.performCommand("jobs editquests list " + job.getName() + " " + q.getConfigName() + " 1");
Util.getQuestsEditorMap().remove(player.getUniqueId());
return true;
}
break;
case "add":
if (args.length >= 4 && args.length <= 5) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
Quest q = job.getQuest(args[2]);
if (q == null) {
return true;
}
ActionType actionT = ActionType.getByName(args[3]);
if (actionT == null)
return false;
int amount = 0;
if (args.length == 5) {
try {
amount = Integer.parseInt(args[4]);
} catch (NumberFormatException e) {
}
}
ActionType actionT = ActionType.getByName(args[3]);
if (actionT == null) {
return false;
}
if (amount < 1) {
amount = 3;
}
String key = args[4];
switch (args[4]) {
case "hand":
ItemStack item = Jobs.getNms().getItemInMainHand(player);
key = item.getType().name() + "-" + item.getData().getData();
break;
case "offhand":
item = ItemReflection.getItemInOffHand(player);
key = item.getType().name() + "-" + item.getData().getData();
break;
case "looking":
case "lookingat":
Block block = Util.getTargetBlock(player, 30);
key = block.getType().name() + "-" + block.getData();
break;
default:
break;
}
RawMessage rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.editquests.help.modify.enter"));
rm.add(Jobs.getLanguage().getMessage("command.editquests.help.modify.hand"),
Jobs.getLanguage().getMessage("command.editquests.help.modify.handHover"), "jobs editquests add " + job.getName()
+ " " + q.getConfigName() + " " + actionT.getName() + " hand " + amount);
rm.add(Jobs.getLanguage().getMessage("command.editquests.help.modify.or"));
rm.add(Jobs.getLanguage().getMessage("command.editquests.help.modify.look"),
Jobs.getLanguage().getMessage("command.editquests.help.modify.lookHover"), "jobs editquests add " + job.getName()
+ " " + q.getConfigName() + " " + actionT.getName() + " looking " + amount);
rm.show(sender);
String myKey = key;
String type = null;
String subType = "";
String meta = "";
int id = 0;
Util.getQuestsEditorMap().put(player.getUniqueId(), "jobs editquests add " + job.getName() +
" " + q.getConfigName() + " " + actionT.getName() + " " + amount);
return true;
}
if (myKey.contains("-")) {
// uses subType
subType = ":" + myKey.split("-")[1];
meta = myKey.split("-")[1];
myKey = myKey.split("-")[0];
}
if (args.length >= 5 && args.length <= 6) {
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
CMIMaterial material = null;
Quest q = job.getQuest(args[2]);
if (q == null) {
return true;
}
switch (actionT) {
case KILL:
case MILK:
case MMKILL:
case BREED:
case SHEAR:
case EXPLORE:
case CUSTOMKILL:
break;
case TNTBREAK:
case VTRADE:
case SMELT:
case REPAIR:
case PLACE:
case EAT:
case FISH:
case ENCHANT:
case DYE:
case CRAFT:
case BREW:
case BREAK:
case STRIPLOGS:
material = CMIMaterial.get(myKey + (subType));
ActionType actionT = ActionType.getByName(args[3]);
if (actionT == null) {
return false;
}
if (material == null)
material = CMIMaterial.get(myKey.replace(" ", "_").toUpperCase());
String key = args[4];
switch (args[4]) {
case "hand":
ItemStack item = Jobs.getNms().getItemInMainHand(player);
key = item.getType().name() + "-" + item.getData().getData();
break;
case "offhand":
item = ItemReflection.getItemInOffHand(player);
key = item.getType().name() + "-" + item.getData().getData();
break;
case "looking":
case "lookingat":
Block block = Util.getTargetBlock(player, 30);
key = block.getType().name() + "-" + block.getData();
break;
default:
break;
}
if (material == null) {
// try integer method
Integer matId = null;
try {
matId = Integer.valueOf(myKey);
} catch (NumberFormatException e) {
}
if (matId != null) {
material = CMIMaterial.get(matId);
if (material != null) {
Jobs.getPluginLogger().warning("Job " + job.getName() + " " + actionT.getName() + " is using ID: " + key + "!");
Jobs.getPluginLogger().warning("Please use the Material name instead: " + material.toString() + "!");
}
String myKey = key;
String type = null;
String subType = "";
String meta = "";
int id = 0;
if (myKey.contains("-")) {
// uses subType
subType = ":" + myKey.split("-")[1];
meta = myKey.split("-")[1];
myKey = myKey.split("-")[0];
}
CMIMaterial material = null;
switch (actionT) {
case KILL:
case MILK:
case MMKILL:
case BREED:
case SHEAR:
case EXPLORE:
case CUSTOMKILL:
break;
case TNTBREAK:
case VTRADE:
case SMELT:
case REPAIR:
case PLACE:
case EAT:
case FISH:
case ENCHANT:
case DYE:
case CRAFT:
case BREW:
case BREAK:
case STRIPLOGS:
material = CMIMaterial.get(myKey + (subType));
if (material == null)
material = CMIMaterial.get(myKey.replace(" ", "_").toUpperCase());
if (material == null) {
// try integer method
Integer matId = null;
try {
matId = Integer.valueOf(myKey);
} catch (NumberFormatException e) {
}
if (matId != null) {
material = CMIMaterial.get(matId);
if (material != null) {
Jobs.getPluginLogger().warning("Job " + job.getName() + " " + actionT.getName() + " is using ID: " + key + "!");
Jobs.getPluginLogger().warning("Please use the Material name instead: " + material.toString() + "!");
}
}
break;
}
break;
default:
break;
}
c: if (material != null && material.getMaterial() != null) {
// Need to include thos ones and count as regular blocks
switch (key.replace("_", "").toLowerCase()) {
case "itemframe":
type = "ITEM_FRAME";
meta = "1";
break c;
case "painting":
type = "PAINTING";
meta = "1";
break c;
case "armorstand":
type = "ARMOR_STAND";
meta = "1";
break c;
default:
break;
}
c: if (material != null && material.getMaterial() != null) {
// Need to include thos ones and count as regular blocks
switch (key.replace("_", "").toLowerCase()) {
case "itemframe":
type = "ITEM_FRAME";
meta = "1";
break c;
case "painting":
type = "PAINTING";
meta = "1";
break c;
case "armorstand":
type = "ARMOR_STAND";
meta = "1";
break c;
default:
if (actionT == ActionType.BREAK || actionT == ActionType.PLACE || actionT == ActionType.STRIPLOGS) {
if (!material.isBlock()) {
player.sendMessage(ChatColor.GOLD + "Quest " + q.getConfigName() + " has an invalid " + actionT.getName() + " type property: " + material
+ "(" + key + ")! Material must be a block!");
break;
}
}
if (material == CMIMaterial.REDSTONE_ORE && actionT == ActionType.BREAK && Version.isCurrentLower(Version.v1_13_R1)) {
player.sendMessage(ChatColor.GOLD + "Quest " + q.getConfigName() + " is using REDSTONE_ORE instead of GLOWING_REDSTONE_ORE.");
player.sendMessage(ChatColor.GOLD + "Automatically changing block to GLOWING_REDSTONE_ORE. Please update your configuration.");
player.sendMessage(ChatColor.GOLD + "In vanilla minecraft, REDSTONE_ORE changes to GLOWING_REDSTONE_ORE when interacted with.");
player.sendMessage(ChatColor.GOLD + "In the future, Jobs using REDSTONE_ORE instead of GLOWING_REDSTONE_ORE may fail to work correctly.");
material = CMIMaterial.LEGACY_GLOWING_REDSTONE_ORE;
} else if (material == CMIMaterial.LEGACY_GLOWING_REDSTONE_ORE && actionT == ActionType.BREAK && Version.isCurrentEqualOrHigher(Version.v1_13_R1)) {
player.sendMessage(ChatColor.GOLD + "Quest " + q.getConfigName() + " is using GLOWING_REDSTONE_ORE instead of REDSTONE_ORE.");
player.sendMessage(ChatColor.GOLD + "Automatically changing block to REDSTONE_ORE. Please update your configuration.");
material = CMIMaterial.REDSTONE_ORE;
}
id = material.getId();
type = material.toString();
} else if (actionT == ActionType.KILL || actionT == ActionType.TAME || actionT == ActionType.BREED || actionT == ActionType.MILK) {
if (actionT == ActionType.BREAK || actionT == ActionType.PLACE || actionT == ActionType.STRIPLOGS) {
if (!material.isBlock()) {
player.sendMessage(ChatColor.GOLD + "Quest " + q.getConfigName() + " has an invalid " + actionT.getName() + " type property: " + material
+ "(" + key + ")! Material must be a block!");
break;
}
}
if (material == CMIMaterial.REDSTONE_ORE && actionT == ActionType.BREAK && Version.isCurrentLower(Version.v1_13_R1)) {
player.sendMessage(ChatColor.GOLD + "Quest " + q.getConfigName() + " is using REDSTONE_ORE instead of GLOWING_REDSTONE_ORE.");
player.sendMessage(ChatColor.GOLD + "Automatically changing block to GLOWING_REDSTONE_ORE. Please update your configuration.");
player.sendMessage(ChatColor.GOLD + "In vanilla minecraft, REDSTONE_ORE changes to GLOWING_REDSTONE_ORE when interacted with.");
player.sendMessage(ChatColor.GOLD + "In the future, Jobs using REDSTONE_ORE instead of GLOWING_REDSTONE_ORE may fail to work correctly.");
material = CMIMaterial.LEGACY_GLOWING_REDSTONE_ORE;
} else if (material == CMIMaterial.LEGACY_GLOWING_REDSTONE_ORE && actionT == ActionType.BREAK && Version.isCurrentEqualOrHigher(Version.v1_13_R1)) {
player.sendMessage(ChatColor.GOLD + "Quest " + q.getConfigName() + " is using GLOWING_REDSTONE_ORE instead of REDSTONE_ORE.");
player.sendMessage(ChatColor.GOLD + "Automatically changing block to REDSTONE_ORE. Please update your configuration.");
material = CMIMaterial.REDSTONE_ORE;
}
id = material.getId();
type = material.toString();
} else if (actionT == ActionType.KILL || actionT == ActionType.TAME || actionT == ActionType.BREED || actionT == ActionType.MILK) {
// check entities
EntityType entity = EntityType.fromName(myKey.toUpperCase());
if (entity == null) {
entity = EntityType.valueOf(myKey.toUpperCase());
}
// check entities
EntityType entity = EntityType.fromName(myKey.toUpperCase());
if (entity == null) {
entity = EntityType.valueOf(myKey.toUpperCase());
}
if (entity != null && entity.isAlive()) {
type = entity.toString();
id = entity.getTypeId();
if (entity != null && entity.isAlive()) {
type = entity.toString();
id = entity.getTypeId();
// using breeder finder
if (actionT == ActionType.BREED)
Jobs.getGCManager().useBreederFinder = true;
}
// using breeder finder
if (actionT == ActionType.BREED)
Jobs.getGCManager().useBreederFinder = true;
}
if (entity == null) {
if (entity == null) {
switch (key.toLowerCase()) {
case "skeletonwither":
type = CMIEntityType.WITHER_SKELETON.name();
@ -461,96 +462,96 @@ public class editquests implements Cmd {
meta = "1";
break;
}
}
}
} else if (actionT == ActionType.ENCHANT) {
Enchantment enchant = Enchantment.getByName(myKey);
if (enchant != null) {
if (Jobs.getVersionCheckManager().getVersion().isEqualOrLower(Version.v1_12_R1)) {
try {
id = (int) enchant.getClass().getMethod("getId").invoke(enchant);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
| NoSuchMethodException | SecurityException e) {
}
} else if (actionT == ActionType.ENCHANT) {
Enchantment enchant = Enchantment.getByName(myKey);
if (enchant != null) {
if (Jobs.getVersionCheckManager().getVersion().isEqualOrLower(Version.v1_12_R1)) {
try {
id = (int) enchant.getClass().getMethod("getId").invoke(enchant);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
| NoSuchMethodException | SecurityException e) {
}
}
type = myKey;
} else if (actionT == ActionType.CUSTOMKILL || actionT == ActionType.SHEAR || actionT == ActionType.MMKILL
|| actionT == ActionType.COLLECT)
type = myKey;
else if (actionT == ActionType.EXPLORE) {
type = myKey;
int a = 10;
try {
a = Integer.valueOf(myKey);
} catch (NumberFormatException e) {
player.sendMessage(ChatColor.GOLD + "Quest " + q.getConfigName() + " has an invalid " + actionT.getName() + " type property: " + key + "!");
break;
}
Jobs.getExplore().setExploreEnabled();
Jobs.getExplore().setPlayerAmount(a + 1);
} else if (actionT == ActionType.CRAFT && myKey.startsWith("!"))
type = myKey.substring(1, myKey.length());
if (type == null) {
}
type = myKey;
} else if (actionT == ActionType.CUSTOMKILL || actionT == ActionType.SHEAR || actionT == ActionType.MMKILL
|| actionT == ActionType.COLLECT)
type = myKey;
else if (actionT == ActionType.EXPLORE) {
type = myKey;
int a = 10;
try {
a = Integer.valueOf(myKey);
} catch (NumberFormatException e) {
player.sendMessage(ChatColor.GOLD + "Quest " + q.getConfigName() + " has an invalid " + actionT.getName() + " type property: " + key + "!");
break;
}
if (actionT == ActionType.TNTBREAK)
Jobs.getGCManager().setTntFinder(true);
Jobs.getExplore().setExploreEnabled();
Jobs.getExplore().setPlayerAmount(a + 1);
} else if (actionT == ActionType.CRAFT && myKey.startsWith("!"))
type = myKey.substring(1, myKey.length());
int amount = 3;
if (args.length == 6) {
try {
amount = Integer.parseInt(args[5]);
} catch (NumberFormatException e) {
}
}
if (amount < 1) {
amount = 3;
}
q.addObjective(new QuestObjective(actionT, id, meta, (type + subType), amount));
player.performCommand("jobs editquests list " + job.getName() + " " + q.getConfigName() + " 1");
String path = q.getCurrentPath();
path = path.replace("/", ".");
org.bukkit.configuration.file.YamlConfiguration file = Jobs.getConfigManager().getJobConfig();
String j = "Jobs." + job.getJobKeyName() + ".";
if (path.equals("Target")) {
Jobs.getConfigManager().changeJobsSettings(file.getString(j + "Target"), (type + subType).toLowerCase());
Jobs.getConfigManager().changeJobsSettings(file.getString(j + "Action"), actionT.getName());
} else if (path.equals("Objectives")) {
for (String l : file.getConfigurationSection(j + "Quests").getKeys(false)) {
List<String> list = file.getStringList(j + "Quests." + l + ".Objectives");
list.add(actionT.getName() + ";" + (type + subType).toLowerCase() + ";" + amount);
file.set(j + "Quests." + l + ".Objectives", list);
}
try {
file.save(Jobs.getConfigManager().getJobFile());
} catch (java.io.IOException e) {
e.printStackTrace();
}
}
Util.getQuestsEditorMap().remove(player.getUniqueId());
return true;
if (type == null) {
player.sendMessage(ChatColor.GOLD + "Quest " + q.getConfigName() + " has an invalid " + actionT.getName() + " type property: " + key + "!");
break;
}
break;
default:
break;
if (actionT == ActionType.TNTBREAK)
Jobs.getGCManager().setTntFinder(true);
int amount = 3;
if (args.length == 6) {
try {
amount = Integer.parseInt(args[5]);
} catch (NumberFormatException e) {
}
}
if (amount < 1) {
amount = 3;
}
q.addObjective(new QuestObjective(actionT, id, meta, (type + subType), amount));
player.performCommand("jobs editquests list " + job.getName() + " " + q.getConfigName() + " 1");
String path = q.getCurrentPath();
path = path.replace("/", ".");
org.bukkit.configuration.file.YamlConfiguration file = Jobs.getConfigManager().getJobConfig();
String j = "Jobs." + job.getJobKeyName() + ".";
if (path.equals("Target")) {
Jobs.getConfigManager().changeJobsSettings(file.getString(j + "Target"), (type + subType).toLowerCase());
Jobs.getConfigManager().changeJobsSettings(file.getString(j + "Action"), actionT.getName());
} else if (path.equals("Objectives")) {
for (String l : file.getConfigurationSection(j + "Quests").getKeys(false)) {
List<String> list = file.getStringList(j + "Quests." + l + ".Objectives");
list.add(actionT.getName() + ";" + (type + subType).toLowerCase() + ";" + amount);
file.set(j + "Quests." + l + ".Objectives", list);
}
try {
file.save(Jobs.getConfigManager().getJobFile());
} catch (java.io.IOException e) {
e.printStackTrace();
}
}
Util.getQuestsEditorMap().remove(player.getUniqueId());
return true;
}
break;
default:
break;
}
}
return false;
}
@ -563,7 +564,7 @@ public class editquests implements Cmd {
if (job != null) {
rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.editquests.help.list.jobs", "%jobname%", job.getChatColor()
+ job.getName()), job.getName(), "jobs editquests list " + job.getName());
+ job.getName()), job.getName(), "jobs editquests list " + job.getName());
rm.show(player);
}
@ -571,8 +572,8 @@ public class editquests implements Cmd {
rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.editquests.help.list.actions", "%actionname%", action.getName()),
action.getName(), "jobs editquests list " + job.getName() + " " + action.getName()
+ " 1");
action.getName(), "jobs editquests list " + job.getName() + " " + action.getName()
+ " 1");
rm.show(player);
}
@ -582,8 +583,8 @@ public class editquests implements Cmd {
String materialName = jInfo.getRealisticName();
rm.add(Jobs.getLanguage().getMessage("command.editquests.help.list.quests", "%questname%", q.getConfigName()),
jInfo.getName(), "jobs editquests list " + job.getName() + " " + action.getName() + " " + q.getConfigName()
+ " " + materialName);
jInfo.getName(), "jobs editquests list " + job.getName() + " " + action.getName() + " " + q.getConfigName()
+ " " + materialName);
rm.show(player);
}
}