mirror of
https://github.com/Zrips/Jobs.git
synced 2025-03-11 22:31:04 +01:00
Fixed when tipped arrow for crafting not works (#802)
This commit is contained in:
parent
12ffc67eed
commit
0c1d7893f4
@ -1270,11 +1270,14 @@ public enum CMIMaterial {
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
try {
|
||||
String metaTag = id.split(":")[1];
|
||||
ItemManager.byName.get(id + ":" + metaTag);
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
|
||||
if (id.contains(":")) {
|
||||
String metaTag = id.split(":")[1];
|
||||
CMIMaterial mat = ItemManager.byName.get(id + ":" + metaTag);
|
||||
if (mat != null) {
|
||||
return mat;
|
||||
}
|
||||
}
|
||||
|
||||
CMIMaterial mat = ItemManager.byName.get(id);
|
||||
if (mat != null) {
|
||||
|
@ -60,9 +60,9 @@ public class ItemManager {
|
||||
: mojangName.replace("_", "").replace(" ", "").toLowerCase();
|
||||
|
||||
if (one.isCanHavePotionType()) {
|
||||
for (Potion p : Potion.values()) {
|
||||
byName.put(cmiName + ":" + p.getName(), one);
|
||||
}
|
||||
for (Potion p : Potion.values()) {
|
||||
byName.put(cmiName + ":" + p.getName().toLowerCase(), one);
|
||||
}
|
||||
}
|
||||
else if (byName.containsKey(cmiName)) {
|
||||
byName.put(cmiName + ":" + data, one);
|
||||
|
@ -32,7 +32,6 @@ public class PotionItemActionInfo extends ItemActionInfo {
|
||||
}
|
||||
|
||||
public String getNameWithPotion() {
|
||||
return getName() + ":" + potionType.name();
|
||||
return getName() + ":" + potionType.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -395,6 +395,9 @@ public class ConfigManager {
|
||||
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 = null;
|
||||
@ -584,8 +587,15 @@ public class ConfigManager {
|
||||
}
|
||||
Jobs.getExplore().setExploreEnabled();
|
||||
Jobs.getExplore().setPlayerAmount(amount);
|
||||
} else if (actionType == ActionType.CRAFT && myKey.startsWith("!"))
|
||||
type = myKey.substring(1, myKey.length());
|
||||
} else if (actionType == ActionType.CRAFT) {
|
||||
if (myKey.startsWith("!")) {
|
||||
type = myKey.substring(1, myKey.length());
|
||||
}
|
||||
|
||||
if (myKey.contains(":")) {
|
||||
subType = myKey.split(":")[1];
|
||||
}
|
||||
}
|
||||
|
||||
if (type == null) {
|
||||
Jobs.getPluginLogger().warning("Job " + jobName + " has an invalid " + actionType.getName() + " type property: " + myKey + "!");
|
||||
@ -1176,6 +1186,9 @@ public class ConfigManager {
|
||||
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;
|
||||
@ -1380,8 +1393,15 @@ public class ConfigManager {
|
||||
|
||||
Jobs.getExplore().setExploreEnabled();
|
||||
Jobs.getExplore().setPlayerAmount(amount);
|
||||
} else if (actionType == ActionType.CRAFT && myKey.startsWith("!"))
|
||||
type = myKey.substring(1, myKey.length());
|
||||
} 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 + "!");
|
||||
|
@ -18,6 +18,7 @@ import com.gamingmesh.jobs.CMILib.ConfigReader;
|
||||
import com.gamingmesh.jobs.container.ActionType;
|
||||
import com.gamingmesh.jobs.container.JobInfo;
|
||||
import com.gamingmesh.jobs.container.NameList;
|
||||
import com.gamingmesh.jobs.container.Potion;
|
||||
import com.gamingmesh.jobs.hooks.HookManager;
|
||||
import com.gamingmesh.jobs.stuff.Util;
|
||||
|
||||
@ -55,10 +56,14 @@ public class NameTranslatorManager {
|
||||
CMIMaterial mat = CMIMaterial.get(materialName.replace(" ", ""));
|
||||
NameList nameLs = ListOfNames.get(mat);
|
||||
|
||||
if (nameLs != null) {
|
||||
return nameLs.getName();
|
||||
if (nameLs != null) {
|
||||
if (meta != null && !meta.isEmpty() && mat.isCanHavePotionType() && Potion.getByName(meta) != null) {
|
||||
return nameLs.getName() + ":" + meta;
|
||||
}
|
||||
|
||||
return nameLs.getName();
|
||||
}
|
||||
|
||||
if (mame != null && !mame.isEmpty()) {
|
||||
mat = CMIMaterial.get(materialName.replace(" ", ""));
|
||||
nameLs = ListOfNames.get(mat);
|
||||
@ -72,13 +77,14 @@ public class NameTranslatorManager {
|
||||
mat = CMIMaterial.get(materialName + ":" + meta);
|
||||
nameLs = ListOfNames.get(mat);
|
||||
if (nameLs == null) {
|
||||
mat = CMIMaterial.get(materialName.replace(" ", ""));
|
||||
nameLs = ListOfNames.get(mat);
|
||||
NameList nameMeta = ListOfNames.get(CMIMaterial.get(meta.replace(" ", "")));
|
||||
if (nameLs != null && nameMeta != null) {
|
||||
return nameLs + ":" + nameMeta;
|
||||
}
|
||||
return mat.getName();
|
||||
mat = CMIMaterial.get(materialName.replace(" ", ""));
|
||||
nameLs = ListOfNames.get(mat);
|
||||
NameList nameMeta = ListOfNames.get(CMIMaterial.get(meta.replace(" ", "")));
|
||||
if (nameLs != null && nameMeta != null) {
|
||||
return nameLs + ":" + nameMeta;
|
||||
}
|
||||
|
||||
return mat.getName();
|
||||
}
|
||||
}
|
||||
|
||||
@ -419,26 +425,26 @@ public class NameTranslatorManager {
|
||||
/** for (colorNames cn : colorNames.values()) {
|
||||
if (cn.getName() == null)
|
||||
continue;
|
||||
|
||||
|
||||
String n = cn.getId() + (cn.getId() == -1 ? "" : ":" + cn.getName());
|
||||
|
||||
|
||||
String name = null;
|
||||
|
||||
|
||||
if (c.getC().isConfigurationSection("ColorList." + n)) {
|
||||
name = c.getC().getString("ColorList." + n + ".Name");
|
||||
}
|
||||
|
||||
|
||||
if (name == null) {
|
||||
n = cn.getId() + "-" + cn.toString();
|
||||
if (c.getC().isConfigurationSection("ColorList." + n)) {
|
||||
name = c.getC().getString("ColorList." + n);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (name == null) {
|
||||
name = cn.getName();
|
||||
}
|
||||
|
||||
|
||||
c.get("ColorList." + cn.getId() + "-" + cn.toString(), name);
|
||||
}*/
|
||||
|
||||
|
@ -225,27 +225,29 @@ public class Job {
|
||||
}
|
||||
|
||||
public JobInfo getJobInfo(ActionInfo action, int level) {
|
||||
BiPredicate<JobInfo, ActionInfo> condition = (jobInfo, actionInfo) -> {
|
||||
if (actionInfo instanceof PotionItemActionInfo) {
|
||||
Jobs.consoleMsg(jobInfo.getName() + ":" + jobInfo.getMeta());
|
||||
return jobInfo.getName().equalsIgnoreCase(((PotionItemActionInfo) action).getNameWithPotion()) ||
|
||||
(jobInfo.getName() + ":" + jobInfo.getMeta()).equalsIgnoreCase(((PotionItemActionInfo) action).getNameWithPotion());
|
||||
}
|
||||
|
||||
BiPredicate<JobInfo, ActionInfo> condition = (jobInfo, actionInfo) -> {
|
||||
if (actionInfo instanceof PotionItemActionInfo) {
|
||||
return jobInfo.getName().equalsIgnoreCase(((PotionItemActionInfo) action).getNameWithPotion()) ||
|
||||
(jobInfo.getName() + ":" + jobInfo.getMeta()).equalsIgnoreCase(((PotionItemActionInfo) action).getNameWithPotion());
|
||||
} else {
|
||||
return jobInfo.getName().equalsIgnoreCase(action.getNameWithSub()) ||
|
||||
(jobInfo.getName() + ":" + jobInfo.getMeta()).equalsIgnoreCase(action.getNameWithSub()) ||
|
||||
jobInfo.getName().equalsIgnoreCase(action.getName());
|
||||
}
|
||||
};
|
||||
return jobInfo.getName().equalsIgnoreCase(action.getNameWithSub()) ||
|
||||
(jobInfo.getName() + ":" + jobInfo.getMeta()).equalsIgnoreCase(action.getNameWithSub()) ||
|
||||
jobInfo.getName().equalsIgnoreCase(action.getName());
|
||||
};
|
||||
|
||||
for (JobInfo info : getJobInfo(action.getType())) {
|
||||
if (condition.test(info, action)) {
|
||||
if (!info.isInLevelRange(level)) {
|
||||
break;
|
||||
}
|
||||
return info;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
for (JobInfo info : getJobInfo(action.getType())) {
|
||||
if (condition.test(info, action)) {
|
||||
if (!info.isInLevelRange(level)) {
|
||||
break;
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,42 +19,46 @@
|
||||
package com.gamingmesh.jobs.container;
|
||||
|
||||
/**
|
||||
* <a href="https://minecraft.gamepedia.com/Potion#Java_Edition">Minecraft-WIKI reference</a>
|
||||
* <a href="https://papermc.io/javadocs/paper/1.13/org/bukkit/potion/PotionType.html">API reference for names</a>
|
||||
*/
|
||||
public enum Potion {
|
||||
NIGHT_VISION("Night Vision"),
|
||||
INVISIBILITY("Invisibility"),
|
||||
LEAPING("Leaping"),
|
||||
FIRE_RESISTANCE("Fire Resistance"),
|
||||
SWIFTNESS("Swiftness"),
|
||||
SLOWNESS("Slowness"),
|
||||
WATER_BREATHING("Water Breathing"),
|
||||
HEALING("Instant Health"),
|
||||
HARMING("Harming"),
|
||||
POISON("Poison"),
|
||||
REGENERATION("Regeneration"),
|
||||
STRENGTH("Strength"),
|
||||
WEAKNESS("Weakness"),
|
||||
LUCK("Luck"),
|
||||
TURTLE_MASTER("The Turtle Master"),
|
||||
SLOW_FALLING("Slow Falling");
|
||||
AWKWARD("AWKWARD"),
|
||||
FIRE_RESISTANCE("FIRE_RESISTANCE"),
|
||||
INSTANT_DAMAGE("INSTANT_DAMAGE"),
|
||||
INSTANT_HEAL("INSTANT_HEAL"),
|
||||
INVISIBILITY("INVISIBILITY"),
|
||||
JUMP("JUMP"),
|
||||
LUCK("LUCK"),
|
||||
MUNDANE("MUNDANE"),
|
||||
NIGHT_VISION("NIGHT_VISION"),
|
||||
POISON("POISON"),
|
||||
REGEN("REGEN"),
|
||||
SLOW_FALLING("SLOW_FALLING"),
|
||||
SLOWNESS("SLOWNESS"),
|
||||
SPEED("SPEED"),
|
||||
STRENGTH("STRENGTH"),
|
||||
THICK("THICK"),
|
||||
TURTLE_MASTER("TURTLE_MASTER"),
|
||||
WATER_BREATHING("WATER_BREATHING"),
|
||||
WEAKNESS("WEAKNESS");
|
||||
|
||||
private final String name;
|
||||
|
||||
Potion(String name) {
|
||||
this.name = name;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
return name;
|
||||
}
|
||||
|
||||
public static Potion getByName(String name) {
|
||||
name = name.replace("_", "");
|
||||
for (Potion one : Potion.values()) {
|
||||
if (one.name.equalsIgnoreCase(name))
|
||||
return one;
|
||||
}
|
||||
return null;
|
||||
name = name.replace("_", "");
|
||||
for (Potion one : Potion.values()) {
|
||||
if (one.name.equalsIgnoreCase(name)) {
|
||||
return one;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -78,8 +78,8 @@ import org.bukkit.inventory.EnchantingInventory;
|
||||
import org.bukkit.inventory.GrindstoneInventory;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.inventory.StonecutterInventory;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
@ -593,11 +593,6 @@ public class JobsPaymentListener implements Listener {
|
||||
if (!payIfCreative(player))
|
||||
return;
|
||||
|
||||
ItemStack currentItem = event.getCurrentItem();
|
||||
if (currentItem == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Checking if item is been repaired, not crafted. Combining 2 items
|
||||
ItemStack[] sourceItems = event.getInventory().getContents();
|
||||
|
||||
@ -688,23 +683,26 @@ public class JobsPaymentListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack currentItem = event.getCurrentItem();
|
||||
if (currentItem != null) {
|
||||
if (currentItem.hasItemMeta() && currentItem.getItemMeta() instanceof PotionMeta) {
|
||||
Jobs.consoleMsg(currentItem + " " + currentItem.hasItemMeta() + " " + currentItem.getItemMeta());
|
||||
PotionMeta potion = (PotionMeta) currentItem.getItemMeta();
|
||||
Jobs.action(jPlayer, new PotionItemActionInfo(currentItem, ActionType.CRAFT, potion.getBasePotionData().getType()));
|
||||
} else {
|
||||
Jobs.action(jPlayer, new ItemActionInfo(currentItem, ActionType.CRAFT));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// If we need to pay only by each craft action we will skip calculation how much was crafted
|
||||
if (!Jobs.getGCManager().PayForEachCraft) {
|
||||
if (resultStack.hasItemMeta() && resultStack.getItemMeta().hasDisplayName()) {
|
||||
Jobs.action(jPlayer, new ItemNameActionInfo(ChatColor.stripColor(resultStack.getItemMeta()
|
||||
.getDisplayName()), ActionType.CRAFT));
|
||||
} else {
|
||||
if (currentItem.hasItemMeta()) {
|
||||
if (currentItem.getItemMeta() instanceof PotionMeta) {
|
||||
PotionMeta potion = (PotionMeta) currentItem.getItemMeta();
|
||||
Jobs.action(jPlayer, new PotionItemActionInfo(currentItem, ActionType.CRAFT, potion.getBasePotionData().getType()));
|
||||
} else {
|
||||
Jobs.action(jPlayer, new ItemActionInfo(currentItem, ActionType.CRAFT));
|
||||
}
|
||||
} else {
|
||||
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.CRAFT));
|
||||
}
|
||||
Jobs.action(jPlayer, new ItemNameActionInfo(ChatColor.stripColor(resultStack.getItemMeta()
|
||||
.getDisplayName()), ActionType.CRAFT));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user