Skip to content

Commit

Permalink
new: added silent lobby (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
xthe-dev committed May 8, 2023
1 parent ddd79b5 commit a6a47f8
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/main/java/cc/woverflow/hytils/HytilsReborn.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import cc.woverflow.hytils.handlers.lobby.limbo.LimboTitle;
import cc.woverflow.hytils.handlers.lobby.mysterybox.MysteryBoxStar;
import cc.woverflow.hytils.handlers.lobby.npc.NPCHandler;
import cc.woverflow.hytils.handlers.lobby.sound.SilentLobby;
import cc.woverflow.hytils.handlers.render.ChestHighlighter;
import cc.woverflow.hytils.util.HypixelAPIUtils;
import cc.woverflow.hytils.util.friends.FriendCache;
Expand Down Expand Up @@ -170,6 +171,7 @@ private void registerHandlers() {
eventBus.register(new LimboTitle());
eventBus.register(new LimboPmDing());
eventBus.register(new MysteryBoxStar());
eventBus.register(new SilentLobby());

// specific games
eventBus.register(new PitLagReducer());
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/cc/woverflow/hytils/config/HytilsConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,13 @@ public class HytilsConfig extends Config {
)
public static boolean mysteryBoxStar = true;

@Switch(
name = "Silent Lobby",
description = "Prevent all sounds from playing when you are in a lobby.",
category = "Lobby", subcategory = "Sounds"
)
public static boolean silentLobby;

@Switch(
name = "Remove Limbo AFK Title",
description = "Remove the AFK title when you get sent to limbo for being AFK.",
Expand Down Expand Up @@ -1111,6 +1118,8 @@ public HytilsConfig() {

addDependency("putInCaps", "notifyWhenKick");

addListener("coloredBeds", () -> Minecraft.getMinecraft().renderGlobal.loadRenderers());

addListener("heightOverlay", () -> Minecraft.getMinecraft().renderGlobal.loadRenderers());
addListener("overlayAmount", () -> {
DarkColorUtils.invalidateCache();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private int[] processColors(JsonArray array) {

public int[] getBedLocations() {
LocrawInfo locrawInfo = LocrawUtil.INSTANCE.getLocrawInfo();
if (locations == null || locrawInfo == null || locrawInfo.getGameType() != LocrawInfo.GameType.BEDWARS) {
if (locations == null || locrawInfo == null || !LocrawUtil.INSTANCE.isInGame() || locrawInfo.getGameType() != LocrawInfo.GameType.BEDWARS || locrawInfo.getGameMode().equals("BEDWARS_PRACTICE")) {
return (this.bedLocations = null);
}
if (!setDefault) {
Expand Down Expand Up @@ -124,18 +124,19 @@ public int[] getBedLocations() {
return (this.bedLocations = defaultBedLocations);
}

@SuppressWarnings("unused")
@Subscribe
private void onLocraw(LocrawEvent event) {
if (!LocrawUtil.INSTANCE.isInGame() || event.info.getGameType() != LocrawInfo.GameType.BEDWARS || event.info.getGameMode().equals("BEDWARS_PRACTICE")) {
return;
}

String serverId = event.info.getServerId();
if (Objects.equals(lastServer, serverId)) {
return;
}
lastServer = serverId;

if (!LocrawUtil.INSTANCE.isInGame() || event.info.getGameType() != LocrawInfo.GameType.BEDWARS) {
return;
}

bedLocations = null;
if (getBedLocations() != null) {
Minecraft.getMinecraft().renderGlobal.loadRenderers();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
public class TipMessageRemover implements ChatReceiveModule {
@Override
public void onMessageReceived(@NotNull ClientChatReceivedEvent event) {
String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText());
String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText().replace("\n", ""));
if (getLanguage().chatCleanerTipRegex.matcher(message).matches()) {
event.setCanceled(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public void onTick(TickEvent.ClientTickEvent e) {
return;
} else if (ticks == 20) {
playSound();
System.out.println(ticks);
return;
}
if (ticks > 40) ticks = -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public LanguageHandler() {
}

private void initialize() {
fallback.initialize();
final String username = Minecraft.getMinecraft().getSession().getUsername();
final JsonObject json = NetworkUtils.getJsonElement("https://api.sk1er.club/player/" + username).getAsJsonObject();
final JsonObject player = json.getAsJsonObject("player");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import cc.woverflow.hytils.handlers.cache.ArmorStandHandler;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityArmorStand;
import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.client.event.RenderLivingEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
Expand All @@ -35,7 +36,7 @@ public void onEntityRenderer(RenderLivingEvent.Pre<EntityLivingBase> event) {
final LocrawInfo locraw = LocrawUtil.INSTANCE.getLocrawInfo();
if (HypixelUtils.INSTANCE.isHypixel() && ((!LocrawUtil.INSTANCE.isInGame() && HytilsConfig.hideUselessArmorStands) || (HytilsConfig.hideUselessArmorStandsGame && LocrawUtil.INSTANCE.isInGame() && locraw != null && (locraw.getGameType() == LocrawInfo.GameType.SKYBLOCK || locraw.getGameType() == LocrawInfo.GameType.BEDWARS || locraw.getGameType() == LocrawInfo.GameType.SKYWARS || locraw.getGameMode().contains("BRIDGE"))))) {
if (event.entity instanceof EntityArmorStand) {
String unformattedArmorStandName = event.entity.getCustomNameTag().toLowerCase();
String unformattedArmorStandName = EnumChatFormatting.getTextWithoutFormattingCodes(event.entity.getCustomNameTag().toLowerCase());
for (String armorStands : ArmorStandHandler.INSTANCE.armorStandNames) {
if (unformattedArmorStandName.contains(armorStands)) {
event.setCanceled(true);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Hytils Reborn - Hypixel focused Quality of Life mod.
* Copyright (C) 2020, 2021, 2022, 2023 Polyfrost, Sk1er LLC and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package cc.woverflow.hytils.handlers.lobby.sound;

import cc.polyfrost.oneconfig.utils.hypixel.HypixelUtils;
import cc.polyfrost.oneconfig.utils.hypixel.LocrawUtil;
import cc.woverflow.hytils.config.HytilsConfig;
import net.minecraftforge.client.event.sound.PlaySoundEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

public class SilentLobby {

@SubscribeEvent
public void onSoundPlay(PlaySoundEvent event) {
if (HypixelUtils.INSTANCE.isHypixel() && !LocrawUtil.INSTANCE.isInGame() && HytilsConfig.silentLobby) {
if (!event.name.startsWith("gui.")) {
event.result = null;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public abstract class LayerArmorBaseMixin_HideIngameArmour {

@Inject(method = "renderLayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/layers/LayerArmorBase;getArmorModel(I)Lnet/minecraft/client/model/ModelBase;"), cancellable = true)
private void cancelArmor(EntityLivingBase entitylivingbaseIn, float p_177182_2_, float p_177182_3_, float partialTicks, float p_177182_5_, float p_177182_6_, float p_177182_7_, float scale, int armorSlot, CallbackInfo ci) {
if (shouldCancel(getCurrentArmor(entitylivingbaseIn, armorSlot))) {
if (shouldCancel(getCurrentArmor(entitylivingbaseIn, armorSlot)) && !entitylivingbaseIn.isInvisible()) {
ci.cancel();
}
}
Expand Down

0 comments on commit a6a47f8

Please sign in to comment.