Skip to content

Commit

Permalink
Fix for bedrock server when recovering sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
luluxe committed Oct 12, 2023
1 parent c6afa2f commit 592064f
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 10 deletions.
2 changes: 1 addition & 1 deletion dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>net</groupId>
<artifactId>communityanalytics</artifactId>
<name>communityanalytics</name>
<version>1.0.6</version>
<version>1.0.7</version>
<url>http://maven.apache.org</url>
<build>
<plugins>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>net</groupId>
<artifactId>communityanalytics</artifactId>
<version>1.0.6</version>
<version>1.0.7</version>
<packaging>jar</packaging>

<name>communityanalytics</name>
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/net/communityanalytics/common/RegexUtil.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package net.communityanalytics.common;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegexUtil {
/**
* Check if a string is a valid domain
Expand All @@ -15,4 +18,18 @@ public static boolean isDomain(String domain) {
return isDomain(domain.split(":")[0]);
return false;
}

/**
* @param message String
* @return String
*/
public static String extractIp(String message) {
Pattern pattern = Pattern.compile("\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}");
Matcher matcher = pattern.matcher(message);

if (matcher.find()) {
return matcher.group();
}
return null;
}
}
13 changes: 10 additions & 3 deletions src/main/java/net/communityanalytics/spigot/data/Session.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,16 @@ public void finish() {
*/
public boolean isValid() {
if (!RegexUtil.isDomain(this.ip_connect)) {
SpigotPlugin.logger().printError("The ip_connect is not a valid domain name: " + this.ip_connect);
SpigotPlugin.logger().printError("Contact CommunityAnalytics on Discord, if you can't solve this problem.");
return false;
String ip = RegexUtil.extractIp(this.ip_connect);
if(ip == null) {
// Try to fix it
SpigotPlugin.logger().printError("The ip_connect is not a valid domain name: " + this.ip_connect);
SpigotPlugin.logger().printError("Contact CommunityAnalytics on Discord, if you can't solve this problem.");
return false;
}

// pe.zedeztsmp.fun123.246.47.444110de2f1a3c47ab Bedrock Error
this.ip_connect = this.ip_connect.split(ip)[0];
}
return ChronoUnit.SECONDS.between(this.join_at, this.quit_at) >= SpigotPlugin.config().getMinimumsSessionDuration();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

public class PlatformManager {
public boolean success = false;
public String version = "1.0.6";
public String version = "1.0.7";

public void getPlatformInfo() {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.bstats.velocity.Metrics;
import org.slf4j.Logger;

@Plugin(id = "communityanalytics", name = "CommunityAnalytics", version = "1.0.6")
@Plugin(id = "communityanalytics", name = "CommunityAnalytics", version = "1.0.7")
public class VelocityPlugin {
public static VelocityPlugin instance;
private final ChannelIdentifier channel = new LegacyChannelIdentifier(CommunityAnalytics.CHANNEL_INFO);
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/bungee.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CommunityAnalytics
author: FNetwork
main: net.communityanalytics.bungee.BungeePlugin
version: 1.0.6
version: 1.0.7
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: CommunityAnalytics
author: FNetwork
main: net.communityanalytics.spigot.SpigotPlugin
website: https://communityanalytics.net
version: 1.0.6
version: 1.0.7
api-version: 1.13
commands:
communityanalytics:
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/velocity-plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "communityanalytics",
"name": "CommunityAnalytics",
"version": "1.0.6",
"version": "1.0.7",
"authors": [
"FNetwork"
],
Expand Down

0 comments on commit 592064f

Please sign in to comment.