Skip to content

Commit

Permalink
Merge pull request #17 from v4Guard/develop
Browse files Browse the repository at this point in the history
v4Guard Plugin v1.1.3c
  • Loading branch information
samfces authored Oct 28, 2022
2 parents 2b7b7e3 + 9de86e2 commit 99065f6
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 17 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.v4guard</groupId>
<artifactId>v4guard-plugin</artifactId>
<version>1.1.3b</version>
<version>1.1.3c</version>
<packaging>jar</packaging>

<properties>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
package io.v4guard.plugin.bungee.accounts;

import io.v4guard.plugin.core.accounts.auth.AuthType;
import io.v4guard.plugin.core.accounts.auth.Authentication;
import io.v4guard.plugin.core.accounts.messaging.MessageReceiver;
import io.v4guard.plugin.core.v4GuardCore;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.api.event.PostLoginEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.event.EventHandler;
import org.bson.Document;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;

public class BungeeMessageReceiver extends MessageReceiver implements Listener {

Expand All @@ -33,8 +35,17 @@ public void onMessage(PluginMessageEvent e){
Document doc = Document.parse(data);
Authentication auth = Authentication.deserialize(doc);
v4GuardCore.getInstance().getAccountShieldManager().sendSocketMessage(auth);
} catch (IOException ex) {
throw new RuntimeException(ex);
} catch (Exception ex) {}
}

@EventHandler(priority = Byte.MAX_VALUE)
public void onPostLogin(PostLoginEvent e) {
if(!v4GuardCore.getInstance().isAccountShieldFound()) {
ProxiedPlayer player = e.getPlayer();
if (player.getPendingConnection().isOnlineMode()) {
Authentication auth = new Authentication(player.getName(), AuthType.MOJANG);
v4GuardCore.getInstance().getAccountShieldManager().sendSocketMessage(auth);
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/io/v4guard/plugin/bungee/v4GuardBungee.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public void onEnable(){
new TextComponent("§e[v4guard-plugin] (Bungee) Enabling... [DONE]")
);
this.messager = new Messager();
getCoreInstance().setAccountShieldFound(
this.getProxy().getPluginManager().getPlugin("v4guard-account-shield") != null
);
}

public Messager getMessager() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,8 @@ public void sendSocketMessage(Authentication auth){
boolean shieldEnabled = (boolean) shieldSettings.getOrDefault("accshield", false);
if(!shieldEnabled) return;

String location = v4GuardCore.getInstance().getCheckManager().getProcessors().get(0).getPlayerServer(auth.getUsername());
if(location != null){
location = "not-connected";
}
Document finalDocument = new Document("username", auth.getUsername())
.append("type", auth.getAuthType().toString())
.append("location", location);
.append("type", auth.getAuthType().toString());
v4GuardCore.getInstance().getBackendConnector().getSocket().emit("accshield:login", finalDocument.toJson());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

public enum AuthType {

LOGIN, REGISTER, UNKNOWN;
LOGIN, REGISTER, MOJANG, UNKNOWN;

}
11 changes: 10 additions & 1 deletion src/main/java/io/v4guard/plugin/core/v4GuardCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ public class v4GuardCore {
private CheckManager checkManager;
private AccountShieldManager accountShieldManager;

public static final String pluginVersion = "1.1.3b";
public static final String pluginVersion = "1.1.3c";

private boolean debug = false;
private boolean accountShieldFound = false;
private v4GuardMode pluginMode;
private Logger logger;

Expand Down Expand Up @@ -53,6 +54,14 @@ public v4GuardCore(v4GuardMode mode) throws IOException, URISyntaxException {

}

public boolean isAccountShieldFound() {
return accountShieldFound;
}

public void setAccountShieldFound(boolean accountShieldFound) {
this.accountShieldFound = accountShieldFound;
}

public Logger getLogger() {
return logger;
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/io/v4guard/plugin/spigot/v4GuardSpigot.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public void onEnable(){
this.getServer().getPluginManager().registerEvents(new AntiVPNListener(), this);
this.getServer().getConsoleSender().sendMessage("§e[v4guard-plugin] (Spigot) Enabling... [DONE]");
this.messager = new Messager();

getCoreInstance().setAccountShieldFound(this.getServer().getPluginManager().isPluginEnabled("v4guard-account-shield"));
}

public Messager getMessager() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
import com.velocitypowered.api.event.PostOrder;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.connection.PluginMessageEvent;
import com.velocitypowered.api.event.connection.PostLoginEvent;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier;
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
import io.v4guard.plugin.core.accounts.auth.AuthType;
import io.v4guard.plugin.core.accounts.auth.Authentication;
import io.v4guard.plugin.core.accounts.messaging.MessageReceiver;
import io.v4guard.plugin.core.v4GuardCore;
import io.v4guard.plugin.velocity.v4GuardVelocity;
import net.md_5.bungee.api.plugin.Listener;
import org.bson.Document;
import org.bukkit.event.Listener;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
Expand All @@ -35,8 +38,17 @@ public void onMessage(PluginMessageEvent e){
Document doc = Document.parse(data);
Authentication auth = Authentication.deserialize(doc);
v4GuardCore.getInstance().getAccountShieldManager().sendSocketMessage(auth);
} catch (IOException ex) {
throw new RuntimeException(ex);
} catch (IOException ex) {}
}

@Subscribe(order = PostOrder.LAST)
public void onPostLogin(PostLoginEvent e) {
if(!v4GuardCore.getInstance().isAccountShieldFound()) {
Player player = e.getPlayer();
if (player.isOnlineMode()) {
Authentication auth = new Authentication(player.getUsername(), AuthType.MOJANG);
v4GuardCore.getInstance().getAccountShieldManager().sendSocketMessage(auth);
}
}
}

Expand Down
16 changes: 14 additions & 2 deletions src/main/java/io/v4guard/plugin/velocity/v4GuardVelocity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.google.inject.Inject;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
import com.velocitypowered.api.plugin.Dependency;
import com.velocitypowered.api.plugin.Plugin;
import com.velocitypowered.api.proxy.ProxyServer;
import io.v4guard.plugin.core.accounts.AccountShieldManager;
Expand All @@ -16,8 +17,18 @@

import java.util.logging.Logger;

@Plugin(id = "v4guard-plugin", name = "v4Guard Plugin", version = v4GuardCore.pluginVersion,
url = "https://v4guard.io", description = "v4Guard Plugin for Minecraft Servers", authors = {"DigitalSynware"})
@Plugin(
id = "v4guard-plugin",
name = "v4Guard Plugin",
version = v4GuardCore.pluginVersion,
url = "https://v4guard.io",
description = "v4Guard Plugin for Minecraft Servers",
authors = {"DigitalSynware"},
dependencies = {
@Dependency(id = "v4guard-account-shield", optional = true)
}

)
public class v4GuardVelocity {

private static v4GuardCore core;
Expand Down Expand Up @@ -58,6 +69,7 @@ public void onProxyInitialization(ProxyInitializeEvent event) {
server.getEventManager().register(this, new AntiVPNListener());
server.getConsoleCommandSource().sendMessage(Component.text("§e[v4guard-plugin] (Velocity) Enabling... [DONE]"));
this.messager = new Messager();
getCoreInstance().setAccountShieldFound(this.getServer().getPluginManager().isLoaded("v4guard-account-shield"));
}

public ProxyServer getServer() {
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/bungee.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ name: v4guard-plugin
version: ${project.version}
main: io.v4guard.plugin.bungee.v4GuardBungee
author: DigitalSynware
softDepends:
- v4guard-account-shield
2 changes: 2 additions & 0 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ name: v4guard-plugin
version: ${project.version}
main: io.v4guard.plugin.spigot.v4GuardSpigot
author: DigitalSynware
softdepend:
- v4guard-account-shield

0 comments on commit 99065f6

Please sign in to comment.