From 4561c7faf08855a6f72fd88e15e7b62332c9a5b0 Mon Sep 17 00:00:00 2001 From: sekwah41 Date: Tue, 24 Mar 2015 20:53:16 +0000 Subject: [PATCH 1/6] added reflection for 1.8_R2 --- .../AdvancedPortalsPlugin.java | 2 +- src/com/sekwah/advancedportals/Listeners.java | 4 +-- .../advancedportals/compat/v1_8_R2.java | 27 +++++++++++++++++++ 3 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 src/com/sekwah/advancedportals/compat/v1_8_R2.java diff --git a/src/com/sekwah/advancedportals/AdvancedPortalsPlugin.java b/src/com/sekwah/advancedportals/AdvancedPortalsPlugin.java index 0de27c0a..0c7c9f26 100644 --- a/src/com/sekwah/advancedportals/AdvancedPortalsPlugin.java +++ b/src/com/sekwah/advancedportals/AdvancedPortalsPlugin.java @@ -39,7 +39,7 @@ public class AdvancedPortalsPlugin extends JavaPlugin { this.setEnabled(false); } } catch (ClassNotFoundException e) { - System.out.println("This version of craftbukkit is not yet supported, please notify the author and give them this version v:" + version); + System.out.println("This version of craftbukkit is not yet supported, please notify the author and give version v:" + version); this.setEnabled(false); } catch (InstantiationException e) { e.printStackTrace(); diff --git a/src/com/sekwah/advancedportals/Listeners.java b/src/com/sekwah/advancedportals/Listeners.java index 83cf5b09..51e4b7c8 100644 --- a/src/com/sekwah/advancedportals/Listeners.java +++ b/src/com/sekwah/advancedportals/Listeners.java @@ -103,12 +103,12 @@ public class Listeners implements Listener { if(PortalMessagesDisplay == 1 && warped){ ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml"); player.sendMessage(""); - player.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] You have warped to \u00A7e" + config.getConfig().getString(Portal.Portals[portalId].portalName + ".destination").replaceAll("_", " ") + "\u00A7."); + player.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] You have been warped to \u00A7e" + config.getConfig().getString(Portal.Portals[portalId].portalName + ".destination").replaceAll("_", " ") + "\u00A7."); player.sendMessage(""); } else if(PortalMessagesDisplay == 2 && warped){ ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml"); - plugin.nmsAccess.sendActionBarMessage("{text:\"\u00A7aYou have warped to \u00A7e" + config.getConfig().getString(Portal.Portals[portalId].portalName + ".destination").replaceAll("_", " ") + "\u00A7a.\"}", player); + plugin.nmsAccess.sendActionBarMessage("{text:\"\u00A7aYou have been warped to \u00A7e" + config.getConfig().getString(Portal.Portals[portalId].portalName + ".destination").replaceAll("_", " ") + "\u00A7a.\"}", player); /**plugin.nmsAccess.sendActionBarMessage("[{text:\"You have warped to \",color:green},{text:\"" + config.getConfig().getString(Portal.Portals[portalId].portalName + ".destination").replaceAll("_", " ") + "\",color:yellow},{\"text\":\".\",color:green}]", player);*/ } diff --git a/src/com/sekwah/advancedportals/compat/v1_8_R2.java b/src/com/sekwah/advancedportals/compat/v1_8_R2.java new file mode 100644 index 00000000..a65f95b0 --- /dev/null +++ b/src/com/sekwah/advancedportals/compat/v1_8_R2.java @@ -0,0 +1,27 @@ +package com.sekwah.advancedportals.compat; + +import net.minecraft.server.v1_8_R2.IChatBaseComponent; +import net.minecraft.server.v1_8_R2.PacketPlayOutChat; +import org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer; +import org.bukkit.entity.Player; + + +public class v1_8_R2 implements NMS { + + @Override + public void sendRawMessage(String rawMessage, Player player) { + IChatBaseComponent comp = IChatBaseComponent.ChatSerializer.a(rawMessage); + // "json message", position(0: chat (chat box), 1: system message (chat box), 2: above action bar) + PacketPlayOutChat packet = new PacketPlayOutChat(comp, (byte) 1); + ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); + } + + + @Override + public void sendActionBarMessage(String rawMessage, Player player) { + IChatBaseComponent comp = IChatBaseComponent.ChatSerializer.a(rawMessage); + // "json message", position(0: chat (chat box), 1: system message (chat box), 2: above action bar) + PacketPlayOutChat packet = new PacketPlayOutChat(comp, (byte) 2); + ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); + } +} From ac21a19a3db54a586a29586ac9b8ce6a176f6d39 Mon Sep 17 00:00:00 2001 From: sekwah41 Date: Wed, 25 Mar 2015 22:51:29 +0000 Subject: [PATCH 2/6] Started adding the extra data for permissions and stuff --- .../AdvancedPortalsCommand.java | 35 +++++++++++++++---- .../advancedportals/DestinationCommand.java | 8 ++--- .../advancedportals/portals/Portal.java | 15 +++++--- .../advancedportals/portals/PortalArgs.java | 16 +++++++++ 4 files changed, 58 insertions(+), 16 deletions(-) create mode 100644 src/com/sekwah/advancedportals/portals/PortalArgs.java diff --git a/src/com/sekwah/advancedportals/AdvancedPortalsCommand.java b/src/com/sekwah/advancedportals/AdvancedPortalsCommand.java index 8153b3a1..999a907b 100644 --- a/src/com/sekwah/advancedportals/AdvancedPortalsCommand.java +++ b/src/com/sekwah/advancedportals/AdvancedPortalsCommand.java @@ -1,6 +1,7 @@ package com.sekwah.advancedportals; import com.sekwah.advancedportals.portals.Portal; +import com.sekwah.advancedportals.portals.PortalArgs; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; @@ -14,10 +15,7 @@ import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.metadata.FixedMetadataValue; -import java.util.Arrays; -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; +import java.util.*; public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter { @@ -75,10 +73,15 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter { boolean hasTriggerBlock = false; boolean hasDestination = false; boolean isBungeePortal = false; + boolean needsPermission = false; String destination = null; String portalName = null; String triggerBlock = null; String serverName = null; + String permission = null; + + ArrayList extraData = new ArrayList(); + for(int i = 1; i < args.length; i++){ if(args[i].toLowerCase().startsWith("name:") && args[i].length() > 5){ hasName = true; @@ -107,7 +110,13 @@ 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:", ""); + //extraData.add(new PortalArgs("bungee", serverName)); } + else if(args[i].toLowerCase().startsWith("permission:") && args[i].length() > 11){ // not completely implemented + needsPermission = true; + permission = args[i].toLowerCase().replaceFirst("permission:", ""); + extraData.add(new PortalArgs("permission", serverName)); + } } if(!hasName){ player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You must include a name for the portal that you are creating in the variables!"); @@ -140,12 +149,19 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter { player.sendMessage("\u00A7abungee: \u00A7e" + serverName); } + if(needsPermission){ + player.sendMessage("\u00A7apermission: \u00A7e" + permission); + } + else{ + player.sendMessage("\u00A7apermission: \u00A7e(none needed)"); + } + Material triggerBlockMat = Material.getMaterial(0); if(hasTriggerBlock){ triggerBlockMat = Material.getMaterial(triggerBlock.toUpperCase()); if(triggerBlockMat != null){ player.sendMessage("\u00A7atriggerBlock: \u00A7e" + triggerBlock.toUpperCase()); - player.sendMessage(Portal.create(pos1, pos2, portalName, destination, triggerBlockMat, serverName)); + player.sendMessage(Portal.create(pos1, pos2, portalName, destination, triggerBlockMat, serverName, (PortalArgs[]) extraData.toArray())); } else{ hasTriggerBlock = false; @@ -153,13 +169,13 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter { player.sendMessage("\u00A7ctriggerBlock: \u00A7edefault(" + Config.getConfig().getString("DefaultPortalTriggerBlock") + ")"); player.sendMessage("\u00A7cThe 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, serverName)); + player.sendMessage(Portal.create(pos1, pos2, portalName, destination, serverName, (PortalArgs[]) extraData.toArray())); } } else{ ConfigAccessor Config = new ConfigAccessor(plugin, "Config.yml"); player.sendMessage("\u00A7atriggerBlock: \u00A7edefault(" + Config.getConfig().getString("DefaultPortalTriggerBlock") + ")"); - player.sendMessage(Portal.create(pos1, pos2, portalName, destination, serverName)); + player.sendMessage(Portal.create(pos1, pos2, portalName, destination, serverName, (PortalArgs[]) extraData.toArray())); } } else{ @@ -432,6 +448,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter { boolean hasTriggerBlock = false; boolean hasDestination = false; boolean isBungeePortal = false; + boolean needsPermission = false; for(int i = 1; i < args.length; i++){ if(args[i].toLowerCase().startsWith("name:") && args[i].length() > 5){ @@ -449,6 +466,9 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter { else if(args[i].toLowerCase().startsWith("bungee:") && args[i].length() > 7){ isBungeePortal = true; } + else if(args[i].toLowerCase().startsWith("permission:") && args[i].length() > 11){ + needsPermission = true; + } } @@ -456,6 +476,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter { if(!hasTriggerBlock){autoComplete.add("triggerblock:");} if(!hasDestination){autoComplete.add("destination:");autoComplete.add("desti:");} if(!isBungeePortal){autoComplete.add("bungee:");} + if(!isBungeePortal){autoComplete.add("permission:");} } } Collections.sort(autoComplete); diff --git a/src/com/sekwah/advancedportals/DestinationCommand.java b/src/com/sekwah/advancedportals/DestinationCommand.java index 7685aed6..fe3efaf1 100644 --- a/src/com/sekwah/advancedportals/DestinationCommand.java +++ b/src/com/sekwah/advancedportals/DestinationCommand.java @@ -59,13 +59,13 @@ public class DestinationCommand implements CommandExecutor, TabCompleter { else if(args[0].toLowerCase().equals("remove")) { ConfigAccessor portalConfig = new ConfigAccessor(plugin, "Destinations.yml"); if(args.length > 1){ - String posX = portalConfig.getConfig().getString(args[1] + ".pos1.X"); + String posX = portalConfig.getConfig().getString(args[1] + ".pos.X"); if(posX != null){ Destination.remove(args[1]); - sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The portal \u00A7e" + args[1] + "\u00A7c has been removed!"); + sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The destination \u00A7e" + args[1] + "\u00A7c has been removed!"); } else{ - sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] No portal by that name exists."); + sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] No destination by that name exists."); } } else{ @@ -84,7 +84,7 @@ public class DestinationCommand implements CommandExecutor, TabCompleter { sender.sendMessage(""); } else if(PortalMessagesDisplay == 2){ - ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml"); + ConfigAccessor config = new ConfigAccessor(plugin, "Destinations.yml"); plugin.nmsAccess.sendActionBarMessage("{text:\"\u00A7aYou have warped to \u00A7e" + args[1].replaceAll("_", " ") + "\u00A7a.\"}", (Player) sender); /**plugin.nmsAccess.sendActionBarMessage("[{text:\"You have warped to \",color:green},{text:\"" + config.getConfig().getString(Portal.Portals[portalId].portalName + ".destination").replaceAll("_", " ") + "\",color:yellow},{\"text\":\".\",color:green}]", player);*/ diff --git a/src/com/sekwah/advancedportals/portals/Portal.java b/src/com/sekwah/advancedportals/portals/Portal.java index 19dc14fe..d078862d 100644 --- a/src/com/sekwah/advancedportals/portals/Portal.java +++ b/src/com/sekwah/advancedportals/portals/Portal.java @@ -11,6 +11,7 @@ import org.bukkit.Material; import org.bukkit.World; import org.bukkit.entity.Player; +import java.util.ArrayList; import java.util.Set; import java.util.logging.Level; @@ -89,11 +90,11 @@ public class Portal { } - 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, PortalArgs... extraData) { + return create(pos1, pos2, name, destination, triggerBlock, null, extraData); } - public static String create(Location pos1, Location pos2 , String name, String destination, Material triggerBlock, String serverName) { + public static String create(Location pos1, Location pos2, String name, String destination, Material triggerBlock, String serverName, PortalArgs... extraData) { if(!pos1.getWorld().equals(pos2.getWorld())){ plugin.getLogger().log(Level.WARNING, "pos1 and pos2 must be in the same world!"); @@ -158,6 +159,10 @@ public class Portal { config.getConfig().set(name + ".pos2.X", LowX); config.getConfig().set(name + ".pos2.Y", LowY); config.getConfig().set(name + ".pos2.Z", LowZ); + + for(PortalArgs arg: extraData){ + config.getConfig().set(name + ".extraData." + arg.argName, arg.value); + } config.saveConfig(); @@ -215,8 +220,8 @@ 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); + public static String create(Location pos1, Location pos2, String portalName, String name, String destination, PortalArgs... extraData) { + return create(pos1, pos2, name, destination,(String) null); } @SuppressWarnings("deprecation") diff --git a/src/com/sekwah/advancedportals/portals/PortalArgs.java b/src/com/sekwah/advancedportals/portals/PortalArgs.java new file mode 100644 index 00000000..db0091ed --- /dev/null +++ b/src/com/sekwah/advancedportals/portals/PortalArgs.java @@ -0,0 +1,16 @@ +package com.sekwah.advancedportals.portals; + +public class PortalArgs { + + public final String argName; + public final String value; + //public final int type; + + public PortalArgs(String argName, String value/*, int type*/){ + this.argName = argName; + this.value = value; + // may be used if values need to be 100% not string + //this.type = type; + } + +} From 5a2bd1796d17a78e3a0976eb2021e452ec430076 Mon Sep 17 00:00:00 2001 From: sekwah41 Date: Fri, 27 Mar 2015 19:18:22 +0000 Subject: [PATCH 3/6] Should be the complete code for custom permissions to use portals --- .../AdvancedPortalsCommand.java | 12 +++++----- .../advancedportals/portals/Portal.java | 22 ++++++++++++------- .../{PortalArgs.java => PortalArg.java} | 4 ++-- 3 files changed, 22 insertions(+), 16 deletions(-) rename src/com/sekwah/advancedportals/portals/{PortalArgs.java => PortalArg.java} (76%) diff --git a/src/com/sekwah/advancedportals/AdvancedPortalsCommand.java b/src/com/sekwah/advancedportals/AdvancedPortalsCommand.java index 999a907b..6e4da115 100644 --- a/src/com/sekwah/advancedportals/AdvancedPortalsCommand.java +++ b/src/com/sekwah/advancedportals/AdvancedPortalsCommand.java @@ -1,7 +1,7 @@ package com.sekwah.advancedportals; import com.sekwah.advancedportals.portals.Portal; -import com.sekwah.advancedportals.portals.PortalArgs; +import com.sekwah.advancedportals.portals.PortalArg; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; @@ -80,7 +80,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter { String serverName = null; String permission = null; - ArrayList extraData = new ArrayList(); + ArrayList extraData = new ArrayList(); for(int i = 1; i < args.length; i++){ if(args[i].toLowerCase().startsWith("name:") && args[i].length() > 5){ @@ -115,7 +115,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter { else if(args[i].toLowerCase().startsWith("permission:") && args[i].length() > 11){ // not completely implemented needsPermission = true; permission = args[i].toLowerCase().replaceFirst("permission:", ""); - extraData.add(new PortalArgs("permission", serverName)); + extraData.add(new PortalArg("permission", serverName)); } } if(!hasName){ @@ -161,7 +161,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter { triggerBlockMat = Material.getMaterial(triggerBlock.toUpperCase()); if(triggerBlockMat != null){ player.sendMessage("\u00A7atriggerBlock: \u00A7e" + triggerBlock.toUpperCase()); - player.sendMessage(Portal.create(pos1, pos2, portalName, destination, triggerBlockMat, serverName, (PortalArgs[]) extraData.toArray())); + player.sendMessage(Portal.create(pos1, pos2, portalName, destination, triggerBlockMat, serverName, (PortalArg[]) extraData.toArray())); } else{ hasTriggerBlock = false; @@ -169,13 +169,13 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter { player.sendMessage("\u00A7ctriggerBlock: \u00A7edefault(" + Config.getConfig().getString("DefaultPortalTriggerBlock") + ")"); player.sendMessage("\u00A7cThe 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, serverName, (PortalArgs[]) extraData.toArray())); + player.sendMessage(Portal.create(pos1, pos2, portalName, destination, serverName, (PortalArg[]) extraData.toArray())); } } else{ ConfigAccessor Config = new ConfigAccessor(plugin, "Config.yml"); player.sendMessage("\u00A7atriggerBlock: \u00A7edefault(" + Config.getConfig().getString("DefaultPortalTriggerBlock") + ")"); - player.sendMessage(Portal.create(pos1, pos2, portalName, destination, serverName, (PortalArgs[]) extraData.toArray())); + player.sendMessage(Portal.create(pos1, pos2, portalName, destination, serverName, (PortalArg[]) extraData.toArray())); } } else{ diff --git a/src/com/sekwah/advancedportals/portals/Portal.java b/src/com/sekwah/advancedportals/portals/Portal.java index d078862d..a4613780 100644 --- a/src/com/sekwah/advancedportals/portals/Portal.java +++ b/src/com/sekwah/advancedportals/portals/Portal.java @@ -11,7 +11,6 @@ import org.bukkit.Material; import org.bukkit.World; import org.bukkit.entity.Player; -import java.util.ArrayList; import java.util.Set; import java.util.logging.Level; @@ -90,11 +89,11 @@ public class Portal { } - public static String create(Location pos1, Location pos2 , String name, String destination, Material triggerBlock, PortalArgs... extraData) { + public static String create(Location pos1, Location pos2 , String name, String destination, Material triggerBlock, PortalArg... extraData) { return create(pos1, pos2, name, destination, triggerBlock, null, extraData); } - public static String create(Location pos1, Location pos2, String name, String destination, Material triggerBlock, String serverName, PortalArgs... extraData) { + public static String create(Location pos1, Location pos2, String name, String destination, Material triggerBlock, String serverName, PortalArg... portalArgs) { if(!pos1.getWorld().equals(pos2.getWorld())){ plugin.getLogger().log(Level.WARNING, "pos1 and pos2 must be in the same world!"); @@ -160,8 +159,8 @@ public class Portal { config.getConfig().set(name + ".pos2.Y", LowY); config.getConfig().set(name + ".pos2.Z", LowZ); - for(PortalArgs arg: extraData){ - config.getConfig().set(name + ".extraData." + arg.argName, arg.value); + for(PortalArg arg: portalArgs){ + config.getConfig().set(name + ".portalArgs." + arg.argName, arg.value); } config.saveConfig(); @@ -220,7 +219,7 @@ public class Portal { return triggerBlock.toString(); } - public static String create(Location pos1, Location pos2, String portalName, String name, String destination, PortalArgs... extraData) { + public static String create(Location pos1, Location pos2, String portalName, String name, String destination, PortalArg... extraData) { return create(pos1, pos2, name, destination,(String) null); } @@ -345,8 +344,15 @@ public class Portal { ConfigAccessor configDesti = new ConfigAccessor(plugin, "Destinations.yml"); String destiName = config.getConfig().getString(portalName + ".destination"); if(configDesti.getConfig().getString(destiName + ".world") != null){ - boolean warped = Destination.warp(player, destiName); - return warped; + String permission = config.getConfig().getString(portalName + ".portalArgs.permission"); + if(permission != null && player.hasPermission(permission)){ + boolean warped = Destination.warp(player, destiName); + return warped; + } + else{ + player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You do not have permission to use this portal!"); + return false; + } } else{ player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The destination you are currently attempting to warp to doesnt exist!"); diff --git a/src/com/sekwah/advancedportals/portals/PortalArgs.java b/src/com/sekwah/advancedportals/portals/PortalArg.java similarity index 76% rename from src/com/sekwah/advancedportals/portals/PortalArgs.java rename to src/com/sekwah/advancedportals/portals/PortalArg.java index db0091ed..5738c044 100644 --- a/src/com/sekwah/advancedportals/portals/PortalArgs.java +++ b/src/com/sekwah/advancedportals/portals/PortalArg.java @@ -1,12 +1,12 @@ package com.sekwah.advancedportals.portals; -public class PortalArgs { +public class PortalArg { public final String argName; public final String value; //public final int type; - public PortalArgs(String argName, String value/*, int type*/){ + public PortalArg(String argName, String value/*, int type*/){ this.argName = argName; this.value = value; // may be used if values need to be 100% not string From 80da8833ef16387f20bbcf0650d9fd5862a7bcf0 Mon Sep 17 00:00:00 2001 From: sekwah41 Date: Fri, 27 Mar 2015 22:44:04 +0000 Subject: [PATCH 4/6] updated warp permissions to allow ops through and also fixed a problem with the portal placer when vanilla portals are broken --- .../sekwah/advancedportals/FlowStopper.java | 19 ++++---- src/com/sekwah/advancedportals/Listeners.java | 47 ++++++++----------- .../sekwah/advancedportals/PortalPlacer.java | 33 +++++++++++-- .../sekwah/advancedportals/PortalProtect.java | 33 ++++++------- .../advancedportals/portals/Portal.java | 2 +- 5 files changed, 72 insertions(+), 62 deletions(-) diff --git a/src/com/sekwah/advancedportals/FlowStopper.java b/src/com/sekwah/advancedportals/FlowStopper.java index c439e731..99b0f551 100644 --- a/src/com/sekwah/advancedportals/FlowStopper.java +++ b/src/com/sekwah/advancedportals/FlowStopper.java @@ -33,15 +33,13 @@ public class FlowStopper implements Listener { // when checking positions check the block and the to block Block blockTo = event.getToBlock(); Block block = event.getBlock(); - - AdvancedPortal[] portals = Portal.Portals; - int portalId = 0; - for(Object portal : portals){ - if(Portal.Portals[portalId].worldName.equals(block.getWorld().getName())){ - if((Portal.Portals[portalId].pos1.getX() + 3D) >= block.getX() && (Portal.Portals[portalId].pos1.getY() + 3D) >= block.getY() && (Portal.Portals[portalId].pos1.getZ() + 3D) >= block.getZ()){ + for(AdvancedPortal portal : Portal.Portals){ + if(portal.worldName.equals(block.getWorld().getName())){ - if((Portal.Portals[portalId].pos2.getX() - 3D) <= block.getX() && (Portal.Portals[portalId].pos2.getY() - 3D) <= block.getY() && (Portal.Portals[portalId].pos2.getZ() - 3D) <= block.getZ()){ + if((portal.pos1.getX() + 3D) >= block.getX() && (portal.pos1.getY() + 3D) >= block.getY() && (portal.pos1.getZ() + 3D) >= block.getZ()){ + + if((portal.pos2.getX() - 3D) <= block.getX() && (portal.pos2.getY() - 3D) <= block.getY() && (portal.pos2.getZ() - 3D) <= block.getZ()){ event.setCancelled(true); @@ -50,11 +48,11 @@ public class FlowStopper implements Listener { } - if(Portal.Portals[portalId].worldName.equals(blockTo.getWorld().getName())){ + if(portal.worldName.equals(blockTo.getWorld().getName())){ - if((Portal.Portals[portalId].pos1.getX() + 3D) >= blockTo.getX() && (Portal.Portals[portalId].pos1.getY() + 3D) >= blockTo.getY() && (Portal.Portals[portalId].pos1.getZ() + 3D) >= blockTo.getZ()){ + if((portal.pos1.getX() + 3D) >= blockTo.getX() && (portal.pos1.getY() + 3D) >= blockTo.getY() && (portal.pos1.getZ() + 3D) >= blockTo.getZ()){ - if((Portal.Portals[portalId].pos2.getX() - 3D) <= blockTo.getX() && (Portal.Portals[portalId].pos2.getY() - 3D) <= blockTo.getY() && (Portal.Portals[portalId].pos2.getZ() - 3D) <= blockTo.getZ()){ + if((portal.pos2.getX() - 3D) <= blockTo.getX() && (portal.pos2.getY() - 3D) <= blockTo.getY() && (portal.pos2.getZ() - 3D) <= blockTo.getZ()){ event.setCancelled(true); @@ -62,7 +60,6 @@ public class FlowStopper implements Listener { } } - portalId++; } } diff --git a/src/com/sekwah/advancedportals/Listeners.java b/src/com/sekwah/advancedportals/Listeners.java index 51e4b7c8..41acf89e 100644 --- a/src/com/sekwah/advancedportals/Listeners.java +++ b/src/com/sekwah/advancedportals/Listeners.java @@ -86,13 +86,12 @@ public class Listeners implements Listener { //System.out.println(loc.getBlock().getType()); // for debugging, remove or comment out when not needed eyeloc.setY(eyeloc.getY() + player.getEyeHeight()); AdvancedPortal[] portals = Portal.Portals; - int portalId = 0; for(AdvancedPortal portal : portals){ - if(Portal.Portals[portalId].worldName.equals(loc.getWorld().getName())){ - if(Portal.Portals[portalId].trigger.equals(loc.getBlock().getType()) - || Portal.Portals[portalId].trigger.equals(eyeloc.getBlock().getType())){ - if((Portal.Portals[portalId].pos1.getX() + 1D) >= loc.getX() && (Portal.Portals[portalId].pos1.getY() + 1D) >= loc.getY() && (Portal.Portals[portalId].pos1.getZ() + 1D) >= loc.getZ()){ - if(Portal.Portals[portalId].pos2.getX() <= loc.getX() && Portal.Portals[portalId].pos2.getY() <= loc.getY() && Portal.Portals[portalId].pos2.getZ() <= loc.getZ()){ + if(portal.worldName.equals(loc.getWorld().getName())){ + if(portal.trigger.equals(loc.getBlock().getType()) + || portal.trigger.equals(eyeloc.getBlock().getType())){ + if((portal.pos1.getX() + 1D) >= loc.getX() && (portal.pos1.getY() + 1D) >= loc.getY() && (portal.pos1.getZ() + 1D) >= loc.getZ()){ + if(portal.pos2.getX() <= loc.getX() && portal.pos2.getY() <= loc.getY() && portal.pos2.getZ() <= loc.getZ()){ WarpEvent warpEvent = new WarpEvent(player, portal.portalName); @@ -103,13 +102,13 @@ public class Listeners implements Listener { if(PortalMessagesDisplay == 1 && warped){ ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml"); player.sendMessage(""); - player.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] You have been warped to \u00A7e" + config.getConfig().getString(Portal.Portals[portalId].portalName + ".destination").replaceAll("_", " ") + "\u00A7."); + player.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] You have been warped to \u00A7e" + config.getConfig().getString(portal.portalName + ".destination").replaceAll("_", " ") + "\u00A7."); player.sendMessage(""); } else if(PortalMessagesDisplay == 2 && warped){ ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml"); - plugin.nmsAccess.sendActionBarMessage("{text:\"\u00A7aYou have been warped to \u00A7e" + config.getConfig().getString(Portal.Portals[portalId].portalName + ".destination").replaceAll("_", " ") + "\u00A7a.\"}", player); - /**plugin.nmsAccess.sendActionBarMessage("[{text:\"You have warped to \",color:green},{text:\"" + config.getConfig().getString(Portal.Portals[portalId].portalName + ".destination").replaceAll("_", " ") + plugin.nmsAccess.sendActionBarMessage("{text:\"\u00A7aYou have been warped to \u00A7e" + config.getConfig().getString(portal.portalName + ".destination").replaceAll("_", " ") + "\u00A7a.\"}", player); + /**plugin.nmsAccess.sendActionBarMessage("[{text:\"You have warped to \",color:green},{text:\"" + config.getConfig().getString(portal.portalName + ".destination").replaceAll("_", " ") + "\",color:yellow},{\"text\":\".\",color:green}]", player);*/ } @@ -123,7 +122,7 @@ public class Listeners implements Listener { } - if(Portal.Portals[portalId].trigger.equals(Material.PORTAL)){ + if(portal.trigger.equals(Material.PORTAL)){ final Player finalplayer = event.getPlayer(); if(player.getGameMode().equals(GameMode.CREATIVE)){ player.setMetadata("HasWarped", new FixedMetadataValue(plugin, true)); @@ -140,7 +139,6 @@ public class Listeners implements Listener { } } - portalId++; } } @@ -161,13 +159,12 @@ public class Listeners implements Listener { Location loc = player.getLocation(); Object[] portals = Portal.Portals; - int portalId = 0; - for(Object portal : portals){ - if(Portal.Portals[portalId].worldName.equals(player.getWorld().getName())){ + for(AdvancedPortal portal : Portal.Portals){ + if(portal.worldName.equals(player.getWorld().getName())){ - if((Portal.Portals[portalId].pos1.getX() + 1D) >= loc.getX() && (Portal.Portals[portalId].pos1.getY() + 1D) >= loc.getY() && (Portal.Portals[portalId].pos1.getZ() + 1D) >= loc.getZ()){ + if((portal.pos1.getX() + 1D) >= loc.getX() && (portal.pos1.getY() + 1D) >= loc.getY() && (portal.pos1.getZ() + 1D) >= loc.getZ()){ - if((Portal.Portals[portalId].pos2.getX()) <= loc.getX() && (Portal.Portals[portalId].pos2.getY()) <= loc.getY() && (Portal.Portals[portalId].pos2.getZ()) <= loc.getZ()){ + if((portal.pos2.getX()) <= loc.getX() && (portal.pos2.getY()) <= loc.getY() && (portal.pos2.getZ()) <= loc.getZ()){ event.setCancelled(true); @@ -175,7 +172,6 @@ public class Listeners implements Listener { } } - portalId++; } } @@ -184,24 +180,22 @@ public class Listeners implements Listener { @SuppressWarnings("deprecation") @EventHandler - public void oniteminteract(PlayerInteractEvent event) { + public void onItemInteract(PlayerInteractEvent event) { // will detect if the player is using an axe so the points of a portal can be set // also any other detections such as sign interaction or basic block protection Player player = event.getPlayer(); if(player.hasMetadata("selectingPortal") && (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK)){ Block block = event.getClickedBlock(); - Object[] portals = Portal.Portals; - int portalId = 0; - for(Object portal : portals){ - if(Portal.Portals[portalId].worldName.equals(block.getWorld().getName())){ + for(AdvancedPortal portal : Portal.Portals){ + if(portal.worldName.equals(block.getWorld().getName())){ - if((Portal.Portals[portalId].pos1.getX() + 3D) >= block.getX() && (Portal.Portals[portalId].pos1.getY() + 3D) >= block.getY() && (Portal.Portals[portalId].pos1.getZ() + 3D) >= block.getZ()){ + if((portal.pos1.getX() + 3D) >= block.getX() && (portal.pos1.getY() + 3D) >= block.getY() && (portal.pos1.getZ() + 3D) >= block.getZ()){ - if((Portal.Portals[portalId].pos2.getX() - 3D) <= block.getX() && (Portal.Portals[portalId].pos2.getY() - 3D) <= block.getY() && (Portal.Portals[portalId].pos2.getZ() - 3D) <= block.getZ()){ - player.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] You have selected: \u00A7e" + Portal.Portals[portalId].portalName); + if((portal.pos2.getX() - 3D) <= block.getX() && (portal.pos2.getY() - 3D) <= block.getY() && (portal.pos2.getZ() - 3D) <= block.getZ()){ + player.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] You have selected: \u00A7e" + portal.portalName); player.removeMetadata("selectingPortal", plugin); - player.setMetadata("selectedPortal", new FixedMetadataValue(plugin, Portal.Portals[portalId].portalName)); // adds the name to the metadata of the character + player.setMetadata("selectedPortal", new FixedMetadataValue(plugin, portal.portalName)); // adds the name to the metadata of the character event.setCancelled(true); player.removeMetadata("selectingPortal", plugin); return; @@ -210,7 +204,6 @@ public class Listeners implements Listener { } } - portalId++; } player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] No portal was selected - if you would like to stop selecting please type \u00A7e/portal select \u00A7cagain!"); event.setCancelled(true); diff --git a/src/com/sekwah/advancedportals/PortalPlacer.java b/src/com/sekwah/advancedportals/PortalPlacer.java index 76992413..3d447190 100644 --- a/src/com/sekwah/advancedportals/PortalPlacer.java +++ b/src/com/sekwah/advancedportals/PortalPlacer.java @@ -1,6 +1,9 @@ package com.sekwah.advancedportals; +import com.sekwah.advancedportals.portals.AdvancedPortal; +import com.sekwah.advancedportals.portals.Portal; import org.bukkit.Material; +import org.bukkit.block.Block; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -11,8 +14,10 @@ public class PortalPlacer implements Listener { @SuppressWarnings("unused") private final AdvancedPortalsPlugin plugin; - // The needed config values will be stored so they are easier to access later - // an example is in the interact event in this if statement if((!UseOnlyServerAxe || event.getItem().getItemMeta().getDisplayName().equals("§eP... + private final double PortalProtectionRadius; + + // The needed config values will be stored so they are easier to access later + // an example is in the interact event in this if statement if((!UseOnlyServerAxe || event.getItem().getItemMeta().getDisplayName().equals("�eP... private boolean PortalPlace = true; public PortalPlacer(AdvancedPortalsPlugin plugin) { @@ -20,6 +25,8 @@ public class PortalPlacer implements Listener { ConfigAccessor config = new ConfigAccessor(plugin, "Config.yml"); this.PortalPlace = config.getConfig().getBoolean("CanBuildPortalBlock"); + + this.PortalProtectionRadius = config.getConfig().getDouble("PortalProtectionRadius"); if(PortalPlace){ plugin.getServer().getPluginManager().registerEvents(this, plugin); @@ -28,11 +35,27 @@ public class PortalPlacer implements Listener { @EventHandler(priority = EventPriority.HIGHEST) public void onBlockPhysics(BlockPhysicsEvent event) { - Material material = event.getBlock().getType(); + Block block = event.getBlock(); + Material material = block.getType(); if (material == Material.PORTAL) { - event.getChangedType(); - event.setCancelled(true); + for(AdvancedPortal portal : Portal.Portals){ + if(portal.worldName.equals(block.getWorld().getName())){ + + if((portal.pos1.getX() + PortalProtectionRadius) >= block.getX() && (portal.pos1.getY() + PortalProtectionRadius) >= block.getY() && (portal.pos1.getZ() + PortalProtectionRadius) >= block.getZ()){ + + if((portal.pos2.getX() - PortalProtectionRadius) <= block.getX() && (portal.pos2.getY() - PortalProtectionRadius) <= block.getY() && (portal.pos2.getZ() - PortalProtectionRadius) <= block.getZ()){ + + event.setCancelled(true); + break; + + } + } + + } + } + //event.getChangedType(); + //event.setCancelled(true); } } diff --git a/src/com/sekwah/advancedportals/PortalProtect.java b/src/com/sekwah/advancedportals/PortalProtect.java index 701359ae..4488910b 100644 --- a/src/com/sekwah/advancedportals/PortalProtect.java +++ b/src/com/sekwah/advancedportals/PortalProtect.java @@ -1,5 +1,6 @@ package com.sekwah.advancedportals; +import com.sekwah.advancedportals.portals.AdvancedPortal; import com.sekwah.advancedportals.portals.Portal; import org.bukkit.block.Block; import org.bukkit.event.EventHandler; @@ -42,16 +43,15 @@ public class PortalProtect implements Listener { if(!event.getPlayer().hasPermission("advancedportals.build")){ Block block = event.getBlock(); - Object[] portals = Portal.Portals; - int portalId = 0; - for(Object portal : portals){ - if(Portal.Portals[portalId].worldName.equals(block.getWorld().getName())){ + for(AdvancedPortal portal : Portal.Portals){ + if(portal.worldName.equals(block.getWorld().getName())){ - if((Portal.Portals[portalId].pos1.getX() + PortalProtectionRadius) >= block.getX() && (Portal.Portals[portalId].pos1.getY() + PortalProtectionRadius) >= block.getY() && (Portal.Portals[portalId].pos1.getZ() + PortalProtectionRadius) >= block.getZ()){ + if((portal.pos1.getX() + PortalProtectionRadius) >= block.getX() && (portal.pos1.getY() + PortalProtectionRadius) >= block.getY() && (portal.pos1.getZ() + PortalProtectionRadius) >= block.getZ()){ - if((Portal.Portals[portalId].pos2.getX() - PortalProtectionRadius) <= block.getX() && (Portal.Portals[portalId].pos2.getY() - PortalProtectionRadius) <= block.getY() && (Portal.Portals[portalId].pos2.getZ() - PortalProtectionRadius) <= block.getZ()){ + if((portal.pos2.getX() - PortalProtectionRadius) <= block.getX() && (portal.pos2.getY() - PortalProtectionRadius) <= block.getY() && (portal.pos2.getZ() - PortalProtectionRadius) <= block.getZ()){ event.setCancelled(true); + break; } } @@ -68,16 +68,15 @@ public class PortalProtect implements Listener { if(!event.getPlayer().hasPermission("advancedportals.build")){ Block block = event.getBlock(); - Object[] portals = Portal.Portals; - for(int portalId = 0; portalId < portals.length; portalId++){ - if(Portal.Portals[portalId].worldName.equals(block.getWorld().getName())){ + for(AdvancedPortal portal : Portal.Portals){ + if(portal.worldName.equals(block.getWorld().getName())){ - if((Portal.Portals[portalId].pos1.getX() + PortalProtectionRadius) >= block.getX() && (Portal.Portals[portalId].pos1.getY() + PortalProtectionRadius) >= block.getY() && (Portal.Portals[portalId].pos1.getZ() + PortalProtectionRadius) >= block.getZ()){ + if((portal.pos1.getX() + PortalProtectionRadius) >= block.getX() && (portal.pos1.getY() + PortalProtectionRadius) >= block.getY() && (portal.pos1.getZ() + PortalProtectionRadius) >= block.getZ()){ - if((Portal.Portals[portalId].pos2.getX() - PortalProtectionRadius) <= block.getX() && (Portal.Portals[portalId].pos2.getY() - PortalProtectionRadius) <= block.getY() && (Portal.Portals[portalId].pos2.getZ() - PortalProtectionRadius) <= block.getZ()){ + if((portal.pos2.getX() - PortalProtectionRadius) <= block.getX() && (portal.pos2.getY() - PortalProtectionRadius) <= block.getY() && (portal.pos2.getZ() - PortalProtectionRadius) <= block.getZ()){ event.setCancelled(true); - + break; } } @@ -92,13 +91,12 @@ public class PortalProtect implements Listener { for (int i = 0; i < blockList.size(); i++) { Block block = blockList.get(i); Object[] portals = Portal.Portals; - int portalId = 0; - for(Object portal : portals){ // change for format for(int i = 0; i < portals.length; i++){ - if(Portal.Portals[portalId].worldName.equals(block.getWorld().getName())){ + for(AdvancedPortal portal : Portal.Portals){ // change for format for(int i = 0; i < portals.length; i++){ + if(portal.worldName.equals(block.getWorld().getName())){ - if((Portal.Portals[portalId].pos1.getX() + PortalProtectionRadius) >= block.getX() && (Portal.Portals[portalId].pos1.getY() + PortalProtectionRadius) >= block.getY() && (Portal.Portals[portalId].pos1.getZ() + PortalProtectionRadius) >= block.getZ()){ + if((portal.pos1.getX() + PortalProtectionRadius) >= block.getX() && (portal.pos1.getY() + PortalProtectionRadius) >= block.getY() && (portal.pos1.getZ() + PortalProtectionRadius) >= block.getZ()){ - if((Portal.Portals[portalId].pos2.getX() - PortalProtectionRadius) <= block.getX() && (Portal.Portals[portalId].pos2.getY() - PortalProtectionRadius) <= block.getY() && (Portal.Portals[portalId].pos2.getZ() - PortalProtectionRadius) <= block.getZ()){ + if((portal.pos2.getX() - PortalProtectionRadius) <= block.getX() && (portal.pos2.getY() - PortalProtectionRadius) <= block.getY() && (portal.pos2.getZ() - PortalProtectionRadius) <= block.getZ()){ blockList.remove(i); i--; @@ -107,7 +105,6 @@ public class PortalProtect implements Listener { } } - portalId++; } } } diff --git a/src/com/sekwah/advancedportals/portals/Portal.java b/src/com/sekwah/advancedportals/portals/Portal.java index a4613780..233b44e1 100644 --- a/src/com/sekwah/advancedportals/portals/Portal.java +++ b/src/com/sekwah/advancedportals/portals/Portal.java @@ -345,7 +345,7 @@ public class Portal { String destiName = config.getConfig().getString(portalName + ".destination"); if(configDesti.getConfig().getString(destiName + ".world") != null){ String permission = config.getConfig().getString(portalName + ".portalArgs.permission"); - if(permission != null && player.hasPermission(permission)){ + if(permission != null && player.hasPermission(permission) || player.isOp()){ boolean warped = Destination.warp(player, destiName); return warped; } From 6318716511b255628819cf8c5536dae769dd8731 Mon Sep 17 00:00:00 2001 From: sekwah41 Date: Fri, 27 Mar 2015 23:24:46 +0000 Subject: [PATCH 5/6] updated the protection and stuff --- src/com/sekwah/advancedportals/AdvancedPortalsCommand.java | 2 +- src/com/sekwah/advancedportals/PortalProtect.java | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/com/sekwah/advancedportals/AdvancedPortalsCommand.java b/src/com/sekwah/advancedportals/AdvancedPortalsCommand.java index 6e4da115..1ea0dca7 100644 --- a/src/com/sekwah/advancedportals/AdvancedPortalsCommand.java +++ b/src/com/sekwah/advancedportals/AdvancedPortalsCommand.java @@ -59,7 +59,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter { else if(args[0].toLowerCase().equals("portal") || args[0].toLowerCase().equals("portalblock")){ PlayerInventory inventory = player.getInventory(); - ItemStack portalBlock = new ItemStack(Material.PORTAL); + ItemStack portalBlock = new ItemStack(Material.PORTAL, 1); inventory.addItem(portalBlock); diff --git a/src/com/sekwah/advancedportals/PortalProtect.java b/src/com/sekwah/advancedportals/PortalProtect.java index 4488910b..b2213076 100644 --- a/src/com/sekwah/advancedportals/PortalProtect.java +++ b/src/com/sekwah/advancedportals/PortalProtect.java @@ -49,7 +49,6 @@ public class PortalProtect implements Listener { if((portal.pos1.getX() + PortalProtectionRadius) >= block.getX() && (portal.pos1.getY() + PortalProtectionRadius) >= block.getY() && (portal.pos1.getZ() + PortalProtectionRadius) >= block.getZ()){ if((portal.pos2.getX() - PortalProtectionRadius) <= block.getX() && (portal.pos2.getY() - PortalProtectionRadius) <= block.getY() && (portal.pos2.getZ() - PortalProtectionRadius) <= block.getZ()){ - event.setCancelled(true); break; From 7f6f6cd75872a1c3b103d376c0707139b9987fef Mon Sep 17 00:00:00 2001 From: sekwah41 Date: Sat, 11 Apr 2015 14:17:28 +0100 Subject: [PATCH 6/6] Problem causing all the portals to stop working has been solved --- .../advancedportals/AdvancedPortalsCommand.java | 14 ++++++++++---- .../sekwah/advancedportals/DestinationCommand.java | 2 +- src/com/sekwah/advancedportals/portals/Portal.java | 3 +-- src/plugin.yml | 6 +++++- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/com/sekwah/advancedportals/AdvancedPortalsCommand.java b/src/com/sekwah/advancedportals/AdvancedPortalsCommand.java index 1ea0dca7..2f7c4054 100644 --- a/src/com/sekwah/advancedportals/AdvancedPortalsCommand.java +++ b/src/com/sekwah/advancedportals/AdvancedPortalsCommand.java @@ -115,7 +115,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter { else if(args[i].toLowerCase().startsWith("permission:") && args[i].length() > 11){ // not completely implemented needsPermission = true; permission = args[i].toLowerCase().replaceFirst("permission:", ""); - extraData.add(new PortalArg("permission", serverName)); + extraData.add(new PortalArg("permission", permission)); } } if(!hasName){ @@ -161,7 +161,9 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter { triggerBlockMat = Material.getMaterial(triggerBlock.toUpperCase()); if(triggerBlockMat != null){ player.sendMessage("\u00A7atriggerBlock: \u00A7e" + triggerBlock.toUpperCase()); - player.sendMessage(Portal.create(pos1, pos2, portalName, destination, triggerBlockMat, serverName, (PortalArg[]) extraData.toArray())); + PortalArg[] portalArgs = new PortalArg[extraData.size()]; + portalArgs = extraData.toArray(portalArgs); + player.sendMessage(Portal.create(pos1, pos2, portalName, destination, triggerBlockMat, serverName, portalArgs)); } else{ hasTriggerBlock = false; @@ -169,13 +171,17 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter { player.sendMessage("\u00A7ctriggerBlock: \u00A7edefault(" + Config.getConfig().getString("DefaultPortalTriggerBlock") + ")"); player.sendMessage("\u00A7cThe 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, serverName, (PortalArg[]) extraData.toArray())); + PortalArg[] portalArgs = new PortalArg[extraData.size()]; + portalArgs = extraData.toArray(portalArgs); + player.sendMessage(Portal.create(pos1, pos2, portalName, destination, serverName, portalArgs)); } } else{ ConfigAccessor Config = new ConfigAccessor(plugin, "Config.yml"); player.sendMessage("\u00A7atriggerBlock: \u00A7edefault(" + Config.getConfig().getString("DefaultPortalTriggerBlock") + ")"); - player.sendMessage(Portal.create(pos1, pos2, portalName, destination, serverName, (PortalArg[]) extraData.toArray())); + PortalArg[] portalArgs = new PortalArg[extraData.size()]; + portalArgs = extraData.toArray(portalArgs); + player.sendMessage(Portal.create(pos1, pos2, portalName, destination, serverName, portalArgs)); } } else{ diff --git a/src/com/sekwah/advancedportals/DestinationCommand.java b/src/com/sekwah/advancedportals/DestinationCommand.java index fe3efaf1..fd06bf94 100644 --- a/src/com/sekwah/advancedportals/DestinationCommand.java +++ b/src/com/sekwah/advancedportals/DestinationCommand.java @@ -74,7 +74,7 @@ public class DestinationCommand implements CommandExecutor, TabCompleter { } else if(args[0].toLowerCase().equals("goto") || args[0].toLowerCase().equals("warp")) { if(args.length > 1){ - System.out.println(args[1]); + //System.out.println(args[1]); ConfigAccessor configDesti = new ConfigAccessor(plugin, "Destinations.yml"); if(configDesti.getConfig().getString(args[1] + ".world") != null){ Destination.warp(sender, args[1]); diff --git a/src/com/sekwah/advancedportals/portals/Portal.java b/src/com/sekwah/advancedportals/portals/Portal.java index 233b44e1..9c51ba36 100644 --- a/src/com/sekwah/advancedportals/portals/Portal.java +++ b/src/com/sekwah/advancedportals/portals/Portal.java @@ -72,7 +72,6 @@ public class Portal { } Portals[portalId].trigger = blockType; - System.out.println("Test: " + portal.toString()); Portals[portalId].portalName = portal.toString(); Portals[portalId].worldName = config.getConfig().getString(portal.toString() + ".world"); World world = Bukkit.getWorld(config.getConfig().getString(portal.toString() + ".world")); @@ -345,7 +344,7 @@ public class Portal { String destiName = config.getConfig().getString(portalName + ".destination"); if(configDesti.getConfig().getString(destiName + ".world") != null){ String permission = config.getConfig().getString(portalName + ".portalArgs.permission"); - if(permission != null && player.hasPermission(permission) || player.isOp()){ + if(permission == null || (permission != null && player.hasPermission(permission)) || player.isOp()){ boolean warped = Destination.warp(player, destiName); return warped; } diff --git a/src/plugin.yml b/src/plugin.yml index ed10eaf4..f322ba9c 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ main: com.sekwah.advancedportals.AdvancedPortalsPlugin name: AdvancedPortals -version: 0.0.4 +version: 0.0.6 author: SEKWAH41 description: An advanced portals plugin for bukkit. commands: @@ -20,10 +20,14 @@ permissions: description: Gives access to all portal commands children: advancedportals.createportal: true + advancedportals.portal: true advancedportals.build: true advancedportals.createportal: description: Allows you to create portals default: op + advancedportals.portal: + description: Allows use of portal commands + default: op advancedportals.build: description: Allows you to build in the portal regions default: op