From 15d99fff8c3459b0d1f07c6bb3354de7b4bed8d8 Mon Sep 17 00:00:00 2001 From: Sekwah Date: Tue, 25 Apr 2023 04:56:51 +0100 Subject: [PATCH] feat: allow random destinations split by , --- .../sekwah/advancedportals/bukkit/portals/Portal.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/sekwah/advancedportals/bukkit/portals/Portal.java b/src/main/java/com/sekwah/advancedportals/bukkit/portals/Portal.java index 30081a3..99b8df2 100644 --- a/src/main/java/com/sekwah/advancedportals/bukkit/portals/Portal.java +++ b/src/main/java/com/sekwah/advancedportals/bukkit/portals/Portal.java @@ -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);