Detecting difference between being teleported by Multiverse vs. the /tp command

Discussion in 'Plugin Development' started by Gildan27, Dec 2, 2012.

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

    Gildan27

    I need to find out if the player was teleported by Multiverse.

    It seems that PlayerTeleportEvent has a getCause() method that seems suitable for this. It returns a TeleportCause that will be "PLUGIN" if a plugin caused the teleport. That's good enough.

    Code:
        @EventHandler
        public void onPlayerTeleportEvent(PlayerTeleportEvent event) {
            plugin.getLogger().info(event.getCause().name());
            //new TeleportEvent(plugin, event.getPlayer(), event).raise();
        }
    This outputs "PLUGIN" for both a Multiverse teleport and a /tp teleport. It occurred to me that Multiverse might be overriding the /tp command, but I disabled all plugins except my plugin, WorldGuard and WorldEdit (my plugin is tightly integrated with WorldGuard/WorldEdit and won't start without them), and it still says "PLUGIN" for /tp.

    Per http://jd.bukkit.org/apidocs/org/bukkit/event/player/PlayerTeleportEvent.TeleportCause.html, I would expect /tp to output "COMMAND" for /tp.

    Any thoughts?
     
  2. Offline

    javoris767

  3. Offline

    Gildan27

    Wow, thanks--it's been a long day, I was making this way more complicated that it needed to be! Thanks a lot, that should work perfectly....

    I think I celebrated too soon...

    Code:
    public class MyPlugin extends JavaPlugin implements Listener {
       
        public JavaPlugin plugin;
       
        @Override
        public void onEnable() {
            this.plugin = this;   
            getServer().getPluginManager().registerEvents(this, this);
        }
       
        @EventHandler
        public void onMVTeleportEvent(MVTeleportEvent event) {
            plugin.getLogger().info(event.getEventName());
            //new TeleportEvent(plugin, event.getTeleportee(), event).raise();
        }
       
    }
    Nothing happens when I go through a Multiverse portal.

    Any ideas?

    Got it--needed to listen for MultiVerse-Portal's MVPortalEvent instead.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
Thread Status:
Not open for further replies.

Share This Page