diff --git a/src/main/java/net/Indyuce/mmocore/MMOCore.java b/src/main/java/net/Indyuce/mmocore/MMOCore.java index 2e07cc61..d867ab2a 100644 --- a/src/main/java/net/Indyuce/mmocore/MMOCore.java +++ b/src/main/java/net/Indyuce/mmocore/MMOCore.java @@ -13,6 +13,7 @@ import org.bukkit.scheduler.BukkitRunnable; import com.codingforcookies.armorequip.ArmorListener; import net.Indyuce.mmocore.api.ConfigFile; +import net.Indyuce.mmocore.api.debug.DebugMode; import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource; import net.Indyuce.mmocore.api.player.stats.StatType; @@ -232,7 +233,7 @@ public class MMOCore extends JavaPlugin { data.giveMana(data.calculateRegen(PlayerResource.MANA)); if (data.canRegen(PlayerResource.STAMINA)) - data.giveMana(data.calculateRegen(PlayerResource.STAMINA)); + data.giveStamina(data.calculateRegen(PlayerResource.STAMINA)); } } }.runTaskTimerAsynchronously(MMOCore.plugin, 100, 20); @@ -240,6 +241,12 @@ public class MMOCore extends JavaPlugin { saveDefaultConfig(); reloadPlugin(); + /* + * enable debug mode for extra debug tools. + */ + if (getConfig().getBoolean("debug")) + new DebugMode(); + Bukkit.getPluginManager().registerEvents(new PlayerAttackEventListener(), this); Bukkit.getPluginManager().registerEvents(new DamageManager(), this); diff --git a/src/main/java/net/Indyuce/mmocore/api/debug/ActionBarRunnable.java b/src/main/java/net/Indyuce/mmocore/api/debug/ActionBarRunnable.java new file mode 100644 index 00000000..38770812 --- /dev/null +++ b/src/main/java/net/Indyuce/mmocore/api/debug/ActionBarRunnable.java @@ -0,0 +1,32 @@ +package net.Indyuce.mmocore.api.debug; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; + +import net.Indyuce.mmocore.MMOCore; +import net.md_5.bungee.api.ChatMessageType; +import net.md_5.bungee.api.chat.TextComponent; + +public class ActionBarRunnable extends BukkitRunnable { + + /* + * how to enable it: set 'debug' to true in the config and use the + * 'debug-action-bar' string parameter. hot changes, only need /mmocore + * reload. + */ + + @Override + public void run() { + Bukkit.getOnlinePlayers().forEach(player -> sendActionBar(player)); + } + + private void sendActionBar(Player player) { + player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(MMOCore.plugin.placeholderParser.parse(player, getMessage()))); + } + + private String getMessage() { + String str = MMOCore.plugin.getConfig().getString("debug-action-bar.format"); + return str == null ? "" : str; + } +} diff --git a/src/main/java/net/Indyuce/mmocore/api/debug/DebugMode.java b/src/main/java/net/Indyuce/mmocore/api/debug/DebugMode.java new file mode 100644 index 00000000..74be61d7 --- /dev/null +++ b/src/main/java/net/Indyuce/mmocore/api/debug/DebugMode.java @@ -0,0 +1,10 @@ +package net.Indyuce.mmocore.api.debug; + +import net.Indyuce.mmocore.MMOCore; + +public class DebugMode { + public DebugMode() { + if (MMOCore.plugin.getConfig().getBoolean("debug-action-bar.enabled")) + new ActionBarRunnable().runTaskTimer(MMOCore.plugin, 0, 10); + } +}