Skip to content

Commit

Permalink
Add minimessage support for tab, and few improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
xism4 committed Jun 16, 2024
1 parent e013905 commit 07a0233
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 146 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,15 @@ private void toggleSubcommand(CommandSender sender) {
private void reloadSubcommand(CommandSender sender) {
if (sender.hasPermission("sternalboard.reload")){
plugin.getRawConfig().reload();

this.config = plugin.getConfig();
plugin.setAnimateScoreboard(config.getBoolean("settings.animated"));

plugin.setAnimateScoreboard(
config.getBoolean("settings.animated")
);

plugin.getScoreboardManager().reload();

if (plugin.isAnimationEnabled()) {
plugin.getRawAnimConfig().reload();
if (plugin.getAnimationManager() != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package com.xism4.sternalboard.managers.tab;

import com.xism4.sternalboard.SternalBoardPlugin;
import com.xism4.sternalboard.managers.tab.list.LegacyTabExecutor;
import com.xism4.sternalboard.managers.tab.list.ModernTabExecutor;
import com.xism4.sternalboard.utils.GameVersion;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

public abstract class TabExecutor {

private static TabExecutor instance = null;

private static TabExecutor getInstance(JavaPlugin plugin) {
private static TabExecutor getInstance(SternalBoardPlugin plugin) {
if (instance == null) {
if (GameVersion.isGreaterEqualThan(GameVersion.v1_13_R1)) {
instance = new ModernTabExecutor(
Expand All @@ -27,7 +27,7 @@ private static TabExecutor getInstance(JavaPlugin plugin) {

public abstract void sendTab(Player player, String header, String footer);

public static void sendTabList(JavaPlugin plugin, Player player, String header, String footer) {
public static void sendTabList(SternalBoardPlugin plugin, Player player, String header, String footer) {
getInstance(plugin).sendTab(
player, header, footer
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package com.xism4.sternalboard.managers.tab.list;


import com.xism4.sternalboard.SternalBoardPlugin;
import com.xism4.sternalboard.managers.tab.TabExecutor;
import com.xism4.sternalboard.utils.color.ColorHandler;
import com.xism4.sternalboard.utils.placeholders.PlaceholderParser;
import com.xism4.sternalboard.utils.TextUtils;
import me.blueslime.nmshandlerapi.SpecifiedClass;
import me.blueslime.nmshandlerapi.method.MethodContainer;
import me.blueslime.nmshandlerapi.method.MethodData;
import me.blueslime.nmshandlerapi.utils.presets.Presets;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

import javax.annotation.Nonnull;
import java.lang.reflect.Field;
Expand Down Expand Up @@ -43,10 +42,10 @@ public class LegacyTabExecutor extends TabExecutor {

private Method playerHandler;

private final JavaPlugin plugin;
private final SternalBoardPlugin sternalBoardPlugin;

public LegacyTabExecutor(JavaPlugin plugin) {
this.plugin = plugin;
public LegacyTabExecutor(SternalBoardPlugin sternalBoardPlugin) {
this.sternalBoardPlugin = sternalBoardPlugin;

generate();
}
Expand Down Expand Up @@ -96,17 +95,9 @@ public void sendTab(Player player, String headerText, String footerText) {
String tempHeader;
String tempFooter;

if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
tempHeader = ColorHandler.convert(
PlaceholderParser.parse(player, check(headerText))
);
tempFooter = ColorHandler.convert(
PlaceholderParser.parse(player, check(footerText))
);
} else {
tempHeader = ColorHandler.convert(check(headerText));
tempFooter = ColorHandler.convert(check(footerText));
}
tempHeader = TextUtils.processPlaceholders(sternalBoardPlugin, player, check(headerText)
);
tempFooter = TextUtils.processPlaceholders(sternalBoardPlugin, player, check(footerText));

try {
Object header = buildComponent(tempHeader);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,24 @@
package com.xism4.sternalboard.managers.tab.list;

import com.xism4.sternalboard.SternalBoardPlugin;
import com.xism4.sternalboard.managers.tab.TabExecutor;
import com.xism4.sternalboard.utils.color.ColorHandler;
import com.xism4.sternalboard.utils.placeholders.PlaceholderParser;
import com.xism4.sternalboard.utils.TextUtils;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

public class ModernTabExecutor extends TabExecutor {
private final JavaPlugin plugin;
private final SternalBoardPlugin plugin;
private TextUtils textUtils;

public ModernTabExecutor(JavaPlugin plugin) {
public ModernTabExecutor(SternalBoardPlugin plugin) {
this.plugin = plugin;
}

@Override
public void sendTab(Player player, String header, String footer) {
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
player.setPlayerListHeaderFooter(
ColorHandler.convert(
PlaceholderParser.parse(player, check(header))
),
ColorHandler.convert(
PlaceholderParser.parse(player, check(footer))
)
);
return;
}
plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI");
player.setPlayerListHeaderFooter(
ColorHandler.convert(check(header)),
ColorHandler.convert(check(footer))
TextUtils.processPlaceholders(plugin, player, check(header)),
TextUtils.processPlaceholders(plugin, player, check(footer))
);
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 07a0233

Please sign in to comment.