add bungeecord portal teleport destination

This commit is contained in:
dalbodeule 2020-01-20 19:55:18 +09:00
parent 89c4253f82
commit a6555b171c
No known key found for this signature in database
GPG Key ID: 2FCD836D79E6D226
34 changed files with 200 additions and 97 deletions

View File

@ -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"
}

View File

@ -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

View File

@ -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;
}

View File

@ -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<OfflinePlayer, String> 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);

View File

@ -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;

View File

@ -1,4 +1,4 @@
package com.sekwah.advancedportals;
package com.sekwah.advancedportals.bukkit;
import org.bukkit.command.CommandSender;

View File

@ -1,4 +1,4 @@
package com.sekwah.advancedportals;
package com.sekwah.advancedportals.bukkit;
import org.bukkit.Bukkit;
import org.bukkit.Location;

View File

@ -1,4 +1,4 @@
package com.sekwah.advancedportals;
package com.sekwah.advancedportals.bukkit;
/**
* This contains generally used settings mostly

View File

@ -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;

View File

@ -1,4 +1,4 @@
package com.sekwah.advancedportals.api.portaldata;
package com.sekwah.advancedportals.bukkit.api.portaldata;
public class PortalArg {

View File

@ -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;

View File

@ -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;

View File

@ -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 {

View File

@ -1,4 +1,4 @@
package com.sekwah.advancedportals.api.warphandler;
package com.sekwah.advancedportals.bukkit.api.warphandler;
import org.bukkit.entity.Player;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -0,0 +1,5 @@
package com.sekwah.advancedportals.bukkit.destinations;
public class PortalWarp {
}

View File

@ -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;

View File

@ -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;

View File

@ -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
);
}
}

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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) {

View File

@ -1,4 +1,4 @@
package com.sekwah.advancedportals.reflection;
package com.sekwah.advancedportals.bukkit.reflection;
import java.lang.reflect.Field;

View File

@ -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!");
}
}

View File

@ -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());
}
}
}
}

View File

@ -1,5 +0,0 @@
package com.sekwah.advancedportals.destinations;
public class PortalWarp {
}

View File

@ -0,0 +1,4 @@
main: com.sekwah.advancedportals.bungee.AdvancedPortalsPlugin
name: AdvancedPortals
version: 0.2.1
author: sekwah41

View File

@ -1,4 +1,4 @@
main: com.sekwah.advancedportals.AdvancedPortalsPlugin
main: com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin
name: AdvancedPortals
version: 0.2.1
author: sekwah41