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 class MMOItems extends JavaPlugin {
|
||||||
public static MMOItems plugin;
|
public static MMOItems plugin;
|
||||||
|
|
||||||
private final PluginUpdateManager pluginUpdateManager = new PluginUpdateManager();
|
private final PluginUpdateManager pluginUpdateManager = new PluginUpdateManager();
|
||||||
private final CraftingManager stationRecipeManager = new CraftingManager();
|
private final CraftingManager stationRecipeManager = new CraftingManager();
|
||||||
private final AbilityManager abilityManager = new AbilityManager();
|
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());
|
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();
|
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();
|
statManager = new StatManager();
|
||||||
|
|
||||||
typeManager.reload();
|
typeManager.reload();
|
||||||
|
templateManager.preloadTemplates();
|
||||||
templateManager.loadCompatibility(); // explained why in method
|
|
||||||
|
|
||||||
if (Bukkit.getPluginManager().getPlugin("MMOCore") != null)
|
if (Bukkit.getPluginManager().getPlugin("MMOCore") != null)
|
||||||
new MMOCoreMMOLoader();
|
new MMOCoreMMOLoader();
|
||||||
@ -138,14 +138,13 @@ public class MMOItems extends JavaPlugin {
|
|||||||
getLogger().log(Level.INFO, "Hooked onto MMOInventory");
|
getLogger().log(Level.INFO, "Hooked onto MMOInventory");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
findRpgPlugin();
|
findRpgPlugin();
|
||||||
|
|
||||||
templateManager.reload();
|
|
||||||
|
|
||||||
tierManager = new TierManager();
|
tierManager = new TierManager();
|
||||||
setManager = new SetManager();
|
setManager = new SetManager();
|
||||||
upgradeManager = new UpgradeManager();
|
upgradeManager = new UpgradeManager();
|
||||||
|
templateManager.reload(); // should be postload() but it's broken waiting for indy to fix
|
||||||
|
|
||||||
dropTableManager = new DropTableManager();
|
dropTableManager = new DropTableManager();
|
||||||
dynamicUpdater = new UpdaterManager();
|
dynamicUpdater = new UpdaterManager();
|
||||||
worldGenManager = new WorldGenManager();
|
worldGenManager = new WorldGenManager();
|
||||||
|
@ -1,5 +1,13 @@
|
|||||||
package net.Indyuce.mmoitems.ability;
|
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.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
@ -12,15 +20,6 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
|||||||
import org.bukkit.event.entity.EntityTargetEvent;
|
import org.bukkit.event.entity.EntityTargetEvent;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
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 class Shadow_Veil extends Ability implements Listener {
|
||||||
public Shadow_Veil() {
|
public Shadow_Veil() {
|
||||||
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK,
|
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
|
@EventHandler
|
||||||
public void cancelMobTarget(EntityTargetEvent event) {
|
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 (player.equals(event.getTarget()))
|
||||||
if (event.getTarget().equals(player))
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,15 @@
|
|||||||
package net.Indyuce.mmoitems.api;
|
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.Color;
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.Particle.DustOptions;
|
import org.bukkit.Particle.DustOptions;
|
||||||
import org.bukkit.entity.Arrow;
|
import org.bukkit.entity.Arrow;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
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 {
|
public class ArrowParticles extends BukkitRunnable {
|
||||||
private final Arrow arrow;
|
private final Arrow arrow;
|
||||||
|
|
||||||
@ -42,11 +40,9 @@ public class ArrowParticles extends BukkitRunnable {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (color != null)
|
if (color != null && particle.getDataType() == DustOptions.class)
|
||||||
if (particle.getDataType() == DustOptions.class)
|
arrow.getWorld().spawnParticle(particle, arrow.getLocation().add(0, .25, 0), amount, offset, offset, offset,
|
||||||
arrow.getWorld().spawnParticle(particle, arrow.getLocation().add(0, .25, 0), amount, offset, offset, offset, new Particle.DustOptions(color, 1));
|
new Particle.DustOptions(color, 1));
|
||||||
else
|
|
||||||
arrow.getWorld().spawnParticle(particle, arrow.getLocation().add(0, .25, 0), amount, offset, offset, offset, color);
|
|
||||||
else
|
else
|
||||||
arrow.getWorld().spawnParticle(particle, arrow.getLocation().add(0, .25, 0), amount, offset, offset, offset, speed);
|
arrow.getWorld().spawnParticle(particle, arrow.getLocation().add(0, .25, 0), amount, offset, offset, offset, speed);
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,17 @@
|
|||||||
package net.Indyuce.mmoitems.api;
|
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.droptable.DropTable;
|
||||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||||
import net.Indyuce.mmoitems.api.util.NumericStatFormula;
|
import net.Indyuce.mmoitems.api.util.NumericStatFormula;
|
||||||
import net.Indyuce.mmoitems.comp.itemglow.TierColor;
|
import net.Indyuce.mmoitems.comp.itemglow.TierColor;
|
||||||
import net.mmogroup.mmolib.MMOLib;
|
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 {
|
public class ItemTier {
|
||||||
private final String name, id;
|
private final String name, id;
|
||||||
@ -36,7 +35,7 @@ public class ItemTier {
|
|||||||
|
|
||||||
public ItemTier(ConfigurationSection config) {
|
public ItemTier(ConfigurationSection config) {
|
||||||
id = config.getName().toUpperCase().replace("-", "_");
|
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;
|
deconstruct = config.contains("deconstruct-item") ? new DropTable(config.getConfigurationSection("deconstruct-item")) : null;
|
||||||
unidentificationInfo = new UnidentificationInfo(config.getConfigurationSection("unidentification"));
|
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.RecipeInfo;
|
||||||
import net.Indyuce.mmoitems.api.crafting.recipe.UpgradingRecipe;
|
import net.Indyuce.mmoitems.api.crafting.recipe.UpgradingRecipe;
|
||||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||||
import net.Indyuce.mmoitems.api.util.PostLoadObject;
|
|
||||||
import net.mmogroup.mmolib.MMOLib;
|
import net.mmogroup.mmolib.MMOLib;
|
||||||
|
import net.mmogroup.mmolib.api.util.PostLoadObject;
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
@ -1,28 +1,28 @@
|
|||||||
package net.Indyuce.mmoitems.api.event;
|
package net.Indyuce.mmoitems.api.event;
|
||||||
|
|
||||||
|
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
|
||||||
|
|
||||||
public class CraftMMOItemEvent extends PlayerDataEvent {
|
public class CraftMMOItemEvent extends PlayerDataEvent {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private ItemStack stack;
|
private ItemStack result;
|
||||||
|
|
||||||
public CraftMMOItemEvent(PlayerData playerData, ItemStack stack) {
|
public CraftMMOItemEvent(PlayerData playerData, ItemStack result) {
|
||||||
super(playerData);
|
super(playerData);
|
||||||
this.stack = stack;
|
|
||||||
}
|
this.result = result;
|
||||||
|
|
||||||
public ItemStack getResult() {
|
|
||||||
return stack;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStack(ItemStack stack) {
|
public ItemStack getResult() {
|
||||||
this.stack = stack;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setResult(ItemStack result) {
|
||||||
|
this.result = result;
|
||||||
|
}
|
||||||
|
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,16 @@
|
|||||||
package net.Indyuce.mmoitems.api.item.build;
|
package net.Indyuce.mmoitems.api.item.build;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import net.Indyuce.mmoitems.MMOItems;
|
||||||
import java.util.HashMap;
|
import net.Indyuce.mmoitems.api.Type;
|
||||||
import java.util.List;
|
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
|
||||||
import java.util.UUID;
|
import net.Indyuce.mmoitems.api.util.StatFormat;
|
||||||
import java.util.logging.Level;
|
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.Material;
|
||||||
import org.bukkit.attribute.Attribute;
|
import org.bukkit.attribute.Attribute;
|
||||||
import org.bukkit.attribute.AttributeModifier;
|
import org.bukkit.attribute.AttributeModifier;
|
||||||
@ -14,22 +19,11 @@ import org.bukkit.inventory.ItemFlag;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import net.Indyuce.mmoitems.MMOItems;
|
import java.util.ArrayList;
|
||||||
import net.Indyuce.mmoitems.api.Type;
|
import java.util.HashMap;
|
||||||
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
|
import java.util.List;
|
||||||
import net.Indyuce.mmoitems.api.util.StatFormat;
|
import java.util.UUID;
|
||||||
import net.Indyuce.mmoitems.stat.data.DoubleData;
|
import java.util.logging.Level;
|
||||||
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;
|
|
||||||
|
|
||||||
public class ItemStackBuilder {
|
public class ItemStackBuilder {
|
||||||
private MMOItem mmoitem;
|
private MMOItem mmoitem;
|
||||||
@ -124,7 +118,7 @@ public class ItemStackBuilder {
|
|||||||
lore.insert("lore", parsed);
|
lore.insert("lore", parsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
meta.setLore(lore.build().toStringList());
|
meta.setLore(lore.build());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This tag is added to entirely override default vanilla item attribute
|
* This tag is added to entirely override default vanilla item attribute
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
package net.Indyuce.mmoitems.api.item.build;
|
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.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
|
|
||||||
import net.Indyuce.mmoitems.MMOItems;
|
|
||||||
import net.mmogroup.mmolib.MMOLib;
|
|
||||||
|
|
||||||
public class LoreBuilder {
|
public class LoreBuilder {
|
||||||
private final List<String> lore = MMOItems.plugin.getLanguage().getDefaultLoreFormat();
|
private final List<String> lore = MMOItems.plugin.getLanguage().getDefaultLoreFormat();
|
||||||
private final Map<String, String> placeholders = new HashMap<>();
|
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
|
* have been inserted in the lore. It cleans all unused lore format
|
||||||
* # lines as well as lore bars
|
* # lines as well as lore bars
|
||||||
*/
|
*/
|
||||||
public LoreBuilder build() {
|
public List<String> build() {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* loops backwards to remove all unused bars in one iteration only,
|
* 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
|
* clear bar codes and parse chat colors only ONCE the bars have been
|
||||||
* the bars have been successfully calculated
|
* successfully calculated
|
||||||
*
|
*
|
||||||
* NEW: also finalize the lore by breaking
|
* NEW: also finalize the lore by breaking lines with the \n escape
|
||||||
* lines with the \n escape character
|
* character
|
||||||
*/
|
*/
|
||||||
final List<String> finalLore = new ArrayList<>();
|
final List<String> cleaned = new ArrayList<>();
|
||||||
for (int i = 0; i < lore.size(); i++) {
|
for (int i = 0; i < lore.size(); i++)
|
||||||
for(final String s : MMOLib.plugin.parseColors(lore.get(i)
|
for (final String s : MMOLib.plugin.parseColors(lore.get(i).replace("{bar}", "").replace("{sbar}", "")).split("\\\\n"))
|
||||||
.replace("{bar}", "").replace("{sbar}", "")).split("\\\\n"))
|
cleaned.add(s);
|
||||||
finalLore.add(s);
|
|
||||||
}
|
return cleaned;
|
||||||
|
|
||||||
lore.clear();
|
|
||||||
lore.addAll(finalLore);
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isBar(String str) {
|
private boolean isBar(String str) {
|
||||||
return str.startsWith("{bar}") || str.startsWith("{sbar}");
|
return str.startsWith("{bar}") || str.startsWith("{sbar}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> toStringList() {
|
|
||||||
return lore;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,5 @@
|
|||||||
package net.Indyuce.mmoitems.api.item.template;
|
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.MMOItems;
|
||||||
import net.Indyuce.mmoitems.api.ItemTier;
|
import net.Indyuce.mmoitems.api.ItemTier;
|
||||||
import net.Indyuce.mmoitems.api.Type;
|
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.api.player.RPGPlayer;
|
||||||
import net.Indyuce.mmoitems.stat.data.random.RandomStatData;
|
import net.Indyuce.mmoitems.stat.data.random.RandomStatData;
|
||||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
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 Type type;
|
||||||
private final String id;
|
private final String id;
|
||||||
|
|
||||||
@ -42,6 +37,8 @@ public class MMOItemTemplate implements ItemReference {
|
|||||||
* different item types share the same ID
|
* different item types share the same ID
|
||||||
*/
|
*/
|
||||||
public MMOItemTemplate(Type type, String id) {
|
public MMOItemTemplate(Type type, String id) {
|
||||||
|
super(null);
|
||||||
|
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
@ -55,11 +52,14 @@ public class MMOItemTemplate implements ItemReference {
|
|||||||
* The config file read to load the template
|
* The config file read to load the template
|
||||||
*/
|
*/
|
||||||
public MMOItemTemplate(Type type, ConfigurationSection config) {
|
public MMOItemTemplate(Type type, ConfigurationSection config) {
|
||||||
Validate.notNull(config, "Could not load template config");
|
super(config);
|
||||||
|
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.id = config.getName().toUpperCase().replace("-", "_").replace(" ", "_");
|
this.id = config.getName().toUpperCase().replace("-", "_").replace(" ", "_");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void whenPostLoaded(ConfigurationSection config) {
|
||||||
if (config.contains("option"))
|
if (config.contains("option"))
|
||||||
for (TemplateOption option : TemplateOption.values())
|
for (TemplateOption option : TemplateOption.values())
|
||||||
if (config.getBoolean("option." + option.name().toLowerCase().replace("_", "-")))
|
if (config.getBoolean("option." + option.name().toLowerCase().replace("_", "-")))
|
||||||
|
@ -21,7 +21,6 @@ import java.util.List;
|
|||||||
|
|
||||||
public class ConfigItem {
|
public class ConfigItem {
|
||||||
private final String id;
|
private final String id;
|
||||||
private final Material material;
|
|
||||||
private final ItemStack icon;
|
private final ItemStack icon;
|
||||||
|
|
||||||
// updated when the plugin reloads
|
// 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 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 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 PREVIOUS_PAGE = new CustomSkull("PREVIOUS_PAGE",
|
||||||
public static final CustomSkull NEXT_PAGE = new CustomSkull("NEXT_PAGE", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTliZjMyOTJlMTI2YTEwNWI1NGViYTcxM2FhMWIxNTJkNTQxYTFkODkzODgyOWM1NjM2NGQxNzhlZDIyYmYifX19", "&aNext Page");
|
"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYmQ2OWUwNmU1ZGFkZmQ4NGU1ZjNkMWMyMTA2M2YyNTUzYjJmYTk0NWVlMWQ0ZDcxNTJmZGM1NDI1YmMxMmE5In19fQ==",
|
||||||
public static final CustomSkull PREVIOUS_IN_QUEUE = new CustomSkull("PREVIOUS_IN_QUEUE", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYmQ2OWUwNmU1ZGFkZmQ4NGU1ZjNkMWMyMTA2M2YyNTUzYjJmYTk0NWVlMWQ0ZDcxNTJmZGM1NDI1YmMxMmE5In19fQ==", "&aPrevious");
|
"&aPrevious Page");
|
||||||
public static final CustomSkull NEXT_IN_QUEUE = new CustomSkull("NEXT_IN_QUEUE", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTliZjMyOTJlMTI2YTEwNWI1NGViYTcxM2FhMWIxNTJkNTQxYTFkODkzODgyOWM1NjM2NGQxNzhlZDIyYmYifX19", "&aNext");
|
public static final CustomSkull NEXT_PAGE = new CustomSkull("NEXT_PAGE",
|
||||||
public static final CustomSkull BACK = new CustomSkull("BACK", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYmQ2OWUwNmU1ZGFkZmQ4NGU1ZjNkMWMyMTA2M2YyNTUzYjJmYTk0NWVlMWQ0ZDcxNTJmZGM1NDI1YmMxMmE5In19fQ==", "&aBack");
|
"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 CraftingRecipeDisplay CRAFTING_RECIPE_DISPLAY = new CraftingRecipeDisplay();
|
||||||
public static final UpgradingRecipeDisplay UPGRADING_RECIPE_DISPLAY = new UpgradingRecipeDisplay();
|
public static final UpgradingRecipeDisplay UPGRADING_RECIPE_DISPLAY = new UpgradingRecipeDisplay();
|
||||||
public static final QueueItemDisplay QUEUE_ITEM_DISPLAY = new QueueItemDisplay();
|
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) {
|
public ConfigItem(String id, Material material) {
|
||||||
this(id, material, null);
|
this(id, material, null);
|
||||||
@ -53,7 +63,6 @@ public class ConfigItem {
|
|||||||
Validate.notNull(material, "Material cannot be null");
|
Validate.notNull(material, "Material cannot be null");
|
||||||
|
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.material = material;
|
|
||||||
this.icon = new ItemStack(material);
|
this.icon = new ItemStack(material);
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.lore = Arrays.asList(lore);
|
this.lore = Arrays.asList(lore);
|
||||||
@ -70,7 +79,6 @@ public class ConfigItem {
|
|||||||
|
|
||||||
icon = MMOUtils.readIcon(config.getString("material"));
|
icon = MMOUtils.readIcon(config.getString("material"));
|
||||||
|
|
||||||
material = icon.getType();
|
|
||||||
name = config.getString("name", "");
|
name = config.getString("name", "");
|
||||||
lore = config.getStringList("lore");
|
lore = config.getStringList("lore");
|
||||||
|
|
||||||
@ -96,7 +104,7 @@ public class ConfigItem {
|
|||||||
|
|
||||||
public void updateItem() {
|
public void updateItem() {
|
||||||
setItem(icon);
|
setItem(icon);
|
||||||
if (material == Material.AIR)
|
if (icon.getType() == Material.AIR)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
@ -113,10 +121,6 @@ public class ConfigItem {
|
|||||||
item = MMOLib.plugin.getVersion().getWrapper().getNBTItem(item).addTag(new ItemTag("ItemId", id)).toItem();
|
item = MMOLib.plugin.getVersion().getWrapper().getNBTItem(item).addTag(new ItemTag("ItemId", id)).toItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Material getMaterial() {
|
|
||||||
return material;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
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;
|
package net.Indyuce.mmoitems.api.util;
|
||||||
|
|
||||||
import java.util.Collection;
|
import net.Indyuce.mmoitems.api.Type;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.Validate;
|
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
|
* 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);
|
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.
|
* @return Collects all the values registered in this template map.
|
||||||
*/
|
*/
|
||||||
|
@ -1,13 +1,5 @@
|
|||||||
package net.Indyuce.mmoitems.comp.parse.placeholders;
|
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 me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
import net.Indyuce.mmoitems.MMOItems;
|
import net.Indyuce.mmoitems.MMOItems;
|
||||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
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.player.MMOPlayerData;
|
||||||
import net.mmogroup.mmolib.api.util.AltChar;
|
import net.mmogroup.mmolib.api.util.AltChar;
|
||||||
import net.mmogroup.mmolib.listener.DamageReduction;
|
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 {
|
public class MMOItemsPlaceholders extends PlaceholderExpansion {
|
||||||
private final DecimalFormat oneDigit = new DecimalFormat("0.#"), twoDigits = new DecimalFormat("0.##");
|
private final DecimalFormat oneDigit = new DecimalFormat("0.#"), twoDigits = new DecimalFormat("0.##");
|
||||||
@ -51,11 +50,10 @@ public class MMOItemsPlaceholders extends PlaceholderExpansion {
|
|||||||
@Override
|
@Override
|
||||||
public String onRequest(@Nullable OfflinePlayer player, @NotNull String identifier) {
|
public String onRequest(@Nullable OfflinePlayer player, @NotNull String identifier) {
|
||||||
// registering before identifier.startsWith("stat_") to prevent issues
|
// registering before identifier.startsWith("stat_") to prevent issues
|
||||||
// i don't register it in the starts with condition because it will mess with
|
// i don't register it in the starts with condition because it will mess
|
||||||
// substring
|
// with substring
|
||||||
if (identifier.equals("stat_defense_percent"))
|
if (identifier.equals("stat_defense_percent"))
|
||||||
return twoDigits.format(
|
return twoDigits.format(100 - new DamageReduction.DefenseCalculator(MMOPlayerData.get(player)).getAppliedDamage(100)) + "%";
|
||||||
new DamageReduction.DefenseCalculator(MMOPlayerData.get(player)).getReductionPercent()) + "%";
|
|
||||||
if (identifier.startsWith("stat_")) {
|
if (identifier.startsWith("stat_")) {
|
||||||
ItemStat stat = MMOItems.plugin.getStats().get(identifier.substring(5).toUpperCase());
|
ItemStat stat = MMOItems.plugin.getStats().get(identifier.substring(5).toUpperCase());
|
||||||
if (stat != null)
|
if (stat != null)
|
||||||
@ -64,8 +62,7 @@ public class MMOItemsPlaceholders extends PlaceholderExpansion {
|
|||||||
|
|
||||||
if (identifier.startsWith("ability_cd_")) {
|
if (identifier.startsWith("ability_cd_")) {
|
||||||
PlayerData data = PlayerData.get(player);
|
PlayerData data = PlayerData.get(player);
|
||||||
return data.hasCooldownInfo(identifier.substring(11))
|
return data.hasCooldownInfo(identifier.substring(11)) ? oneDigit.format(data.getCooldownInfo(identifier.substring(11)).getRemaining())
|
||||||
? oneDigit.format(data.getCooldownInfo(identifier.substring(11)).getRemaining())
|
|
||||||
: "0";
|
: "0";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package net.Indyuce.mmoitems.listener;
|
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.Keyed;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -18,10 +21,6 @@ import org.bukkit.inventory.EquipmentSlot;
|
|||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
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 {
|
public class DisableInteractions implements Listener {
|
||||||
|
|
||||||
// anvils
|
// anvils
|
||||||
@ -32,45 +31,48 @@ public class DisableInteractions implements Listener {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
NBTItem item = NBTItem.get(event.getCurrentItem());
|
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);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// grindstone
|
// grindstone
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void b(InventoryClickEvent event) {
|
public void b(InventoryClickEvent event) {
|
||||||
if (MMOLib.plugin.getVersion().isBelowOrEqual(1, 13))
|
if (MMOLib.plugin.getVersion().isBelowOrEqual(1, 13))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Inventory inv = event.getClickedInventory();
|
Inventory inv = event.getClickedInventory();
|
||||||
if (inv == null || inv.getType() != InventoryType.GRINDSTONE || event.getSlot() != 2)
|
if (inv == null || inv.getType() != InventoryType.GRINDSTONE || event.getSlot() != 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
NBTItem item = NBTItem.get(event.getCurrentItem());
|
NBTItem item = NBTItem.get(event.getCurrentItem());
|
||||||
if (item.hasType() && (MMOItems.plugin.getConfig().getBoolean("disable-interactions.repair") || item.getBoolean("MMOITEMS_DISABLE_REPAIRING")))
|
if (item.hasType()
|
||||||
event.setCancelled(true);
|
&& (MMOItems.plugin.getConfig().getBoolean("disable-interactions.repair") || item.getBoolean("MMOITEMS_DISABLE_REPAIRING")))
|
||||||
}
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
// smithing table
|
// smithing table
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void c(InventoryClickEvent event) {
|
public void c(InventoryClickEvent event) {
|
||||||
if (MMOLib.plugin.getVersion().isBelowOrEqual(1, 15))
|
if (MMOLib.plugin.getVersion().isBelowOrEqual(1, 15))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Inventory inv = event.getClickedInventory();
|
Inventory inv = event.getClickedInventory();
|
||||||
if (inv == null || inv.getType() != InventoryType.SMITHING || event.getSlot() != 2)
|
if (inv == null || inv.getType() != InventoryType.SMITHING || event.getSlot() != 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
NBTItem item = NBTItem.get(event.getCurrentItem());
|
NBTItem item = NBTItem.get(event.getCurrentItem());
|
||||||
if (item.hasType() && (MMOItems.plugin.getConfig().getBoolean("disable-interactions.smith") || item.getBoolean("MMOITEMS_DISABLE_SMITHING")))
|
if (item.hasType() && (MMOItems.plugin.getConfig().getBoolean("disable-interactions.smith") || item.getBoolean("MMOITEMS_DISABLE_SMITHING")))
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// enchanting tables
|
// enchanting tables
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void d(EnchantItemEvent event) {
|
public void d(EnchantItemEvent event) {
|
||||||
NBTItem item = NBTItem.get(event.getItem());
|
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);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,31 +95,33 @@ public class DisableInteractions implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// interaction (entity)
|
// interaction (entity)
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void g(PlayerInteractEntityEvent event) {
|
public void g(PlayerInteractEntityEvent event) {
|
||||||
if (event.getRightClicked() instanceof ArmorStand)
|
if (event.getRightClicked() instanceof ArmorStand)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
NBTItem item = NBTItem.get(event.getHand() == EquipmentSlot.OFF_HAND ? event.getPlayer().getInventory().getItemInOffHand() : event.getPlayer().getInventory().getItemInMainHand());
|
NBTItem item = NBTItem.get(event.getHand() == EquipmentSlot.OFF_HAND ? event.getPlayer().getInventory().getItemInOffHand()
|
||||||
if (item.getBoolean("MMOITEMS_DISABLE_INTERACTION"))
|
: event.getPlayer().getInventory().getItemInMainHand());
|
||||||
event.setCancelled(true);
|
if (item.getBoolean("MMOITEMS_DISABLE_INTERACTION"))
|
||||||
}
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
// interaction (consume)
|
|
||||||
@EventHandler
|
// interaction (consume)
|
||||||
public void h(PlayerItemConsumeEvent event) {
|
@EventHandler
|
||||||
NBTItem item = NBTItem.get(event.getItem());
|
public void h(PlayerItemConsumeEvent event) {
|
||||||
if (item.getBoolean("MMOITEMS_DISABLE_INTERACTION"))
|
NBTItem item = NBTItem.get(event.getItem());
|
||||||
event.setCancelled(true);
|
if (item.getBoolean("MMOITEMS_DISABLE_INTERACTION"))
|
||||||
}
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
// workbench
|
// workbench
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void i(CraftItemEvent event) {
|
public void i(CraftItemEvent event) {
|
||||||
if(event.getRecipe() instanceof Keyed)
|
if (event.getRecipe() instanceof Keyed)
|
||||||
if(((Keyed) event.getRecipe()).getKey().getNamespace().equalsIgnoreCase("mmoitems")) return;
|
if (((Keyed) event.getRecipe()).getKey().getNamespace().equalsIgnoreCase("mmoitems"))
|
||||||
|
return;
|
||||||
|
|
||||||
boolean disableCrafting = MMOItems.plugin.getConfig().getBoolean("disable-interactions.craft");
|
boolean disableCrafting = MMOItems.plugin.getConfig().getBoolean("disable-interactions.craft");
|
||||||
for (ItemStack item : event.getInventory().getMatrix()) {
|
for (ItemStack item : event.getInventory().getMatrix()) {
|
||||||
NBTItem nbtItem = NBTItem.get(item);
|
NBTItem nbtItem = NBTItem.get(item);
|
||||||
@ -146,23 +150,24 @@ public class DisableInteractions implements Listener {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
NBTItem arrow = NBTItem.get(stack);
|
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);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int firstArrow(Player player) {
|
private int firstArrow(Player player) {
|
||||||
|
|
||||||
// check offhand first
|
// check offhand first
|
||||||
if (player.getInventory().getItemInOffHand() != null && player.getInventory().getItemInOffHand().getType().name().contains("ARROW"))
|
if (player.getInventory().getItemInOffHand() != null && player.getInventory().getItemInOffHand().getType().name().contains("ARROW"))
|
||||||
return 40;
|
return 40;
|
||||||
|
|
||||||
// check for every slot
|
// check for every slot
|
||||||
ItemStack[] storage = player.getInventory().getStorageContents();
|
ItemStack[] storage = player.getInventory().getStorageContents();
|
||||||
for (int j = 0; j < storage.length; j++) {
|
for (int j = 0; j < storage.length; j++) {
|
||||||
ItemStack item = storage[j];
|
ItemStack item = storage[j];
|
||||||
if (item != null && item.getType().name().contains("ARROW"))
|
if (item != null && item.getType().name().contains("ARROW"))
|
||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package net.Indyuce.mmoitems.manager;
|
package net.Indyuce.mmoitems.manager;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import net.Indyuce.mmoitems.MMOItems;
|
||||||
import java.util.List;
|
import net.Indyuce.mmoitems.api.ConfigFile;
|
||||||
import java.util.Map;
|
import net.Indyuce.mmoitems.api.block.CustomBlock;
|
||||||
import java.util.Optional;
|
import net.Indyuce.mmoitems.api.droptable.DropTable;
|
||||||
import java.util.logging.Level;
|
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.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -24,13 +25,11 @@ import org.bukkit.event.block.BlockBreakEvent;
|
|||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import net.Indyuce.mmoitems.MMOItems;
|
import java.util.HashMap;
|
||||||
import net.Indyuce.mmoitems.api.ConfigFile;
|
import java.util.List;
|
||||||
import net.Indyuce.mmoitems.api.block.CustomBlock;
|
import java.util.Map;
|
||||||
import net.Indyuce.mmoitems.api.droptable.DropTable;
|
import java.util.Optional;
|
||||||
import net.Indyuce.mmoitems.api.event.CustomBlockDropEvent;
|
import java.util.logging.Level;
|
||||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
|
||||||
import net.Indyuce.mmoitems.listener.CustomBlockListener;
|
|
||||||
|
|
||||||
public class DropTableManager implements Listener {
|
public class DropTableManager implements Listener {
|
||||||
private final Map<EntityType, DropTable> monsters = new HashMap<>();
|
private final Map<EntityType, DropTable> monsters = new HashMap<>();
|
||||||
@ -79,7 +78,7 @@ public class DropTableManager implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void blockDrops(EntityDeathEvent event) {
|
public void entityDrops(EntityDeathEvent event) {
|
||||||
LivingEntity entity = event.getEntity();
|
LivingEntity entity = event.getEntity();
|
||||||
Player killer = entity.getKiller();
|
Player killer = entity.getKiller();
|
||||||
if (killer != null && killer.hasMetadata("NPC"))
|
if (killer != null && killer.hasMetadata("NPC"))
|
||||||
@ -89,7 +88,7 @@ public class DropTableManager implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public void entityDrops(BlockBreakEvent event) {
|
public void blockDrops(BlockBreakEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (player == null || player.getGameMode() == GameMode.CREATIVE)
|
if (player == null || player.getGameMode() == GameMode.CREATIVE)
|
||||||
return;
|
return;
|
||||||
|
@ -1,41 +1,39 @@
|
|||||||
package net.Indyuce.mmoitems.manager;
|
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.io.File;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.logging.Level;
|
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 {
|
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() {
|
public boolean hasLayout(String id) {
|
||||||
layouts.clear();
|
return layouts.containsKey(id);
|
||||||
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) {
|
public Collection<Layout> getLayouts() {
|
||||||
return layouts.containsKey(id);
|
return layouts.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<Layout> getLayouts() {
|
public Layout getLayout(String id) {
|
||||||
return layouts.values();
|
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
|
// simple path changes
|
||||||
rename(config.getConfig().getConfigurationSection(id + ".base"), "regeneration", "health-regeneration");
|
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"), "element.light", "element.lightness");
|
||||||
rename(config.getConfig().getConfigurationSection(id + ".base"), "consume-cooldown", "item-cooldown");
|
|
||||||
|
|
||||||
// sound changes
|
// sound changes
|
||||||
if (config.getConfig().getConfigurationSection(id + ".base").contains("consume-sound")) {
|
if (config.getConfig().getConfigurationSection(id + ".base").contains("consume-sound")) {
|
||||||
|
@ -216,6 +216,7 @@ public class TemplateManager {
|
|||||||
// items (mmocore) don't error out and need
|
// items (mmocore) don't error out and need
|
||||||
// a reload
|
// a reload
|
||||||
public void loadCompatibility() {
|
public void loadCompatibility() {
|
||||||
|
|
||||||
templates.clear();
|
templates.clear();
|
||||||
|
|
||||||
for (Type type : MMOItems.plugin.getTypes().getAll()) {
|
for (Type type : MMOItems.plugin.getTypes().getAll()) {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package net.Indyuce.mmoitems.stat;
|
package net.Indyuce.mmoitems.stat;
|
||||||
|
|
||||||
import net.Indyuce.mmoitems.MMOItems;
|
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.build.ItemStackBuilder;
|
||||||
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
|
|
||||||
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
|
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
|
||||||
import net.Indyuce.mmoitems.stat.data.StringData;
|
import net.Indyuce.mmoitems.stat.data.StringData;
|
||||||
import net.Indyuce.mmoitems.stat.data.type.StatData;
|
import net.Indyuce.mmoitems.stat.data.type.StatData;
|
||||||
@ -21,8 +21,13 @@ public class DisplayName extends StringStat {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void whenApplied(ItemStackBuilder item, StatData data) {
|
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
|
@Override
|
||||||
@ -30,35 +35,4 @@ public class DisplayName extends StringStat {
|
|||||||
if (mmoitem.getNBT().getItem().getItemMeta().hasDisplayName())
|
if (mmoitem.getNBT().getItem().getItemMeta().hasDisplayName())
|
||||||
mmoitem.setData(ItemStat.NAME, new StringData(mmoitem.getNBT().getItem().getItemMeta().getDisplayName()));
|
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