Solved Prevent player from creating a vehicle?

Discussion in 'Plugin Development' started by Minecrell, Feb 22, 2013.

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

    Minecrell

    I'm trying to let a player place a vehicle only once in a specific time, but in VehicleCreateEvent I haven't got the player, and BlockPlaceEvent doesn't work for vehicle... I got it working for boats with the PlayerInteractEvent, but for minecarts the event is triggered 2 times when creating a new minecart, so the first one get allowed and the second time it is blocked because the plugin already saved the time for the first PlayerInteractEvent and so the minecart won't be created...

    Any chance for this?
     
  2. Offline

    Minecrell

    Adamki11s
    I don't want to prevent them from crafting minecarts, I want to prevent them from placing / creating minecarts. ;)
     
  3. Minecrell
    Sorry, my bad. Are you sure you are doing everything correctly? I just tested in a quick plugin and the event only fires once for both minecarts and boats.
     
  4. Offline

    Minecrell

    Adamki11s
    I will try a quick plugin too. Maybe it is because something with my plugin where I tried it.

    Adamki11s
    I tried it and it still fires 2 times for minecarts and now for boats too...

    Source:
    Code:java
    1. public class Test extends JavaPlugin implements Listener {
    2.  
    3. public void onEnable() {
    4. this.getServer().getPluginManager().registerEvents(this, this);
    5. }
    6.  
    7. @EventHandler
    8. public void onPlayerInteract(PlayerInteractEvent event) {
    9. event.getPlayer().sendMessage(".");
    10. }
    11.  
    12. }


    (I got 2 points)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  5. Does cancelling the vehicle create event on its own not work? Because when I tested it I only registered the VehicleCreateEvent.
     
  6. Offline

    Minecrell

    Of cause it works, but how do get the players instance when I use VehicleCreateEvent? I need the player name for only allowing the player to create a vehicle when he didn't created an other vehicle a specific time ago.
     
  7. Minecrell
    Ah yes I see what you mean, Its frustrating when these things happen :/. Have you tried creating a minecart at the location forcefully, i'm not sure if this can be done though?
     
    Minecrell likes this.
  8. Offline

    Minecrell

  9. Minecrell
    Is it possible to 'place' a minecart/boat into the world as you would a block? Maybe there is a way to spawn it in.
     
    Minecrell likes this.
  10. Offline

    Minecrell

    Adamki11s likes this.
Thread Status:
Not open for further replies.

Share This Page