Skip to content

Commit

Permalink
more porting (it builds now!)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wyvest committed Jun 29, 2024
1 parent 37495f8 commit 938f9f5
Show file tree
Hide file tree
Showing 61 changed files with 425 additions and 416 deletions.
15 changes: 8 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,19 @@ sourceSets {

// Adds the Polyfrost maven repository so that we can get the libraries necessary to develop the mod.
repositories {
mavenLocal()
maven("https://repo.polyfrost.org/snapshots")
maven("https://repo.polyfrost.org/releases")
}

// Configures the libraries/dependencies for your mod.
dependencies {
// Adds the OneConfig library, so we can develop with it.
compileOnly("org.polyfrost.oneconfig:config-impl:1.0.0-alpha7")
compileOnly("org.polyfrost.oneconfig:commands:1.0.0-alpha7")
compileOnly("org.polyfrost.oneconfig:events:1.0.0-alpha7")
compileOnly("org.polyfrost.oneconfig:ui:1.0.0-alpha7")
modCompileOnly("org.polyfrost.oneconfig:$platform:1.0.0-alpha7")
compileOnly("org.polyfrost.oneconfig:config-impl:1.0.0-alpha.14")
compileOnly("org.polyfrost.oneconfig:commands:1.0.0-alpha.14")
compileOnly("org.polyfrost.oneconfig:events:1.0.0-alpha.14")
compileOnly("org.polyfrost.oneconfig:ui:1.0.0-alpha.14")
modCompileOnly("org.polyfrost.oneconfig:$platform:1.0.0-alpha.14")


modRuntimeOnly("me.djtheredstoner:DevAuth-${if (platform.isFabric) "fabric" else if (platform.isLegacyForge) "forge-legacy" else "forge-latest"}:1.1.2")

Expand Down Expand Up @@ -181,7 +182,7 @@ tasks {
// Configures our shadow/shade configuration, so we can
// include some dependencies within our mod jar file.
named<ShadowJar>("shadowJar") {
archiveClassifier.set("dev") // TODO: machete gets confused by the `dev` prefix.
archiveClassifier.set("dev")
configurations = listOf(shade)
duplicatesStrategy = DuplicatesStrategy.EXCLUDE

Expand Down
12 changes: 3 additions & 9 deletions src/main/java/org/polyfrost/hytils/HytilsReborn.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

package org.polyfrost.hytils;

import org.polyfrost.oneconfig.api.config.v1.ConfigManager;
import org.polyfrost.oneconfig.api.event.v1.EventManager;
import org.polyfrost.oneconfig.api.ui.v1.notifications.Notifications;
import org.polyfrost.universal.ChatColor;
import org.polyfrost.universal.UChat;
Expand Down Expand Up @@ -124,6 +122,7 @@ public void init(FMLInitializationEvent event) {
BedLocationHandler.INSTANCE.initialize();
LocrawGamesHandler.INSTANCE.initialize();
HeightHandler.INSTANCE.initialize();
new HypixelAPIUtils().initialize();

registerHandlers();
}
Expand All @@ -142,13 +141,13 @@ public void postInit(FMLPostInitializationEvent event) {
isChatting = false;
if (HytilsConfig.chattingIntegration) {
HytilsConfig.chattingIntegration = false;
ConfigManager.active().save(config.getTree());
config.save();
Notifications.INSTANCE.send("Hytils Reborn", "Hytils Reborn has detected Chatting, but it is not the latest version. Please update Chatting to the latest version.");
}
}
}

Multithreading.runAsync(() -> rank = HypixelAPIUtils.getRank(Minecraft.getMinecraft().getSession().getUsername()));
Multithreading.submit(() -> rank = HypixelAPIUtils.getRank(Minecraft.getMinecraft().getSession().getUsername()));
}

@Mod.EventHandler
Expand Down Expand Up @@ -192,11 +191,6 @@ private void registerHandlers() {
eventBus.register(new MiddleBeaconMiniWalls());
eventBus.register(new MiddleWaypointUHC());
eventBus.register(new DropperHurtSound());

// height overlay
EventManager.INSTANCE.register(HeightHandler.INSTANCE);

eventBus.register(new HypixelAPIUtils());
}

public void sendMessage(String message) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import net.hypixel.data.type.GameType;
import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.Parameter;
import org.polyfrost.oneconfig.api.hypixel.v0.HypixelAPI;
import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils;
import org.polyfrost.universal.ChatColor;
import org.polyfrost.universal.UChat;
import org.polyfrost.oneconfig.utils.v1.Multithreading;
Expand Down Expand Up @@ -55,17 +55,17 @@ private void main() {

@Command(description = "Visits a player's house in Housing.")
private void main(@Parameter("Player Name") GameProfile player) {
if (!HypixelUtils.INSTANCE.isHypixel()) {
if (!HypixelUtils.isHypixel()) {
UChat.chat(ChatColor.RED + "You must be on Hypixel to use this command!");
return;
}
if (usernameRegex.matcher(player.getName()).matches()) {
playerName = player.getName();

// if we are in the housing lobby, just immediately run the /visit command
HypixelAPI.Location location = HypixelAPI.getLocation();
HypixelUtils.Location location = HypixelUtils.getLocation();
Optional<GameType> gameType = location.getGameType();
if (gameType.isPresent() && gameType.get() == GameType.HOUSING && !location.isGame()) {
if (gameType.isPresent() && gameType.get() == GameType.HOUSING && !location.inGame()) {
visit(0);
} else {
HytilsReborn.INSTANCE.getCommandQueue().queue("/l housing");
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/org/polyfrost/hytils/command/HytilsCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@ public class HytilsCommand {

@Command
private void main() {
HytilsReborn.INSTANCE.getConfig().openGui();
//TODO
//HytilsReborn.INSTANCE.getConfig().openGui();
}

@Command(value = {"guildexp", "guildexperience"}, description = "Shows your guild experience")
@SuppressWarnings("SameParameterValue")
private void gexp(@Parameter("Username") @Nullable GameProfile player, @Parameter("GEXP Type") @Nullable GEXPType type) {
Multithreading.runAsync(() -> {
Multithreading.submit(() -> {
if (player != null) {
if (type == null) {
if (HypixelAPIUtils.getGEXP(player.getName())) {
Expand Down Expand Up @@ -102,7 +103,7 @@ private void gexp(@Parameter("Username") @Nullable GameProfile player, @Paramete
@Command(value = {"winstreak", "ws"}, description = "Shows your winstreak")
@SuppressWarnings("SameParameterValue")
private void winstreak(@Parameter("Username") @Nullable GameProfile player, @Parameter("Winstreak Type") @Nullable WinstreakType gamemode) {
Multithreading.runAsync(() -> {
Multithreading.submit(() -> {
if (player != null) {
if (gamemode != null) {
if (HypixelAPIUtils.getWinstreak(player.getName(), gamemode.name())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class IgnoreTemporaryCommand {

static {
initialize();
Multithreading.runAsync(() -> {
Multithreading.submit(() -> {
Timer timer = new Timer(1, ignored -> {
if (Minecraft.getMinecraft().theWorld != null && Minecraft.getMinecraft().thePlayer != null) {
if (json != null) {
Expand Down Expand Up @@ -80,7 +80,7 @@ public class IgnoreTemporaryCommand {

@Command(greedy = true)
private void main(@Parameter("Player Name") GameProfile playerName, @Parameter("Time") String time) {
Multithreading.runAsync(() -> {
Multithreading.submit(() -> {
try {
long millis = addMillis(time.replace(",", "").replace(" ", ""));
json.addProperty(playerName.getName(), millis + new Date().getTime());
Expand All @@ -106,7 +106,7 @@ private void add(@Parameter("Player Name") GameProfile playerName, @Parameter("T
@Command(description = "Removes a player from the ignore list.")
private void remove(@Parameter("Player Name") GameProfile playerName) {
json.remove(playerName.getName());
Multithreading.runAsync(() -> {
Multithreading.submit(() -> {
try {
FileUtils.writeStringToFile(ignoreFile, json.toString(), StandardCharsets.UTF_8);
} catch (IOException e) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/polyfrost/hytils/command/LimboCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package org.polyfrost.hytils.command;

import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils;
import org.polyfrost.universal.ChatColor;
import org.polyfrost.universal.UChat;
import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.Command;
Expand All @@ -27,7 +28,7 @@
public class LimboCommand {
@Command(description = "Sends you to limbo.")
private void main() {
if (HypixelUtils.INSTANCE.isHypixel()) {
if (HypixelUtils.isHypixel()) {
Minecraft.getMinecraft().thePlayer.sendChatMessage("§");
} else {
UChat.chat(ChatColor.RED + "You must be on Hypixel to use this command.");
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/org/polyfrost/hytils/command/PlayCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@

package org.polyfrost.hytils.command;


import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils;
import org.polyfrost.universal.ChatColor;
import org.polyfrost.universal.UChat;
import org.polyfrost.oneconfig.utils.v1.Multithreading;
import org.polyfrost.oneconfig.utils.v1.NetworkUtils;
import org.polyfrost.oneconfig.api.commands.v1.CommandManager;
import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.Command;
import org.polyfrost.oneconfig.api.hypixel.v1.HypixelUtils;
import org.polyfrost.hytils.HytilsReborn;
import org.polyfrost.hytils.command.parser.GameName;
import org.polyfrost.hytils.command.parser.GameNameParser;
Expand All @@ -46,7 +45,7 @@ public class PlayCommand {
private static Map<String, String> games = new HashMap<>();

public static void init() {
Multithreading.runAsync(() -> {
Multithreading.submit(() -> {
try {
String url = "https://data.woverflow.cc/games.json";
String content = NetworkUtils.getString(url);
Expand All @@ -66,7 +65,7 @@ public static void init() {
@Command
private void main(GameName game) {
boolean autocompletePlayCommands = HytilsConfig.autocompletePlayCommands;
if (!HypixelUtils.INSTANCE.isHypixel()) {
if (!HypixelUtils.isHypixel()) {
HytilsReborn.INSTANCE.getCommandQueue().queue("/play " + game.name);
return;
}
Expand Down
63 changes: 39 additions & 24 deletions src/main/java/org/polyfrost/hytils/command/RequeueCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

package org.polyfrost.hytils.command;

import net.hypixel.data.type.GameType;
import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils;
import org.polyfrost.universal.ChatColor;
import org.polyfrost.universal.UChat;
import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.Command;
Expand All @@ -33,41 +35,54 @@ public class RequeueCommand {

@Command(description = "Requeues you into the last game you played.")
private void main() {
LocrawInfo locraw = LocrawUtil.INSTANCE.getLocrawInfo();
LocrawInfo lastLocraw = LocrawUtil.INSTANCE.getLastLocrawInfo();
if (!HypixelUtils.INSTANCE.isHypixel() || locraw == null || lastLocraw == null) {
HypixelUtils.Location location = HypixelUtils.getLocation();
if (!HypixelUtils.isHypixel()) {
return;
}

if (LocrawUtil.INSTANCE.isInGame()) {
game = locraw.getGameMode();
switch (locraw.getGameType()) {
case SKYBLOCK:
case HOUSING:
case REPLAY:
UChat.chat(ChatColor.RED + "You must be in a valid game to use this command.");
return;
if (location.inGame()) {
game = location.getMode().orElse(null);
if (game == null) {
UChat.chat(ChatColor.RED + "You must be in a valid game to use this command.");
return;
}
} else if (!LocrawUtil.INSTANCE.isInGame() && !lastLocraw.getGameMode().equals("lobby")) {
game = lastLocraw.getGameMode();
switch (lastLocraw.getGameType()) {
case SKYBLOCK:
game = lastLocraw.getRawGameType(); // requeues you back into SkyBlock when you are in the lobby. Useful when you get kicked for being AFK.
break;
case HOUSING:
case REPLAY:
UChat.chat(ChatColor.RED + "The last round has to be a valid game to use this command.");
return;
if (location.getGameType().isPresent()) {
switch (location.getGameType().get()) {
case SKYBLOCK:
case HOUSING:
case REPLAY:
UChat.chat(ChatColor.RED + "You must be in a valid game to use this command.");
return;
}
}
} else if (!location.inGame() && location.wasInGame()) {
game = location.getLastMode().orElse(null);
if (game == null) {
UChat.chat(ChatColor.RED + "You must be in a valid game to use this command.");
return;
}
if (location.getLastGameType().isPresent()) {
switch (location.getLastGameType().get()) {
case SKYBLOCK:
game = GameType.SKYBLOCK.getDatabaseName(); // requeues you back into SkyBlock when you are in the lobby. Useful when you get kicked for being AFK.
break;
case HOUSING:
case REPLAY:
UChat.chat(ChatColor.RED + "The last round has to be a valid game to use this command.");
return;
}
}
} else {
UChat.chat(ChatColor.RED + "The last round has to be a game to use this command.");
return;
}

// tries to get the game name from the LocrawGamesHandler, if it doesn't exist, it will use the game name from the LocrawInfo.
String value = LocrawGamesHandler.locrawGames.get(locraw.getRawGameType().toLowerCase() + "_" + game.toLowerCase());
if (value != null) {
game = value;
if (location.getGameType().isPresent()) {
String value = LocrawGamesHandler.locrawGames.get(location.getGameType().get().getDatabaseName().toLowerCase() + "_" + game.toLowerCase());
if (value != null) {
game = value;
}
}

// if the limboPlayCommandHelper is enabled and the player is in limbo, it will queue the /lobby command before the /play command.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@

package org.polyfrost.hytils.command;

import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.Parameter;
import org.polyfrost.universal.ChatColor;
import org.polyfrost.universal.UChat;
import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.Command;
import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.Description;
import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.Main;
import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.SubCommand;
import org.polyfrost.hytils.handlers.chat.modules.triggers.SilentRemoval;
import com.mojang.authlib.GameProfile;

Expand All @@ -35,13 +33,12 @@ public class SilentRemoveCommand {

protected static final Pattern usernameRegex = Pattern.compile("\\w{1,16}");

@Main
public void handle() {
public void main() {
UChat.chat(ChatColor.RED + "Usage: /silentremove <player>");
}

@Main(description = "Adds or removes a player from the silent list.")
private void main(@Description("Player Name") GameProfile player) {
@Command(description = "Adds or removes a player from the silent list.")
private void main(@Parameter("Player Name") GameProfile player) {
String name = player.getName();
if (!usernameRegex.matcher(name).matches()) {
UChat.chat(ChatColor.RED + "Invalid username.");
Expand All @@ -58,7 +55,7 @@ private void main(@Description("Player Name") GameProfile player) {
UChat.chat("&aAdded &e" + name + " &ato the removal queue.");
}

@SubCommand(description = "Clears the silent removal queue.")
@Command(description = "Clears the silent removal queue.")
private void clear() {
final Set<String> silentUsers = SilentRemoval.getSilentUsers();
if (silentUsers.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@

package org.polyfrost.hytils.command;

import net.hypixel.data.type.GameType;
import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.Parameter;
import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils;
import org.polyfrost.universal.ChatColor;
import org.polyfrost.universal.UChat;
import org.polyfrost.oneconfig.utils.v1.Multithreading;
import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.Command;
import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.Description;
import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.Main;
import org.polyfrost.oneconfig.api.hypixel.v1.HypixelUtils;
import org.polyfrost.oneconfig.api.hypixel.v1.LocrawInfo;
import org.polyfrost.oneconfig.api.hypixel.v1.LocrawUtil;
import org.polyfrost.hytils.HytilsReborn;
import com.mojang.authlib.GameProfile;
import net.minecraft.util.EnumChatFormatting;
Expand All @@ -37,7 +35,7 @@
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;

@Command(value = "skyblockvisit", aliases = "sbvisit")
@Command({"skyblockvisit", "sbvisit"})
public class SkyblockVisitCommand {

/**
Expand All @@ -47,20 +45,20 @@ public class SkyblockVisitCommand {

protected static String playerName = "";

@Main
private void handle() {
@Command
private void main() {
UChat.chat(EnumChatFormatting.RED + "Usage: /skyblockvisit <username>");
}

@Main(description = "Visit a player's SkyBlock island.")
private void main(@Description("Player Name") GameProfile player) {
if (!HypixelUtils.INSTANCE.isHypixel()) {
@Command(description = "Visit a player's SkyBlock island.")
private void main(@Parameter("Player Name") GameProfile player) {
if (!HypixelUtils.isHypixel()) {
UChat.chat(ChatColor.RED + "You must be on Hypixel to use this command!");
return;
}
if (usernameRegex.matcher(player.getName()).matches()) {
playerName = player.getName();
if (LocrawUtil.INSTANCE.getLocrawInfo() != null && LocrawUtil.INSTANCE.getLocrawInfo().getGameType() == LocrawInfo.GameType.SKYBLOCK && LocrawUtil.INSTANCE.isInGame()) {
if (GameType.SKYBLOCK.equals(HypixelUtils.getLocation().getGameType().orElse(null)) && HypixelUtils.getLocation().inGame()) {
visit(0);
return;
}
Expand Down
Loading

0 comments on commit 938f9f5

Please sign in to comment.