Skip to content

Commit

Permalink
beta 5 stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
koxx12-dev committed Jun 24, 2021
1 parent ff9359c commit d8e3055
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public String getCommandUsage(ICommandSender sender) {
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
if (args.length != 1) {
SCC.displayScreen = SCC.config.gui();
} else if (args[0].equalsIgnoreCase("reload")){
} else if (args[0].equalsIgnoreCase("reload")) {
HTTPstuff.reloadTags();
} else {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED+"Unknown command\n"+EnumChatFormatting.RED+"\"/scc\" for config gui\n"+EnumChatFormatting.RED+"\"/scc reload\" to reload tags"));
Expand Down
51 changes: 40 additions & 11 deletions src/main/java/io/github/koxx12_dev/scc/GUI/SCCConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,37 @@
import gg.essential.vigilance.Vigilant;
import gg.essential.vigilance.data.Property;
import gg.essential.vigilance.data.PropertyType;
import io.github.koxx12_dev.scc.Utils.HTTPstuff;

import java.io.File;

public class SCCConfig extends Vigilant {

@Property(type = PropertyType.SWITCH, name = "Hide custom tags", description = "Hides all custom tags in new messages", category = "Main", subcategory = "Tags")
public static boolean TagsHidden = false;
@Property(type = PropertyType.SWITCH, name = "Show Debug Options", description = "SHOWS DEBUG STUFF USELESS FOR EVERYONE BUT ME -koxx12", category = "DEBUG", subcategory = "DEBUG", hidden = true)
public static boolean ShowDebug = false;

@Property(type = PropertyType.SWITCH, name = "Show custom tags", description = "Show all custom tags in new messages", category = "Main", subcategory = "Tags")
public static boolean TagsShow = true;

@Property(type = PropertyType.SWITCH, name = "Shorten custom tag", description = "Shortens all custom tags in new messages", category = "Main", subcategory = "Tags")
public static boolean ShortenTags = false;

@Property(type = PropertyType.BUTTON, name = "Reload Tags", description = "Reloads custom tags", category = "Main", subcategory = "Tags")
private void reload() {
HTTPstuff.reloadTags();
}
@Property(type = PropertyType.CHECKBOX, name = "Reload Tags", description = "Reloads custom tags", category = "Main", subcategory = "Tags")
public static boolean reloadTags = false;

@Property(type = PropertyType.SWITCH, name = "Debug Tags", description = "Replaces every message with your tag", category = "DEBUG", subcategory = "DEBUG")
public static boolean DebugTags = false;

@Property(type = PropertyType.SWITCH, name = "Debug Display Tags", description = "Changes player names to your tag", category = "DEBUG", subcategory = "DEBUG")
public static boolean DebugDisplayTags = false;

@Property(type = PropertyType.SWITCH, name = "DEBUG MODE", description = "FOR DEV ONLY", category = "DEBUG", subcategory = "DEBUG",hidden = true)
public static boolean DEBUG = false;
@Property(type = PropertyType.TEXT, name = "Discord RPC Second Line", description = "Allows you to set second line of the Discord RPC", category = "Main", subcategory = "RPC")
public static String RPCLineTwo = "SBE bad";

@Property(type = PropertyType.TEXT, name = "Discord RPC text", description = "Allows you to set one line of the Discord RPC", category = "Main", subcategory = "RPC")
public static String RPCText = "SBE bad";
@Property(type = PropertyType.TEXT, name = "Discord RPC First Line", description = "Allows you to set first line of the Discord RPC", category = "Main", subcategory = "RPC")
public static String RPCLineOne = "%player% is very cool";

@Property(type = PropertyType.TEXT, name = "Discord RPC Img Text", description = "Allows you to set text of the img", category = "Main", subcategory = "RPC")
public static String RPCImgText = "Skyclient is cool";

@Property(type = PropertyType.SWITCH, name = "Discord RPC", description = "Enables Discord RPC", category = "Main", subcategory = "RPC")
public static boolean RPC = true;
Expand All @@ -35,12 +44,32 @@ private void reload() {
@Property(type = PropertyType.SWITCH, name = "Sbe sucks Mode", description = "Do i need to explain this?", category = "Main", subcategory = "RPC")
public static boolean BadSbeMode = false;

@Property(type = PropertyType.SWITCH, name = "Tags in Display Names", description = "Shows tags above player names (May crash)", category = "Main", subcategory = "Tags")
public static boolean DisplayTags = false;

//@Property(type = PropertyType.TEXT, name = "Skyclient Cosmetics API key", description = "SCC Api key is used for every feature of this mod", category = "Main", subcategory = "Main", protectedText = true)
//public static String SCCApiKey = "";

public SCCConfig() {
super(new File("./config/skyclientcosmetics.toml"));

initialize();

addDependency("DebugTags","ShowDebug");
addDependency("DebugDisplayTags","ShowDebug");

addDependency("BadSbeMode","RPC");
addDependency("RPCLineTwo","RPC");
addDependency("RPCLineOne","RPC");
addDependency("RPCImgText","RPC");

addDependency("ShortenTags","TagsShow");
addDependency("reloadTags","TagsShow");
addDependency("DisplayTags","TagsShow");




}

}
4 changes: 4 additions & 0 deletions src/main/java/io/github/koxx12_dev/scc/SCC.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,9 @@ public void onTick(TickEvent.ClientTickEvent event) {
Minecraft.getMinecraft().displayGuiScreen(displayScreen);
displayScreen = null;
}
if (SCCConfig.reloadTags) {
HTTPstuff.reloadTags();
SCCConfig.reloadTags = false;
}
}
}
19 changes: 9 additions & 10 deletions src/main/java/io/github/koxx12_dev/scc/Utils/RPC.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import net.arikia.dev.drpc.DiscordEventHandlers;
import net.arikia.dev.drpc.DiscordRPC;
import net.arikia.dev.drpc.DiscordRichPresence;
import net.minecraft.client.Minecraft;

import java.time.Instant;

Expand All @@ -29,9 +28,9 @@ public void initRPC() {

DiscordEventHandlers handlers = new DiscordEventHandlers.Builder().setReadyEventHandler((user) -> {
System.out.println("Discord user: " + user.username);
DiscordRichPresence.Builder presence = new DiscordRichPresence.Builder(SCCConfig.RPCText);
presence.setDetails(Minecraft.getMinecraft().getSession().getUsername()+" is very cool");
presence.setBigImage("skyclienticon","skyclient is very cool");
DiscordRichPresence.Builder presence = new DiscordRichPresence.Builder(Transformers.DiscordPlaceholder(SCCConfig.RPCLineTwo));
presence.setDetails(Transformers.DiscordPlaceholder(SCCConfig.RPCLineOne));
presence.setBigImage("skyclienticon",SCCConfig.RPCImgText);
presence.setStartTimestamps(timestamp);
DiscordRPC.discordUpdatePresence(presence.build());
SCC.RPCon = true;
Expand All @@ -45,16 +44,16 @@ public void updateRPC() {
DiscordRPC.discordClearPresence();
} else if(SCCConfig.BadSbeMode){

DiscordRichPresence.Builder presence = new DiscordRichPresence.Builder(SCCConfig.RPCText);
presence.setDetails(Minecraft.getMinecraft().getSession().getUsername()+" hates SBE");
presence.setBigImage("nosbe","SBE is a trash mod");
DiscordRichPresence.Builder presence = new DiscordRichPresence.Builder(Transformers.DiscordPlaceholder(SCCConfig.RPCLineTwo));
presence.setDetails(Transformers.DiscordPlaceholder(SCCConfig.RPCLineOne));
presence.setBigImage("nosbe",SCCConfig.RPCImgText);
presence.setStartTimestamps(timestamp);
DiscordRPC.discordUpdatePresence(presence.build());

} else {
DiscordRichPresence.Builder presence = new DiscordRichPresence.Builder(SCCConfig.RPCText);
presence.setDetails(Minecraft.getMinecraft().getSession().getUsername()+" is very cool");
presence.setBigImage("skyclienticon","skyclient is very cool");
DiscordRichPresence.Builder presence = new DiscordRichPresence.Builder(Transformers.DiscordPlaceholder(SCCConfig.RPCLineTwo));
presence.setDetails(Transformers.DiscordPlaceholder(SCCConfig.RPCLineOne));
presence.setBigImage("skyclienticon",SCCConfig.RPCImgText);
presence.setStartTimestamps(timestamp);
DiscordRPC.discordUpdatePresence(presence.build());
}
Expand Down
18 changes: 17 additions & 1 deletion src/main/java/io/github/koxx12_dev/scc/Utils/Transformers.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package io.github.koxx12_dev.scc.Utils;

import io.github.koxx12_dev.scc.SCC;
import net.minecraft.client.Minecraft;

public class Transformers {

public static String cleanMessage(String msg) {
//if null, keep null (no gain or loss of safety)
if (msg == null)
Expand Down Expand Up @@ -29,6 +33,18 @@ public static String cleanMessage(String msg) {
.replaceAll("\u00A78","")
.replaceAll("\u00A70","");

return msg.toString();//build the string, and return
return msg;//build the string, and return
}
public static String DiscordPlaceholder(String text) {
String text2 = text.replaceAll("%player%", Minecraft.getMinecraft().getSession().getUsername())
.replaceAll("%fps%", String.valueOf(Minecraft.getDebugFPS()))
.replaceAll("%shorttag%", cleanMessage(SCC.UUIDtagsShort.get(Minecraft.getMinecraft().getSession().getUsername())))
.replaceAll("%tag%", cleanMessage(SCC.UUIDtags.get(Minecraft.getMinecraft().getSession().getUsername())));

try {
return text2.replaceAll("%hand%", cleanMessage(Minecraft.getMinecraft().thePlayer.getHeldItem().getDisplayName()));
} catch (NullPointerException e) {
return text2.replaceAll("%hand%", "Nothing");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,26 @@ public class ChatListeners {

@SubscribeEvent
public void onChatMsg(ClientChatReceivedEvent event) {
if (!SCCConfig.TagsHidden && DetectionStuff.isOnHypixel()) {
if (SCCConfig.TagsShow && DetectionStuff.isOnHypixel()) {

System.out.println(event.message.getUnformattedText()+" , "+Transformers.cleanMessage(event.message.getUnformattedText()));
//System.out.println(event.message.getFormattedText()+" , "+Transformers.cleanMessage(event.message.getUnformattedText()));

System.out.println(event.message.getUnformattedText().split(" ") +" "+ Transformers.cleanMessage(event.message.getUnformattedText()).split(" "));
//System.out.println(event.message.getUnformattedText().split(" ") +" "+ Transformers.cleanMessage(event.message.getUnformattedText()).split(" "));

List<String> msgAsList = new ArrayList<>(Arrays.asList(event.message.getUnformattedText().split(" ")));
List<String> msgAsList = new ArrayList<>(Arrays.asList(event.message.getFormattedText().split(" ")));
List<String> cleanMsgAsList = new ArrayList<>(Arrays.asList(Transformers.cleanMessage(event.message.getUnformattedText()).split(" ")));


System.out.println("\""+cleanMsgAsList+"\"\n\""+msgAsList+"\"");
//System.out.println("\""+cleanMsgAsList+"\"\n\""+msgAsList+"\"");

for (int i = 0; i < (cleanMsgAsList.toArray().length-1); i++) {

String val = cleanMsgAsList.get(i);
String valClean = cleanMsgAsList.get(i).replaceAll(",","").replaceAll(":","");
System.out.println(val+" , "+cleanMsgAsList.toArray().length);
//System.out.println(val+" , "+cleanMsgAsList.toArray().length);
if (SCC.HypixelRanks.contains(val)) {

System.out.println(val+" , "+i);
//System.out.println(val+" , "+i);

int j = (i+1);
try {
Expand All @@ -49,7 +49,7 @@ public void onChatMsg(ClientChatReceivedEvent event) {
val2 = SCC.UUIDtagsShort.get(cleanMsgAsList.get(j).replaceAll(":",""));
}

System.out.println(cleanMsgAsList.get(j)+" , "+val2);
//System.out.println(cleanMsgAsList.get(j)+" , "+val2);
if (val2 != null) {
msgAsList.add(i,val2);
event.message = new ChatComponentText(String.join(" ", msgAsList));
Expand Down Expand Up @@ -83,7 +83,7 @@ public void onChatMsg(ClientChatReceivedEvent event) {


}
if (SCCConfig.DEBUG) {
if (SCCConfig.DebugTags) {
try {
System.out.println(event.message = new ChatComponentText(SCC.UUIDtags.get(Minecraft.getMinecraft().getSession().getUsername())));
} catch (Exception e) {
Expand All @@ -92,5 +92,4 @@ public void onChatMsg(ClientChatReceivedEvent event) {

}
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package io.github.koxx12_dev.scc.listeners;

import io.github.koxx12_dev.scc.GUI.SCCConfig;
import io.github.koxx12_dev.scc.SCC;
import io.github.koxx12_dev.scc.threads.JoinThread;
import net.minecraft.client.Minecraft;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.network.FMLNetworkEvent;

Expand All @@ -14,4 +18,26 @@ public void onPlayerLoggedIn(FMLNetworkEvent.ClientConnectedToServerEvent event)

}

@SubscribeEvent
public void onNameFormat(PlayerEvent.NameFormat event) {
if (SCCConfig.DebugDisplayTags) {
event.displayname = SCC.UUIDtags.get(Minecraft.getMinecraft().getSession().getUsername());
}

if (SCCConfig.DisplayTags) {
System.out.println(event.displayname);
if (SCC.UUIDtags.containsKey(event.displayname)) {
System.out.println(event.displayname);
String tag;

if (SCCConfig.ShortenTags) {
tag = SCC.UUIDtagsShort.get(event.displayname);
} else {
tag = SCC.UUIDtags.get(event.displayname);
}
event.displayname = tag + " " + event.displayname;
}
}
}

}

0 comments on commit d8e3055

Please sign in to comment.