Skip to content

Commit

Permalink
нейм протект для друзей (сделал dest4590)
Browse files Browse the repository at this point in the history
  • Loading branch information
Slieko committed May 26, 2024
1 parent ea304da commit 577b2c1
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/main/java/thunder/hack/core/impl/FriendManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void addFriend(String friend) {
friends.add(friend);
}

public List<String> getFriends() {
public static List<String> getFriends() {
return friends;
}

Expand Down
22 changes: 16 additions & 6 deletions src/main/java/thunder/hack/injection/MixinTextVisitFactory.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package thunder.hack.injection;

import thunder.hack.core.impl.ModuleManager;
import thunder.hack.modules.misc.NameProtect;
import net.minecraft.text.TextVisitFactory;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArg;

import thunder.hack.core.impl.ModuleManager;
import thunder.hack.modules.misc.NameProtect;
import java.util.List;
import static thunder.hack.modules.Module.mc;

@Mixin(value = {TextVisitFactory.class})
Expand All @@ -17,12 +17,22 @@ private static String adjustText(String text) {
}

private static String protect(String string) {
if (!ModuleManager.nameProtect.isEnabled() || mc.player == null)
if (!ModuleManager.nameProtect.isEnabled() || mc.player == null) {
return string;
}

String me = mc.getSession().getUsername();
if (string.contains(me))
if (string.contains(me)) {
return string.replace(me, NameProtect.getCustomName());
}

List<String> friends = thunder.hack.core.impl.FriendManager.getFriends();
for (String friend : friends) {
if (string.contains(friend)) {
string = string.replace(friend, NameProtect.getCustomFriendsName());
}
}

return string;
}
}
}
19 changes: 18 additions & 1 deletion src/main/java/thunder/hack/modules/misc/NameProtect.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,33 @@
package thunder.hack.modules.misc;

import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import thunder.hack.ThunderHack;
import thunder.hack.core.impl.FriendManager;
import thunder.hack.core.impl.ModuleManager;
import thunder.hack.gui.hud.impl.TargetHud;
import thunder.hack.modules.Module;
import thunder.hack.setting.Setting;

import javax.naming.Name;
import java.util.Objects;
import java.util.Set;

public class NameProtect extends Module {
public NameProtect() {
super("NameProtect", Category.MISC);
}

public static Setting<String> newName = new Setting<>("name", "Hell_Raider");
// friends name protect by dest4590 (https://github.com/dest4590/ThunderHack-Recode/commit/c77e0b9a71afcaec41d88793f12e9cb51328f051#diff-34f70393f6b4a9eebb6ef8909815d48f52849a9860bb19fe7fe1203d68f663a0)
public static Setting<Boolean> friendProtect = new Setting<>("Friend Protect", Boolean.TRUE);
public static Setting<String> friendName = new Setting<>("Friend Name", "Hell_Raider").withParent(friendProtect);

public static String getCustomName() {
return newName.getValue().replaceAll("&", "\u00a7");
return ModuleManager.nameProtect.isEnabled() ? newName.getValue().replaceAll("&", "\u00a7") : mc.getGameProfile().getName();
}
public static String getCustomFriendsName() {
return ModuleManager.nameProtect.isEnabled() && NameProtect.friendProtect.getValue() ? friendName.getValue().replaceAll("&", "\u00a7") : mc.getGameProfile().getName();
}

}
11 changes: 10 additions & 1 deletion src/main/java/thunder/hack/modules/render/NameTags.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@
import org.joml.Vector4d;
import org.lwjgl.opengl.GL11;
import thunder.hack.ThunderHack;
import thunder.hack.core.impl.FriendManager;
import thunder.hack.core.impl.ModuleManager;
import thunder.hack.gui.font.FontRenderers;
import thunder.hack.gui.hud.impl.PotionHud;
import thunder.hack.modules.Module;
import thunder.hack.modules.client.HudEditor;
import thunder.hack.modules.misc.NameProtect;
import thunder.hack.setting.Setting;
import thunder.hack.setting.impl.ColorSetting;
import thunder.hack.utility.render.Render2DEngine;
Expand Down Expand Up @@ -118,7 +121,13 @@ public void onRender2D(DrawContext context) {
if (ping.getValue()) final_string += getEntityPing(ent) + "ms ";
if (gamemode.getValue()) final_string += translateGamemode(getEntityGamemode(ent)) + " ";

final_string += (ent.getDisplayName().getString()) + " ";
if (ModuleManager.nameProtect.isEnabled() && FriendManager.getFriends().contains(ent.getName().getString()) && NameProtect.friendProtect.getValue()) {
final_string += NameProtect.getCustomName() + " ";
}
else {
final_string += (ent.getDisplayName().getString()) + " ";
}


if (hp.getValue() && health.is(Health.Number)) {
final_string += getHealthColor(getHealth(ent)) + round2(getHealth(ent)) + " ";
Expand Down

0 comments on commit 577b2c1

Please sign in to comment.