From bbe92cfd75a4c41463f7252528f3fd865ace077b Mon Sep 17 00:00:00 2001 From: sekwah41 Date: Tue, 12 Aug 2014 12:17:24 +0100 Subject: [PATCH] Added cross server teleportation with bungee(or at least should have, its currently untested) --- .../AdvancedPortalsCommand.java | 8 +++----- .../portalcontrolls/Portal.java | 20 +++++++++++++------ 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Advanced Portals/src/com/sekwah/advancedportals/AdvancedPortalsCommand.java b/Advanced Portals/src/com/sekwah/advancedportals/AdvancedPortalsCommand.java index a1f0d212..1dcdfed2 100644 --- a/Advanced Portals/src/com/sekwah/advancedportals/AdvancedPortalsCommand.java +++ b/Advanced Portals/src/com/sekwah/advancedportals/AdvancedPortalsCommand.java @@ -86,7 +86,6 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter { String portalName = null; String triggerBlock = null; String serverName = null; - List addArgs = new ArrayList(); for(int i = 1; i < args.length; i++){ if(args[i].toLowerCase().startsWith("name:") && args[i].length() > 5){ hasName = true; @@ -111,7 +110,6 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter { else if(args[i].toLowerCase().startsWith("bungee:") && args[i].length() > 7){ // not completely implemented isBungeePortal = true; serverName = args[i].toLowerCase().replaceFirst("bungee:", ""); - addArgs.add(args[i]); } } if(!hasName){ @@ -150,20 +148,20 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter { triggerBlockMat = Material.getMaterial(triggerBlock.toUpperCase()); if(triggerBlockMat != null){ player.sendMessage("§atriggerBlock: §e" + triggerBlock.toUpperCase()); - player.sendMessage(Portal.create(pos1, pos2, portalName, destination, triggerBlockMat, addArgs));; } + player.sendMessage(Portal.create(pos1, pos2, portalName, destination, triggerBlockMat, serverName));; } else{ hasTriggerBlock = false; ConfigAccessor Config = new ConfigAccessor(plugin, "Config.yml"); player.sendMessage("§ctriggerBlock: §edefault(" + Config.getConfig().getString("DefaultPortalTriggerBlock") + ")"); player.sendMessage("§cThe block " + triggerBlock.toUpperCase() + " is not a valid block name in minecraft so the trigger block has been set to the default!"); - player.sendMessage(Portal.create(pos1, pos2, portalName, destination, addArgs)); + player.sendMessage(Portal.create(pos1, pos2, portalName, destination, serverName)); } } else{ ConfigAccessor Config = new ConfigAccessor(plugin, "Config.yml"); player.sendMessage("§atriggerBlock: §edefault(" + Config.getConfig().getString("DefaultPortalTriggerBlock") + ")"); - player.sendMessage(Portal.create(pos1, pos2, portalName, destination, addArgs)); + player.sendMessage(Portal.create(pos1, pos2, portalName, destination, serverName)); } } else{ diff --git a/Advanced Portals/src/com/sekwah/advancedportals/portalcontrolls/Portal.java b/Advanced Portals/src/com/sekwah/advancedportals/portalcontrolls/Portal.java index 6b28cde1..cf2a108b 100644 --- a/Advanced Portals/src/com/sekwah/advancedportals/portalcontrolls/Portal.java +++ b/Advanced Portals/src/com/sekwah/advancedportals/portalcontrolls/Portal.java @@ -88,7 +88,11 @@ public class Portal { } - public static String create(Location pos1, Location pos2 , String name, String destination , Material triggerBlock, List addArgs) { + public static String create(Location pos1, Location pos2 , String name, String destination, Material triggerBlock) { + return create(pos1, pos2, name, destination, triggerBlock, null); + } + + public static String create(Location pos1, Location pos2 , String name, String destination, Material triggerBlock, String serverName) { if(!pos1.getWorld().equals(pos2.getWorld())){ plugin.getLogger().log(Level.WARNING, "pos1 and pos2 must be in the same world!"); @@ -144,6 +148,8 @@ public class Portal { config.getConfig().set(name + ".destination", destination); + config.getConfig().set(name + ".bungee", serverName); + config.getConfig().set(name + ".pos1.X", HighX); config.getConfig().set(name + ".pos1.Y", HighY); config.getConfig().set(name + ".pos1.Z", HighZ); @@ -209,9 +215,13 @@ public class Portal { } return triggerBlock.toString(); } - + + public static String create(Location pos1, Location pos2, String name, String destination) { + return create(pos1, pos2, name, destination,(String) null); + } + @SuppressWarnings("deprecation") - public static String create(Location pos1, Location pos2, String name, String destination, List addArgs) { // add stuff for destination names or coordinates + public static String create(Location pos1, Location pos2, String name, String destination, String serverName) { // add stuff for destination names or coordinates ConfigAccessor config = new ConfigAccessor(plugin, "Config.yml"); Material triggerBlockType; @@ -231,9 +241,7 @@ public class Portal { // TODO add a for loop which scans through the addArgs and adds them to the config so that the application can use them - String result = create(pos1, pos2, name, destination, triggerBlockType, addArgs); - - loadPortals(); + String result = create(pos1, pos2, name, destination, triggerBlockType, serverName); return result; }