[help]

Discussion in 'Plugin Development' started by xguysprison, Jul 19, 2014.

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

    xguysprison

    hey guys so can one of you guys give me a code where if someone click on an item in my gui it opens another gui. (i tryed opening it with a command dident look like working )
     
  2. Offline

    Necrodoom

    Paste your current code and explain what isnt working.
     
  3. Offline

    Gamesareme

    Have you got the code to do any thing for you when you clicked something in it? Or are you really asking how to do that?
     
  4. Offline

    xguysprison

    @gamesarmen no i am asking if i did something wrong i that code becus when i do the command the gui dont open
     
  5. Offline

    ZodiacTheories

  6. Offline

    _LB

    You have not given us any code to look at ;)
     
  7. Offline

    xguysprison

  8. Offline

    _LB

    The code you pasted does not seem to be the code we're dealing with. Also, please wait more than 4 minutes for a response, I'm not a computer!
     
  9. Offline

    xguysprison

    _LB i mean the problem with the code this one

    if (name.equals("red cards")) {
    RedCards.open(player);¨


    but this is what happens http://gyazo.com/526b2937ec7a9d52356abed380aeeb6a can you help me ?



    and im sorry for spamming it my pc keeps buggin :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  10. Offline

    _LB

    We need a large majority of the code to understand what's wrong, two lines isn't enough.

    Hope you get your computer issues resolved ;)
     
  11. Offline

    xguysprison

  12. Offline

    _LB

    Can we see the source to RedCards?
     
  13. Offline

    xguysprison

  14. Offline

    _LB

    The video has a low framerate and I can't really tell what the problem is - could you explain it in more detail what is wrong and what should be happening? (Not with a video)
     
  15. Offline

    xguysprison

    _LB when i click on it. It comes up fast and then it leaves the gui dosent stay up. it just comes up fast i dosent stay so players can click on it becus it just closes so fast
     
  16. Offline

    _LB

    Ah, I think the issue is that you're trying to open the GUI during the click event of another GUI. You need to delay the opening of the GUI by 1 tick after you close the current GUI. Have a look at this
     
  17. Offline

    xguysprison

    _LB can you please just send a example of the code ?

    like what i shoud do in my code ?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  18. Offline

    Gamesareme

    Code:java
    1. new BukkitRunnable() {
    2. @Override
    3. public void run() {
    4.  
    5. }
    6. }.runTaskLater(this.plugin, 10);

    try this, just place your code in the run section. :) This needs to be in your event, I believe.
     
  19. Offline

    xguysprison

  20. Offline

    _LB

    That's called spoonfeeding and is discouraged. You should figure it out for yourself, copy and paste only makes things worse.
     
  21. Offline

    Gamesareme

    I think it goes like this.
    Code:java
    1. @Override
    2. public void onOptionClick(OptionClickEvent event) {
    3. Player player = event.getPlayer();
    4. String name = event.getName().toLowerCase();
    5. if (name.equals("red cards")) {
    6. new BukkitRunnable() {
    7. @Override
    8. void run() {
    9. RedCards.open(player);
    10. }
    11. }.runTaskLater(this.plugin, 10);
    12. } if (name.equals("black cards")) {
    13. event.getPlayer().chat("/shop");
    14. }
    15. }

    oops sorry about that. I did not think this was spoonfeeding. :(
     
  22. Offline

    xguysprison

    _LB @Gamesareme how to do put it like this or ?
    Code:
    new BukkitRunnable() {
    @Override
    public void run() {
     
    }
    }.runTaskLater(RedCards.open.BarMenu, 10);
    please help i am not sure how ti add it together with the gui

    Gamesareme thx

    ill test when i am done eating

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  23. Offline

    Gamesareme

  24. Offline

    xguysprison

    @Gamesareme

    Code:
    }.runTaskLater(this.plugin, 10);
    this is whats confusing me a little what shoud i place in this and what shoud i place in plugin
     
  25. Offline

    Gamesareme

    Just leave that where it is. I think the 10 says how many ticks to wait. I know it looks random. It did to me as well.

    Hang on this will throw up an error right? You have not defined plugin.
    If you named your Main class Main, then add this bit of code just after your RedCards class.
    Code:
    Main plugin;
        public RedCards(Main main) {
            plugin = main;
        }
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  26. Offline

    xguysprison

    Gamesareme can you explain this a bit more ?

    this is my project

    main is SubplexBars
     
  27. Offline

    jimuskin

    xguysprison

    You need to define the instance of your main class is what he means. By doing so, it will remove the error.
     
  28. Offline

    xguysprison

    jimuskin i mean is this right ?

    Code:
    package me.casper.SubplexBarPlugin;
     
    import org.bukkit.Material;
    import org.bukkit.entity.Player;
    import org.bukkit.inventory.ItemStack;
     
    import com.xguys.BarPlugin.utils.IconMenu;
    import com.xguys.BarPlugin.utils.IconMenu.OptionClickEvent;
     
    public class RedCards {
       
        Main plugin;
        public RedCards(Main main) {
            plugin = main;
        }
     
  29. Offline

    jimuskin

    xguysprison :confused:, when I say main class, I mean the class that extends JavaPlugin. I'm almost positive that if you put that into an IDE, you will get errors....
     
  30. Offline

    xguysprison

    @jumuskin where in this shoud i place it ?
    Code:
    package me.casper.SubplexBarPlugin;
     
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class Main extends JavaPlugin {
       
        public static Main instance;
       
        @Override
        public void onEnable(){
            instance = this;
            getLogger().info("Subplex stuff has started");
            getServer().getPluginManager().registerEvents(new PlayerListener(), getinstance());
        }
       
       
        @Override
        public void onDisable(){
            instance = null;
            getLogger().info("Subplex stuff has started");
           
           
        }
     
     
        public static Main getinstance() {
            return instance;
     
        }
       
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
            if (cmd.getName().equalsIgnoreCase("selector")) {
                Player player = (Player) sender;
                BarMenu.open(player);
            }
            return false;
        }
    }
       
    
     
Thread Status:
Not open for further replies.

Share This Page