Util *BROKEN* *PLEASE READ* Create a Minigame!

Discussion in 'Resources' started by JPG2000, Nov 11, 2013.

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

    ajs333

    JPG2000
    Could this method be used to create a mini game like LMS (Last Man Standing) for a KitPvP server? I was just skimming the code and it seemed like I don't need all of it like the Load an arena form the config...
     
  2. Offline

    JPG2000

    ajs333 Um, you need it the load arenas method. If you didn't, arenas wouldn't last through reloads:

    I make an Arena 'Pie'
    */reload*
    WHERE's PIE?!?!?!
     
  3. Offline

    ajs333

    JPG2000
    What if it is just in a plan world... like a warp...??
     
  4. Offline

    PieMan456

    JPG2000
    Where can I find some object tuts. I can't seem to find any.
     
  5. Offline

    xTrollxDudex

    PieMan456
    Java tuotorials should have this
     
  6. Offline

    PieMan456

  7. Offline

    xTrollxDudex

  8. Offline

    L33m4n123

    Hey. Just wanted to give you a written Thumps Up. Using your code for a Plugin I am writing currently. And it basicly reduced the time I need to write the plugin at arround 30%.
    Ok for you if I 'only' use your packets and your comments for giving you credits?^^
     
  9. Offline

    FatAussieFatBoy

    Now this might just be me, but every time I try to use this Code I get an error with my createArena() and loadArena() :/

    I believe that I might be doing something wrong with my FileConfiguration ---> FileConfiguration path = plugin.getConfig(); "plugin" is set to my Main.java using ---> public Main plugin;

    Any ideas?
     
  10. Offline

    L33m4n123

    Make sure that you actually HAVE an arena in the arena config file before calling loadArena()

    Also make sure that it saves the world aswell when you create an arena since by default it doesn't save the worldname

    JPG2000 What you might want to update (unless done so they actually look into the code)

    Instead of
    Code:java
    1. World world = Bukkit.getWorld("arenas." + keys + ".world");

    you need to do

    Code:java
    1. World world = Bukkit.getWorld(fc.getString("arenas."+keys+".world"));


    and in the createArena() method you are not saving the world there which might come in handy if you try to get it from the file on the loadArena() method ;)

    Edit: Oh and I just see. the complete loadArenas() Method is, the way it is right now not working if you ONLY set up the config file
     
    JPG2000 likes this.
  11. Offline

    xXMaTTHDXx

    Pieman456 Could you show me how to save the locations when using set locations, I am a bit confused! I think you got it to work so could you spread the knowledge.
     
  12. Offline

    Krotass

    Could someone help me?
    Code:java
    1. if (alias.equalsIgnoreCase("leave")) {
    2. ArenaManager.getManager().removePlayer(player, args[0]); //Would use our method made in our ArenaManager class, args[0] is the first argument they typed
    3. }


    It gives me an error at the player (player,args[o]); saying: player cannot be resolved to a variable. (same goes with the join command)

    I think this is because of my onCommand. Could someone tell me if this is true?


    OnCommand:
    Code:java
    1. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
     
  13. Offline

    Developing

    JPG2000 In the Arena Manager class , line 174. You can put
    Code:java
    1. arena.getPlayers().remove(s);

    instead of
    Code:java
    1. arena.getPlayers().remove(player.getName());


    Though it wouldnt make much of a difference , it is still shorter and faster.
     
  14. Offline

    JPG2000

    Developing Yeah, I missed that :p

    Krotass Everyone's first line of onCommand (besides the variable names) should be the same. Could you send me the whole method (onCommand)?

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

    Krotass

    JPG2000

    Errors:

    alias: alias cannot be resolved
    player: alias cannot be resolved
    getManager (forceend command): alias cannot be resolved

    Code:java
    1. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    2.  
    3.  
    4. if (!(sender instanceof Player)) {
    5. sender.sendMessage(ChatColor.GREEN + "Please use this command ingame");
    6. return true;
    7. }
    8.  
    9.  
    10. if (alias.equalsIgnoreCase("join")) {
    11. //We would have to check the arguments first, but lets just be lazy! :p
    12. ArenaManager.getManager().addPlayer(player, args[0]); //Would use our method made in our ArenaManager class, args[0] is the first argument they typed
    13. }
    14.  
    15. if (alias.equalsIgnoreCase("leave")) {
    16. ArenaManager.getManager().removePlayer(player, args[0]); //Would use our method made in our ArenaManager class, args[0] is the first argument they typed
    17. }
    18.  
    19. if (alias.equalsIgnoreCase("ForceStartArena")) {
    20. ArenaManager.getManager().startArena(args[0]); //Starts an arena
    21. }
    22.  
    23. if (alias.equalsIgnoreCase("ForceEndArena")) {
    24. ArenaManager.getManager.endArena(args[0]); //Ends an arena
    25. }
    26. }

    }
     
  16. Offline

    mydeblob

    Krotass
    Looks like you sort of copied the code. Change the "alias" to "cmd"
    You must also
    Code:java
    1. return true;

    On all your commands
    Edit:
    For example,
    Code:java
    1. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    2.  
    3.  
    4. if (!(sender instanceof Player)) {
    5. sender.sendMessage(ChatColor.GREEN + "Please use this command ingame");
    6. return true;
    7. }
    8.  
    9.  
    10. if (cmd.equalsIgnoreCase("join")) {
    11. //We would have to check the arguments first, but lets just be lazy! :p
    12. ArenaManager.getManager().addPlayer(player, args[0]); //Would use our method made in our ArenaManager class, args[0] is the first argument they typed
    13. return true;
    14. }
    15. return false;
    16. }
     
    JPG2000 likes this.
  17. Offline

    JPG2000

    Krotass Also check the args.length before you add the player to an argument, since it'll be null and thrown an error if the player typed one argument.
     
  18. Offline

    Krotass

    JPG2000 mydeblob

    I changed the code but the player section is not working (as before)

    Errors:
    player: player cannot be resolved to a variable

    Code:java
    1. if (cmd.getName().equalsIgnoreCase("join")) {
    2. if(args.length == 0)
    3. ArenaManager.getManager().addPlayer(player, args[0]);
    4. return true;
    5. }
     
  19. Offline

    JPG2000

    Krotass You don't have a player variable made. Create on:
    Code:java
    1. Player player = (Player) sender;


    Now, I would like to get in something. Firstly, I honestly think that what your creating is way beyond your skill level, and as good as it is to push your abilities, this one is not working. You really don't (from my understanding and research) understand the fundamentals of java. By fundamentals, I mean pure basics, such as variables and objects and methods. If you tried to learn the other things in java (and later on Bukkit) you could create this mini game, using your own systems that works, and do all this in a breeze.

    SIDE NOTE: I don't like this kind of lecture, because its you and your life. Your welcome to go ahead and stay on this track, but trust me, you'll grow (and most likely quit out of rage) 10 times slower then if you start off with eiser things.

    BASICLY: Take a break for this, go learn (I recommend thenewbostone) and work your way up.
     
  20. Offline

    Krotass

    JPG2000 I did not add this yes. The reason why is because it would give me an error in the addplayer selection as I think I said...
     
  21. Offline

    JPG2000

    Krotass That response made no sense. What I said is true; its erroring because you didn't have a player variable.

    BTW: Read my little short paragraph(s), its good advice man...
     
  22. Offline

    Krotass



    I did read it and yeah I will start looking in the his tutorials again. It's just a pain watching them and I kind lost track of them at episode 23 or something when I realized there was more than 80 tutorials. I'll stop using this and stop begging you about stuff.
     
  23. Offline

    JPG2000

    Krotass No no no. Thats not what I said. I said take your foot off of the petal. Just start with easier things, and questions are fine.
     
  24. Offline

    abc33

    JPG2000

    In ArenaManager (from line 215 to 217) you read the same value for the end location (always read endX var) from config:

    double endX = fc.getDouble("arenas." + "keys." + "endX");
    double endY = fc.getDouble("arenas." + "keys." + "endX");
    double endZ = fc.getDouble("arenas." + "keys." + "endX");

    The code would be the following:

    double endX = fc.getDouble("arenas." + "keys." + "endX");
    double endY = fc.getDouble("arenas." + "keys." + "endY");
    double endZ = fc.getDouble("arenas." + "keys." + "endZ");


    Anyway it's a very good tutorial. I'm using part of this code to write a plugin.
    If I have any suggestion I'll say here :)
    Keep up this work!!
     
  25. Offline

    Squid_Boss

    There is an error with the endPlayer method, in the for loop you call for arena.getPlayers() and then further down in the loop you have it remove the play from arena, causing an error. I fixed it by just removing that line, and after the loop I put this:
    Code:java
    1. arena.getPlayers().remove(arena.getPlayers());

    That should fix the error right up. :)
    PS: Honestly, I'm sure (Since arena.getPlayers() is an arraylist) you could probably just do this:
    Code:java
    1. arena.getPlayers().clear();

    Just to shorten it up even further.
     
  26. Offline

    Eballer48

    Suggestions:

    When adding a player to the arena, remove their active potion effects.
    Code:java
    1.  
    2. for (PotionEffect effect : player.getActivePotionEffects()) {
    3. player.removePotionEffect(effect.getType());
    4. }
    5.  

    and remember, grammar is important.
    Code:java
    1.  
    2. int playersLeft = arena.getPlayers().size();
    3. arena.sendMessage(player.getName() + " has left the Arena! " + playersLeft + (playersLeft==1?" player":" players") + " remain.");
    4.  
     
  27. Offline

    DrMedia

     
  28. Offline

    jusjus112

    JPG2000 or xTrollxDudex
    I have an question about the CreateArena method and the config!
    When edit your config, for example the null in your code.
    when i do
    Code:java
    1. Plugin p;
    2. FileConfiguration fc = plugin.getConfig();
    but it give me an nullpointerException!

    And question two: You have in the CreateArena Method, spawn points for join start and end!
    Code:java
    1. ArenaManager.getManager().createArena(args[0], player.getLocation(), player.getLocation(), player.getLocation(), i);
    2. // createArena(arena, joinlocation, startlocation, endlocation, maxplayers);

    But how do i sets those spawns not at the same time?
     
  29. Offline

    xTrollxDudex

    jusjus112
    Why did you tahg me, this isn't my thread. You also forgot to initialize 'p'
     
  30. Offline

    jusjus112

Thread Status:
Not open for further replies.

Share This Page