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:
parent
a3ee77e70d
commit
bf58cf0766
@ -40,4 +40,8 @@ public class EnchantActionInfo extends BaseActionInfo {
|
||||
public String getNameWithSub() {
|
||||
return name + ":" + level;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
}
|
||||
|
@ -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());
|
||||
|
Loading…
Reference in New Issue
Block a user