Skip to content

Commit

Permalink
bo'om gear
Browse files Browse the repository at this point in the history
  • Loading branch information
HerXayah committed Nov 6, 2022
1 parent 4266daa commit e8ae1c1
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 121 deletions.
63 changes: 15 additions & 48 deletions src/main/java/meow/emily/patootie/Emily.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,30 +61,8 @@ public void onEnable() {
(user, entityPlayer, networkPlayerInfo, list) ->
list.add(createBlacklistRemoval())
);

System.out.println("Starting...");
}

/* @SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) {
if (!voiceexist) {
for (LabyModAddon addon : AddonLoader.getAddons()) {
if (addon == null || addon.about == null || addon.about.name == null) {
continue;
}
LabyModAddon voicechat = AddonLoader.getAddonByUUID(UUID.fromString(String.valueOf(vcUuid8)));
if (voicechat instanceof VoiceChat && addon.about.name.equals("VoiceChat")) {
voiceChat = (VoiceChat) addon;
System.out.println(PREFIX + "VoiceChat found!");
voiceexist = true;
} else {
System.out.println(PREFIX + "VoiceChat not found!");
voiceexist = false;
}
}
}
} */

private UserActionEntry createBlacklistEntry() {
return new UserActionEntry(
"Blacklist Player",
Expand All @@ -95,14 +73,8 @@ private UserActionEntry createBlacklistEntry() {
public void execute(User user, EntityPlayer entityPlayer, NetworkPlayerInfo networkPlayerInfo) {
try {
UUID uuid = networkPlayerInfo.getGameProfile().getId();
LabyMod.getInstance().displayMessageInChat(networkPlayerInfo.getGameProfile().getId().toString());
//LabyMod.getInstance().displayMessageInChat(networkPlayerInfo.getGameProfile().getId().toString());
VoiceChat voiceChat = (VoiceChat) AddonLoader.getAddonByUUID(vcUuid8);
if (isVoiceexist()) {
Map<UUID, Integer> volume = voiceChat.getPlayerVolumes();
voiceChat.getPlayerVolumes().put(uuid, 0);
volume.put(uuid, 0);
voiceChat.savePlayersVolumes();
}
playersToRender.put(networkPlayerInfo.getGameProfile().getId(), 0);
savePlayersToRender();
playersToRenderString.add(networkPlayerInfo.getGameProfile().getName());
Expand Down Expand Up @@ -131,7 +103,7 @@ private UserActionEntry createBlacklistRemoval() {
@Override
public void execute(User user, EntityPlayer entityPlayer, NetworkPlayerInfo networkPlayerInfo) {
try {
RemovePlayer(networkPlayerInfo.getGameProfile().getName());
removePlayer(networkPlayerInfo.getGameProfile().getName());
UUID uuid = networkPlayerInfo.getGameProfile().getId();
VoiceChat voiceChat = (VoiceChat) AddonLoader.getAddonByUUID(vcUuid8);
if (isVoiceexist()) {
Expand Down Expand Up @@ -200,7 +172,7 @@ protected void fillSettings(List<SettingsElement> subSettings) {
subSettings.add(new BooleanElement(
"Enable PlayerHider",
this, new ControlElement.IconData(Material.REDSTONE),
"enabled", isModOn())
"enabled", modOn)
);
subSettings.add(new BooleanElement(
"Enable Messages",
Expand All @@ -217,24 +189,12 @@ protected void fillSettings(List<SettingsElement> subSettings) {
new ControlElement.IconData(Material.REDSTONE_TORCH_ON), this.key, integer -> {
this.key = integer;
getConfig().addProperty("key", integer);
saveConfig();
});

// If you know how to make both, THIS and the STRING Value to update simultaniously
// feel free to edit this in, so we can use This
/*
StringElement Blacklistbutton = new StringElement(
"Blacklist", new ControlElement.IconData(Material.COAL_BLOCK),
String.join(",", playersToRenderString), this::AddPlayer);
subSettings.add(new HeaderElement(ModColor.cl('a') + "Seperate them by Comma"));
*/
subSettings.add(keyElement);
}

public void RemovePlayer(String s) {
public void removePlayer(String s) {
// remove from the list

playersToRenderString.remove(s);
savePlayersToRenderString();
// playersToRenderString.removeIf(player -> player.equals(s));
Expand All @@ -248,14 +208,10 @@ public void savePlayersToRender() {
Integer volume = uuidIntegerEntry.getValue();
object.addProperty(uuid, volume);
}
//labyMod().displayMessageInChat(playersToRender.toString());
getConfig().add("playersToRender", object);
saveConfig();
}

private LabyMod labyMod() {
return LabyMod.getInstance();
}

public void savePlayersToRenderString() {
JsonArray jsonArray = new JsonArray();
Expand All @@ -270,6 +226,17 @@ public void savePlayersToRenderString() {
saveConfig();
}

/* public void listToMap(EntityPlayer user) {
// convert list to map
playersToRenderString.forEach(player -> {
playersToRender.put(user.getUniqueID(), 0); // add player to map
});
} */

private LabyMod labyMod() {
return LabyMod.getInstance();
}

public int getKey() {
return this.key;
}
Expand Down
24 changes: 0 additions & 24 deletions src/main/java/meow/emily/patootie/events/CommandHandler.java

This file was deleted.

104 changes: 55 additions & 49 deletions src/main/java/meow/emily/patootie/events/PlayerEventHandler.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package meow.emily.patootie.events;

import com.mojang.realmsclient.gui.ChatFormatting;
import meow.emily.patootie.Emily;
import meow.emily.patootie.util.Utils;
import net.labymod.addon.AddonLoader;
Expand All @@ -26,10 +25,16 @@ public class PlayerEventHandler {
// UUID VoiceChat 1.8
private final UUID vcUuid8 = UUID.fromString("43152d5b-ca80-4b29-8f48-39fd63e48dee");

boolean keyPressed = false;
boolean keystate = false;

// im gonna kms ngl
Emily instance = Emily.getInstance();
LabyMod labymod = LabyMod.getInstance();
Minecraft minecraft = Minecraft.getMinecraft();

@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) {
Emily instance = Emily.getInstance();
if (!instance.isVoiceexist()) {
LabyModAddon addon = AddonLoader.getAddonByUUID(UUID.fromString(String.valueOf(vcUuid8)));
if (addon instanceof VoiceChat && addon.about.name.equals("VoiceChat")) {
Expand All @@ -43,10 +48,9 @@ public void onTick(TickEvent.ClientTickEvent event) {

@SubscribeEvent
public void onPrePlayerRender(RenderPlayerEvent.Pre e) {
Emily instance = Emily.getInstance();
EntityPlayer enPlayer = e.entityPlayer;
if (instance.isRenderPlayers() && instance.isModOn()) {
if (instance.isRenderPlayers() && !enPlayer.equals(Minecraft.getMinecraft().thePlayer)) {
if (instance.isRenderPlayers() && !enPlayer.equals(minecraft.thePlayer)) {
List<String> localPlayersToRender = instance.getPlayersToRenderString();
if (Utils.isNPC(enPlayer)) {
e.setCanceled(false);
Expand All @@ -61,78 +65,80 @@ public void onPrePlayerRender(RenderPlayerEvent.Pre e) {
}

public void mute(EntityPlayer player) {
Emily instance = Emily.getInstance();
VoiceChat voiceChat = (VoiceChat) AddonLoader.getAddonByUUID(this.vcUuid8);
if (!player.equals(Minecraft.getMinecraft().thePlayer)) {
if (!player.equals(minecraft.thePlayer)) {
voiceChat.getPlayerVolumes().put(player.getUniqueID(), 0);
voiceChat.savePlayersVolumes();
}
}

public void RemovePlayer(String s) {
// remove from the list
Emily instance = Emily.getInstance();
instance.getPlayersToRenderString().remove(s);
instance.savePlayersToRenderString();
// playersToRenderString.removeIf(player -> player.equals(s));
instance.saveConfig();
}

public void unmute(EntityPlayer player) {
Emily instance = Emily.getInstance();
VoiceChat voiceChat = (VoiceChat) AddonLoader.getAddonByUUID(this.vcUuid8);
UUID uuid = player.getUniqueID();
Map<UUID, Integer> volume = voiceChat.getPlayerVolumes();
if (!player.equals(Minecraft.getMinecraft().thePlayer)) {
if (!player.equals(minecraft.thePlayer)) {
volume.put(uuid, 100);
}
voiceChat.savePlayersVolumes();
}

public void SetConfig(Boolean answer) {
instance.setRenderPlayers(answer);
instance.setMuted(answer);
instance.saveConfig();
}

public void sendMessage(String message) {
try {
labymod.displayMessageInChat(message);
} catch (Exception e) {
e.printStackTrace();
labymod.displayMessageInChat(e.getMessage());
}

}

@SubscribeEvent
public void onKeyInput(InputEvent.KeyInputEvent e) {
EntityPlayer enPlayer = Minecraft.getMinecraft().thePlayer;
Emily instance = Emily.getInstance();
LabyMod labymod = LabyMod.getInstance();
if (instance.getKey() > -1) {
if (Keyboard.isKeyDown(instance.getKey())) {
if (instance.isModOn()) {
if (instance.isRenderPlayers()) {
instance.setRenderPlayers(false);
instance.setMuted(false);
instance.saveConfig();
if (instance.isVoiceexist() && instance.isPlayerUnmute()) {
Minecraft.getMinecraft().theWorld.playerEntities.stream()
.filter(entityPlayer ->
Emily.getInstance().getPlayersToRenderString()
.contains(entityPlayer.getName())).
forEach(this::unmute);
//RemovePlayer(enPlayer.getGameProfile().getName());
}
if (instance.isConfigMessage()) {
labymod.displayMessageInChat(ChatFormatting.GRAY + ">>" + "[" + ChatFormatting.AQUA + "PH" + ChatFormatting.WHITE + "]" + ChatFormatting.BOLD + ChatFormatting.GREEN + " on");
}
} else {
instance.setRenderPlayers(true);
instance.setMuted(true);
instance.saveConfig();
if (instance.isVoiceexist()) {
if (enPlayer != null) {
Minecraft.getMinecraft().theWorld.playerEntities.stream()
.filter(entityPlayer ->
Emily.getInstance().getPlayersToRenderString()
.contains(entityPlayer.getName())).
forEach(this::mute);
}
}
if (instance.isConfigMessage()) {
labymod.displayMessageInChat(ChatFormatting.GRAY + ">>" + "[" + ChatFormatting.AQUA + "PH" + ChatFormatting.WHITE + "]" + ChatFormatting.BOLD + ChatFormatting.DARK_RED + " off");
}
}
} else {
labymod.displayMessageInChat(ChatFormatting.GRAY + ">>" + "[" + ChatFormatting.AQUA + "PH" + ChatFormatting.WHITE + "]" + ChatFormatting.BOLD + ChatFormatting.DARK_RED + " Please enable mod in config.");
EntityPlayer enPlayer = minecraft.thePlayer;
if (Keyboard.getEventKey() == instance.getKey() && !Keyboard.getEventKeyState() &&
instance.isModOn() && instance.getKey() > -1) {
if (instance.isRenderPlayers()) {
SetConfig(false);
if (instance.isVoiceexist() && instance.isPlayerUnmute()) {
minecraft.theWorld.playerEntities.stream()
.filter(entityPlayer ->
instance.getPlayersToRenderString()
.contains(entityPlayer.getName())).
forEach(this::unmute);
}
if (instance.isConfigMessage()) {
sendMessage("[PH] - Off");
}
} else {
SetConfig(false);
if (instance.isVoiceexist() && instance.isPlayerUnmute()) {
minecraft.theWorld.playerEntities.stream()
.filter(entityPlayer ->
instance.getPlayersToRenderString()
.contains(entityPlayer.getName())).
forEach(this::mute);
}
if (instance.isConfigMessage()) {
sendMessage("[PH] - On");
}
}
} else if (Keyboard.getEventKey() == instance.getKey() &&
!Keyboard.getEventKeyState() && !instance.isModOn() && instance.getKey() > -1) {
sendMessage("[PH] - Mod seems to be disabled. Check Config.");
}
}
}

0 comments on commit e8ae1c1

Please sign in to comment.