Tutorial Make a minigame plugin!

Discussion in 'Resources' started by xTrollxDudex, Aug 15, 2013.

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

    TheGator02

    Hello i need some help on minigame development I really would like to make a ctf plugin (capture the flag) that has custom classes and automatic restart soo when the blue or red team wins the server will automaticly restart and start another game with a new map

    Please reply THANKS!!
     
  2. Offline

    xTrollxDudex

  3. Offline

    Java4Monkeys

    The commands for some reason are not registering, My plugin.yml seems to have no problem as the plugin works but the commands don't seem to heres my code, and please explain since I still have a lot to learn in java but im no noob
    Code:
    package me.BuissnessMonkey.gtb;
     
    import org.bukkit.ChatColor;
    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 {
       
       
        @Override
        public void onEnable(){
           
        }
       
        @Override
       
        public void onDisable(){
           
        }
       
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String label, String args[]){
            if(!(sender instanceof Player)){
                sender.sendMessage(ChatColor.RED + "Only players may execute this!");
                return true;
            }
            Player p = (Player) sender;
           
            if(cmd.getName().equalsIgnoreCase("gtbcreate")){
                ArenaManager.getManager().createArena(p.getLocation());
                p.sendMessage(ChatColor.GREEN + "Created a gtb arena at" + p.getLocation().toString());
                return true;
            }
            if(cmd.getName().equalsIgnoreCase("gtbjoin")){
                if(args.length !=1){
                    p.sendMessage(ChatColor.RED + "insuffcient arguments");
                    return true;
                }
                int num = 0;
                try{
                    num = Integer.parseInt(args[0]);
                }catch(NumberFormatException e){
                    p.sendMessage(ChatColor.RED + "Invalid Arena ID");
                }
                ArenaManager.getManager().addPlayer(p,  num);
               
                return true;
                   
                }
            if(cmd.getName().equals("gtbleave")){
                ArenaManager.getManager().removePlayer(p);
                p.sendMessage(ChatColor.YELLOW + "You have left the arena");
               
                return true;
            }
            int num = 0;
            try{
                num = Integer.parseInt(args[0]);
            }catch(NumberFormatException e){
                p.sendMessage(ChatColor.RED + "Invalid arena ID");
               
            }
            ArenaManager.getManager().removeArena(num);
           
            return true;
           
     
           
        }
       
     
    }
    
    oops forgot to tag you xTrollxDudex read whats at the top ^

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Dec 6, 2015
  4. Offline

    xTrollxDudex

  5. Offline

    Java4Monkeys

    Here it is
    Code:
    name: GrandTheftBlocks
    version: 1.1
    main: me.BuissnessMonkey.gtb.Main
    author: BuissnessMonkey
    description: a Gtb plugin.
    commands:
    gtbcreate:
        description: create an arena.
        usage: /<command> [id]
        default: op
    gtbjoin:
        description: join an arena.
        usage: /<command> [id]
        default: op
    gtbleave:
        description: leave an arena.
        usage: /<command. [id]
        default: op
     
  6. Offline

    xTrollxDudex

  7. Offline

    Java4Monkeys

    What does indent mean, sorry I don't know
     
  8. Offline

    xTrollxDudex

  9. Offline

    Java4Monkeys

  10. Offline

    cpi2001

    Thanks for the help :D
    [​IMG]
     
  11. Offline

    Giraffeknee

    I keep getting an NPE at
    Code:java
    1. ArenaManager.getManager().createArena(p.getLocation());
     
  12. Offline

    xTrollxDudex

  13. Offline

    Giraffeknee

    I had a config and had it saved, let me try again.

    Yeah I have the config generated, and I only put a comment in it. Was there supposed to be something else in it? I thought that it should have had the "Arenas" in it but it doesn't. I have the code as shown on the tutorial.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Dec 6, 2015
  14. Offline

    xTrollxDudex

    Giraffeknee
    Use the GitHub one. The actual tutorial is just a frame to build your minigame off of.
     
  15. Offline

    Giraffeknee

    I did, I guess I'll look over everything. Thanks for the replies though :D!

    EDIT: It works, thanks man.

    ps: Great tutorial
     
  16. Offline

    Giraffeknee

    Everytime I start the server it seems to generate a "-1" in the Arenas.Arenas path in the config, I looked through the code and I didn't seem to find that anywhere (like the loadGames() method, my config, or the onEnable/Disable() methods). Do you know if that was anywhere in the code? I also seem to have an issue with the removeArena() method, when I try to remove that arena that generates when the server starts it always gives an internal error.
    Oh and I know this has been talked about but I'd like to see an example of how you would add multiple spawns, I understand you could add the spawn fields but I'd like to know how you'd randomize the player being teleported to the one of the spawns on addPlayer(a.spawn#), and how would you decide whether or not spawn# is occupied.
     
  17. Offline

    xTrollxDudex

    Giraffeknee
    Use your own implementation wrapper for a dpawn and a boolean and occupy when a player is teleported to the spawn. Loop through a list of them an make sure the boolean is false before teleporting to the location.

    Post stacktrace for the internal error.

    Is -1 a negative or an entry to the list?

    If you don't know what I mean by these, I suggest you learn Java.
     
  18. Offline

    Giraffeknee

    Here is the stacktrace error: http://pastebin.com/kGEx88Lb. By the way I'm running the command /bt(my command) remove 3. The arena's number id is 3. -1 is an entry to the list.
    Thanks for the spawns advice.
     
  19. Offline

    xTrollxDudex

  20. Offline

    Giraffeknee

  21. Offline

    xTrollxDudex

  22. Offline

    Giraffeknee

  23. Offline

    xTrollxDudex

    Giraffeknee
    Remove the bottom part of your remove command, the method fromthe manaer already removes the arena for you, your don't need to remove it twice.
     
  24. Offline

    Giraffeknee

    Alright, thanks.
     
  25. Offline

    Giraffeknee

    It still didn't work, has this happened to anyone else?
    If I was unclear the first time what I mean is it generates a "-1" in the config's arena list after the first arena is created but after that arena is removed, the number stays there. That sets me back to zero arenas, but when I create another it adds a "-1" to the arena list in the config again. Sorry to be a nuisance but this is somewhat frustrating as it should be removing that "-1".
     
  26. Offline

    xTrollxDudex

  27. Offline

    Giraffeknee

    Haha, I've done that. Like I said when I create an arena, and lets say it is the only arena (so it is arena "1"), it just does it again and adds the "-1" to the arena list in the config. It won't remove when I remove the arena in game, the arena along with it's information removes, but the arena's id does not remove from the list.
     
  28. Offline

    xTrollxDudex

    Giraffeknee
    By the way, I never subtracted the arenaSize when I remove the arena. You may want to take a look at that section again.
     
  29. Offline

    xXMaTTHDXx

    xTrollxDudex, how would I make multiple spawns like survival games? Like I want to be able to set as many as I want then tp people accordingly. It has been a real hassle for me..
     
  30. Offline

    xTrollxDudex

    xXMaTTHDXx
    Store location list. Store int with default value 0. Add spawns to list. Tp player to the get(int) from the list. Increment int.
     
    xXMaTTHDXx likes this.
Thread Status:
Not open for further replies.

Share This Page