mirror of
https://github.com/Zrips/Jobs.git
synced 2025-01-20 07:01:22 +01:00
Refactor recognizing materials to decrease the file size
This commit is contained in:
parent
d151fbec0f
commit
0b31783c84
@ -1,24 +1,19 @@
|
||||
package com.gamingmesh.jobs.commands.list;
|
||||
|
||||
import com.gamingmesh.jobs.CMILib.CMIEntityType;
|
||||
import com.gamingmesh.jobs.CMILib.CMIMaterial;
|
||||
import com.gamingmesh.jobs.CMILib.ItemReflection;
|
||||
import com.gamingmesh.jobs.CMILib.RawMessage;
|
||||
import com.gamingmesh.jobs.CMILib.Version;
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.commands.Cmd;
|
||||
import com.gamingmesh.jobs.commands.JobCommand;
|
||||
import com.gamingmesh.jobs.config.ConfigManager.KeyValues;
|
||||
import com.gamingmesh.jobs.container.ActionType;
|
||||
import com.gamingmesh.jobs.container.CurrencyType;
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.container.JobInfo;
|
||||
import com.gamingmesh.jobs.stuff.ChatColor;
|
||||
import com.gamingmesh.jobs.stuff.PageInfo;
|
||||
import com.gamingmesh.jobs.stuff.Util;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@ -43,11 +38,13 @@ public class editjobs implements Cmd {
|
||||
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.getNameWithColor()), one.getName(), "jobs editjobs list " + one.getName());
|
||||
rm.show(sender);
|
||||
}
|
||||
|
||||
Util.getJobsEditorMap().remove(player.getUniqueId());
|
||||
return true;
|
||||
}
|
||||
@ -56,16 +53,20 @@ public class editjobs implements Cmd {
|
||||
Job job = Jobs.getJob(args[1]);
|
||||
if (job == null)
|
||||
return false;
|
||||
|
||||
showPath(player, job, null, null);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
Util.getJobsEditorMap().remove(player.getUniqueId());
|
||||
return true;
|
||||
}
|
||||
@ -81,14 +82,19 @@ public class editjobs implements Cmd {
|
||||
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);
|
||||
|
||||
PageInfo pi = new PageInfo(15, action.size(), page);
|
||||
|
||||
for (JobInfo one : action) {
|
||||
if (!pi.isEntryOk())
|
||||
continue;
|
||||
@ -114,22 +120,18 @@ public class editjobs implements Cmd {
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
JobInfo jInfo = null;
|
||||
|
||||
for (JobInfo one : action) {
|
||||
if (one.getName().equalsIgnoreCase(args[3])) {
|
||||
jInfo = one;
|
||||
@ -158,29 +160,24 @@ public class editjobs implements Cmd {
|
||||
.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;
|
||||
|
||||
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;
|
||||
@ -192,35 +189,28 @@ public class editjobs implements Cmd {
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
@ -232,12 +222,10 @@ public class editjobs implements Cmd {
|
||||
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) {
|
||||
@ -263,10 +251,8 @@ public class editjobs implements Cmd {
|
||||
}
|
||||
|
||||
Jobs.getConfigManager().changeJobsSettings(jInfo.getConfigPath() + "/" + sType, value);
|
||||
|
||||
player.performCommand("jobs editjobs list " + job.getName() + " " + actionT.getName() + " " + jInfo.getName());
|
||||
Util.getJobsEditorMap().remove(player.getUniqueId());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -276,17 +262,14 @@ public class editjobs implements Cmd {
|
||||
|
||||
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;
|
||||
|
||||
@ -303,13 +286,9 @@ public class editjobs implements Cmd {
|
||||
}
|
||||
|
||||
action.remove(jInfo);
|
||||
|
||||
Jobs.getConfigManager().changeJobsSettings(jInfo.getConfigPath(), null);
|
||||
|
||||
player.performCommand("jobs editjobs list " + job.getName() + " " + actionT.getName() + " 1");
|
||||
|
||||
Util.getJobsEditorMap().remove(player.getUniqueId());
|
||||
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
@ -318,17 +297,14 @@ public class editjobs implements Cmd {
|
||||
|
||||
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;
|
||||
|
||||
List<JobInfo> action = job.getJobInfo(actionT);
|
||||
|
||||
if (action == null || action.isEmpty())
|
||||
return false;
|
||||
|
||||
@ -342,23 +318,19 @@ public class editjobs implements Cmd {
|
||||
rm.show(sender);
|
||||
|
||||
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;
|
||||
|
||||
ActionType actionT = ActionType.getByName(args[2]);
|
||||
|
||||
if (actionT == null)
|
||||
return false;
|
||||
|
||||
List<JobInfo> action = job.getJobInfo(actionT);
|
||||
|
||||
if (action == null || action.isEmpty())
|
||||
return false;
|
||||
|
||||
@ -381,218 +353,21 @@ public class editjobs implements Cmd {
|
||||
break;
|
||||
}
|
||||
|
||||
String myKey = key;
|
||||
String type = null;
|
||||
String subType = "";
|
||||
String meta = "";
|
||||
int id = 0;
|
||||
KeyValues keyValue = Jobs.getConfigManager().getKeyValue(key, actionT, job.getName());
|
||||
if (keyValue == null)
|
||||
return false;
|
||||
|
||||
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 BOSS:
|
||||
case TAME:
|
||||
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 BAKE:
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
if (actionT == ActionType.BREAK || actionT == ActionType.PLACE || actionT == ActionType.STRIPLOGS) {
|
||||
if (!material.isBlock()) {
|
||||
player.sendMessage(ChatColor.GOLD + "Job " + job.getName() + " 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 + "Job " + job.getName() + " 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 + "Job " + job.getName() + " 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.getMaterial().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());
|
||||
}
|
||||
|
||||
if (entity != null) {
|
||||
if (entity.isAlive()) {
|
||||
type = entity.toString();
|
||||
id = entity.getTypeId();
|
||||
|
||||
// using breeder finder
|
||||
if (actionT == ActionType.BREED)
|
||||
Jobs.getGCManager().useBreederFinder = true;
|
||||
} else if (entity == EntityType.ENDER_CRYSTAL) {
|
||||
type = entity.toString();
|
||||
id = entity.getTypeId();
|
||||
}
|
||||
}
|
||||
|
||||
if (entity == null) {
|
||||
switch (key.toLowerCase()) {
|
||||
case "skeletonwither":
|
||||
type = CMIEntityType.WITHER_SKELETON.name();
|
||||
id = 51;
|
||||
meta = "1";
|
||||
break;
|
||||
case "skeletonstray":
|
||||
type = CMIEntityType.STRAY.name();
|
||||
id = 51;
|
||||
meta = "2";
|
||||
break;
|
||||
case "zombievillager":
|
||||
type = CMIEntityType.ZOMBIE_VILLAGER.name();
|
||||
id = 54;
|
||||
meta = "1";
|
||||
break;
|
||||
case "zombiehusk":
|
||||
type = CMIEntityType.HUSK.name();
|
||||
id = 54;
|
||||
meta = "2";
|
||||
break;
|
||||
case "horseskeleton":
|
||||
type = CMIEntityType.SKELETON_HORSE.name();
|
||||
id = 100;
|
||||
meta = "1";
|
||||
break;
|
||||
case "horsezombie":
|
||||
type = CMIEntityType.ZOMBIE_HORSE.name();
|
||||
id = 100;
|
||||
meta = "2";
|
||||
break;
|
||||
case "guardianelder":
|
||||
type = CMIEntityType.ELDER_GUARDIAN.name();
|
||||
id = 68;
|
||||
meta = "1";
|
||||
break;
|
||||
default:
|
||||
type = CMIEntityType.getByName(myKey.toUpperCase()).name();
|
||||
id = CMIEntityType.getByName(myKey.toUpperCase()).getId();
|
||||
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 (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
type = myKey;
|
||||
} else if (actionT == ActionType.CUSTOMKILL || actionT == ActionType.SHEAR || actionT == ActionType.MMKILL
|
||||
|| actionT == ActionType.COLLECT || actionT == ActionType.BAKE || actionT == ActionType.BOSS)
|
||||
type = myKey;
|
||||
else if (actionT == ActionType.EXPLORE) {
|
||||
type = myKey;
|
||||
int amount = 10;
|
||||
try {
|
||||
amount = Integer.valueOf(myKey);
|
||||
} catch (NumberFormatException e) {
|
||||
player.sendMessage(ChatColor.GOLD + "Job " + job.getName() + " has an invalid " + actionT.getName() + " type property: " + key + "!");
|
||||
break;
|
||||
}
|
||||
Jobs.getExplore().setExploreEnabled();
|
||||
Jobs.getExplore().setPlayerAmount(amount);
|
||||
} else if (actionT == ActionType.CRAFT && myKey.startsWith("!"))
|
||||
type = myKey.substring(1, myKey.length());
|
||||
|
||||
if (type == null) {
|
||||
player.sendMessage(ChatColor.GOLD + "Job " + job.getName() + " has an invalid " + actionT.getName() + " type property: " + key + "!");
|
||||
break;
|
||||
}
|
||||
String type = keyValue.getType(),
|
||||
subType = keyValue.getSubType(),
|
||||
meta = keyValue.getMeta();
|
||||
int id = keyValue.getId();
|
||||
|
||||
if (actionT == ActionType.TNTBREAK)
|
||||
Jobs.getGCManager().setTntFinder(true);
|
||||
|
||||
double income = 0D;
|
||||
double points = 0D;
|
||||
double experience = 0D;
|
||||
double income = 0D,
|
||||
points = 0D,
|
||||
experience = 0D;
|
||||
|
||||
int fromlevel = 1;
|
||||
int untilLevel = -1;
|
||||
@ -606,6 +381,7 @@ public class editjobs implements Cmd {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
action.add(jInfo);
|
||||
player.performCommand("jobs editjobs list " + job.getName() + " " + actionT.getName() + " " + jInfo.getName());
|
||||
|
||||
@ -614,7 +390,6 @@ public class editjobs implements Cmd {
|
||||
Jobs.getConfigManager().changeJobsSettings(jInfo.getConfigPath() + "/experience", 0);
|
||||
|
||||
Util.getJobsEditorMap().remove(player.getUniqueId());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -627,7 +402,6 @@ public class editjobs implements Cmd {
|
||||
}
|
||||
|
||||
private static void showPath(Player player, Job job, ActionType action, JobInfo jInfo) {
|
||||
|
||||
RawMessage rm = new RawMessage();
|
||||
rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.job"), "&eJob list", "jobs editjobs");
|
||||
rm.show(player);
|
||||
|
@ -180,7 +180,6 @@ public class editquests implements Cmd {
|
||||
}
|
||||
|
||||
HashMap<String, QuestObjective> obj = quest.getObjectives().get(actionT);
|
||||
|
||||
if (obj == null || obj.isEmpty())
|
||||
return false;
|
||||
|
||||
|
@ -35,7 +35,6 @@ import org.apache.commons.lang.StringEscapeUtils;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||
|
||||
@ -398,19 +397,20 @@ public class ConfigManager {
|
||||
meta = myKey.split("-")[1];
|
||||
myKey = myKey.split("-")[0];
|
||||
} else if (myKey.contains(":")) { // when we uses tipped arrow effect types
|
||||
meta = myKey.split(":")[1];
|
||||
myKey = myKey.split(":")[0];
|
||||
String[] split = myKey.split(":");
|
||||
meta = split.length > 1 ? split[1] : myKey;
|
||||
myKey = split[0];
|
||||
}
|
||||
|
||||
CMIMaterial material = null;
|
||||
CMIMaterial material = CMIMaterial.NONE;
|
||||
|
||||
switch (actionType) {
|
||||
case KILL:
|
||||
case MILK:
|
||||
case MMKILL:
|
||||
case BOSS:
|
||||
case TAME:
|
||||
case BREED:
|
||||
case TAME:
|
||||
case SHEAR:
|
||||
case EXPLORE:
|
||||
case CUSTOMKILL:
|
||||
@ -432,15 +432,15 @@ public class ConfigManager {
|
||||
case COLLECT:
|
||||
material = CMIMaterial.get(myKey + (subType));
|
||||
|
||||
if (material == null)
|
||||
if (material == CMIMaterial.NONE)
|
||||
material = CMIMaterial.get(myKey.replace(" ", "_").toUpperCase());
|
||||
|
||||
if (material == null) {
|
||||
if (material == CMIMaterial.NONE) {
|
||||
// try integer method
|
||||
Integer matId = null;
|
||||
try {
|
||||
matId = Integer.valueOf(myKey);
|
||||
} catch (NumberFormatException e) {
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
if (matId != null) {
|
||||
material = CMIMaterial.get(matId);
|
||||
@ -450,15 +450,25 @@ public class ConfigManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
if (actionType == ActionType.STRIPLOGS && Version.isCurrentLower(Version.v1_13_R1))
|
||||
return null;
|
||||
|
||||
c: if (material != null && material.getMaterial() != null) {
|
||||
if (material != null && material.getMaterial() != null && material.isAir()) {
|
||||
Jobs.getPluginLogger().warning("Job " + myKey + " " + actionType.getName() + " can't recognize material! (" + myKey + ")");
|
||||
return null;
|
||||
}
|
||||
|
||||
// Need to include thos ones and count as regular blocks
|
||||
if (material != null && Version.isCurrentLower(Version.v1_13_R1) && meta.isEmpty())
|
||||
meta = String.valueOf(material.getData());
|
||||
|
||||
c: if (material != null && material != CMIMaterial.NONE && material.getMaterial() != null) {
|
||||
// Need to include those ones and count as regular blocks
|
||||
switch (myKey.replace("_", "").toLowerCase()) {
|
||||
case "itemframe":
|
||||
type = "ITEM_FRAME";
|
||||
@ -482,11 +492,12 @@ public class ConfigManager {
|
||||
// Break and Place actions MUST be blocks
|
||||
if (actionType == ActionType.BREAK || actionType == ActionType.PLACE || actionType == ActionType.STRIPLOGS) {
|
||||
if (!material.isBlock()) {
|
||||
Jobs.getPluginLogger().warning("Job " + jobName + " has an invalid " + actionType.getName() + " type property: " + material
|
||||
+ "(" + myKey + ")! Material must be a block! Use \"/jobs blockinfo\" on a target block");
|
||||
return null;
|
||||
Jobs.getPluginLogger().warning("Job " + myKey + " has an invalid " + actionType.getName() + " type property: " + material
|
||||
+ " (" + myKey + ")! Material must be a block! Use \"/jobs blockinfo\" on a target block");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// START HACK
|
||||
/*
|
||||
* Historically, GLOWING_REDSTONE_ORE would ONLY work as REDSTONE_ORE, and putting
|
||||
@ -499,7 +510,7 @@ public class ConfigManager {
|
||||
* configurations broken.
|
||||
*/
|
||||
if (material == CMIMaterial.REDSTONE_ORE && actionType == ActionType.BREAK && Version.isCurrentLower(Version.v1_13_R1)) {
|
||||
Jobs.getPluginLogger().warning("Job " + jobName + " is using REDSTONE_ORE instead of GLOWING_REDSTONE_ORE.");
|
||||
Jobs.getPluginLogger().warning("Job " + myKey + " is using REDSTONE_ORE instead of GLOWING_REDSTONE_ORE.");
|
||||
Jobs.getPluginLogger().warning("Automatically changing block to GLOWING_REDSTONE_ORE. Please update your configuration.");
|
||||
Jobs.getPluginLogger().warning("In vanilla minecraft, REDSTONE_ORE changes to GLOWING_REDSTONE_ORE when interacted with.");
|
||||
Jobs.getPluginLogger().warning("In the future, Jobs using REDSTONE_ORE instead of GLOWING_REDSTONE_ORE may fail to work correctly.");
|
||||
@ -513,29 +524,26 @@ public class ConfigManager {
|
||||
|
||||
type = material.getMaterial().toString();
|
||||
id = material.getId();
|
||||
} else if (actionType == ActionType.KILL || actionType == ActionType.TAME || actionType == ActionType.BREED || actionType == ActionType.MILK) {
|
||||
|
||||
} else if (actionType == ActionType.KILL || actionType == ActionType.TAME || actionType == ActionType.BREED || actionType == ActionType.MILK) {
|
||||
// check entities
|
||||
EntityType entity = EntityType.fromName(myKey);
|
||||
if (entity == null) {
|
||||
entity = EntityType.valueOf(myKey);
|
||||
}
|
||||
CMIEntityType entity = CMIEntityType.getByName(myKey);
|
||||
|
||||
if (entity != null) {
|
||||
if (entity.isAlive()) {
|
||||
type = entity.toString();
|
||||
id = entity.getTypeId();
|
||||
id = entity.getId();
|
||||
|
||||
// using breeder finder
|
||||
if (actionType == ActionType.BREED)
|
||||
Jobs.getGCManager().useBreederFinder = true;
|
||||
} else if (entity == EntityType.ENDER_CRYSTAL) {
|
||||
} else if (entity == CMIEntityType.ENDER_CRYSTAL) {
|
||||
type = entity.toString();
|
||||
id = entity.getTypeId();
|
||||
id = entity.getId();
|
||||
}
|
||||
}
|
||||
|
||||
if (entity == null) {
|
||||
// Pre 1.13 checks for custom names
|
||||
if (entity == null) {
|
||||
switch (myKey.toLowerCase()) {
|
||||
case "skeletonwither":
|
||||
type = CMIEntityType.WITHER_SKELETON.name();
|
||||
@ -579,19 +587,26 @@ public class ConfigManager {
|
||||
|
||||
} else if (actionType == ActionType.ENCHANT) {
|
||||
CMIEnchantment enchant = CMIEnchantment.get(myKey);
|
||||
type = enchant == null ? myKey : enchant.toString();
|
||||
} else if (actionType == ActionType.CUSTOMKILL || actionType == ActionType.SHEAR || actionType == ActionType.MMKILL
|
||||
|| actionType == ActionType.COLLECT || actionType == ActionType.BAKE || actionType == ActionType.BOSS)
|
||||
type = myKey;
|
||||
else if (actionType == ActionType.EXPLORE) {
|
||||
type = myKey;
|
||||
int amount = 10;
|
||||
try {
|
||||
amount = Integer.valueOf(myKey);
|
||||
} catch (NumberFormatException e) {
|
||||
Jobs.getPluginLogger().warning("Job " + jobName + " has an invalid " + actionType.getName() + " type property: " + myKey + "!");
|
||||
if (enchant == null && material == CMIMaterial.NONE) {
|
||||
Jobs.getPluginLogger().warning("Job " + myKey + " has an invalid " + actionType.getName() + " type property: " + myKey + "!");
|
||||
return null;
|
||||
}
|
||||
|
||||
type = enchant == null ? myKey : enchant.toString();
|
||||
} else if (actionType == ActionType.CUSTOMKILL || actionType == ActionType.COLLECT || actionType == ActionType.MMKILL
|
||||
|| actionType == ActionType.SHEAR || actionType == ActionType.BAKE || actionType == ActionType.BOSS) {
|
||||
type = myKey;
|
||||
} else if (actionType == ActionType.EXPLORE) {
|
||||
type = myKey;
|
||||
|
||||
int amount = 10;
|
||||
try {
|
||||
amount = Integer.valueOf(myKey);
|
||||
} catch (NumberFormatException e) {
|
||||
Jobs.getPluginLogger().warning("Job " + myKey + " has an invalid " + actionType.getName() + " type property: " + myKey + "!");
|
||||
return null;
|
||||
}
|
||||
|
||||
Jobs.getExplore().setExploreEnabled();
|
||||
Jobs.getExplore().setPlayerAmount(amount);
|
||||
} else if (actionType == ActionType.CRAFT) {
|
||||
@ -605,7 +620,7 @@ public class ConfigManager {
|
||||
}
|
||||
|
||||
if (type == null) {
|
||||
Jobs.getPluginLogger().warning("Job " + jobName + " has an invalid " + actionType.getName() + " type property: " + myKey + "!");
|
||||
Jobs.getPluginLogger().warning("Job " + myKey + " has an invalid " + actionType.getName() + " type property: " + myKey + "!");
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -1189,248 +1204,14 @@ public class ConfigManager {
|
||||
continue;
|
||||
}
|
||||
|
||||
String myKey = key,
|
||||
type = null,
|
||||
subType = "",
|
||||
meta = "";
|
||||
int id = 0;
|
||||
|
||||
if (myKey.contains("-")) {
|
||||
// uses subType
|
||||
subType = ":" + myKey.split("-")[1];
|
||||
meta = myKey.split("-")[1];
|
||||
myKey = myKey.split("-")[0];
|
||||
} else if (myKey.contains(":")) { // when we uses tipped arrow effect types
|
||||
meta = myKey.split(":")[1];
|
||||
myKey = myKey.split(":")[0];
|
||||
}
|
||||
|
||||
CMIMaterial material = CMIMaterial.NONE;
|
||||
|
||||
switch (actionType) {
|
||||
case KILL:
|
||||
case MILK:
|
||||
case MMKILL:
|
||||
case BOSS:
|
||||
case BREED:
|
||||
case TAME:
|
||||
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 BAKE:
|
||||
case BREW:
|
||||
case BREAK:
|
||||
case STRIPLOGS:
|
||||
case COLLECT:
|
||||
material = CMIMaterial.get(myKey + (subType));
|
||||
|
||||
if (material == CMIMaterial.NONE)
|
||||
material = CMIMaterial.get(myKey.replace(" ", "_").toUpperCase());
|
||||
|
||||
if (material == CMIMaterial.NONE) {
|
||||
// try integer method
|
||||
Integer matId = null;
|
||||
try {
|
||||
matId = Integer.valueOf(myKey);
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
if (matId != null) {
|
||||
material = CMIMaterial.get(matId);
|
||||
if (material != null) {
|
||||
log.warning("Job " + jobKey + " " + actionType.getName() + " is using ID: " + key + "!");
|
||||
log.warning("Please use the Material name instead: " + material.toString() + "!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (actionType == ActionType.STRIPLOGS && Version.isCurrentLower(Version.v1_13_R1))
|
||||
KeyValues keyValue = getKeyValue(key, actionType, jobKey);
|
||||
if (keyValue == null)
|
||||
continue;
|
||||
|
||||
if (material != null && material.getMaterial() != null && material.isAir()) {
|
||||
log.warning("Job " + jobKey + " " + actionType.getName() + " can't recognize material! (" + key + ")");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (material != null && Version.isCurrentLower(Version.v1_13_R1) && meta.isEmpty())
|
||||
meta = String.valueOf(material.getData());
|
||||
|
||||
c: if (material != null && material != CMIMaterial.NONE && material.getMaterial() != null) {
|
||||
|
||||
// Need to include those ones and count as regular blocks
|
||||
switch (key.replace("_", "").toLowerCase()) {
|
||||
case "itemframe":
|
||||
type = "ITEM_FRAME";
|
||||
id = 18;
|
||||
meta = "1";
|
||||
break c;
|
||||
case "painting":
|
||||
type = "PAINTING";
|
||||
id = 9;
|
||||
meta = "1";
|
||||
break c;
|
||||
case "armorstand":
|
||||
type = "ARMOR_STAND";
|
||||
id = 30;
|
||||
meta = "1";
|
||||
break c;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Break and Place actions MUST be blocks
|
||||
if (actionType == ActionType.BREAK || actionType == ActionType.PLACE || actionType == ActionType.STRIPLOGS) {
|
||||
if (!material.isBlock()) {
|
||||
log.warning("Job " + jobKey + " has an invalid " + actionType.getName() + " type property: " + material
|
||||
+ " (" + key + ")! Material must be a block! Use \"/jobs blockinfo\" on a target block");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// START HACK
|
||||
/*
|
||||
* Historically, GLOWING_REDSTONE_ORE would ONLY work as REDSTONE_ORE, and putting
|
||||
* GLOWING_REDSTONE_ORE in the configuration would not work. Unfortunately, this is
|
||||
* completely backwards and wrong.
|
||||
*
|
||||
* To maintain backwards compatibility, all instances of REDSTONE_ORE should normalize
|
||||
* to GLOWING_REDSTONE_ORE, and warn the user to change their configuration. In the
|
||||
* future this hack may be removed and anybody using REDSTONE_ORE will have their
|
||||
* configurations broken.
|
||||
*/
|
||||
if (material == CMIMaterial.REDSTONE_ORE && actionType == ActionType.BREAK && Version.isCurrentLower(Version.v1_13_R1)) {
|
||||
log.warning("Job " + jobKey + " is using REDSTONE_ORE instead of GLOWING_REDSTONE_ORE.");
|
||||
log.warning("Automatically changing block to GLOWING_REDSTONE_ORE. Please update your configuration.");
|
||||
log.warning("In vanilla minecraft, REDSTONE_ORE changes to GLOWING_REDSTONE_ORE when interacted with.");
|
||||
log.warning("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 && actionType == ActionType.BREAK && Version.isCurrentEqualOrHigher(Version.v1_13_R1)) {
|
||||
log.warning("Job " + job.getName() + " is using GLOWING_REDSTONE_ORE instead of REDSTONE_ORE.");
|
||||
log.warning("Automatically changing block to REDSTONE_ORE. Please update your configuration.");
|
||||
material = CMIMaterial.REDSTONE_ORE;
|
||||
}
|
||||
// END HACK
|
||||
|
||||
type = material.getMaterial().toString();
|
||||
id = material.getId();
|
||||
} else if (actionType == ActionType.KILL || actionType == ActionType.TAME || actionType == ActionType.BREED || actionType == ActionType.MILK) {
|
||||
|
||||
// check entities
|
||||
CMIEntityType entity = CMIEntityType.getByName(key);
|
||||
|
||||
if (entity != null) {
|
||||
if (entity.isAlive()) {
|
||||
type = entity.toString();
|
||||
id = entity.getId();
|
||||
|
||||
// using breeder finder
|
||||
if (actionType == ActionType.BREED)
|
||||
Jobs.getGCManager().useBreederFinder = true;
|
||||
} else if (entity == CMIEntityType.ENDER_CRYSTAL) {
|
||||
type = entity.toString();
|
||||
id = entity.getId();
|
||||
}
|
||||
}
|
||||
|
||||
// Pre 1.13 checks for custom names
|
||||
if (entity == null) {
|
||||
switch (key.toLowerCase()) {
|
||||
case "skeletonwither":
|
||||
type = CMIEntityType.WITHER_SKELETON.name();
|
||||
id = 51;
|
||||
meta = "1";
|
||||
break;
|
||||
case "skeletonstray":
|
||||
type = CMIEntityType.STRAY.name();
|
||||
id = 51;
|
||||
meta = "2";
|
||||
break;
|
||||
case "zombievillager":
|
||||
type = CMIEntityType.ZOMBIE_VILLAGER.name();
|
||||
id = 54;
|
||||
meta = "1";
|
||||
break;
|
||||
case "zombiehusk":
|
||||
type = CMIEntityType.HUSK.name();
|
||||
id = 54;
|
||||
meta = "2";
|
||||
break;
|
||||
case "horseskeleton":
|
||||
type = CMIEntityType.SKELETON_HORSE.name();
|
||||
id = 100;
|
||||
meta = "1";
|
||||
break;
|
||||
case "horsezombie":
|
||||
type = CMIEntityType.ZOMBIE_HORSE.name();
|
||||
id = 100;
|
||||
meta = "2";
|
||||
break;
|
||||
case "guardianelder":
|
||||
type = CMIEntityType.ELDER_GUARDIAN.name();
|
||||
id = 68;
|
||||
meta = "1";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} else if (actionType == ActionType.ENCHANT) {
|
||||
CMIEnchantment enchant = CMIEnchantment.get(myKey);
|
||||
if (enchant == null && material == CMIMaterial.NONE) {
|
||||
log.warning("Job " + jobKey + " has an invalid " + actionType.getName() + " type property: " + key + "!");
|
||||
continue;
|
||||
}
|
||||
|
||||
type = enchant == null ? myKey : enchant.toString();
|
||||
} else if (actionType == ActionType.CUSTOMKILL || actionType == ActionType.COLLECT || actionType == ActionType.MMKILL
|
||||
|| actionType == ActionType.SHEAR || actionType == ActionType.BAKE || actionType == ActionType.BOSS)
|
||||
type = myKey;
|
||||
else if (actionType == ActionType.EXPLORE) {
|
||||
type = myKey;
|
||||
int amount = 10;
|
||||
try {
|
||||
amount = Integer.valueOf(myKey);
|
||||
} catch (NumberFormatException e) {
|
||||
log.warning("Job " + jobKey + " has an invalid " + actionType.getName() + " type property: " + key + "!");
|
||||
continue;
|
||||
}
|
||||
|
||||
Jobs.getExplore().setExploreEnabled();
|
||||
Jobs.getExplore().setPlayerAmount(amount);
|
||||
} else if (actionType == ActionType.CRAFT) {
|
||||
if (myKey.startsWith("!")) {
|
||||
type = myKey.substring(1, myKey.length());
|
||||
}
|
||||
|
||||
if (myKey.contains(":")) {
|
||||
subType = myKey.split(":")[1];
|
||||
}
|
||||
}
|
||||
|
||||
if (type == null) {
|
||||
log.warning("Job " + jobKey + " has an invalid " + actionType.getName() + " type property: " + key + "!");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (":ALL".equalsIgnoreCase(subType)) {
|
||||
meta = "ALL";
|
||||
type = CMIMaterial.getGeneralMaterialName(type);
|
||||
}
|
||||
int id = keyValue.getId();
|
||||
String type = keyValue.getType(),
|
||||
subType = keyValue.getSubType(),
|
||||
meta = keyValue.getMeta();
|
||||
|
||||
if (actionType == ActionType.TNTBREAK)
|
||||
Jobs.getGCManager().setTntFinder(true);
|
||||
|
Loading…
Reference in New Issue
Block a user