mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2025-01-05 06:57:35 +01:00
> 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:
parent
502563bbc0
commit
7402b572ab
59
pom.xml
59
pom.xml
@ -4,7 +4,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>net.Indyuce</groupId>
|
<groupId>net.Indyuce</groupId>
|
||||||
<artifactId>MMOItems</artifactId>
|
<artifactId>MMOItems</artifactId>
|
||||||
<version>6.4</version>
|
<version>6.5</version>
|
||||||
<name>MMOItems</name>
|
<name>MMOItems</name>
|
||||||
<description>A great item solution for your RPG server.</description>
|
<description>A great item solution for your RPG server.</description>
|
||||||
|
|
||||||
@ -47,32 +47,6 @@
|
|||||||
<encoding>UTF-8</encoding>
|
<encoding>UTF-8</encoding>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</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>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
<repositories>
|
<repositories>
|
||||||
@ -94,23 +68,6 @@
|
|||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
<dependencies>
|
<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 -->
|
<!-- Minecraft -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mojang</groupId>
|
<groupId>com.mojang</groupId>
|
||||||
@ -125,6 +82,20 @@
|
|||||||
<systemPath>${basedir}/lib/spigot.jar</systemPath>
|
<systemPath>${basedir}/lib/spigot.jar</systemPath>
|
||||||
</dependency>
|
</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 -->
|
<!-- APIs -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jetbrains</groupId>
|
<groupId>org.jetbrains</groupId>
|
||||||
|
@ -50,6 +50,7 @@ import net.Indyuce.mmoitems.listener.DurabilityListener;
|
|||||||
import net.Indyuce.mmoitems.listener.ElementListener;
|
import net.Indyuce.mmoitems.listener.ElementListener;
|
||||||
import net.Indyuce.mmoitems.listener.ItemListener;
|
import net.Indyuce.mmoitems.listener.ItemListener;
|
||||||
import net.Indyuce.mmoitems.listener.ItemUse;
|
import net.Indyuce.mmoitems.listener.ItemUse;
|
||||||
|
import net.Indyuce.mmoitems.listener.LootsplosionListener;
|
||||||
import net.Indyuce.mmoitems.listener.PlayerListener;
|
import net.Indyuce.mmoitems.listener.PlayerListener;
|
||||||
import net.Indyuce.mmoitems.manager.AbilityManager;
|
import net.Indyuce.mmoitems.manager.AbilityManager;
|
||||||
import net.Indyuce.mmoitems.manager.BlockManager;
|
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.TypeManager;
|
||||||
import net.Indyuce.mmoitems.manager.UpgradeManager;
|
import net.Indyuce.mmoitems.manager.UpgradeManager;
|
||||||
import net.Indyuce.mmoitems.manager.WorldGenManager;
|
import net.Indyuce.mmoitems.manager.WorldGenManager;
|
||||||
import net.mmogroup.mmolib.api.player.MMOPlayerData;
|
|
||||||
import net.mmogroup.mmolib.version.SpigotPlugin;
|
import net.mmogroup.mmolib.version.SpigotPlugin;
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -120,16 +120,14 @@ public class MMOItems extends JavaPlugin {
|
|||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
plugin = this;
|
plugin = this;
|
||||||
|
|
||||||
if (getServer().getPluginManager().getPlugin("WorldGuard") != null)
|
if (getServer().getPluginManager().getPlugin("WorldGuard") != null) try {
|
||||||
try {
|
|
||||||
flagPlugin = new WorldGuardFlags();
|
flagPlugin = new WorldGuardFlags();
|
||||||
getLogger().log(Level.INFO, "Hooked onto WorldGuard");
|
getLogger().log(Level.INFO, "Hooked onto WorldGuard");
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
getLogger().log(Level.WARNING, "Could not initialize support with WorldGuard 7: " + exception.getMessage());
|
getLogger().log(Level.WARNING, "Could not initialize support with WorldGuard 7: " + exception.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getServer().getPluginManager().getPlugin("WorldEdit") != null)
|
if (getServer().getPluginManager().getPlugin("WorldEdit") != null) try {
|
||||||
try {
|
|
||||||
new WorldEditSupport();
|
new WorldEditSupport();
|
||||||
getLogger().log(Level.INFO, "Hooked onto WorldEdit");
|
getLogger().log(Level.INFO, "Hooked onto WorldEdit");
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
@ -146,8 +144,7 @@ public class MMOItems extends JavaPlugin {
|
|||||||
typeManager.reload();
|
typeManager.reload();
|
||||||
templateManager.preloadTemplates();
|
templateManager.preloadTemplates();
|
||||||
|
|
||||||
if (Bukkit.getPluginManager().getPlugin("MMOCore") != null)
|
if (Bukkit.getPluginManager().getPlugin("MMOCore") != null) new MMOCoreMMOLoader();
|
||||||
new MMOCoreMMOLoader();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
@ -191,8 +188,7 @@ public class MMOItems extends JavaPlugin {
|
|||||||
worldGenManager = new WorldGenManager();
|
worldGenManager = new WorldGenManager();
|
||||||
blockManager = new BlockManager();
|
blockManager = new BlockManager();
|
||||||
|
|
||||||
if (Bukkit.getPluginManager().getPlugin("Vault") != null)
|
if (Bukkit.getPluginManager().getPlugin("Vault") != null) vaultSupport = new VaultSupport();
|
||||||
vaultSupport = new VaultSupport();
|
|
||||||
|
|
||||||
getLogger().log(Level.INFO, "Loading crafting stations, please wait..");
|
getLogger().log(Level.INFO, "Loading crafting stations, please wait..");
|
||||||
layoutManager.reload();
|
layoutManager.reload();
|
||||||
@ -209,6 +205,8 @@ public class MMOItems extends JavaPlugin {
|
|||||||
Bukkit.getPluginManager().registerEvents(new GuiListener(), this);
|
Bukkit.getPluginManager().registerEvents(new GuiListener(), this);
|
||||||
Bukkit.getPluginManager().registerEvents(new ElementListener(), this);
|
Bukkit.getPluginManager().registerEvents(new ElementListener(), this);
|
||||||
Bukkit.getPluginManager().registerEvents(new CustomBlockListener(), 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
|
* 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) {
|
if (Bukkit.getPluginManager().getPlugin("GlowAPI") != null && Bukkit.getPluginManager().getPlugin("PacketListenerApi") != null) {
|
||||||
Bukkit.getPluginManager().registerEvents(new ItemGlowListener(), this);
|
Bukkit.getPluginManager().registerEvents(new ItemGlowListener(), this);
|
||||||
getLogger().log(Level.INFO, "Hooked onto GlowAPI (Item Glow)");
|
getLogger().log(Level.INFO, "Hooked onto GlowAPI (Item Glow)");
|
||||||
} else
|
} else Bukkit.getPluginManager().registerEvents(new NoGlowListener(), this);
|
||||||
Bukkit.getPluginManager().registerEvents(new NoGlowListener(), this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Bukkit.getPluginManager().getPlugin("RealDualWield") != null) {
|
if (Bukkit.getPluginManager().getPlugin("RealDualWield") != null) {
|
||||||
@ -301,8 +298,7 @@ public class MMOItems extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
recipeManager.load(book, amounts);
|
recipeManager.load(book, amounts);
|
||||||
if(amounts)
|
if (amounts) Bukkit.getPluginManager().registerEvents(new CraftingListener(), this);
|
||||||
Bukkit.getPluginManager().registerEvents(new CraftingListener(), this);
|
|
||||||
|
|
||||||
// amount and bukkit recipes
|
// amount and bukkit recipes
|
||||||
getLogger().log(Level.INFO, "Loading recipes, please wait...");
|
getLogger().log(Level.INFO, "Loading recipes, please wait...");
|
||||||
@ -321,7 +317,7 @@ public class MMOItems extends JavaPlugin {
|
|||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
|
|
||||||
// save player data
|
// 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
|
// save item updater data
|
||||||
ConfigFile updater = new ConfigFile("/dynamic", "updater");
|
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
|
* player level, class, resources like mana and stamina for item or skill
|
||||||
* costs, item restrictions, etc.
|
* costs, item restrictions, etc.
|
||||||
*
|
*
|
||||||
* @param handler
|
* @param handler Your RPGHandler instance
|
||||||
* Your RPGHandler instance
|
|
||||||
*/
|
*/
|
||||||
public void setRPG(RPGHandler handler) {
|
public void setRPG(RPGHandler handler) {
|
||||||
Validate.notNull(handler, "RPGHandler cannot be null");
|
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
|
* checks held items + armor slots. However other plugins like MMOInv do
|
||||||
* implement custom slots and therefore must register a custom
|
* implement custom slots and therefore must register a custom
|
||||||
* PlayerInventory instance.
|
* PlayerInventory instance.
|
||||||
*
|
* <p>
|
||||||
* Default instance is DefaultPlayerInventory in comp.inventory
|
* Default instance is DefaultPlayerInventory in comp.inventory
|
||||||
*
|
*
|
||||||
* @param value
|
* @param value The player inventory subclass
|
||||||
* The player inventory subclass
|
|
||||||
*/
|
*/
|
||||||
public void setPlayerInventory(PlayerInventory value) {
|
public void setPlayerInventory(PlayerInventory value) {
|
||||||
inventory = value;
|
inventory = value;
|
||||||
@ -494,8 +488,7 @@ public class MMOItems extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void findRpgPlugin() {
|
public void findRpgPlugin() {
|
||||||
if (rpgPlugin != null)
|
if (rpgPlugin != null) return;
|
||||||
return;
|
|
||||||
|
|
||||||
for (RPGHandler.PluginEnum plugin : RPGHandler.PluginEnum.values())
|
for (RPGHandler.PluginEnum plugin : RPGHandler.PluginEnum.values())
|
||||||
if (Bukkit.getPluginManager().getPlugin(plugin.getName()) != null) {
|
if (Bukkit.getPluginManager().getPlugin(plugin.getName()) != null) {
|
||||||
@ -522,10 +515,8 @@ public class MMOItems extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param itemLevel
|
* @param itemLevel The desired item level
|
||||||
* The desired item level
|
* @param itemTier The desired item tier, can be null
|
||||||
* @param itemTier
|
|
||||||
* The desired item tier, can be null
|
|
||||||
* @return Generates an item given an item template with a specific item
|
* @return Generates an item given an item template with a specific item
|
||||||
* level and item tier
|
* level and item tier
|
||||||
*/
|
*/
|
||||||
|
@ -230,7 +230,7 @@ public class Type {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static Type get(ItemStack item) {
|
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
|
* @return The type or NPE if it couldn't be found
|
||||||
*/
|
*/
|
||||||
public static Type get(String id) {
|
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
|
* @return If a registered type with this ID could be found
|
||||||
*/
|
*/
|
||||||
public static boolean isValid(String id) {
|
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 {
|
public enum EquipmentSlot {
|
||||||
|
@ -72,7 +72,7 @@ public class Consumable extends UseItem {
|
|||||||
* Unidentified items do not have any type, so you must check if the
|
* Unidentified items do not have any type, so you must check if the
|
||||||
* item has a type first.
|
* item has a type first.
|
||||||
*/
|
*/
|
||||||
Type targetType = target.getType();
|
Type targetType = Type.get(target.getType());
|
||||||
if (targetType == null) {
|
if (targetType == null) {
|
||||||
if (getNBTItem().getBoolean("MMOITEMS_CAN_IDENTIFY") && target.hasTag("MMOITEMS_UNIDENTIFIED_ITEM")) {
|
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
|
* 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.
|
* 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 (soulbindingChance > 0) {
|
||||||
if (target.getItem().getAmount() > 1) {
|
if (target.getItem().getAmount() > 1) {
|
||||||
Message.CANT_BIND_STACKED.format(ChatColor.RED).send(player, "soulbound");
|
Message.CANT_BIND_STACKED.format(ChatColor.RED).send(player, "soulbound");
|
||||||
@ -198,7 +198,7 @@ public class Consumable extends UseItem {
|
|||||||
if (called.isCancelled())
|
if (called.isCancelled())
|
||||||
return false;
|
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,
|
(targetMMO = new LiveMMOItem(target)).setData(ItemStats.SOULBOUND,
|
||||||
((Soulbound) ItemStats.SOULBOUND).newSoulboundData(player.getUniqueId(), player.getName(), soulboundLevel));
|
((Soulbound) ItemStats.SOULBOUND).newSoulboundData(player.getUniqueId(), player.getName(), soulboundLevel));
|
||||||
target.getItem().setItemMeta(targetMMO.newBuilder().build().getItemMeta());
|
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
|
* have at least the soulbound's level to be able to break the item
|
||||||
* soulbound.
|
* soulbound.
|
||||||
*/
|
*/
|
||||||
double soulboundBreakChance = getNBTItem().getStat(ItemStats.SOULBOUND_BREAK_CHANCE);
|
double soulboundBreakChance = getNBTItem().getStat(ItemStats.SOULBOUND_BREAK_CHANCE.getId());
|
||||||
if (soulboundBreakChance > 0) {
|
if (soulboundBreakChance > 0) {
|
||||||
MMOItem targetMMO = new VolatileMMOItem(target);
|
MMOItem targetMMO = new VolatileMMOItem(target);
|
||||||
if (!targetMMO.hasData(ItemStats.SOULBOUND)) {
|
if (!targetMMO.hasData(ItemStats.SOULBOUND)) {
|
||||||
@ -232,7 +232,7 @@ public class Consumable extends UseItem {
|
|||||||
SoulboundData soulbound = (SoulboundData) targetMMO.getData(ItemStats.SOULBOUND);
|
SoulboundData soulbound = (SoulboundData) targetMMO.getData(ItemStats.SOULBOUND);
|
||||||
|
|
||||||
// check for soulbound level
|
// 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");
|
Message.LOW_SOULBOUND_LEVEL.format(ChatColor.RED, "#level#", MMOUtils.intToRoman(soulbound.getLevel())).send(player, "soulbound");
|
||||||
return false;
|
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 repairing, does not apply if there's no repair power or if the
|
||||||
* item still has all its uses left
|
* 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) {
|
if (repairPower > 0) {
|
||||||
|
|
||||||
// custom durability
|
// custom durability
|
||||||
|
@ -52,7 +52,7 @@ public class GemStone extends UseItem {
|
|||||||
return new ApplyResult(ResultType.NONE);
|
return new ApplyResult(ResultType.NONE);
|
||||||
|
|
||||||
// check for success rate
|
// 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) {
|
if (successRate != 0 && random.nextDouble() > successRate / 100) {
|
||||||
player.playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1, 1);
|
player.playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1, 1);
|
||||||
Message.GEM_STONE_BROKE
|
Message.GEM_STONE_BROKE
|
||||||
|
@ -54,7 +54,7 @@ public class ItemSkin extends UseItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check for success rate
|
// check for success rate
|
||||||
double successRate = getNBTItem().getStat(ItemStats.SUCCESS_RATE);
|
double successRate = getNBTItem().getStat(ItemStats.SUCCESS_RATE.getId());
|
||||||
if (successRate != 0)
|
if (successRate != 0)
|
||||||
if (random.nextDouble() < 1 - successRate / 100) {
|
if (random.nextDouble() < 1 - successRate / 100) {
|
||||||
player.playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1, 1);
|
player.playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1, 1);
|
||||||
|
@ -95,6 +95,10 @@ public class UseItem {
|
|||||||
Bukkit.dispatchCommand(player, parsed);
|
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) {
|
public static UseItem getItem(Player player, NBTItem item, Type type) {
|
||||||
if (type.corresponds(Type.CONSUMABLE))
|
if (type.corresponds(Type.CONSUMABLE))
|
||||||
return new Consumable(player, item);
|
return new Consumable(player, item);
|
||||||
|
@ -43,7 +43,7 @@ public class Weapon extends UseItem {
|
|||||||
if (!isSwing && getPlayerData().isOnCooldown(cooldown))
|
if (!isSwing && getPlayerData().isOnCooldown(cooldown))
|
||||||
return false;
|
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) {
|
if (manaCost > 0 && playerData.getRPG().getMana() < manaCost) {
|
||||||
Message.NOT_ENOUGH_MANA.format(ChatColor.RED).send(getPlayer(), "not-enough-mana");
|
Message.NOT_ENOUGH_MANA.format(ChatColor.RED).send(getPlayer(), "not-enough-mana");
|
||||||
@ -69,7 +69,7 @@ public class Weapon extends UseItem {
|
|||||||
@SuppressWarnings("UnusedReturnValue")
|
@SuppressWarnings("UnusedReturnValue")
|
||||||
public ItemAttackResult targetedAttack(CachedStats stats, LivingEntity target, ItemAttackResult result) {
|
public ItemAttackResult targetedAttack(CachedStats stats, LivingEntity target, ItemAttackResult result) {
|
||||||
// cooldown
|
// cooldown
|
||||||
double attackSpeed = getNBTItem().getStat(ItemStats.ATTACK_SPEED);
|
double attackSpeed = getNBTItem().getStat(ItemStats.ATTACK_SPEED.getId());
|
||||||
attackSpeed = attackSpeed == 0 ? 1.493 : 1 / attackSpeed;
|
attackSpeed = attackSpeed == 0 ? 1.493 : 1 / attackSpeed;
|
||||||
if (!hasEnoughResources(attackSpeed, CooldownType.ATTACK, true))
|
if (!hasEnoughResources(attackSpeed, CooldownType.ATTACK, true))
|
||||||
return result.setSuccessful(false);
|
return result.setSuccessful(false);
|
||||||
|
@ -42,7 +42,7 @@ public class Crossbow extends UntargetedWeapon {
|
|||||||
|
|
||||||
getPlayer().getWorld().playSound(getPlayer().getLocation(), Sound.ENTITY_ARROW_SHOOT, 1, 1);
|
getPlayer().getWorld().playSound(getPlayer().getLocation(), Sound.ENTITY_ARROW_SHOOT, 1, 1);
|
||||||
Arrow arrow = getPlayer().launchProjectile(Arrow.class);
|
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));
|
getPlayer().setVelocity(getPlayer().getVelocity().setX(0).setZ(0));
|
||||||
|
|
||||||
MMOItems.plugin.getEntities().registerCustomProjectile(getNBTItem(), stats.newTemporary(), arrow, true);
|
MMOItems.plugin.getEntities().registerCustomProjectile(getNBTItem(), stats.newTemporary(), arrow, true);
|
||||||
|
@ -42,8 +42,8 @@ public class Lute extends UntargetedWeapon {
|
|||||||
durItem.decreaseDurability(1).update();
|
durItem.decreaseDurability(1).update();
|
||||||
|
|
||||||
double attackDamage = getValue(stats.getStat(ItemStats.ATTACK_DAMAGE), 1);
|
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"));
|
||||||
Vector weight = new Vector(0, -.003 * getNBTItem().getStat(ItemStats.NOTE_WEIGHT), 0);
|
Vector weight = new Vector(0, -.003 * getNBTItem().getStat(ItemStats.NOTE_WEIGHT.getId()), 0);
|
||||||
|
|
||||||
LuteAttackEffect effect = LuteAttackEffect.get(getNBTItem());
|
LuteAttackEffect effect = LuteAttackEffect.get(getNBTItem());
|
||||||
Sound sound = new SoundReader(getNBTItem().getString("MMOITEMS_LUTE_ATTACK_SOUND"), VersionSound.BLOCK_NOTE_BLOCK_BELL.toSound()).getSound();
|
Sound sound = new SoundReader(getNBTItem().getString("MMOITEMS_LUTE_ATTACK_SOUND"), VersionSound.BLOCK_NOTE_BLOCK_BELL.toSound()).getSound();
|
||||||
|
@ -35,11 +35,11 @@ public class Musket extends UntargetedWeapon {
|
|||||||
durItem.decreaseDurability(1).update();
|
durItem.decreaseDurability(1).update();
|
||||||
|
|
||||||
double attackDamage = stats.getStat(ItemStats.ATTACK_DAMAGE);
|
double attackDamage = stats.getStat(ItemStats.ATTACK_DAMAGE);
|
||||||
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 recoil = getValue(getNBTItem().getStat(ItemStats.RECOIL), MMOItems.plugin.getConfig().getDouble("default.recoil"));
|
double recoil = getValue(getNBTItem().getStat(ItemStats.RECOIL.getId()), MMOItems.plugin.getConfig().getDouble("default.recoil"));
|
||||||
|
|
||||||
// knockback
|
// knockback
|
||||||
double knockback = getNBTItem().getStat(ItemStats.KNOCKBACK);
|
double knockback = getNBTItem().getStat(ItemStats.KNOCKBACK.getId());
|
||||||
if (knockback > 0)
|
if (knockback > 0)
|
||||||
getPlayer().setVelocity(getPlayer().getVelocity().add(getPlayer().getEyeLocation().getDirection().setY(0).normalize().multiply(-1 * knockback).setY(-.2)));
|
getPlayer().setVelocity(getPlayer().getVelocity().add(getPlayer().getEyeLocation().getDirection().setY(0).normalize().multiply(-1 * knockback).setY(-.2)));
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ public class Staff extends UntargetedWeapon {
|
|||||||
durItem.decreaseDurability(1).update();
|
durItem.decreaseDurability(1).update();
|
||||||
|
|
||||||
double attackDamage = getValue(stats.getStat(ItemStats.ATTACK_DAMAGE), 1);
|
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());
|
StaffSpirit spirit = StaffSpirit.get(getNBTItem());
|
||||||
if (spirit != null) {
|
if (spirit != null) {
|
||||||
|
@ -36,7 +36,7 @@ public class Whip extends UntargetedWeapon {
|
|||||||
durItem.decreaseDurability(1).update();
|
durItem.decreaseDurability(1).update();
|
||||||
|
|
||||||
double attackDamage = getValue(stats.getStat(ItemStats.ATTACK_DAMAGE), 1);
|
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);
|
double a = Math.toRadians(getPlayer().getEyeLocation().getYaw() + 160);
|
||||||
Location loc = getPlayer().getEyeLocation().add(new Vector(Math.cos(a), 0, Math.sin(a)).multiply(.5));
|
Location loc = getPlayer().getEyeLocation().add(new Vector(Math.cos(a), 0, Math.sin(a)).multiply(.5));
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.Indyuce.mmoitems.api.item.mmoitem;
|
package net.Indyuce.mmoitems.api.item.mmoitem;
|
||||||
|
|
||||||
|
import net.Indyuce.mmoitems.api.Type;
|
||||||
import net.mmogroup.mmolib.api.item.NBTItem;
|
import net.mmogroup.mmolib.api.item.NBTItem;
|
||||||
|
|
||||||
public abstract class ReadMMOItem extends MMOItem {
|
public abstract class ReadMMOItem extends MMOItem {
|
||||||
@ -13,7 +14,7 @@ public abstract class ReadMMOItem extends MMOItem {
|
|||||||
* The NBTItem being read to generate an MMOItem
|
* The NBTItem being read to generate an MMOItem
|
||||||
*/
|
*/
|
||||||
public ReadMMOItem(NBTItem item) {
|
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;
|
this.item = item;
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ import java.util.Set;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class PlayerData {
|
public class PlayerData {
|
||||||
|
private static final Map<UUID, PlayerData> data = new HashMap<>();
|
||||||
private final MMOPlayerData mmoData;
|
private final MMOPlayerData mmoData;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -87,8 +87,6 @@ public class PlayerData {
|
|||||||
private final PlayerStats stats;
|
private final PlayerStats stats;
|
||||||
|
|
||||||
private PlayerData(MMOPlayerData mmoData) {
|
private PlayerData(MMOPlayerData mmoData) {
|
||||||
mmoData.setMMOItems(this);
|
|
||||||
|
|
||||||
this.mmoData = mmoData;
|
this.mmoData = mmoData;
|
||||||
this.rpgPlayer = MMOItems.plugin.getRPG().getInfo(this);
|
this.rpgPlayer = MMOItems.plugin.getRPG().getInfo(this);
|
||||||
this.stats = new PlayerStats(this);
|
this.stats = new PlayerStats(this);
|
||||||
@ -106,8 +104,7 @@ public class PlayerData {
|
|||||||
if (MMOItems.plugin.hasVault()) {
|
if (MMOItems.plugin.hasVault()) {
|
||||||
Permission perms = MMOItems.plugin.getVault().getPermissions();
|
Permission perms = MMOItems.plugin.getVault().getPermissions();
|
||||||
permissions.forEach(perm -> {
|
permissions.forEach(perm -> {
|
||||||
if (perms.has(getPlayer(), perm))
|
if (perms.has(getPlayer(), perm)) perms.playerRemove(getPlayer(), perm);
|
||||||
perms.playerRemove(getPlayer(), perm);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
cancelRunnables();
|
cancelRunnables();
|
||||||
@ -150,8 +147,7 @@ public class PlayerData {
|
|||||||
public void checkForInventoryUpdate() {
|
public void checkForInventoryUpdate() {
|
||||||
if (!mmoData.isOnline()) return;
|
if (!mmoData.isOnline()) return;
|
||||||
PlayerInventory inv = getPlayer().getInventory();
|
PlayerInventory inv = getPlayer().getInventory();
|
||||||
if (!equals(helmet, inv.getHelmet()) || !equals(chestplate, inv.getChestplate()) || !equals(leggings, inv.getLeggings())
|
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()))
|
||||||
|| !equals(boots, inv.getBoots()) || !equals(hand, inv.getItemInMainHand()) || !equals(offhand, inv.getItemInOffHand()))
|
|
||||||
updateInventory();
|
updateInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,14 +155,13 @@ public class PlayerData {
|
|||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(MMOItems.plugin, this::updateInventory);
|
Bukkit.getScheduler().scheduleSyncDelayedTask(MMOItems.plugin, this::updateInventory);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean equals(ItemStack item, ItemStack item1) {
|
private boolean isNotSame(ItemStack item, ItemStack item1) {
|
||||||
return Objects.equals(item, item1);
|
return !Objects.equals(item, item1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancelRunnables() {
|
public void cancelRunnables() {
|
||||||
itemParticles.forEach(BukkitRunnable::cancel);
|
itemParticles.forEach(BukkitRunnable::cancel);
|
||||||
if (overridingItemParticles != null)
|
if (overridingItemParticles != null) overridingItemParticles.cancel();
|
||||||
overridingItemParticles.cancel();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -177,8 +172,7 @@ public class PlayerData {
|
|||||||
if (!mmoData.isOnline()) return false;
|
if (!mmoData.isOnline()) return false;
|
||||||
NBTItem main = MMOLib.plugin.getVersion().getWrapper().getNBTItem(getPlayer().getInventory().getItemInMainHand());
|
NBTItem main = MMOLib.plugin.getVersion().getWrapper().getNBTItem(getPlayer().getInventory().getItemInMainHand());
|
||||||
NBTItem off = MMOLib.plugin.getVersion().getWrapper().getNBTItem(getPlayer().getInventory().getItemInOffHand());
|
NBTItem off = MMOLib.plugin.getVersion().getWrapper().getNBTItem(getPlayer().getInventory().getItemInOffHand());
|
||||||
return (main.getBoolean("MMOITEMS_TWO_HANDED") && (off.getItem() != null && off.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));
|
||||||
|| (off.getBoolean("MMOITEMS_TWO_HANDED") && (main.getItem() != null && main.getItem().getType() != Material.AIR));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateInventory() {
|
public void updateInventory() {
|
||||||
@ -196,8 +190,7 @@ public class PlayerData {
|
|||||||
if (MMOItems.plugin.hasVault()) {
|
if (MMOItems.plugin.hasVault()) {
|
||||||
Permission perms = MMOItems.plugin.getVault().getPermissions();
|
Permission perms = MMOItems.plugin.getVault().getPermissions();
|
||||||
permissions.forEach(perm -> {
|
permissions.forEach(perm -> {
|
||||||
if (perms.has(getPlayer(), perm))
|
if (perms.has(getPlayer(), perm)) perms.playerRemove(getPlayer(), perm);
|
||||||
perms.playerRemove(getPlayer(), perm);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
permissions.clear();
|
permissions.clear();
|
||||||
@ -212,20 +205,17 @@ public class PlayerData {
|
|||||||
for (EquippedItem item : MMOItems.plugin.getInventory().getInventory(getPlayer())) {
|
for (EquippedItem item : MMOItems.plugin.getInventory().getInventory(getPlayer())) {
|
||||||
NBTItem nbtItem = item.newNBTItem();
|
NBTItem nbtItem = item.newNBTItem();
|
||||||
|
|
||||||
Type type = nbtItem.getType();
|
Type type = Type.get(nbtItem.getType());
|
||||||
if (type == null)
|
if (type == null) continue;
|
||||||
continue;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* if the player is holding an item the wrong way i.e if the item is
|
* 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
|
* not in the right slot. intuitive methods with small exceptions
|
||||||
* like BOTH_HANDS and ANY
|
* like BOTH_HANDS and ANY
|
||||||
*/
|
*/
|
||||||
if (!item.matches(type))
|
if (!item.matches(type)) continue;
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!getRPG().canUse(nbtItem, false))
|
if (!getRPG().canUse(nbtItem, false)) continue;
|
||||||
continue;
|
|
||||||
|
|
||||||
playerInventory.add(new VolatileMMOItem(nbtItem));
|
playerInventory.add(new VolatileMMOItem(nbtItem));
|
||||||
}
|
}
|
||||||
@ -248,10 +238,8 @@ public class PlayerData {
|
|||||||
ParticleData particleData = (ParticleData) item.getData(ItemStats.ITEM_PARTICLES);
|
ParticleData particleData = (ParticleData) item.getData(ItemStats.ITEM_PARTICLES);
|
||||||
|
|
||||||
if (particleData.getType().hasPriority()) {
|
if (particleData.getType().hasPriority()) {
|
||||||
if (overridingItemParticles == null)
|
if (overridingItemParticles == null) overridingItemParticles = particleData.start(this);
|
||||||
overridingItemParticles = particleData.start(this);
|
} else itemParticles.add(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
|
// if the item with the abilities is in the players offhand AND
|
||||||
// its disabled in the config then just move on, else add the
|
// its disabled in the config then just move on, else add the
|
||||||
// ability
|
// ability
|
||||||
if (item.getNBT().getItem().equals(getPlayer().getInventory().getItemInOffHand())
|
if (item.getNBT().getItem().equals(getPlayer().getInventory().getItemInOffHand()) && MMOItems.plugin.getConfig().getBoolean("disable-abilities-in-offhand")) {
|
||||||
&& MMOItems.plugin.getConfig().getBoolean("disable-abilities-in-offhand")) {
|
|
||||||
continue;
|
continue;
|
||||||
} else
|
} else itemAbilities.addAll(((AbilityListData) item.getData(ItemStats.ABILITIES)).getAbilities());
|
||||||
itemAbilities.addAll(((AbilityListData) item.getData(ItemStats.ABILITIES)).getAbilities());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -285,8 +271,7 @@ public class PlayerData {
|
|||||||
for (VolatileMMOItem item : getMMOItems()) {
|
for (VolatileMMOItem item : getMMOItems()) {
|
||||||
String tag = item.getNBT().getString("MMOITEMS_ITEM_SET");
|
String tag = item.getNBT().getString("MMOITEMS_ITEM_SET");
|
||||||
ItemSet itemSet = MMOItems.plugin.getSets().get(tag);
|
ItemSet itemSet = MMOItems.plugin.getSets().get(tag);
|
||||||
if (itemSet == null)
|
if (itemSet == null) continue;
|
||||||
continue;
|
|
||||||
|
|
||||||
int nextInt = (sets.getOrDefault(itemSet, 0)) + 1;
|
int nextInt = (sets.getOrDefault(itemSet, 0)) + 1;
|
||||||
sets.put(itemSet, nextInt);
|
sets.put(itemSet, nextInt);
|
||||||
@ -341,8 +326,7 @@ public class PlayerData {
|
|||||||
if (MMOItems.plugin.hasVault()) {
|
if (MMOItems.plugin.hasVault()) {
|
||||||
Permission perms = MMOItems.plugin.getVault().getPermissions();
|
Permission perms = MMOItems.plugin.getVault().getPermissions();
|
||||||
permissions.forEach(perm -> {
|
permissions.forEach(perm -> {
|
||||||
if (!perms.has(getPlayer(), perm))
|
if (!perms.has(getPlayer(), perm)) perms.playerAdd(getPlayer(), perm);
|
||||||
perms.playerAdd(getPlayer(), perm);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -381,8 +365,7 @@ public class PlayerData {
|
|||||||
|
|
||||||
private boolean hasAbility(CastingMode castMode) {
|
private boolean hasAbility(CastingMode castMode) {
|
||||||
for (AbilityData ability : itemAbilities)
|
for (AbilityData ability : itemAbilities)
|
||||||
if (ability.getCastingMode() == castMode)
|
if (ability.getCastingMode() == castMode) return true;
|
||||||
return true;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -393,8 +376,7 @@ public class PlayerData {
|
|||||||
* performance improvement, do not cache the player stats into a
|
* performance improvement, do not cache the player stats into a
|
||||||
* CachedStats if the player has no ability on that cast mode
|
* CachedStats if the player has no ability on that cast mode
|
||||||
*/
|
*/
|
||||||
if (!hasAbility(castMode))
|
if (!hasAbility(castMode)) return result;
|
||||||
return result;
|
|
||||||
|
|
||||||
return castAbilities(getStats().newTemporary(), target, result, castMode);
|
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,
|
* and make sure player can attack target. if ability has no target,
|
||||||
* check for WG flag at the caster location
|
* check for WG flag at the caster location
|
||||||
*/
|
*/
|
||||||
if (target == null ? !MMOItems.plugin.getFlags().isFlagAllowed(getPlayer(), CustomFlag.MI_ABILITIES)
|
if (target == null ? !MMOItems.plugin.getFlags().isFlagAllowed(getPlayer(), CustomFlag.MI_ABILITIES) : !MMOItems.plugin.getFlags().isFlagAllowed(target.getLocation(), CustomFlag.MI_ABILITIES) || !MMOUtils.canDamage(getPlayer(), target))
|
||||||
: !MMOItems.plugin.getFlags().isFlagAllowed(target.getLocation(), CustomFlag.MI_ABILITIES)
|
|
||||||
|| !MMOUtils.canDamage(getPlayer(), target))
|
|
||||||
return result.setSuccessful(false);
|
return result.setSuccessful(false);
|
||||||
|
|
||||||
for (AbilityData ability : itemAbilities)
|
for (AbilityData ability : itemAbilities)
|
||||||
if (ability.getCastingMode() == castMode)
|
if (ability.getCastingMode() == castMode) cast(stats, target, result, ability);
|
||||||
cast(stats, target, result, ability);
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -436,31 +415,25 @@ public class PlayerData {
|
|||||||
public void cast(CachedStats stats, LivingEntity target, ItemAttackResult attack, AbilityData ability) {
|
public void cast(CachedStats stats, LivingEntity target, ItemAttackResult attack, AbilityData ability) {
|
||||||
AbilityUseEvent event = new AbilityUseEvent(this, ability, target);
|
AbilityUseEvent event = new AbilityUseEvent(this, ability, target);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
if (event.isCancelled())
|
if (event.isCancelled()) return;
|
||||||
return;
|
|
||||||
|
|
||||||
if (!rpgPlayer.canCast(ability))
|
if (!rpgPlayer.canCast(ability)) return;
|
||||||
return;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* check if ability can be cast (custom conditions)
|
* check if ability can be cast (custom conditions)
|
||||||
*/
|
*/
|
||||||
AbilityResult abilityResult = ability.getAbility().whenRan(stats, target, ability, attack);
|
AbilityResult abilityResult = ability.getAbility().whenRan(stats, target, ability, attack);
|
||||||
if (!abilityResult.isSuccessful())
|
if (!abilityResult.isSuccessful()) return;
|
||||||
return;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* the player can cast the ability, and it was successfully cast on its
|
* the player can cast the ability, and it was successfully cast on its
|
||||||
* target, removes resources needed from the player
|
* target, removes resources needed from the player
|
||||||
*/
|
*/
|
||||||
if (ability.hasModifier("mana"))
|
if (ability.hasModifier("mana")) rpgPlayer.giveMana(-abilityResult.getModifier("mana"));
|
||||||
rpgPlayer.giveMana(-abilityResult.getModifier("mana"));
|
if (ability.hasModifier("stamina")) rpgPlayer.giveStamina(-abilityResult.getModifier("stamina"));
|
||||||
if (ability.hasModifier("stamina"))
|
|
||||||
rpgPlayer.giveStamina(-abilityResult.getModifier("stamina"));
|
|
||||||
|
|
||||||
double cooldown = abilityResult.getModifier("cooldown") * (1 - Math.min(.8, stats.getStat(ItemStats.COOLDOWN_REDUCTION) / 100));
|
double cooldown = abilityResult.getModifier("cooldown") * (1 - Math.min(.8, stats.getStat(ItemStats.COOLDOWN_REDUCTION) / 100));
|
||||||
if (cooldown > 0)
|
if (cooldown > 0) applyAbilityCooldown(ability.getAbility(), cooldown);
|
||||||
applyAbilityCooldown(ability.getAbility(), cooldown);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* finally cast the ability (BUG FIX) cooldown MUST be applied BEFORE
|
* finally cast the ability (BUG FIX) cooldown MUST be applied BEFORE
|
||||||
@ -524,7 +497,8 @@ public class PlayerData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static PlayerData get(UUID uuid) {
|
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
|
* initialized
|
||||||
*/
|
*/
|
||||||
public static void load(Player player) {
|
public static void load(Player player) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Double check they are online, for some reason even if this is fired
|
* 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.
|
* from the join event the player can be offline if they left in the same tick or something.
|
||||||
*/
|
*/
|
||||||
if (!player.isOnline())
|
if (!player.isOnline() || data.containsKey(player.getUniqueId())) return;
|
||||||
return;
|
PlayerData newData = PlayerData.get(player.getUniqueId());
|
||||||
|
|
||||||
MMOPlayerData mmoData = MMOPlayerData.get(player.getUniqueId());
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* if no mmoitems data could be found, it must be initialized
|
* update the cached RPGPlayer in case of any major
|
||||||
*/
|
|
||||||
if (mmoData.getMMOItems() == null)
|
|
||||||
mmoData.setMMOItems(new PlayerData(mmoData));
|
|
||||||
|
|
||||||
/*
|
|
||||||
* otherwise just update the cached RPGPlayer in case of any major
|
|
||||||
* change in the player data of other rpg plugins
|
* change in the player data of other rpg plugins
|
||||||
*/
|
*/
|
||||||
else
|
newData.rpgPlayer = MMOItems.plugin.getRPG().getInfo(newData);
|
||||||
mmoData.getMMOItems().rpgPlayer = MMOItems.plugin.getRPG().getInfo(mmoData.getMMOItems());
|
/* cache the playerdata */
|
||||||
|
data.put(player.getUniqueId(), newData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Collection<PlayerData> getLoaded() {
|
||||||
|
return data.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum CooldownType {
|
public enum CooldownType {
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package net.Indyuce.mmoitems.api.util.message;
|
package net.Indyuce.mmoitems.api.util.message;
|
||||||
|
|
||||||
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
|
||||||
import net.Indyuce.mmoitems.MMOItems;
|
import net.Indyuce.mmoitems.MMOItems;
|
||||||
import net.mmogroup.mmolib.MMOLib;
|
import net.mmogroup.mmolib.MMOLib;
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.Indyuce.mmoitems.command.item;
|
package net.Indyuce.mmoitems.command.item;
|
||||||
|
|
||||||
|
import net.Indyuce.mmoitems.api.Type;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -33,7 +34,7 @@ public class UnidentifyCommandTreeNode extends CommandTreeNode {
|
|||||||
return CommandResult.FAILURE;
|
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.");
|
sender.sendMessage(MMOItems.plugin.getPrefix() + "Successfully unidentified the item you are holding.");
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package net.Indyuce.mmoitems.comp.inventory;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.Indyuce.mmoitems.api.Type;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -34,7 +35,7 @@ public class OrnamentPlayerInventory implements PlayerInventory, Listener {
|
|||||||
|
|
||||||
for (ItemStack item : player.getInventory().getContents()) {
|
for (ItemStack item : player.getInventory().getContents()) {
|
||||||
NBTItem nbtItem;
|
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));
|
list.add(new EquippedItem(nbtItem, EquipmentSlot.ANY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +46,7 @@ public class OrnamentPlayerInventory implements PlayerInventory, Listener {
|
|||||||
public void a(EntityPickupItemEvent event) {
|
public void a(EntityPickupItemEvent event) {
|
||||||
if (event.getEntityType() == EntityType.PLAYER) {
|
if (event.getEntityType() == EntityType.PLAYER) {
|
||||||
NBTItem nbt = NBTItem.get(event.getItem().getItemStack());
|
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();
|
PlayerData.get((Player) event.getEntity()).updateInventory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -53,7 +54,7 @@ public class OrnamentPlayerInventory implements PlayerInventory, Listener {
|
|||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void b(PlayerDropItemEvent event) {
|
public void b(PlayerDropItemEvent event) {
|
||||||
NBTItem nbt = NBTItem.get(event.getItemDrop().getItemStack());
|
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();
|
PlayerData.get(event.getPlayer()).updateInventory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package net.Indyuce.mmoitems.comp.inventory;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.Indyuce.mmoitems.api.Type;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -48,7 +49,7 @@ public class RPGInventoryHook implements PlayerInventory, Listener {
|
|||||||
if (ornaments)
|
if (ornaments)
|
||||||
for (ItemStack item : player.getInventory().getContents()) {
|
for (ItemStack item : player.getInventory().getContents()) {
|
||||||
NBTItem nbtItem;
|
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));
|
list.add(new EquippedItem(nbtItem, EquipmentSlot.ANY));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,12 +17,8 @@ import net.Indyuce.mmoitems.comp.mmocore.stat.Required_Attribute;
|
|||||||
import net.Indyuce.mmoitems.comp.rpg.RPGHandler;
|
import net.Indyuce.mmoitems.comp.rpg.RPGHandler;
|
||||||
|
|
||||||
public class MMOCoreHook implements RPGHandler, Listener {
|
public class MMOCoreHook implements RPGHandler, Listener {
|
||||||
|
/* called when MMOItems enables */
|
||||||
/*
|
|
||||||
* called when MMOItems enables
|
|
||||||
*/
|
|
||||||
public MMOCoreHook() {
|
public MMOCoreHook() {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* only works when the server is reloaded. needs /reload when changing
|
* only works when the server is reloaded. needs /reload when changing
|
||||||
* attributes or professions to refresh MMOItems stats
|
* 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) {
|
public MMOCoreRPGPlayer(net.Indyuce.mmoitems.api.player.PlayerData playerData) {
|
||||||
super(playerData);
|
super(playerData);
|
||||||
|
|
||||||
data = playerData.getMMOPlayerData().getMMOCore();
|
data = PlayerData.get(playerData.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayerData getData() {
|
public PlayerData getData() {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package net.Indyuce.mmoitems.comp.mmocore.load;
|
package net.Indyuce.mmoitems.comp.mmocore.load;
|
||||||
|
|
||||||
import net.Indyuce.mmoitems.ItemStats;
|
import net.Indyuce.mmoitems.ItemStats;
|
||||||
|
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
@ -32,7 +33,7 @@ public class ItemTemplateDropItem extends ItemGenerationDropItem {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void collect(LootBuilder builder) {
|
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);
|
MMOItem mmoitem = rollMMOItem(template, rpgPlayer);
|
||||||
|
|
||||||
if (rollSoulbound())
|
if (rollSoulbound())
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
package net.Indyuce.mmoitems.comp.mmocore.load;
|
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.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.api.quest.trigger.Trigger;
|
import net.Indyuce.mmocore.api.quest.trigger.Trigger;
|
||||||
import net.Indyuce.mmoitems.MMOItems;
|
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.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
|
||||||
import net.mmogroup.mmolib.api.MMOLineConfig;
|
import net.mmogroup.mmolib.api.MMOLineConfig;
|
||||||
import net.mmogroup.mmolib.api.util.SmartGive;
|
import net.mmogroup.mmolib.api.util.SmartGive;
|
||||||
|
import org.apache.commons.lang.Validate;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class MMOItemTrigger extends Trigger {
|
public class MMOItemTrigger extends Trigger {
|
||||||
private final MMOItemTemplate template;
|
private final MMOItemTemplate template;
|
||||||
@ -33,7 +32,7 @@ public class MMOItemTrigger extends Trigger {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply(PlayerData player) {
|
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);
|
item.setAmount(amount);
|
||||||
new SmartGive(player.getPlayer()).give(item);
|
new SmartGive(player.getPlayer()).give(item);
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package net.Indyuce.mmoitems.comp.mmocore.load;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import net.Indyuce.mmoitems.ItemStats;
|
import net.Indyuce.mmoitems.ItemStats;
|
||||||
|
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
@ -41,7 +42,7 @@ public class RandomItemDropItem extends ItemGenerationDropItem {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void collect(LootBuilder builder) {
|
public void collect(LootBuilder builder) {
|
||||||
RPGPlayer rpgPlayer = builder.getEntity().getMMOPlayerData().getMMOItems().getRPG();
|
RPGPlayer rpgPlayer = PlayerData.get(builder.getEntity().getUniqueId()).getRPG();
|
||||||
|
|
||||||
TemplateExplorer explorer = new TemplateExplorer();
|
TemplateExplorer explorer = new TemplateExplorer();
|
||||||
if (matchClass)
|
if (matchClass)
|
||||||
|
@ -24,7 +24,7 @@ public class Required_Attribute extends DoubleStat implements ItemRestriction, G
|
|||||||
@Override
|
@Override
|
||||||
public boolean canUse(RPGPlayer player, NBTItem item, boolean message) {
|
public boolean canUse(RPGPlayer player, NBTItem item, boolean message) {
|
||||||
MMOCoreRPGPlayer mmocore = (MMOCoreRPGPlayer) player;
|
MMOCoreRPGPlayer mmocore = (MMOCoreRPGPlayer) player;
|
||||||
if (mmocore.getData().getAttributes().getAttribute(attribute) < item.getStat(this)) {
|
if (mmocore.getData().getAttributes().getAttribute(attribute) < item.getStat(getId())) {
|
||||||
if (message) {
|
if (message) {
|
||||||
new AddonMessage("not-enough-attribute").format(ChatColor.RED, "#attribute#", attribute.getName()).send(player.getPlayer(), "cant-use-item");
|
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);
|
player.getPlayer().playSound(player.getPlayer().getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1.5f);
|
||||||
|
@ -24,7 +24,7 @@ public class Required_Profession extends DoubleStat implements ItemRestriction,
|
|||||||
@Override
|
@Override
|
||||||
public boolean canUse(RPGPlayer player, NBTItem item, boolean message) {
|
public boolean canUse(RPGPlayer player, NBTItem item, boolean message) {
|
||||||
MMOCoreHook.MMOCoreRPGPlayer mmocore = (MMOCoreHook.MMOCoreRPGPlayer) player;
|
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) {
|
if (message) {
|
||||||
new AddonMessage("not-enough-profession").format(ChatColor.RED, "#profession#", profession.getName()).send(player.getPlayer(), "cant-use-item");
|
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);
|
player.getPlayer().playSound(player.getPlayer().getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1.5f);
|
||||||
|
@ -131,7 +131,7 @@ public class ItemUse implements Listener {
|
|||||||
NBTItem offhandItem = MMOLib.plugin.getVersion().getWrapper().getNBTItem(player.getInventory().getItemInOffHand());
|
NBTItem offhandItem = MMOLib.plugin.getVersion().getWrapper().getNBTItem(player.getInventory().getItemInOffHand());
|
||||||
ItemAttackResult result = new ItemAttackResult(event.getDamage(), DamageType.WEAPON, DamageType.PHYSICAL);
|
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);
|
Weapon weapon = new Weapon(playerData, item);
|
||||||
|
|
||||||
if (weapon.getMMOItem().getType().getItemSet() == TypeSet.RANGE) {
|
if (weapon.getMMOItem().getType().getItemSet() == TypeSet.RANGE) {
|
||||||
@ -150,7 +150,7 @@ public class ItemUse implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (offhandItem.hasType() && item.getType() != Type.BLOCK) {
|
if (offhandItem.hasType() && Type.get(item.getType()) != Type.BLOCK) {
|
||||||
Weapon weapon = new Weapon(playerData, offhandItem);
|
Weapon weapon = new Weapon(playerData, offhandItem);
|
||||||
|
|
||||||
if (weapon.getMMOItem().getType().getItemSet() == TypeSet.RANGE) {
|
if (weapon.getMMOItem().getType().getItemSet() == TypeSet.RANGE) {
|
||||||
@ -239,7 +239,7 @@ public class ItemUse implements Listener {
|
|||||||
if (!picked.hasType())
|
if (!picked.hasType())
|
||||||
return;
|
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)
|
if (result.getType() == ItemSkin.ResultType.NONE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -257,7 +257,7 @@ public class ItemUse implements Listener {
|
|||||||
if (!picked.hasType())
|
if (!picked.hasType())
|
||||||
return;
|
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)
|
if (result.getType() == GemStone.ResultType.NONE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -283,7 +283,7 @@ public class ItemUse implements Listener {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
NBTItem item = MMOLib.plugin.getVersion().getWrapper().getNBTItem(event.getBow());
|
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());
|
PlayerData playerData = PlayerData.get((Player) event.getEntity());
|
||||||
if (type != null)
|
if (type != null)
|
||||||
@ -293,8 +293,8 @@ public class ItemUse implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Arrow arrow = (Arrow) event.getProjectile();
|
Arrow arrow = (Arrow) event.getProjectile();
|
||||||
if (!(item.getStat(ItemStats.ARROW_VELOCITY) <= 0))
|
if (!(item.getStat(ItemStats.ARROW_VELOCITY.getId()) <= 0))
|
||||||
arrow.setVelocity(arrow.getVelocity().multiply(1 + (item.getStat(ItemStats.ARROW_VELOCITY) / 2)));
|
arrow.setVelocity(arrow.getVelocity().multiply(1 + (item.getStat(ItemStats.ARROW_VELOCITY.getId()) / 2)));
|
||||||
MMOItems.plugin.getEntities().registerCustomProjectile(item, playerData.getStats().newTemporary(), event.getProjectile(),
|
MMOItems.plugin.getEntities().registerCustomProjectile(item, playerData.getStats().newTemporary(), event.getProjectile(),
|
||||||
type != null, event.getForce());
|
type != null, event.getForce());
|
||||||
}
|
}
|
||||||
@ -324,7 +324,7 @@ public class ItemUse implements Listener {
|
|||||||
return;
|
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();
|
useItem.executeCommands();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -120,7 +120,7 @@ public class PlayerListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
NBTItem nbtItem = MMOLib.plugin.getVersion().getWrapper().getNBTItem(item.getItem());
|
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());
|
PlayerData playerData = PlayerData.get((Player) event.getEntity().getShooter());
|
||||||
if (type != null && !new Weapon(playerData, nbtItem).canBeUsed()) {
|
if (type != null && !new Weapon(playerData, nbtItem).canBeUsed()) {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package net.Indyuce.mmoitems.manager;
|
package net.Indyuce.mmoitems.manager;
|
||||||
|
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
|
||||||
import net.Indyuce.mmoitems.MMOItems;
|
import net.Indyuce.mmoitems.MMOItems;
|
||||||
import net.Indyuce.mmoitems.MMOUtils;
|
import net.Indyuce.mmoitems.MMOUtils;
|
||||||
import net.Indyuce.mmoitems.api.ConfigFile;
|
import net.Indyuce.mmoitems.api.ConfigFile;
|
||||||
@ -270,7 +269,7 @@ public class ConfigManager implements Reloadable {
|
|||||||
File folder = new File(MMOItems.plugin.getDataFolder() + "/" + path);
|
File folder = new File(MMOItems.plugin.getDataFolder() + "/" + path);
|
||||||
if (!folder.exists())
|
if (!folder.exists())
|
||||||
if(!folder.mkdir())
|
if(!folder.mkdir())
|
||||||
MMOCore.log(Level.WARNING, "Could not create directory!");
|
MMOItems.plugin.getLogger().log(Level.WARNING, "Could not create directory!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -39,7 +39,7 @@ public class TemplateManager implements Reloadable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasTemplate(NBTItem nbt) {
|
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) {
|
public MMOItemTemplate getTemplate(Type type, String id) {
|
||||||
@ -47,7 +47,7 @@ public class TemplateManager implements Reloadable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public MMOItemTemplate getTemplate(NBTItem nbt) {
|
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"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3,7 +3,6 @@ package net.Indyuce.mmoitems.manager;
|
|||||||
import net.Indyuce.mmoitems.MMOItems;
|
import net.Indyuce.mmoitems.MMOItems;
|
||||||
import net.Indyuce.mmoitems.api.Type;
|
import net.Indyuce.mmoitems.api.Type;
|
||||||
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
|
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.item.template.MMOItemTemplate;
|
||||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||||
import net.mmogroup.mmolib.MMOLib;
|
import net.mmogroup.mmolib.MMOLib;
|
||||||
@ -44,12 +43,10 @@ public class UpdaterManager implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void updateOnClick(InventoryClickEvent event) {
|
public void updateOnClick(InventoryClickEvent event) {
|
||||||
ItemStack item = event.getCurrentItem();
|
ItemStack item = event.getCurrentItem();
|
||||||
if (item == null || item.getType() == Material.AIR)
|
if (item == null || item.getType() == Material.AIR) return;
|
||||||
return;
|
|
||||||
|
|
||||||
ItemStack newItem = getUpdated(item, (Player) event.getWhoClicked());
|
ItemStack newItem = getUpdated(item, (Player) event.getWhoClicked());
|
||||||
if (!newItem.equals(item))
|
if (!newItem.equals(item)) event.setCurrentItem(newItem);
|
||||||
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
|
* If the item type is null, then it is not an mmoitem and it does not
|
||||||
* need to be updated
|
* need to be updated
|
||||||
*/
|
*/
|
||||||
Type type = item.getType();
|
Type type = Type.get(item.getType());
|
||||||
if (type == null)
|
if (type == null) return item.getItem();
|
||||||
return item.getItem();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* check the internal UUID of the item, if it does not make the one
|
* 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
|
* apply older gem stones, using a light MMOItem so the item does not
|
||||||
* calculate every stat data from the older item.
|
* 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))
|
/*if (did.hasOption(KeepOption.KEEP_GEMS) && volatileItem.hasData(ItemStats.GEM_SOCKETS))
|
||||||
newMMOItem.replaceData(ItemStats.GEM_SOCKETS, volatileItem.getData(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)) {
|
//if (did.hasOption(KeepOption.KEEP_LORE)) {
|
||||||
int n = 0;
|
int n = 0;
|
||||||
for (String s : item.getItem().getItemMeta().getLore()) {
|
for (String s : item.getItem().getItemMeta().getLore()) {
|
||||||
if (!s.startsWith(ChatColor.GRAY + ""))
|
if (!s.startsWith(ChatColor.GRAY + "")) break;
|
||||||
break;
|
|
||||||
lore.add(n++, s);
|
lore.add(n++, s);
|
||||||
}
|
}
|
||||||
//}
|
//}
|
||||||
@ -157,8 +152,7 @@ public class UpdaterManager implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public enum KeepOption {
|
public enum KeepOption {
|
||||||
KEEP_LORE("Any lore line starting with '&7' will be", "kept when updating your item.", "", "This option is supposed to keep",
|
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."),
|
||||||
"the item custom enchants.", ChatColor.RED + "May not support every enchant plugin."),
|
|
||||||
KEEP_ENCHANTS("The item keeps its old enchantments."),
|
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_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."),
|
KEEP_NAME("The item keeps its display name."),
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
# a Spigot Plugin by Team Requiem
|
# a Spigot Plugin by Team Requiem
|
||||||
|
|
||||||
# DO NOT TOUCH
|
# DO NOT TOUCH
|
||||||
config-version: 4
|
config-version: 5
|
||||||
|
|
||||||
# Notifies players with the 'mmoitems.update-notify' perm node when
|
# Notifies players with the 'mmoitems.update-notify' perm node when
|
||||||
# they join the server if a new update is available for download.
|
# they join the server if a new update is available for download.
|
||||||
@ -275,6 +275,15 @@ item-revision:
|
|||||||
click: false
|
click: false
|
||||||
join: 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...
|
# 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...
|
# The fist time I saw her, with her hands on her knee... how do I say this...
|
Loading…
Reference in New Issue
Block a user