Skip to content

Commit

Permalink
Boop Invites
Browse files Browse the repository at this point in the history
  • Loading branch information
MisterCheezeCake committed Aug 26, 2024
1 parent 2819436 commit 5b941f6
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/main/java/wtf/cheeze/sbt/SkyblockTweaks.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import wtf.cheeze.sbt.command.SBTCommand;
import wtf.cheeze.sbt.config.SkyblockTweaksConfig;
import wtf.cheeze.sbt.config.persistent.PersistentData;
import wtf.cheeze.sbt.features.PartyCommands;
import wtf.cheeze.sbt.features.PartyFeatures;
import wtf.cheeze.sbt.features.huds.*;
import wtf.cheeze.sbt.utils.*;
import wtf.cheeze.sbt.utils.actionbar.ActionBarTransformer;
Expand Down Expand Up @@ -92,7 +92,7 @@ public void onInitialize() {
ActionBarTransformer.registerEvents();
NotificationHandler.registerEvents();
ModAPIUtils.registerEvents();
PartyCommands.registerEvents();
PartyFeatures.registerEvents();
ProfileManager.registerEvents();

UpdateChecker.checkForUpdates();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/wtf/cheeze/sbt/config/ConfigImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import wtf.cheeze.sbt.config.categories.General;
import wtf.cheeze.sbt.config.categories.Huds;
import wtf.cheeze.sbt.features.MenuHighlights;
import wtf.cheeze.sbt.features.PartyCommands;
import wtf.cheeze.sbt.features.PartyFeatures;
import wtf.cheeze.sbt.utils.Version;
import wtf.cheeze.sbt.utils.actionbar.ActionBarTransformer;

Expand All @@ -47,7 +47,7 @@ public class ConfigImpl {
public MenuHighlights.Config hubSelectorHighlight = new MenuHighlights.Config();

@SerialEntry
public PartyCommands.Config partyCommands = new PartyCommands.Config();
public PartyFeatures.Config partyCommands = new PartyFeatures.Config();

@SerialEntry
public Huds huds = new Huds();
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/wtf/cheeze/sbt/config/categories/General.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import wtf.cheeze.sbt.config.ConfigImpl;
import wtf.cheeze.sbt.config.SkyblockTweaksConfig;
import wtf.cheeze.sbt.features.MenuHighlights;
import wtf.cheeze.sbt.features.PartyCommands;
import wtf.cheeze.sbt.features.PartyFeatures;
import wtf.cheeze.sbt.utils.Version;
import wtf.cheeze.sbt.utils.actionbar.ActionBarTransformer;

Expand All @@ -21,8 +21,8 @@ public static ConfigCategory getCategory(ConfigImpl defaults, ConfigImpl config)
.option(Version.getStreamOption(defaults, config))
.group(InventoryTweaks.getGroup(defaults, config))
.group(MenuHighlights.Config.getGroup(defaults, config))
.group(PartyCommands.Config.getGroup(defaults, config))
.option(PartyCommands.Config.getBlackList(defaults, config))
.group(PartyFeatures.Config.getGroup(defaults, config))
.option(PartyFeatures.Config.getBlackList(defaults, config))
.group(HudTweaks.getGroup(defaults, config))
.group(ActionBarTransformer.Config.getGroup(defaults, config))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
import dev.isxander.yacl3.api.OptionGroup;
import dev.isxander.yacl3.api.controller.IntegerFieldControllerBuilder;
import dev.isxander.yacl3.api.controller.StringControllerBuilder;
import dev.isxander.yacl3.config.v2.api.SerialEntry;
import net.azureaaron.hmapi.network.HypixelNetworking;
import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents;
import net.minecraft.text.HoverEvent;
import net.minecraft.text.Text;
import wtf.cheeze.sbt.SkyblockTweaks;
import wtf.cheeze.sbt.config.ConfigImpl;
Expand All @@ -36,10 +38,11 @@
import java.util.List;
import java.util.regex.Pattern;

public class PartyCommands {
public class PartyFeatures {

public static Pattern PARTY_PATTERN = Pattern.compile("Party > ([^:]+): !(.+)");
public static Pattern BACKUP_UPDATE_PATTERN = Pattern.compile("The party was transferred to (.+) by .+");
public static Pattern BOOP_PATTERN = Pattern.compile("From (.*): Boop!");

public static long lastPartyCommand = 0;

Expand Down Expand Up @@ -97,15 +100,31 @@ public static void registerEvents() {
} else {
SkyblockTweaks.DATA.amITheLeader = false;
}
} else if (s.matches("From .*: Boop!")) {
if (!SkyblockTweaks.CONFIG.config.partyCommands.boopInvites) return;
var matcher = BOOP_PATTERN.matcher(s);
if (!matcher.matches()) return;
var n = matcher.group(1);
var name = n.contains(" ") ? n.split(" ")[1] : n;
SkyblockTweaks.mc.send(() -> SkyblockTweaks.mc.player.sendMessage(getInviteMessage(name), false));
}
});
}

public static class Config {
@SerialEntry
public boolean enabled = true;
@SerialEntry
public List<String> blockedUsers = new ArrayList<>();
@SerialEntry
public int cooldown = 750;

@SerialEntry
public boolean boopInvites = true;




public static ListOption<String> getBlackList(ConfigImpl defaults, ConfigImpl config) {
return ListOption.<String>createBuilder()
.name(Text.literal("Party Commands Blocked Users"))
Expand All @@ -121,6 +140,7 @@ public static ListOption<String> getBlackList(ConfigImpl defaults, ConfigImpl co
.build();
}
public static OptionGroup getGroup(ConfigImpl defaults, ConfigImpl config) {

var enabled = Option.<Boolean>createBuilder()
.name(Text.literal("Enable Party Commands"))
.description(OptionDescription.of(Text.literal("Whether or not to enable party commands")))
Expand All @@ -142,16 +162,32 @@ public static OptionGroup getGroup(ConfigImpl defaults, ConfigImpl config) {
)
.build();

var inviteBoop = Option.<Boolean>createBuilder()
.name(Text.literal("Boop Invites"))
.description(OptionDescription.of(Text.literal("Whether or not to prompt a party invite when booped by a player")))
.controller(SkyblockTweaksConfig::generateBooleanController)
.binding(
defaults.partyCommands.boopInvites,
() -> config.partyCommands.boopInvites,
value -> config.partyCommands.boopInvites = (Boolean) value
)
.build();


return OptionGroup.createBuilder()
.name(Text.literal("Party Commands"))
.description(OptionDescription.of(Text.literal("Settings for Party Commands")))
.name(Text.literal("Party Features"))
.description(OptionDescription.of(Text.literal("Settings for Party Features")))
.option(enabled)
.option(cooldown)
.option(inviteBoop)
.build();
}

}

private static Text getInviteMessage(String name) {
return TextUtils.getTextThatRunsCommand("§7[§aSkyblockTweaks§f§7] §bClick here to invite §e" + name + "§b to your party!","§3Click here to run §e/p " + name , "/p invite " + name);
}


}
8 changes: 8 additions & 0 deletions src/main/java/wtf/cheeze/sbt/utils/TextUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,12 @@ public static Text getTextThatLinksToURL(String text, String hovered, String url
return style;
});
}

public static Text getTextThatRunsCommand(String text, String hovered, String command) {
return Text.literal(text).styled(style -> {
style = style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.literal(hovered)));
style = style.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command));
return style;
});
}
}

0 comments on commit 5b941f6

Please sign in to comment.