1- /*
2- * Hytils Reborn - Hypixel focused Quality of Life mod.
3- * Copyright (C) 2022 W-OVERFLOW
4- *
5- * This program is free software: you can redistribute it and/or modify
6- * it under the terms of the GNU General Public License as published by
7- * the Free Software Foundation, either version 3 of the License, or
8- * (at your option) any later version.
9- *
10- * This program is distributed in the hope that it will be useful,
11- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13- * GNU General Public License for more details.
14- *
15- * You should have received a copy of the GNU General Public License
16- * along with this program. If not, see <https://www.gnu.org/licenses/>.
17- */
18-
191package cc .woverflow .hysentials ;
202
213import cc .polyfrost .oneconfig .events .EventManager ;
224import cc .polyfrost .oneconfig .libs .universal .ChatColor ;
235import cc .polyfrost .oneconfig .libs .universal .UChat ;
6+ import cc .woverflow .hysentials .guis .club .ClubDashboardHandler ;
7+ import cc .woverflow .hysentials .handlers .chat .modules .misc .Limit256 ;
8+ import cc .woverflow .hysentials .util .MUtils ;
249import cc .polyfrost .oneconfig .utils .commands .CommandManager ;
2510import cc .woverflow .hysentials .command .*;
2611import cc .woverflow .hysentials .config .HysentialsConfig ;
3015import cc .woverflow .hysentials .guis .club .ClubDashboard ;
3116import cc .woverflow .hysentials .guis .gameMenu .RevampedGameMenu ;
3217import cc .woverflow .hysentials .guis .misc .PlayerInvHandler ;
33- import cc .woverflow .hysentials .guis .misc .PlayerInventory ;
3418import cc .woverflow .hysentials .guis .sbBoxes .SBBoxesEditor ;
3519import cc .woverflow .hysentials .handlers .cache .HeightHandler ;
3620import cc .woverflow .hysentials .handlers .chat .ChatHandler ;
21+ import cc .woverflow .hysentials .handlers .chat .modules .bwranks .BWSReplace ;
3722import cc .woverflow .hysentials .handlers .display .GuiDisplayHandler ;
3823import cc .woverflow .hysentials .handlers .guis .GameMenuOpen ;
3924import cc .woverflow .hysentials .handlers .htsl .*;
4025import cc .woverflow .hysentials .handlers .imageicons .ImageIcon ;
4126import cc .woverflow .hysentials .handlers .language .LanguageHandler ;
4227import cc .woverflow .hysentials .handlers .lobby .HousingLagReducer ;
4328import cc .woverflow .hysentials .handlers .lobby .LobbyChecker ;
29+ import cc .woverflow .hysentials .handlers .npc .QuestNPC ;
4430import cc .woverflow .hysentials .handlers .redworks .BwRanks ;
4531import cc .woverflow .hysentials .handlers .redworks .NeighborInstall ;
4632import cc .woverflow .hysentials .handlers .sbb .Actionbar ;
4733import cc .woverflow .hysentials .handlers .sbb .SbbRenderer ;
34+ import cc .woverflow .hysentials .htsl .Cluster ;
4835import cc .woverflow .hysentials .pets .cubit .CubitCompanion ;
4936import cc .woverflow .hysentials .pets .hamster .HamsterCompanion ;
5037import cc .woverflow .hysentials .util .*;
5138import cc .woverflow .hysentials .util .blockw .OnlineCache ;
52- import cc .woverflow .hysentials .util .friends .FriendCache ;
53- import cc .woverflow .hysentials .util .skyblock .SkyblockChecker ;
5439import cc .woverflow .hysentials .websocket .Socket ;
40+ import cc .woverflow .hytils .util .friends .FriendCache ;
5541import net .minecraft .client .Minecraft ;
42+ import net .minecraft .client .gui .FontRenderer ;
5643import net .minecraft .util .ResourceLocation ;
5744import net .minecraftforge .client .ClientCommandHandler ;
5845import net .minecraftforge .common .MinecraftForge ;
7158import javax .net .ssl .HttpsURLConnection ;
7259import javax .net .ssl .SSLContext ;
7360import java .io .*;
61+ import java .lang .reflect .Field ;
7462import java .net .HttpURLConnection ;
7563import java .net .URL ;
64+ import java .nio .charset .Charset ;
7665import java .nio .charset .StandardCharsets ;
7766
7867@ Mod (
@@ -91,11 +80,9 @@ public class Hysentials {
9180 public File modDir = new File ("OVERFLOW" , MOD_NAME );
9281
9382 private HysentialsConfig config ;
94- private final Logger logger = LogManager .getLogger ("Hytils Reborn " );
83+ private final Logger logger = LogManager .getLogger ("Hysentials " );
9584
9685 private final LanguageHandler languageHandler = new LanguageHandler ();
97- private final SkyblockChecker skyblockChecker = new SkyblockChecker ();
98- private final FriendCache friendCache = new FriendCache ();
9986 private final OnlineCache onlineCache = new OnlineCache ();
10087
10188 private final LobbyChecker lobbyChecker = new LobbyChecker ();
@@ -108,6 +95,7 @@ public class Hysentials {
10895 public JsonData rankColors ;
10996 public boolean isPatcher ;
11097 public boolean isChatting ;
98+ public boolean isHytils ;
11199 private boolean loadedCall ;
112100
113101 public DiscordRPC discordRPC ;
@@ -128,8 +116,22 @@ public void onFMLPreInitialization(FMLPreInitializationEvent event) {
128116 @ Mod .EventHandler
129117 public void init (FMLInitializationEvent event ) {
130118 config = new HysentialsConfig ();
119+ File file = new File (modDir , "./config/hysentials" );
120+ if (!file .exists () && !file .mkdirs ()) {
121+ throw new RuntimeException ("Failed to create config directory! Please report this to sinender on Discord" );
122+ }
131123 sbBoxes = new JsonData ("./config/hysentials/lines.json" , new JSONObject ().put ("lines" , new JSONArray ()));
132124 rankColors = new JsonData ("/assets/minecraft/textures/icons/colors.json" , "./config/hysentials/color.jsonn" , true );
125+
126+ try {
127+ System .setProperty ("file.encoding" , "UTF-8" );
128+ Field charset = Charset .class .getDeclaredField ("defaultCharset" );
129+ charset .setAccessible (true );
130+ charset .set (null , null );
131+ } catch (Exception e ) {
132+ e .printStackTrace ();
133+ }
134+
133135 try {
134136 SSLStore store = new SSLStore ();
135137 store .load ("/ssl/hysentials.der" );
@@ -158,11 +160,13 @@ public void init(FMLInitializationEvent event) {
158160 CommandManager .INSTANCE .registerCommand (new ActionLibraryCommand ());
159161 CommandManager .INSTANCE .registerCommand (new ClubCommand ());
160162
161- try {
162- DiscordCore .init ();
163- discordRPC = new DiscordRPC ();
164- } catch (IOException e ) {
165- throw new RuntimeException (e );
163+ if (Socket .cachedServerData .has ("rpc" ) && Socket .cachedServerData .getBoolean ("rpc" )) {
164+ try {
165+ DiscordCore .init ();
166+ discordRPC = new DiscordRPC ();
167+ } catch (IOException e ) {
168+ throw new RuntimeException (e );
169+ }
166170 }
167171
168172 HeightHandler .INSTANCE .initialize ();
@@ -174,15 +178,13 @@ public void init(FMLInitializationEvent event) {
174178 public void postInit (FMLPostInitializationEvent event ) {
175179 isPatcher = Loader .isModLoaded ("patcher" );
176180 isChatting = Loader .isModLoaded ("chatting" );
181+ isHytils = Loader .isModLoaded ("hytils-reborn" );
177182 chatHandler .init ();
178183
179- rank = HypixelAPIUtils .getRank (Minecraft .getMinecraft ().getSession ().getUsername ());
180-
181184 Socket .createSocket ();
182185 registerImages ();
183186 cc .woverflow .hysentials .htsl .Loader .registerLoaders ();
184-
185- // doorbellBot = new DoorbellBot();
187+ Cluster .registerClusters ();
186188
187189 MinecraftForge .EVENT_BUS .post (new HysentialsLoadedEvent ());
188190 }
@@ -192,7 +194,7 @@ public void finishedStarting(FMLLoadCompleteEvent event) {
192194 this .loadedCall = true ;
193195 }
194196
195-
197+ public static FontRenderer minecraftFont ;
196198 private void registerImages () {
197199 new ImageIcon ("front" , new ResourceLocation ("textures/icons/front.png" ));
198200 new ImageIcon ("back" , new ResourceLocation ("textures/icons/back.png" ));
@@ -202,6 +204,8 @@ private void registerImages() {
202204 new ImageIcon ("party" , new ResourceLocation ("textures/icons/party.png" ));
203205 new ImageIcon ("to" , new ResourceLocation ("textures/icons/to.png" ));
204206 new ImageIcon ("from" , new ResourceLocation ("textures/icons/from.png" ));
207+ new ImageIcon ("team" , new ResourceLocation ("textures/icons/team.png" ));
208+ new ImageIcon ("friend" , new ResourceLocation ("textures/icons/friend.png" ));
205209
206210 for (HypixelRanks rank : HypixelRanks .values ()) {
207211 try {
@@ -214,6 +218,7 @@ private void registerImages() {
214218 new ImageIcon (String .valueOf (i ), new ResourceLocation ("textures/icons/" + i + ".png" ));
215219 }
216220 imageIconRenderer = new ImageIconRenderer ();
221+ minecraftFont = Minecraft .getMinecraft ().fontRendererObj ;
217222 Minecraft .getMinecraft ().fontRendererObj = imageIconRenderer ;
218223 }
219224
@@ -244,10 +249,17 @@ private void registerHandlers() {
244249 eventBus .register (new Queue ());
245250 eventBus .register (new Navigator ());
246251 eventBus .register (new ActionGUIHandler ());
252+ eventBus .register (new FunctionsGUIHandler ());
247253 eventBus .register (new Exporter ());
248254 eventBus .register (new HousingMenuHandler ());
249- eventBus .register (new ClubDashboard ());
255+ eventBus .register (new ClubDashboardHandler ());
250256 eventBus .register (new PlayerInvHandler ());
257+ eventBus .register (new BWSReplace ());
258+ eventBus .register (new QuestNPC ());
259+ eventBus .register (new MUtils ());
260+ eventBus .register (new Limit256 ());
261+ eventBus .register (cubitCompanion = new CubitCompanion ());
262+ new Renderer ();
251263
252264 // height overlay
253265 EventManager .INSTANCE .register (HeightHandler .INSTANCE );
@@ -262,7 +274,7 @@ private void registerHandlers() {
262274 }
263275
264276 public void sendMessage (String message ) {
265- UChat .chat (ChatColor . GOLD + "[" + MOD_NAME + "] " + ChatColor .Companion .translateAlternateColorCodes ('&' , message ));
277+ UChat .chat (HysentialsConfig . chatPrefix + " " + ChatColor .Companion .translateAlternateColorCodes ('&' , message ));
266278 }
267279
268280 public HysentialsConfig getConfig () {
@@ -293,14 +305,6 @@ public Logger getLogger() {
293305 return logger ;
294306 }
295307
296- public SkyblockChecker getSkyblockChecker () {
297- return skyblockChecker ;
298- }
299-
300- public FriendCache getFriendCache () {
301- return friendCache ;
302- }
303-
304308 public OnlineCache getOnlineCache () {
305309 return onlineCache ;
306310 }
0 commit comments