A few questions needed to be answered!

Discussion in 'Plugin Development' started by Epixpenguin, Apr 25, 2014.

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

    Epixpenguin

    Ok, I've got a few questions that I need answered to help make a few plugins for my server.
    1) How can you reset a minigame arena? Could I do a world restart or something else?
    2) How can I generate a chunks of land like in skyblock?
    3) How to teleport a random player to a location and to do the same with more players without teleporting a player again?
    Thanks for the help!
     
  2. Offline

    BillyGalbreath

    1 and 2 use worldedit api.

    3 iterate list of players and generate random location each iteration.
     
  3. Offline

    Epixpenguin

    Will this work, still kind of new to plugins. Also I don't know how to get source code, but I know how to generate a cube like worldedit. Would it be like that but on a higher scale?
    Code:java
    1. for(Player p : Bukkit.getOnlinePlayers()){
    2. p.teleport(location);
    3. }
     
  4. Offline

    BDKing88

    Epixpenguin That would teleport everyone online, you need to make it choose a random player from the online players.
     
  5. Offline

    Epixpenguin

    So how would I do that? Btw, the plugin will be on a separate server where it will be used for only about 6-12 players/
     
  6. Offline

    BDKing88

    Epixpenguin Like BillyGalbreath said, you have to iterate through the online players and randomly select one. Then once that person is selected, add them to a list and check through that list and make any in it not able to be randomly selected again.
     
  7. Offline

    Epixpenguin

    BDKing88 well I still a noob at plugins so I didn't know what he meant by iterate through the players.
     
  8. Offline

    BDKing88

    Epixpenguin Iterate through the players means go through the players.
     
  9. Offline

    Epixpenguin

    I know what iterate means but as in the code to iterate players.

    BDKing88
    Anyways you shouldn't act so ignorant at someone if they don't know how to code something. Just because they don't know it means you should show them how to do it instead so they don't fail at coding.

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

    xTigerRebornx

    Epixpenguin You could use Java's Random class for generating a random number to use to get a random Player from Bukkit#getOnlinePlayers()
    And for WorldEdit API, you'd simply go and look for WorldEdit's javadocs (or source-code) for the API, something a simple google search can find
     
  11. Offline

    Epixpenguin

    xTigerRebornx
    So like creating a random?
    Code:java
    1. class pineapple{
    2. public void static main(String args()){
    3. Random r = new Random();
    4. int i = 0;
    5. i = r.nextInt(2);
    6. switch(i){
    7. case 1:
    8. System.out.println("One");
    9. case 2:
    10. System.out.println("Two");
    11. }
    12. }
    13. }


    Also what about resetting a map in a minigame, like spleef?

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

    Wizehh


    PHP:
    Player getRandomPlayer() {
        
    Player[] playerArray;
        
    playerArray Bukkit.getOnlinePlayers();
        return 
    playerArray[new Random().nextInt(playerArray.length)];
    }
    As for the resetting of the map, I would turn off world-saving, then restart the server when the game is finished.
     
  13. Offline

    BDKing88

    Epixpenguin I'm not acting ignorant. I'm just not going to spoon feed you through every step, you'll never learn anything that way.
     
    BillyGalbreath likes this.
Thread Status:
Not open for further replies.

Share This Page