Multiple questions

Discussion in 'Plugin Development' started by rob1998@, Jan 23, 2014.

Thread Status:
Not open for further replies.
  1. Hello I'm working on a new minigame plugin and I have a few questions:
    1. I want that players have to wait 60 seconds in the lobby, during this time they see a countdown in the chat.
    2. I want them to random spawn on spawns that are set. I already have the code for setting the spawns, I just need the random spawning part.
    3. When the host of the minigame sends the command to end all players ingame(not all online players) should be teleported back to their previous location. The teleport part I already have but how to get all players?

    I stored the names of the ingame players in a array list.
    Please give me some examples for these things.
     
  2. Offline

    Shockwave317

    rob1998@
    1. Dude not that hard go take a look (Scheduler)
    2. not sure but I would number each player that joins with a number then the spawn allocated to that number they teleport to (I can think of several ways to do this)
    3. when the people join add them into a hashmap or config then when the end command is run grab there names from the hashmap or config....
    Hope this helps...
     



  3. 1. I know but how to add the countdown?
    2. oke, thanks.
    3. I have my HashMap like this:

    public static HashMap<String, Integer> ingame = new HashMap<String, Integer>();
    How do I get the player names from it?
     
  4. Offline

    Shockwave317

    rob1998@
    This is just out of my brain but try
    Code:java
    1. if (ingame.contains(getServer().getOnlinePlayers()) {
    2. //code
    3. }
     
  5. doesn't work.

    I fixed 2 and 3, please tell me how to show a countdown in a delayed task?

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

    Shockwave317

  7. I know, I now have something like this:
    Code:java
    1.  
    2. int task = getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){
    3. int remaining = 60;
    4. @Override
    5. public void run(){
    6. if (remaining == 60){
    7. Bukkit.broadcastMessage("[GunGame] The game will start in 1 minute!");
    8. }
    9. else if (remaining == 45){
    10. Bukkit.broadcastMessage("[GunGame] The game will start in " + remaining + " seconds!");
    11. }
    12. else if (remaining == 30){
    13. Bukkit.broadcastMessage("[GunGame] The game will start in " + remaining + " seconds!");
    14. }
    15. else if (remaining == 15){
    16. Bukkit.broadcastMessage("[GunGame] The game will start in " + remaining + " seconds!");
    17. }
    18. else if (remaining < 11 && remaining > 0){
    19. for (Player pl : ingame.keySet()) {
    20. Bukkit.broadcastMessage("[GunGame] The game will start in " + remaining + " seconds!");
    21. pl.playSound(pl.getLocation(),Sound.CLICK, 100F, 2.0F);
    22. }
    23. }
    24. else if (remaining == 0){
    25. Bukkit.getScheduler().cancelTask(task);
    26. }
    27. remaining--;
    28. }
    29. },0L, 20L);


    But it says I need to change task to final, but then it gives another error. I searched on this forum and tried many different ways, but non of them helped me..
     
  8. Offline

    sockmonkey1

    I'm 80% sure you're not doing the minigames right. Take a look at this. And look at my post at the very last page that explain how to use multiple teleport points.
    The tutorial (By Jpg2000) is on how to make a minigames plugin with arenas (and they have names not numbers).
    Also tahg me in that thread if you need help.
     
  9. I don't have multiple arena's, I have 1 arena with multiple spawns (each player has a spawn)
     
  10. Offline

    sockmonkey1

    Oh. I still suggest that, should you ever want to add more than one its a quick command. And you also get the ease of just going;
    Code:java
    1. Arena arena = ArenaManager.getManager.getArena(a);
    2. player.telelport(arena.getLoc1());
     
Thread Status:
Not open for further replies.

Share This Page