Skip to content

Commit

Permalink
Updated YACL to 3.1.1 (no longer supports 1.19.2)
Browse files Browse the repository at this point in the history
Updated to 1.20.1
Fixed an incompatibility with Xaero's Minimap/Xaero's Worldmap
You can no longer add more than 2 auto private names through the gui
Fixed server detection (AutoAdvert and AutoRaffle should now work as expected on economy)
Join commands will now only be executed on Skyblock/Economy/Classic (not in hub or other servers)
Mention highlighting/sounds can now be enabled independently (Mention sounds no longer have to be enabled in order for highlighting to work)
  • Loading branch information
hashalite committed Sep 4, 2023
1 parent d42d3d1 commit 73a7353
Show file tree
Hide file tree
Showing 20 changed files with 491 additions and 395 deletions.
4 changes: 2 additions & 2 deletions README.md

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.0-SNAPSHOT'
id 'fabric-loom' version '1.3-SNAPSHOT'
id 'maven-publish'
}

Expand All @@ -13,6 +13,7 @@ group = project.maven_group
repositories {
maven { url "https://maven.isxander.dev/releases" }
maven { url "https://maven.terraformersmc.com/" }
maven {url "https://oss.sonatype.org/content/repositories/snapshots/"}
}

dependencies {
Expand Down
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
org.gradle.jvmargs=-Xmx2G
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
mc_version=1.19.4
yarn_mappings=1.19.4+build.2
loader_version=0.14.19
mc_version=1.20.1
yarn_mappings=1.20.1+build.10
loader_version=0.14.22
# Mod Properties
mod_version=1.1.6
mod_version=1.1.7
maven_group=net.xolt
archives_base_name=sbutils
# Dependencies
# check this on https://modmuss50.me/fabric.html
fabric_version=0.80.0+1.19.4
modmenu_version=6.2.0
yacl_version=2.5.0+1.19.4
fabric_version=0.88.1+1.20.1
modmenu_version=7.2.1
yacl_version=3.1.1+1.20
exp4j_version = 0.4.8
596 changes: 302 additions & 294 deletions src/main/java/net/xolt/sbutils/config/ConfigGui.java

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions src/main/java/net/xolt/sbutils/config/ModConfig.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package net.xolt.sbutils.config;

import com.mojang.brigadier.context.CommandContext;
import dev.isxander.yacl.api.NameableEnum;
import dev.isxander.yacl.config.ConfigEntry;
import dev.isxander.yacl.config.ConfigInstance;
import dev.isxander.yacl3.api.NameableEnum;
import dev.isxander.yacl3.config.ConfigEntry;
import dev.isxander.yacl3.config.ConfigInstance;
import net.minecraft.command.argument.EnumArgumentType;
import net.minecraft.item.Item;
import net.minecraft.item.Items;
Expand Down Expand Up @@ -53,11 +53,12 @@ public class ModConfig {
// Mentions Settings

@ConfigEntry public boolean mentions = false;
@ConfigEntry public boolean excludeServerMsgs = true;
@ConfigEntry public boolean excludeSelfMsgs = true;
@ConfigEntry public boolean playMentionSound = true;
@ConfigEntry public NotifSound mentionSound = NotifSound.EXPERIENCE;
@ConfigEntry public boolean mentionHighlight = true;
@ConfigEntry public Color highlightColor = Color.GOLD;
@ConfigEntry public boolean excludeServerMsgs = true;
@ConfigEntry public boolean excludeSelfMsgs = true;
@ConfigEntry public boolean mentionsCurrentAccount = true;
@ConfigEntry public List<String> mentionsAliases = List.of();

Expand Down
7 changes: 3 additions & 4 deletions src/main/java/net/xolt/sbutils/config/ModConfigInstance.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package net.xolt.sbutils.config;

import com.google.gson.*;
import dev.isxander.yacl.config.ConfigEntry;
import dev.isxander.yacl.config.ConfigInstance;
import java.awt.*;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;

import dev.isxander.yacl.config.GsonConfigInstance;
import dev.isxander.yacl3.config.ConfigEntry;
import dev.isxander.yacl3.config.ConfigInstance;
import dev.isxander.yacl3.config.GsonConfigInstance;
import net.minecraft.text.Style;
import net.minecraft.text.Text;
import net.xolt.sbutils.SbUtils;
Expand Down
22 changes: 12 additions & 10 deletions src/main/java/net/xolt/sbutils/features/AutoAdvert.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static void registerCommand(CommandDispatcher<FabricClientCommandSource>
})
.then(ClientCommandManager.literal("info")
.executes(context -> {
Messenger.printAutoAdvertInfo(ModConfig.INSTANCE.getConfig().autoAdvert, ServerDetector.currentServer == null, getUpdatedAdIndex(getAdList()), delayLeft(), userWhitelisted(), ModConfig.INSTANCE.getConfig().advertUseWhitelist);
Messenger.printAutoAdvertInfo(ModConfig.INSTANCE.getConfig().autoAdvert, ServerDetector.isOnSkyblock(), getUpdatedAdIndex(getAdList()), delayLeft(), userWhitelisted(), ModConfig.INSTANCE.getConfig().advertUseWhitelist);
return Command.SINGLE_SUCCESS;
}))
.then(ClientCommandManager.literal("sbFile")
Expand Down Expand Up @@ -169,7 +169,7 @@ public static void registerCommand(CommandDispatcher<FabricClientCommandSource>
}

private static int onListCommand() {
if (ServerDetector.currentServer == null) {
if (!ServerDetector.isOnSkyblock()) {
Messenger.printMessage("message.sbutils.autoAdvert.notOnSkyblock");
return Command.SINGLE_SUCCESS;
}
Expand All @@ -179,7 +179,7 @@ private static int onListCommand() {
}

private static int onAddCommand(String advert) {
if (ServerDetector.currentServer == null) {
if (!ServerDetector.isOnSkyblock()) {
Messenger.printMessage("message.sbutils.autoAdvert.notOnSkyblock");
return Command.SINGLE_SUCCESS;
}
Expand All @@ -194,7 +194,7 @@ private static int onAddCommand(String advert) {
}

private static int onDelCommand(int index) {
if (ServerDetector.currentServer == null) {
if (!ServerDetector.isOnSkyblock()) {
Messenger.printMessage("message.sbutils.autoAdvert.notOnSkyblock");
return Command.SINGLE_SUCCESS;
}
Expand All @@ -217,7 +217,7 @@ private static int onDelCommand(int index) {
}

private static int onInsertCommand(int index, String advert) {
if (ServerDetector.currentServer == null) {
if (!ServerDetector.isOnSkyblock()) {
Messenger.printMessage("message.sbutils.autoAdvert.notOnSkyblock");
return Command.SINGLE_SUCCESS;
}
Expand All @@ -240,7 +240,7 @@ private static int onInsertCommand(int index, String advert) {
}

private static int onToggleCommand(int index) {
if (ServerDetector.currentServer == null) {
if (!ServerDetector.isOnSkyblock()) {
Messenger.printMessage("message.sbutils.autoAdvert.notOnSkyblock");
return Command.SINGLE_SUCCESS;
}
Expand Down Expand Up @@ -306,7 +306,7 @@ public static void tick() {
joinedAt = System.currentTimeMillis();
}

if (ServerDetector.currentServer == null || (ModConfig.INSTANCE.getConfig().advertUseWhitelist && !userWhitelisted())) {
if (!ServerDetector.isOnSkyblock() || (ModConfig.INSTANCE.getConfig().advertUseWhitelist && !userWhitelisted())) {
return;
}

Expand Down Expand Up @@ -398,19 +398,21 @@ private static List<String> formatAdList(List<String> ads) {

private static String getAdFile() {
String adFile;
if (ServerDetector.currentServer == null) {
if (!ServerDetector.isOnSkyblock()) {
return null;
} else {
switch (ServerDetector.currentServer) {
case SKYBLOCK:
adFile = ModConfig.INSTANCE.getConfig().skyblockAdFile;
break;
case ECONOMY:
adFile = ModConfig.INSTANCE.getConfig().economyAdFile;
break;
case CLASSIC:
adFile = ModConfig.INSTANCE.getConfig().classicAdFile;
break;
default:
adFile = ModConfig.INSTANCE.getConfig().skyblockAdFile;
break;
return null;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/xolt/sbutils/features/AutoPrivate.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private static int onDelNameCommand(String name) {
}

public static boolean onSignEditorOpen(SignEditorOpenS2CPacket packet) {
if (!ModConfig.INSTANCE.getConfig().autoPrivate) {
if (!ModConfig.INSTANCE.getConfig().autoPrivate || !packet.isFront()) {
return false;
}
return updateSign(packet);
Expand All @@ -113,7 +113,7 @@ private static boolean updateSign(SignEditorOpenS2CPacket packet) {
lines[i] = names.get(i);
}

MC.getNetworkHandler().sendPacket(new UpdateSignC2SPacket(packet.getPos(), "[private]", "", lines[0], lines[1]));
MC.getNetworkHandler().sendPacket(new UpdateSignC2SPacket(packet.getPos(), true, "[private]", "", lines[0], lines[1]));
return true;
}
}
8 changes: 4 additions & 4 deletions src/main/java/net/xolt/sbutils/features/AutoRaffle.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,17 @@ public static void onJoinGame() {
}

public static void buyTickets() {
if (ServerDetector.currentServer == null) {
if (!ServerDetector.isOnSkyblock()) {
return;
} else {
switch (ServerDetector.currentServer) {
case SKYBLOCK:
buySkyblockTickets();
break;
case ECONOMY:
buyEconomyTickets();
break;
case CLASSIC:
break;
default:
buySkyblockTickets();
break;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/xolt/sbutils/features/JoinCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.xolt.sbutils.SbUtils;
import net.xolt.sbutils.config.ModConfig;
import net.xolt.sbutils.features.common.ServerDetector;
import net.xolt.sbutils.util.IOHandler;
import net.xolt.sbutils.util.Messenger;

Expand Down Expand Up @@ -115,7 +116,7 @@ public static void registerCommand(CommandDispatcher<FabricClientCommandSource>
}

public static void tick() {
if (!ModConfig.INSTANCE.getConfig().joinCmdsEnabled || !waitingToSend) {
if (!ModConfig.INSTANCE.getConfig().joinCmdsEnabled || !ServerDetector.isOnSkyblock() || !waitingToSend) {
return;
}

Expand Down
14 changes: 13 additions & 1 deletion src/main/java/net/xolt/sbutils/features/Mentions.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ public static void registerCommand(CommandDispatcher<FabricClientCommandSource>
Messenger.printChangedSetting("text.sbutils.config.category.mentions", ModConfig.INSTANCE.getConfig().mentions);
return Command.SINGLE_SUCCESS;
})
.then(ClientCommandManager.literal("playSound")
.executes(context -> {
Messenger.printSetting("text.sbutils.config.option.playMentionSound", ModConfig.INSTANCE.getConfig().playMentionSound);
return Command.SINGLE_SUCCESS;
})
.then(ClientCommandManager.argument("enabled", BoolArgumentType.bool())
.executes(context -> {
ModConfig.INSTANCE.getConfig().playMentionSound = BoolArgumentType.getBool(context, "enabled");
ModConfig.INSTANCE.save();
Messenger.printChangedSetting("text.sbutils.config.option.playMentionSound", ModConfig.INSTANCE.getConfig().playMentionSound);
return Command.SINGLE_SUCCESS;
})))
.then(ClientCommandManager.literal("excludeServer")
.executes(context -> {
Messenger.printSetting("text.sbutils.config.option.excludeServerMsgs", ModConfig.INSTANCE.getConfig().excludeServerMsgs);
Expand Down Expand Up @@ -160,7 +172,7 @@ private static int onDelAliasCommand(String name) {
}

public static void processMessage(Text message) {
if (!ModConfig.INSTANCE.getConfig().mentions || !isValidMessage(message)) {
if (!ModConfig.INSTANCE.getConfig().mentions || !ModConfig.INSTANCE.getConfig().playMentionSound || !isValidMessage(message)) {
return;
}

Expand Down
90 changes: 68 additions & 22 deletions src/main/java/net/xolt/sbutils/features/common/ServerDetector.java
Original file line number Diff line number Diff line change
@@ -1,55 +1,101 @@
package net.xolt.sbutils.features.common;

import net.minecraft.text.Text;
import net.minecraft.text.TextColor;
import net.minecraft.util.Formatting;
import com.mojang.brigadier.tree.CommandNode;
import net.minecraft.command.CommandSource;
import net.xolt.sbutils.features.AutoAdvert;
import net.xolt.sbutils.util.RegexFilters;

import java.util.List;
import static net.xolt.sbutils.SbUtils.MC;

public class ServerDetector {

public static SbServer currentServer;
private static boolean receivedCommandTree = false;
private static boolean receivedTabHeader = false;
private static String tabHeader;

public static void processMessage(Text message) {
if (RegexFilters.skyblockJoinFilter.matcher(message.getString()).matches()) {
List<Text> siblings = message.getSiblings();
if (siblings.size() < 1) {
return;
}
public static void onPlayerListHeader(String header) {
tabHeader = header;
receivedTabHeader = true;
if (receivedCommandTree) {
determineServer();
}
}

public static void afterCommandTree() {
receivedCommandTree = true;
if (receivedTabHeader) {
determineServer();
}
}

private static void determineServer() {
if (!receivedCommandTree || !receivedTabHeader || MC.getNetworkHandler() == null
|| !RegexFilters.addressFilter.matcher(MC.getNetworkHandler().getConnection().getAddress().toString()).matches()) {
currentServer = null;
onSwitchServer();
return;
}

TextColor serverColor = siblings.get(siblings.size() - 1).getStyle().getColor();
if (serverColor.equals(TextColor.fromFormatting(Formatting.GREEN))) {
currentServer = SbServer.SKYBLOCK;
onSwitchServer();
} else if (serverColor.equals(TextColor.fromFormatting(Formatting.LIGHT_PURPLE))) {
currentServer = SbServer.ECONOMY;
onSwitchServer();
} else if (serverColor.equals(TextColor.fromFormatting(Formatting.YELLOW))) {
currentServer = SbServer.CLASSIC;
onSwitchServer();
for (CommandNode<CommandSource> node : MC.getNetworkHandler().getCommandDispatcher().getRoot().getChildren()) {
switch (node.getName()) {
case "crophoppers:crophoppers":
currentServer = SbServer.ECONOMY;
onSwitchServer();
return;
case "mineversesidebar:sidebar":
currentServer = SbServer.HUB;
onSwitchServer();
return;
case "plugman:plugman":
currentServer = SbServer.SKYBLOCK;
onSwitchServer();
return;
}
}

if (tabHeader.contains("Skyblock Classic")) {
currentServer = SbServer.CLASSIC;
onSwitchServer();
return;
}

if (tabHeader.contains("SkyWars")) {
currentServer = SbServer.SKYWARS;
onSwitchServer();
return;
}

currentServer = null;
onSwitchServer();
}

public static void onJoinGame() {
public static void onDisconnect() {
resetServer();
}

public static void onDisconnect() {
public static void onJoinGame() {
resetServer();
}

public static void onSwitchServer() {
AutoAdvert.refreshPrevAdlist();
}

public static boolean isOnSkyblock() {
return currentServer == SbServer.SKYBLOCK || currentServer == SbServer.ECONOMY || currentServer == SbServer.CLASSIC;
}

private static void resetServer() {
currentServer = null;
receivedCommandTree = false;
receivedTabHeader = false;
tabHeader = null;
}

public enum SbServer {
HUB,
SKYWARS,
SKYBLOCK,
ECONOMY,
CLASSIC;
Expand Down
Loading

0 comments on commit 73a7353

Please sign in to comment.