|
7 | 7 | */ |
8 | 8 | package net.wurstclient.hacks; |
9 | 9 |
|
| 10 | +import java.util.Locale; |
| 11 | + |
10 | 12 | import net.minecraft.client.multiplayer.ClientPacketListener; |
11 | 13 | import net.minecraft.core.BlockPos; |
12 | 14 | import net.wurstclient.Category; |
|
26 | 28 | public final class SafeTpHack extends Hack |
27 | 29 | implements UpdateListener, ChatInputListener |
28 | 30 | { |
| 31 | + private static final String[][] TPA_ACCEPT_KEYWORDS = |
| 32 | + {{"accepted", "teleport"}, {"accepted", "request"}, {"accepted", "tpa"}, |
| 33 | + {"accepted", "tpahere"}, {"akzeptiert", "anfrage"}}; |
| 34 | + |
29 | 35 | private final TextFieldSetting command = new TextFieldSetting("Command", |
30 | 36 | "description.wurst.setting.safetp.command", "/t spawn", |
31 | 37 | value -> value != null && !value.trim().isEmpty()); |
@@ -161,13 +167,12 @@ public void onReceivedMessage(ChatInputEvent event) |
161 | 167 | if(!saferTpaHere.isChecked()) |
162 | 168 | return; |
163 | 169 |
|
164 | | - String message = event.getComponent().getString().toLowerCase(); |
| 170 | + String message = |
| 171 | + event.getComponent().getString().toLowerCase(Locale.ROOT); |
165 | 172 | if(message.startsWith("\u00a7c[\u00a76wurst\u00a7c]")) |
166 | 173 | return; |
167 | 174 |
|
168 | | - if((message.contains("accepted") && message.contains("teleport")) |
169 | | - || (message.contains("accepted") && message.contains("request")) |
170 | | - || (message.contains("akzeptiert") && message.contains("anfrage"))) |
| 175 | + if(isTpaAcceptanceMessage(message)) |
171 | 176 | { |
172 | 177 | ChatUtils.message("SaferTPAHere: TPA acceptance detected."); |
173 | 178 | if(MC.player == null || MC.getConnection() == null) |
@@ -209,6 +214,25 @@ public void onReceivedMessage(ChatInputEvent event) |
209 | 214 | } |
210 | 215 | } |
211 | 216 |
|
| 217 | + private boolean isTpaAcceptanceMessage(String message) |
| 218 | + { |
| 219 | + for(String[] keywords : TPA_ACCEPT_KEYWORDS) |
| 220 | + { |
| 221 | + boolean matches = true; |
| 222 | + for(String keyword : keywords) |
| 223 | + if(!message.contains(keyword)) |
| 224 | + { |
| 225 | + matches = false; |
| 226 | + break; |
| 227 | + } |
| 228 | + |
| 229 | + if(matches) |
| 230 | + return true; |
| 231 | + } |
| 232 | + |
| 233 | + return false; |
| 234 | + } |
| 235 | + |
212 | 236 | @Override |
213 | 237 | public void onUpdate() |
214 | 238 | { |
|
0 commit comments