[SOLVED] How to make people respawn with potion effects?

Discussion in 'Plugin Development' started by MrDent009, Jul 16, 2012.

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

    MrDent009

    I've been wondering how to do this. I know it is possible but not sure how to make it work in MyPlayerListener class.

    I have this (the event of respawning) :
    Code:
        @EventHandler(priority = EventPriority.HIGH)
    public void onPlayerRespawn(PlayerRespawnEvent event) {
    event.getPlayer().addPotionEffects(PotionEffectType.SLOW,PotionEffectType.BLINDNESS,PotionEffectType.CONFUSION);
     
         
            
    Now I have an error when someone dies.
    Code:
    23:57:58 [SEVERE] Could not pass event PlayerRespawnEvent to SuckMyFlower
    org.bukkit.event.EventException
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:304)
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav
    a:62)
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.j
    ava:460)
            at net.minecraft.server.ServerConfigurationManager.moveToWorld(ServerCon
    figurationManager.java:289)
            at net.minecraft.server.ServerConfigurationManager.moveToWorld(ServerCon
    figurationManager.java:248)
            at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:1036)
            at net.minecraft.server.Packet9Respawn.handle(SourceFile:28)
            at net.minecraft.server.NetworkManager.b(NetworkManager.java:229)
            at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:113)
            at net.minecraft.server.NetworkListenThread.a(NetworkListenThread.java:7
    8)
            at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:567)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:459)
            at net.minecraft.server.ThreadServerApplication.run(SourceFile:492)
    Caused by: java.lang.Error: Unresolved compilation problem:
            The method addPotionEffects(Collection<PotionEffect>) in the type Living
    Entity is not applicable for the arguments (PotionEffectType, PotionEffectType,
    PotionEffectType)
     
            at me.Dent009.SuckMyFlower.MyPlayerListener.onPlayerRespawn(MyPlayerList
    ener.java:24)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
            at java.lang.reflect.Method.invoke(Unknown Source)
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:302)
            ... 12 more
     
  2. Offline

    CorrieKay

    create the potion effect, then add it to the player on respawn. :confused:
     
  3. Offline

    MrDent009

    CorrieKay
    I got this...not sure what it'll do..

    Code:
    @EventHandler(priority = EventPriority.HIGH)
        public void onPlayerRespawn(PlayerRespawnEvent event) {
        event.getPlayer().addPotionEffect();
     
  4. Offline

    CorrieKay

    create a new potion effect

    then add the potion effect to the player with addPotionEffect(PotionEffect);
     
  5. he is doing
    addPotionEffects(PotionEffect,PotionEffect,PotionEffect);
    while he wanted to do
    addPotionEffects(collection<PotionEffect>)
    so he need to do
    addPotionEffects(Arrays.asList(PotionEffect,Potioneffect,PotionEffect))
    so
    event.getPlayer().addPotionEffects(Arrays.asList(PotionEffectType.SLOW,PotionEffectType.BLINDNESS,PotionEffectType.CONFUSION));
     
Thread Status:
Not open for further replies.

Share This Page