mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2025-03-01 15:51:03 +01:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
0e2696dbcd
@ -55,7 +55,7 @@ import java.util.logging.Level;
|
||||
|
||||
public class MMOItems extends JavaPlugin {
|
||||
public static MMOItems plugin;
|
||||
|
||||
|
||||
private final PluginUpdateManager pluginUpdateManager = new PluginUpdateManager();
|
||||
private final CraftingManager stationRecipeManager = new CraftingManager();
|
||||
private final AbilityManager abilityManager = new AbilityManager();
|
||||
@ -102,17 +102,17 @@ public class MMOItems extends JavaPlugin {
|
||||
getLogger().log(Level.WARNING, "Could not initialize support with WorldEdit 7: " + exception.getMessage());
|
||||
}
|
||||
|
||||
/*
|
||||
* stat manager must be initialized before MMOCore compatibility
|
||||
* initializes so that MMOCore can register its stats
|
||||
*/
|
||||
|
||||
saveDefaultConfig();
|
||||
|
||||
/*
|
||||
* Stat manager must be initialized before MMOCore compatibility
|
||||
* initializes so that MMOCore can register its stats. Types and item
|
||||
* templates are also loaded as soon as MI is loaded so that other
|
||||
* plugins can load template references
|
||||
*/
|
||||
statManager = new StatManager();
|
||||
|
||||
typeManager.reload();
|
||||
|
||||
templateManager.loadCompatibility(); // explained why in method
|
||||
templateManager.preloadTemplates();
|
||||
|
||||
if (Bukkit.getPluginManager().getPlugin("MMOCore") != null)
|
||||
new MMOCoreMMOLoader();
|
||||
@ -138,14 +138,13 @@ public class MMOItems extends JavaPlugin {
|
||||
getLogger().log(Level.INFO, "Hooked onto MMOInventory");
|
||||
}
|
||||
|
||||
|
||||
findRpgPlugin();
|
||||
|
||||
templateManager.reload();
|
||||
|
||||
tierManager = new TierManager();
|
||||
setManager = new SetManager();
|
||||
upgradeManager = new UpgradeManager();
|
||||
templateManager.reload(); // should be postload() but it's broken waiting for indy to fix
|
||||
|
||||
dropTableManager = new DropTableManager();
|
||||
dynamicUpdater = new UpdaterManager();
|
||||
worldGenManager = new WorldGenManager();
|
||||
|
@ -1,5 +1,13 @@
|
||||
package net.Indyuce.mmoitems.ability;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.ability.Ability;
|
||||
import net.Indyuce.mmoitems.api.ability.AbilityResult;
|
||||
import net.Indyuce.mmoitems.api.ability.SimpleAbilityResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Particle;
|
||||
@ -12,15 +20,6 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityTargetEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.ability.Ability;
|
||||
import net.Indyuce.mmoitems.api.ability.AbilityResult;
|
||||
import net.Indyuce.mmoitems.api.ability.SimpleAbilityResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
|
||||
public class Shadow_Veil extends Ability implements Listener {
|
||||
public Shadow_Veil() {
|
||||
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK,
|
||||
@ -118,8 +117,7 @@ public class Shadow_Veil extends Ability implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void cancelMobTarget(EntityTargetEvent event) {
|
||||
// FIXME NPE for some reason, not sure if getTarget or player is null. Doubt its getTarget but you never know. https://git.lumine.io/mythiccraft/mmoitems/-/issues/126
|
||||
if (event.getTarget().equals(player))
|
||||
if (player.equals(event.getTarget()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,15 @@
|
||||
package net.Indyuce.mmoitems.api;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.mmogroup.mmolib.api.item.NBTItem;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Particle.DustOptions;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.mmogroup.mmolib.api.item.NBTItem;
|
||||
|
||||
public class ArrowParticles extends BukkitRunnable {
|
||||
private final Arrow arrow;
|
||||
|
||||
@ -42,11 +40,9 @@ public class ArrowParticles extends BukkitRunnable {
|
||||
return;
|
||||
}
|
||||
|
||||
if (color != null)
|
||||
if (particle.getDataType() == DustOptions.class)
|
||||
arrow.getWorld().spawnParticle(particle, arrow.getLocation().add(0, .25, 0), amount, offset, offset, offset, new Particle.DustOptions(color, 1));
|
||||
else
|
||||
arrow.getWorld().spawnParticle(particle, arrow.getLocation().add(0, .25, 0), amount, offset, offset, offset, color);
|
||||
if (color != null && particle.getDataType() == DustOptions.class)
|
||||
arrow.getWorld().spawnParticle(particle, arrow.getLocation().add(0, .25, 0), amount, offset, offset, offset,
|
||||
new Particle.DustOptions(color, 1));
|
||||
else
|
||||
arrow.getWorld().spawnParticle(particle, arrow.getLocation().add(0, .25, 0), amount, offset, offset, offset, speed);
|
||||
}
|
||||
|
@ -1,18 +1,17 @@
|
||||
package net.Indyuce.mmoitems.api;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.Indyuce.mmoitems.api.droptable.DropTable;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||
import net.Indyuce.mmoitems.api.util.NumericStatFormula;
|
||||
import net.Indyuce.mmoitems.comp.itemglow.TierColor;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class ItemTier {
|
||||
private final String name, id;
|
||||
@ -36,7 +35,7 @@ public class ItemTier {
|
||||
|
||||
public ItemTier(ConfigurationSection config) {
|
||||
id = config.getName().toUpperCase().replace("-", "_");
|
||||
name = config.getString("name");
|
||||
name = MMOLib.plugin.parseColors(config.getString("name"));
|
||||
deconstruct = config.contains("deconstruct-item") ? new DropTable(config.getConfigurationSection("deconstruct-item")) : null;
|
||||
unidentificationInfo = new UnidentificationInfo(config.getConfigurationSection("unidentification"));
|
||||
|
||||
|
@ -7,8 +7,8 @@ import net.Indyuce.mmoitems.api.crafting.recipe.Recipe.RecipeOption;
|
||||
import net.Indyuce.mmoitems.api.crafting.recipe.RecipeInfo;
|
||||
import net.Indyuce.mmoitems.api.crafting.recipe.UpgradingRecipe;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||
import net.Indyuce.mmoitems.api.util.PostLoadObject;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.util.PostLoadObject;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
@ -1,28 +1,28 @@
|
||||
package net.Indyuce.mmoitems.api.event;
|
||||
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||
|
||||
public class CraftMMOItemEvent extends PlayerDataEvent {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private ItemStack stack;
|
||||
|
||||
public CraftMMOItemEvent(PlayerData playerData, ItemStack stack) {
|
||||
private ItemStack result;
|
||||
|
||||
public CraftMMOItemEvent(PlayerData playerData, ItemStack result) {
|
||||
super(playerData);
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
public ItemStack getResult() {
|
||||
return stack;
|
||||
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public void setStack(ItemStack stack) {
|
||||
this.stack = stack;
|
||||
public ItemStack getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public void setResult(ItemStack result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
@ -1,11 +1,16 @@
|
||||
package net.Indyuce.mmoitems.api.item.build;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
|
||||
import net.Indyuce.mmoitems.api.util.StatFormat;
|
||||
import net.Indyuce.mmoitems.stat.data.*;
|
||||
import net.Indyuce.mmoitems.stat.data.type.UpgradeInfo;
|
||||
import net.Indyuce.mmoitems.stat.type.DoubleStat;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.item.ItemTag;
|
||||
import net.mmogroup.mmolib.api.item.NBTItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.attribute.AttributeModifier;
|
||||
@ -14,22 +19,11 @@ import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
|
||||
import net.Indyuce.mmoitems.api.util.StatFormat;
|
||||
import net.Indyuce.mmoitems.stat.data.DoubleData;
|
||||
import net.Indyuce.mmoitems.stat.data.MaterialData;
|
||||
import net.Indyuce.mmoitems.stat.data.StoredTagsData;
|
||||
import net.Indyuce.mmoitems.stat.data.StringData;
|
||||
import net.Indyuce.mmoitems.stat.data.StringListData;
|
||||
import net.Indyuce.mmoitems.stat.data.UpgradeData;
|
||||
import net.Indyuce.mmoitems.stat.data.type.UpgradeInfo;
|
||||
import net.Indyuce.mmoitems.stat.type.DoubleStat;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.item.ItemTag;
|
||||
import net.mmogroup.mmolib.api.item.NBTItem;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class ItemStackBuilder {
|
||||
private MMOItem mmoitem;
|
||||
@ -124,7 +118,7 @@ public class ItemStackBuilder {
|
||||
lore.insert("lore", parsed);
|
||||
}
|
||||
|
||||
meta.setLore(lore.build().toStringList());
|
||||
meta.setLore(lore.build());
|
||||
|
||||
/*
|
||||
* This tag is added to entirely override default vanilla item attribute
|
||||
|
@ -1,15 +1,14 @@
|
||||
package net.Indyuce.mmoitems.api.item.build;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
|
||||
public class LoreBuilder {
|
||||
private final List<String> lore = MMOItems.plugin.getLanguage().getDefaultLoreFormat();
|
||||
private final Map<String, String> placeholders = new HashMap<>();
|
||||
@ -91,7 +90,7 @@ public class LoreBuilder {
|
||||
* have been inserted in the lore. It cleans all unused lore format
|
||||
* # lines as well as lore bars
|
||||
*/
|
||||
public LoreBuilder build() {
|
||||
public List<String> build() {
|
||||
|
||||
/*
|
||||
* loops backwards to remove all unused bars in one iteration only,
|
||||
@ -114,29 +113,21 @@ public class LoreBuilder {
|
||||
}
|
||||
|
||||
/*
|
||||
* clear bar codes and parse chat colors only ONCE
|
||||
* the bars have been successfully calculated
|
||||
* clear bar codes and parse chat colors only ONCE the bars have been
|
||||
* successfully calculated
|
||||
*
|
||||
* NEW: also finalize the lore by breaking
|
||||
* lines with the \n escape character
|
||||
* NEW: also finalize the lore by breaking lines with the \n escape
|
||||
* character
|
||||
*/
|
||||
final List<String> finalLore = new ArrayList<>();
|
||||
for (int i = 0; i < lore.size(); i++) {
|
||||
for(final String s : MMOLib.plugin.parseColors(lore.get(i)
|
||||
.replace("{bar}", "").replace("{sbar}", "")).split("\\\\n"))
|
||||
finalLore.add(s);
|
||||
}
|
||||
|
||||
lore.clear();
|
||||
lore.addAll(finalLore);
|
||||
return this;
|
||||
final List<String> cleaned = new ArrayList<>();
|
||||
for (int i = 0; i < lore.size(); i++)
|
||||
for (final String s : MMOLib.plugin.parseColors(lore.get(i).replace("{bar}", "").replace("{sbar}", "")).split("\\\\n"))
|
||||
cleaned.add(s);
|
||||
|
||||
return cleaned;
|
||||
}
|
||||
|
||||
private boolean isBar(String str) {
|
||||
return str.startsWith("{bar}") || str.startsWith("{sbar}");
|
||||
}
|
||||
|
||||
public List<String> toStringList() {
|
||||
return lore;
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,5 @@
|
||||
package net.Indyuce.mmoitems.api.item.template;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.ItemTier;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
@ -20,8 +8,15 @@ import net.Indyuce.mmoitems.api.item.build.MMOItemBuilder;
|
||||
import net.Indyuce.mmoitems.api.player.RPGPlayer;
|
||||
import net.Indyuce.mmoitems.stat.data.random.RandomStatData;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
import net.mmogroup.mmolib.api.util.PostLoadObject;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
public class MMOItemTemplate implements ItemReference {
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class MMOItemTemplate extends PostLoadObject implements ItemReference {
|
||||
private final Type type;
|
||||
private final String id;
|
||||
|
||||
@ -42,6 +37,8 @@ public class MMOItemTemplate implements ItemReference {
|
||||
* different item types share the same ID
|
||||
*/
|
||||
public MMOItemTemplate(Type type, String id) {
|
||||
super(null);
|
||||
|
||||
this.type = type;
|
||||
this.id = id;
|
||||
}
|
||||
@ -55,11 +52,14 @@ public class MMOItemTemplate implements ItemReference {
|
||||
* The config file read to load the template
|
||||
*/
|
||||
public MMOItemTemplate(Type type, ConfigurationSection config) {
|
||||
Validate.notNull(config, "Could not load template config");
|
||||
super(config);
|
||||
|
||||
this.type = type;
|
||||
this.id = config.getName().toUpperCase().replace("-", "_").replace(" ", "_");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void whenPostLoaded(ConfigurationSection config) {
|
||||
if (config.contains("option"))
|
||||
for (TemplateOption option : TemplateOption.values())
|
||||
if (config.getBoolean("option." + option.name().toLowerCase().replace("_", "-")))
|
||||
|
@ -21,7 +21,6 @@ import java.util.List;
|
||||
|
||||
public class ConfigItem {
|
||||
private final String id;
|
||||
private final Material material;
|
||||
private final ItemStack icon;
|
||||
|
||||
// updated when the plugin reloads
|
||||
@ -33,16 +32,27 @@ public class ConfigItem {
|
||||
|
||||
public static final ConfigItem CONFIRM = new ConfigItem("CONFIRM", VersionMaterial.GREEN_STAINED_GLASS_PANE.toMaterial(), "&aConfirm");
|
||||
public static final ConfigItem FILL = new ConfigItem("FILL", VersionMaterial.GRAY_STAINED_GLASS_PANE.toMaterial(), "&8");
|
||||
public static final CustomSkull PREVIOUS_PAGE = new CustomSkull("PREVIOUS_PAGE", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYmQ2OWUwNmU1ZGFkZmQ4NGU1ZjNkMWMyMTA2M2YyNTUzYjJmYTk0NWVlMWQ0ZDcxNTJmZGM1NDI1YmMxMmE5In19fQ==", "&aPrevious Page");
|
||||
public static final CustomSkull NEXT_PAGE = new CustomSkull("NEXT_PAGE", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTliZjMyOTJlMTI2YTEwNWI1NGViYTcxM2FhMWIxNTJkNTQxYTFkODkzODgyOWM1NjM2NGQxNzhlZDIyYmYifX19", "&aNext Page");
|
||||
public static final CustomSkull PREVIOUS_IN_QUEUE = new CustomSkull("PREVIOUS_IN_QUEUE", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYmQ2OWUwNmU1ZGFkZmQ4NGU1ZjNkMWMyMTA2M2YyNTUzYjJmYTk0NWVlMWQ0ZDcxNTJmZGM1NDI1YmMxMmE5In19fQ==", "&aPrevious");
|
||||
public static final CustomSkull NEXT_IN_QUEUE = new CustomSkull("NEXT_IN_QUEUE", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTliZjMyOTJlMTI2YTEwNWI1NGViYTcxM2FhMWIxNTJkNTQxYTFkODkzODgyOWM1NjM2NGQxNzhlZDIyYmYifX19", "&aNext");
|
||||
public static final CustomSkull BACK = new CustomSkull("BACK", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYmQ2OWUwNmU1ZGFkZmQ4NGU1ZjNkMWMyMTA2M2YyNTUzYjJmYTk0NWVlMWQ0ZDcxNTJmZGM1NDI1YmMxMmE5In19fQ==", "&aBack");
|
||||
public static final CustomSkull PREVIOUS_PAGE = new CustomSkull("PREVIOUS_PAGE",
|
||||
"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYmQ2OWUwNmU1ZGFkZmQ4NGU1ZjNkMWMyMTA2M2YyNTUzYjJmYTk0NWVlMWQ0ZDcxNTJmZGM1NDI1YmMxMmE5In19fQ==",
|
||||
"&aPrevious Page");
|
||||
public static final CustomSkull NEXT_PAGE = new CustomSkull("NEXT_PAGE",
|
||||
"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTliZjMyOTJlMTI2YTEwNWI1NGViYTcxM2FhMWIxNTJkNTQxYTFkODkzODgyOWM1NjM2NGQxNzhlZDIyYmYifX19",
|
||||
"&aNext Page");
|
||||
public static final CustomSkull PREVIOUS_IN_QUEUE = new CustomSkull("PREVIOUS_IN_QUEUE",
|
||||
"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYmQ2OWUwNmU1ZGFkZmQ4NGU1ZjNkMWMyMTA2M2YyNTUzYjJmYTk0NWVlMWQ0ZDcxNTJmZGM1NDI1YmMxMmE5In19fQ==",
|
||||
"&aPrevious");
|
||||
public static final CustomSkull NEXT_IN_QUEUE = new CustomSkull("NEXT_IN_QUEUE",
|
||||
"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTliZjMyOTJlMTI2YTEwNWI1NGViYTcxM2FhMWIxNTJkNTQxYTFkODkzODgyOWM1NjM2NGQxNzhlZDIyYmYifX19",
|
||||
"&aNext");
|
||||
public static final CustomSkull BACK = new CustomSkull("BACK",
|
||||
"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYmQ2OWUwNmU1ZGFkZmQ4NGU1ZjNkMWMyMTA2M2YyNTUzYjJmYTk0NWVlMWQ0ZDcxNTJmZGM1NDI1YmMxMmE5In19fQ==",
|
||||
"&aBack");
|
||||
public static final CraftingRecipeDisplay CRAFTING_RECIPE_DISPLAY = new CraftingRecipeDisplay();
|
||||
public static final UpgradingRecipeDisplay UPGRADING_RECIPE_DISPLAY = new UpgradingRecipeDisplay();
|
||||
public static final QueueItemDisplay QUEUE_ITEM_DISPLAY = new QueueItemDisplay();
|
||||
|
||||
public static final ConfigItem[] values = { CONFIRM, FILL, PREVIOUS_PAGE, NEXT_PAGE, PREVIOUS_IN_QUEUE, NEXT_IN_QUEUE, BACK, CRAFTING_RECIPE_DISPLAY, UPGRADING_RECIPE_DISPLAY, QUEUE_ITEM_DISPLAY };
|
||||
public static final ConfigItem[] values = { CONFIRM, FILL, PREVIOUS_PAGE, NEXT_PAGE, PREVIOUS_IN_QUEUE, NEXT_IN_QUEUE, BACK,
|
||||
CRAFTING_RECIPE_DISPLAY, UPGRADING_RECIPE_DISPLAY, QUEUE_ITEM_DISPLAY };
|
||||
|
||||
public ConfigItem(String id, Material material) {
|
||||
this(id, material, null);
|
||||
@ -53,7 +63,6 @@ public class ConfigItem {
|
||||
Validate.notNull(material, "Material cannot be null");
|
||||
|
||||
this.id = id;
|
||||
this.material = material;
|
||||
this.icon = new ItemStack(material);
|
||||
this.name = name;
|
||||
this.lore = Arrays.asList(lore);
|
||||
@ -70,7 +79,6 @@ public class ConfigItem {
|
||||
|
||||
icon = MMOUtils.readIcon(config.getString("material"));
|
||||
|
||||
material = icon.getType();
|
||||
name = config.getString("name", "");
|
||||
lore = config.getStringList("lore");
|
||||
|
||||
@ -96,7 +104,7 @@ public class ConfigItem {
|
||||
|
||||
public void updateItem() {
|
||||
setItem(icon);
|
||||
if (material == Material.AIR)
|
||||
if (icon.getType() == Material.AIR)
|
||||
return;
|
||||
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
@ -113,10 +121,6 @@ public class ConfigItem {
|
||||
item = MMOLib.plugin.getVersion().getWrapper().getNBTItem(item).addTag(new ItemTag("ItemId", id)).toItem();
|
||||
}
|
||||
|
||||
public Material getMaterial() {
|
||||
return material;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
@ -1,31 +0,0 @@
|
||||
package net.Indyuce.mmoitems.api.util;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
public abstract class PostLoadObject {
|
||||
private ConfigurationSection config;
|
||||
|
||||
/**
|
||||
* Objects which must load some data afterwards, like quests which must load
|
||||
* their parent quests after all quests were initialized or classes which
|
||||
* must load their subclasses
|
||||
*
|
||||
* @param config
|
||||
* Configuration section which must be cached during a small
|
||||
* period of time till the rest of the data is loaded
|
||||
*/
|
||||
public PostLoadObject(ConfigurationSection config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
public void postLoad() {
|
||||
whenPostLoaded(config);
|
||||
|
||||
/*
|
||||
* clean config object for garbage collection
|
||||
*/
|
||||
config = null;
|
||||
}
|
||||
|
||||
protected abstract void whenPostLoaded(ConfigurationSection config);
|
||||
}
|
@ -1,15 +1,10 @@
|
||||
package net.Indyuce.mmoitems.api.util;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
import org.apache.commons.lang.Validate;
|
||||
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Allows the use of two nested maps to efficiently store data about mmoitem
|
||||
@ -78,6 +73,17 @@ public class TemplateMap<C> {
|
||||
typeMap.get(type.getId()).idMap.put(id, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies a specific consumer for every template. This is used to postload
|
||||
* all templates when MMOItems enables
|
||||
*
|
||||
* @param action
|
||||
* Action performed for every registered template
|
||||
*/
|
||||
public void forEach(Consumer<C> action) {
|
||||
typeMap.values().forEach(submap -> submap.idMap.values().forEach(action));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collects all the values registered in this template map.
|
||||
*/
|
||||
|
@ -1,13 +1,5 @@
|
||||
package net.Indyuce.mmoitems.comp.parse.placeholders;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||
@ -17,6 +9,13 @@ import net.mmogroup.mmolib.api.item.NBTItem;
|
||||
import net.mmogroup.mmolib.api.player.MMOPlayerData;
|
||||
import net.mmogroup.mmolib.api.util.AltChar;
|
||||
import net.mmogroup.mmolib.listener.DamageReduction;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
public class MMOItemsPlaceholders extends PlaceholderExpansion {
|
||||
private final DecimalFormat oneDigit = new DecimalFormat("0.#"), twoDigits = new DecimalFormat("0.##");
|
||||
@ -51,11 +50,10 @@ public class MMOItemsPlaceholders extends PlaceholderExpansion {
|
||||
@Override
|
||||
public String onRequest(@Nullable OfflinePlayer player, @NotNull String identifier) {
|
||||
// registering before identifier.startsWith("stat_") to prevent issues
|
||||
// i don't register it in the starts with condition because it will mess with
|
||||
// substring
|
||||
// i don't register it in the starts with condition because it will mess
|
||||
// with substring
|
||||
if (identifier.equals("stat_defense_percent"))
|
||||
return twoDigits.format(
|
||||
new DamageReduction.DefenseCalculator(MMOPlayerData.get(player)).getReductionPercent()) + "%";
|
||||
return twoDigits.format(100 - new DamageReduction.DefenseCalculator(MMOPlayerData.get(player)).getAppliedDamage(100)) + "%";
|
||||
if (identifier.startsWith("stat_")) {
|
||||
ItemStat stat = MMOItems.plugin.getStats().get(identifier.substring(5).toUpperCase());
|
||||
if (stat != null)
|
||||
@ -64,8 +62,7 @@ public class MMOItemsPlaceholders extends PlaceholderExpansion {
|
||||
|
||||
if (identifier.startsWith("ability_cd_")) {
|
||||
PlayerData data = PlayerData.get(player);
|
||||
return data.hasCooldownInfo(identifier.substring(11))
|
||||
? oneDigit.format(data.getCooldownInfo(identifier.substring(11)).getRemaining())
|
||||
return data.hasCooldownInfo(identifier.substring(11)) ? oneDigit.format(data.getCooldownInfo(identifier.substring(11)).getRemaining())
|
||||
: "0";
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,8 @@
|
||||
package net.Indyuce.mmoitems.listener;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.item.NBTItem;
|
||||
import org.bukkit.Keyed;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -18,10 +21,6 @@ import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.item.NBTItem;
|
||||
|
||||
public class DisableInteractions implements Listener {
|
||||
|
||||
// anvils
|
||||
@ -32,45 +31,48 @@ public class DisableInteractions implements Listener {
|
||||
return;
|
||||
|
||||
NBTItem item = NBTItem.get(event.getCurrentItem());
|
||||
if (item.hasType() && (MMOItems.plugin.getConfig().getBoolean("disable-interactions.repair") || item.getBoolean("MMOITEMS_DISABLE_REPAIRING")))
|
||||
if (item.hasType()
|
||||
&& (MMOItems.plugin.getConfig().getBoolean("disable-interactions.repair") || item.getBoolean("MMOITEMS_DISABLE_REPAIRING")))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
// grindstone
|
||||
@EventHandler
|
||||
public void b(InventoryClickEvent event) {
|
||||
if (MMOLib.plugin.getVersion().isBelowOrEqual(1, 13))
|
||||
return;
|
||||
// grindstone
|
||||
@EventHandler
|
||||
public void b(InventoryClickEvent event) {
|
||||
if (MMOLib.plugin.getVersion().isBelowOrEqual(1, 13))
|
||||
return;
|
||||
|
||||
Inventory inv = event.getClickedInventory();
|
||||
if (inv == null || inv.getType() != InventoryType.GRINDSTONE || event.getSlot() != 2)
|
||||
return;
|
||||
Inventory inv = event.getClickedInventory();
|
||||
if (inv == null || inv.getType() != InventoryType.GRINDSTONE || event.getSlot() != 2)
|
||||
return;
|
||||
|
||||
NBTItem item = NBTItem.get(event.getCurrentItem());
|
||||
if (item.hasType() && (MMOItems.plugin.getConfig().getBoolean("disable-interactions.repair") || item.getBoolean("MMOITEMS_DISABLE_REPAIRING")))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
NBTItem item = NBTItem.get(event.getCurrentItem());
|
||||
if (item.hasType()
|
||||
&& (MMOItems.plugin.getConfig().getBoolean("disable-interactions.repair") || item.getBoolean("MMOITEMS_DISABLE_REPAIRING")))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
// smithing table
|
||||
@EventHandler
|
||||
public void c(InventoryClickEvent event) {
|
||||
if (MMOLib.plugin.getVersion().isBelowOrEqual(1, 15))
|
||||
return;
|
||||
// smithing table
|
||||
@EventHandler
|
||||
public void c(InventoryClickEvent event) {
|
||||
if (MMOLib.plugin.getVersion().isBelowOrEqual(1, 15))
|
||||
return;
|
||||
|
||||
Inventory inv = event.getClickedInventory();
|
||||
if (inv == null || inv.getType() != InventoryType.SMITHING || event.getSlot() != 2)
|
||||
return;
|
||||
Inventory inv = event.getClickedInventory();
|
||||
if (inv == null || inv.getType() != InventoryType.SMITHING || event.getSlot() != 2)
|
||||
return;
|
||||
|
||||
NBTItem item = NBTItem.get(event.getCurrentItem());
|
||||
if (item.hasType() && (MMOItems.plugin.getConfig().getBoolean("disable-interactions.smith") || item.getBoolean("MMOITEMS_DISABLE_SMITHING")))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
NBTItem item = NBTItem.get(event.getCurrentItem());
|
||||
if (item.hasType() && (MMOItems.plugin.getConfig().getBoolean("disable-interactions.smith") || item.getBoolean("MMOITEMS_DISABLE_SMITHING")))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
// enchanting tables
|
||||
@EventHandler
|
||||
public void d(EnchantItemEvent event) {
|
||||
NBTItem item = NBTItem.get(event.getItem());
|
||||
if (item.hasType() && (MMOItems.plugin.getConfig().getBoolean("disable-interactions.enchant") || item.getBoolean("MMOITEMS_DISABLE_ENCHANTING")))
|
||||
if (item.hasType()
|
||||
&& (MMOItems.plugin.getConfig().getBoolean("disable-interactions.enchant") || item.getBoolean("MMOITEMS_DISABLE_ENCHANTING")))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@ -93,31 +95,33 @@ public class DisableInteractions implements Listener {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
// interaction (entity)
|
||||
@EventHandler
|
||||
public void g(PlayerInteractEntityEvent event) {
|
||||
if (event.getRightClicked() instanceof ArmorStand)
|
||||
return;
|
||||
|
||||
NBTItem item = NBTItem.get(event.getHand() == EquipmentSlot.OFF_HAND ? event.getPlayer().getInventory().getItemInOffHand() : event.getPlayer().getInventory().getItemInMainHand());
|
||||
if (item.getBoolean("MMOITEMS_DISABLE_INTERACTION"))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
// interaction (consume)
|
||||
@EventHandler
|
||||
public void h(PlayerItemConsumeEvent event) {
|
||||
NBTItem item = NBTItem.get(event.getItem());
|
||||
if (item.getBoolean("MMOITEMS_DISABLE_INTERACTION"))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
// interaction (entity)
|
||||
@EventHandler
|
||||
public void g(PlayerInteractEntityEvent event) {
|
||||
if (event.getRightClicked() instanceof ArmorStand)
|
||||
return;
|
||||
|
||||
NBTItem item = NBTItem.get(event.getHand() == EquipmentSlot.OFF_HAND ? event.getPlayer().getInventory().getItemInOffHand()
|
||||
: event.getPlayer().getInventory().getItemInMainHand());
|
||||
if (item.getBoolean("MMOITEMS_DISABLE_INTERACTION"))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
// interaction (consume)
|
||||
@EventHandler
|
||||
public void h(PlayerItemConsumeEvent event) {
|
||||
NBTItem item = NBTItem.get(event.getItem());
|
||||
if (item.getBoolean("MMOITEMS_DISABLE_INTERACTION"))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
// workbench
|
||||
@EventHandler
|
||||
public void i(CraftItemEvent event) {
|
||||
if(event.getRecipe() instanceof Keyed)
|
||||
if(((Keyed) event.getRecipe()).getKey().getNamespace().equalsIgnoreCase("mmoitems")) return;
|
||||
|
||||
if (event.getRecipe() instanceof Keyed)
|
||||
if (((Keyed) event.getRecipe()).getKey().getNamespace().equalsIgnoreCase("mmoitems"))
|
||||
return;
|
||||
|
||||
boolean disableCrafting = MMOItems.plugin.getConfig().getBoolean("disable-interactions.craft");
|
||||
for (ItemStack item : event.getInventory().getMatrix()) {
|
||||
NBTItem nbtItem = NBTItem.get(item);
|
||||
@ -146,23 +150,24 @@ public class DisableInteractions implements Listener {
|
||||
return;
|
||||
|
||||
NBTItem arrow = NBTItem.get(stack);
|
||||
if (arrow.hasType() && MMOItems.plugin.getConfig().getBoolean("disable-interactions.arrow-shooting") || arrow.getBoolean("MMOITEMS_DISABLE_ARROW_SHOOTING"))
|
||||
if (arrow.hasType() && MMOItems.plugin.getConfig().getBoolean("disable-interactions.arrow-shooting")
|
||||
|| arrow.getBoolean("MMOITEMS_DISABLE_ARROW_SHOOTING"))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
private int firstArrow(Player player) {
|
||||
private int firstArrow(Player player) {
|
||||
|
||||
// check offhand first
|
||||
if (player.getInventory().getItemInOffHand() != null && player.getInventory().getItemInOffHand().getType().name().contains("ARROW"))
|
||||
return 40;
|
||||
// check offhand first
|
||||
if (player.getInventory().getItemInOffHand() != null && player.getInventory().getItemInOffHand().getType().name().contains("ARROW"))
|
||||
return 40;
|
||||
|
||||
// check for every slot
|
||||
ItemStack[] storage = player.getInventory().getStorageContents();
|
||||
for (int j = 0; j < storage.length; j++) {
|
||||
ItemStack item = storage[j];
|
||||
if (item != null && item.getType().name().contains("ARROW"))
|
||||
return j;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
// check for every slot
|
||||
ItemStack[] storage = player.getInventory().getStorageContents();
|
||||
for (int j = 0; j < storage.length; j++) {
|
||||
ItemStack item = storage[j];
|
||||
if (item != null && item.getType().name().contains("ARROW"))
|
||||
return j;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
package net.Indyuce.mmoitems.manager;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.ConfigFile;
|
||||
import net.Indyuce.mmoitems.api.block.CustomBlock;
|
||||
import net.Indyuce.mmoitems.api.droptable.DropTable;
|
||||
import net.Indyuce.mmoitems.api.event.CustomBlockDropEvent;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||
import net.Indyuce.mmoitems.listener.CustomBlockListener;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
@ -24,13 +25,11 @@ import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.ConfigFile;
|
||||
import net.Indyuce.mmoitems.api.block.CustomBlock;
|
||||
import net.Indyuce.mmoitems.api.droptable.DropTable;
|
||||
import net.Indyuce.mmoitems.api.event.CustomBlockDropEvent;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||
import net.Indyuce.mmoitems.listener.CustomBlockListener;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class DropTableManager implements Listener {
|
||||
private final Map<EntityType, DropTable> monsters = new HashMap<>();
|
||||
@ -79,7 +78,7 @@ public class DropTableManager implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void blockDrops(EntityDeathEvent event) {
|
||||
public void entityDrops(EntityDeathEvent event) {
|
||||
LivingEntity entity = event.getEntity();
|
||||
Player killer = entity.getKiller();
|
||||
if (killer != null && killer.hasMetadata("NPC"))
|
||||
@ -89,7 +88,7 @@ public class DropTableManager implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void entityDrops(BlockBreakEvent event) {
|
||||
public void blockDrops(BlockBreakEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (player == null || player.getGameMode() == GameMode.CREATIVE)
|
||||
return;
|
||||
|
@ -1,41 +1,39 @@
|
||||
package net.Indyuce.mmoitems.manager;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.crafting.Layout;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.crafting.Layout;
|
||||
|
||||
public class LayoutManager {
|
||||
private final Map<String, Layout> layouts = new HashMap<>();
|
||||
private final Map<String, Layout> layouts = new HashMap<>();
|
||||
|
||||
public LayoutManager() {
|
||||
}
|
||||
public void reload() {
|
||||
layouts.clear();
|
||||
for (File file : new File(MMOItems.plugin.getDataFolder() + "/layouts").listFiles())
|
||||
try {
|
||||
Layout layout = new Layout(file.getName().substring(0, file.getName().length() - 4), YamlConfiguration.loadConfiguration(file));
|
||||
layouts.put(layout.getId(), layout);
|
||||
} catch (IllegalArgumentException exception) {
|
||||
MMOItems.plugin.getLogger().log(Level.WARNING, "Could not load layout '" + file.getName() + "': " + exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
layouts.clear();
|
||||
for (File file : new File(MMOItems.plugin.getDataFolder() + "/layouts").listFiles())
|
||||
try {
|
||||
Layout layout = new Layout(file.getName().substring(0, file.getName().length() - 4), YamlConfiguration.loadConfiguration(file));
|
||||
layouts.put(layout.getId(), layout);
|
||||
} catch (IllegalArgumentException exception) {
|
||||
MMOItems.plugin.getLogger().log(Level.WARNING, "Could not load layout '" + file.getName() + "': " + exception.getMessage());
|
||||
}
|
||||
}
|
||||
public boolean hasLayout(String id) {
|
||||
return layouts.containsKey(id);
|
||||
}
|
||||
|
||||
public boolean hasLayout(String id) {
|
||||
return layouts.containsKey(id);
|
||||
}
|
||||
public Collection<Layout> getLayouts() {
|
||||
return layouts.values();
|
||||
}
|
||||
|
||||
public Collection<Layout> getLayouts() {
|
||||
return layouts.values();
|
||||
}
|
||||
|
||||
public Layout getLayout(String id) {
|
||||
return layouts.getOrDefault(id, layouts.get("default"));
|
||||
}
|
||||
public Layout getLayout(String id) {
|
||||
return layouts.getOrDefault(id, layouts.get("default"));
|
||||
}
|
||||
}
|
||||
|
@ -153,7 +153,6 @@ public class PluginUpdateManager {
|
||||
// simple path changes
|
||||
rename(config.getConfig().getConfigurationSection(id + ".base"), "regeneration", "health-regeneration");
|
||||
rename(config.getConfig().getConfigurationSection(id + ".base"), "element.light", "element.lightness");
|
||||
rename(config.getConfig().getConfigurationSection(id + ".base"), "consume-cooldown", "item-cooldown");
|
||||
|
||||
// sound changes
|
||||
if (config.getConfig().getConfigurationSection(id + ".base").contains("consume-sound")) {
|
||||
|
@ -216,6 +216,7 @@ public class TemplateManager {
|
||||
// items (mmocore) don't error out and need
|
||||
// a reload
|
||||
public void loadCompatibility() {
|
||||
|
||||
templates.clear();
|
||||
|
||||
for (Type type : MMOItems.plugin.getTypes().getAll()) {
|
||||
|
@ -1,8 +1,8 @@
|
||||
package net.Indyuce.mmoitems.stat;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.ItemTier;
|
||||
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
|
||||
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
|
||||
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
|
||||
import net.Indyuce.mmoitems.stat.data.StringData;
|
||||
import net.Indyuce.mmoitems.stat.data.type.StatData;
|
||||
@ -21,8 +21,13 @@ public class DisplayName extends StringStat {
|
||||
|
||||
@Override
|
||||
public void whenApplied(ItemStackBuilder item, StatData data) {
|
||||
item.getMeta().setDisplayName(new DisplayNamePlaceholders(data.toString(), item.getMMOItem()).parse());
|
||||
String format = data.toString();
|
||||
|
||||
ItemTier tier = MMOItems.plugin.getTiers().findTier(item.getMMOItem());
|
||||
format = format.replace("<tier-name>", tier != null ? ChatColor.stripColor(tier.getName()) : "");
|
||||
format = format.replace("<tier-color>", tier != null ? ChatColor.getLastColors(tier.getName()) : "&f");
|
||||
|
||||
item.getMeta().setDisplayName(MMOLib.plugin.parseColors(format));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -30,35 +35,4 @@ public class DisplayName extends StringStat {
|
||||
if (mmoitem.getNBT().getItem().getItemMeta().hasDisplayName())
|
||||
mmoitem.setData(ItemStat.NAME, new StringData(mmoitem.getNBT().getItem().getItemMeta().getDisplayName()));
|
||||
}
|
||||
|
||||
private class DisplayNamePlaceholders {
|
||||
|
||||
private String name;
|
||||
|
||||
private final MMOItem mmoitem;
|
||||
|
||||
private DisplayNamePlaceholders(String name, MMOItem mmoitem) {
|
||||
this.name = name;
|
||||
this.mmoitem = mmoitem;
|
||||
}
|
||||
|
||||
private String parse() {
|
||||
name = name.replace("<tier-name>", (mmoitem.hasData(ItemStat.TIER) && MMOItems.plugin.getTiers().findTier(mmoitem) != null)
|
||||
? stripColorCodes(MMOItems.plugin.getTiers().findTier(mmoitem).getName()) : "");
|
||||
name = name.replace("<tier-color>", (mmoitem.hasData(ItemStat.TIER) && MMOItems.plugin.getTiers().findTier(mmoitem) != null)
|
||||
? stripText(MMOItems.plugin.getTiers().findTier(mmoitem).getName()) : "&f");
|
||||
name = name.replace("<type-name>", (mmoitem.hasData(ItemStat.DISPLAYED_TYPE))
|
||||
? stripColorCodes(mmoitem.getData(ItemStat.DISPLAYED_TYPE).toString()) : stripColorCodes(mmoitem.getType().getName()));
|
||||
return MMOLib.plugin.parseColors(name);
|
||||
}
|
||||
|
||||
private String stripColorCodes(String message) {
|
||||
return ChatColor.stripColor(MMOLib.plugin.parseColors(message));
|
||||
}
|
||||
|
||||
private String stripText(String message) {
|
||||
return ChatColor.getLastColors(MMOLib.plugin.parseColors(message));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user