renamed modules dir

This commit is contained in:
2022-07-20 13:28:01 +02:00
parent 7dcd92f72d
commit d2ca501203
205 changed files with 12 additions and 12 deletions

1
pandalib-bungee/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/target/

37
pandalib-bungee/pom.xml Normal file
View File

@@ -0,0 +1,37 @@
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>fr.pandacube.lib</groupId>
<artifactId>pandalib-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>pandalib-bungee</artifactId>
<packaging>jar</packaging>
<repositories>
<repository>
<id>bungeecord-repo</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>fr.pandacube.lib</groupId>
<artifactId>pandalib-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<version>${bungeecord.version}</version>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,72 @@
package fr.pandacube.lib.bungee.util;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.connection.Server;
import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.api.plugin.PluginManager;
import net.md_5.bungee.event.EventHandler;
public class PluginMessagePassthrough implements Listener {
private static final List<String> channels = Collections.synchronizedList(new ArrayList<>());
private static final PluginMessagePassthrough instance = new PluginMessagePassthrough();
public static void init(Plugin plugin) {
PluginManager pm = ProxyServer.getInstance().getPluginManager();
pm.unregisterListener(instance);
pm.registerListener(plugin, instance);
}
public static void clear() {
synchronized (channels) {
unregisterAll(channels.toArray(new String[0]));
}
}
public static void registerAll(String... channels) {
for (String channel : channels)
register(channel);
}
public static void unregisterAll(String... channels) {
for (String channel : channels)
unregister(channel);
}
public static void register(String channel) {
synchronized (channels) {
if (channels.contains(channel))
return;
ProxyServer.getInstance().registerChannel(channel);
channels.add(channel);
}
}
public static void unregister(String channel) {
synchronized (channels) {
if (!channels.contains(channel))
return;
ProxyServer.getInstance().unregisterChannel(channel);
channels.remove(channel);
}
}
@EventHandler
public void onPluginMessage(PluginMessageEvent event) {
String channel = event.getTag();
if (!channels.contains(channel))
return;
if (event.getReceiver() instanceof ProxiedPlayer) {
((ProxiedPlayer)event.getReceiver()).sendData(channel, event.getData());
} else if (event.getReceiver() instanceof Server) {
((Server)event.getReceiver()).sendData(channel, event.getData());
}
}
}