Plugin Help User To Spawn In With Potion Effect.

Discussion in 'Plugin Help/Development/Requests' started by Tomw787, Jan 9, 2016.

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


    I'm wondering if anyone can help me with the following code, I'm just wanting a user to spawn in with a potion effect and an item. Help will be greatly appreciated. :)

    package com.tomplays.nightvision;
    import java.util.logging.Logger;
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.potion.PotionEffect;
    import org.bukkit.potion.PotionEffectType;
    public class MainClass extends JavaPlugin{
        public void onEnable(){
            PluginDescriptionFile pdfFile = getDescription();
            Logger logger = getLogger();
   + " Has been enabled (V. " + pdfFile.getVersion() + ")");
        public void onDisable(){
            PluginDescriptionFile pdfFile = getDescription();
            Logger logger = getLogger();
   + " Has been disabled (V. " + pdfFile.getVersion() + ")");
            public void onPlayerJoin (PlayerJoinEvent e) {
                Player player = e.getPlayer();
                e.setJoinMessage(ChatColor.AQUA + "Welcome!");
                player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 100000, 100 ));
                player.getInventory().addItem(new ItemStack(Material.APPLE, 1));
    } }
  2. Offline


    Dont forget to use "player.getDisplayName" to set the JoinMessage

    Maybe this works:

        public void onPlayerJoin(PlayerJoinEvent e){
            Player p = e.getPlayer();
            p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 99999, 2));
            e.setJoinMessage(ChatColor.GREEN + "+ " + ChatColor.WHITE + p.getDisplayName());
  3. Offline


    Hey, This still ain't working, any suggestions?
  4. Offline


    @Tomw787 Do you get any errors? Which parts work on your server? Do you get the welcome message/apple still?
  5. Offline


    Nope, Nothing is working at all on server
  6. Offline


    Hi @oceantheskatr, remember me? :p

    Anyway it is because you haven't implemented Listener and registered the event
    oceantheskatr and Tomw787 like this.
  7. Offline


    Thanks! It works now!
Thread Status:
Not open for further replies.

Share This Page