Refactored and Improved MMO

This commit is contained in:
Auxilor 2020-11-29 09:32:18 +00:00
parent c49d690c9e
commit c81afe8d58
23 changed files with 232 additions and 47 deletions

View File

@ -1,3 +1,7 @@
plugins {
id 'com.github.johnrengelman.shadow' version '5.2.0'
}
repositories { repositories {
maven { maven {
url 'https://mvn.lumine.io/repository/maven-public/' url 'https://mvn.lumine.io/repository/maven-public/'
@ -9,6 +13,7 @@ dependencies {
compileOnly project(':plugin') compileOnly project(':plugin')
compileOnly 'net.Indyuce:MMOCore:1.4.11' compileOnly 'net.Indyuce:MMOCore:1.4.11'
compileOnly 'net.Indyuce:MMOItems:6.4' compileOnly 'net.Indyuce:MMOItems:6.4'
shadow files('/lib/MMOLib-1.4.3.jar')
} }
jar{ jar{

Binary file not shown.

View File

@ -1,9 +1,11 @@
package com.willfp.ecoenchants.mmo; package com.willfp.ecoenchants.mmo;
import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.extensions.Extension; import com.willfp.ecoenchants.extensions.Extension;
import com.willfp.ecoenchants.mmo.enchants.Athletic; import com.willfp.ecoenchants.mmo.enchants.misc.Strengthening;
import com.willfp.ecoenchants.mmo.enchants.Augment; 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.Discounted;
import com.willfp.ecoenchants.mmo.enchants.abilities.Recover; import com.willfp.ecoenchants.mmo.enchants.abilities.Recover;
import com.willfp.ecoenchants.mmo.enchants.mana.Drain; 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.Endurance;
import com.willfp.ecoenchants.mmo.enchants.stamina.Fortitude; import com.willfp.ecoenchants.mmo.enchants.stamina.Fortitude;
import com.willfp.ecoenchants.mmo.enchants.stamina.Motivate; import com.willfp.ecoenchants.mmo.enchants.stamina.Motivate;
import com.willfp.ecoenchants.mmo.structure.MMOEnchant;
import com.willfp.ecoenchants.util.Logger; import com.willfp.ecoenchants.util.Logger;
import org.bukkit.Bukkit;
public class MMOMain extends Extension { public class MMOMain extends Extension {
public static final EcoEnchant ELIXIR = new Elixir(); 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 FORTITUDE = new Fortitude();
public static final EcoEnchant MOTIVATE = new Motivate(); public static final EcoEnchant MOTIVATE = new Motivate();
public static final EcoEnchant ATHLETIC = new Athletic(); public static final EcoEnchant ATHLETIC = new Athletic();
public static final EcoEnchant STRENGTHENING = new Strengthening();
@Override @Override
protected void onEnable() { protected void onEnable() {
@ -35,6 +40,10 @@ public class MMOMain extends Extension {
Logger.error("Disabling..."); Logger.error("Disabling...");
this.disable(); this.disable();
} }
MMOEnchant.REGISTRY.forEach(mmoEnchant -> {
Bukkit.getPluginManager().registerEvents((EcoEnchant) mmoEnchant, EcoEnchantsPlugin.getInstance());
});
} }
@Override @Override

View File

@ -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) {
}
}

View File

@ -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) {
}
}

View File

@ -2,7 +2,7 @@ package com.willfp.ecoenchants.mmo.enchants.abilities;
import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.util.EnchantChecks; 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 com.willfp.ecoenchants.mmo.MMOPrerequisites;
import net.Indyuce.mmoitems.api.event.AbilityUseEvent; import net.Indyuce.mmoitems.api.event.AbilityUseEvent;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -2,7 +2,7 @@ package com.willfp.ecoenchants.mmo.enchants.abilities;
import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.util.EnchantChecks; 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 com.willfp.ecoenchants.mmo.MMOPrerequisites;
import net.Indyuce.mmoitems.api.event.AbilityUseEvent; import net.Indyuce.mmoitems.api.event.AbilityUseEvent;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -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());
}
}

View File

@ -1,7 +1,7 @@
package com.willfp.ecoenchants.mmo.enchants.mana; package com.willfp.ecoenchants.mmo.enchants.mana;
import com.willfp.ecoenchants.enchantments.EcoEnchants; 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 com.willfp.ecoenchants.mmo.integrations.mmo.MMOManager;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;

View File

@ -1,7 +1,7 @@
package com.willfp.ecoenchants.mmo.enchants.mana; package com.willfp.ecoenchants.mmo.enchants.mana;
import com.willfp.ecoenchants.enchantments.EcoEnchants; 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.mmo.integrations.mmo.MMOManager;
import com.willfp.ecoenchants.nms.Cooldown; import com.willfp.ecoenchants.nms.Cooldown;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;

View File

@ -1,7 +1,7 @@
package com.willfp.ecoenchants.mmo.enchants.mana; package com.willfp.ecoenchants.mmo.enchants.mana;
import com.willfp.ecoenchants.enchantments.EcoEnchants; 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.mmo.integrations.mmo.MMOManager;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;

View File

@ -2,7 +2,7 @@ package com.willfp.ecoenchants.mmo.enchants.mana;
import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.util.EnchantChecks; 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.event.PlayerRegenResourceEvent;
import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource; import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -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());
}
}

View File

@ -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());
}
}

View File

@ -2,7 +2,7 @@ package com.willfp.ecoenchants.mmo.enchants.stamina;
import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.util.EnchantChecks; 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.event.PlayerRegenResourceEvent;
import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource; import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -1,7 +1,7 @@
package com.willfp.ecoenchants.mmo.enchants.stamina; package com.willfp.ecoenchants.mmo.enchants.stamina;
import com.willfp.ecoenchants.enchantments.EcoEnchants; 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.mmo.integrations.mmo.MMOManager;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;

View File

@ -1,7 +1,7 @@
package com.willfp.ecoenchants.mmo.enchants.stamina; package com.willfp.ecoenchants.mmo.enchants.stamina;
import com.willfp.ecoenchants.enchantments.EcoEnchants; 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.mmo.integrations.mmo.MMOManager;
import com.willfp.ecoenchants.nms.Cooldown; import com.willfp.ecoenchants.nms.Cooldown;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;

View File

@ -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<>();
}

View File

@ -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.enchantments.EcoEnchant;
import com.willfp.ecoenchants.mmo.MMOMain;
import com.willfp.ecoenchants.mmo.MMOPrerequisites;
import com.willfp.ecoenchants.util.optional.Prerequisite; 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) { protected MMOEnchantment(String key, EnchantmentType type, Prerequisite... prerequisites) {
super(key, type, MMOMain.class, MMOPrerequisites.append(prerequisites, MMOPrerequisites.HAS_MMOCORE)); super(key, type, MMOMain.class, MMOPrerequisites.append(prerequisites, MMOPrerequisites.HAS_MMOCORE));
MMOEnchant.REGISTRY.add(this);
} }
} }

View File

@ -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.enchantments.itemtypes.Spell;
import com.willfp.ecoenchants.mmo.MMOMain;
import com.willfp.ecoenchants.mmo.MMOPrerequisites;
import com.willfp.ecoenchants.util.optional.Prerequisite; 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) { protected MMOSpell(String key, Prerequisite... prerequisites) {
super(key, MMOMain.class, MMOPrerequisites.append(prerequisites, MMOPrerequisites.HAS_MMOCORE)); super(key, MMOMain.class, MMOPrerequisites.append(prerequisites, MMOPrerequisites.HAS_MMOCORE));
MMOEnchant.REGISTRY.add(this);
} }
} }

View File

@ -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

View File

@ -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

View File

@ -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