Skip to content

Commit

Permalink
Merge pull request #147 from beanbeanjuice/development
Browse files Browse the repository at this point in the history
Integration v0.3.8
  • Loading branch information
beanbeanjuice committed May 21, 2024
2 parents 8056123 + 6746261 commit 17c2e47
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 33 deletions.
46 changes: 23 additions & 23 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ plugins {
}

group = "com.beanbeanjuice"
version = "0.3.7"
version = "0.3.8"

java {
sourceCompatibility = JavaVersion.VERSION_17
Expand Down Expand Up @@ -53,54 +53,54 @@ repositories {

dependencies {
// Velocity
compileOnly("com.velocitypowered:velocity-api:3.3.0-SNAPSHOT")
annotationProcessor("com.velocitypowered:velocity-api:3.3.0-SNAPSHOT")
compileOnly("com.velocitypowered", "velocity-api", "3.3.0-SNAPSHOT")
annotationProcessor("com.velocitypowered", "velocity-api", "3.3.0-SNAPSHOT")

// Bungee
compileOnly("net.md-5:bungeecord-api:1.20-R0.1-SNAPSHOT")
implementation("net.kyori:adventure-api:4.16.0") // Convert Velocity -> Bungee
implementation("net.kyori:adventure-text-minimessage:4.16.0") // Convert Velocity -> Bungee
implementation("net.kyori:adventure-text-serializer-plain:4.16.0") // Convert Velocity -> Bungee
implementation("net.kyori:adventure-text-serializer-legacy:4.16.0") // Convert Velocity -> Bungee
implementation("net.kyori:adventure-text-serializer-gson:4.16.0") // Convert Velocity -> Bungee
implementation("net.kyori:adventure-text-serializer-bungeecord:4.3.2") // Convert Velocity -> Bungee
compileOnly("net.md-5", "bungeecord-api", "1.20-R0.2")
implementation("net.kyori", "adventure-api", "4.17.0") // Convert Velocity -> Bungee
implementation("net.kyori", "adventure-text-minimessage", "4.17.0") // Convert Velocity -> Bungee
implementation("net.kyori", "adventure-text-serializer-plain", "4.17.0") // Convert Velocity -> Bungee
implementation("net.kyori", "adventure-text-serializer-legacy", "4.17.0") // Convert Velocity -> Bungee
implementation("net.kyori", "adventure-text-serializer-gson", "4.17.0") // Convert Velocity -> Bungee
implementation("net.kyori", "adventure-text-serializer-bungeecord", "4.3.2") // Convert Velocity -> Bungee

// Discord Support
implementation("net.dv8tion:JDA:5.0.0-beta.20") {
implementation("net.dv8tion", "JDA", "5.0.0-beta.20") {
exclude(module = "opus-java")
}

// PremiumVanish/SuperVanish Support
compileOnly("com.github.LeonMangler:PremiumVanishAPI:2.9.0-4")
compileOnly("com.github.LeonMangler", "PremiumVanishAPI", "2.9.0-4")

// Better YAML Support
implementation("dev.dejvokep:boosted-yaml:1.3.1")
implementation("dev.dejvokep", "boosted-yaml", "1.3.5")

// bStats
implementation("org.bstats:bstats-velocity:3.0.2")
implementation("org.bstats:bstats-bungeecord:3.0.2")
implementation("org.bstats", "bstats-velocity", "3.0.2")
implementation("org.bstats", "bstats-bungeecord", "3.0.2")

// Lombok
compileOnly("org.projectlombok:lombok:1.18.30")
annotationProcessor("org.projectlombok:lombok:1.18.30")
compileOnly("org.projectlombok", "lombok", "1.18.32")
annotationProcessor("org.projectlombok", "lombok", "1.18.32")

// LuckPerms Support
compileOnly("net.luckperms:api:5.4")
compileOnly("net.luckperms", "api", "5.4")

// LiteBans Support
compileOnly("com.gitlab.ruany:LiteBansAPI:0.5.0")
compileOnly("com.gitlab.ruany", "LiteBansAPI", "0.5.0")

// AdvancedBan Support
compileOnly("com.github.DevLeoko:AdvancedBan:v2.3.0")
compileOnly("com.github.DevLeoko", "AdvancedBan", "v2.3.0")

// NetworkManager Support
compileOnly("nl.chimpgamer.networkmanager:api:2.14.10")
compileOnly("nl.chimpgamer.networkmanager", "api", "2.14.10")

// Spicord Support
compileOnly("org.spicord:spicord-common:5.4.0")
compileOnly("org.spicord", "spicord-common", "5.4.0")

// Timestamp
implementation("joda-time:joda-time:2.12.7")
implementation("joda-time", "joda-time", "2.12.7")
}

configure<ProcessResources>("processResources") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void onEnable() {

epochHelper = new EpochHelper(config);

this.getLogger().info("Initializing discord bot.");
this.getLogger().info("Attempting to initialize Discord bot... (if enabled)");
discordBot = new Bot(this.config);

this.getProxy().getScheduler().runAsync(this, () -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public SimpleProxyChatVelocity(ProxyServer proxyServer, Logger logger, @DataDire
@Subscribe(order = PostOrder.LAST)
public void onProxyInitialization(ProxyInitializeEvent event) {
// Initialize discord bot.
this.getLogger().info("Initializing discord bot.");
this.getLogger().info("Attempting to initialize Discord bot... (if enabled)");
discordBot = new Bot(this.config);

// Bot ready.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public ChatHandler(Config config, EpochHelper epochHelper, Bot discordBot,

this.globalLogger = globalLogger;
this.pluginLogger = pluginLogger;
discordBot.getJDA().ifPresent((jda) -> jda.addEventListener(new DiscordChatHandler(config, this::sendFromDiscord)));
discordBot.addRunnableToQueue(() -> discordBot.getJDA().ifPresent((jda) -> jda.addEventListener(new DiscordChatHandler(config, this::sendFromDiscord))));
}

private Optional<String> getValidMessage(String message) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,11 @@ public void addRunnableToQueue(Runnable runnable) {
}

public void start() throws InterruptedException {
String token = config.getAsString(ConfigDataKey.BOT_TOKEN);
if (token.isEmpty() || token.equalsIgnoreCase("TOKEN_HERE") || token.equalsIgnoreCase("null")) return;

bot = JDABuilder
.createLight(config.getAsString(ConfigDataKey.BOT_TOKEN))
.createLight(token)
.setActivity(Activity.watching("Starting Proxy..."))
.enableCache(CacheFlag.ROLE_TAGS)
.setMemberCachePolicy(MemberCachePolicy.ALL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import net.md_5.bungee.api.config.ServerInfo;

import java.util.HashMap;
import java.util.Optional;

public class BungeePreviousServerHandler {

Expand All @@ -13,8 +14,8 @@ public void put(final String playerName, final ServerInfo serverInfo) {
previousServers.put(playerName, serverInfo);
}

public ServerInfo get(final String playerName) {
return previousServers.get(playerName);
public Optional<ServerInfo> get(final String playerName) {
return Optional.ofNullable(previousServers.get(playerName));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void onProxyChatEvent(ChatEvent event) {
if (event.isCommand() || event.isProxyCommand()) return;

ProxiedPlayer player = (ProxiedPlayer) event.getSender();
if (BungeeVanishAPI.isInvisible(player)) return;
if (plugin.getConfig().getAsBoolean(ConfigDataKey.VANISH_ENABLED) && BungeeVanishAPI.isInvisible(player)) return;
if (!Helper.playerCanChat(plugin.getConfig(), player.getUniqueId(), player.getName())) return;

Server currentServer = (Server) event.getReceiver();
Expand Down Expand Up @@ -103,8 +103,10 @@ void leave(ProxiedPlayer player, boolean isFake) {
plugin.getProxy().getScheduler().schedule(
plugin,
() -> {
if (isFake) chatHandler.runProxyLeaveMessage(player.getName(), player.getUniqueId(), previousServerHandler.get(player.getName()).getName(), this::sendToAllServersVanish);
else chatHandler.runProxyLeaveMessage(player.getName(), player.getUniqueId(), previousServerHandler.get(player.getName()).getName(), this::sendToAllServers);
previousServerHandler.get(player.getName()).ifPresent((serverInfo) -> {
if (isFake) chatHandler.runProxyLeaveMessage(player.getName(), player.getUniqueId(), serverInfo.getName(), this::sendToAllServersVanish);
else chatHandler.runProxyLeaveMessage(player.getName(), player.getUniqueId(), serverInfo.getName(), this::sendToAllServers);
});
},
50L, TimeUnit.MILLISECONDS); // 50ms is 1 tick
} catch (Exception e) {
Expand All @@ -128,6 +130,8 @@ public void join(ProxiedPlayer player, Server server, boolean isFake) {
plugin.getProxy().getScheduler().schedule(
plugin,
() -> {
previousServerHandler.put(player.getName(), server.getInfo());

if (isFake) chatHandler.runProxyJoinMessage(player.getName(), player.getUniqueId(), server.getInfo().getName(), this::sendToAllServersVanish);
else chatHandler.runProxyJoinMessage(player.getName(), player.getUniqueId(), server.getInfo().getName(), this::sendToAllServers);
},
Expand All @@ -145,6 +149,7 @@ public void onPlayerServerSwitch(ServerSwitchEvent event) {
if (event.getFrom() == null) return; // This means the player just joined the network.

ServerInfo from = event.getFrom();
previousServerHandler.put(player.getName(), event.getPlayer().getServer().getInfo());

chatHandler.runProxySwitchMessage(
event.getFrom().getName(),
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/bungee.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: SimpleProxyChat
version: '${version}'
main: com.beanbeanjuice.simpleproxychat.SimpleProxyChatBungee
softdepend: [PlaceholderAPI, PremiumVanish, LuckPerms, LiteBans, NetworkManager]
softdepend: [PlaceholderAPI, PremiumVanish, LuckPerms, LiteBans, AdvancedBan, NetworkManager]
author: beanbeanjuice
description: A simple plugin to send chat messages between servers as well as to Discord.
4 changes: 4 additions & 0 deletions src/main/resources/velocity-plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
"id": "litebans",
"optional": true
},
{
"id": "advancedban",
"optional": true
},
{
"id": "networkmanager",
"optional": true
Expand Down

0 comments on commit 17c2e47

Please sign in to comment.