mirror of
https://github.com/Zrips/Jobs.git
synced 2025-01-02 14:29:07 +01:00
parent
7e5ab9bb9c
commit
b7dbd08d83
@ -2059,11 +2059,11 @@ public enum CMIMaterial {
|
||||
}
|
||||
|
||||
public boolean isValidItem() {
|
||||
return !equals(CMIMaterial.NONE) && !isAir() && getMaterial() != null;
|
||||
return this != CMIMaterial.NONE && !isAir() && getMaterial() != null;
|
||||
}
|
||||
|
||||
public boolean isNone() {
|
||||
return equals(CMIMaterial.NONE);
|
||||
return this == CMIMaterial.NONE;
|
||||
}
|
||||
|
||||
public static boolean isAir(Material mat) {
|
||||
|
@ -10,6 +10,7 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
|
||||
import com.gamingmesh.jobs.CMILib.CMIChatColor;
|
||||
@ -89,6 +90,8 @@ public class ItemBoostManager {
|
||||
cfg.addComment("exampleBoost.enchants", "(Optional) Item custom enchants",
|
||||
"All enchantment names can be found https://hub.spigotmc.org/javadocs/spigot/org/bukkit/enchantments/Enchantment.html");
|
||||
cfg.get("exampleBoost.enchants", Arrays.asList("FIRE_ASPECT=1", "DAMAGE_ALL=1"));
|
||||
cfg.addComment("exampleBoost.leather-color", "(Optional) Leather armour colors (0-255)");
|
||||
cfg.get("exampleBoost.leather-color", "82,34,125");
|
||||
cfg.addComment("exampleBoost.moneyBoost", "[Required] Money boost: 1.1 is equals 10% more income when 0.9 is equals 10% less from base income");
|
||||
for (CurrencyType oneC : CurrencyType.values()) {
|
||||
cfg.get("exampleBoost." + oneC.toString().toLowerCase() + "Boost", 1D);
|
||||
@ -167,7 +170,22 @@ public class ItemBoostManager {
|
||||
String name = cfg.getC().isString(one + ".name") ? cfg.get(one + ".name", "") : null;
|
||||
String node = one.toLowerCase();
|
||||
|
||||
JobItems item = new JobItems(node, mat, 1, name, lore, enchants, b, jobs);
|
||||
Color leatherColor = null;
|
||||
if (cfg.getC().isString(one + ".leather-color")) {
|
||||
String[] split = cfg.getC().getString(one + ".leather-color").split(",", 3);
|
||||
if (split.length != 0) {
|
||||
int red = Integer.parseInt(split[0]);
|
||||
int green = split.length > 0 ? Integer.parseInt(split[1]) : 0;
|
||||
int blue = split.length > 1 ? Integer.parseInt(split[2]) : 0;
|
||||
|
||||
try {
|
||||
leatherColor = Color.fromRGB(red, green, blue);
|
||||
} catch (IllegalArgumentException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JobItems item = new JobItems(node, mat, 1, name, lore, enchants, b, jobs, null, leatherColor);
|
||||
|
||||
if (cfg.getC().isInt(one + ".levelFrom"))
|
||||
item.setFromLevel(cfg.get(one + ".levelFrom", 0));
|
||||
|
@ -73,7 +73,7 @@ public class SignUtil {
|
||||
signsByType.put(identifier, old);
|
||||
}
|
||||
|
||||
public void LoadSigns() {
|
||||
public void loadSigns() {
|
||||
if (!Jobs.getGCManager().SignsEnabled)
|
||||
return;
|
||||
|
||||
|
@ -265,7 +265,7 @@ public class GeneralConfigManager {
|
||||
// Item/Block/mobs name list
|
||||
Jobs.getNameTranslatorManager().load();
|
||||
// signs information
|
||||
Jobs.getSignUtil().LoadSigns();
|
||||
Jobs.getSignUtil().loadSigns();
|
||||
// Shop
|
||||
Jobs.getShopManager().load();
|
||||
}
|
||||
|
@ -460,7 +460,7 @@ public class ShopManager {
|
||||
}
|
||||
|
||||
items.add(new JobItems(node, id == null ? CMIMaterial.STONE : CMIMaterial.get(id), amount, name, lore,
|
||||
enchants, new BoostMultiplier(), new ArrayList<Job>(), potionData));
|
||||
enchants, new BoostMultiplier(), new ArrayList<Job>(), potionData, null));
|
||||
}
|
||||
sItem.setitems(items);
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package com.gamingmesh.jobs.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@ -35,21 +34,11 @@ public class YmlMaker {
|
||||
}
|
||||
|
||||
public void reloadConfig() {
|
||||
InputStreamReader f = null;
|
||||
try {
|
||||
f = new InputStreamReader(new FileInputStream(configFile), StandardCharsets.UTF_8);
|
||||
} catch (FileNotFoundException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
if (f == null) {
|
||||
if (!exists())
|
||||
return;
|
||||
}
|
||||
|
||||
configuration = YamlConfiguration.loadConfiguration(f);
|
||||
|
||||
try {
|
||||
f.close();
|
||||
try (InputStreamReader reader = new InputStreamReader(new FileInputStream(configFile), StandardCharsets.UTF_8)) {
|
||||
configuration = YamlConfiguration.loadConfiguration(reader);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -24,11 +24,13 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
@ -45,6 +47,7 @@ public class JobItems {
|
||||
private ItemStack item;
|
||||
|
||||
private Object potion;
|
||||
private Color leatherColor;
|
||||
|
||||
private final Map<Enchantment, Integer> enchants = new HashMap<>();
|
||||
private BoostMultiplier boostMultiplier = new BoostMultiplier();
|
||||
@ -55,11 +58,11 @@ public class JobItems {
|
||||
private int untilLevel = Integer.MAX_VALUE;
|
||||
|
||||
public JobItems(String node, CMIMaterial mat, int amount, String name, List<String> lore, Map<Enchantment, Integer> enchants, BoostMultiplier boostMultiplier, List<Job> jobs) {
|
||||
this(node, mat, amount, name, lore, enchants, boostMultiplier, jobs, null);
|
||||
this(node, mat, amount, name, lore, enchants, boostMultiplier, jobs, null, null);
|
||||
}
|
||||
|
||||
public JobItems(String node, CMIMaterial mat, int amount, String name, List<String> lore, Map<Enchantment, Integer> enchants, BoostMultiplier boostMultiplier, List<Job> jobs,
|
||||
Object potion) {
|
||||
Object potion, Color leatherColor) {
|
||||
if (mat == null) {
|
||||
mat = CMIMaterial.STONE;
|
||||
}
|
||||
@ -77,7 +80,7 @@ public class JobItems {
|
||||
setJobs(jobs);
|
||||
|
||||
ItemMeta meta = (item = mat.newItemStack()).getItemMeta();
|
||||
if (CMIMaterial.isPotion(mat.getMaterial()) && potion != null && meta instanceof PotionMeta) {
|
||||
if (potion != null && CMIMaterial.isPotion(mat.getMaterial()) && meta instanceof PotionMeta) {
|
||||
PotionMeta potionMeta = (PotionMeta) meta;
|
||||
|
||||
if (Version.isCurrentEqualOrHigher(Version.v1_10_R1) && potion instanceof org.bukkit.potion.PotionData) {
|
||||
@ -90,6 +93,10 @@ public class JobItems {
|
||||
}
|
||||
|
||||
meta = potionMeta;
|
||||
} else if (leatherColor != null && CMIMaterial.isLeatherArmor(mat.getMaterial()) && meta instanceof LeatherArmorMeta) {
|
||||
LeatherArmorMeta armorMeta = (LeatherArmorMeta) meta;
|
||||
armorMeta.setColor(this.leatherColor = leatherColor);
|
||||
meta = armorMeta;
|
||||
}
|
||||
|
||||
if (meta != null) {
|
||||
@ -146,6 +153,10 @@ public class JobItems {
|
||||
}
|
||||
|
||||
meta = potionMeta;
|
||||
} else if (leatherColor != null && CMIMaterial.isLeatherArmor(item.getType()) && meta instanceof LeatherArmorMeta) {
|
||||
LeatherArmorMeta armorMeta = (LeatherArmorMeta) meta;
|
||||
armorMeta.setColor(leatherColor);
|
||||
meta = armorMeta;
|
||||
}
|
||||
|
||||
if (meta.hasDisplayName())
|
||||
|
@ -185,11 +185,15 @@ public class BlockOwnerShip {
|
||||
: type == BlockTypes.BLAST_FURNACE ? "BlastFurnace"
|
||||
: type == BlockTypes.BREWING_STAND ? "Brewing" : type == BlockTypes.SMOKER ? "Smoker" : "");
|
||||
|
||||
if (isReassignDisabled() || !f.getConfig().isConfigurationSection(path))
|
||||
if (isReassignDisabled())
|
||||
return;
|
||||
|
||||
int total = 0;
|
||||
ConfigurationSection section = f.getConfig().getConfigurationSection(path);
|
||||
if (section == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int total = 0;
|
||||
for (String one : section.getKeys(false)) {
|
||||
String value = section.getString(one);
|
||||
List<String> ls = new ArrayList<>();
|
||||
|
Loading…
Reference in New Issue
Block a user