This commit is contained in:
Ka0rX 2022-07-28 12:27:33 +02:00
parent 39e5096c3b
commit b3d783dea4
2 changed files with 333 additions and 339 deletions

View File

@ -7,6 +7,7 @@ import io.lumine.mythic.utils.plugin.LuminePlugin;
import net.Indyuce.mmocore.api.ConfigFile;
import net.Indyuce.mmocore.api.PlayerActionBar;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.player.attribute.AttributeModifier;
import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource;
import net.Indyuce.mmocore.api.player.stats.StatType;
import net.Indyuce.mmocore.api.util.debug.DebugMode;
@ -24,6 +25,7 @@ import net.Indyuce.mmocore.comp.region.WorldGuardMMOLoader;
import net.Indyuce.mmocore.comp.region.WorldGuardRegionHandler;
import net.Indyuce.mmocore.comp.vault.VaultEconomy;
import net.Indyuce.mmocore.comp.vault.VaultMMOLoader;
import net.Indyuce.mmocore.guild.GuildModule;
import net.Indyuce.mmocore.guild.GuildModuleType;
import net.Indyuce.mmocore.guild.provided.Guild;
import net.Indyuce.mmocore.guild.provided.MMOCoreGuildModule;
@ -46,11 +48,17 @@ import net.Indyuce.mmocore.party.PartyModule;
import net.Indyuce.mmocore.party.PartyModuleType;
import net.Indyuce.mmocore.party.provided.MMOCorePartyModule;
import net.Indyuce.mmocore.skill.cast.SkillCastingMode;
import net.Indyuce.mmocore.skill.custom.mechanic.ExperienceMechanic;
import net.Indyuce.mmocore.skill.custom.mechanic.ManaMechanic;
import net.Indyuce.mmocore.skill.custom.mechanic.StaminaMechanic;
import net.Indyuce.mmocore.skill.custom.mechanic.StelliumMechanic;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import io.lumine.mythic.lib.metrics.bukkit.Metrics;
import org.bukkit.command.CommandMap;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
@ -59,7 +67,7 @@ import java.lang.reflect.Field;
import java.util.Iterator;
import java.util.logging.Level;
public class MMOCore extends LuminePlugin {
public class MMOCore extends JavaPlugin {
public static MMOCore plugin;
public final WaypointManager waypointManager = new WaypointManager();
@ -98,7 +106,7 @@ public class MMOCore extends LuminePlugin {
// Modules
@NotNull
public PartyModule partyModule;
public GuildModule guildModule;
public boolean shouldDebugSQL = false;
private static final int MYTHICLIB_COMPATIBILITY_INDEX = 7;
@ -107,17 +115,19 @@ public class MMOCore extends LuminePlugin {
plugin = this;
}
public void load() {
@Override
public void onLoad() {
// Check if the ML build matches
if (MYTHICLIB_COMPATIBILITY_INDEX != MythicLib.MMOCORE_COMPATIBILITY_INDEX) {
getLogger().log(Level.WARNING, "Your versions of MythicLib and MMOCore do not match. Make sure you are using the latest builds of both plugins");
disable();
return;
}
// Register target restrictions due to MMOCore in MythicLib
// Register MMOCore-specific objects
MythicLib.plugin.getEntities().registerRestriction(new MMOCoreTargetRestriction());
MythicLib.plugin.getModifiers().registerModifierType("attribute", configObject -> new AttributeModifier(configObject));
// Skill creation
MythicLib.plugin.getSkills().registerMechanic("mana", config -> new ManaMechanic(config));
MythicLib.plugin.getSkills().registerMechanic("stamina", config -> new StaminaMechanic(config));
MythicLib.plugin.getSkills().registerMechanic("stellium", config -> new StelliumMechanic(config));
MythicLib.plugin.getSkills().registerMechanic("experience", config -> new ExperienceMechanic(config));
// Register extra objective, drop items...
if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null)
@ -189,22 +199,6 @@ public class MMOCore extends LuminePlugin {
}
}.runTaskTimer(MMOCore.plugin, 100, 20);
/*
* Clean active loot chests every 5 minutes. Cannot register this runnable in
* the loot chest manager because it is instanced when the plugin loads
*/
new BukkitRunnable() {
public void run() {
Iterator<LootChest> iterator = lootChests.getActive().iterator();
while (iterator.hasNext()) {
LootChest next = iterator.next();
if (next.shouldExpire()) {
iterator.remove();
next.expire(false);
}
}
}
}.runTaskTimer(this, 5 * 60 * 20, 5 * 60 * 20);
/*
* For the sake of the lord, make sure they aren't using MMOItems Mana and
@ -242,7 +236,6 @@ public class MMOCore extends LuminePlugin {
}
// Load party module
try {
String partyPluginName = UtilityMethods.enumName(getConfig().getString("party-plugin"));
@ -374,7 +367,8 @@ public class MMOCore extends LuminePlugin {
}
}
public void disable() {
@Override
public void onDisable() {
// Save player data
for (PlayerData data : PlayerData.getAll())
@ -402,7 +396,7 @@ public class MMOCore extends LuminePlugin {
* Called either when the server starts when initializing the manager for
* the first time, or when issuing a plugin reload; in that case, stuff
* like listeners must all be cleared before.
*
* <p>
* Also see {@link MMOCoreManager}
*
* @param clearBefore True when issuing a plugin reload
@ -442,7 +436,6 @@ public class MMOCore extends LuminePlugin {
if (getConfig().isConfigurationSection("action-bar"))
actionBarManager.reload(getConfig().getConfigurationSection("action-bar"));
StatType.load();
if (clearBefore)
PlayerData.getAll().forEach(PlayerData::update);

View File

@ -278,7 +278,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
}
}
Bukkit.broadcastMessage(playerStats.getStat(StatType.HEALTH_REGENERATION)+"");
Bukkit.broadcastMessage(playerStats.getStat("HEALTH_REGENERATION")+"");
if (nodeStates.get(node) == NodeState.UNLOCKABLE)
setNodeState(node, NodeState.UNLOCKED);
@ -812,8 +812,9 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
return;
}
value = MMOCore.plugin.boosterManager.calculateExp(null, value);
value *= 1 + getStats().getStat(StatType.ADDITIONAL_EXPERIENCE) / 100;
// Apply buffs AFTER splitting exp
value *= (1 + getStats().getStat("ADDITIONAL_EXPERIENCE") / 100) * MMOCore.plugin.boosterManager.getMultiplier(null);
// Splitting exp through party members
AbstractParty party;