Added cross server teleportation with bungee(or at least should have,

its currently untested)
This commit is contained in:
sekwah41 2014-08-12 12:17:24 +01:00
parent a3ec952e10
commit bbe92cfd75
2 changed files with 17 additions and 11 deletions

View File

@ -86,7 +86,6 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
String portalName = null;
String triggerBlock = null;
String serverName = null;
List<String> addArgs = new ArrayList<String>();
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{

View File

@ -88,7 +88,11 @@ public class Portal {
}
public static String create(Location pos1, Location pos2 , String name, String destination , Material triggerBlock, List<String> 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<String> 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;
}