mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-11-26 15:45:12 +01:00
Refactored and Improved MMO
This commit is contained in:
parent
c49d690c9e
commit
c81afe8d58
@ -1,3 +1,7 @@
|
||||
plugins {
|
||||
id 'com.github.johnrengelman.shadow' version '5.2.0'
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
url 'https://mvn.lumine.io/repository/maven-public/'
|
||||
@ -9,6 +13,7 @@ dependencies {
|
||||
compileOnly project(':plugin')
|
||||
compileOnly 'net.Indyuce:MMOCore:1.4.11'
|
||||
compileOnly 'net.Indyuce:MMOItems:6.4'
|
||||
shadow files('/lib/MMOLib-1.4.3.jar')
|
||||
}
|
||||
|
||||
jar{
|
||||
|
BIN
Extensions/MMO/lib/MMOLib-1.4.3.jar
Normal file
BIN
Extensions/MMO/lib/MMOLib-1.4.3.jar
Normal file
Binary file not shown.
@ -1,9 +1,11 @@
|
||||
package com.willfp.ecoenchants.mmo;
|
||||
|
||||
import com.willfp.ecoenchants.EcoEnchantsPlugin;
|
||||
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.misc.Strengthening;
|
||||
import com.willfp.ecoenchants.mmo.enchants.stamina.Athletic;
|
||||
import com.willfp.ecoenchants.mmo.enchants.mana.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;
|
||||
@ -13,7 +15,9 @@ 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.mmo.structure.MMOEnchant;
|
||||
import com.willfp.ecoenchants.util.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class MMOMain extends Extension {
|
||||
public static final EcoEnchant ELIXIR = new Elixir();
|
||||
@ -27,6 +31,7 @@ public class MMOMain extends Extension {
|
||||
public static final EcoEnchant FORTITUDE = new Fortitude();
|
||||
public static final EcoEnchant MOTIVATE = new Motivate();
|
||||
public static final EcoEnchant ATHLETIC = new Athletic();
|
||||
public static final EcoEnchant STRENGTHENING = new Strengthening();
|
||||
|
||||
@Override
|
||||
protected void onEnable() {
|
||||
@ -35,6 +40,10 @@ public class MMOMain extends Extension {
|
||||
Logger.error("Disabling...");
|
||||
this.disable();
|
||||
}
|
||||
|
||||
MMOEnchant.REGISTRY.forEach(mmoEnchant -> {
|
||||
Bukkit.getPluginManager().registerEvents((EcoEnchant) mmoEnchant, EcoEnchantsPlugin.getInstance());
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,16 +0,0 @@
|
||||
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) {
|
||||
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
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) {
|
||||
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@ 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.structure.MMOEnchantment;
|
||||
import com.willfp.ecoenchants.mmo.MMOPrerequisites;
|
||||
import net.Indyuce.mmoitems.api.event.AbilityUseEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -2,7 +2,7 @@ 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.structure.MMOEnchantment;
|
||||
import com.willfp.ecoenchants.mmo.MMOPrerequisites;
|
||||
import net.Indyuce.mmoitems.api.event.AbilityUseEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -0,0 +1,36 @@
|
||||
package com.willfp.ecoenchants.mmo.enchants.mana;
|
||||
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.events.armorequip.ArmorEquipEvent;
|
||||
import com.willfp.ecoenchants.mmo.structure.MMOEnchantment;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.player.MMOPlayerData;
|
||||
import net.mmogroup.mmolib.api.stat.SharedStat;
|
||||
import net.mmogroup.mmolib.api.stat.modifier.StatModifier;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Augment extends MMOEnchantment {
|
||||
private static final String KEY = "ecoenchants_bonus_mana";
|
||||
|
||||
public Augment() {
|
||||
super("augment", EnchantmentType.NORMAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArmorEquip(Player player, int level, ArmorEquipEvent event) {
|
||||
MMOPlayerData data = MMOPlayerData.get(player);
|
||||
|
||||
data.getStatMap().getInstance(SharedStat.MAX_MANA).remove(KEY);
|
||||
|
||||
if(level == 0) {
|
||||
MMOLib.plugin.getStats().runUpdates(data.getStatMap());
|
||||
return;
|
||||
}
|
||||
|
||||
int mana = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "mana-per-level") * level;
|
||||
|
||||
data.getStatMap().getInstance(SharedStat.MAX_MANA).addModifier(KEY, new StatModifier(mana));
|
||||
|
||||
MMOLib.plugin.getStats().runUpdates(data.getStatMap());
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package com.willfp.ecoenchants.mmo.enchants.mana;
|
||||
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.mmo.MMOSpell;
|
||||
import com.willfp.ecoenchants.mmo.structure.MMOSpell;
|
||||
import com.willfp.ecoenchants.mmo.integrations.mmo.MMOManager;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.willfp.ecoenchants.mmo.enchants.mana;
|
||||
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.mmo.MMOEnchantment;
|
||||
import com.willfp.ecoenchants.mmo.structure.MMOEnchantment;
|
||||
import com.willfp.ecoenchants.mmo.integrations.mmo.MMOManager;
|
||||
import com.willfp.ecoenchants.nms.Cooldown;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.willfp.ecoenchants.mmo.enchants.mana;
|
||||
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.mmo.MMOEnchantment;
|
||||
import com.willfp.ecoenchants.mmo.structure.MMOEnchantment;
|
||||
import com.willfp.ecoenchants.mmo.integrations.mmo.MMOManager;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
@ -2,7 +2,7 @@ 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 com.willfp.ecoenchants.mmo.structure.MMOEnchantment;
|
||||
import net.Indyuce.mmocore.api.event.PlayerRegenResourceEvent;
|
||||
import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -0,0 +1,36 @@
|
||||
package com.willfp.ecoenchants.mmo.enchants.misc;
|
||||
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.events.armorequip.ArmorEquipEvent;
|
||||
import com.willfp.ecoenchants.mmo.structure.MMOEnchantment;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.player.MMOPlayerData;
|
||||
import net.mmogroup.mmolib.api.stat.SharedStat;
|
||||
import net.mmogroup.mmolib.api.stat.modifier.StatModifier;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Strengthening extends MMOEnchantment {
|
||||
private static final String KEY = "ecoenchants_bonus_strength";
|
||||
|
||||
public Strengthening() {
|
||||
super("strengthening", EnchantmentType.NORMAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArmorEquip(Player player, int level, ArmorEquipEvent event) {
|
||||
MMOPlayerData data = MMOPlayerData.get(player);
|
||||
|
||||
data.getStatMap().getInstance(SharedStat.ATTACK_DAMAGE).remove(KEY);
|
||||
|
||||
if(level == 0) {
|
||||
MMOLib.plugin.getStats().runUpdates(data.getStatMap());
|
||||
return;
|
||||
}
|
||||
|
||||
double multiplier = (this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "multiplier") * level) * data.getStatMap().getInstance(SharedStat.ATTACK_DAMAGE).getBase();
|
||||
|
||||
data.getStatMap().getInstance(SharedStat.ATTACK_DAMAGE).addModifier(KEY, new StatModifier(multiplier));
|
||||
|
||||
MMOLib.plugin.getStats().runUpdates(data.getStatMap());
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.willfp.ecoenchants.mmo.enchants.stamina;
|
||||
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.events.armorequip.ArmorEquipEvent;
|
||||
import com.willfp.ecoenchants.mmo.structure.MMOEnchantment;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.player.MMOPlayerData;
|
||||
import net.mmogroup.mmolib.api.stat.SharedStat;
|
||||
import net.mmogroup.mmolib.api.stat.modifier.StatModifier;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Athletic extends MMOEnchantment {
|
||||
private static final String KEY = "ecoenchants_bonus_stamina";
|
||||
|
||||
public Athletic() {
|
||||
super("athletic", EnchantmentType.NORMAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArmorEquip(Player player, int level, ArmorEquipEvent event) {
|
||||
MMOPlayerData data = MMOPlayerData.get(player);
|
||||
|
||||
data.getStatMap().getInstance(SharedStat.MAX_STAMINA).remove(KEY);
|
||||
|
||||
if(level == 0) {
|
||||
MMOLib.plugin.getStats().runUpdates(data.getStatMap());
|
||||
return;
|
||||
}
|
||||
|
||||
int stamina = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "stamina-per-level") * level;
|
||||
|
||||
data.getStatMap().getInstance(SharedStat.MAX_STAMINA).addModifier(KEY, new StatModifier(stamina));
|
||||
|
||||
MMOLib.plugin.getStats().runUpdates(data.getStatMap());
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@ 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 com.willfp.ecoenchants.mmo.structure.MMOEnchantment;
|
||||
import net.Indyuce.mmocore.api.event.PlayerRegenResourceEvent;
|
||||
import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.willfp.ecoenchants.mmo.enchants.stamina;
|
||||
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.mmo.MMOEnchantment;
|
||||
import com.willfp.ecoenchants.mmo.structure.MMOEnchantment;
|
||||
import com.willfp.ecoenchants.mmo.integrations.mmo.MMOManager;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.willfp.ecoenchants.mmo.enchants.stamina;
|
||||
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.mmo.MMOEnchantment;
|
||||
import com.willfp.ecoenchants.mmo.structure.MMOEnchantment;
|
||||
import com.willfp.ecoenchants.mmo.integrations.mmo.MMOManager;
|
||||
import com.willfp.ecoenchants.nms.Cooldown;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
@ -0,0 +1,8 @@
|
||||
package com.willfp.ecoenchants.mmo.structure;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public interface MMOEnchant {
|
||||
public static final Set<MMOEnchant> REGISTRY = new HashSet<>();
|
||||
}
|
@ -1,10 +1,14 @@
|
||||
package com.willfp.ecoenchants.mmo;
|
||||
package com.willfp.ecoenchants.mmo.structure;
|
||||
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.mmo.MMOMain;
|
||||
import com.willfp.ecoenchants.mmo.MMOPrerequisites;
|
||||
import com.willfp.ecoenchants.util.optional.Prerequisite;
|
||||
|
||||
public abstract class MMOEnchantment extends EcoEnchant {
|
||||
public abstract class MMOEnchantment extends EcoEnchant implements MMOEnchant {
|
||||
protected MMOEnchantment(String key, EnchantmentType type, Prerequisite... prerequisites) {
|
||||
super(key, type, MMOMain.class, MMOPrerequisites.append(prerequisites, MMOPrerequisites.HAS_MMOCORE));
|
||||
|
||||
MMOEnchant.REGISTRY.add(this);
|
||||
}
|
||||
}
|
@ -1,10 +1,15 @@
|
||||
package com.willfp.ecoenchants.mmo;
|
||||
package com.willfp.ecoenchants.mmo.structure
|
||||
;
|
||||
|
||||
import com.willfp.ecoenchants.enchantments.itemtypes.Spell;
|
||||
import com.willfp.ecoenchants.mmo.MMOMain;
|
||||
import com.willfp.ecoenchants.mmo.MMOPrerequisites;
|
||||
import com.willfp.ecoenchants.util.optional.Prerequisite;
|
||||
|
||||
public abstract class MMOSpell extends Spell {
|
||||
public abstract class MMOSpell extends Spell implements MMOEnchant {
|
||||
protected MMOSpell(String key, Prerequisite... prerequisites) {
|
||||
super(key, MMOMain.class, MMOPrerequisites.append(prerequisites, MMOPrerequisites.HAS_MMOCORE));
|
||||
|
||||
MMOEnchant.REGISTRY.add(this);
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
#
|
||||
# Athletic EcoEnchant
|
||||
#
|
||||
|
||||
name: "Athletic"
|
||||
description: Increases your max 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:
|
||||
stamina-per-level: 10 # Bonus max stamina to give per level
|
@ -0,0 +1,26 @@
|
||||
#
|
||||
# Augment EcoEnchant
|
||||
#
|
||||
|
||||
name: "Augment"
|
||||
description: Increases your max 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:
|
||||
mana-per-level: 10 # Bonus max mana to give per level
|
@ -0,0 +1,26 @@
|
||||
#
|
||||
# Strengthening EcoEnchant
|
||||
#
|
||||
|
||||
name: "Strengthening"
|
||||
description: Increases your attack damage while wearing.
|
||||
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.02 # Multiplier * Levels * Base Attack Damage is added to your total attack damage while wearing
|
Loading…
Reference in New Issue
Block a user