[SOLVED] Cancel Portaling - Can Nether Portaling be Prevented?

Discussion in 'Plugin Development' started by DragonSoulSong, Feb 14, 2012.

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

    DragonSoulSong

    Does anyone know how I could prevent a player from being transported to the Nether by standing in a portal block (block id 90 aka Material.PORTAL) unless a certain condition is met? I've been attempting to puzzle this out for about a week and nothing I have tried so far has worked. Any ideas?

    Thanks in advance,
    DragonSoulSong
     
  2. Offline

    Njol

    Have you already tried cancelling PlayerPortalEvent if the conditions aren't met?
     
  3. Offline

    desht

    I can state for a fact that cancelling the PlayerPortalEvent does work, because I added exactly this in the last ChessCraft release (portal blocks are a valid material to use on chess boards, but I don't want them sending players off to the nether).

    You still get the wobbly client-side animation (which gets more and more severe... a little nausea inducing :) ) until you step out of the block, but you don't get ported.

    https://github.com/desht/ChessCraft...chesscraft/listeners/ChessPlayerListener.java, see onPlayerPortal().
     
  4. Offline

    DragonSoulSong

    Yeah. It didn't seem to work...

    Hmm...interesting...I'll give it another shot. Thanks! :)

    Ok, so Just to test, I tried cancelling ALL PlayerPortalEvents and I still get sent to the Nether for some reason. Any clue why? Here's my code:
    Show Spoiler
    @EventHandler
    public void onPlayerPortal(PlayerPortalEvent event) {

    //if (!(event.getPlayer().getItemInHand().getTypeId() == plugin.portalUseItem)) {

    event.setCancelled(true);
    //}

    //else {

    //}
    }


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

    desht

    Might be a silly question, but have you registered the handler? Try putting a debug print statement in there to verify the handler is definitely getting called. Otherwise, really not sure...
     
  6. try running whit no other plugins to prevent other are enabling the event again
     
    KaiBB likes this.
  7. Offline

    DragonSoulSong

    Hmm...I'm actually not sure. I thought I had, but I could be wrong, as I'm not all that familiar yet with the new event system. Good thought.


    Good thinking, though all of my other plugins currently don't come anywhere near said event. Thanks though. :)

    Ok, problem solved! It was indeed that I simply didn't have the event properly registered...oops! Thanks again to all. :)

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

Share This Page