Help, ServerPopper

Discussion in 'Spigot Plugin Development' started by TimLampen, Apr 1, 2014.

Thread Status:
Not open for further replies.
  1. I am trying to make a plugin that will pop the player that another player is looking at on left or right click then send a message. I am having trouble with this, can anyone help?
    \/\/\/==Pop.java
    Code (Text):
    package me.timlampen.serverpop;

    import org.bukkit.ChatColor;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.PlayerEvent;
    import org.bukkit.event.player.PlayerInteractEvent;

    public class Pop implements Listener{
        public static Pop plugin;
       
        @EventHandler
        public void onPlayerInteract(PlayerInteractEvent event) {
           
        if (event.getAction() == Action.RIGHT_CLICK_AIR) {
        PlayerEvent.hidePlayer(player);
        event.getPlayer().sendMessage("hi");
        }
    }
    }
    \/\/\/==Main.java
    Code (Text):
    package me.timlampen.serverpop;

    import java.util.logging.Logger;

    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;

    public class Main extends JavaPlugin{
        public final Logger logger = Logger.getLogger("Minecraft");
        public static Main plugin;
        public final Pop bl = new Pop();
       
        @Override
        public void onDisable(){
            PluginDescriptionFile pdffile = this.getDescription();
            this.logger.info(pdffile.getName() + " Has Been Disabled!");
           
        }
        @Override
        public void onEnable() {
            PluginDescriptionFile pdffile = this.getDescription();
            this.logger.info(pdffile.getName() + " Version " + pdffile.getVersion() + " Has Been Enabled!");
            PluginManager pm = getServer().getPluginManager();
            pm.registerEvents(this.bl, this);
       
        }
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
            Player player = (Player) sender;
            return false;
        }
    }
           
     
    I am not the best at java, just starting, but I can take the comments saying 'Learn Java'.
    Thanks to those who try to help :)
     
  2. Try using PlayerInteractEntityEvent instead of PlayerInteractEvent- the latter is when you interact with blocks, instead of players.
     
  3. Code (Text):
    package me.timlampen.serverpop;

    import org.bukkit.ChatColor;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.PlayerEvent;
    import org.bukkit.event.player.PlayerInteractEntityEvent;
    import org.bukkit.event.player.PlayerInteractEvent;

    public class Pop implements Listener{
        public static Pop plugin;
       
        @EventHandler
        public void onPlayerInteract(PlayerInteractEntityEvent event) {
           
        if (event.getRightClicked() !=null) {
        PlayerEvent.hidePlayer();
        event.getPlayer().sendMessage("hi");
        }
    }
    }
    Getting an error on " PlayerEvent.hidePlayer(); " , solutions?
     
  4. What are you trying to accomplish with PlayerEvent.hidePlayer();? I've never seen that done before, there might be an easier way?

    Regardless, what does the error say?
     
  5. Trying to make the targetplayer who the player is right clicking to disappear from the player who right clicked and say something.
     
  6. changed the Pop.java\/\/\/
    Code (Text):
    package me.timlampen.serverpop;

    import org.bukkit.ChatColor;
    import org.bukkit.OfflinePlayer;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.PlayerEvent;
    import org.bukkit.event.player.PlayerInteractEntityEvent;
    import org.bukkit.event.player.PlayerInteractEvent;

    public class Pop implements Listener{
        public static Pop plugin;
       
        @EventHandler
        public void onPlayerInteract(PlayerInteractEntityEvent event) {
           
        if (event.getRightClicked() !=null) {
        PlayerEvent.hidePlayer(targetPlayer);
        event.getPlayer().sendMessage("hi");
        }
    }
    }
    Error --> http://gyazo.com/01faf9e25d7bb3ad8e6c4f66103b95d6
     
  7. That's a plugin.yml error. Fix your yml.
     
  8. How would I achieve this?
     
  9. Something like this, make the targetplayer actually get the event to get the target. I dont have my IDE open so not sure the event. should be pretty easy to do. also, It mite be better to make it when they hit a player pop them instead of just click.
    Code (Text):
    package me.timlampen.serverpop;

    import org.bukkit.ChatColor;
    import org.bukkit.OfflinePlayer;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.PlayerEvent;
    import org.bukkit.event.player.PlayerInteractEntityEvent;
    import org.bukkit.event.player.PlayerInteractEvent;

    public class Pop implements Listener{
        public static Pop plugin;
     
        @EventHandler
        public void onPlayerInteract(PlayerInteractEntityEvent event) {
           Player targetPlayer = event.gettargethere
        if (event.getRightClicked() !=null) {
        PlayerEvent.hidePlayer(targetPlayer);
        event.getPlayer().sendMessage("hi");
        }
    }
    }
     
  10. Code (Text):
    package me.timlampen.serverpop;

    import org.bukkit.ChatColor;
    import org.bukkit.OfflinePlayer;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.PlayerEvent;
    import org.bukkit.event.player.PlayerInteractEntityEvent;
    import org.bukkit.event.player.PlayerInteractEvent;

    public class Pop implements Listener{
        public static Pop plugin;
     
        @EventHandler
        public void onPlayerInteract(PlayerInteractEntityEvent event) {
           Player targetPlayer = event.gettargethere
        if (event.getRightClicked() !=null) {
        PlayerEvent.hidePlayer(targetPlayer);
        event.getPlayer().sendMessage("hi");
        }
    }
    }
    Now I get this error --> http://gyazo.com/642cf652ad32b77335234c2a534d86c1 also I like your Idea of hitting them, like in shotbow :)
     
  11. geNAZt

    Supporter

    Why don't you first go and learn java ? The code you have posted here and the errors you get let me think that you have no idea of what you are doing there.
     
    • Agree Agree x 2
  12. Everyone has to start somewhere
    (Reading the first post helps to)
     
  13. geNAZt

    Supporter

    Why do you try to learn bukkit first ? Its the wrong way
     
    • Agree Agree x 1
  14. I find bukkit is easier, since you already have all the events, and you just have to figure out how to get from Point A to Point B
     
    • Funny Funny x 1
  15. geNAZt

    Supporter

    Bukkit is not easier when you can't do anything in java. First you should try to read the basics guide from oracle. Look some java basic videos. Understand what you have done wrong and fix it. I could fix it for you but that's not the goal.

    Also you should look for an IDE. Since the most errors in here a IDE would tell you what you have dine wrong.

    If you get a simple program to function. Then you could go and look for the JavaDocs for bukkit. There is anything documented and its really easy to understand.
     
    • Agree Agree x 1
  16. I have done that, but all the tutorials are about how to make something happen in the console of eclipse, and my god, I was getting bored of that. So I decided to try and learn to how to use this information and make something useful, so I made a double jump plugin and server log in message plugin. I thought that this might be a bit harder, but not much harder so I decided to try and make this... Everyone needs help some days, and I need help with this. Because if I understand this, I am able to broaden the things that I can do. So if you don't want to help me, that is fine, but please don't try to criticize someone for trying to learn a different way that you did, or the usual way.
     
    • Agree Agree x 2
    • Funny Funny x 1
Thread Status:
Not open for further replies.