1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-30 21:07:48 +01:00

Add explicit job info handling for EnchantActionInfo to ensure correct matching

This commit is contained in:
BeepoWuff 2021-09-19 00:48:42 +10:00
parent a3ee77e70d
commit bf58cf0766
No known key found for this signature in database
GPG Key ID: 4C176134BCA5058C
2 changed files with 19 additions and 0 deletions

View File

@ -40,4 +40,8 @@ public class EnchantActionInfo extends BaseActionInfo {
public String getNameWithSub() {
return name + ":" + level;
}
public int getLevel() {
return level;
}
}

View File

@ -29,6 +29,8 @@ import java.util.Map;
import java.util.Random;
import java.util.function.BiPredicate;
import com.gamingmesh.jobs.CMILib.CMIEnchantment;
import com.gamingmesh.jobs.actions.EnchantActionInfo;
import org.bukkit.block.Block;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
@ -307,6 +309,19 @@ public class Job {
return jobInfo.getName().equalsIgnoreCase(subName) || (jobInfo.getName() + ":" + jobInfo.getMeta()).equalsIgnoreCase(subName);
}
if (actionInfo instanceof EnchantActionInfo) {
EnchantActionInfo enchantActionInfo = (EnchantActionInfo)actionInfo;
String enchantName = CMIEnchantment.get(actionInfo.getName()).toString();
return (
// Enchantment without level e.g. silk_touch
jobInfo.getName().equalsIgnoreCase(enchantName) ||
// Enchantment with level e.g. fire_aspect:1
jobInfo.getName().equalsIgnoreCase(enchantName + ":" + enchantActionInfo.getLevel())
);
}
return jobInfo.getName().equalsIgnoreCase(action.getNameWithSub()) ||
(jobInfo.getName() + ":" + jobInfo.getMeta()).equalsIgnoreCase(action.getNameWithSub()) ||
jobInfo.getName().equalsIgnoreCase(action.getName());