Skip to content

Commit e931aa2

Browse files
committed
v0.1.7 - new proxy check
1 parent 7f672a1 commit e931aa2

File tree

4 files changed

+45
-21
lines changed

4 files changed

+45
-21
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ group = "me.redth"
4444
// Sets the name of the output jar (the one you put in your mods folder and send to other people)
4545
// It outputs all versions of the mod into the `build` directory.
4646
base {
47-
archivesName.set("$mod_id-$platform")
47+
archivesName.set("$mod_archives_name-$platform")
4848
}
4949

5050
// Configures the Polyfrost Loom, our plugin fork to easily set up the programming environment.

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ mod_name=MMCUtils
55
# Sets the id of your mod that mod loaders use to recognize it.
66
mod_id=mmcutils
77
# Sets the version of your mod. Make sure to update this when you make changes according to semver.
8-
mod_version=1.0.6
8+
mod_version=0.1.7
99
# Sets the name of the jar file that you put in your 'mods' folder.
1010
mod_archives_name=MMCUtils
1111

src/main/java/me/redth/mmcutils/Configuration.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ public class Configuration extends Config {
1919
@Switch(name = "Disable Player List", subcategory = "Other", description = "Prevent accidentally tapping tab and lag your pc.")
2020
public static boolean disablePlayerList = true;
2121

22-
@Switch(name = "Height Overlay", subcategory = "Height Overlay", description = "Make wools and terracottas darker at height limit.")
22+
@Switch(name = "Height Overlay", category = "Height Overlay", description = "Make wools and terracottas darker at height limit.")
2323
public static boolean heightLimitOverlay = true;
2424

25-
@Slider(name = "Height Overlay Darkness", subcategory = "Height Overlay", min = 0, max = 10, step = 1, description = "Adjust the darkness of height limit overlay.")
25+
@Slider(name = "Height Overlay Darkness", category = "Height Overlay", min = 0, max = 10, step = 1, description = "Adjust the darkness of height limit overlay.")
2626
public static int heightLimitDarkness = 3;
2727

28-
@HUD(name = "Height Limit Distance HUD")
28+
@HUD(name = "Height Limit Distance HUD", category = "Height Limit Distance HUD")
2929
public static HeightLimitHud hud = new HeightLimitHud();
3030

3131
public Configuration() {
Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
package me.redth.mmcutils;
22

3+
import cc.polyfrost.oneconfig.libs.universal.ChatColor;
34
import com.google.common.collect.ImmutableList;
4-
55
import net.minecraft.client.Minecraft;
6+
import net.minecraft.scoreboard.Score;
7+
import net.minecraft.scoreboard.ScoreObjective;
8+
import net.minecraft.scoreboard.ScorePlayerTeam;
9+
import net.minecraft.scoreboard.Scoreboard;
610
import net.minecraftforge.client.event.ClientChatReceivedEvent;
711
import net.minecraftforge.client.event.RenderGameOverlayEvent;
812
import net.minecraftforge.common.MinecraftForge;
@@ -12,6 +16,8 @@
1216
import net.minecraftforge.fml.common.network.FMLNetworkEvent;
1317

1418
import java.util.List;
19+
import java.util.Timer;
20+
import java.util.TimerTask;
1521

1622
@Mod(modid = MMCUtils.MODID, name = MMCUtils.NAME, version = MMCUtils.VERSION)
1723
public class MMCUtils {
@@ -22,36 +28,34 @@ public class MMCUtils {
2228
public static final List<String> BRIDGING_GAMES = ImmutableList.of("Bed Fight", "Fireball Fight", "Bridges", "Battle Rush");
2329

2430
private static final Minecraft mc = Minecraft.getMinecraft();
25-
public static boolean inMMC, inPractice, inPartyChat, inBridgingGame;
31+
public static boolean checkedScoreboard, inPractice, inPartyChat, inBridgingGame;
2632

2733
@Mod.EventHandler
2834
public void init(FMLInitializationEvent e) {
2935
MinecraftForge.EVENT_BUS.register(this);
3036
new Configuration();
3137
}
3238

33-
@SubscribeEvent
34-
public void onJoin(FMLNetworkEvent.ClientConnectedToServerEvent e) {
35-
if (!e.isLocal && mc.getCurrentServerData().serverIP.contains("minemen.club")) inMMC = true;
36-
}
37-
3839
@SubscribeEvent
3940
public void onQuit(FMLNetworkEvent.ClientDisconnectionFromServerEvent e) {
40-
inMMC = inPractice = inPartyChat = inBridgingGame = false;
41+
checkedScoreboard = inPractice = inPartyChat = inBridgingGame = false;
4142
}
4243

4344
@SubscribeEvent
4445
public void onChat(ClientChatReceivedEvent e) {
45-
if (!inMMC) return;
46-
4746
String clean = e.message.getUnformattedText();
48-
if (!inPractice && "Minemen Club".equals(clean) && Configuration.autoQueue) {
49-
String[] split = mc.getCurrentServerData().serverIP.split(".minemen.club");
50-
String mmcProxy = split[0].length() == 2 ? split[0] : "na";
51-
mc.thePlayer.sendChatMessage("/joinqueue " + mmcProxy + "-practice");
52-
inPractice = true;
47+
48+
if (!checkedScoreboard && !inPractice && "Minemen Club".equals(clean) && Configuration.autoQueue) {
49+
new Timer().schedule(new TimerTask() {
50+
@Override
51+
public void run() {
52+
checkScoreboard();
53+
}
54+
}, 1000L);
5355
}
5456

57+
if (!inPractice) return;
58+
5559
if (!inPartyChat && ALL_PROXY.contains(clean) && Configuration.autoPartyChat) {
5660
mc.thePlayer.sendChatMessage("/p chat");
5761
inPartyChat = true;
@@ -68,8 +72,28 @@ public void onChat(ClientChatReceivedEvent e) {
6872
@SubscribeEvent
6973
public void onRenderGameOverlay(RenderGameOverlayEvent.Pre e) {
7074
if (e.type != RenderGameOverlayEvent.ElementType.PLAYER_LIST) return;
71-
if (!inMMC) return;
75+
if (!checkedScoreboard) return;
7276
if (!Configuration.disablePlayerList) return;
7377
e.setCanceled(true);
7478
}
79+
80+
public static void checkScoreboard() {
81+
checkedScoreboard = true;
82+
Scoreboard scoreboard = mc.theWorld.getScoreboard();
83+
if (scoreboard == null) return;
84+
ScoreObjective objective = scoreboard.getObjectiveInDisplaySlot(1);
85+
if (objective == null) return;
86+
for (Score score : scoreboard.getSortedScores(objective)) {
87+
ScorePlayerTeam team = scoreboard.getPlayersTeam(score.getPlayerName());
88+
String text = ScorePlayerTeam.formatPlayerName(team, score.getPlayerName());
89+
text = ChatColor.Companion.stripColorCodes(text);
90+
if (text == null) continue;
91+
String[] split = text.split(".minemen.club");
92+
if (split[0].length() != 2) continue;
93+
String mmcProxy = split[0];
94+
mc.thePlayer.sendChatMessage("/joinqueue " + mmcProxy + "-practice");
95+
inPractice = true;
96+
break;
97+
}
98+
}
7599
}

0 commit comments

Comments
 (0)