Skip to content

Commit

Permalink
2.0.9 - Fixed newer TAB builds support
Browse files Browse the repository at this point in the history
  • Loading branch information
Tanguygab committed Apr 8, 2024
1 parent 3247634 commit 0bafae0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group = 'io.github.tanguygab'
version = '2.0.8'
version = '2.0.9'

compileJava.options.encoding = 'UTF-8'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class ActionBarManager extends TabFeature implements UnLoadable, CommandL

@Getter private final String featureName = "ActionBar";
@Getter private final String refreshDisplayName = "&aActionBar&r";
@Getter private final String command = "/toggleactionbar";

private final TABAdditions plugin;
@Getter private final Map<String, ActionBarLine> actionBars = new LinkedHashMap<>();
Expand Down Expand Up @@ -96,7 +97,7 @@ public void onJoin(TabPlayer player) {

@Override
public boolean onCommand(@NotNull TabPlayer player, String msg) {
if (msg.equals("/toggleactionbar") && plugin.toggleCmd(toggleCmd,player,toggled,plugin.getTranslation().actionBarOn,plugin.getTranslation().actionBarOff)) {
if (msg.equals(command) && plugin.toggleCmd(toggleCmd,player,toggled,plugin.getTranslation().actionBarOn,plugin.getTranslation().actionBarOff)) {
refresh(player,true);
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
import org.jetbrains.annotations.NotNull;

import java.lang.reflect.Field;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.*;
Expand All @@ -34,6 +35,7 @@ public class Chat extends TabFeature implements UnLoadable, JoinListener, Comman

@Getter private final String featureName = "Chat";
@Getter private final String refreshDisplayName = "&aChat&r";
@Getter private final String command = "/togglechat";
private final TABAdditions plugin = TABAdditions.getInstance();
private final TAB tab = TAB.getInstance();
public final MiniMessage mm = MiniMessage.miniMessage();
Expand Down Expand Up @@ -172,6 +174,15 @@ public Chat(ConfigurationFile config) {
bukkitBridgeChatEnabled = plugin.getPlatform().isProxy() && config.getBoolean("chat-from-bukkit-bridge",false);

for (TabPlayer player : tab.getOnlinePlayers()) loadProperties(player);

try {
Field cmds = tab.getFeatureManager().getClass().getDeclaredField("listeningCommands");
cmds.setAccessible(true);
((List<String>) cmds.get(tab.getFeatureManager())).addAll(List.of("/ignore", "/clearchat",
"/togglemsg", "/socialspy", "/togglementions", "/toggleemojis", "/emojis"));
} catch (Exception e) {
e.printStackTrace();
}
}

private void loadProperties(TabPlayer player) {
Expand Down Expand Up @@ -218,7 +229,7 @@ public boolean onCommand(@NotNull TabPlayer p, String cmd) {
if (cmd.equals("/socialspy")) return p.hasPermission("tabadditions.chat.socialspy") && socialSpyManager != null && socialSpyManager.onCommand(p,cmd);

TranslationFile msgs = plugin.getTranslation();
if (cmd.equals("/togglechat")) return plugin.toggleCmd(toggleCmd,p,toggled,toggleChatPlaceholder,msgs.chatOn,msgs.chatOff,false);
if (cmd.equals(command)) return plugin.toggleCmd(toggleCmd,p,toggled,toggleChatPlaceholder,msgs.chatOn,msgs.chatOff,false);
if (cmd.equals("/clearchat")) {
if (!clearchatEnabled || !p.hasPermission("tabadditions.chat.clearchat")) return false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class TitleManager extends TabFeature implements UnLoadable, Refreshable,

@Getter private final String featureName = "Title";
@Getter private final String refreshDisplayName = "&aTitle&r";
@Getter private final String command = "/toggletitle";

private final TABAdditions plugin;
@Getter private final Map<String, Title> titles = new HashMap<>();
Expand Down Expand Up @@ -94,7 +95,7 @@ public void onJoin(TabPlayer player) {

@Override
public boolean onCommand(@NotNull TabPlayer player, String msg) {
if (msg.equals("/toggletitle") && plugin.toggleCmd(toggleCmd,player,toggled,plugin.getTranslation().titleOn,plugin.getTranslation().titleOff)) {
if (msg.equals(command) && plugin.toggleCmd(toggleCmd,player,toggled,plugin.getTranslation().titleOn,plugin.getTranslation().titleOff)) {
refresh(player,true);
return true;
}
Expand Down

0 comments on commit 0bafae0

Please sign in to comment.