mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-27 00:45:40 +01:00
added debug methods
This commit is contained in:
parent
136b97e66e
commit
29f39e0bb9
@ -13,6 +13,7 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||||||
import com.codingforcookies.armorequip.ArmorListener;
|
import com.codingforcookies.armorequip.ArmorListener;
|
||||||
|
|
||||||
import net.Indyuce.mmocore.api.ConfigFile;
|
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.PlayerData;
|
||||||
import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource;
|
import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource;
|
||||||
import net.Indyuce.mmocore.api.player.stats.StatType;
|
import net.Indyuce.mmocore.api.player.stats.StatType;
|
||||||
@ -232,7 +233,7 @@ public class MMOCore extends JavaPlugin {
|
|||||||
data.giveMana(data.calculateRegen(PlayerResource.MANA));
|
data.giveMana(data.calculateRegen(PlayerResource.MANA));
|
||||||
|
|
||||||
if (data.canRegen(PlayerResource.STAMINA))
|
if (data.canRegen(PlayerResource.STAMINA))
|
||||||
data.giveMana(data.calculateRegen(PlayerResource.STAMINA));
|
data.giveStamina(data.calculateRegen(PlayerResource.STAMINA));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.runTaskTimerAsynchronously(MMOCore.plugin, 100, 20);
|
}.runTaskTimerAsynchronously(MMOCore.plugin, 100, 20);
|
||||||
@ -240,6 +241,12 @@ public class MMOCore extends JavaPlugin {
|
|||||||
saveDefaultConfig();
|
saveDefaultConfig();
|
||||||
reloadPlugin();
|
reloadPlugin();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* enable debug mode for extra debug tools.
|
||||||
|
*/
|
||||||
|
if (getConfig().getBoolean("debug"))
|
||||||
|
new DebugMode();
|
||||||
|
|
||||||
Bukkit.getPluginManager().registerEvents(new PlayerAttackEventListener(), this);
|
Bukkit.getPluginManager().registerEvents(new PlayerAttackEventListener(), this);
|
||||||
|
|
||||||
Bukkit.getPluginManager().registerEvents(new DamageManager(), this);
|
Bukkit.getPluginManager().registerEvents(new DamageManager(), this);
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
10
src/main/java/net/Indyuce/mmocore/api/debug/DebugMode.java
Normal file
10
src/main/java/net/Indyuce/mmocore/api/debug/DebugMode.java
Normal file
@ -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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user