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

Added velocity support #641

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions bundle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<!-- Add velocity module -->
<dependency>
<groupId>me.leoko.advancedban</groupId>
<artifactId>AdvancedBan-Velocity</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
</dependencies>

<build>
Expand All @@ -40,10 +47,7 @@
<pattern>org.apache.commons</pattern>
<shadedPattern>${project.groupId}.shaded.org.apache.commons</shadedPattern>
</relocation>
<relocation>
<pattern>org.slf4j</pattern>
<shadedPattern>${project.groupId}.shaded.org.slf4j</shadedPattern>
</relocation>
<!-- Removed org.slf4j relocation making issues with velocity enabling plugin -->
<relocation>
<pattern>com.zaxxer.hikari</pattern>
<shadedPattern>${project.groupId}.shaded.com.zaxxer.hikari</shadedPattern>
Expand Down
2 changes: 1 addition & 1 deletion bungee/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<!-- RedisBungee -->
<repository>
<id>md_5-snapshots</id>
<url>http://repo.md-5.net/content/repositories/snapshots/</url>
<url>https://repo.md-5.net/content/repositories/snapshots/</url>
</repository>
<!-- CloudNet -->
<repository>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ public class DynamicDataSource {
public DynamicDataSource(boolean preferMySQL) throws ClassNotFoundException {
MethodInterface mi = Universal.get().getMethods();
if (preferMySQL) {
String ip = mi.getString(mi.getMySQLFile(), "MySQL.IP", "Unknown");
String dbName = mi.getString(mi.getMySQLFile(), "MySQL.DB-Name", "Unknown");
String usrName = mi.getString(mi.getMySQLFile(), "MySQL.Username", "Unknown");
String password = mi.getString(mi.getMySQLFile(), "MySQL.Password", "Unknown");
String properties = mi.getString(mi.getMySQLFile(), "MySQL.Properties", "verifyServerCertificate=false&useSSL=false&useUnicode=true&characterEncoding=utf8");
int port = mi.getInteger(mi.getMySQLFile(), "MySQL.Port", 3306);
String ip = mi.getString(mi.getConfig(), "MySQL.IP", "Unknown");
String dbName = mi.getString(mi.getConfig(), "MySQL.DB-Name", "Unknown");
String usrName = mi.getString(mi.getConfig(), "MySQL.Username", "Unknown");
String password = mi.getString(mi.getConfig(), "MySQL.Password", "Unknown");
String properties = mi.getString(mi.getConfig(), "MySQL.Properties", "verifyServerCertificate=false&useSSL=false&useUnicode=true&characterEncoding=utf8");
int port = mi.getInteger(mi.getConfig(), "MySQL.Port", 3306);

Class.forName("com.mysql.jdbc.Driver");
config.setJdbcUrl("jdbc:mysql://" + ip + ":" + port + "/" + dbName + "?"+properties);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,15 @@ public void create(boolean silent) {
if (mi.isOnline(getName())) {
final Object p = mi.getPlayer(getName());

PunishmentManager.get().getLoadedPunishments(false).add(this);

if (getType().getBasic() == PunishmentType.BAN || getType() == PunishmentType.KICK) {
mi.runSync(() -> mi.kickPlayer(getName(), getLayoutBSN()));
} else {
if (getType().getBasic() != PunishmentType.NOTE)
for (String str : getLayout()) {
mi.sendMessage(p, str);
}
PunishmentManager.get().getLoadedPunishments(false).add(this);
}
}

Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<module>bukkit</module>
<module>bungee</module>
<module>bundle</module>
<module>velocity</module>
</modules>

<properties>
Expand Down
74 changes: 74 additions & 0 deletions velocity/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>me.leoko.advancedban</groupId>
<artifactId>AdvancedBan</artifactId>
<version>2.3.0</version>
</parent>

<artifactId>AdvancedBan-Velocity</artifactId>
<packaging>jar</packaging>

<properties>
<java.version>11</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<repositories>
<repository>
<id>papermc-repo</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>com.velocitypowered</groupId>
<artifactId>velocity-api</artifactId>
<version>3.3.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.leoko.advancedban</groupId>
<artifactId>AdvancedBan-Core</artifactId>
<version>2.3.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.Carleslc.Simple-YAML</groupId>
<artifactId>Simple-Yaml</artifactId>
<version>1.8.4</version>
</dependency>
<dependency>
<groupId>net.luckperms</groupId>
<artifactId>api</artifactId>
<version>5.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<!-- Should be the same version as HikariCP uses -->
<version>1.7.30</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.26</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package me.leoko.advancedban.velocity;

import com.google.inject.Inject;
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.plugin.Dependency;
import com.velocitypowered.api.plugin.Plugin;
import com.velocitypowered.api.plugin.annotation.DataDirectory;
import com.velocitypowered.api.proxy.ProxyServer;
import me.leoko.advancedban.Universal;
import me.leoko.advancedban.velocity.listener.ChatListenerVelocity;
import me.leoko.advancedban.velocity.listener.ConnectionListenerVelocity;
import org.slf4j.Logger;

import java.nio.file.Path;

@Plugin(
id = "advancedban",
name = "AdvancedBan",
version = "1.0-SNAPSHOT",
authors = {"Leoko"},
dependencies = {
@Dependency(id = "luckperms", optional = true)
}
)
public class VelocityMain {

@Inject
private final Logger logger;
private final Path dataDirectory;
private final ProxyServer server;
private static VelocityMain instance;


@Inject
public VelocityMain(ProxyServer server, @DataDirectory Path dataDirectory, Logger logger){
this.server = server;
this.dataDirectory = dataDirectory;
this.logger = logger;
instance = this;
}


@Subscribe
public void onProxyInitialization(ProxyInitializeEvent event) {

server.getEventManager().register(this, new ConnectionListenerVelocity());
server.getEventManager().register(this, new ChatListenerVelocity());

Universal.get().setup(new VelocityMethods(server, dataDirectory, logger));

}

public static VelocityMain get() {
return instance;
}
}
Loading