feat: allow random destinations split by ,

This commit is contained in:
Sekwah 2023-04-25 04:56:51 +01:00 committed by GitHub
parent 10c009b485
commit 15d99fff8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 3 deletions

View File

@ -515,10 +515,12 @@ public class Portal {
if (portal.getDestiation() != null) {
if(plugin.isProxyPluginEnabled()) {
String[] destinations = portal.getDestiation().split(",");
String destination = destinations[random.nextInt(destinations.length)];
ByteArrayDataOutput outForList = ByteStreams.newDataOutput();
outForList.writeUTF(BungeeMessages.ENTER_PORTAL);
outForList.writeUTF(bungeeServer);
outForList.writeUTF(portal.getDestiation());
outForList.writeUTF(destination);
outForList.writeUTF(player.getUniqueId().toString());
player.sendPluginMessage(plugin, BungeeMessages.CHANNEL_NAME, outForList.toByteArray());
@ -540,9 +542,11 @@ public class Portal {
// Down to bungee to sort out the teleporting but yea theoretically they should
// warp.
} else if (portal.getDestiation() != null) {
String[] destinations = portal.getDestiation().split(",");
String destination = destinations[random.nextInt(destinations.length)];
ConfigAccessor configDesti = new ConfigAccessor(plugin, "destinations.yml");
if (configDesti.getConfig().getString(portal.getDestiation() + ".world") != null) {
warped = Destination.warp(player, portal.getDestiation(), portal, hasMessage, false);
if (configDesti.getConfig().getString(destination + ".world") != null) {
warped = Destination.warp(player, destination, portal, hasMessage, false);
if (!warped) {
if(doKnockback)
throwPlayerBack(player);