Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sidestream #1

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ default Component getMcLeaksKickMessage(@NotNull String playerName, @NotNull UUI
*
* @throws NullPointerException if playerName, playerUuid, or ip is null
*/
@Nullable
@NotNull
Component getMcLeaksKickMessage(@NotNull String playerName, @NotNull UUID playerUuid, @NotNull String ip);

/**
Expand Down
24 changes: 11 additions & 13 deletions Bungee/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,10 @@
<id>papermc-snpashots</id>
<url>https://papermc.io/repo/repository/maven-snapshots/</url>
</repository>
<!--<repository>
<repository>
<id>bungeecord-repo</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>-->

</repository>
<repository>
<id>egg82-nexus</id>
<url>https://nexus.egg82.me/repository/maven-releases/</url>
Expand All @@ -245,14 +244,14 @@
<url>https://repo.aikar.co/content/groups/aikar/</url>
</repository>

<repository> <!-- for development builds -->
<id>sonatype-oss-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>
<repository>
<id>github-rjenkinsjr</id>
<url>https://raw.github.com/rjenkinsjr/maven2/repo</url>
</repository>
<repository>
<id>plan</id>
<url>https://dl.bintray.com/rsl1122/Plan-repository</url>
</repository>
<repository>
<id>CodeMC</id>
<url>https://repo.codemc.org/repository/maven-public</url>
Expand Down Expand Up @@ -289,9 +288,9 @@
<version>${cloud.version}</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<groupId>me.lucko</groupId>
<artifactId>adventure-platform-bungeecord</artifactId>
<version>${adventure.version}</version>
<version>${adventure.bungeecord.version}</version>
</dependency>
<dependency>
<groupId>ninja.egg82</groupId>
Expand Down Expand Up @@ -322,10 +321,9 @@
<version>${bstats.version}</version>
</dependency>
<dependency>
<groupId>com.djrapitops</groupId>
<artifactId>Plan-api</artifactId>
<groupId>com.github.plan-player-analytics</groupId>
<artifactId>Plan</artifactId>
<version>${plan.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.luckperms</groupId>
Expand All @@ -347,7 +345,7 @@
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-minimessage</artifactId>
<version>${adventure.version}</version>
<version>${minimessage.version}</version>
</dependency>
<dependency>
<groupId>net.oneandone.reflections8</groupId>
Expand Down
5 changes: 2 additions & 3 deletions Bungee/src/main/java/me/egg82/antivpn/AntiVPN.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import me.egg82.antivpn.messaging.handler.MessagingHandlerImpl;
import me.egg82.antivpn.services.GameAnalyticsErrorHandler;
import me.egg82.antivpn.storage.StorageService;
import me.egg82.antivpn.utils.ExceptionUtil;
import me.egg82.antivpn.utils.ValidationUtil;
import net.engio.mbassy.bus.MBassador;
import net.md_5.bungee.api.ChatColor;
Expand Down Expand Up @@ -159,7 +158,7 @@ public void onDisable() {
try {
VPNAPIProvider.getInstance().runUpdateTask().join();
} catch (CancellationException | CompletionException ex) {
ExceptionUtil.handleException(ex, logger);
logger.error(ex.getClass().getName() + ": " + ex.getMessage(), ex);
}

for (EventHolder eventHolder : eventHolders) {
Expand Down Expand Up @@ -356,7 +355,7 @@ private void loadTasks() {
try {
VPNAPIProvider.getInstance().runUpdateTask().join();
} catch (CancellationException | CompletionException ex) {
ExceptionUtil.handleException(ex, logger);
logger.error(ex.getClass().getName() + ": " + ex.getMessage(), ex);
}
}, 1L, 1L, TimeUnit.SECONDS).getId());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;
import java.util.UUID;
Expand Down Expand Up @@ -90,7 +89,7 @@ public boolean kickForMcLeaks(@NotNull String playerName, @NotNull UUID playerUu
}

@Override
public @Nullable String getMcLeaksKickMessage(@NotNull String playerName, @NotNull UUID playerUuid, @NotNull String ip) {
public @NotNull String getMcLeaksKickMessage(@NotNull String playerName, @NotNull UUID playerUuid, @NotNull String ip) {
CachedConfig cachedConfig = ConfigUtil.getCachedConfig();

if (!cachedConfig.getMCLeaksKickMessage().isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import me.egg82.antivpn.api.model.ip.IPManager;
import me.egg82.antivpn.api.model.player.PlayerManager;
import me.egg82.antivpn.locale.MessageKey;
import me.egg82.antivpn.utils.ExceptionUtil;
import me.egg82.antivpn.utils.ValidationUtil;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -35,7 +34,7 @@ private void checkIp(@NotNull String ip) {
if (ipManager.getCurrentAlgorithmMethod() == AlgorithmMethod.CONSESNSUS) {
ipManager.consensus(ip, true).whenCompleteAsync((val, ex) -> {
if (ex != null) {
ExceptionUtil.handleException(ex, logger);
logger.error(ex.getClass().getName() + ": " + ex.getMessage(), ex);
issuer.sendError(MessageKey.ERROR__INTERNAL);
return;
}
Expand All @@ -44,7 +43,7 @@ private void checkIp(@NotNull String ip) {
} else {
ipManager.cascade(ip, true).whenCompleteAsync((val, ex) -> {
if (ex != null) {
ExceptionUtil.handleException(ex, logger);
logger.error(ex.getClass().getName() + ": " + ex.getMessage(), ex);
issuer.sendError(MessageKey.ERROR__INTERNAL);
return;
}
Expand All @@ -60,7 +59,7 @@ private void checkPlayer(@NotNull String playerName) {
.thenComposeAsync(uuid -> playerManager.checkMcLeaks(uuid, true))
.whenCompleteAsync((val, ex) -> {
if (ex != null) {
ExceptionUtil.handleException(ex, logger);
logger.error(ex.getClass().getName() + ": " + ex.getMessage(), ex);
issuer.sendError(MessageKey.ERROR__INTERNAL);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import me.egg82.antivpn.config.ConfigUtil;
import me.egg82.antivpn.locale.MessageKey;
import me.egg82.antivpn.utils.DNSUtil;
import me.egg82.antivpn.utils.ExceptionUtil;
import org.jetbrains.annotations.NotNull;

import java.text.DecimalFormat;
Expand Down Expand Up @@ -103,7 +102,7 @@ private void test(@NotNull Source<? extends SourceModel> source, @NotNull String
error += 1;
continue;
} catch (ExecutionException | CancellationException ex) {
ExceptionUtil.handleException(ex, logger);
logger.error(ex.getClass().getName() + ": " + ex.getMessage(), ex);
if (!(ex.getCause() instanceof APIException) || !((APIException) ex.getCause()).isHard()) {
error += 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import me.egg82.antivpn.config.CachedConfig;
import me.egg82.antivpn.config.ConfigUtil;
import me.egg82.antivpn.locale.MessageKey;
import me.egg82.antivpn.utils.ExceptionUtil;
import org.jetbrains.annotations.NotNull;

import java.util.*;
Expand Down Expand Up @@ -43,7 +42,7 @@ public void run() {

futures.add(source.getResult(ip).whenCompleteAsync((val, ex) -> {
if (ex != null) {
ExceptionUtil.handleException(ex, logger);
logger.error(ex.getClass().getName() + ": " + ex.getMessage(), ex);
latch.countDown();
return;
}
Expand Down
17 changes: 8 additions & 9 deletions Bungee/src/main/java/me/egg82/antivpn/events/PlayerEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import me.egg82.antivpn.hooks.LuckPermsHook;
import me.egg82.antivpn.services.lookup.PlayerInfo;
import me.egg82.antivpn.services.lookup.PlayerLookup;
import me.egg82.antivpn.utils.ExceptionUtil;
import me.egg82.antivpn.utils.ValidationUtil;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.chat.TextComponent;
Expand Down Expand Up @@ -88,7 +87,7 @@ private void checkPerms(@NotNull PreLoginEvent event) {
Thread.currentThread().interrupt();
uuid = null;
} catch (ExecutionException | CancellationException ex) {
ExceptionUtil.handleException(ex, logger);
logger.error(ex.getClass().getName() + ": " + ex.getMessage(), ex);
uuid = null;
}

Expand All @@ -102,7 +101,7 @@ private void checkPerms(@NotNull PreLoginEvent event) {
Thread.currentThread().interrupt();
val = null;
} catch (ExecutionException | CancellationException ex) {
ExceptionUtil.handleException(ex, logger);
logger.error(ex.getClass().getName() + ": " + ex.getMessage(), ex);
val = null;
}
checkPermsPlayer(event, uuid, Boolean.TRUE.equals(val));
Expand Down Expand Up @@ -213,15 +212,15 @@ private void cacheData(@NotNull String ip, @NotNull UUID uuid, @NotNull CachedCo
} catch (InterruptedException ignored) {
Thread.currentThread().interrupt();
} catch (ExecutionException | CancellationException ex) {
ExceptionUtil.handleException(ex, logger);
logger.error(ex.getClass().getName() + ": " + ex.getMessage(), ex);
}
} else {
try {
ipManager.cascade(ip, true).get(); // Calling this will cache the result internally, even if the value is unused
} catch (InterruptedException ignored) {
Thread.currentThread().interrupt();
} catch (ExecutionException | CancellationException ex) {
ExceptionUtil.handleException(ex, logger);
logger.error(ex.getClass().getName() + ": " + ex.getMessage(), ex);
}
}
}
Expand All @@ -234,7 +233,7 @@ private void cacheData(@NotNull String ip, @NotNull UUID uuid, @NotNull CachedCo
} catch (InterruptedException ignored) {
Thread.currentThread().interrupt();
} catch (ExecutionException | CancellationException ex) {
ExceptionUtil.handleException(ex, logger);
logger.error(ex.getClass().getName() + ": " + ex.getMessage(), ex);
}
}
}
Expand Down Expand Up @@ -321,7 +320,7 @@ private boolean isVpn(@NotNull String ip, @NotNull String name, @NotNull CachedC
Thread.currentThread().interrupt();
isVPN = false;
} catch (ExecutionException | CancellationException ex) {
ExceptionUtil.handleException(ex, logger);
logger.error(ex.getClass().getName() + ": " + ex.getMessage(), ex);
isVPN = false;
}
} else {
Expand All @@ -331,7 +330,7 @@ private boolean isVpn(@NotNull String ip, @NotNull String name, @NotNull CachedC
Thread.currentThread().interrupt();
isVPN = false;
} catch (ExecutionException | CancellationException ex) {
ExceptionUtil.handleException(ex, logger);
logger.error(ex.getClass().getName() + ": " + ex.getMessage(), ex);
isVPN = false;
}
}
Expand Down Expand Up @@ -366,7 +365,7 @@ private boolean isMcLeaks(@NotNull String name, @NotNull UUID uuid, @NotNull Cac
Thread.currentThread().interrupt();
isMCLeaks = false;
} catch (ExecutionException | CancellationException ex) {
ExceptionUtil.handleException(ex, logger);
logger.error(ex.getClass().getName() + ": " + ex.getMessage(), ex);
isMCLeaks = false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import me.egg82.antivpn.api.model.ip.IPManager;
import me.egg82.antivpn.api.model.player.PlayerManager;
import me.egg82.antivpn.config.ConfigUtil;
import me.egg82.antivpn.utils.ExceptionUtil;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -109,7 +108,7 @@ public long getVpns() {
} catch (InterruptedException ignored) {
Thread.currentThread().interrupt();
} catch (ExecutionException | CancellationException ex) {
ExceptionUtil.handleException(ex, logger);
logger.error(ex.getClass().getName() + ": " + ex.getMessage(), ex);
}
} else {
try {
Expand All @@ -119,7 +118,7 @@ public long getVpns() {
} catch (InterruptedException ignored) {
Thread.currentThread().interrupt();
} catch (ExecutionException | CancellationException ex) {
ExceptionUtil.handleException(ex, logger);
logger.error(ex.getClass().getName() + ": " + ex.getMessage(), ex);
}
}
latch.countDown();
Expand Down Expand Up @@ -169,7 +168,7 @@ public long getMcLeaks() {
} catch (InterruptedException ignored) {
Thread.currentThread().interrupt();
} catch (ExecutionException | CancellationException ex) {
ExceptionUtil.handleException(ex, logger);
logger.error(ex.getClass().getName() + ": " + ex.getMessage(), ex);
}
latch.countDown();
});
Expand Down Expand Up @@ -219,15 +218,15 @@ public boolean getUsingVpn(@NotNull UUID playerID) {
} catch (InterruptedException ignored) {
Thread.currentThread().interrupt();
} catch (ExecutionException | CancellationException ex) {
ExceptionUtil.handleException(ex, logger);
logger.error(ex.getClass().getName() + ": " + ex.getMessage(), ex);
}
} else {
try {
return Boolean.TRUE.equals(ipManager.cascade(ip, true).get());
} catch (InterruptedException ignored) {
Thread.currentThread().interrupt();
} catch (ExecutionException | CancellationException ex) {
ExceptionUtil.handleException(ex, logger);
logger.error(ex.getClass().getName() + ": " + ex.getMessage(), ex);
}
}

Expand All @@ -249,7 +248,7 @@ public boolean getMcLeaks(@NotNull UUID playerId) {
} catch (InterruptedException ignored) {
Thread.currentThread().interrupt();
} catch (ExecutionException | CancellationException ex) {
ExceptionUtil.handleException(ex, logger);
logger.error(ex.getClass().getName() + ": " + ex.getMessage(), ex);
}

return false;
Expand Down
10 changes: 10 additions & 0 deletions Common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@
<id>sponge</id>
<url>https://repo.spongepowered.org/repository/maven-public/</url>
</repository>
<repository>
<id>wesjd-repo</id>
<url>https://nexus.wesjd.net/repository/thirdparty/</url>
</repository>
</repositories>

<dependencies>
Expand Down Expand Up @@ -205,6 +209,12 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>me.gong</groupId>
<artifactId>mcleaks-api</artifactId>
<version>1.9.5-SNAPSHOT</version>
</dependency>

<!-- API -->
<dependency>
<groupId>org.jetbrains</groupId>
Expand Down
8 changes: 4 additions & 4 deletions Common/src/main/java/me/egg82/antivpn/api/VPNAPIImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import me.egg82.antivpn.api.model.player.AbstractPlayerManager;
import me.egg82.antivpn.api.model.source.SourceManagerImpl;
import me.egg82.antivpn.api.platform.Platform;
import me.egg82.antivpn.api.platform.PluginMetadata;
import me.egg82.antivpn.config.ConfigUtil;
import me.egg82.antivpn.utils.PacketUtil;
import me.egg82.antivpn.api.platform.AbstractPluginMetadata;
import net.kyori.event.EventBus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand All @@ -17,7 +17,7 @@

public class VPNAPIImpl implements VPNAPI {
private final @NotNull Platform platform;
private final @NotNull AbstractPluginMetadata pluginMetadata;
private final @NotNull PluginMetadata pluginMetadata;

private final @NotNull AbstractIPManager ipManager;
private final @NotNull AbstractPlayerManager playerManager;
Expand All @@ -30,7 +30,7 @@ public class VPNAPIImpl implements VPNAPI {

public VPNAPIImpl(
@NotNull Platform platform,
@NotNull AbstractPluginMetadata pluginMetadata,
@NotNull PluginMetadata pluginMetadata,
@NotNull AbstractIPManager ipManager,
@NotNull AbstractPlayerManager playerManager,
@NotNull SourceManagerImpl sourceManager,
Expand Down Expand Up @@ -69,7 +69,7 @@ public VPNAPIImpl(

@Override
@NotNull
public AbstractPluginMetadata getPluginMetadata() { return pluginMetadata; }
public PluginMetadata getPluginMetadata() { return pluginMetadata; }

@Override
@NotNull
Expand Down
Loading