diff --git a/src/main/java/xyz/omegaware/addon/modules/TPAAutomationModule.java b/src/main/java/xyz/omegaware/addon/modules/TPAAutomationModule.java index e3c884b..f4e9539 100644 --- a/src/main/java/xyz/omegaware/addon/modules/TPAAutomationModule.java +++ b/src/main/java/xyz/omegaware/addon/modules/TPAAutomationModule.java @@ -1,6 +1,7 @@ package xyz.omegaware.addon.modules; import meteordevelopment.meteorclient.settings.*; +import meteordevelopment.meteorclient.systems.friends.Friends; import meteordevelopment.meteorclient.utils.player.ChatUtils; import net.minecraft.text.Text; import net.minecraft.util.Formatting; @@ -22,16 +23,6 @@ public TPAAutomationModule() { private final SettingGroup sgApprovedUsers = this.settings.createGroup("Approved Users"); private final SettingGroup sgGeneral = this.settings.createGroup("General"); - String[] TSRKitBotUsers = { - "royalburner", - "Poolyin", - "PoolyinHelper", - "RoyalHelper", - "TSRMANIA", - "WomenAreScary", - "ElectricCallboy" - }; - private final Setting> approvedUsers = sgApprovedUsers.add(new StringListSetting.Builder() .name("approved-users-list") .description("A list of users to filter.") @@ -39,6 +30,13 @@ public TPAAutomationModule() { .build() ); + private final Setting acceptFriends = sgGeneral.add(new BoolSetting.Builder() + .name("accept-friends") + .description("Automatically accept teleport requests from your Meteor friend list.") + .defaultValue(true) + .build() + ); + private final Setting acceptTSRBots = sgGeneral.add(new BoolSetting.Builder() .name("accept-tsr-bots") .description("Automatically accept teleport requests that are from the TSR bot users.") @@ -86,6 +84,16 @@ public TPAAutomationModule() { private static final Pattern TPA_DENIED_PATTERN = Pattern.compile("^Request from ([A-Za-z0-9_]{3,16}) denied!$"); private static final Pattern TPA_REQUEST_PATTERN = Pattern.compile("^([A-Za-z0-9_]{3,16}) wants to teleport to you\\.$"); + private static final Set TSR_KIT_BOT_USERS = Set.of( + "royalburner", + "Poolyin", + "PoolyinHelper", + "RoyalHelper", + "TSRMANIA", + "WomenAreScary", + "ElectricCallboy" + ); + @Override public void onActivate() { if (!OmegawareAddons.is6B6T()) { @@ -145,20 +153,15 @@ private void onMessageReceive(ReceiveMessageEvent event) { .append(Text.literal(username).formatted(Formatting.WHITE)) .append(Text.literal("!").formatted(Formatting.WHITE)); - if (approvedUsers.get().contains(username) || (acceptTSRBots.get() && Set.of(TSRKitBotUsers).contains(username))) { + if (approvedUsers.get().contains(username) || (acceptFriends.get() && Friends.get().get(username) != null) || (acceptTSRBots.get() && TSR_KIT_BOT_USERS.contains(username))) { ChatUtils.sendPlayerMsg("/tpy " + username); - if (printTpaAccepted.get()) { - ChatUtils.sendMsg(accepted); - } - } else { - if (autoDeny.get()) { - ChatUtils.sendPlayerMsg("/tpn " + username); + if (printTpaAccepted.get()) ChatUtils.sendMsg(accepted); - if (printTpaIgnored.get()) { - ChatUtils.sendMsg(ignored); - } - } + } else if (autoDeny.get()){ + ChatUtils.sendPlayerMsg("/tpn " + username); + + if (printTpaIgnored.get()) ChatUtils.sendMsg(ignored); } if (filterTpaMessages.get() && printTpaDetected.get()) {