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) @JobCommand(721)
public boolean perform(Jobs plugin, CommandSender sender, String[] args) { public boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (sender instanceof Player) { if (sender instanceof Player) {
Player player = (Player) sender; Player player = (Player) sender;
if (args.length == 0) { if (args.length == 0) {
args = new String[] { "list" }; args = new String[] { "list" };
}
switch (args[0]) {
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]) { if (args.length == 2) {
case "list": Job job = Jobs.getJob(args[1]);
if (args.length == 1) { if (job == null)
showPath(player, null, null, null, null); return false;
for (Job one : Jobs.getJobs()) { showPath(player, job, null, null, null);
RawMessage rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.editquests.help.list.jobs", "%jobname%", one.getChatColor() for (ActionType oneI : ActionType.values()) {
+ one.getName()), one.getName(), "jobs editquests list " + one.getName()); List<JobInfo> action = job.getJobInfo(oneI);
rm.show(sender); 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 == 2) { Util.getQuestsEditorMap().remove(player.getUniqueId());
Job job = Jobs.getJob(args[1]); return true;
if (job == null) }
return false;
showPath(player, job, null, null, null); if (args.length == 5) {
Integer page = null;
for (ActionType oneI : ActionType.values()) { try {
List<JobInfo> action = job.getJobInfo(oneI); page = Integer.parseInt(args[4]);
if (action == null || action.isEmpty()) } catch (NumberFormatException e) {
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) { if (page != null) {
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) {
Job job = Jobs.getJob(args[1]); Job job = Jobs.getJob(args[1]);
if (job == null) if (job == null)
return false; return false;
@ -177,248 +114,312 @@ public class editquests implements Cmd {
if (obj == null || obj.isEmpty()) if (obj == null || obj.isEmpty())
return false; return false;
player.performCommand("jobs editquests list " + job.getName() + " " + actionT.getName() + " " QuestObjective o = null;
+ quest.getConfigName() + " 1"); PageInfo pi = new PageInfo(15, obj.size(), page);
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]); for (Entry<String, QuestObjective> one : obj.entrySet()) {
if (actionT == null) if (!pi.isEntryOk())
return false; continue;
List<JobInfo> action = job.getJobInfo(actionT); o = one.getValue();
if (action == null || action.isEmpty()) String target = o == null ? "STONE" : o.getTargetName();
return false;
List<Quest> quests = job.getQuests(); String objName = target.toLowerCase().replace('_', ' ');
if (quests == null || quests.isEmpty()) objName = Character.toUpperCase(objName.charAt(0)) + objName.substring(1);
return false; 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]); RawMessage rm = new RawMessage();
if (q == null) { rm.add(Jobs.getLanguage().getMessage("command.editquests.help.list.objectives", "%objectivename%", objName),
return false; 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()
String target = args[4]; + " " + quest.getConfigName() + " " + target);
if (target == null) { rm.show(sender);
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(); RawMessage rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.editquests.help.modify.enter")); rm.add(Jobs.getLanguage().getMessage("command.editquests.help.list.objectiveAdd"),
rm.add(Jobs.getLanguage().getMessage("command.editquests.help.modify.hand"), "&eAdd new", "jobs editquests add " + job.getName() + " " + quest.getConfigName()
Jobs.getLanguage().getMessage("command.editquests.help.modify.handHover"), "jobs editquests add " + job.getName() + " " + (o == null ? "Unknown" : o.getAction().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); rm.show(sender);
Util.getQuestsEditorMap().put(player.getUniqueId(), "jobs editquests add " + job.getName() + Util.getQuestsEditorMap().remove(player.getUniqueId());
" " + q.getConfigName() + " " + actionT.getName() + " " + amount);
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; return true;
} }
if (args.length >= 5 && args.length <= 6) { quests.remove(q);
Job job = Jobs.getJob(args[1]);
if (job == null)
return false;
Quest q = job.getQuest(args[2]); Jobs.getConfigManager().changeJobsSettings(q.getCurrentPath(), null);
if (q == null) {
return true; 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 (amount < 1) {
if (actionT == null) { amount = 3;
return false; }
}
String key = args[4]; RawMessage rm = new RawMessage();
switch (args[4]) { rm.add(Jobs.getLanguage().getMessage("command.editquests.help.modify.enter"));
case "hand": rm.add(Jobs.getLanguage().getMessage("command.editquests.help.modify.hand"),
ItemStack item = Jobs.getNms().getItemInMainHand(player); Jobs.getLanguage().getMessage("command.editquests.help.modify.handHover"), "jobs editquests add " + job.getName()
key = item.getType().name() + "-" + item.getData().getData(); + " " + q.getConfigName() + " " + actionT.getName() + " hand " + amount);
break; rm.add(Jobs.getLanguage().getMessage("command.editquests.help.modify.or"));
case "offhand": rm.add(Jobs.getLanguage().getMessage("command.editquests.help.modify.look"),
item = ItemReflection.getItemInOffHand(player); Jobs.getLanguage().getMessage("command.editquests.help.modify.lookHover"), "jobs editquests add " + job.getName()
key = item.getType().name() + "-" + item.getData().getData(); + " " + q.getConfigName() + " " + actionT.getName() + " looking " + amount);
break; rm.show(sender);
case "looking":
case "lookingat":
Block block = Util.getTargetBlock(player, 30);
key = block.getType().name() + "-" + block.getData();
break;
default:
break;
}
String myKey = key; Util.getQuestsEditorMap().put(player.getUniqueId(), "jobs editquests add " + job.getName() +
String type = null; " " + q.getConfigName() + " " + actionT.getName() + " " + amount);
String subType = ""; return true;
String meta = ""; }
int id = 0;
if (myKey.contains("-")) { if (args.length >= 5 && args.length <= 6) {
// uses subType Job job = Jobs.getJob(args[1]);
subType = ":" + myKey.split("-")[1]; if (job == null)
meta = myKey.split("-")[1]; return false;
myKey = myKey.split("-")[0];
}
CMIMaterial material = null; Quest q = job.getQuest(args[2]);
if (q == null) {
return true;
}
switch (actionT) { ActionType actionT = ActionType.getByName(args[3]);
case KILL: if (actionT == null) {
case MILK: return false;
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) String key = args[4];
material = CMIMaterial.get(myKey.replace(" ", "_").toUpperCase()); 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) { String myKey = key;
// try integer method String type = null;
Integer matId = null; String subType = "";
try { String meta = "";
matId = Integer.valueOf(myKey); int id = 0;
} catch (NumberFormatException e) {
} if (myKey.contains("-")) {
if (matId != null) { // uses subType
material = CMIMaterial.get(matId); subType = ":" + myKey.split("-")[1];
if (material != null) { meta = myKey.split("-")[1];
Jobs.getPluginLogger().warning("Job " + job.getName() + " " + actionT.getName() + " is using ID: " + key + "!"); myKey = myKey.split("-")[0];
Jobs.getPluginLogger().warning("Please use the Material name instead: " + material.toString() + "!"); }
}
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: default:
break; break;
} }
c: if (material != null && material.getMaterial() != null) { if (actionT == ActionType.BREAK || actionT == ActionType.PLACE || actionT == ActionType.STRIPLOGS) {
if (!material.isBlock()) {
// Need to include thos ones and count as regular blocks player.sendMessage(ChatColor.GOLD + "Quest " + q.getConfigName() + " has an invalid " + actionT.getName() + " type property: " + material
switch (key.replace("_", "").toLowerCase()) { + "(" + key + ")! Material must be a block!");
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; 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) { // check entities
if (!material.isBlock()) { EntityType entity = EntityType.fromName(myKey.toUpperCase());
player.sendMessage(ChatColor.GOLD + "Quest " + q.getConfigName() + " has an invalid " + actionT.getName() + " type property: " + material if (entity == null) {
+ "(" + key + ")! Material must be a block!"); entity = EntityType.valueOf(myKey.toUpperCase());
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 if (entity != null && entity.isAlive()) {
EntityType entity = EntityType.fromName(myKey.toUpperCase()); type = entity.toString();
if (entity == null) { id = entity.getTypeId();
entity = EntityType.valueOf(myKey.toUpperCase());
}
if (entity != null && entity.isAlive()) { // using breeder finder
type = entity.toString(); if (actionT == ActionType.BREED)
id = entity.getTypeId(); Jobs.getGCManager().useBreederFinder = true;
}
// using breeder finder if (entity == null) {
if (actionT == ActionType.BREED)
Jobs.getGCManager().useBreederFinder = true;
}
if (entity == null) {
switch (key.toLowerCase()) { switch (key.toLowerCase()) {
case "skeletonwither": case "skeletonwither":
type = CMIEntityType.WITHER_SKELETON.name(); type = CMIEntityType.WITHER_SKELETON.name();
@ -461,96 +462,96 @@ public class editquests implements Cmd {
meta = "1"; meta = "1";
break; break;
} }
} }
} else if (actionT == ActionType.ENCHANT) { } else if (actionT == ActionType.ENCHANT) {
Enchantment enchant = Enchantment.getByName(myKey); Enchantment enchant = Enchantment.getByName(myKey);
if (enchant != null) { if (enchant != null) {
if (Jobs.getVersionCheckManager().getVersion().isEqualOrLower(Version.v1_12_R1)) { if (Jobs.getVersionCheckManager().getVersion().isEqualOrLower(Version.v1_12_R1)) {
try { try {
id = (int) enchant.getClass().getMethod("getId").invoke(enchant); id = (int) enchant.getClass().getMethod("getId").invoke(enchant);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
| NoSuchMethodException | SecurityException e) { | NoSuchMethodException | SecurityException e) {
}
} }
} }
type = myKey; }
} else if (actionT == ActionType.CUSTOMKILL || actionT == ActionType.SHEAR || actionT == ActionType.MMKILL type = myKey;
|| actionT == ActionType.COLLECT) } else if (actionT == ActionType.CUSTOMKILL || actionT == ActionType.SHEAR || actionT == ActionType.MMKILL
type = myKey; || actionT == ActionType.COLLECT)
else if (actionT == ActionType.EXPLORE) { type = myKey;
type = myKey; else if (actionT == ActionType.EXPLORE) {
int a = 10; type = myKey;
try { int a = 10;
a = Integer.valueOf(myKey); try {
} catch (NumberFormatException e) { a = Integer.valueOf(myKey);
player.sendMessage(ChatColor.GOLD + "Quest " + q.getConfigName() + " has an invalid " + actionT.getName() + " type property: " + key + "!"); } catch (NumberFormatException e) {
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) {
player.sendMessage(ChatColor.GOLD + "Quest " + q.getConfigName() + " has an invalid " + actionT.getName() + " type property: " + key + "!"); player.sendMessage(ChatColor.GOLD + "Quest " + q.getConfigName() + " has an invalid " + actionT.getName() + " type property: " + key + "!");
break; break;
} }
if (actionT == ActionType.TNTBREAK) Jobs.getExplore().setExploreEnabled();
Jobs.getGCManager().setTntFinder(true); Jobs.getExplore().setPlayerAmount(a + 1);
} else if (actionT == ActionType.CRAFT && myKey.startsWith("!"))
type = myKey.substring(1, myKey.length());
int amount = 3; if (type == null) {
if (args.length == 6) { player.sendMessage(ChatColor.GOLD + "Quest " + q.getConfigName() + " has an invalid " + actionT.getName() + " type property: " + key + "!");
try { break;
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; if (actionT == ActionType.TNTBREAK)
default: Jobs.getGCManager().setTntFinder(true);
break;
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; return false;
} }
@ -563,7 +564,7 @@ public class editquests implements Cmd {
if (job != null) { if (job != null) {
rm = new RawMessage(); rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.editquests.help.list.jobs", "%jobname%", job.getChatColor() 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); rm.show(player);
} }
@ -571,8 +572,8 @@ public class editquests implements Cmd {
rm = new RawMessage(); rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.editquests.help.list.actions", "%actionname%", action.getName()), rm.add(Jobs.getLanguage().getMessage("command.editquests.help.list.actions", "%actionname%", action.getName()),
action.getName(), "jobs editquests list " + job.getName() + " " + action.getName() action.getName(), "jobs editquests list " + job.getName() + " " + action.getName()
+ " 1"); + " 1");
rm.show(player); rm.show(player);
} }
@ -582,8 +583,8 @@ public class editquests implements Cmd {
String materialName = jInfo.getRealisticName(); String materialName = jInfo.getRealisticName();
rm.add(Jobs.getLanguage().getMessage("command.editquests.help.list.quests", "%questname%", q.getConfigName()), rm.add(Jobs.getLanguage().getMessage("command.editquests.help.list.quests", "%questname%", q.getConfigName()),
jInfo.getName(), "jobs editquests list " + job.getName() + " " + action.getName() + " " + q.getConfigName() jInfo.getName(), "jobs editquests list " + job.getName() + " " + action.getName() + " " + q.getConfigName()
+ " " + materialName); + " " + materialName);
rm.show(player); rm.show(player);
} }
} }