Skip to content

Commit 59d4bb9

Browse files
committed
Prevent reconnecting on transfer packet, close #6
1 parent 6bf0a5b commit 59d4bb9

3 files changed

Lines changed: 25 additions & 13 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 1.0.3
4+
5+
- Added exception to prevent reconnecting when disconnected by transfer packet
6+
37
## 1.0.2
48

59
- Fixed YACL dependency ID

common/src/main/java/dev/terminalmc/autoreconnectrf/util/ScreenMixinUtil.java

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,15 @@ public static boolean checkConditions(Screen screen) {
4747
AutoReconnect.lastDcReasonStr = reasonStr;
4848
AutoReconnect.lastDcReasonKey = null;
4949
boolean match = false;
50-
51-
// Check regex conditions
52-
for (Pattern condition : AutoReconnect.conditionPatterns) {
53-
if (condition.matcher(reasonStr).find()) {
54-
AutoReconnect.LOG.info("Matched pattern '{}' against reason '{}'",
55-
condition, reasonStr);
56-
match = true;
57-
break;
58-
}
59-
}
60-
// Check key conditions
61-
if (!match && reason.getContents() instanceof TranslatableContents tc) {
50+
51+
if (reason.getContents() instanceof TranslatableContents tc) {
6252
String key = tc.getKey();
6353
AutoReconnect.lastDcReasonKey = key;
54+
55+
// Check for transfer packet
56+
if (key.equals("disconnect.transfer")) return false;
57+
58+
// Check key conditions
6459
for (String condition : Config.options().conditionKeys) {
6560
if (key.contains(condition)) {
6661
AutoReconnect.LOG.info("Matched key '{}' against reason key '{}'",
@@ -70,6 +65,19 @@ public static boolean checkConditions(Screen screen) {
7065
}
7166
}
7267
}
68+
69+
if (!match) {
70+
// Check regex conditions
71+
for (Pattern condition : AutoReconnect.conditionPatterns) {
72+
if (condition.matcher(reasonStr).find()) {
73+
AutoReconnect.LOG.info("Matched pattern '{}' against reason '{}'",
74+
condition, reasonStr);
75+
match = true;
76+
break;
77+
}
78+
}
79+
}
80+
7381
if (Config.options().conditionType) {
7482
return match;
7583
} else {

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Neo/Forge version ranges: https://maven.apache.org/enforcer/enforcer-rules/versionRanges.html
44

55
# Project
6-
mod_version=1.0.2
6+
mod_version=1.0.3
77
mod_group=dev.terminalmc
88
mod_id=autoreconnectrf
99
mod_name=AutoReconnect

0 commit comments

Comments
 (0)