diff --git a/src/main/java/com/sekwah/advancedportals/bukkit/AdvancedPortalsCommand.java b/src/main/java/com/sekwah/advancedportals/bukkit/AdvancedPortalsCommand.java index 9f47b1e..750872e 100644 --- a/src/main/java/com/sekwah/advancedportals/bukkit/AdvancedPortalsCommand.java +++ b/src/main/java/com/sekwah/advancedportals/bukkit/AdvancedPortalsCommand.java @@ -564,7 +564,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter { if (args.length > 2) { StringBuilder portalCommand = new StringBuilder(args[2]); for (int i = 3; i < args.length; i++) { - portalCommand.append(args[i]); + portalCommand.append(" ").append(args[i]); } if (Portal.addCommand(portalName, portalCommand.toString())) { sender.sendMessage( diff --git a/src/main/java/com/sekwah/advancedportals/bukkit/destinations/Destination.java b/src/main/java/com/sekwah/advancedportals/bukkit/destinations/Destination.java index db4c67b..3d322bf 100644 --- a/src/main/java/com/sekwah/advancedportals/bukkit/destinations/Destination.java +++ b/src/main/java/com/sekwah/advancedportals/bukkit/destinations/Destination.java @@ -4,6 +4,8 @@ import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin; import com.sekwah.advancedportals.bukkit.PluginMessages; import com.sekwah.advancedportals.bukkit.config.ConfigAccessor; import com.sekwah.advancedportals.bukkit.effects.WarpEffects; +import com.sekwah.advancedportals.bukkit.portals.AdvancedPortal; +import com.sekwah.advancedportals.bukkit.portals.Portal; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Bukkit; @@ -13,6 +15,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerTeleportEvent; +import java.util.UUID; import java.util.logging.Level; public class Destination { @@ -155,6 +158,16 @@ public class Destination { player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("\u00A7aYou have warped to \u00A7e" + name.replaceAll("_", " ") + "\u00A7a.")); } + Location newLoc = player.getLocation(); + Location newEyeLoc = player.getEyeLocation(); + UUID uuid = player.getUniqueId(); + for (AdvancedPortal portal : Portal.portals) { + if (!portal.inPortal.contains(uuid) && !portal.isDelayed() + && (Portal.locationInPortalTrigger(portal, newLoc) || Portal.locationInPortalTrigger(portal, newEyeLoc))) { + portal.inPortal.add(uuid); + } + } + return true; } else { player.sendMessage(PluginMessages.customPrefixFail + "\u00A7c The destination you are trying to warp to seems to be linked to a world that doesn't exist!"); diff --git a/src/main/java/com/sekwah/advancedportals/bukkit/listeners/Listeners.java b/src/main/java/com/sekwah/advancedportals/bukkit/listeners/Listeners.java index 5abd2bd..659c602 100644 --- a/src/main/java/com/sekwah/advancedportals/bukkit/listeners/Listeners.java +++ b/src/main/java/com/sekwah/advancedportals/bukkit/listeners/Listeners.java @@ -23,7 +23,9 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.FixedMetadataValue; import java.util.HashMap; +import java.util.Locale; import java.util.Map; +import java.util.UUID; public class Listeners implements Listener { @@ -93,11 +95,19 @@ public class Listeners implements Listener { Portal.joinCooldown.put(player.getName(), System.currentTimeMillis()); - String uuid = player.getUniqueId().toString(); + Location loc = player.getLocation(); + Location eyeLoc = player.getEyeLocation(); + UUID uuid = player.getUniqueId(); + for (AdvancedPortal portal : Portal.portals) { + if (!portal.inPortal.contains(uuid) + && (Portal.locationInPortalTrigger(portal, loc) || Portal.locationInPortalTrigger(portal, eyeLoc))) { + portal.inPortal.add(uuid); + } + } - if (plugin.PlayerDestiMap.containsKey(uuid)) { - Destination.warp(player, plugin.PlayerDestiMap.get(uuid), false, true); - plugin.PlayerDestiMap.remove(uuid); + if (plugin.PlayerDestiMap.containsKey(uuid.toString())) { + Destination.warp(player, plugin.PlayerDestiMap.get(uuid.toString()), false, true); + plugin.PlayerDestiMap.remove(uuid.toString()); } } @@ -110,20 +120,19 @@ public class Listeners implements Listener { Player player = event.getPlayer(); - Location loc = event.getTo(); - Location eyeLoc = new Location(loc.getWorld(), loc.getX(), loc.getY() + player.getEyeHeight(), loc.getZ()); - - checkTriggerLocations(player, false, loc, eyeLoc); + checkTriggerLocations(player, false, event.getTo(), player.getEyeLocation()); } public void checkTriggerLocations(Player player, boolean useDelayed, Location... locations) { for (AdvancedPortal portal : Portal.portals) { - boolean delayed = portal.hasArg("delayed") && portal.getArg("delayed").equalsIgnoreCase("true"); + boolean removeInPortal = true; + boolean delayed = portal.isDelayed(); for (Location loc : locations) { if (delayed == useDelayed) { if (delayed ? Portal.locationInPortal(portal, loc, 1) : Portal.locationInPortalTrigger(portal, loc)) { + removeInPortal = false; if (portal.getTriggers().contains(Material.NETHER_PORTAL)) { if (player.getGameMode().equals(GameMode.CREATIVE)) { player.setMetadata("hasWarped", new FixedMetadataValue(plugin, true)); @@ -145,10 +154,12 @@ public class Listeners implements Listener { if (!delayed) portal.inPortal.add(player.getUniqueId()); return; - } else if (!delayed) - portal.inPortal.remove(player.getUniqueId()); + } } } + if(removeInPortal) { + portal.inPortal.remove(player.getUniqueId()); + } } } diff --git a/src/main/java/com/sekwah/advancedportals/bukkit/listeners/PortalPlacer.java b/src/main/java/com/sekwah/advancedportals/bukkit/listeners/PortalPlacer.java index a4793da..7b230ff 100644 --- a/src/main/java/com/sekwah/advancedportals/bukkit/listeners/PortalPlacer.java +++ b/src/main/java/com/sekwah/advancedportals/bukkit/listeners/PortalPlacer.java @@ -83,6 +83,7 @@ public class PortalPlacer implements Listener { @EventHandler(priority = EventPriority.HIGHEST) public void onBlockPhysics(BlockPhysicsEvent event) { Block block = event.getBlock(); + Block newBlock = block.getWorld().getBlockAt(block.getLocation()); Material material = block.getType(); if (material == Material.NETHER_PORTAL && Portal.inPortalRegion(block.getLocation(), Portal.getPortalProtectionRadius())) event.setCancelled(true); diff --git a/src/main/java/com/sekwah/advancedportals/bukkit/portals/AdvancedPortal.java b/src/main/java/com/sekwah/advancedportals/bukkit/portals/AdvancedPortal.java index 234f621..11d7e46 100644 --- a/src/main/java/com/sekwah/advancedportals/bukkit/portals/AdvancedPortal.java +++ b/src/main/java/com/sekwah/advancedportals/bukkit/portals/AdvancedPortal.java @@ -112,4 +112,8 @@ public class AdvancedPortal { public void setBungee(String bungee) { this.bungee = bungee; } + + public boolean isDelayed() { + return this.hasArg("delayed") && this.getArg("delayed").equalsIgnoreCase("true"); + } } diff --git a/src/main/java/com/sekwah/advancedportals/bukkit/portals/Portal.java b/src/main/java/com/sekwah/advancedportals/bukkit/portals/Portal.java index 79a5ca0..8872f3d 100644 --- a/src/main/java/com/sekwah/advancedportals/bukkit/portals/Portal.java +++ b/src/main/java/com/sekwah/advancedportals/bukkit/portals/Portal.java @@ -417,12 +417,19 @@ public class Portal { String permission = portal.getArg("permission"); + boolean noMessage = permission != null && permission.startsWith("nomsg."); + if(noMessage) { + permission.substring(6); + } + if (!(permission == null || player.hasPermission(permission) || player.isOp())) { - player.sendMessage( - PluginMessages.customPrefixFail + "\u00A7c You do not have permission to use this portal!"); - failSound(player, portal); - if(doKnockback) - throwPlayerBack(player); + if(!noMessage) { + player.sendMessage( + PluginMessages.customPrefixFail + "\u00A7c You do not have permission to use this portal!"); + failSound(player, portal); + if(doKnockback) + throwPlayerBack(player); + } return false; } diff --git a/src/main/java/com/sekwah/advancedportals/bungee/AdvancedPortalsPlugin.java b/src/main/java/com/sekwah/advancedportals/bungee/AdvancedPortalsPlugin.java index c2d8687..870defe 100644 --- a/src/main/java/com/sekwah/advancedportals/bungee/AdvancedPortalsPlugin.java +++ b/src/main/java/com/sekwah/advancedportals/bungee/AdvancedPortalsPlugin.java @@ -18,6 +18,8 @@ public class AdvancedPortalsPlugin extends Plugin { public void onEnable() { getProxy().registerChannel(channelName); + if(channelName != null) + getProxy().getPluginManager().registerListener(this, new PluginMessageReceiver(this)); getProxy().getPluginManager().registerListener(this, new EventListener(this)); diff --git a/src/main/resources/bungee.yml b/src/main/resources/bungee.yml index c1ae892..3669e28 100644 --- a/src/main/resources/bungee.yml +++ b/src/main/resources/bungee.yml @@ -1,4 +1,4 @@ main: com.sekwah.advancedportals.bungee.AdvancedPortalsPlugin name: AdvancedPortals -version: 0.5.9 +version: 0.5.10 author: sekwah41 diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 7ba0c19..22b8fb0 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ main: com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin name: AdvancedPortals -version: 0.5.9 +version: 0.5.10 author: sekwah41 description: An advanced portals plugin for bukkit. api-version: 1.13