Skip to content

Commit

Permalink
Support older Vivecraft versions too
Browse files Browse the repository at this point in the history
  • Loading branch information
Techjar committed Jun 30, 2020
1 parent 5960818 commit b734fa4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}

version = '1.0'
version = '1.1'

// In this section you declare the dependencies for your production and test code
dependencies {
Expand Down
20 changes: 11 additions & 9 deletions src/main/java/com/techjar/vbe/VBE.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,34 @@
import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.event.EventHandler;

public class VBE extends Plugin implements Listener {
import java.util.Arrays;

public static final String CHANNEL = "vivecraft:data";
public class VBE extends Plugin implements Listener {
public static final String[] CHANNELS = new String[]{"vivecraft:data", "Vivecraft"};

@Override
public void onEnable() {
this.getProxy().registerChannel(CHANNEL);
for (String channel : CHANNELS)
this.getProxy().registerChannel(channel);
}

@Override
public void onDisable() {
this.getProxy().unregisterChannel(CHANNEL);
for (String channel : CHANNELS)
this.getProxy().unregisterChannel(channel);
}

@EventHandler
public void on(PluginMessageEvent event) {
if (!event.getTag().equalsIgnoreCase(CHANNEL))
String channel = event.getTag();
if (Arrays.stream(CHANNELS).noneMatch(channel::equals))
return;
if (event.getReceiver() instanceof ProxiedPlayer) {
ProxiedPlayer player = (ProxiedPlayer)event.getReceiver();
player.sendData(CHANNEL, event.getData());
player.sendData(channel, event.getData());
} else if (event.getReceiver() instanceof Server) {
Server server = (Server)event.getReceiver();
server.sendData(CHANNEL, event.getData());
server.sendData(channel, event.getData());
}
}


}
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Vivecraft_BungeeCord_Extensions
main: com.techjar.vbe.VBE
version: 1.0
version: 1.1
author: Techjar

0 comments on commit b734fa4

Please sign in to comment.