mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2025-01-23 09:41:20 +01:00
Removed name placeholders, added config update n4
There is no longer a parent option for modifiers, you need to specify the exact same modifier id as the public modifier
This commit is contained in:
parent
95cfa11917
commit
7c42b86480
@ -8,7 +8,6 @@ import net.Indyuce.mmoitems.api.Type;
|
||||
import net.Indyuce.mmoitems.api.crafting.ConfigMMOItem;
|
||||
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
|
||||
import net.Indyuce.mmoitems.api.player.RPGPlayer;
|
||||
import net.Indyuce.mmoitems.stat.DisplayName;
|
||||
import net.Indyuce.mmoitems.stat.data.MaterialData;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
import net.mmogroup.mmolib.api.MMOLineConfig;
|
||||
@ -67,7 +66,7 @@ public class MMOItemIngredient extends Ingredient {
|
||||
|
||||
private String findName() {
|
||||
if (template.getBaseItemData().containsKey(ItemStat.NAME))
|
||||
return ((DisplayName) ItemStat.NAME).getDisplayName(template.getBaseItemData().get(ItemStat.NAME).toString());
|
||||
return template.getBaseItemData().get(ItemStat.NAME).toString();
|
||||
if (template.getBaseItemData().containsKey(ItemStat.MATERIAL))
|
||||
return MMOUtils.caseOnWords(
|
||||
((MaterialData) template.getBaseItemData().get(ItemStat.MATERIAL)).getMaterial().name().toLowerCase().replace("_", " "));
|
||||
|
@ -50,10 +50,11 @@ public class TemplateModifier {
|
||||
* when providing a non-null itemGenManager, it indicates that public
|
||||
* modifiers were loaded and that the constructor can use them
|
||||
*/
|
||||
if (manager != null && config.contains("parent")) {
|
||||
String parentFormat = config.get("parent").toString().toLowerCase().replace("_", "-").replace(" ", "_");
|
||||
Validate.isTrue(manager.hasModifier(parentFormat), "Could not find public modifier with ID '" + parentFormat + "'");
|
||||
TemplateModifier parent = manager.getModifier(parentFormat);
|
||||
if (!config.contains("stats")) {
|
||||
Validate.notNull(manager, "Cannot create a private modifier outside an item template");
|
||||
|
||||
Validate.isTrue(manager.hasModifier(id), "Could not find public modifier with ID '" + id + "'");
|
||||
TemplateModifier parent = manager.getModifier(id);
|
||||
|
||||
chance = Math.max(Math.min(config.getDouble("chance", parent.chance), 1), 0);
|
||||
weight = config.getDouble("weight", parent.weight);
|
||||
|
@ -68,40 +68,6 @@ public class MMOItemsCommand implements CommandExecutor {
|
||||
|
||||
// ==================================================================================================================================
|
||||
if (args.length < 1) {
|
||||
|
||||
for (Type type : MMOItems.plugin.getTypes().getAll()) {
|
||||
ConfigFile config = type.getConfigFile();
|
||||
for (String id : config.getConfig().getKeys(false)) {
|
||||
|
||||
for (String statKey : config.getConfig().getConfigurationSection(id + ".base").getKeys(false)) {
|
||||
|
||||
String str = config.getConfig().getString(id + ".base." + statKey);
|
||||
if (str != null)
|
||||
try {
|
||||
|
||||
String[] split = str.split("\\=");
|
||||
Validate.isTrue(split.length == 2);
|
||||
double val1 = Double.parseDouble(split[0]);
|
||||
double val2 = Double.parseDouble(split[1]);
|
||||
|
||||
double avg = (val1 + val2) / 2;
|
||||
double max = Math.max(Math.abs(val1), Math.abs(val2));
|
||||
double rel = (max - avg) / max;
|
||||
|
||||
config.getConfig().set(id + ".base." + statKey + ".base", avg);
|
||||
config.getConfig().set(id + ".base." + statKey + ".spread", rel / 3);
|
||||
config.getConfig().set(id + ".base." + statKey + ".max-spread", rel);
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
config.save();
|
||||
}
|
||||
|
||||
new PluginHelp(sender).open(1);
|
||||
return true;
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import java.nio.file.StandardCopyOption;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.logging.Level;
|
||||
@ -33,7 +32,7 @@ import net.mmogroup.mmolib.api.util.AltChar;
|
||||
public class ConfigManager {
|
||||
|
||||
// cached config files
|
||||
private ConfigFile abilities, items, loreFormat, messages, potionEffects, stats, attackEffects, namePlaceholders;
|
||||
private ConfigFile abilities, items, loreFormat, messages, potionEffects, stats, attackEffects;
|
||||
|
||||
// cached config options
|
||||
public boolean abilityPlayerDamage, dodgeKnockbackEnabled, replaceMushroomDrops, worldGenEnabled, upgradeRequirementsCheck;
|
||||
@ -42,29 +41,16 @@ public class ConfigManager {
|
||||
public double dodgeKnockbackForce, soulboundBaseDamage, soulboundPerLvlDamage, levelSpread;
|
||||
public NumericStatFormula defaultItemCapacity;
|
||||
|
||||
private static final Random random = new Random();
|
||||
private static final String[] fileNames = { "abilities", "messages", "potion-effects", "stats", "items", "attack-effects" };
|
||||
private static final String[] languages = { "french", "chinese", "spanish", "russian", "polish" };
|
||||
|
||||
// try to setup non existing languages
|
||||
public ConfigManager() {
|
||||
File mainLanguageFolder = new File(MMOItems.plugin.getDataFolder() + "/language");
|
||||
if (!mainLanguageFolder.exists())
|
||||
mainLanguageFolder.mkdir();
|
||||
|
||||
File itemFolder = new File(MMOItems.plugin.getDataFolder() + "/item");
|
||||
if (!itemFolder.exists())
|
||||
itemFolder.mkdir();
|
||||
|
||||
File dynamicFolder = new File(MMOItems.plugin.getDataFolder() + "/dynamic");
|
||||
if (!dynamicFolder.exists())
|
||||
dynamicFolder.mkdir();
|
||||
|
||||
if (!new File(MMOItems.plugin.getDataFolder() + "/generator").exists()) {
|
||||
new File(MMOItems.plugin.getDataFolder() + "/generator").mkdir();
|
||||
new File(MMOItems.plugin.getDataFolder() + "/generator/templates").mkdir();
|
||||
new File(MMOItems.plugin.getDataFolder() + "/generator/modifiers").mkdir();
|
||||
}
|
||||
mkdir("item");
|
||||
mkdir("dynamic");
|
||||
mkdir("language");
|
||||
mkdir("modifiers");
|
||||
|
||||
File craftingStationsFolder = new File(MMOItems.plugin.getDataFolder() + "/crafting-stations");
|
||||
if (!craftingStationsFolder.exists()) {
|
||||
@ -186,7 +172,6 @@ public class ConfigManager {
|
||||
potionEffects = new ConfigFile("/language", "potion-effects");
|
||||
stats = new ConfigFile("/language", "stats");
|
||||
attackEffects = new ConfigFile("/language", "attack-effects");
|
||||
namePlaceholders = new ConfigFile("name-placeholders");
|
||||
|
||||
/*
|
||||
* reload cached config options for quicker access - these options are
|
||||
@ -254,14 +239,6 @@ public class ConfigManager {
|
||||
return potionEffects.getConfig().getString(type.getName().toLowerCase().replace("_", "-"));
|
||||
}
|
||||
|
||||
public String getNamePlaceholder(String path) {
|
||||
if (!namePlaceholders.getConfig().contains(path))
|
||||
return null;
|
||||
|
||||
List<String> possible = namePlaceholders.getConfig().getStringList(path);
|
||||
return possible.get(random.nextInt(possible.size()));
|
||||
}
|
||||
|
||||
public String getLuteAttackEffectName(LuteAttackEffect effect) {
|
||||
return attackEffects.getConfig().getString("lute-attack." + effect.name().toLowerCase().replace("_", "-"));
|
||||
}
|
||||
@ -270,6 +247,19 @@ public class ConfigManager {
|
||||
return attackEffects.getConfig().getString("staff-spirit." + spirit.name().toLowerCase().replace("_", "-"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an empty directory in the MMOItems plugin folder if it does not
|
||||
* exist
|
||||
*
|
||||
* @param path
|
||||
* The path of your folder
|
||||
*/
|
||||
private void mkdir(String path) {
|
||||
File folder = new File(MMOItems.plugin.getDataFolder() + "/" + path);
|
||||
if (!folder.exists())
|
||||
folder.mkdir();
|
||||
}
|
||||
|
||||
/*
|
||||
* all config files that have a default configuration are stored here, they
|
||||
* get copied into the plugin folder when the plugin enables
|
||||
@ -279,24 +269,15 @@ public class ConfigManager {
|
||||
// default general config files -> /MMOItems
|
||||
ITEM_TIERS("item-tiers.yml", "", "item-tiers.yml"),
|
||||
ITEM_TYPES("item-types.yml", "", "item-types.yml", true),
|
||||
GEN_TEMPLATES("gen-templates.yml", "", "gen-templates.yml"),
|
||||
DROPS("drops.yml", "", "drops.yml"),
|
||||
ITEM_SETS("item-sets.yml", "", "item-sets.yml"),
|
||||
NAME_PLACEHOLDERS("name-placeholders.yml", "", "name-placeholders.yml"),
|
||||
UPGRADE_TEMPLATES("upgrade-templates.yml", "", "upgrade-templates.yml"),
|
||||
|
||||
// LEGACY_CONFIGS("legacy-configs.zip", "", "legacy-configs.zip", true),
|
||||
// Not included in the jar anymore
|
||||
EXAMPLE_MODIFIERS("modifiers/example-modifiers.yml", "modifiers", "example-modifiers.yml"),
|
||||
|
||||
// default language files -> /MMOItems/language
|
||||
LORE_FORMAT("lore-format.yml", "language", "lore-format.yml"),
|
||||
STATS("stats.yml", "language", "stats.yml"),
|
||||
|
||||
// item generator
|
||||
EXAMPLE_GEN_TEMPLATES("generator/templates/example-templates.yml", "generator/templates", "example-templates.yml"),
|
||||
EXAMPLE_GEN_MODIFIERS("generator/modifiers/example-modifiers.yml", "generator/modifiers", "example-modifiers.yml"),
|
||||
ITEM_GEN_CONFIG("generator/config.yml", "generator", "config.yml"),
|
||||
|
||||
// default item config files -> /MMOItems/item
|
||||
ARMOR("item/armor.yml", "item", "armor.yml"),
|
||||
AXE("item/axe.yml", "item", "axe.yml"),
|
||||
|
@ -10,6 +10,7 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@ -29,100 +30,106 @@ public class PluginUpdateManager {
|
||||
private final Map<Integer, PluginUpdate> updates = new HashMap<>();
|
||||
|
||||
public PluginUpdateManager() {
|
||||
register(new PluginUpdate(1, new String[] { "Applies a fix for skull textures values in 4.7.1.", "Texture values data storage changed in 4.7.1 due to the UUID change." }, sender -> {
|
||||
register(new PluginUpdate(1, new String[] { "Applies a fix for skull textures values in 4.7.1.",
|
||||
"Texture values data storage changed in 4.7.1 due to the UUID change." }, sender -> {
|
||||
|
||||
for (Type type : MMOItems.plugin.getTypes().getAll()) {
|
||||
ConfigFile config = type.getConfigFile();
|
||||
for (String key : config.getConfig().getKeys(false)) {
|
||||
ConfigurationSection section = config.getConfig().getConfigurationSection(key);
|
||||
if (section.contains("skull-texture") && section.get("skull-texture") instanceof String) {
|
||||
section.set("skull-texture.value", section.getString("skull-texture"));
|
||||
section.set("skull-texture.uuid", UUID.randomUUID().toString());
|
||||
}
|
||||
}
|
||||
|
||||
config.save();
|
||||
}
|
||||
}));
|
||||
|
||||
register(new PluginUpdate(3, new String[] { "5.3.2: converts all your crafting station recipes to the newest config format.", "&cWarning, running this update will get rid of your # config file comments." }, sender -> {
|
||||
|
||||
for (File file : new File(MMOItems.plugin.getDataFolder() + "/crafting-stations").listFiles()) {
|
||||
FileConfiguration config = YamlConfiguration.loadConfiguration(file);
|
||||
|
||||
if (config.contains("recipes")) {
|
||||
for (String key : config.getConfigurationSection("recipes").getKeys(false))
|
||||
try {
|
||||
|
||||
List<String> ingredients = config.getStringList("recipes." + key + ".ingredients");
|
||||
List<String> newest = new ArrayList<String>();
|
||||
|
||||
for (String ingredient : ingredients) {
|
||||
String[] split = ingredient.split("\\ ");
|
||||
if (split[0].equals("mmoitem")) {
|
||||
String format = "mmoitem{type=" + split[1] + ",id=" + split[2];
|
||||
if (split.length > 3)
|
||||
format += ",amount=" + split[3];
|
||||
if (split.length > 4)
|
||||
format += ",display=\"" + split[4].replace("_", " ") + "\"";
|
||||
newest.add(format + "}");
|
||||
}
|
||||
|
||||
else if (split[0].equals("vanilla")) {
|
||||
String format = "vanilla{type=" + split[1];
|
||||
if (split.length > 2 && !split[2].equals("."))
|
||||
format += ",name=\"" + split[2] + "\"";
|
||||
if (split.length > 3)
|
||||
format += ",amount=" + split[3];
|
||||
if (split.length > 4)
|
||||
format += ",display=\"" + split[4].replace("_", " ") + "\"";
|
||||
newest.add(format + "}");
|
||||
}
|
||||
|
||||
else {
|
||||
MMOItems.plugin.getLogger().log(Level.INFO, "Config Update 3: Could not match ingredient from '" + ingredient + "' from recipe '" + key + "', added it anyway.");
|
||||
newest.add(ingredient);
|
||||
}
|
||||
for (Type type : MMOItems.plugin.getTypes().getAll()) {
|
||||
ConfigFile config = type.getConfigFile();
|
||||
for (String key : config.getConfig().getKeys(false)) {
|
||||
ConfigurationSection section = config.getConfig().getConfigurationSection(key);
|
||||
if (section.contains("skull-texture") && section.get("skull-texture") instanceof String) {
|
||||
section.set("skull-texture.value", section.getString("skull-texture"));
|
||||
section.set("skull-texture.uuid", UUID.randomUUID().toString());
|
||||
}
|
||||
|
||||
config.set("recipes." + key + ".ingredients", newest);
|
||||
|
||||
List<String> conditions = config.getStringList("recipes." + key + ".conditions");
|
||||
newest = new ArrayList<>();
|
||||
|
||||
for (String condition : conditions) {
|
||||
String[] split = condition.split("\\ ");
|
||||
if (split[0].equalsIgnoreCase("class"))
|
||||
newest.add("class{list=\"" + condition.replace(split[0] + " ", "").replace(" ", ",") + "\"}");
|
||||
else if (split[0].equalsIgnoreCase("perms"))
|
||||
newest.add("permission{list=\"" + condition.replace(split[0] + " ", "").replace(" ", ",") + "\"}");
|
||||
else if (split[0].equalsIgnoreCase("food") || split[0].equals("mana") || split[0].equals("stamina"))
|
||||
newest.add(split[0] + "{amount=" + split[1] + "}");
|
||||
else if (split[0].equalsIgnoreCase("level"))
|
||||
newest.add("level{level=" + split[1] + "}");
|
||||
else if (split[0].equalsIgnoreCase("profession"))
|
||||
newest.add("profession{profession=" + split[1] + ",level=" + split[2] + "}");
|
||||
else if (split[0].equalsIgnoreCase("exp"))
|
||||
newest.add("exp{profession=" + split[1] + ",amount=" + split[2] + "}");
|
||||
else {
|
||||
MMOItems.plugin.getLogger().log(Level.INFO, "Config Update 3: Could not match condition from '" + condition + "' from recipe '" + key + "', added it anyway.");
|
||||
newest.add(condition);
|
||||
}
|
||||
}
|
||||
|
||||
config.set("recipes." + key + ".conditions", newest);
|
||||
} catch (Exception exception) {
|
||||
MMOItems.plugin.getLogger().log(Level.INFO, "Config Update 3: Could not convert recipe with key '" + key + "': " + exception.getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
config.save(file);
|
||||
} catch (IOException exception) {
|
||||
MMOItems.plugin.getLogger().log(Level.INFO, "Config Update 3: Could not save config '" + file.getName() + "': " + exception.getMessage());
|
||||
config.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}));
|
||||
}));
|
||||
|
||||
register(new PluginUpdate(3, new String[] { "5.3.2: converts all your crafting station recipes to the newest config format.",
|
||||
"&cWarning, running this update will get rid of your # config file comments." }, sender -> {
|
||||
|
||||
for (File file : new File(MMOItems.plugin.getDataFolder() + "/crafting-stations").listFiles()) {
|
||||
FileConfiguration config = YamlConfiguration.loadConfiguration(file);
|
||||
|
||||
if (config.contains("recipes")) {
|
||||
for (String key : config.getConfigurationSection("recipes").getKeys(false))
|
||||
try {
|
||||
|
||||
List<String> ingredients = config.getStringList("recipes." + key + ".ingredients");
|
||||
List<String> newest = new ArrayList<String>();
|
||||
|
||||
for (String ingredient : ingredients) {
|
||||
String[] split = ingredient.split("\\ ");
|
||||
if (split[0].equals("mmoitem")) {
|
||||
String format = "mmoitem{type=" + split[1] + ",id=" + split[2];
|
||||
if (split.length > 3)
|
||||
format += ",amount=" + split[3];
|
||||
if (split.length > 4)
|
||||
format += ",display=\"" + split[4].replace("_", " ") + "\"";
|
||||
newest.add(format + "}");
|
||||
}
|
||||
|
||||
else if (split[0].equals("vanilla")) {
|
||||
String format = "vanilla{type=" + split[1];
|
||||
if (split.length > 2 && !split[2].equals("."))
|
||||
format += ",name=\"" + split[2] + "\"";
|
||||
if (split.length > 3)
|
||||
format += ",amount=" + split[3];
|
||||
if (split.length > 4)
|
||||
format += ",display=\"" + split[4].replace("_", " ") + "\"";
|
||||
newest.add(format + "}");
|
||||
}
|
||||
|
||||
else {
|
||||
MMOItems.plugin.getLogger().log(Level.INFO, "Config Update 3: Could not match ingredient from '"
|
||||
+ ingredient + "' from recipe '" + key + "', added it anyway.");
|
||||
newest.add(ingredient);
|
||||
}
|
||||
}
|
||||
|
||||
config.set("recipes." + key + ".ingredients", newest);
|
||||
|
||||
List<String> conditions = config.getStringList("recipes." + key + ".conditions");
|
||||
newest = new ArrayList<>();
|
||||
|
||||
for (String condition : conditions) {
|
||||
String[] split = condition.split("\\ ");
|
||||
if (split[0].equalsIgnoreCase("class"))
|
||||
newest.add("class{list=\"" + condition.replace(split[0] + " ", "").replace(" ", ",") + "\"}");
|
||||
else if (split[0].equalsIgnoreCase("perms"))
|
||||
newest.add("permission{list=\"" + condition.replace(split[0] + " ", "").replace(" ", ",") + "\"}");
|
||||
else if (split[0].equalsIgnoreCase("food") || split[0].equals("mana") || split[0].equals("stamina"))
|
||||
newest.add(split[0] + "{amount=" + split[1] + "}");
|
||||
else if (split[0].equalsIgnoreCase("level"))
|
||||
newest.add("level{level=" + split[1] + "}");
|
||||
else if (split[0].equalsIgnoreCase("profession"))
|
||||
newest.add("profession{profession=" + split[1] + ",level=" + split[2] + "}");
|
||||
else if (split[0].equalsIgnoreCase("exp"))
|
||||
newest.add("exp{profession=" + split[1] + ",amount=" + split[2] + "}");
|
||||
else {
|
||||
MMOItems.plugin.getLogger().log(Level.INFO, "Config Update 3: Could not match condition from '"
|
||||
+ condition + "' from recipe '" + key + "', added it anyway.");
|
||||
newest.add(condition);
|
||||
}
|
||||
}
|
||||
|
||||
config.set("recipes." + key + ".conditions", newest);
|
||||
} catch (Exception exception) {
|
||||
MMOItems.plugin.getLogger().log(Level.INFO,
|
||||
"Config Update 3: Could not convert recipe with key '" + key + "': " + exception.getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
config.save(file);
|
||||
} catch (IOException exception) {
|
||||
MMOItems.plugin.getLogger().log(Level.INFO,
|
||||
"Config Update 3: Could not save config '" + file.getName() + "': " + exception.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
register(new PluginUpdate(2,
|
||||
new String[] { "Enables the item updater for every item.", "&cNot recommended unless you know what you are doing." }, sender -> {
|
||||
@ -130,6 +137,60 @@ public class PluginUpdateManager {
|
||||
for (String id : type.getConfigFile().getConfig().getKeys(false))
|
||||
MMOItems.plugin.getUpdater().enable(new UpdaterData(type, id, UUID.randomUUID(), true));
|
||||
}));
|
||||
|
||||
register(new PluginUpdate(4,
|
||||
new String[] { "Transforms all your current MMOItems into item templates and fixes some stat formats which have been changed.",
|
||||
"&cIt is REALLY important to save a backup before using this config update!" },
|
||||
sender -> {
|
||||
|
||||
// translates items into templates
|
||||
for (Type type : MMOItems.plugin.getTypes().getAll()) {
|
||||
ConfigFile config = type.getConfigFile();
|
||||
idLoop: for (String id : config.getConfig().getKeys(false)) {
|
||||
if (config.getConfig().getConfigurationSection(id).contains("base"))
|
||||
continue idLoop;
|
||||
|
||||
config.getConfig().createSection(id + ".base", config.getConfig().getConfigurationSection(id).getValues(false));
|
||||
for (String statKey : config.getConfig().getConfigurationSection(id).getKeys(false))
|
||||
if (!statKey.equals("base"))
|
||||
config.getConfig().set(id + "." + statKey, null);
|
||||
}
|
||||
|
||||
config.save();
|
||||
}
|
||||
|
||||
// fixes stat formats
|
||||
for (Type type : MMOItems.plugin.getTypes().getAll()) {
|
||||
ConfigFile config = type.getConfigFile();
|
||||
for (String id : config.getConfig().getKeys(false)) {
|
||||
|
||||
for (String statKey : config.getConfig().getConfigurationSection(id + ".base").getKeys(false)) {
|
||||
|
||||
String str = config.getConfig().getString(id + ".base." + statKey);
|
||||
if (str != null)
|
||||
try {
|
||||
|
||||
String[] split = str.split("\\=");
|
||||
Validate.isTrue(split.length == 2);
|
||||
double val1 = Double.parseDouble(split[0]);
|
||||
double val2 = Double.parseDouble(split[1]);
|
||||
|
||||
double avg = (val1 + val2) / 2;
|
||||
double max = Math.max(Math.abs(val1), Math.abs(val2));
|
||||
double rel = (max - avg) / max;
|
||||
|
||||
config.getConfig().set(id + ".base." + statKey + ".base", avg);
|
||||
config.getConfig().set(id + ".base." + statKey + ".spread", rel / 3);
|
||||
config.getConfig().set(id + ".base." + statKey + ".max-spread", rel);
|
||||
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
config.save();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
public void register(PluginUpdate update) {
|
||||
|
@ -161,10 +161,12 @@ public class TemplateManager {
|
||||
* (input)
|
||||
*/
|
||||
public int rollLevel(int playerLevel) {
|
||||
double found = random.nextGaussian() * MMOItems.plugin.getLanguage().levelSpread + playerLevel;
|
||||
double spread = MMOItems.plugin.getLanguage().levelSpread;
|
||||
double found = random.nextGaussian() * spread * .7 + playerLevel;
|
||||
|
||||
// cannot be more than 2x the level and must be higher than 1
|
||||
found = Math.max(Math.min(2 * playerLevel, found), 1);
|
||||
// must be in [level - spread, level + spread]
|
||||
// lower bound must be higher than 1
|
||||
found = Math.max(Math.min(found, playerLevel + spread), Math.max(1, playerLevel - spread));
|
||||
|
||||
return (int) found;
|
||||
}
|
||||
@ -174,7 +176,7 @@ public class TemplateManager {
|
||||
modifiers.clear();
|
||||
|
||||
MMOItems.plugin.getLogger().log(Level.INFO, "Loading template modifiers, please wait..");
|
||||
for (File file : new File(MMOItems.plugin.getDataFolder() + "/generator/modifiers").listFiles()) {
|
||||
for (File file : new File(MMOItems.plugin.getDataFolder() + "/modifiers").listFiles()) {
|
||||
FileConfiguration config = YamlConfiguration.loadConfiguration(file);
|
||||
for (String key : config.getKeys(false))
|
||||
try {
|
||||
|
@ -1,9 +1,7 @@
|
||||
package net.Indyuce.mmoitems.stat;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
|
||||
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
|
||||
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
|
||||
@ -16,12 +14,13 @@ import net.mmogroup.mmolib.version.VersionMaterial;
|
||||
|
||||
public class DisplayName extends StringStat {
|
||||
public DisplayName() {
|
||||
super("NAME", new ItemStack(VersionMaterial.OAK_SIGN.toMaterial()), "Display Name", new String[] { "The item display name." }, new String[] { "all" });
|
||||
super("NAME", new ItemStack(VersionMaterial.OAK_SIGN.toMaterial()), "Display Name", new String[] { "The item display name." },
|
||||
new String[] { "all" });
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenApplied(ItemStackBuilder item, StatData data) {
|
||||
item.getMeta().setDisplayName(fix(MMOLib.plugin.parseColors(getDisplayName(data.toString()))));
|
||||
item.getMeta().setDisplayName(MMOLib.plugin.parseColors(data.toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -31,33 +30,35 @@ public class DisplayName extends StringStat {
|
||||
}
|
||||
|
||||
/*
|
||||
* when loading display names, Spigot does not register white color codes
|
||||
* when they are placed first in the item name. if the name starts with the
|
||||
* When loading display names, Spigot does not register white color codes
|
||||
* when they are placed first in the item name. If the name starts with the
|
||||
* white color code, just add an extra color code which won't be seen on the
|
||||
* item
|
||||
*/
|
||||
@Deprecated
|
||||
private String fix(String str) {
|
||||
return str.startsWith(ChatColor.WHITE + "") ? "" + ChatColor.GREEN + ChatColor.WHITE + str : str;
|
||||
}
|
||||
// @Deprecated
|
||||
// private String fix(String str) {
|
||||
// return str.startsWith(ChatColor.WHITE + "") ? "" + ChatColor.GREEN +
|
||||
// ChatColor.WHITE + str : str;
|
||||
// }
|
||||
|
||||
public String getDisplayName(String display) {
|
||||
|
||||
// name placeholders
|
||||
String[] split = display.split("\\<");
|
||||
if (split.length > 1)
|
||||
// starting at 0 is pointless
|
||||
for (int j = 1; j < split.length; j++) {
|
||||
String jstr = split[j];
|
||||
if (!jstr.contains(">"))
|
||||
continue;
|
||||
|
||||
String ref = jstr.split("\\>")[0];
|
||||
String placeholder = MMOItems.plugin.getLanguage().getNamePlaceholder(ref);
|
||||
if (placeholder != null)
|
||||
display = display.replace("<" + ref + ">", placeholder);
|
||||
}
|
||||
|
||||
return display;
|
||||
}
|
||||
// public String getDisplayName(String display) {
|
||||
//
|
||||
// // name placeholders
|
||||
// String[] split = display.split("\\<");
|
||||
// if (split.length > 1)
|
||||
// // starting at 0 is pointless
|
||||
// for (int j = 1; j < split.length; j++) {
|
||||
// String jstr = split[j];
|
||||
// if (!jstr.contains(">"))
|
||||
// continue;
|
||||
//
|
||||
// String ref = jstr.split("\\>")[0];
|
||||
// String placeholder =
|
||||
// MMOItems.plugin.getLanguage().getNamePlaceholder(ref);
|
||||
// if (placeholder != null)
|
||||
// display = display.replace("<" + ref + ">", placeholder);
|
||||
// }
|
||||
//
|
||||
// return display;
|
||||
// }
|
||||
}
|
||||
|
@ -1,8 +1,3 @@
|
||||
# --------------------------------------------------------------
|
||||
#
|
||||
# Thanks for using MMOItems!
|
||||
#
|
||||
# --------------------------------------------------------------
|
||||
|
||||
# Notifies players with the 'mmoitems.update-notify' perm node when
|
||||
# they join the server if a new update is available for download.
|
||||
@ -28,20 +23,16 @@ disable-abilities-in-offhand: false
|
||||
# 10 ticks which corresponds to 2 inventory updates a second.
|
||||
inventory-update-delay: 10
|
||||
|
||||
# When generating an item, the item gen must
|
||||
# choose an item level which coincides with
|
||||
# the player's level (otherwise unplayable).
|
||||
# When generating an item, the item level
|
||||
# must match approximately the player level
|
||||
# otherwise the player cannot use items/get useless items.
|
||||
#
|
||||
# The item level is modeled by a gaussian
|
||||
# random variable which mean is the player level.
|
||||
# You can edit the standard deviation here.
|
||||
#
|
||||
# Leave it like this if don't you know
|
||||
# what it does, default value is fine.
|
||||
# The item level is always somewhere in the
|
||||
# interval [playerLevel - spread, playerLevel + spread]
|
||||
item-level-spread: 2
|
||||
|
||||
# When an item is generated with no tier,
|
||||
# this is the capacity it should have.
|
||||
# this is the capacity formula it will use.
|
||||
default-item-capacity:
|
||||
base: 3
|
||||
scale: 0
|
||||
|
@ -14,14 +14,11 @@ COMPOSITE_BOW:
|
||||
modifiers:
|
||||
swiftness:
|
||||
weight: 3
|
||||
parent: swiftness
|
||||
heavy:
|
||||
chance: 0.05
|
||||
weight: 3
|
||||
parent: heavy
|
||||
doom:
|
||||
impending-doom:
|
||||
weight: 5
|
||||
parent: impending-doom
|
||||
HELL_BOW:
|
||||
base:
|
||||
material: BOW
|
||||
|
@ -17,10 +17,8 @@ LONG_SWORD:
|
||||
modifiers:
|
||||
sharp:
|
||||
chance: 0.5
|
||||
parent: sharp
|
||||
fiery:
|
||||
chance: 0.5
|
||||
parent: fiery
|
||||
CUTLASS:
|
||||
base:
|
||||
material: IRON_SWORD
|
||||
|
@ -1,70 +0,0 @@
|
||||
# Name placeholders can be used in the item display name
|
||||
# A placeholder will return a random element of each list.
|
||||
# To use a placeholder, simply add <placeholder> inside the name of your item.
|
||||
#
|
||||
# e.g:
|
||||
# TEST_ITEM:
|
||||
# material: IRON_SWORD
|
||||
# display-name: '<lms-sword> Iron Sword'
|
||||
#
|
||||
# You can put multiple of the same placeholder in each
|
||||
# list to give some placeholder less chance to be chosen.
|
||||
# These placeholders will be harder to obtain.
|
||||
|
||||
lms:
|
||||
- 'Large'
|
||||
- 'Medium'
|
||||
- 'Small'
|
||||
lms-sword:
|
||||
- 'Long'
|
||||
- 'Normal'
|
||||
- 'Normal'
|
||||
- 'Normal'
|
||||
- 'Short'
|
||||
- 'Short'
|
||||
- 'Short'
|
||||
cs:
|
||||
- 'Factory New'
|
||||
- 'Minimal Wear'
|
||||
- 'Field Tested'
|
||||
- 'Well Worn'
|
||||
- 'Battle Scarred'
|
||||
mythical:
|
||||
- 'Epic'
|
||||
- 'Mythical'
|
||||
- 'Mystic'
|
||||
- 'Legendary'
|
||||
- 'Unreal'
|
||||
- 'Godly'
|
||||
greekGod:
|
||||
- 'Poseidon'
|
||||
- 'Zeus'
|
||||
- 'Hephaistos'
|
||||
- 'Hares'
|
||||
- 'Athena'
|
||||
- 'Hermes'
|
||||
wood:
|
||||
- 'Oak'
|
||||
- 'Birch'
|
||||
- 'Jungle'
|
||||
- 'Spruce'
|
||||
- 'Dark Oak'
|
||||
- 'Acacia'
|
||||
gem-stone:
|
||||
- 'Lapis'
|
||||
- 'Topaz'
|
||||
- 'Ruby'
|
||||
- 'Emerald'
|
||||
- 'Diamond'
|
||||
- 'Amethyst'
|
||||
- 'Sapphire'
|
||||
- 'Amber'
|
||||
ore:
|
||||
- 'Gold'
|
||||
- 'Iron'
|
||||
- 'Silver'
|
||||
- 'Platinum'
|
||||
- 'Palladium'
|
||||
- 'Adamantite'
|
||||
- 'Orichalcum'
|
||||
- 'Cobalt'
|
Loading…
Reference in New Issue
Block a user