Skip to content

Commit

Permalink
v0.1.7 - new proxy check
Browse files Browse the repository at this point in the history
  • Loading branch information
RedthMC committed Sep 11, 2023
1 parent 7f672a1 commit e931aa2
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 21 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ group = "me.redth"
// Sets the name of the output jar (the one you put in your mods folder and send to other people)
// It outputs all versions of the mod into the `build` directory.
base {
archivesName.set("$mod_id-$platform")
archivesName.set("$mod_archives_name-$platform")
}

// Configures the Polyfrost Loom, our plugin fork to easily set up the programming environment.
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mod_name=MMCUtils
# Sets the id of your mod that mod loaders use to recognize it.
mod_id=mmcutils
# Sets the version of your mod. Make sure to update this when you make changes according to semver.
mod_version=1.0.6
mod_version=0.1.7
# Sets the name of the jar file that you put in your 'mods' folder.
mod_archives_name=MMCUtils

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/me/redth/mmcutils/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ public class Configuration extends Config {
@Switch(name = "Disable Player List", subcategory = "Other", description = "Prevent accidentally tapping tab and lag your pc.")
public static boolean disablePlayerList = true;

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

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

@HUD(name = "Height Limit Distance HUD")
@HUD(name = "Height Limit Distance HUD", category = "Height Limit Distance HUD")
public static HeightLimitHud hud = new HeightLimitHud();

public Configuration() {
Expand Down
56 changes: 40 additions & 16 deletions src/main/java/me/redth/mmcutils/MMCUtils.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package me.redth.mmcutils;

import cc.polyfrost.oneconfig.libs.universal.ChatColor;
import com.google.common.collect.ImmutableList;

import net.minecraft.client.Minecraft;
import net.minecraft.scoreboard.Score;
import net.minecraft.scoreboard.ScoreObjective;
import net.minecraft.scoreboard.ScorePlayerTeam;
import net.minecraft.scoreboard.Scoreboard;
import net.minecraftforge.client.event.ClientChatReceivedEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.common.MinecraftForge;
Expand All @@ -12,6 +16,8 @@
import net.minecraftforge.fml.common.network.FMLNetworkEvent;

import java.util.List;
import java.util.Timer;
import java.util.TimerTask;

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

private static final Minecraft mc = Minecraft.getMinecraft();
public static boolean inMMC, inPractice, inPartyChat, inBridgingGame;
public static boolean checkedScoreboard, inPractice, inPartyChat, inBridgingGame;

@Mod.EventHandler
public void init(FMLInitializationEvent e) {
MinecraftForge.EVENT_BUS.register(this);
new Configuration();
}

@SubscribeEvent
public void onJoin(FMLNetworkEvent.ClientConnectedToServerEvent e) {
if (!e.isLocal && mc.getCurrentServerData().serverIP.contains("minemen.club")) inMMC = true;
}

@SubscribeEvent
public void onQuit(FMLNetworkEvent.ClientDisconnectionFromServerEvent e) {
inMMC = inPractice = inPartyChat = inBridgingGame = false;
checkedScoreboard = inPractice = inPartyChat = inBridgingGame = false;
}

@SubscribeEvent
public void onChat(ClientChatReceivedEvent e) {
if (!inMMC) return;

String clean = e.message.getUnformattedText();
if (!inPractice && "Minemen Club".equals(clean) && Configuration.autoQueue) {
String[] split = mc.getCurrentServerData().serverIP.split(".minemen.club");
String mmcProxy = split[0].length() == 2 ? split[0] : "na";
mc.thePlayer.sendChatMessage("/joinqueue " + mmcProxy + "-practice");
inPractice = true;

if (!checkedScoreboard && !inPractice && "Minemen Club".equals(clean) && Configuration.autoQueue) {
new Timer().schedule(new TimerTask() {
@Override
public void run() {
checkScoreboard();
}
}, 1000L);
}

if (!inPractice) return;

if (!inPartyChat && ALL_PROXY.contains(clean) && Configuration.autoPartyChat) {
mc.thePlayer.sendChatMessage("/p chat");
inPartyChat = true;
Expand All @@ -68,8 +72,28 @@ public void onChat(ClientChatReceivedEvent e) {
@SubscribeEvent
public void onRenderGameOverlay(RenderGameOverlayEvent.Pre e) {
if (e.type != RenderGameOverlayEvent.ElementType.PLAYER_LIST) return;
if (!inMMC) return;
if (!checkedScoreboard) return;
if (!Configuration.disablePlayerList) return;
e.setCanceled(true);
}

public static void checkScoreboard() {
checkedScoreboard = true;
Scoreboard scoreboard = mc.theWorld.getScoreboard();
if (scoreboard == null) return;
ScoreObjective objective = scoreboard.getObjectiveInDisplaySlot(1);
if (objective == null) return;
for (Score score : scoreboard.getSortedScores(objective)) {
ScorePlayerTeam team = scoreboard.getPlayersTeam(score.getPlayerName());
String text = ScorePlayerTeam.formatPlayerName(team, score.getPlayerName());
text = ChatColor.Companion.stripColorCodes(text);
if (text == null) continue;
String[] split = text.split(".minemen.club");
if (split[0].length() != 2) continue;
String mmcProxy = split[0];
mc.thePlayer.sendChatMessage("/joinqueue " + mmcProxy + "-practice");
inPractice = true;
break;
}
}
}

0 comments on commit e931aa2

Please sign in to comment.