diff --git a/build.gradle b/build.gradle index 93d61cc4..57d66087 100644 --- a/build.gradle +++ b/build.gradle @@ -34,13 +34,16 @@ configurations { } repositories { - maven { url "http://repo.maven.apache.org/maven2" } + maven { url "https://repo.maven.apache.org/maven2" } maven { url "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" } + maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } } // includeLibs just says to include the library in the final jar dependencies { implementation "org.bukkit:bukkit:1.15.1-R0.1-SNAPSHOT" + implementation "net.md-5:bungeecord-api:1.15-SNAPSHOT" + implementation "io.netty:netty-all:4.0.4.Final" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 94920145..23b9682c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ +#Sun Jan 19 19:02:36 KST 2020 +distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-bin.zip -zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME diff --git a/src/main/java/com/sekwah/advancedportals/AdvancedPortalsCommand.java b/src/main/java/com/sekwah/advancedportals/bukkit/AdvancedPortalsCommand.java similarity index 99% rename from src/main/java/com/sekwah/advancedportals/AdvancedPortalsCommand.java rename to src/main/java/com/sekwah/advancedportals/bukkit/AdvancedPortalsCommand.java index 720dccae..0a9cd820 100644 --- a/src/main/java/com/sekwah/advancedportals/AdvancedPortalsCommand.java +++ b/src/main/java/com/sekwah/advancedportals/bukkit/AdvancedPortalsCommand.java @@ -1,10 +1,10 @@ -package com.sekwah.advancedportals; +package com.sekwah.advancedportals.bukkit; -import com.sekwah.advancedportals.api.events.WarpEvent; -import com.sekwah.advancedportals.api.portaldata.PortalArg; -import com.sekwah.advancedportals.listeners.Listeners; -import com.sekwah.advancedportals.portals.AdvancedPortal; -import com.sekwah.advancedportals.portals.Portal; +import com.sekwah.advancedportals.bukkit.api.events.WarpEvent; +import com.sekwah.advancedportals.bukkit.api.portaldata.PortalArg; +import com.sekwah.advancedportals.bukkit.listeners.Listeners; +import com.sekwah.advancedportals.bukkit.portals.AdvancedPortal; +import com.sekwah.advancedportals.bukkit.portals.Portal; import org.bukkit.DyeColor; import org.bukkit.Location; import org.bukkit.Material; @@ -243,7 +243,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter { player.sendMessage(PluginMessages.customPrefix + "\u00A7e You have created a new portal with the following details:"); player.sendMessage("\u00A7aname: \u00A7e" + portalName); if (hasDestination) { - if (destiPosX == null) { + if (!isBungeePortal && destiPosX == null) { player.sendMessage("\u00A7cdestination: \u00A7e" + destination + " (destination does not exist)"); return true; } diff --git a/src/main/java/com/sekwah/advancedportals/AdvancedPortalsPlugin.java b/src/main/java/com/sekwah/advancedportals/bukkit/AdvancedPortalsPlugin.java similarity index 85% rename from src/main/java/com/sekwah/advancedportals/AdvancedPortalsPlugin.java rename to src/main/java/com/sekwah/advancedportals/bukkit/AdvancedPortalsPlugin.java index 93580760..9f461fa1 100644 --- a/src/main/java/com/sekwah/advancedportals/AdvancedPortalsPlugin.java +++ b/src/main/java/com/sekwah/advancedportals/bukkit/AdvancedPortalsPlugin.java @@ -1,20 +1,25 @@ -package com.sekwah.advancedportals; +package com.sekwah.advancedportals.bukkit; -import com.sekwah.advancedportals.compat.CraftBukkit; -import com.sekwah.advancedportals.destinations.Destination; -import com.sekwah.advancedportals.destinations.DestinationCommand; -import com.sekwah.advancedportals.effects.WarpEffects; -import com.sekwah.advancedportals.listeners.*; -import com.sekwah.advancedportals.metrics.Metrics; -import com.sekwah.advancedportals.portals.Portal; +import com.sekwah.advancedportals.bukkit.compat.CraftBukkit; +import com.sekwah.advancedportals.bukkit.destinations.Destination; +import com.sekwah.advancedportals.bukkit.destinations.DestinationCommand; +import com.sekwah.advancedportals.bukkit.effects.WarpEffects; +import com.sekwah.advancedportals.bukkit.listeners.*; +import com.sekwah.advancedportals.bukkit.metrics.Metrics; +import com.sekwah.advancedportals.bukkit.portals.Portal; +import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; +import java.util.HashMap; + public class AdvancedPortalsPlugin extends JavaPlugin { public CraftBukkit compat = null; private Settings settings; + public HashMap PlayerDestiMap = new HashMap<>(); + public void onEnable() { String packageName = getServer().getClass().getPackage().getName(); @@ -61,7 +66,6 @@ public class AdvancedPortalsPlugin extends JavaPlugin { this.getServer().getConsoleSender().sendMessage("\u00A7aAdvanced portals have been successfully enabled!"); - } catch (ClassNotFoundException e) { e.printStackTrace(); this.getLogger().warning("This version of craftbukkit is not yet supported, please notify sekwah and tell him about this version v:" + version); diff --git a/src/main/java/com/sekwah/advancedportals/ConfigAccessor.java b/src/main/java/com/sekwah/advancedportals/bukkit/ConfigAccessor.java similarity index 98% rename from src/main/java/com/sekwah/advancedportals/ConfigAccessor.java rename to src/main/java/com/sekwah/advancedportals/bukkit/ConfigAccessor.java index 73b646f3..2931c928 100644 --- a/src/main/java/com/sekwah/advancedportals/ConfigAccessor.java +++ b/src/main/java/com/sekwah/advancedportals/bukkit/ConfigAccessor.java @@ -1,4 +1,4 @@ -package com.sekwah.advancedportals; +package com.sekwah.advancedportals.bukkit; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; diff --git a/src/main/java/com/sekwah/advancedportals/PluginMessages.java b/src/main/java/com/sekwah/advancedportals/bukkit/PluginMessages.java similarity index 97% rename from src/main/java/com/sekwah/advancedportals/PluginMessages.java rename to src/main/java/com/sekwah/advancedportals/bukkit/PluginMessages.java index 27a6170f..c7effaa6 100644 --- a/src/main/java/com/sekwah/advancedportals/PluginMessages.java +++ b/src/main/java/com/sekwah/advancedportals/bukkit/PluginMessages.java @@ -1,4 +1,4 @@ -package com.sekwah.advancedportals; +package com.sekwah.advancedportals.bukkit; import org.bukkit.command.CommandSender; diff --git a/src/main/java/com/sekwah/advancedportals/Selection.java b/src/main/java/com/sekwah/advancedportals/bukkit/Selection.java similarity index 99% rename from src/main/java/com/sekwah/advancedportals/Selection.java rename to src/main/java/com/sekwah/advancedportals/bukkit/Selection.java index 574fefc9..12b69770 100644 --- a/src/main/java/com/sekwah/advancedportals/Selection.java +++ b/src/main/java/com/sekwah/advancedportals/bukkit/Selection.java @@ -1,4 +1,4 @@ -package com.sekwah.advancedportals; +package com.sekwah.advancedportals.bukkit; import org.bukkit.Bukkit; import org.bukkit.Location; diff --git a/src/main/java/com/sekwah/advancedportals/Settings.java b/src/main/java/com/sekwah/advancedportals/bukkit/Settings.java similarity index 95% rename from src/main/java/com/sekwah/advancedportals/Settings.java rename to src/main/java/com/sekwah/advancedportals/bukkit/Settings.java index 4dfb6920..0f6f2a90 100644 --- a/src/main/java/com/sekwah/advancedportals/Settings.java +++ b/src/main/java/com/sekwah/advancedportals/bukkit/Settings.java @@ -1,4 +1,4 @@ -package com.sekwah.advancedportals; +package com.sekwah.advancedportals.bukkit; /** * This contains generally used settings mostly diff --git a/src/main/java/com/sekwah/advancedportals/api/events/WarpEvent.java b/src/main/java/com/sekwah/advancedportals/bukkit/api/events/WarpEvent.java similarity index 93% rename from src/main/java/com/sekwah/advancedportals/api/events/WarpEvent.java rename to src/main/java/com/sekwah/advancedportals/bukkit/api/events/WarpEvent.java index 1ea02efd..4834f56b 100644 --- a/src/main/java/com/sekwah/advancedportals/api/events/WarpEvent.java +++ b/src/main/java/com/sekwah/advancedportals/bukkit/api/events/WarpEvent.java @@ -1,6 +1,6 @@ -package com.sekwah.advancedportals.api.events; +package com.sekwah.advancedportals.bukkit.api.events; -import com.sekwah.advancedportals.portals.AdvancedPortal; +import com.sekwah.advancedportals.bukkit.portals.AdvancedPortal; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; diff --git a/src/main/java/com/sekwah/advancedportals/api/portaldata/PortalArg.java b/src/main/java/com/sekwah/advancedportals/bukkit/api/portaldata/PortalArg.java similarity index 84% rename from src/main/java/com/sekwah/advancedportals/api/portaldata/PortalArg.java rename to src/main/java/com/sekwah/advancedportals/bukkit/api/portaldata/PortalArg.java index 8939f7a4..d820162e 100644 --- a/src/main/java/com/sekwah/advancedportals/api/portaldata/PortalArg.java +++ b/src/main/java/com/sekwah/advancedportals/bukkit/api/portaldata/PortalArg.java @@ -1,4 +1,4 @@ -package com.sekwah.advancedportals.api.portaldata; +package com.sekwah.advancedportals.bukkit.api.portaldata; public class PortalArg { diff --git a/src/main/java/com/sekwah/advancedportals/api/portaldata/PortalTags.java b/src/main/java/com/sekwah/advancedportals/bukkit/api/portaldata/PortalTags.java similarity index 93% rename from src/main/java/com/sekwah/advancedportals/api/portaldata/PortalTags.java rename to src/main/java/com/sekwah/advancedportals/bukkit/api/portaldata/PortalTags.java index 2609eacd..e071e3d4 100644 --- a/src/main/java/com/sekwah/advancedportals/api/portaldata/PortalTags.java +++ b/src/main/java/com/sekwah/advancedportals/bukkit/api/portaldata/PortalTags.java @@ -1,4 +1,4 @@ -package com.sekwah.advancedportals.api.portaldata; +package com.sekwah.advancedportals.bukkit.api.portaldata; import java.util.ArrayList; import java.util.HashMap; diff --git a/src/main/java/com/sekwah/advancedportals/api/registry/TagRegistry.java b/src/main/java/com/sekwah/advancedportals/bukkit/api/registry/TagRegistry.java similarity index 91% rename from src/main/java/com/sekwah/advancedportals/api/registry/TagRegistry.java rename to src/main/java/com/sekwah/advancedportals/bukkit/api/registry/TagRegistry.java index 86f45e84..bf3d6fc8 100644 --- a/src/main/java/com/sekwah/advancedportals/api/registry/TagRegistry.java +++ b/src/main/java/com/sekwah/advancedportals/bukkit/api/registry/TagRegistry.java @@ -1,7 +1,7 @@ -package com.sekwah.advancedportals.api.registry; +package com.sekwah.advancedportals.bukkit.api.registry; -import com.sekwah.advancedportals.AdvancedPortalsPlugin; -import com.sekwah.advancedportals.api.warphandler.TagHandler; +import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin; +import com.sekwah.advancedportals.bukkit.api.warphandler.TagHandler; import java.util.ArrayList; import java.util.HashMap; diff --git a/src/main/java/com/sekwah/advancedportals/api/warphandler/ActivationData.java b/src/main/java/com/sekwah/advancedportals/bukkit/api/warphandler/ActivationData.java similarity index 92% rename from src/main/java/com/sekwah/advancedportals/api/warphandler/ActivationData.java rename to src/main/java/com/sekwah/advancedportals/bukkit/api/warphandler/ActivationData.java index f18c4f98..537e4dc0 100644 --- a/src/main/java/com/sekwah/advancedportals/api/warphandler/ActivationData.java +++ b/src/main/java/com/sekwah/advancedportals/bukkit/api/warphandler/ActivationData.java @@ -1,6 +1,6 @@ -package com.sekwah.advancedportals.api.warphandler; +package com.sekwah.advancedportals.bukkit.api.warphandler; -import com.sekwah.advancedportals.portals.Portal; +import com.sekwah.advancedportals.bukkit.portals.Portal; public class ActivationData { diff --git a/src/main/java/com/sekwah/advancedportals/api/warphandler/TagHandler.java b/src/main/java/com/sekwah/advancedportals/bukkit/api/warphandler/TagHandler.java similarity index 97% rename from src/main/java/com/sekwah/advancedportals/api/warphandler/TagHandler.java rename to src/main/java/com/sekwah/advancedportals/bukkit/api/warphandler/TagHandler.java index 8def9eca..78f7e01b 100644 --- a/src/main/java/com/sekwah/advancedportals/api/warphandler/TagHandler.java +++ b/src/main/java/com/sekwah/advancedportals/bukkit/api/warphandler/TagHandler.java @@ -1,4 +1,4 @@ -package com.sekwah.advancedportals.api.warphandler; +package com.sekwah.advancedportals.bukkit.api.warphandler; import org.bukkit.entity.Player; diff --git a/src/main/java/com/sekwah/advancedportals/compat/CraftBukkit.java b/src/main/java/com/sekwah/advancedportals/bukkit/compat/CraftBukkit.java similarity index 96% rename from src/main/java/com/sekwah/advancedportals/compat/CraftBukkit.java rename to src/main/java/com/sekwah/advancedportals/bukkit/compat/CraftBukkit.java index 93dba54d..428ab94a 100644 --- a/src/main/java/com/sekwah/advancedportals/compat/CraftBukkit.java +++ b/src/main/java/com/sekwah/advancedportals/bukkit/compat/CraftBukkit.java @@ -1,7 +1,7 @@ -package com.sekwah.advancedportals.compat; +package com.sekwah.advancedportals.bukkit.compat; -import com.sekwah.advancedportals.AdvancedPortalsPlugin; -import com.sekwah.advancedportals.reflection.ReflectionHelper; +import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin; +import com.sekwah.advancedportals.bukkit.reflection.ReflectionHelper; import org.bukkit.entity.Player; import java.lang.reflect.Constructor; diff --git a/src/main/java/com/sekwah/advancedportals/destinations/Destination.java b/src/main/java/com/sekwah/advancedportals/bukkit/destinations/Destination.java similarity index 96% rename from src/main/java/com/sekwah/advancedportals/destinations/Destination.java rename to src/main/java/com/sekwah/advancedportals/bukkit/destinations/Destination.java index 85db2a19..1c026077 100644 --- a/src/main/java/com/sekwah/advancedportals/destinations/Destination.java +++ b/src/main/java/com/sekwah/advancedportals/bukkit/destinations/Destination.java @@ -1,9 +1,9 @@ -package com.sekwah.advancedportals.destinations; +package com.sekwah.advancedportals.bukkit.destinations; -import com.sekwah.advancedportals.AdvancedPortalsPlugin; -import com.sekwah.advancedportals.ConfigAccessor; -import com.sekwah.advancedportals.PluginMessages; -import com.sekwah.advancedportals.effects.WarpEffects; +import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin; +import com.sekwah.advancedportals.bukkit.ConfigAccessor; +import com.sekwah.advancedportals.bukkit.PluginMessages; +import com.sekwah.advancedportals.bukkit.effects.WarpEffects; import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.Location; diff --git a/src/main/java/com/sekwah/advancedportals/destinations/DestinationCommand.java b/src/main/java/com/sekwah/advancedportals/bukkit/destinations/DestinationCommand.java similarity index 96% rename from src/main/java/com/sekwah/advancedportals/destinations/DestinationCommand.java rename to src/main/java/com/sekwah/advancedportals/bukkit/destinations/DestinationCommand.java index 4b943958..2cbeecb6 100644 --- a/src/main/java/com/sekwah/advancedportals/destinations/DestinationCommand.java +++ b/src/main/java/com/sekwah/advancedportals/bukkit/destinations/DestinationCommand.java @@ -1,8 +1,8 @@ -package com.sekwah.advancedportals.destinations; +package com.sekwah.advancedportals.bukkit.destinations; -import com.sekwah.advancedportals.AdvancedPortalsPlugin; -import com.sekwah.advancedportals.ConfigAccessor; -import com.sekwah.advancedportals.PluginMessages; +import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin; +import com.sekwah.advancedportals.bukkit.ConfigAccessor; +import com.sekwah.advancedportals.bukkit.PluginMessages; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; diff --git a/src/main/java/com/sekwah/advancedportals/bukkit/destinations/PortalWarp.java b/src/main/java/com/sekwah/advancedportals/bukkit/destinations/PortalWarp.java new file mode 100644 index 00000000..f27e1427 --- /dev/null +++ b/src/main/java/com/sekwah/advancedportals/bukkit/destinations/PortalWarp.java @@ -0,0 +1,5 @@ +package com.sekwah.advancedportals.bukkit.destinations; + +public class PortalWarp { + +} diff --git a/src/main/java/com/sekwah/advancedportals/effects/WarpEffects.java b/src/main/java/com/sekwah/advancedportals/bukkit/effects/WarpEffects.java similarity index 94% rename from src/main/java/com/sekwah/advancedportals/effects/WarpEffects.java rename to src/main/java/com/sekwah/advancedportals/bukkit/effects/WarpEffects.java index 1db222c4..52009c6a 100644 --- a/src/main/java/com/sekwah/advancedportals/effects/WarpEffects.java +++ b/src/main/java/com/sekwah/advancedportals/bukkit/effects/WarpEffects.java @@ -1,6 +1,6 @@ -package com.sekwah.advancedportals.effects; +package com.sekwah.advancedportals.bukkit.effects; -import com.sekwah.advancedportals.AdvancedPortalsPlugin; +import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin; import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.Sound; diff --git a/src/main/java/com/sekwah/advancedportals/injector/PacketInjector.java b/src/main/java/com/sekwah/advancedportals/bukkit/injector/PacketInjector.java similarity index 86% rename from src/main/java/com/sekwah/advancedportals/injector/PacketInjector.java rename to src/main/java/com/sekwah/advancedportals/bukkit/injector/PacketInjector.java index 6272ff36..35358a2c 100644 --- a/src/main/java/com/sekwah/advancedportals/injector/PacketInjector.java +++ b/src/main/java/com/sekwah/advancedportals/bukkit/injector/PacketInjector.java @@ -1,7 +1,7 @@ -package com.sekwah.advancedportals.injector; +package com.sekwah.advancedportals.bukkit.injector; -import com.sekwah.advancedportals.AdvancedPortalsPlugin; -import com.sekwah.advancedportals.reflection.ReflectionHelper; +import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin; +import com.sekwah.advancedportals.bukkit.reflection.ReflectionHelper; import io.netty.channel.Channel; import java.lang.reflect.Field; diff --git a/src/main/java/com/sekwah/advancedportals/listeners/BungeeListener.java b/src/main/java/com/sekwah/advancedportals/bukkit/listeners/BungeeListener.java similarity index 61% rename from src/main/java/com/sekwah/advancedportals/listeners/BungeeListener.java rename to src/main/java/com/sekwah/advancedportals/bukkit/listeners/BungeeListener.java index 64273dd9..829ac2fb 100644 --- a/src/main/java/com/sekwah/advancedportals/listeners/BungeeListener.java +++ b/src/main/java/com/sekwah/advancedportals/bukkit/listeners/BungeeListener.java @@ -1,11 +1,14 @@ -package com.sekwah.advancedportals.listeners; +package com.sekwah.advancedportals.bukkit.listeners; import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteStreams; -import com.sekwah.advancedportals.AdvancedPortalsPlugin; +import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin; +import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; import org.bukkit.plugin.messaging.PluginMessageListener; +import java.util.UUID; + public class BungeeListener implements PluginMessageListener { private AdvancedPortalsPlugin plugin; @@ -16,14 +19,26 @@ public class BungeeListener implements PluginMessageListener { @Override public void onPluginMessageReceived(String channel, Player player, byte[] message) { - if (!channel.equals("BungeeCord")) { + if (!channel.equals("AdvancedPortals")) { return; } ByteArrayDataInput in = ByteStreams.newDataInput(message); String subchannel = in.readUTF(); - if (subchannel.equals("AdvancedPortals")) { - // Any data after this is read like the packets used in the naruto mod - // (same order as sent) + + plugin.getLogger().fine(subchannel); + + if (subchannel.equals("BungeePortal")) { + String targetPlayerUUID = in.readUTF(); + String targetDestination = in.readUTF(); + + OfflinePlayer msgPlayer = plugin.getServer().getOfflinePlayer(UUID.fromString(targetPlayerUUID)); + + plugin.PlayerDestiMap.put(msgPlayer, targetDestination); + + plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> + plugin.PlayerDestiMap.remove(msgPlayer), + 20L*10 + ); } } diff --git a/src/main/java/com/sekwah/advancedportals/listeners/FlowStopper.java b/src/main/java/com/sekwah/advancedportals/bukkit/listeners/FlowStopper.java similarity index 83% rename from src/main/java/com/sekwah/advancedportals/listeners/FlowStopper.java rename to src/main/java/com/sekwah/advancedportals/bukkit/listeners/FlowStopper.java index a3270068..c12a97bd 100644 --- a/src/main/java/com/sekwah/advancedportals/listeners/FlowStopper.java +++ b/src/main/java/com/sekwah/advancedportals/bukkit/listeners/FlowStopper.java @@ -1,8 +1,8 @@ -package com.sekwah.advancedportals.listeners; +package com.sekwah.advancedportals.bukkit.listeners; -import com.sekwah.advancedportals.AdvancedPortalsPlugin; -import com.sekwah.advancedportals.ConfigAccessor; -import com.sekwah.advancedportals.portals.Portal; +import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin; +import com.sekwah.advancedportals.bukkit.ConfigAccessor; +import com.sekwah.advancedportals.bukkit.portals.Portal; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; diff --git a/src/main/java/com/sekwah/advancedportals/listeners/Listeners.java b/src/main/java/com/sekwah/advancedportals/bukkit/listeners/Listeners.java similarity index 94% rename from src/main/java/com/sekwah/advancedportals/listeners/Listeners.java rename to src/main/java/com/sekwah/advancedportals/bukkit/listeners/Listeners.java index 3be1978d..e4458436 100644 --- a/src/main/java/com/sekwah/advancedportals/listeners/Listeners.java +++ b/src/main/java/com/sekwah/advancedportals/bukkit/listeners/Listeners.java @@ -1,11 +1,12 @@ -package com.sekwah.advancedportals.listeners; +package com.sekwah.advancedportals.bukkit.listeners; -import com.sekwah.advancedportals.AdvancedPortalsPlugin; -import com.sekwah.advancedportals.ConfigAccessor; -import com.sekwah.advancedportals.PluginMessages; -import com.sekwah.advancedportals.api.events.WarpEvent; -import com.sekwah.advancedportals.portals.AdvancedPortal; -import com.sekwah.advancedportals.portals.Portal; +import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin; +import com.sekwah.advancedportals.bukkit.ConfigAccessor; +import com.sekwah.advancedportals.bukkit.PluginMessages; +import com.sekwah.advancedportals.bukkit.api.events.WarpEvent; +import com.sekwah.advancedportals.bukkit.destinations.Destination; +import com.sekwah.advancedportals.bukkit.portals.AdvancedPortal; +import com.sekwah.advancedportals.bukkit.portals.Portal; import org.bukkit.*; import org.bukkit.block.data.BlockData; import org.bukkit.block.data.Orientable; @@ -64,6 +65,12 @@ public class Listeners implements Listener { @EventHandler public void onJoinEvent(PlayerJoinEvent event) { Portal.cooldown.put(event.getPlayer().getName(), System.currentTimeMillis()); + + if (plugin.PlayerDestiMap.containsKey(event.getPlayer())) { + String desti = plugin.PlayerDestiMap.get(event.getPlayer()); + + Destination.warp(event.getPlayer(), desti); + } } @EventHandler diff --git a/src/main/java/com/sekwah/advancedportals/listeners/PortalPlacer.java b/src/main/java/com/sekwah/advancedportals/bukkit/listeners/PortalPlacer.java similarity index 91% rename from src/main/java/com/sekwah/advancedportals/listeners/PortalPlacer.java rename to src/main/java/com/sekwah/advancedportals/bukkit/listeners/PortalPlacer.java index d8026bef..d3dfe2f3 100644 --- a/src/main/java/com/sekwah/advancedportals/listeners/PortalPlacer.java +++ b/src/main/java/com/sekwah/advancedportals/bukkit/listeners/PortalPlacer.java @@ -1,8 +1,8 @@ -package com.sekwah.advancedportals.listeners; +package com.sekwah.advancedportals.bukkit.listeners; -import com.sekwah.advancedportals.AdvancedPortalsPlugin; -import com.sekwah.advancedportals.ConfigAccessor; -import com.sekwah.advancedportals.portals.Portal; +import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin; +import com.sekwah.advancedportals.bukkit.ConfigAccessor; +import com.sekwah.advancedportals.bukkit.portals.Portal; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.event.EventHandler; diff --git a/src/main/java/com/sekwah/advancedportals/listeners/PortalProtect.java b/src/main/java/com/sekwah/advancedportals/bukkit/listeners/PortalProtect.java similarity index 90% rename from src/main/java/com/sekwah/advancedportals/listeners/PortalProtect.java rename to src/main/java/com/sekwah/advancedportals/bukkit/listeners/PortalProtect.java index bfb5eb42..fa9851e4 100644 --- a/src/main/java/com/sekwah/advancedportals/listeners/PortalProtect.java +++ b/src/main/java/com/sekwah/advancedportals/bukkit/listeners/PortalProtect.java @@ -1,9 +1,9 @@ -package com.sekwah.advancedportals.listeners; +package com.sekwah.advancedportals.bukkit.listeners; -import com.sekwah.advancedportals.AdvancedPortalsPlugin; -import com.sekwah.advancedportals.ConfigAccessor; -import com.sekwah.advancedportals.PluginMessages; -import com.sekwah.advancedportals.portals.Portal; +import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin; +import com.sekwah.advancedportals.bukkit.ConfigAccessor; +import com.sekwah.advancedportals.bukkit.PluginMessages; +import com.sekwah.advancedportals.bukkit.portals.Portal; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; diff --git a/src/main/java/com/sekwah/advancedportals/metrics/Metrics.java b/src/main/java/com/sekwah/advancedportals/bukkit/metrics/Metrics.java similarity index 99% rename from src/main/java/com/sekwah/advancedportals/metrics/Metrics.java rename to src/main/java/com/sekwah/advancedportals/bukkit/metrics/Metrics.java index 9a608b01..90d4f644 100644 --- a/src/main/java/com/sekwah/advancedportals/metrics/Metrics.java +++ b/src/main/java/com/sekwah/advancedportals/bukkit/metrics/Metrics.java @@ -1,4 +1,4 @@ -package com.sekwah.advancedportals.metrics; +package com.sekwah.advancedportals.bukkit.metrics; import com.google.gson.JsonArray; import com.google.gson.JsonObject; diff --git a/src/main/java/com/sekwah/advancedportals/portals/AdvancedPortal.java b/src/main/java/com/sekwah/advancedportals/bukkit/portals/AdvancedPortal.java similarity index 96% rename from src/main/java/com/sekwah/advancedportals/portals/AdvancedPortal.java rename to src/main/java/com/sekwah/advancedportals/bukkit/portals/AdvancedPortal.java index 47e51364..234f621a 100644 --- a/src/main/java/com/sekwah/advancedportals/portals/AdvancedPortal.java +++ b/src/main/java/com/sekwah/advancedportals/bukkit/portals/AdvancedPortal.java @@ -1,6 +1,6 @@ -package com.sekwah.advancedportals.portals; +package com.sekwah.advancedportals.bukkit.portals; -import com.sekwah.advancedportals.api.portaldata.PortalArg; +import com.sekwah.advancedportals.bukkit.api.portaldata.PortalArg; import org.bukkit.Location; import org.bukkit.Material; diff --git a/src/main/java/com/sekwah/advancedportals/portals/Portal.java b/src/main/java/com/sekwah/advancedportals/bukkit/portals/Portal.java similarity index 95% rename from src/main/java/com/sekwah/advancedportals/portals/Portal.java rename to src/main/java/com/sekwah/advancedportals/bukkit/portals/Portal.java index 59ea32d9..c5d5fe5d 100644 --- a/src/main/java/com/sekwah/advancedportals/portals/Portal.java +++ b/src/main/java/com/sekwah/advancedportals/bukkit/portals/Portal.java @@ -1,13 +1,13 @@ -package com.sekwah.advancedportals.portals; +package com.sekwah.advancedportals.bukkit.portals; import com.google.common.io.ByteArrayDataOutput; import com.google.common.io.ByteStreams; -import com.sekwah.advancedportals.AdvancedPortalsPlugin; -import com.sekwah.advancedportals.ConfigAccessor; -import com.sekwah.advancedportals.PluginMessages; -import com.sekwah.advancedportals.api.portaldata.PortalArg; -import com.sekwah.advancedportals.destinations.Destination; -import com.sekwah.advancedportals.effects.WarpEffects; +import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin; +import com.sekwah.advancedportals.bukkit.ConfigAccessor; +import com.sekwah.advancedportals.bukkit.PluginMessages; +import com.sekwah.advancedportals.bukkit.api.portaldata.PortalArg; +import com.sekwah.advancedportals.bukkit.destinations.Destination; +import com.sekwah.advancedportals.bukkit.effects.WarpEffects; import org.bukkit.*; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.Player; @@ -407,11 +407,21 @@ public class Portal { if (showBungeeMessage) { player.sendMessage(PluginMessages.customPrefix + "\u00A7a Attempting to warp to \u00A7e" + bungeeServer + "\u00A7a."); } - ByteArrayDataOutput out = ByteStreams.newDataOutput(); - out.writeUTF("Connect"); - out.writeUTF(bungeeServer); + + ByteArrayDataOutput outForList = ByteStreams.newDataOutput(); + outForList.writeUTF("PortalEnter"); + outForList.writeUTF(bungeeServer); + outForList.writeUTF(player.getUniqueId().toString()); + outForList.writeUTF(portal.getDestiation()); + + player.sendPluginMessage(plugin, "AdvancedPortals", outForList.toByteArray()); + + ByteArrayDataOutput outForSend = ByteStreams.newDataOutput(); + outForSend.writeUTF("Connect"); + outForSend.writeUTF(bungeeServer); + portal.inPortal.add(player.getUniqueId()); - player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray()); + player.sendPluginMessage(plugin, "BungeeCord", outForSend.toByteArray()); // Down to bungee to sort out the teleporting but yea theoretically they should warp. } else if (portal.getDestiation() != null) { diff --git a/src/main/java/com/sekwah/advancedportals/reflection/ReflectionHelper.java b/src/main/java/com/sekwah/advancedportals/bukkit/reflection/ReflectionHelper.java similarity index 93% rename from src/main/java/com/sekwah/advancedportals/reflection/ReflectionHelper.java rename to src/main/java/com/sekwah/advancedportals/bukkit/reflection/ReflectionHelper.java index d0db79d2..ee8bda22 100644 --- a/src/main/java/com/sekwah/advancedportals/reflection/ReflectionHelper.java +++ b/src/main/java/com/sekwah/advancedportals/bukkit/reflection/ReflectionHelper.java @@ -1,4 +1,4 @@ -package com.sekwah.advancedportals.reflection; +package com.sekwah.advancedportals.bukkit.reflection; import java.lang.reflect.Field; diff --git a/src/main/java/com/sekwah/advancedportals/bungee/AdvancedPortalsPlugin.java b/src/main/java/com/sekwah/advancedportals/bungee/AdvancedPortalsPlugin.java new file mode 100644 index 00000000..530f27bd --- /dev/null +++ b/src/main/java/com/sekwah/advancedportals/bungee/AdvancedPortalsPlugin.java @@ -0,0 +1,16 @@ +package com.sekwah.advancedportals.bungee; + +import net.md_5.bungee.api.plugin.Plugin; + +public class AdvancedPortalsPlugin extends Plugin { + @Override + public void onEnable() { + getProxy().registerChannel("AdvancedPortals"); + getLogger().info("\u00A7aAdvanced portals have been successfully enabled!"); + } + + @Override + public void onDisable() { + getLogger().info("\\u00A7cAdvanced portals are being disabled!"); + } +} diff --git a/src/main/java/com/sekwah/advancedportals/bungee/listener/PluginMessageReceiver.java b/src/main/java/com/sekwah/advancedportals/bungee/listener/PluginMessageReceiver.java new file mode 100644 index 00000000..1a1a4619 --- /dev/null +++ b/src/main/java/com/sekwah/advancedportals/bungee/listener/PluginMessageReceiver.java @@ -0,0 +1,43 @@ +package com.sekwah.advancedportals.bungee.listener; + +import com.google.common.io.ByteArrayDataInput; +import com.google.common.io.ByteArrayDataOutput; +import com.google.common.io.ByteStreams; +import com.sekwah.advancedportals.bungee.AdvancedPortalsPlugin; +import net.md_5.bungee.api.config.ServerInfo; +import net.md_5.bungee.api.event.PluginMessageEvent; +import net.md_5.bungee.api.plugin.Listener; +import net.md_5.bungee.event.EventHandler; + +public class PluginMessageReceiver implements Listener { + private AdvancedPortalsPlugin plugin; + + public PluginMessageReceiver (AdvancedPortalsPlugin plugin) { + this.plugin = plugin; + } + + @EventHandler + public void onMessageReceived(PluginMessageEvent event) { + if(!event.getTag().equalsIgnoreCase("AdvancedPortals")) return; + + ByteArrayDataInput in = ByteStreams.newDataInput(event.getData()); + String subChannel = in.readUTF(); + + if (subChannel.equalsIgnoreCase("PortalEnter")) { + String targetServer = in.readUTF(); + String targetPlayerUUID = in.readUTF(); + String targetDestination = in.readUTF(); + + ServerInfo server = plugin.getProxy().getServerInfo(targetServer); + + if (server != null) { + ByteArrayDataOutput out = ByteStreams.newDataOutput(); + out.writeUTF("BungeePortal"); + out.writeUTF(targetPlayerUUID); + out.writeUTF(targetDestination); + + server.sendData("AdvancedPortals", out.toByteArray()); + } + } + } +} diff --git a/src/main/java/com/sekwah/advancedportals/destinations/PortalWarp.java b/src/main/java/com/sekwah/advancedportals/destinations/PortalWarp.java deleted file mode 100644 index 54b0ae80..00000000 --- a/src/main/java/com/sekwah/advancedportals/destinations/PortalWarp.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.sekwah.advancedportals.destinations; - -public class PortalWarp { - -} diff --git a/src/main/resources/bungee.yml b/src/main/resources/bungee.yml new file mode 100644 index 00000000..78804f8b --- /dev/null +++ b/src/main/resources/bungee.yml @@ -0,0 +1,4 @@ +main: com.sekwah.advancedportals.bungee.AdvancedPortalsPlugin +name: AdvancedPortals +version: 0.2.1 +author: sekwah41 \ No newline at end of file diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 38a85370..3725565c 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,4 +1,4 @@ -main: com.sekwah.advancedportals.AdvancedPortalsPlugin +main: com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin name: AdvancedPortals version: 0.2.1 author: sekwah41