Portals

Discussion in 'Plugin Development' started by Developher, Jul 31, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    Developher

    I am attempting to make a portal execute a command on the event, which is done. Now, I need to define where the portal would be. EX: (sign) [Portal]. If the portal had that sign, it would perform the command. If not, it would do nothing but teleport as usual.

    Code:
    package me.developher.meepportals;
     
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerPortalEvent;
     
    public class PlayerListener implements Listener {
     
     
    @EventHandler
    public void PlayerEnterPortalEvent(PlayerPortalEvent e) {
     
     
     
    e.getPlayer().sendMessage(ChatColor.GREEN + "[" + ChatColor.DARK_GREEN + "MeepPortals" + ChatColor.GREEN + "] You have been teleported!");
    e.getPlayer().performCommand("wilderness");
     
    }
     
     
    }
    
    Buuuuuuump.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 27, 2016
  2. Offline

    r0306

    Developher
    Listen for SignChangeEvent and detect the first line and check if it matches [Portal]. If it does, create a new custom portal object which stores the location of the portal. When the PlayerPortalEvent is triggered, call getTravelAgent().getLocation() and if the location matches the stored location, run the command.
     
Thread Status:
Not open for further replies.

Share This Page