Skip to content

Commit

Permalink
Remove GameRestyle, Fix Fake Triggers, Add Hytillities Support
Browse files Browse the repository at this point in the history
  • Loading branch information
udu3324 committed Feb 15, 2022
1 parent f6fce88 commit 390b841
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 167 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ repositories {
maven { url 'https://repo.hypixel.net/repository/Hypixel/' }
}

version = "1.2.0"
version = "1.2.3"
group= "com.udu3324.hytools" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "Hytools"

Expand Down
28 changes: 3 additions & 25 deletions src/main/java/com/udu3324/hytools/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,15 @@ public void processCommand(ICommandSender sender, String[] args) throws CommandE
collection.put("partyguess", "1");
collection.put("partyguessfriends", "2");
collection.put("partyguessguilds", "3");
collection.put("gamerestyle", "4");
collection.put("nickalert", "5");
collection.put("nickalerthypixelapi", "6");
collection.put("nickalert", "4");
collection.put("nickalerthypixelapi", "4");

if (args.length < 1) {
sender.addChatMessage(new ChatComponentText("\n" + EnumChatFormatting.GOLD + "[+]= Hytools v" + Reference.VERSION + " by udu3324 =[+]\n"
+ EnumChatFormatting.GOLD + "Check out my GitHub! https://github.com/udu3324 \n\n"
+ EnumChatFormatting.DARK_AQUA + "/hytools partyguess [toggle/on/off] [toggled|" + Config.getPartyGuess() + "]\n"
+ EnumChatFormatting.DARK_GREEN + "/hytools partyguessfriends [toggle/on/off] [toggled|" + Config.getPartyGuessFriend() +"]\n"
+ EnumChatFormatting.DARK_GREEN + "/hytools partyguessfriends [toggle/on/off] [toggled|" + Config.getPartyGuessFriend() +"] \n"
+ EnumChatFormatting.GOLD + "/hytools partyguessguilds [toggle/on/off] [toggled|" + Config.getPartyGuessGuild() + "]\n"
+ EnumChatFormatting.BLUE + "/hytools gamerestyle [toggle/on/off] [toggled|" + Config.getGameRestyle() + "]\n"
+ EnumChatFormatting.DARK_PURPLE + "/hytools nickalert [toggle/on/off] [toggled|" + Config.getNickAlert() + "]\n"
+ EnumChatFormatting.GRAY + "Using Hypixel API for NickAlert is in the grey area of being allowed. " + EnumChatFormatting.BOLD + "Use at your own risk.\n"
+ EnumChatFormatting.DARK_PURPLE + "/hytools nickalerthypixelapi [toggle/on/off] [toggled|" + Config.getNickAlertHypixelAPI() + "]"));
Expand Down Expand Up @@ -70,12 +68,6 @@ public void processCommand(ICommandSender sender, String[] args) throws CommandE
} else {
data = "OFF";
}
} else if (command.equals("GAMERESTYLE")) {
if (Config.getGameRestyle()) {
data = "ON";
} else {
data = "OFF";
}
} else if (command.equals("NICKALERT")) {
if (Config.getNickAlert()) {
data = "ON";
Expand Down Expand Up @@ -161,20 +153,6 @@ public void processCommand(ICommandSender sender, String[] args) throws CommandE
data = "ON";
}
}
} else if (command.equals("GAMERESTYLE")) {
if (data.equals("ON")) {
Config.setGameRestyle(true);
} else if (data.equals("OFF")) {
Config.setGameRestyle(false);
} else if (data.equals("TOGGLE")) {
if (Config.getGameRestyle()) {
Config.setGameRestyle(false);
data = "OFF";
} else { //would be off
Config.setGameRestyle(true);
data = "ON";
}
}
} else if (command.equals("NICKALERT")) {
if (data.equals("ON")) {
Config.setNickAlert(true);
Expand Down
18 changes: 1 addition & 17 deletions src/main/java/com/udu3324/hytools/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,6 @@ public static void create() {
w.write("party-guess-friendmsg_toggled: true" + System.lineSeparator());
w.write("party-guess-guildcheck_toggled: true" + System.lineSeparator());
w.write(System.lineSeparator());
w.write("# Game Restyle Config" + System.lineSeparator());
w.write("game-restyle_toggled: true" + System.lineSeparator());
w.write(System.lineSeparator());
w.write("# Nick Alert Config" + System.lineSeparator());
w.write("nick-alert_toggled: true" + System.lineSeparator());
w.write("nick-alert-hypixel-api_toggled: false" + System.lineSeparator());
Expand Down Expand Up @@ -192,19 +189,6 @@ public static Boolean getNickAlert() {
}
}

public static void setGameRestyle(Boolean bool) {
setValueFromConfig("game-restyle_toggled", String.valueOf(bool));
}

public static Boolean getGameRestyle() {
String str = getValueFromConfig("game-restyle_toggled");
if (str.equals("true")) {
return true;
} else {
return false;
}
}

public static void setNickAlert(Boolean bool) {
setValueFromConfig("nick-alert_toggled", String.valueOf(bool));
}
Expand All @@ -221,4 +205,4 @@ public static Boolean getNickAlertHypixelAPI() {
public static void setNickAlertHypixelAPI(Boolean bool) {
setValueFromConfig("nick-alert-hypixel-api_toggled", String.valueOf(bool));
}
}
}
59 changes: 26 additions & 33 deletions src/main/java/com/udu3324/hytools/Hytools.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

import com.udu3324.hytools.hyapi.HypixelApiKey;
import com.udu3324.hytools.mcapi.UUID;
import com.udu3324.hytools.tools.gamerestyle.GameRestyle;
import com.udu3324.hytools.tools.nickalert.NickAlert;
import com.udu3324.hytools.tools.partyguess.PartyGuess;

Expand Down Expand Up @@ -74,7 +73,7 @@ public void init(FMLInitializationEvent event) {

@SubscribeEvent
public void onWorldLoaded(EntityJoinWorldEvent event) {
if (!doOnceOnWorldLoaded) { //prevents infinite loop
if (!doOnceOnWorldLoaded) {
return;
}
// if statements have to be seperate or else serverIP could be null and crash mc
Expand All @@ -98,22 +97,18 @@ public void onWorldLoaded(EntityJoinWorldEvent event) {

doOnceOnWorldLoaded = false;
}

public static void runPaGuNiAl(final String filtered) {
Matcher noSpace = Pattern.compile("^ ").matcher(filtered);

if (!noSpace.find()) {
PartyGuess.guessMessageParty(filtered);

new Thread(new Runnable() {
@Override
public void run() {
NickAlert.checkIfNicked(filtered);
}
}).start();
}
}

void runTools(final String filtered, final Boolean bool) {
PartyGuess.guessMessageParty(filtered, bool);

new Thread(new Runnable() {
@Override
public void run() {
NickAlert.checkIfNicked(filtered, bool);
}
}).start();
}

@SubscribeEvent
public void onPlayerChat(ClientChatReceivedEvent event) {
if (!isOnHypixel) { //stop if not on hypixel
Expand All @@ -127,7 +122,6 @@ public void onPlayerChat(ClientChatReceivedEvent event) {
}

final String filtered = event.message.getUnformattedText();
final String unfiltered = event.message.getFormattedText();

//get the new api key in chat and prevent client from seeing it on the first time
Matcher m = Pattern.compile("^Your new API key is ").matcher(filtered);
Expand All @@ -143,21 +137,20 @@ public void onPlayerChat(ClientChatReceivedEvent event) {
}
}

Matcher gameStarts = Pattern.compile("(?=.*^The game starts in )(?=.* seconds!$)").matcher(filtered);
Matcher gameStarts2 = Pattern.compile("(?=.*^The game starts in )(?=.* second!$)").matcher(filtered);

Matcher playerLeave = Pattern.compile(" has quit!$").matcher(filtered);
Matcher playerJoin = Pattern.compile("(?=.* has joined \\().*(?=.*\\)!$)").matcher(filtered);
Matcher joined = Pattern.compile("(?=.* has joined \\()(?=.*\\)!$)").matcher(filtered);
Matcher noFrontSpace = Pattern.compile("^ ").matcher(filtered);

Matcher hytillities = Pattern.compile("(?=.*^\\+ \\()(?=.*\\) )").matcher(filtered);

int countOfSpaces = filtered.length() - filtered.replace(" ", "").length();

if (gameStarts.find() || gameStarts2.find()) {
event.setCanceled(GameRestyle.startsIn(filtered));
} else if (playerJoin.find()) {
runPaGuNiAl(filtered);
event.setCanceled(GameRestyle.joinMSG(unfiltered));
} else if (playerLeave.find()) {
event.setCanceled(GameRestyle.leaveMSG(unfiltered));
} else if (filtered.equals("We don't have enough players! Start cancelled.")) {
event.setCanceled(GameRestyle.startCanceled());
System.out.println("filtered length: " + filtered.length());
if (joined.find() && !noFrontSpace.find() && countOfSpaces == 3) {
System.out.println("filtered length: " + filtered.length());
runTools(filtered, false);
} else if (hytillities.find() && !noFrontSpace.find() && countOfSpaces == 2) {
System.out.println("filtered length: " + filtered.length());
runTools(filtered, true);
}
}
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/udu3324/hytools/Reference.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
public class Reference {
public static final String MODID = "HT";
public static final String NAME = "Hytools";
public static final String VERSION = "1.2.0";
public static final String VERSION = "1.2.3";
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,18 @@ static Boolean hasLoggedOntoHypixel(String UUID) {
return false;
}

public static void checkIfNicked(String message) {
public static void checkIfNicked(String message, Boolean hytillities) {
if (!Config.getNickAlert()) {
//this is to disable nick alert if it's disabled in config
return;
}

String username = message.substring(0, message.indexOf(" "));
String username;
if (hytillities) {
username = message.substring(message.indexOf(" ", 3) + 1, message.length());
} else {
username = message.substring(0, message.indexOf(" "));
}

String uuid = null;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,19 @@ public class PartyGuess {
// time delay when the code resets
public static int delay = 10; //ms

public static void guessMessageParty(String message) {
public static void guessMessageParty(String message, Boolean hytillities) {
if (!Config.getPartyGuess()) {
//this is to disable party guess if it's disabled in config
return;
}

String username = message.substring(0, message.indexOf(" "));

String username;
if (hytillities) {
username = message.substring(message.indexOf(" ", 3) + 1, message.length());
} else {
username = message.substring(0, message.indexOf(" "));
}

if (doOnceBeforeTimeReset) {
tempUserArray.clear();

Expand Down

0 comments on commit 390b841

Please sign in to comment.