@@ -48,55 +48,42 @@ public void onPrePlayerRender(RenderPlayerEvent.Pre e) {
48
48
if (instance .isRenderPlayers () && instance .isModOn ()) {
49
49
if (instance .isRenderPlayers () && !enPlayer .equals (Minecraft .getMinecraft ().player )) {
50
50
List <String > localPlayersToRender = instance .getPlayersToRenderString ();
51
- if (! Utils .isNPC (enPlayer )) {
51
+ if (Utils .isNPC (enPlayer )) {
52
52
e .setCanceled (false );
53
53
for (String s : localPlayersToRender ) {
54
54
if (s .equals (enPlayer .getGameProfile ().getName ())) {
55
55
e .setCanceled (true );
56
- if (instance .isVoiceexist ()) {
57
- if (instance .isMuted ()) {
58
- mute (enPlayer );
59
- }
60
- }
61
56
}
62
57
}
63
58
}
64
59
}
65
- } /* else {
66
- if (instance.isPlayerUnmute() && instance.isVoiceexist() && !enPlayer.equals(Minecraft.getMinecraft().thePlayer && !instance.isModOn())) {
67
- if (!instance.isRenderPlayers() && !Utils.isNPC(enPlayer)) {
68
- Map<UUID, Integer> volume = instance.getPlayersToRender();
69
- // for each uuid in the map
70
- for (UUID uuid : volume.keySet()) {
71
- // if the uuid is the same as the player
72
- if (uuid.equals(enPlayer.getUniqueID())) {
73
- // get the volume
74
- unmute(enPlayer);
75
- }
76
- }
77
- instance.setPlayerUnmute(!instance.isPlayerUnmute());
78
- }
79
- }
80
- } */
60
+ }
81
61
}
82
62
83
- // Call unmute when mod is also disabled on player.
84
- // currently only works when player is invis, otherwise wont unmute.
85
63
public void mute (EntityPlayer player ) {
86
64
Emily instance = Emily .getInstance ();
87
65
VoiceChat voiceChat = (VoiceChat ) AddonLoader .getAddonByUUID (this .vcUuid12 );
88
- voiceChat .getPlayerVolumes ().put (player .getUniqueID (), 0 );
89
- voiceChat .savePlayersVolumes ();
66
+ if (!player .equals (Minecraft .getMinecraft ().player )) {
67
+ voiceChat .getPlayerVolumes ().put (player .getUniqueID (), 0 );
68
+ voiceChat .savePlayersVolumes ();
69
+ }
70
+ }
71
+
72
+ public void RemovePlayer (String s ) {
73
+ // remove from the list
74
+ Emily instance = Emily .getInstance ();
75
+ instance .getPlayersToRenderString ().remove (s );
76
+ instance .savePlayersToRenderString ();
77
+ // playersToRenderString.removeIf(player -> player.equals(s));
78
+ instance .saveConfig ();
90
79
}
91
80
92
81
public void unmute (EntityPlayer player ) {
93
82
Emily instance = Emily .getInstance ();
94
83
VoiceChat voiceChat = (VoiceChat ) AddonLoader .getAddonByUUID (this .vcUuid12 );
95
- UUID uuid = player .getGameProfile (). getId ();
84
+ UUID uuid = player .getUniqueID ();
96
85
Map <UUID , Integer > volume = voiceChat .getPlayerVolumes ();
97
- if (volume .containsKey (uuid )) {
98
- volume .put (uuid , voiceChat .getVolume (uuid ));
99
- } else {
86
+ if (!player .equals (Minecraft .getMinecraft ().player )) {
100
87
volume .put (uuid , 100 );
101
88
}
102
89
voiceChat .savePlayersVolumes ();
@@ -114,10 +101,13 @@ public void onKeyInput(InputEvent.KeyInputEvent e) {
114
101
instance .setRenderPlayers (false );
115
102
instance .setMuted (false );
116
103
instance .saveConfig ();
117
- if (instance .isVoiceexist ()) {
118
- if (enPlayer != null ) {
119
- unmute (enPlayer );
120
- }
104
+ if (instance .isVoiceexist () && instance .isPlayerUnmute ()) {
105
+ Minecraft .getMinecraft ().world .playerEntities .stream ()
106
+ .filter (entityPlayer ->
107
+ Emily .getInstance ().getPlayersToRenderString ()
108
+ .contains (entityPlayer .getName ())).
109
+ forEach (this ::unmute );
110
+ //RemovePlayer(enPlayer.getGameProfile().getName());
121
111
}
122
112
if (instance .isConfigMessage ()) {
123
113
labymod .displayMessageInChat (ChatFormatting .GRAY + ">>" + "[" + ChatFormatting .AQUA + "PH" + ChatFormatting .WHITE + "]" + ChatFormatting .BOLD + ChatFormatting .GREEN + " on" );
@@ -128,7 +118,11 @@ public void onKeyInput(InputEvent.KeyInputEvent e) {
128
118
instance .saveConfig ();
129
119
if (instance .isVoiceexist ()) {
130
120
if (enPlayer != null ) {
131
- mute (enPlayer );
121
+ Minecraft .getMinecraft ().world .playerEntities .stream ()
122
+ .filter (entityPlayer ->
123
+ Emily .getInstance ().getPlayersToRenderString ()
124
+ .contains (entityPlayer .getName ())).
125
+ forEach (this ::mute );
132
126
}
133
127
}
134
128
if (instance .isConfigMessage ()) {
@@ -141,4 +135,4 @@ public void onKeyInput(InputEvent.KeyInputEvent e) {
141
135
}
142
136
}
143
137
}
144
- }
138
+ }
0 commit comments