Skip to content

Commit 4887ec2

Browse files
committed
Vastly improved custom name and custom rank
Improved terminal display to not toggle on&off Skywars click friend should now activate immediately added mod icon Sinseeker cooldown Party finder name highlight improved wither shield sound and average ping thing improved the config a bit
1 parent 32aea61 commit 4887ec2

21 files changed

Lines changed: 496 additions & 537 deletions

src/main/java/com/ownwn/ownwnaddons/OwnwnAddons.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
import com.ownwn.ownwnaddons.features.*;
99
import com.ownwn.ownwnaddons.features.chat.*;
1010
import com.ownwn.ownwnaddons.features.dungeons.DungeonsTerminalDisplay;
11-
import com.ownwn.ownwnaddons.features.dungeons.SecretClickSounds;
11+
import com.ownwn.ownwnaddons.features.dungeons.PartyFinderHighlight;
12+
import com.ownwn.ownwnaddons.features.dungeons.SinSeekerCooldown;
1213
import com.ownwn.ownwnaddons.utils.CheckSlot;
1314
import com.ownwn.ownwnaddons.utils.FetchOnServerJoin;
1415
import com.ownwn.ownwnaddons.utils.NewConfig;
@@ -45,31 +46,33 @@ public void onFMLInitialization(net.minecraftforge.fml.common.event.FMLInitializ
4546
config = new NewConfig();
4647

4748
MinecraftForge.EVENT_BUS.register(this);
48-
MinecraftForge.EVENT_BUS.register(new CustomName());
4949
MinecraftForge.EVENT_BUS.register(new TrevorChatCleanup());
5050
MinecraftForge.EVENT_BUS.register(new BazaarChatCleanup());
5151
MinecraftForge.EVENT_BUS.register(new TrevorCooldown());
5252
MinecraftForge.EVENT_BUS.register(new BankChatCleanup());
5353
MinecraftForge.EVENT_BUS.register(new SBAChromaReplacement());
5454
MinecraftForge.EVENT_BUS.register(new DungeonsChatCleanup());
55-
MinecraftForge.EVENT_BUS.register(new SecretClickSounds());
5655
MinecraftForge.EVENT_BUS.register(new WitherShieldSound());
5756
MinecraftForge.EVENT_BUS.register(new FetchOnServerJoin());
5857
MinecraftForge.EVENT_BUS.register(new DungeonsTerminalDisplay());
59-
MinecraftForge.EVENT_BUS.register(new SkywarsClickFriend());
58+
MinecraftForge.EVENT_BUS.register(new MinigameClickFriend());
6059

6160
MinecraftForge.EVENT_BUS.register(new ThirdPersonFOV());
6261
MinecraftForge.EVENT_BUS.register(new SecretStuff());
6362
MinecraftForge.EVENT_BUS.register(new GardenMilestoneMsg());
6463
MinecraftForge.EVENT_BUS.register(new TickUtils());
6564
MinecraftForge.EVENT_BUS.register(new CheckSlot());
65+
MinecraftForge.EVENT_BUS.register(new SinSeekerCooldown());
66+
MinecraftForge.EVENT_BUS.register(new PartyFinderHighlight());
67+
// MinecraftForge.EVENT_BUS.register(new OwaDevMode());
68+
MinecraftForge.EVENT_BUS.register(new CustomNames());
6669

6770

6871
CommandManager.INSTANCE.registerCommand(new Owa());
6972
CommandManager.INSTANCE.registerCommand(new HyperionPrice());
7073
CommandManager.INSTANCE.registerCommand(new FragRunCalc());
71-
EventManager.INSTANCE.register(new SkywarsClickFriend());
72-
EventManager.INSTANCE.register(new OwaDevMode());
74+
EventManager.INSTANCE.register(new MinigameClickFriend());
75+
// EventManager.INSTANCE.register(new OwaDevMode());
7376

7477

7578

src/main/java/com/ownwn/ownwnaddons/features/CustomName.java

Lines changed: 0 additions & 148 deletions
This file was deleted.
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
package com.ownwn.ownwnaddons.features;
2+
3+
import com.ownwn.ownwnaddons.OwnwnAddons;
4+
import com.ownwn.ownwnaddons.utils.ColourUtils;
5+
import com.ownwn.ownwnaddons.utils.FetchOnServerJoin;
6+
import com.ownwn.ownwnaddons.utils.NewConfig;
7+
import com.ownwn.ownwnaddons.utils.Utils;
8+
import net.minecraft.client.Minecraft;
9+
import net.minecraftforge.client.event.ClientChatReceivedEvent;
10+
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
11+
12+
import java.util.regex.Matcher;
13+
import java.util.regex.Pattern;
14+
public class CustomNames {
15+
16+
public static String username = "-Placeholder";
17+
// usernames cannot have dashes so there's no chance this will accidentally trigger.
18+
19+
public static String[] hypixelRanks = {
20+
"", // leave empty for default rank
21+
"[VIP] ",
22+
"[VIP+] ",
23+
"[MVP] ",
24+
"[MVP+] ",
25+
"[MVP++] "
26+
27+
};
28+
29+
30+
public static Pattern VIP_PATTERN;
31+
public static Pattern VIP_PLUS_PATTERN;
32+
public static Pattern MVP_PATTERN;
33+
public static Pattern MVP_PLUS_PATTERN;
34+
public static Pattern MVP_DOUBLEPLUS_PATTERN;
35+
36+
public static String replacePlayerNameAndRank(String text) {
37+
if (!NewConfig.CUSTOM_NAME_TOGGLE || NewConfig.CUSTOM_NAME_EDITOR.equals("")) {
38+
return text;
39+
}
40+
if (Minecraft.getMinecraft().thePlayer == null) {
41+
return text;
42+
}
43+
44+
45+
if (!text.contains(username)) {
46+
return text;
47+
}
48+
49+
if (NewConfig.CUSTOM_RANK_TOGGLE && !NewConfig.CUSTOM_RANK_EDITOR.equals("") && NewConfig.PLAYER_HYPIXEL_RANK != 0) {
50+
if (Utils.stripFormatting(text).contains(hypixelRanks[NewConfig.PLAYER_HYPIXEL_RANK] + username)) {
51+
Pattern chosenPattern;
52+
53+
// kid named java 8 switch statement:
54+
switch (NewConfig.PLAYER_HYPIXEL_RANK) {
55+
case 1:
56+
chosenPattern = VIP_PATTERN;
57+
break;
58+
case 2:
59+
chosenPattern = VIP_PLUS_PATTERN;
60+
break;
61+
case 3:
62+
chosenPattern = MVP_PATTERN;
63+
break;
64+
case 4:
65+
chosenPattern = MVP_PLUS_PATTERN;
66+
break;
67+
case 5:
68+
chosenPattern = MVP_DOUBLEPLUS_PATTERN;
69+
break;
70+
default:
71+
throw new IllegalArgumentException(OwnwnAddons.PREFIX + "&cInvalid rank: " + NewConfig.PLAYER_HYPIXEL_RANK);
72+
}
73+
74+
Matcher matcher = chosenPattern.matcher(text);
75+
if (matcher.find()) {
76+
77+
String newRank = NewConfig.CUSTOM_RANK_EDITOR.replace("&&", "§");
78+
text = text.replace(matcher.group(0), newRank + "§r " + username + "§r");
79+
}
80+
}
81+
}
82+
83+
text = text.replace(username, NewConfig.CUSTOM_NAME_EDITOR.replace("&&", "§") + "§r");
84+
return text;
85+
}
86+
87+
88+
public static String replaceOtherNames(String text) {
89+
if (Minecraft.getMinecraft().thePlayer == null) {
90+
return text;
91+
}
92+
if (!NewConfig.SHARED_RAINBOW_NAMES) {
93+
return text;
94+
}
95+
if (FetchOnServerJoin.nameList == null || FetchOnServerJoin.nameList.size() == 0) {
96+
return text;
97+
}
98+
99+
for (String name : FetchOnServerJoin.nameList) {
100+
101+
if (name.equals(username)) {
102+
continue;
103+
}
104+
105+
String newName = "§" + ColourUtils.chooseColour() + name + "§r";
106+
text = text.replace(name, newName);
107+
}
108+
text = text.replace("§zOwnwn§rAddons", "§zOwnwnAddons§r");
109+
// ^ stop "Ownwn" being coloured when typing the mod name
110+
return text;
111+
}
112+
113+
114+
public static String replaceChromaMessages(String text) {
115+
116+
if (Minecraft.getMinecraft().thePlayer == null) {
117+
return text;
118+
}
119+
if (NewConfig.CHROMA_TEXT_REPLACE.equals("")) {
120+
return text;
121+
}
122+
String newColour = "§";
123+
124+
newColour += ColourUtils.chooseColour();
125+
126+
for (String replacementText: NewConfig.CHROMA_TEXT_REPLACE.replace("&&", "§").split(", ")) {
127+
if (replacementText.startsWith("§l") || replacementText.startsWith("§l", 2)) {
128+
newColour = newColour.replace("§l", "") + "§l";
129+
} else {
130+
newColour = newColour.replace("§l", "");
131+
}
132+
text = text.replace(replacementText, newColour + Utils.stripFormatting(replacementText) + "§r");
133+
// it *technically* works
134+
}
135+
136+
return text;
137+
}
138+
139+
140+
@SubscribeEvent
141+
public void onChat(ClientChatReceivedEvent event) {
142+
/* listen for a chat message to ensure the player is not null so we can grab their name.
143+
this could be done with mc.get$ession().getUsername() but getting the session looks sus
144+
and probably doesn't support account switching (e.g. essential) */
145+
146+
if (!username.equals("-Placeholder")) { // the username has already been set
147+
return;
148+
}
149+
username = Minecraft.getMinecraft().thePlayer.getName();
150+
151+
// compile patterns when the game is open, so that we can include the players' username.
152+
VIP_PATTERN = Pattern.compile("(§a\\[VIP]) " + username);
153+
VIP_PLUS_PATTERN = Pattern.compile("(§a\\[VIP§6\\+§a]) " + username);
154+
155+
MVP_PATTERN = Pattern.compile("(§b\\[MVP]) " + username);
156+
MVP_PLUS_PATTERN = Pattern.compile("(§b\\[MVP§.\\+§b]|§b\\[MVP(?:§r)+(?:§.)+\\+(?:§r)+(?:§b)+]) " + username);
157+
MVP_DOUBLEPLUS_PATTERN = Pattern.compile("(§6\\[MVP(?:§.)*\\+\\+(?:§.)*]) " + username);
158+
// ^ the MVP+ regex is completely cooked, for some reason my name gets load of extra section signs??
159+
// e.g. §r§8[§r§5161§r§8] §r§b[MVP§r§4+§r§b] Ownwn§r§f: hi§r
160+
// have updated the MVP++ pattern just in case this occurs with MVP++ too.
161+
}
162+
}

0 commit comments

Comments
 (0)