Created MMO Extension
This commit is contained in:
22
Extensions/MMO/build.gradle
Normal file
22
Extensions/MMO/build.gradle
Normal file
@@ -0,0 +1,22 @@
|
||||
repositories {
|
||||
maven {
|
||||
url 'https://mvn.lumine.io/repository/maven-public/'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly 'org.spigotmc:spigot-api:1.15.2-R0.1-SNAPSHOT'
|
||||
compileOnly project(':plugin')
|
||||
compileOnly 'net.Indyuce:MMOCore:1.4.11'
|
||||
compileOnly 'net.Indyuce:MMOItems:6.4'
|
||||
}
|
||||
|
||||
jar{
|
||||
archiveFileName = project.name + " Extension" + ".jar"
|
||||
}
|
||||
|
||||
description = 'MMO'
|
||||
|
||||
tasks.withType(Jar) {
|
||||
destinationDirectory = file("$rootDir/bin/")
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.willfp.ecoenchants.mmo;
|
||||
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.util.optional.Prerequisite;
|
||||
|
||||
public abstract class MMOEnchantment extends EcoEnchant {
|
||||
protected MMOEnchantment(String key, EnchantmentType type, Prerequisite... prerequisites) {
|
||||
super(key, type, MMOMain.class, MMOPrerequisites.append(prerequisites, MMOPrerequisites.HAS_MMOCORE));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.willfp.ecoenchants.mmo;
|
||||
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.extensions.Extension;
|
||||
import com.willfp.ecoenchants.mmo.enchants.Athletic;
|
||||
import com.willfp.ecoenchants.mmo.enchants.Augment;
|
||||
import com.willfp.ecoenchants.mmo.enchants.abilities.Discounted;
|
||||
import com.willfp.ecoenchants.mmo.enchants.abilities.Recover;
|
||||
import com.willfp.ecoenchants.mmo.enchants.mana.Drain;
|
||||
import com.willfp.ecoenchants.mmo.enchants.mana.Elixir;
|
||||
import com.willfp.ecoenchants.mmo.enchants.mana.Siphon;
|
||||
import com.willfp.ecoenchants.mmo.enchants.mana.Spirituality;
|
||||
import com.willfp.ecoenchants.mmo.enchants.stamina.Endurance;
|
||||
import com.willfp.ecoenchants.mmo.enchants.stamina.Fortitude;
|
||||
import com.willfp.ecoenchants.mmo.enchants.stamina.Motivate;
|
||||
import com.willfp.ecoenchants.util.Logger;
|
||||
|
||||
public class MMOMain extends Extension {
|
||||
public static final EcoEnchant ELIXIR = new Elixir();
|
||||
public static final EcoEnchant SIPHON = new Siphon();
|
||||
public static final EcoEnchant DRAIN = new Drain();
|
||||
public static final EcoEnchant SPIRITUALITY = new Spirituality();
|
||||
public static final EcoEnchant AUGMENT = new Augment();
|
||||
public static final EcoEnchant DISCOUNTED = new Discounted();
|
||||
public static final EcoEnchant RECOVER = new Recover();
|
||||
public static final EcoEnchant ENDURANCE = new Endurance();
|
||||
public static final EcoEnchant FORTITUDE = new Fortitude();
|
||||
public static final EcoEnchant MOTIVATE = new Motivate();
|
||||
public static final EcoEnchant ATHLETIC = new Athletic();
|
||||
|
||||
@Override
|
||||
protected void onEnable() {
|
||||
if(!MMOPrerequisites.HAS_MMOCORE.isMet()) {
|
||||
Logger.error("MMO Extension requires MMOCore to be installed!");
|
||||
Logger.error("Disabling...");
|
||||
this.disable();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDisable() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.willfp.ecoenchants.mmo;
|
||||
|
||||
import com.willfp.ecoenchants.util.optional.Prerequisite;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class MMOPrerequisites {
|
||||
private static final Set<String> enabledPlugins = Arrays.stream(Bukkit.getPluginManager().getPlugins()).map(Plugin::getName).collect(Collectors.toSet());
|
||||
|
||||
public static final Prerequisite HAS_MMOCORE = new Prerequisite(
|
||||
() -> enabledPlugins.contains("MMOCore"),
|
||||
"Has mmocore installed"
|
||||
);
|
||||
public static final Prerequisite HAS_MMOITEMS = new Prerequisite(
|
||||
() -> enabledPlugins.contains("MMOItems"),
|
||||
"Has mmoitems installed"
|
||||
);
|
||||
|
||||
public static Prerequisite[] append(Prerequisite[] array, Prerequisite newElement) {
|
||||
Prerequisite[] copy = new Prerequisite[array.length+1];
|
||||
System.arraycopy(array, 0, copy, 0, array.length);
|
||||
copy[array.length] = newElement;
|
||||
return copy;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.willfp.ecoenchants.mmo;
|
||||
|
||||
import com.willfp.ecoenchants.enchantments.itemtypes.Spell;
|
||||
import com.willfp.ecoenchants.util.optional.Prerequisite;
|
||||
|
||||
public abstract class MMOSpell extends Spell {
|
||||
protected MMOSpell(String key, Prerequisite... prerequisites) {
|
||||
super(key, MMOMain.class, MMOPrerequisites.append(prerequisites, MMOPrerequisites.HAS_MMOCORE));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.willfp.ecoenchants.mmo.enchants;
|
||||
|
||||
import com.willfp.ecoenchants.events.armorequip.ArmorEquipEvent;
|
||||
import com.willfp.ecoenchants.mmo.MMOEnchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Athletic extends MMOEnchantment {
|
||||
public Athletic() {
|
||||
super("augment", EnchantmentType.NORMAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArmorEquip(Player player, int level, ArmorEquipEvent event) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.willfp.ecoenchants.mmo.enchants;
|
||||
|
||||
import com.willfp.ecoenchants.events.armorequip.ArmorEquipEvent;
|
||||
import com.willfp.ecoenchants.mmo.MMOEnchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Augment extends MMOEnchantment {
|
||||
public Augment() {
|
||||
super("augment", EnchantmentType.NORMAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArmorEquip(Player player, int level, ArmorEquipEvent event) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.willfp.ecoenchants.mmo.enchants.abilities;
|
||||
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantChecks;
|
||||
import com.willfp.ecoenchants.mmo.MMOEnchantment;
|
||||
import com.willfp.ecoenchants.mmo.MMOPrerequisites;
|
||||
import net.Indyuce.mmoitems.api.event.AbilityUseEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
public class Discounted extends MMOEnchantment {
|
||||
public Discounted() {
|
||||
super("discounted", EnchantmentType.NORMAL, MMOPrerequisites.HAS_MMOITEMS);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onAbility(AbilityUseEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if(!EnchantChecks.mainhand(player, this))
|
||||
return;
|
||||
|
||||
int level = EnchantChecks.getMainhandLevel(player, this);
|
||||
|
||||
double cost = event.getAbility().getModifier("mana");
|
||||
if(cost == 0.0D) return;
|
||||
|
||||
double multiplier = 1 - (this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier") * level);
|
||||
cost *= multiplier;
|
||||
|
||||
event.getAbility().setModifier("mana", cost);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.willfp.ecoenchants.mmo.enchants.abilities;
|
||||
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantChecks;
|
||||
import com.willfp.ecoenchants.mmo.MMOEnchantment;
|
||||
import com.willfp.ecoenchants.mmo.MMOPrerequisites;
|
||||
import net.Indyuce.mmoitems.api.event.AbilityUseEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
public class Recover extends MMOEnchantment {
|
||||
public Recover() {
|
||||
super("recover", EnchantmentType.NORMAL, MMOPrerequisites.HAS_MMOITEMS);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onAbility(AbilityUseEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if(!EnchantChecks.mainhand(player, this))
|
||||
return;
|
||||
|
||||
int level = EnchantChecks.getMainhandLevel(player, this);
|
||||
|
||||
double cooldown = event.getAbility().getModifier("cooldown");
|
||||
|
||||
if(cooldown == 0.0D) return;
|
||||
|
||||
double multiplier = 1 - (this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier") * level);
|
||||
cooldown *= multiplier;
|
||||
|
||||
event.getAbility().setModifier("cooldown", cooldown);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.willfp.ecoenchants.mmo.enchants.mana;
|
||||
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.mmo.MMOSpell;
|
||||
import com.willfp.ecoenchants.mmo.integrations.mmo.MMOManager;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class Drain extends MMOSpell {
|
||||
public Drain() {
|
||||
super("drain");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUse(Player player, int level, PlayerInteractEvent event) {
|
||||
double radius = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "radius-per-level") * level;
|
||||
double amount = 1 - ((this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "percentage-per-level") / 100) * level);
|
||||
|
||||
player.getNearbyEntities(radius, radius, radius).forEach(entity -> {
|
||||
if(!(entity instanceof Player))
|
||||
return;
|
||||
|
||||
Player victim = (Player) entity;
|
||||
MMOManager.setMana(victim, MMOManager.getMana(player) * amount);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.willfp.ecoenchants.mmo.enchants.mana;
|
||||
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.mmo.MMOEnchantment;
|
||||
import com.willfp.ecoenchants.mmo.integrations.mmo.MMOManager;
|
||||
import com.willfp.ecoenchants.nms.Cooldown;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
public class Elixir extends MMOEnchantment {
|
||||
public Elixir() {
|
||||
super("elixir", EnchantmentType.NORMAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) {
|
||||
if(!(attacker instanceof Player && victim instanceof Player))
|
||||
return;
|
||||
Player pAttacker = (Player) attacker;
|
||||
Player pVictim = (Player) victim;
|
||||
|
||||
boolean notcharged = this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged");
|
||||
if (Cooldown.getCooldown(pAttacker) != 1.0f && !notcharged)
|
||||
return;
|
||||
|
||||
double victimMana = MMOManager.getMana(pVictim);
|
||||
|
||||
double quantity = (this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "percentage-per-level") / 100) * level;
|
||||
|
||||
double toSteal = victimMana * quantity;
|
||||
|
||||
MMOManager.setMana(pVictim, victimMana - toSteal);
|
||||
MMOManager.giveMana(pAttacker, toSteal);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.willfp.ecoenchants.mmo.enchants.mana;
|
||||
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.mmo.MMOEnchantment;
|
||||
import com.willfp.ecoenchants.mmo.integrations.mmo.MMOManager;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
public class Siphon extends MMOEnchantment {
|
||||
public Siphon() {
|
||||
super("siphon", EnchantmentType.NORMAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, EntityDamageByEntityEvent event) {
|
||||
if(!(attacker instanceof Player && victim instanceof Player))
|
||||
return;
|
||||
Player pAttacker = (Player) attacker;
|
||||
Player pVictim = (Player) victim;
|
||||
|
||||
double victimMana = MMOManager.getMana(pVictim);
|
||||
|
||||
double quantity = (this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "percentage-per-level") / 100) * level;
|
||||
|
||||
double toSteal = victimMana * quantity;
|
||||
|
||||
MMOManager.setMana(pVictim, victimMana - toSteal);
|
||||
MMOManager.giveMana(pAttacker, toSteal);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.willfp.ecoenchants.mmo.enchants.mana;
|
||||
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantChecks;
|
||||
import com.willfp.ecoenchants.mmo.MMOEnchantment;
|
||||
import net.Indyuce.mmocore.api.event.PlayerRegenResourceEvent;
|
||||
import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
public class Spirituality extends MMOEnchantment {
|
||||
public Spirituality() {
|
||||
super("spirituality", EnchantmentType.NORMAL);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onRegainMana(PlayerRegenResourceEvent event) {
|
||||
if(!event.getResource().equals(PlayerResource.MANA))
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
int levels = EnchantChecks.getArmorPoints(player, this);
|
||||
if(levels == 0) return;
|
||||
|
||||
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier") * levels;
|
||||
event.setAmount(event.getAmount() * (multiplier + 1));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.willfp.ecoenchants.mmo.enchants.stamina;
|
||||
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantChecks;
|
||||
import com.willfp.ecoenchants.mmo.MMOEnchantment;
|
||||
import net.Indyuce.mmocore.api.event.PlayerRegenResourceEvent;
|
||||
import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
public class Endurance extends MMOEnchantment {
|
||||
public Endurance() {
|
||||
super("endurance", EnchantmentType.NORMAL);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onRegainMana(PlayerRegenResourceEvent event) {
|
||||
if(!event.getResource().equals(PlayerResource.STAMINA))
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
int levels = EnchantChecks.getArmorPoints(player, this);
|
||||
if(levels == 0) return;
|
||||
|
||||
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier") * levels;
|
||||
event.setAmount(event.getAmount() * (multiplier + 1));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.willfp.ecoenchants.mmo.enchants.stamina;
|
||||
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.mmo.MMOEnchantment;
|
||||
import com.willfp.ecoenchants.mmo.integrations.mmo.MMOManager;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
public class Fortitude extends MMOEnchantment {
|
||||
public Fortitude() {
|
||||
super("fortitude", EnchantmentType.NORMAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, EntityDamageByEntityEvent event) {
|
||||
if(!(attacker instanceof Player && victim instanceof Player))
|
||||
return;
|
||||
Player pAttacker = (Player) attacker;
|
||||
Player pVictim = (Player) victim;
|
||||
|
||||
double victimStamina = MMOManager.getStamina(pVictim);
|
||||
|
||||
double quantity = (this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "percentage-per-level") / 100) * level;
|
||||
|
||||
double toSteal = victimStamina * quantity;
|
||||
|
||||
MMOManager.setStamina(pVictim, victimStamina - toSteal);
|
||||
MMOManager.giveStamina(pAttacker, toSteal);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.willfp.ecoenchants.mmo.enchants.stamina;
|
||||
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.mmo.MMOEnchantment;
|
||||
import com.willfp.ecoenchants.mmo.integrations.mmo.MMOManager;
|
||||
import com.willfp.ecoenchants.nms.Cooldown;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
public class Motivate extends MMOEnchantment {
|
||||
public Motivate() {
|
||||
super("motivate", EnchantmentType.NORMAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) {
|
||||
if(!(attacker instanceof Player && victim instanceof Player))
|
||||
return;
|
||||
Player pAttacker = (Player) attacker;
|
||||
Player pVictim = (Player) victim;
|
||||
|
||||
boolean notcharged = this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged");
|
||||
if (Cooldown.getCooldown(pAttacker) != 1.0f && !notcharged)
|
||||
return;
|
||||
|
||||
double victimStamina = MMOManager.getStamina(pVictim);
|
||||
|
||||
double quantity = (this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "percentage-per-level") / 100) * level;
|
||||
|
||||
double toSteal = victimStamina * quantity;
|
||||
|
||||
MMOManager.setStamina(pVictim, victimStamina - toSteal);
|
||||
MMOManager.giveStamina(pAttacker, toSteal);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.willfp.ecoenchants.mmo.integrations.mmo;
|
||||
|
||||
import com.willfp.ecoenchants.integrations.Integration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface MMOIntegration extends Integration {
|
||||
double getMana(Player player);
|
||||
void setMana(Player player, double amount);
|
||||
double getMaxMana(Player player);
|
||||
void giveMana(Player player, double amount);
|
||||
|
||||
double getStamina(Player player);
|
||||
void setStamina(Player player, double amount);
|
||||
double getMaxStamina(Player player);
|
||||
void giveStamina(Player player, double amount);
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.willfp.ecoenchants.mmo.integrations.mmo;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class MMOManager {
|
||||
private static final Set<MMOIntegration> integrations = new HashSet<>();
|
||||
|
||||
public static void register(MMOIntegration integration) {
|
||||
integrations.add(integration);
|
||||
}
|
||||
|
||||
private static MMOIntegration getIntegration() {
|
||||
Validate.notEmpty(integrations, "There must be an existing mmo integration!");
|
||||
return integrations.stream().findFirst().get();
|
||||
}
|
||||
|
||||
public static double getMana(Player player) {
|
||||
MMOIntegration integration = getIntegration();
|
||||
return integration.getMana(player);
|
||||
}
|
||||
|
||||
public static double getMaxMana(Player player) {
|
||||
MMOIntegration integration = getIntegration();
|
||||
return integration.getMaxMana(player);
|
||||
}
|
||||
|
||||
public static void setMana(Player player, double amount) {
|
||||
MMOIntegration integration = getIntegration();
|
||||
integration.setMana(player, amount);
|
||||
}
|
||||
|
||||
public static void giveMana(Player player, double amount) {
|
||||
MMOIntegration integration = getIntegration();
|
||||
integration.giveMana(player, amount);
|
||||
}
|
||||
|
||||
public static double getStamina(Player player) {
|
||||
MMOIntegration integration = getIntegration();
|
||||
return integration.getMana(player);
|
||||
}
|
||||
|
||||
public static double getMaxStamina(Player player) {
|
||||
MMOIntegration integration = getIntegration();
|
||||
return integration.getMaxMana(player);
|
||||
}
|
||||
|
||||
public static void setStamina(Player player, double amount) {
|
||||
MMOIntegration integration = getIntegration();
|
||||
integration.setMana(player, amount);
|
||||
}
|
||||
|
||||
public static void giveStamina(Player player, double amount) {
|
||||
MMOIntegration integration = getIntegration();
|
||||
integration.giveMana(player, amount);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.willfp.ecoenchants.mmo.integrations.mmo.plugins;
|
||||
|
||||
import com.willfp.ecoenchants.mmo.integrations.mmo.MMOIntegration;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.player.stats.StatType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class MMOCore implements MMOIntegration {
|
||||
@Override
|
||||
public double getMana(Player player) {
|
||||
return PlayerData.get(player).getMana();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMana(Player player, double amount) {
|
||||
PlayerData.get(player).setMana(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveMana(Player player, double amount) {
|
||||
PlayerData.get(player).giveMana(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxMana(Player player) {
|
||||
return PlayerData.get(player).getStats().getStat(StatType.MAX_MANA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getStamina(Player player) {
|
||||
return PlayerData.get(player).getStamina();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStamina(Player player, double amount) {
|
||||
PlayerData.get(player).setStamina(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveStamina(Player player, double amount) {
|
||||
PlayerData.get(player).giveStamina(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxStamina(Player player) {
|
||||
return PlayerData.get(player).getStats().getStat(StatType.MAX_STAMINA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginName() {
|
||||
return "MMOCore";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#
|
||||
# Discounted EcoEnchant
|
||||
#
|
||||
|
||||
name: "Discounted"
|
||||
description: Reduces mana cost for abilities.
|
||||
enabled: true
|
||||
|
||||
obtaining:
|
||||
table: true
|
||||
villager: true
|
||||
loot: true
|
||||
rarity: epic
|
||||
|
||||
general-config:
|
||||
targets:
|
||||
- bow
|
||||
- sword
|
||||
- axe
|
||||
grindstoneable: true
|
||||
conflicts: []
|
||||
maximum-level: 5
|
||||
|
||||
config:
|
||||
multiplier: 0.1 # Mana cost = initial cost * (1 - multiplier * level), thus 10 cost with discounted 5 means final cost is 5
|
||||
25
Extensions/MMO/src/main/resources/enchants/normal/elixir.yml
Normal file
25
Extensions/MMO/src/main/resources/enchants/normal/elixir.yml
Normal file
@@ -0,0 +1,25 @@
|
||||
#
|
||||
# Elixir EcoEnchant
|
||||
#
|
||||
|
||||
name: "Elixir"
|
||||
description: Steals a portion of your victim's mana.
|
||||
enabled: true
|
||||
|
||||
obtaining:
|
||||
table: true
|
||||
villager: true
|
||||
loot: true
|
||||
rarity: epic
|
||||
|
||||
general-config:
|
||||
targets:
|
||||
- sword
|
||||
- axe
|
||||
grindstoneable: true
|
||||
conflicts: []
|
||||
maximum-level: 3
|
||||
|
||||
config:
|
||||
allow-not-fully-charged: false
|
||||
percentage-per-level: 5 # Percentage of your opponents mana to steal per level
|
||||
@@ -0,0 +1,29 @@
|
||||
#
|
||||
# Endurance EcoEnchant
|
||||
#
|
||||
|
||||
name: "Endurance"
|
||||
description: Increases the rate that you regain stamina.
|
||||
enabled: true
|
||||
|
||||
obtaining:
|
||||
table: true
|
||||
villager: true
|
||||
loot: true
|
||||
rarity: epic
|
||||
|
||||
general-config:
|
||||
targets:
|
||||
- helmet
|
||||
- chestplate
|
||||
- leggings
|
||||
- boots
|
||||
grindstoneable: true
|
||||
conflicts: []
|
||||
maximum-level: 4
|
||||
|
||||
config:
|
||||
multiplier: 0.1 # How many times faster to regain per level
|
||||
# The formula is default amount * (1 + (multiplier * level))
|
||||
# ie, If you were going to regen 10 stamina with a multiplier of 0.1 and 8 levels, then you would regenerate:
|
||||
# 10 * (1 + (0.1 * 8)) = 10 * 1.8 = 18
|
||||
@@ -0,0 +1,24 @@
|
||||
#
|
||||
# Fortitude EcoEnchant
|
||||
#
|
||||
|
||||
name: "Fortitude"
|
||||
description: Steals a portion of your victim's stamina.
|
||||
enabled: true
|
||||
|
||||
obtaining:
|
||||
table: true
|
||||
villager: true
|
||||
loot: true
|
||||
rarity: epic
|
||||
|
||||
general-config:
|
||||
targets:
|
||||
- bow
|
||||
- crossbow
|
||||
grindstoneable: true
|
||||
conflicts: []
|
||||
maximum-level: 3
|
||||
|
||||
config:
|
||||
percentage-per-level: 5 # Percentage of your opponents stamina to steal per level
|
||||
@@ -0,0 +1,25 @@
|
||||
#
|
||||
# Motivate EcoEnchant
|
||||
#
|
||||
|
||||
name: "Motivate"
|
||||
description: Steals a portion of your victim's stamina.
|
||||
enabled: true
|
||||
|
||||
obtaining:
|
||||
table: true
|
||||
villager: true
|
||||
loot: true
|
||||
rarity: epic
|
||||
|
||||
general-config:
|
||||
targets:
|
||||
- sword
|
||||
- axe
|
||||
grindstoneable: true
|
||||
conflicts: []
|
||||
maximum-level: 3
|
||||
|
||||
config:
|
||||
allow-not-fully-charged: false
|
||||
percentage-per-level: 5 # Percentage of your opponents stamina to steal per level
|
||||
@@ -0,0 +1,25 @@
|
||||
#
|
||||
# Recover EcoEnchant
|
||||
#
|
||||
|
||||
name: "Recover"
|
||||
description: Reduces cooldown for abilities.
|
||||
enabled: true
|
||||
|
||||
obtaining:
|
||||
table: true
|
||||
villager: true
|
||||
loot: true
|
||||
rarity: epic
|
||||
|
||||
general-config:
|
||||
targets:
|
||||
- bow
|
||||
- sword
|
||||
- axe
|
||||
grindstoneable: true
|
||||
conflicts: []
|
||||
maximum-level: 5
|
||||
|
||||
config:
|
||||
multiplier: 0.1 # Cooldown = initial cooldown * (1 - multiplier * level), thus 8 cooldown with recover 5 means final cooldown is 4
|
||||
24
Extensions/MMO/src/main/resources/enchants/normal/siphon.yml
Normal file
24
Extensions/MMO/src/main/resources/enchants/normal/siphon.yml
Normal file
@@ -0,0 +1,24 @@
|
||||
#
|
||||
# Siphon EcoEnchant
|
||||
#
|
||||
|
||||
name: "Siphon"
|
||||
description: Steals a portion of your victim's mana.
|
||||
enabled: true
|
||||
|
||||
obtaining:
|
||||
table: true
|
||||
villager: true
|
||||
loot: true
|
||||
rarity: epic
|
||||
|
||||
general-config:
|
||||
targets:
|
||||
- bow
|
||||
- crossbow
|
||||
grindstoneable: true
|
||||
conflicts: []
|
||||
maximum-level: 3
|
||||
|
||||
config:
|
||||
percentage-per-level: 5 # Percentage of your opponents mana to steal per level
|
||||
@@ -0,0 +1,29 @@
|
||||
#
|
||||
# Spirituality EcoEnchant
|
||||
#
|
||||
|
||||
name: "Spirituality"
|
||||
description: Increases the rate that you regain mana.
|
||||
enabled: true
|
||||
|
||||
obtaining:
|
||||
table: true
|
||||
villager: true
|
||||
loot: true
|
||||
rarity: epic
|
||||
|
||||
general-config:
|
||||
targets:
|
||||
- helmet
|
||||
- chestplate
|
||||
- leggings
|
||||
- boots
|
||||
grindstoneable: true
|
||||
conflicts: []
|
||||
maximum-level: 4
|
||||
|
||||
config:
|
||||
multiplier: 0.1 # How many times faster to regain per level
|
||||
# The formula is default amount * (1 + (multiplier * level))
|
||||
# ie, If you were going to regen 10 mana with a multiplier of 0.1 and 8 levels, then you would regenerate:
|
||||
# 10 * (1 + (0.1 * 8)) = 10 * 1.8 = 18
|
||||
26
Extensions/MMO/src/main/resources/enchants/spell/drain.yml
Normal file
26
Extensions/MMO/src/main/resources/enchants/spell/drain.yml
Normal file
@@ -0,0 +1,26 @@
|
||||
#
|
||||
# Drain EcoEnchant
|
||||
#
|
||||
|
||||
name: "Drain"
|
||||
description: Reduces all nearby players' mana.
|
||||
enabled: true
|
||||
|
||||
obtaining:
|
||||
table: true
|
||||
villager: true
|
||||
loot: true
|
||||
rarity: legendary
|
||||
|
||||
general-config:
|
||||
targets:
|
||||
- sword
|
||||
grindstoneable: true
|
||||
conflicts: []
|
||||
maximum-level: 3
|
||||
|
||||
config:
|
||||
activation-sound: ENTITY_ENDERMAN_TELEPORT
|
||||
cooldown: 240 # In seconds
|
||||
radius-per-level: 10 # Radius to check nearby players' mana
|
||||
percentage-per-level: 10 # Percentage of nearby players' mana to reduce
|
||||
3
Extensions/MMO/src/main/resources/extension.yml
Normal file
3
Extensions/MMO/src/main/resources/extension.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
name: MMO
|
||||
main: com.willfp.ecoenchants.mmo.MMOMain
|
||||
version: 1.0.0
|
||||
@@ -37,3 +37,7 @@ findProject(':SprintArtifacts').projectDir = file('Extensions/SprintArtifacts')
|
||||
|
||||
include('Alchemy')
|
||||
findProject(':Alchemy').projectDir = file('Extensions/Alchemy')
|
||||
|
||||
include('MMO')
|
||||
findProject(':MMO').projectDir = file('Extensions/MMO')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user