> MMOItems 6.5 - API Handling Rewrite

REQUIRES MMOLIB 1.7!!!
- Rewrote MMOLib compatibility API (MMOLib is still a dependency!)
- Lootsplosions are now a part of MMOItems.
This commit is contained in:
ASangarin 2020-12-06 17:47:13 +01:00
parent 502563bbc0
commit 7402b572ab
32 changed files with 741 additions and 688 deletions

59
pom.xml
View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>net.Indyuce</groupId>
<artifactId>MMOItems</artifactId>
<version>6.4</version>
<version>6.5</version>
<name>MMOItems</name>
<description>A great item solution for your RPG server.</description>
@ -47,32 +47,6 @@
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>../build.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<outputDirectory>${jar.path}</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
@ -94,23 +68,6 @@
</repository>
</repositories>
<dependencies>
<!-- MMOs -->
<dependency>
<groupId>net.mmogroup</groupId>
<artifactId>MMOLib</artifactId>
<version>1.0.9</version>
<scope>system</scope>
<systemPath>${basedir}/lib/MMOLib.jar</systemPath>
</dependency>
<dependency>
<groupId>net.Indyuce</groupId>
<artifactId>mmocore</artifactId>
<version>1.4.12</version>
<scope>system</scope>
<systemPath>${basedir}/lib/MMOCore.jar</systemPath>
</dependency>
<!-- Minecraft -->
<dependency>
<groupId>com.mojang</groupId>
@ -125,6 +82,20 @@
<systemPath>${basedir}/lib/spigot.jar</systemPath>
</dependency>
<!-- MMOs -->
<dependency>
<groupId>net.Indyuce</groupId>
<artifactId>MMOCore</artifactId>
<version>1.5</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.Indyuce</groupId>
<artifactId>MMOLib</artifactId>
<version>1.6</version>
<scope>provided</scope>
</dependency>
<!-- APIs -->
<dependency>
<groupId>org.jetbrains</groupId>

View File

@ -50,6 +50,7 @@ import net.Indyuce.mmoitems.listener.DurabilityListener;
import net.Indyuce.mmoitems.listener.ElementListener;
import net.Indyuce.mmoitems.listener.ItemListener;
import net.Indyuce.mmoitems.listener.ItemUse;
import net.Indyuce.mmoitems.listener.LootsplosionListener;
import net.Indyuce.mmoitems.listener.PlayerListener;
import net.Indyuce.mmoitems.manager.AbilityManager;
import net.Indyuce.mmoitems.manager.BlockManager;
@ -69,7 +70,6 @@ import net.Indyuce.mmoitems.manager.TierManager;
import net.Indyuce.mmoitems.manager.TypeManager;
import net.Indyuce.mmoitems.manager.UpgradeManager;
import net.Indyuce.mmoitems.manager.WorldGenManager;
import net.mmogroup.mmolib.api.player.MMOPlayerData;
import net.mmogroup.mmolib.version.SpigotPlugin;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
@ -120,16 +120,14 @@ public class MMOItems extends JavaPlugin {
public void onLoad() {
plugin = this;
if (getServer().getPluginManager().getPlugin("WorldGuard") != null)
try {
if (getServer().getPluginManager().getPlugin("WorldGuard") != null) try {
flagPlugin = new WorldGuardFlags();
getLogger().log(Level.INFO, "Hooked onto WorldGuard");
} catch (Exception exception) {
getLogger().log(Level.WARNING, "Could not initialize support with WorldGuard 7: " + exception.getMessage());
}
if (getServer().getPluginManager().getPlugin("WorldEdit") != null)
try {
if (getServer().getPluginManager().getPlugin("WorldEdit") != null) try {
new WorldEditSupport();
getLogger().log(Level.INFO, "Hooked onto WorldEdit");
} catch (Exception exception) {
@ -146,8 +144,7 @@ public class MMOItems extends JavaPlugin {
typeManager.reload();
templateManager.preloadTemplates();
if (Bukkit.getPluginManager().getPlugin("MMOCore") != null)
new MMOCoreMMOLoader();
if (Bukkit.getPluginManager().getPlugin("MMOCore") != null) new MMOCoreMMOLoader();
}
public void onEnable() {
@ -191,8 +188,7 @@ public class MMOItems extends JavaPlugin {
worldGenManager = new WorldGenManager();
blockManager = new BlockManager();
if (Bukkit.getPluginManager().getPlugin("Vault") != null)
vaultSupport = new VaultSupport();
if (Bukkit.getPluginManager().getPlugin("Vault") != null) vaultSupport = new VaultSupport();
getLogger().log(Level.INFO, "Loading crafting stations, please wait..");
layoutManager.reload();
@ -209,6 +205,8 @@ public class MMOItems extends JavaPlugin {
Bukkit.getPluginManager().registerEvents(new GuiListener(), this);
Bukkit.getPluginManager().registerEvents(new ElementListener(), this);
Bukkit.getPluginManager().registerEvents(new CustomBlockListener(), this);
if (getConfig().getBoolean("lootsplosion.enabled"))
Bukkit.getPluginManager().registerEvents(new LootsplosionListener(), this);
/*
* this class implements the Listener, if the option
@ -272,8 +270,7 @@ public class MMOItems extends JavaPlugin {
if (Bukkit.getPluginManager().getPlugin("GlowAPI") != null && Bukkit.getPluginManager().getPlugin("PacketListenerApi") != null) {
Bukkit.getPluginManager().registerEvents(new ItemGlowListener(), this);
getLogger().log(Level.INFO, "Hooked onto GlowAPI (Item Glow)");
} else
Bukkit.getPluginManager().registerEvents(new NoGlowListener(), this);
} else Bukkit.getPluginManager().registerEvents(new NoGlowListener(), this);
}
if (Bukkit.getPluginManager().getPlugin("RealDualWield") != null) {
@ -301,8 +298,7 @@ public class MMOItems extends JavaPlugin {
}
recipeManager.load(book, amounts);
if(amounts)
Bukkit.getPluginManager().registerEvents(new CraftingListener(), this);
if (amounts) Bukkit.getPluginManager().registerEvents(new CraftingListener(), this);
// amount and bukkit recipes
getLogger().log(Level.INFO, "Loading recipes, please wait...");
@ -321,7 +317,7 @@ public class MMOItems extends JavaPlugin {
public void onDisable() {
// save player data
MMOPlayerData.getLoaded().stream().filter(data -> data.getMMOItems() != null).forEach(data -> data.getMMOItems().save());
PlayerData.getLoaded().forEach(PlayerData::save);
// save item updater data
ConfigFile updater = new ConfigFile("/dynamic", "updater");
@ -374,8 +370,7 @@ public class MMOItems extends JavaPlugin {
* player level, class, resources like mana and stamina for item or skill
* costs, item restrictions, etc.
*
* @param handler
* Your RPGHandler instance
* @param handler Your RPGHandler instance
*/
public void setRPG(RPGHandler handler) {
Validate.notNull(handler, "RPGHandler cannot be null");
@ -403,11 +398,10 @@ public class MMOItems extends JavaPlugin {
* checks held items + armor slots. However other plugins like MMOInv do
* implement custom slots and therefore must register a custom
* PlayerInventory instance.
*
* <p>
* Default instance is DefaultPlayerInventory in comp.inventory
*
* @param value
* The player inventory subclass
* @param value The player inventory subclass
*/
public void setPlayerInventory(PlayerInventory value) {
inventory = value;
@ -494,8 +488,7 @@ public class MMOItems extends JavaPlugin {
}
public void findRpgPlugin() {
if (rpgPlugin != null)
return;
if (rpgPlugin != null) return;
for (RPGHandler.PluginEnum plugin : RPGHandler.PluginEnum.values())
if (Bukkit.getPluginManager().getPlugin(plugin.getName()) != null) {
@ -522,10 +515,8 @@ public class MMOItems extends JavaPlugin {
}
/**
* @param itemLevel
* The desired item level
* @param itemTier
* The desired item tier, can be null
* @param itemLevel The desired item level
* @param itemTier The desired item tier, can be null
* @return Generates an item given an item template with a specific item
* level and item tier
*/

View File

@ -230,7 +230,7 @@ public class Type {
*/
@Deprecated
public static Type get(ItemStack item) {
return MMOLib.plugin.getVersion().getWrapper().getNBTItem(item).getType();
return Type.get(MMOLib.plugin.getVersion().getWrapper().getNBTItem(item).getType());
}
/**
@ -241,7 +241,7 @@ public class Type {
* @return The type or NPE if it couldn't be found
*/
public static Type get(String id) {
return MMOItems.plugin.getTypes().get(id.toUpperCase().replace("-", "_").replace(" ", "_"));
return isValid(id) ? MMOItems.plugin.getTypes().get(id.toUpperCase().replace("-", "_").replace(" ", "_")) : null;
}
/**
@ -252,7 +252,7 @@ public class Type {
* @return If a registered type with this ID could be found
*/
public static boolean isValid(String id) {
return MMOItems.plugin.getTypes().has(id.toUpperCase().replace("-", "_").replace(" ", "_"));
return id != null && MMOItems.plugin.getTypes().has(id.toUpperCase().replace("-", "_").replace(" ", "_"));
}
public enum EquipmentSlot {

View File

@ -72,7 +72,7 @@ public class Consumable extends UseItem {
* Unidentified items do not have any type, so you must check if the
* item has a type first.
*/
Type targetType = target.getType();
Type targetType = Type.get(target.getType());
if (targetType == null) {
if (getNBTItem().getBoolean("MMOITEMS_CAN_IDENTIFY") && target.hasTag("MMOITEMS_UNIDENTIFIED_ITEM")) {
@ -177,7 +177,7 @@ public class Consumable extends UseItem {
* applying a soulbound onto an item. it does not work if the item
* already has a soulbound, and it has a chance to successfully apply.
*/
double soulbindingChance = getNBTItem().getStat(ItemStats.SOULBINDING_CHANCE);
double soulbindingChance = getNBTItem().getStat(ItemStats.SOULBINDING_CHANCE.getId());
if (soulbindingChance > 0) {
if (target.getItem().getAmount() > 1) {
Message.CANT_BIND_STACKED.format(ChatColor.RED).send(player, "soulbound");
@ -198,7 +198,7 @@ public class Consumable extends UseItem {
if (called.isCancelled())
return false;
int soulboundLevel = (int) Math.max(1, getNBTItem().getStat(ItemStats.SOULBOUND_LEVEL));
int soulboundLevel = (int) Math.max(1, getNBTItem().getStat(ItemStats.SOULBOUND_LEVEL.getId()));
(targetMMO = new LiveMMOItem(target)).setData(ItemStats.SOULBOUND,
((Soulbound) ItemStats.SOULBOUND).newSoulboundData(player.getUniqueId(), player.getName(), soulboundLevel));
target.getItem().setItemMeta(targetMMO.newBuilder().build().getItemMeta());
@ -220,7 +220,7 @@ public class Consumable extends UseItem {
* have at least the soulbound's level to be able to break the item
* soulbound.
*/
double soulboundBreakChance = getNBTItem().getStat(ItemStats.SOULBOUND_BREAK_CHANCE);
double soulboundBreakChance = getNBTItem().getStat(ItemStats.SOULBOUND_BREAK_CHANCE.getId());
if (soulboundBreakChance > 0) {
MMOItem targetMMO = new VolatileMMOItem(target);
if (!targetMMO.hasData(ItemStats.SOULBOUND)) {
@ -232,7 +232,7 @@ public class Consumable extends UseItem {
SoulboundData soulbound = (SoulboundData) targetMMO.getData(ItemStats.SOULBOUND);
// check for soulbound level
if (Math.max(1, getNBTItem().getStat(ItemStats.SOULBOUND_LEVEL)) < soulbound.getLevel()) {
if (Math.max(1, getNBTItem().getStat(ItemStats.SOULBOUND_LEVEL.getId())) < soulbound.getLevel()) {
Message.LOW_SOULBOUND_LEVEL.format(ChatColor.RED, "#level#", MMOUtils.intToRoman(soulbound.getLevel())).send(player, "soulbound");
return false;
}
@ -261,7 +261,7 @@ public class Consumable extends UseItem {
* Item repairing, does not apply if there's no repair power or if the
* item still has all its uses left
*/
int repairPower = (int) getNBTItem().getStat(ItemStats.REPAIR);
int repairPower = (int) getNBTItem().getStat(ItemStats.REPAIR.getId());
if (repairPower > 0) {
// custom durability

View File

@ -52,7 +52,7 @@ public class GemStone extends UseItem {
return new ApplyResult(ResultType.NONE);
// check for success rate
double successRate = getNBTItem().getStat(ItemStats.SUCCESS_RATE);
double successRate = getNBTItem().getStat(ItemStats.SUCCESS_RATE.getId());
if (successRate != 0 && random.nextDouble() > successRate / 100) {
player.playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1, 1);
Message.GEM_STONE_BROKE

View File

@ -54,7 +54,7 @@ public class ItemSkin extends UseItem {
}
// check for success rate
double successRate = getNBTItem().getStat(ItemStats.SUCCESS_RATE);
double successRate = getNBTItem().getStat(ItemStats.SUCCESS_RATE.getId());
if (successRate != 0)
if (random.nextDouble() < 1 - successRate / 100) {
player.playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1, 1);

View File

@ -95,6 +95,10 @@ public class UseItem {
Bukkit.dispatchCommand(player, parsed);
}
public static UseItem getItem(Player player, NBTItem item, String type) {
return getItem(player, item, Type.get(type));
}
public static UseItem getItem(Player player, NBTItem item, Type type) {
if (type.corresponds(Type.CONSUMABLE))
return new Consumable(player, item);

View File

@ -43,7 +43,7 @@ public class Weapon extends UseItem {
if (!isSwing && getPlayerData().isOnCooldown(cooldown))
return false;
double manaCost = getNBTItem().getStat(ItemStats.MANA_COST), staminaCost = getNBTItem().getStat(ItemStats.STAMINA_COST);
double manaCost = getNBTItem().getStat(ItemStats.MANA_COST.getId()), staminaCost = getNBTItem().getStat(ItemStats.STAMINA_COST.getId());
if (manaCost > 0 && playerData.getRPG().getMana() < manaCost) {
Message.NOT_ENOUGH_MANA.format(ChatColor.RED).send(getPlayer(), "not-enough-mana");
@ -69,7 +69,7 @@ public class Weapon extends UseItem {
@SuppressWarnings("UnusedReturnValue")
public ItemAttackResult targetedAttack(CachedStats stats, LivingEntity target, ItemAttackResult result) {
// cooldown
double attackSpeed = getNBTItem().getStat(ItemStats.ATTACK_SPEED);
double attackSpeed = getNBTItem().getStat(ItemStats.ATTACK_SPEED.getId());
attackSpeed = attackSpeed == 0 ? 1.493 : 1 / attackSpeed;
if (!hasEnoughResources(attackSpeed, CooldownType.ATTACK, true))
return result.setSuccessful(false);

View File

@ -42,7 +42,7 @@ public class Crossbow extends UntargetedWeapon {
getPlayer().getWorld().playSound(getPlayer().getLocation(), Sound.ENTITY_ARROW_SHOOT, 1, 1);
Arrow arrow = getPlayer().launchProjectile(Arrow.class);
arrow.setVelocity(getPlayer().getEyeLocation().getDirection().multiply(3 * getValue(getNBTItem().getStat(ItemStats.ARROW_VELOCITY), 1)));
arrow.setVelocity(getPlayer().getEyeLocation().getDirection().multiply(3 * getValue(getNBTItem().getStat(ItemStats.ARROW_VELOCITY.getId()), 1)));
getPlayer().setVelocity(getPlayer().getVelocity().setX(0).setZ(0));
MMOItems.plugin.getEntities().registerCustomProjectile(getNBTItem(), stats.newTemporary(), arrow, true);

View File

@ -42,8 +42,8 @@ public class Lute extends UntargetedWeapon {
durItem.decreaseDurability(1).update();
double attackDamage = getValue(stats.getStat(ItemStats.ATTACK_DAMAGE), 1);
double range = getValue(getNBTItem().getStat(ItemStats.RANGE), MMOItems.plugin.getConfig().getDouble("default.range"));
Vector weight = new Vector(0, -.003 * getNBTItem().getStat(ItemStats.NOTE_WEIGHT), 0);
double range = getValue(getNBTItem().getStat(ItemStats.RANGE.getId()), MMOItems.plugin.getConfig().getDouble("default.range"));
Vector weight = new Vector(0, -.003 * getNBTItem().getStat(ItemStats.NOTE_WEIGHT.getId()), 0);
LuteAttackEffect effect = LuteAttackEffect.get(getNBTItem());
Sound sound = new SoundReader(getNBTItem().getString("MMOITEMS_LUTE_ATTACK_SOUND"), VersionSound.BLOCK_NOTE_BLOCK_BELL.toSound()).getSound();

View File

@ -35,11 +35,11 @@ public class Musket extends UntargetedWeapon {
durItem.decreaseDurability(1).update();
double attackDamage = stats.getStat(ItemStats.ATTACK_DAMAGE);
double range = getValue(getNBTItem().getStat(ItemStats.RANGE), MMOItems.plugin.getConfig().getDouble("default.range"));
double recoil = getValue(getNBTItem().getStat(ItemStats.RECOIL), MMOItems.plugin.getConfig().getDouble("default.recoil"));
double range = getValue(getNBTItem().getStat(ItemStats.RANGE.getId()), MMOItems.plugin.getConfig().getDouble("default.range"));
double recoil = getValue(getNBTItem().getStat(ItemStats.RECOIL.getId()), MMOItems.plugin.getConfig().getDouble("default.recoil"));
// knockback
double knockback = getNBTItem().getStat(ItemStats.KNOCKBACK);
double knockback = getNBTItem().getStat(ItemStats.KNOCKBACK.getId());
if (knockback > 0)
getPlayer().setVelocity(getPlayer().getVelocity().add(getPlayer().getEyeLocation().getDirection().setY(0).normalize().multiply(-1 * knockback).setY(-.2)));

View File

@ -40,7 +40,7 @@ public class Staff extends UntargetedWeapon {
durItem.decreaseDurability(1).update();
double attackDamage = getValue(stats.getStat(ItemStats.ATTACK_DAMAGE), 1);
double range = getValue(getNBTItem().getStat(ItemStats.RANGE), MMOItems.plugin.getConfig().getDouble("default.range"));
double range = getValue(getNBTItem().getStat(ItemStats.RANGE.getId()), MMOItems.plugin.getConfig().getDouble("default.range"));
StaffSpirit spirit = StaffSpirit.get(getNBTItem());
if (spirit != null) {

View File

@ -36,7 +36,7 @@ public class Whip extends UntargetedWeapon {
durItem.decreaseDurability(1).update();
double attackDamage = getValue(stats.getStat(ItemStats.ATTACK_DAMAGE), 1);
double range = getValue(getNBTItem().getStat(ItemStats.RANGE), MMOItems.plugin.getConfig().getDouble("default.range"));
double range = getValue(getNBTItem().getStat(ItemStats.RANGE.getId()), MMOItems.plugin.getConfig().getDouble("default.range"));
double a = Math.toRadians(getPlayer().getEyeLocation().getYaw() + 160);
Location loc = getPlayer().getEyeLocation().add(new Vector(Math.cos(a), 0, Math.sin(a)).multiply(.5));

View File

@ -1,5 +1,6 @@
package net.Indyuce.mmoitems.api.item.mmoitem;
import net.Indyuce.mmoitems.api.Type;
import net.mmogroup.mmolib.api.item.NBTItem;
public abstract class ReadMMOItem extends MMOItem {
@ -13,7 +14,7 @@ public abstract class ReadMMOItem extends MMOItem {
* The NBTItem being read to generate an MMOItem
*/
public ReadMMOItem(NBTItem item) {
super(item.getType(), item.getString("MMOITEMS_ITEM_ID"));
super(Type.get(item.getType()), item.getString("MMOITEMS_ITEM_ID"));
this.item = item;
}

View File

@ -51,7 +51,7 @@ import java.util.Set;
import java.util.UUID;
public class PlayerData {
private static final Map<UUID, PlayerData> data = new HashMap<>();
private final MMOPlayerData mmoData;
/*
@ -87,8 +87,6 @@ public class PlayerData {
private final PlayerStats stats;
private PlayerData(MMOPlayerData mmoData) {
mmoData.setMMOItems(this);
this.mmoData = mmoData;
this.rpgPlayer = MMOItems.plugin.getRPG().getInfo(this);
this.stats = new PlayerStats(this);
@ -106,8 +104,7 @@ public class PlayerData {
if (MMOItems.plugin.hasVault()) {
Permission perms = MMOItems.plugin.getVault().getPermissions();
permissions.forEach(perm -> {
if (perms.has(getPlayer(), perm))
perms.playerRemove(getPlayer(), perm);
if (perms.has(getPlayer(), perm)) perms.playerRemove(getPlayer(), perm);
});
}
cancelRunnables();
@ -150,8 +147,7 @@ public class PlayerData {
public void checkForInventoryUpdate() {
if (!mmoData.isOnline()) return;
PlayerInventory inv = getPlayer().getInventory();
if (!equals(helmet, inv.getHelmet()) || !equals(chestplate, inv.getChestplate()) || !equals(leggings, inv.getLeggings())
|| !equals(boots, inv.getBoots()) || !equals(hand, inv.getItemInMainHand()) || !equals(offhand, inv.getItemInOffHand()))
if (isNotSame(helmet, inv.getHelmet()) || isNotSame(chestplate, inv.getChestplate()) || isNotSame(leggings, inv.getLeggings()) || isNotSame(boots, inv.getBoots()) || isNotSame(hand, inv.getItemInMainHand()) || isNotSame(offhand, inv.getItemInOffHand()))
updateInventory();
}
@ -159,14 +155,13 @@ public class PlayerData {
Bukkit.getScheduler().scheduleSyncDelayedTask(MMOItems.plugin, this::updateInventory);
}
private boolean equals(ItemStack item, ItemStack item1) {
return Objects.equals(item, item1);
private boolean isNotSame(ItemStack item, ItemStack item1) {
return !Objects.equals(item, item1);
}
public void cancelRunnables() {
itemParticles.forEach(BukkitRunnable::cancel);
if (overridingItemParticles != null)
overridingItemParticles.cancel();
if (overridingItemParticles != null) overridingItemParticles.cancel();
}
/*
@ -177,8 +172,7 @@ public class PlayerData {
if (!mmoData.isOnline()) return false;
NBTItem main = MMOLib.plugin.getVersion().getWrapper().getNBTItem(getPlayer().getInventory().getItemInMainHand());
NBTItem off = MMOLib.plugin.getVersion().getWrapper().getNBTItem(getPlayer().getInventory().getItemInOffHand());
return (main.getBoolean("MMOITEMS_TWO_HANDED") && (off.getItem() != null && off.getItem().getType() != Material.AIR))
|| (off.getBoolean("MMOITEMS_TWO_HANDED") && (main.getItem() != null && main.getItem().getType() != Material.AIR));
return (main.getBoolean("MMOITEMS_TWO_HANDED") && (off.getItem() != null && off.getItem().getType() != Material.AIR)) || (off.getBoolean("MMOITEMS_TWO_HANDED") && (main.getItem() != null && main.getItem().getType() != Material.AIR));
}
public void updateInventory() {
@ -196,8 +190,7 @@ public class PlayerData {
if (MMOItems.plugin.hasVault()) {
Permission perms = MMOItems.plugin.getVault().getPermissions();
permissions.forEach(perm -> {
if (perms.has(getPlayer(), perm))
perms.playerRemove(getPlayer(), perm);
if (perms.has(getPlayer(), perm)) perms.playerRemove(getPlayer(), perm);
});
}
permissions.clear();
@ -212,20 +205,17 @@ public class PlayerData {
for (EquippedItem item : MMOItems.plugin.getInventory().getInventory(getPlayer())) {
NBTItem nbtItem = item.newNBTItem();
Type type = nbtItem.getType();
if (type == null)
continue;
Type type = Type.get(nbtItem.getType());
if (type == null) continue;
/*
* if the player is holding an item the wrong way i.e if the item is
* not in the right slot. intuitive methods with small exceptions
* like BOTH_HANDS and ANY
*/
if (!item.matches(type))
continue;
if (!item.matches(type)) continue;
if (!getRPG().canUse(nbtItem, false))
continue;
if (!getRPG().canUse(nbtItem, false)) continue;
playerInventory.add(new VolatileMMOItem(nbtItem));
}
@ -248,10 +238,8 @@ public class PlayerData {
ParticleData particleData = (ParticleData) item.getData(ItemStats.ITEM_PARTICLES);
if (particleData.getType().hasPriority()) {
if (overridingItemParticles == null)
overridingItemParticles = particleData.start(this);
} else
itemParticles.add(particleData.start(this));
if (overridingItemParticles == null) overridingItemParticles = particleData.start(this);
} else itemParticles.add(particleData.start(this));
}
/*
@ -261,11 +249,9 @@ public class PlayerData {
// if the item with the abilities is in the players offhand AND
// its disabled in the config then just move on, else add the
// ability
if (item.getNBT().getItem().equals(getPlayer().getInventory().getItemInOffHand())
&& MMOItems.plugin.getConfig().getBoolean("disable-abilities-in-offhand")) {
if (item.getNBT().getItem().equals(getPlayer().getInventory().getItemInOffHand()) && MMOItems.plugin.getConfig().getBoolean("disable-abilities-in-offhand")) {
continue;
} else
itemAbilities.addAll(((AbilityListData) item.getData(ItemStats.ABILITIES)).getAbilities());
} else itemAbilities.addAll(((AbilityListData) item.getData(ItemStats.ABILITIES)).getAbilities());
}
/*
@ -285,8 +271,7 @@ public class PlayerData {
for (VolatileMMOItem item : getMMOItems()) {
String tag = item.getNBT().getString("MMOITEMS_ITEM_SET");
ItemSet itemSet = MMOItems.plugin.getSets().get(tag);
if (itemSet == null)
continue;
if (itemSet == null) continue;
int nextInt = (sets.getOrDefault(itemSet, 0)) + 1;
sets.put(itemSet, nextInt);
@ -341,8 +326,7 @@ public class PlayerData {
if (MMOItems.plugin.hasVault()) {
Permission perms = MMOItems.plugin.getVault().getPermissions();
permissions.forEach(perm -> {
if (!perms.has(getPlayer(), perm))
perms.playerAdd(getPlayer(), perm);
if (!perms.has(getPlayer(), perm)) perms.playerAdd(getPlayer(), perm);
});
}
}
@ -381,8 +365,7 @@ public class PlayerData {
private boolean hasAbility(CastingMode castMode) {
for (AbilityData ability : itemAbilities)
if (ability.getCastingMode() == castMode)
return true;
if (ability.getCastingMode() == castMode) return true;
return false;
}
@ -393,8 +376,7 @@ public class PlayerData {
* performance improvement, do not cache the player stats into a
* CachedStats if the player has no ability on that cast mode
*/
if (!hasAbility(castMode))
return result;
if (!hasAbility(castMode)) return result;
return castAbilities(getStats().newTemporary(), target, result, castMode);
}
@ -407,14 +389,11 @@ public class PlayerData {
* and make sure player can attack target. if ability has no target,
* check for WG flag at the caster location
*/
if (target == null ? !MMOItems.plugin.getFlags().isFlagAllowed(getPlayer(), CustomFlag.MI_ABILITIES)
: !MMOItems.plugin.getFlags().isFlagAllowed(target.getLocation(), CustomFlag.MI_ABILITIES)
|| !MMOUtils.canDamage(getPlayer(), target))
if (target == null ? !MMOItems.plugin.getFlags().isFlagAllowed(getPlayer(), CustomFlag.MI_ABILITIES) : !MMOItems.plugin.getFlags().isFlagAllowed(target.getLocation(), CustomFlag.MI_ABILITIES) || !MMOUtils.canDamage(getPlayer(), target))
return result.setSuccessful(false);
for (AbilityData ability : itemAbilities)
if (ability.getCastingMode() == castMode)
cast(stats, target, result, ability);
if (ability.getCastingMode() == castMode) cast(stats, target, result, ability);
return result;
}
@ -436,31 +415,25 @@ public class PlayerData {
public void cast(CachedStats stats, LivingEntity target, ItemAttackResult attack, AbilityData ability) {
AbilityUseEvent event = new AbilityUseEvent(this, ability, target);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled())
return;
if (event.isCancelled()) return;
if (!rpgPlayer.canCast(ability))
return;
if (!rpgPlayer.canCast(ability)) return;
/*
* check if ability can be cast (custom conditions)
*/
AbilityResult abilityResult = ability.getAbility().whenRan(stats, target, ability, attack);
if (!abilityResult.isSuccessful())
return;
if (!abilityResult.isSuccessful()) return;
/*
* the player can cast the ability, and it was successfully cast on its
* target, removes resources needed from the player
*/
if (ability.hasModifier("mana"))
rpgPlayer.giveMana(-abilityResult.getModifier("mana"));
if (ability.hasModifier("stamina"))
rpgPlayer.giveStamina(-abilityResult.getModifier("stamina"));
if (ability.hasModifier("mana")) rpgPlayer.giveMana(-abilityResult.getModifier("mana"));
if (ability.hasModifier("stamina")) rpgPlayer.giveStamina(-abilityResult.getModifier("stamina"));
double cooldown = abilityResult.getModifier("cooldown") * (1 - Math.min(.8, stats.getStat(ItemStats.COOLDOWN_REDUCTION) / 100));
if (cooldown > 0)
applyAbilityCooldown(ability.getAbility(), cooldown);
if (cooldown > 0) applyAbilityCooldown(ability.getAbility(), cooldown);
/*
* finally cast the ability (BUG FIX) cooldown MUST be applied BEFORE
@ -524,7 +497,8 @@ public class PlayerData {
}
public static PlayerData get(UUID uuid) {
return MMOPlayerData.get(uuid).getMMOItems();
if (PlayerData.data.containsKey(uuid)) return data.get(uuid);
return new PlayerData(MMOPlayerData.get(uuid));
}
/*
@ -532,28 +506,23 @@ public class PlayerData {
* initialized
*/
public static void load(Player player) {
/*
* Double check they are online, for some reason even if this is fired
* from the join event the player can be offline if they left in the same tick or something.
*/
if (!player.isOnline())
return;
MMOPlayerData mmoData = MMOPlayerData.get(player.getUniqueId());
if (!player.isOnline() || data.containsKey(player.getUniqueId())) return;
PlayerData newData = PlayerData.get(player.getUniqueId());
/*
* if no mmoitems data could be found, it must be initialized
*/
if (mmoData.getMMOItems() == null)
mmoData.setMMOItems(new PlayerData(mmoData));
/*
* otherwise just update the cached RPGPlayer in case of any major
* update the cached RPGPlayer in case of any major
* change in the player data of other rpg plugins
*/
else
mmoData.getMMOItems().rpgPlayer = MMOItems.plugin.getRPG().getInfo(mmoData.getMMOItems());
newData.rpgPlayer = MMOItems.plugin.getRPG().getInfo(newData);
/* cache the playerdata */
data.put(player.getUniqueId(), newData);
}
public static Collection<PlayerData> getLoaded() {
return data.values();
}
public enum CooldownType {

View File

@ -1,11 +1,11 @@
package net.Indyuce.mmoitems.api.util.message;
import net.Indyuce.mmocore.api.player.PlayerData;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmoitems.MMOItems;
import net.mmogroup.mmolib.MMOLib;

View File

@ -1,5 +1,6 @@
package net.Indyuce.mmoitems.command.item;
import net.Indyuce.mmoitems.api.Type;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -33,7 +34,7 @@ public class UnidentifyCommandTreeNode extends CommandTreeNode {
return CommandResult.FAILURE;
}
player.getInventory().setItemInMainHand(item.getType().getUnidentifiedTemplate().newBuilder(item).build());
player.getInventory().setItemInMainHand(Type.get(item.getType()).getUnidentifiedTemplate().newBuilder(item).build());
sender.sendMessage(MMOItems.plugin.getPrefix() + "Successfully unidentified the item you are holding.");
return CommandResult.SUCCESS;
}

View File

@ -3,6 +3,7 @@ package net.Indyuce.mmoitems.comp.inventory;
import java.util.ArrayList;
import java.util.List;
import net.Indyuce.mmoitems.api.Type;
import org.bukkit.Bukkit;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
@ -34,7 +35,7 @@ public class OrnamentPlayerInventory implements PlayerInventory, Listener {
for (ItemStack item : player.getInventory().getContents()) {
NBTItem nbtItem;
if (item != null && (nbtItem = MMOLib.plugin.getVersion().getWrapper().getNBTItem(item)).hasType() && nbtItem.getType().getEquipmentType() == EquipmentSlot.ANY)
if (item != null && (nbtItem = MMOLib.plugin.getVersion().getWrapper().getNBTItem(item)).hasType() && Type.get(nbtItem.getType()).getEquipmentType() == EquipmentSlot.ANY)
list.add(new EquippedItem(nbtItem, EquipmentSlot.ANY));
}
@ -45,7 +46,7 @@ public class OrnamentPlayerInventory implements PlayerInventory, Listener {
public void a(EntityPickupItemEvent event) {
if (event.getEntityType() == EntityType.PLAYER) {
NBTItem nbt = NBTItem.get(event.getItem().getItemStack());
if (nbt.hasType() && nbt.getType().getEquipmentType() == EquipmentSlot.ANY)
if (nbt.hasType() && Type.get(nbt.getType()).getEquipmentType() == EquipmentSlot.ANY)
PlayerData.get((Player) event.getEntity()).updateInventory();
}
}
@ -53,7 +54,7 @@ public class OrnamentPlayerInventory implements PlayerInventory, Listener {
@EventHandler(ignoreCancelled = true)
public void b(PlayerDropItemEvent event) {
NBTItem nbt = NBTItem.get(event.getItemDrop().getItemStack());
if (nbt.hasType() && nbt.getType().getEquipmentType() == EquipmentSlot.ANY)
if (nbt.hasType() && Type.get(nbt.getType()).getEquipmentType() == EquipmentSlot.ANY)
PlayerData.get(event.getPlayer()).updateInventory();
}
}

View File

@ -3,6 +3,7 @@ package net.Indyuce.mmoitems.comp.inventory;
import java.util.ArrayList;
import java.util.List;
import net.Indyuce.mmoitems.api.Type;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -48,7 +49,7 @@ public class RPGInventoryHook implements PlayerInventory, Listener {
if (ornaments)
for (ItemStack item : player.getInventory().getContents()) {
NBTItem nbtItem;
if (item != null && (nbtItem = MMOLib.plugin.getVersion().getWrapper().getNBTItem(item)).hasType() && nbtItem.getType().getEquipmentType() == EquipmentSlot.ANY)
if (item != null && (nbtItem = MMOLib.plugin.getVersion().getWrapper().getNBTItem(item)).hasType() && Type.get(nbtItem.getType()).getEquipmentType() == EquipmentSlot.ANY)
list.add(new EquippedItem(nbtItem, EquipmentSlot.ANY));
}

View File

@ -17,12 +17,8 @@ import net.Indyuce.mmoitems.comp.mmocore.stat.Required_Attribute;
import net.Indyuce.mmoitems.comp.rpg.RPGHandler;
public class MMOCoreHook implements RPGHandler, Listener {
/*
* called when MMOItems enables
*/
/* called when MMOItems enables */
public MMOCoreHook() {
/*
* only works when the server is reloaded. needs /reload when changing
* attributes or professions to refresh MMOItems stats
@ -63,7 +59,7 @@ public class MMOCoreHook implements RPGHandler, Listener {
public MMOCoreRPGPlayer(net.Indyuce.mmoitems.api.player.PlayerData playerData) {
super(playerData);
data = playerData.getMMOPlayerData().getMMOCore();
data = PlayerData.get(playerData.getUniqueId());
}
public PlayerData getData() {

View File

@ -1,6 +1,7 @@
package net.Indyuce.mmoitems.comp.mmocore.load;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.api.player.PlayerData;
import org.apache.commons.lang.Validate;
import org.bukkit.inventory.ItemStack;
@ -32,7 +33,7 @@ public class ItemTemplateDropItem extends ItemGenerationDropItem {
@Override
public void collect(LootBuilder builder) {
RPGPlayer rpgPlayer = builder.getEntity().getMMOPlayerData().getMMOItems().getRPG();
RPGPlayer rpgPlayer = PlayerData.get(builder.getEntity().getUniqueId()).getRPG();
MMOItem mmoitem = rollMMOItem(template, rpgPlayer);
if (rollSoulbound())

View File

@ -1,8 +1,5 @@
package net.Indyuce.mmoitems.comp.mmocore.load;
import org.apache.commons.lang.Validate;
import org.bukkit.inventory.ItemStack;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.quest.trigger.Trigger;
import net.Indyuce.mmoitems.MMOItems;
@ -10,6 +7,8 @@ import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
import net.mmogroup.mmolib.api.MMOLineConfig;
import net.mmogroup.mmolib.api.util.SmartGive;
import org.apache.commons.lang.Validate;
import org.bukkit.inventory.ItemStack;
public class MMOItemTrigger extends Trigger {
private final MMOItemTemplate template;
@ -33,7 +32,7 @@ public class MMOItemTrigger extends Trigger {
@Override
public void apply(PlayerData player) {
ItemStack item = template.newBuilder(player.getMMOPlayerData().getMMOItems().getRPG()).build().newBuilder().build();
ItemStack item = template.newBuilder(net.Indyuce.mmoitems.api.player.PlayerData.get(player.getUniqueId()).getRPG()).build().newBuilder().build();
item.setAmount(amount);
new SmartGive(player.getPlayer()).give(item);
}

View File

@ -3,6 +3,7 @@ package net.Indyuce.mmoitems.comp.mmocore.load;
import java.util.Optional;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.api.player.PlayerData;
import org.apache.commons.lang.Validate;
import org.bukkit.inventory.ItemStack;
@ -41,7 +42,7 @@ public class RandomItemDropItem extends ItemGenerationDropItem {
@Override
public void collect(LootBuilder builder) {
RPGPlayer rpgPlayer = builder.getEntity().getMMOPlayerData().getMMOItems().getRPG();
RPGPlayer rpgPlayer = PlayerData.get(builder.getEntity().getUniqueId()).getRPG();
TemplateExplorer explorer = new TemplateExplorer();
if (matchClass)

View File

@ -24,7 +24,7 @@ public class Required_Attribute extends DoubleStat implements ItemRestriction, G
@Override
public boolean canUse(RPGPlayer player, NBTItem item, boolean message) {
MMOCoreRPGPlayer mmocore = (MMOCoreRPGPlayer) player;
if (mmocore.getData().getAttributes().getAttribute(attribute) < item.getStat(this)) {
if (mmocore.getData().getAttributes().getAttribute(attribute) < item.getStat(getId())) {
if (message) {
new AddonMessage("not-enough-attribute").format(ChatColor.RED, "#attribute#", attribute.getName()).send(player.getPlayer(), "cant-use-item");
player.getPlayer().playSound(player.getPlayer().getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1.5f);

View File

@ -24,7 +24,7 @@ public class Required_Profession extends DoubleStat implements ItemRestriction,
@Override
public boolean canUse(RPGPlayer player, NBTItem item, boolean message) {
MMOCoreHook.MMOCoreRPGPlayer mmocore = (MMOCoreHook.MMOCoreRPGPlayer) player;
if (mmocore.getData().getCollectionSkills().getLevel(this.profession) < item.getStat(this)) {
if (mmocore.getData().getCollectionSkills().getLevel(this.profession) < item.getStat(getId())) {
if (message) {
new AddonMessage("not-enough-profession").format(ChatColor.RED, "#profession#", profession.getName()).send(player.getPlayer(), "cant-use-item");
player.getPlayer().playSound(player.getPlayer().getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1.5f);

View File

@ -131,7 +131,7 @@ public class ItemUse implements Listener {
NBTItem offhandItem = MMOLib.plugin.getVersion().getWrapper().getNBTItem(player.getInventory().getItemInOffHand());
ItemAttackResult result = new ItemAttackResult(event.getDamage(), DamageType.WEAPON, DamageType.PHYSICAL);
if (item.hasType() && item.getType() != Type.BLOCK) {
if (item.hasType() && Type.get(item.getType()) != Type.BLOCK) {
Weapon weapon = new Weapon(playerData, item);
if (weapon.getMMOItem().getType().getItemSet() == TypeSet.RANGE) {
@ -150,7 +150,7 @@ public class ItemUse implements Listener {
return;
}
}
if (offhandItem.hasType() && item.getType() != Type.BLOCK) {
if (offhandItem.hasType() && Type.get(item.getType()) != Type.BLOCK) {
Weapon weapon = new Weapon(playerData, offhandItem);
if (weapon.getMMOItem().getType().getItemSet() == TypeSet.RANGE) {
@ -239,7 +239,7 @@ public class ItemUse implements Listener {
if (!picked.hasType())
return;
ItemSkin.ApplyResult result = ((ItemSkin) useItem).applyOntoItem(picked, picked.getType());
ItemSkin.ApplyResult result = ((ItemSkin) useItem).applyOntoItem(picked, Type.get(picked.getType()));
if (result.getType() == ItemSkin.ResultType.NONE)
return;
@ -257,7 +257,7 @@ public class ItemUse implements Listener {
if (!picked.hasType())
return;
GemStone.ApplyResult result = ((GemStone) useItem).applyOntoItem(picked, picked.getType());
GemStone.ApplyResult result = ((GemStone) useItem).applyOntoItem(picked, Type.get(picked.getType()));
if (result.getType() == GemStone.ResultType.NONE)
return;
@ -283,7 +283,7 @@ public class ItemUse implements Listener {
return;
NBTItem item = MMOLib.plugin.getVersion().getWrapper().getNBTItem(event.getBow());
Type type = item.getType();
Type type = Type.get(item.getType());
PlayerData playerData = PlayerData.get((Player) event.getEntity());
if (type != null)
@ -293,8 +293,8 @@ public class ItemUse implements Listener {
}
Arrow arrow = (Arrow) event.getProjectile();
if (!(item.getStat(ItemStats.ARROW_VELOCITY) <= 0))
arrow.setVelocity(arrow.getVelocity().multiply(1 + (item.getStat(ItemStats.ARROW_VELOCITY) / 2)));
if (!(item.getStat(ItemStats.ARROW_VELOCITY.getId()) <= 0))
arrow.setVelocity(arrow.getVelocity().multiply(1 + (item.getStat(ItemStats.ARROW_VELOCITY.getId()) / 2)));
MMOItems.plugin.getEntities().registerCustomProjectile(item, playerData.getStats().newTemporary(), event.getProjectile(),
type != null, event.getForce());
}
@ -324,7 +324,7 @@ public class ItemUse implements Listener {
return;
}
useItem.getPlayerData().applyItemCooldown(useItem.getMMOItem().getId(), useItem.getNBTItem().getStat(ItemStats.ITEM_COOLDOWN));
useItem.getPlayerData().applyItemCooldown(useItem.getMMOItem().getId(), useItem.getNBTItem().getStat(ItemStats.ITEM_COOLDOWN.getId()));
useItem.executeCommands();
}
}

View File

@ -0,0 +1,115 @@
package net.Indyuce.mmoitems.listener;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.ItemTier;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.Particle;
import org.bukkit.entity.Item;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicMobDeathEvent;
import net.mmogroup.mmolib.MMOLib;
import net.mmogroup.mmolib.api.item.NBTItem;
public class LootsplosionListener implements Listener {
private static final Random random = new Random();
private final boolean colored;
public LootsplosionListener() {
colored = Bukkit.getPluginManager().getPlugin("MMOItems") != null
&& MMOItems.plugin.getConfig().getBoolean("lootsplosion.show-color");
}
@EventHandler(priority = EventPriority.HIGH)
public void b(MythicMobDeathEvent event) {
if (event.getMob().getVariables().has("Lootsplosion"))
new LootsplosionHandler(event);
}
public class LootsplosionHandler implements Listener {
private final List<ItemStack> drops;
/*
* Y coordinate offset so the velocity is not directly negated when the
* item spawns on the ground
*/
private final double offset;
public LootsplosionHandler(MythicMobDeathEvent event) {
offset = event.getEntity().getHeight() / 2;
drops = new ArrayList<>(event.getDrops());
Bukkit.getPluginManager().registerEvents(this, MMOItems.plugin);
}
private void close() {
ItemSpawnEvent.getHandlerList().unregister(this);
}
@EventHandler
public void a(ItemSpawnEvent event) {
Item item = event.getEntity();
if (!drops.contains(item.getItemStack())) {
close();
return;
}
drops.remove(item.getItemStack());
item.teleport(item.getLocation().add(0, offset, 0));
item.setVelocity(randomVector());
if (colored)
Bukkit.getScheduler().runTask(MMOItems.plugin, () -> {
NBTItem nbt = MMOLib.plugin.getVersion().getWrapper().getNBTItem(item.getItemStack());
if (nbt.hasTag("MMOITEMS_TIER")) {
ItemTier tier = MMOItems.plugin.getTiers().get(nbt.getString("MMOITEMS_TIER"));
if (tier.hasColor())
new LootColor(item, tier.getColor().toBukkit());
}
});
}
}
private Vector randomVector() {
double offset = MMOItems.plugin.getConfig().getDouble("lootsplosion.offset"),
height = MMOItems.plugin.getConfig().getDouble("lootsplosion.height");
return new Vector(Math.cos(random.nextDouble() * Math.PI * 2) * offset, height, Math.sin(random.nextDouble() * Math.PI * 2) * offset);
}
public static class LootColor extends BukkitRunnable {
private final Item item;
private final Color color;
private int j = 0;
public LootColor(Item item, Color color) {
this.item = item;
this.color = color;
runTaskTimer(MMOItems.plugin, 0, 1);
}
@Override
public void run() {
if (j++ > 100 || item.isDead() || item.isOnGround()) {
cancel();
return;
}
item.getWorld().spawnParticle(Particle.REDSTONE, item.getLocation(), 1, new Particle.DustOptions(color, 1.3f));
}
}
}

View File

@ -120,7 +120,7 @@ public class PlayerListener implements Listener {
return;
NBTItem nbtItem = MMOLib.plugin.getVersion().getWrapper().getNBTItem(item.getItem());
Type type = nbtItem.getType();
Type type = Type.get(nbtItem.getType());
PlayerData playerData = PlayerData.get((Player) event.getEntity().getShooter());
if (type != null && !new Weapon(playerData, nbtItem).canBeUsed()) {

View File

@ -1,6 +1,5 @@
package net.Indyuce.mmoitems.manager;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.ConfigFile;
@ -270,7 +269,7 @@ public class ConfigManager implements Reloadable {
File folder = new File(MMOItems.plugin.getDataFolder() + "/" + path);
if (!folder.exists())
if(!folder.mkdir())
MMOCore.log(Level.WARNING, "Could not create directory!");
MMOItems.plugin.getLogger().log(Level.WARNING, "Could not create directory!");
}
/*

View File

@ -39,7 +39,7 @@ public class TemplateManager implements Reloadable {
}
public boolean hasTemplate(NBTItem nbt) {
return hasTemplate(nbt.getType(), nbt.getString("MMOITEMS_ITEM_ID"));
return hasTemplate(Type.get(nbt.getType()), nbt.getString("MMOITEMS_ITEM_ID"));
}
public MMOItemTemplate getTemplate(Type type, String id) {
@ -47,7 +47,7 @@ public class TemplateManager implements Reloadable {
}
public MMOItemTemplate getTemplate(NBTItem nbt) {
return getTemplate(nbt.getType(), nbt.getString("MMOITEMS_ITEM_ID"));
return getTemplate(Type.get(nbt.getType()), nbt.getString("MMOITEMS_ITEM_ID"));
}
/**

View File

@ -3,7 +3,6 @@ package net.Indyuce.mmoitems.manager;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
import net.Indyuce.mmoitems.api.item.mmoitem.VolatileMMOItem;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
import net.Indyuce.mmoitems.api.player.PlayerData;
import net.mmogroup.mmolib.MMOLib;
@ -44,12 +43,10 @@ public class UpdaterManager implements Listener {
@EventHandler
public void updateOnClick(InventoryClickEvent event) {
ItemStack item = event.getCurrentItem();
if (item == null || item.getType() == Material.AIR)
return;
if (item == null || item.getType() == Material.AIR) return;
ItemStack newItem = getUpdated(item, (Player) event.getWhoClicked());
if (!newItem.equals(item))
event.setCurrentItem(newItem);
if (!newItem.equals(item)) event.setCurrentItem(newItem);
}
/**
@ -79,9 +76,8 @@ public class UpdaterManager implements Listener {
* If the item type is null, then it is not an mmoitem and it does not
* need to be updated
*/
Type type = item.getType();
if (type == null)
return item.getItem();
Type type = Type.get(item.getType());
if (type == null) return item.getItem();
/*
* check the internal UUID of the item, if it does not make the one
@ -100,7 +96,7 @@ public class UpdaterManager implements Listener {
* apply older gem stones, using a light MMOItem so the item does not
* calculate every stat data from the older item.
*/
MMOItem volatileItem = new VolatileMMOItem(item);
//MMOItem volatileItem = new VolatileMMOItem(item);
/*if (did.hasOption(KeepOption.KEEP_GEMS) && volatileItem.hasData(ItemStats.GEM_SOCKETS))
newMMOItem.replaceData(ItemStats.GEM_SOCKETS, volatileItem.getData(ItemStats.GEM_SOCKETS));
@ -131,8 +127,7 @@ public class UpdaterManager implements Listener {
//if (did.hasOption(KeepOption.KEEP_LORE)) {
int n = 0;
for (String s : item.getItem().getItemMeta().getLore()) {
if (!s.startsWith(ChatColor.GRAY + ""))
break;
if (!s.startsWith(ChatColor.GRAY + "")) break;
lore.add(n++, s);
}
//}
@ -157,8 +152,7 @@ public class UpdaterManager implements Listener {
}
public enum KeepOption {
KEEP_LORE("Any lore line starting with '&7' will be", "kept when updating your item.", "", "This option is supposed to keep",
"the item custom enchants.", ChatColor.RED + "May not support every enchant plugin."),
KEEP_LORE("Any lore line starting with '&7' will be", "kept when updating your item.", "", "This option is supposed to keep", "the item custom enchants.", ChatColor.RED + "May not support every enchant plugin."),
KEEP_ENCHANTS("The item keeps its old enchantments."),
KEEP_DURABILITY("The item keeps its durability.", "Don't use this option if you", "are using texture-by-durability!"),
KEEP_NAME("The item keeps its display name."),

View File

@ -8,7 +8,7 @@
# a Spigot Plugin by Team Requiem
# DO NOT TOUCH
config-version: 4
config-version: 5
# Notifies players with the 'mmoitems.update-notify' perm node when
# they join the server if a new update is available for download.
@ -275,6 +275,15 @@ item-revision:
click: false
join: false
# Offset is the distance traveled on X and Y coordinates
# Height is the Y velocity coordinate. Lootsplosions
# only trigger with MythicMobs monsters.
# Requires a SERVER reload when changed.
lootsplosion:
enabled: true
color: true
offset: .2
height: .6
# When I was a kid, I saw the Mona Lisa in my school art book...
# The fist time I saw her, with her hands on her knee... how do I say this...