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

    xTrollxDudex

    jusjus112
     
  2. Offline

    jusjus112

    I did, but not in my example
     
  3. Offline

    jusjus112

    JPG2000
    Can you help me with what i must set for the FileConfiguration?
    I've tried:
    Code:java
    1. Main p;
    2.  
    3. public void API(Main i){
    4. p = i;
    5. }
    6.  
    7. p.arenas();
    8. p.getConfig();
    9. this.getConfig();
    10. plugin.getConfig();

    I get the same error when i put this in it?
    PHP:
    10.01 09:38:11 [ServerINFO at org.bukkit.craftbukkit.v1_6_R3.CraftServer.dispatchCommand(CraftServer.java:528)
    10.01 09:38:11 [ServerINFO at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:192)
    10.01 09:38:11 [ServerINFO at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:23)
    10.01 09:38:11 [ServerINFO at org.bukkit.Bukkit.reload(Bukkit.java:277)
    10.01 09:38:11 [ServerINFO at org.bukkit.craftbukkit.v1_6_R3.CraftServer.reload(CraftServer.java:615)
    10.01 09:38:11 [ServerINFO at org.bukkit.craftbukkit.v1_6_R3.CraftServer.enablePlugins(CraftServer.java:266)
    10.01 09:38:11 [ServerINFO at org.bukkit.craftbukkit.v1_6_R3.CraftServer.loadPlugin(CraftServer.java:284)
    10.01 09:38:11 [ServerINFO at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:381)
    10.01 09:38:11 [ServerINFO at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:457)
    10.01 09:38:11 [ServerINFO at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:217)
    10.01 09:38:11 [ServerINFO at mgm.Main.onEnable(Main.java:25)
    10.01 09:38:11 [ServerINFO at mgm.ArenaManager.loadArenas(ArenaManager.java:128)
    10.01 09:38:11 [ServerINFO java.lang.NullPointerException
    10.01 09
    :38:11 [ServerSEVERE Error occurred while enabling Minigame v0.1 (Is it up to date?)
     
  4. Offline

    sockmonkey1

    jusjus112
    Put this in your main:
    Code:java
    1. public static JavaPlugin getJavaPlugin() {
    2. JavaPlugin plugin = tag.plugin;
    3. return plugin;
    4. }


    And then put this on top of your ArenaManager:
    Code:java
    1. public class ArenaManager {
    2. private static ArenaManager am = new ArenaManager();
    3. private JavaPlugin plugin = <YOURMIANCLASSNAMEHERE>.getJavaPlugin();


    Then you can just use plugin.getConfig(); Making the code less ugly and more clean.
     
  5. Offline

    calebbfmv

    Just something I was noticing.
    When you want to save the locations outside of the Bukkit config, like in a db file, or a regular .yml file, you need to call your save method after every
    Code:
    fc.set("ksjdklj');
    
    Something you might want to look into or find a fix, because I couldn't.

    FYI This is in ArenaManager.load(Arena a);
     
  6. Offline

    sockmonkey1

    If anyone was wanting to know how to use the createArena method and use different points. I kind of tweaked his method (Which is what I think JPG2000 wanted us to do), and I'm willing to share what I did to help other people. I made it so you have to use multiple commands to set up the arena (EX: /plugin create <arenaname> <maxplayers>, or /plugin setjoin <arenaname> and so on...)


    So if you take your createArena method and change it to this:

    Code:java
    1. public void createArena(String arenaName, int maxPlayers) {
    2.  
    3. // Now, lets create an arena object to represent it:
    4. @SuppressWarnings("unused")
    5. Arena arena = new Arena(arenaName, null, null, null, maxPlayers);
    6.  
    7. // Now here is where you would save it all to a file, again, im going to
    8. // create a null FileConfiguration, USE YOUR OWN!!!
    9. FileConfiguration fc = plugin.getConfig(); // USE YOUR OWN PUNK
    10.  
    11. fc.set("arenas." + arenaName, null); // Set its name
    12. String path = "arenas." + arenaName + ".";
    13. fc.set(path + "maxPlayers", maxPlayers);
    14. // Now sets the other values
    15. // Now save it up down here
    16. plugin.saveConfig();
    17. }

    Its a lot shorter because we removed all of the locations and stuff. You will want to tweak your commands to reflect this change. You'll want to make your command check for a longer length. Here is how I did it.

    Code:java
    1. if (args.length == 3) {
    2. if (args[0].equalsIgnoreCase("create")) {
    3. int i = Integer.parseInt(args[2]);
    4. ArenaManager.getManager().createArena(args[1], i);
    5. }

    So this is checking for the arena name and max players. At this point all it does is add it to the config file with the name and max players. Which is a good start but what if you didn't finish setting up the rest of the arena and someone tries to join it, They won't have a spawn and that will cause a lot of nullpointer errors. So lets add a check before the addPlayer method.
    Code:java
    1. public void addPlayers(Player player, String arenaName) {
    2.  
    3. if (getArena(arenaName) != null) { // If the arena exsists
    4.  
    5. Arena arena = getArena(arenaName); // Create an arena for using in
    6. // this method
    7. if (arena.getStartLocation() != null) {
    8. if (arena.getJoinLocation() != null) {
    9. if (arena.getitLocation() != null) {
    10. if (!arena.isFull()) { // If the arena is not full
    11.  
    12. if (!arena.isInGame()) {
    13. if (!arena.getPlayers().contains(
    14. player.getName())) {

    I suggest that you add a message at the end of the checks saying something like "This arena wasn't set up right, please tell an admin" So it doesn't just kick them without a message.

    Okay now that the possible errors are avoided, lets add the other spawns in.

    So I created several methods using what was in the createArena method before we removed it all. These methods will be called from your command just like createArena was.

    Code:java
    1. public void SetStart(String arenaName, Location startLocation) {
    2. FileConfiguration fc = plugin.getConfig();
    3. String path = "arenas." + arenaName + ".";
    4. fc.set(path + "startX", startLocation.getX());
    5. fc.set(path + "startY", startLocation.getY());
    6. fc.set(path + "startZ", startLocation.getZ());
    7. Arena arena = getArena(arenaName);
    8. arena.setStartLocation(startLocation);
    9. plugin.saveConfig();
    10. }
    11.  
    12. public void SetJoin(String arenaName, Location joinLocation) {
    13. FileConfiguration fc = plugin.getConfig();
    14. String path = "arenas." + arenaName + ".";
    15. fc.set(path + "joinX", joinLocation.getX());
    16. fc.set(path + "joinY", joinLocation.getY());
    17. fc.set(path + "joinZ", joinLocation.getZ());
    18. Arena arena = getArena(arenaName);
    19. arena.setJoinLocation(joinLocation);
    20. plugin.saveConfig();
    21. }
    22.  
    23. public void SetEnd(String arenaName, Location endLocation) {
    24. FileConfiguration fc = plugin.getConfig();
    25. String path = "arenas." + arenaName + ".";
    26. fc.set(path + "endX", endLocation.getX());
    27. fc.set(path + "endY", endLocation.getY());
    28. fc.set(path + "endZ", endLocation.getZ());
    29. Arena arena = getArena(arenaName);
    30. arena.setEndLocation(endLocation);
    31. plugin.saveConfig();
    32. }


    So to use this in the command just put it under the if (args.length == 2) {
    Code:java
    1. if (args.length == 2) {
    2. if (args[0].equalsIgnoreCase("join")) {
    3. Location loc = p.getLocation();
    4. p.getInventory().clear();
    5. ArenaManager.getManager().addPlayers(p, args[1]);
    6.  
    7. // Admin commands
    8.  
    9. } if (args[0].equalsIgnoreCase("start")) {
    10. ArenaManager.getManager().startArena(args[1]);
    11. } else if (args[0].equalsIgnoreCase("end")) {
    12. ArenaManager.getManager().endArena(args[1]);
    13. } else if (args[0].equalsIgnoreCase("create")) {
    14. p.sendMessage("§4use /tag create <arenaname> <max number>");
    15. } else if (args[0].equalsIgnoreCase("remove")) {
    16. ArenaManager.getManager().RemoveArena(p, args[1]);
    17. } else if (args[0].equalsIgnoreCase("setstart")) {
    18. ArenaManager.getManager().SetStart(args[1],
    19. p.getLocation());
    20. player.sendMessage("§2Added this to the start location.");
    21. } else if (args[0].equalsIgnoreCase("setjoin")) {
    22. ArenaManager.getManager().SetJoin(args[1],
    23. p.getLocation());
    24. p.sendMessage("§2Added this to the join location.");
    25. } else if (args[0].equalsIgnoreCase("setend")) {
    26. ArenaManager.getManager().SetIt(args[1],
    27. p.getLocation());
    28. p.sendMessage("§2Added this to the end location.");
    29. }


    This should add the extra points to your game. I also thought I should add this method I made that makes removing arenas a lot easier. And just add it to the commands under the args.length == 2 as well
    Code:java
    1. public void RemoveArena(Player player, String arenaName) {
    2. FileConfiguration fc = plugin.getConfig();
    3. String path = "arenas." + arenaName;
    4. fc.set(path, null);
    5. plugin.saveConfig();
    6. player.sendMessage("Arena removed.");
    7. Arena.arenaObjects.remove(getArena(arenaName));
    8. }


    Hope this helps some people!

    PS:
    I want to add that my post like 2 above this contains how I did the plugin.getConfig(); for the configuration thing.

    Best Regards ~
    Colin
     
    ledship likes this.
  7. Offline

    apple2114

    I like the tutorial. But i have 1 probablem which is that when a player disconnects he does not get removed from the arena he was in if you could help me that would be great :)

    also i have fixed some probablems with your code


    Arena class is the same

    heres the ArenaManager


    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.World;
    import org.bukkit.entity.Player;

    import wool.placer;
    import wool.remover;
    //replace all YourMainClass with your main class... lol
    public class ArenaManager{

    public static YourMainClass plugin;

    public ArenaManager(YourMainClass instance)
    {
    plugin = instance;
    }

    //A method for getting one of the Arenas out of the list by name:
    public static Arena getArena(String name){
    for(Arena a: Arena.arenaObjects){ //For all of the arenas in the list of objects
    if(a.getName().equals(name)){ //If the name of an arena object in the list is equal to the one in the parameter...
    return a; //Return that object
    }
    }
    return null; //No objects were found, return null
    }


    //A method for adding players
    public static void addPlayers(Player player, String arenaName){
    if(getArena(arenaName) != null){ //If the arena exsists
    Arena arena = getArena(arenaName); //Create an arena for using in this method
    if(!arena.isFull()){ //If the arena is not full
    if(!arena.isInGame()){
    if(!arena.getPlayers().contains(player.getName())){
    //Every check is complete, arena is joinable
    player.getInventory().clear(); //Clear the players inventory
    player.setHealth(20); //Heal the player
    player.setFireTicks(0); //Heal the player even more ^ ^ ^
    //Teleport to the arena's join location
    player.teleport(arena.getJoinLocation());
    //Add the player to the arena list
    arena.getPlayers().add(player.getName()); //Add the players name to the arena
    int playersLeft = arena.getMaxPlayers() - arena.getPlayers().size(); //How many players needed to start
    //Send the arena's players a message
    arena.sendMessage(ChatColor.BLUE + player.getName() + " has joined the arena! We only need " + playersLeft + " to start the game!");
    if(playersLeft == 0){ //IF there are 0 players needed to start the game
    startArena(arenaName); //Start the arena, see the method way below :)
    plugin.start(arenaName);
    }
    }
    }else{ //Specifiend arena is in game, send the player an error message
    player.sendMessage(ChatColor.RED + "The arena you are looking for is currently full!");
    }
    }else{ //Specified arena is full, send the player an error message
    player.sendMessage(ChatColor.RED + "The arena you are looking for is currently full!");
    }
    }else{ //The arena doesn't exsist, send the player an error message
    player.sendMessage(ChatColor.RED + "The arena you are looking for could not be found!");
    }
    }


    //A method for removing players
    public static void removePlayer(Player player, String arenaName){
    if(getArena(arenaName) != null){ //If the arena exsists
    Arena arena = getArena(arenaName); //Create an arena for using in this method
    if(arena.getPlayers().contains(player.getName())){ //If the arena has the player already
    //Every check is complete, arena is leavable
    player.getInventory().clear(); //Clear the players inventory
    player.setHealth(20); //Heal the player
    player.setFireTicks(0); //Heal the player even more ^ ^ ^
    //Teleport to the arena's join location
    player.teleport(arena.getEndLocation());
    //remove the player to the arena list
    arena.getPlayers().remove(player.getName()); //Removes the players name to the arena
    //Send the arena's players a message
    arena.sendMessage(ChatColor.BLUE + player.getName() + " has left the Arena! There are " + arena.getPlayers().size() + " players currently left!");
    if(arena.getPlayers().size() <= 1){
    endArena(arenaName);
    }
    }else{ //Specified arena doesn't have the player, send the player an error message
    player.sendMessage(ChatColor.RED + "Your not in the arena your looking for!");
    }
    }else{ //The arena doesn't exsist, send the player an error message
    player.sendMessage(ChatColor.RED + "The arena you are looking for could not be found!");
    }
    }


    //A method for starting an Arena:
    public static void startArena(final String arenaName) {
    if (getArena(arenaName) != null) { //If the arena exsists
    Arena arena = getArena(arenaName); //Create an arena for using in this method
    arena.sendMessage(ChatColor.GOLD + "The arena has BEGUN!");
    //Set ingame
    arena.setInGame(true);
    for (String s: arena.getPlayers()) {//Loop through every player in the arena
    Bukkit.getPlayer(s).teleport(arena.getStartLocation());//Teleports the player to the arena start location
    //Do custom stuff here, like give weapons etc, but for the purpose of this tutorial, i'll do nothing
    //Set inGame
    }
    }
    }

    //A method for ending an Arena:
    public static void endArena(final String arenaName){
    if (getArena(arenaName) != null) { //If the arena exsists
    Arena arena = getArena(arenaName); //Create an arena for using in this method
    //Send them a message
    arena.sendMessage(ChatColor.GOLD + "The arena has ended :(");
    //Set ingame
    arena.setInGame(false);
    for (String s: arena.getPlayers()) {//Loop through every player in the arena

    //Teleport them:
    Player player = Bukkit.getPlayer(s); //Create a player by the name
    player.teleport(arena.getEndLocation());

    player.getInventory().clear(); //Clear the players inventory
    player.setHealth(20); //Heal the player
    player.setFireTicks(0); //Heal the player even more ^ ^ ^

    arena.getPlayers().remove(s);
    placer.whiteplace(arenaName);
    placer.blackplace(arenaName);
    placer.redplace(arenaName);
    placer.orangeplace(arenaName);
    placer.yellowplace(arenaName);
    placer.greenplace(arenaName);
    placer.cyanplace(arenaName);
    placer.blueplace(arenaName);
    placer.magentaplace(arenaName);
    }
    }
    }



    //Loading the arenas
    public static void loadArenas(){
    for (String keys : plugin.getConfig().getConfigurationSection("arenas").getKeys(false)){
    World JoinWorld = Bukkit.getServer().getWorld(plugin.getConfig().getString("arenas." + keys + ".joinWorld"));
    double JoinX = plugin.getConfig().getDouble("arenas." + keys + ".joinX");
    double JoinY = plugin.getConfig().getDouble("arenas." + keys + ".joinY");
    double JoinZ = plugin.getConfig().getDouble("arenas." + keys + ".joinZ");
    Location joinLocation = new Location(JoinWorld, JoinX, JoinY, JoinZ);

    World StartWorld = Bukkit.getServer().getWorld(plugin.getConfig().getString("arenas." + keys + ".startWorld"));
    double StartX = plugin.getConfig().getDouble("arenas." + keys + ".startX");
    double StartY = plugin.getConfig().getDouble("arenas." + keys + ".startY");
    double StartZ = plugin.getConfig().getDouble("arenas." + keys + ".startZ");
    Location startLocation = new Location(StartWorld, StartX, StartY, StartZ);

    World EndWorld = Bukkit.getServer().getWorld(plugin.getConfig().getString("arenas." + keys + ".endWorld"));
    double EndX = plugin.getConfig().getDouble("arenas." + keys + ".endX");
    double EndY = plugin.getConfig().getDouble("arenas." + keys + ".endY");
    double EndZ = plugin.getConfig().getDouble("arenas." + keys + ".endZ");
    Location endLocation = new Location(EndWorld, EndX, EndY, EndZ);

    int maxPlayers = plugin.getConfig().getInt("arenas." + keys + ".maxPlayers");
    Arena arena = new Arena(keys, joinLocation, startLocation, endLocation, 2);
    }
    }

    public static void joinCreate(String arenaName, Location joinLocation){
    plugin.getConfig().set("arenas." + arenaName + ".joinWorld", joinLocation.getWorld().getName());
    plugin.getConfig().set("arenas." + arenaName + ".joinX", joinLocation.getBlockX());
    plugin.getConfig().set("arenas." + arenaName + ".joinY", joinLocation.getBlockY());
    plugin.getConfig().set("arenas." + arenaName + ".joinZ", joinLocation.getBlockZ());
    plugin.saveConfig();
    }

    public static void startCreate(String arenaName, Location startLocation){
    plugin.getConfig().set("arenas." + arenaName + ".startWorld", startLocation.getWorld().getName());
    plugin.getConfig().set("arenas." + arenaName + ".startX", startLocation.getBlockX());
    plugin.getConfig().set("arenas." + arenaName + ".startY", startLocation.getBlockY());
    plugin.getConfig().set("arenas." + arenaName + ".startZ", startLocation.getBlockZ());
    plugin.getConfig().set("arenas." + arenaName + ".maxPlayers", 2);
    plugin.saveConfig();
    }

    public static void endCreate(String arenaName, Location endLocation){
    plugin.getConfig().set("arenas." + arenaName + ".endWorld", endLocation.getWorld().getName());
    plugin.getConfig().set("arenas." + arenaName + ".endX", endLocation.getBlockX());
    plugin.getConfig().set("arenas." + arenaName + ".endY", endLocation.getBlockY());
    plugin.getConfig().set("arenas." + arenaName + ".endZ", endLocation.getBlockZ());
    plugin.saveConfig();
    }
    }





    and implement this go to your main class and add right under on enable ArenaManager.plugin = this; and add public static yourmainclass plugin; right under the public class YOURMAINCLASSextends JavaPlugin implements Listener{ in your main class

    also with any minigame plugin you need a Listener for a players death i persinally dont know how ide get the arena the players in

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

    calebbfmv

    apple2114
    Do you even [tag]?
    To do that, create a method with a for loop of arenas, a for loop of players IN the arenas, then return which one he is in:
    This is how I do it:
    Code:
        public static boolean hasPlayerPlus(Player player) {
            for (Arena a : arenas) {
                for (String s : a.getPlayers()) {
                    Player p = Bukkit.getPlayer(s);
                    if (player.getName().equalsIgnoreCase(p.getName())) {
                        return player.getName().equalsIgnoreCase(p.getName());
                    }
                }
            }
            return false;
        }
    
        public static Arena get(Player player) {
            for (Arena a : arenas) {
                for (String s : a.getPlayers()) {
                    if (player.getName().equalsIgnoreCase(s)) {
                        return a;
                    }
                }
            }
            return null;
        }
    
    JPG2000
    Hey man, I was noticing the lack of converting methods for you locations, so the file gets loaded with X, Y, and Z for each point, which could get messy, so here are some ones I wrote that you might want to use:
    Code:
        public static Location convertString(String str){
            String[] string = str.split(",");
            String world = string[0];
            double x = Integer.parseInt(string[1]);
            double y = Integer.parseInt(string[2]);
            double z = Integer.parseInt(string[3]);    
            float pitch = Integer.parseInt(string[4]);
            float yaw = Integer.parseInt(string[5]);
            Location loc = new Location(Bukkit.getWorld(world), x, y, z, pitch, yaw);
            return loc;
        }
    
        public static String convertLoc(Location loc){
            String world = loc.getWorld().getName();
            int x = loc.getBlockX();
            int y = loc.getBlockY();
            int z = loc.getBlockZ();
            int pitch = (int) loc.getPitch();
            int yaw = (int) loc.getYaw();
            return new String(world + "," + x + "," + y + "," + z + "," + pitch + "," + yaw);
        }
    
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  9. Offline

    apple2114

    alright thank you :) thow im doing a game like color match if you have ever heard of it and i kinda dont want a loop so could i just kick them every game?
    using something like at end of game or / timer do "arena.getPlayers().clear()"

    also why do you use equalsIgnoreCase i mean you dont need it when it copies the name it does keep all caps and letters and lowercase so you dont need that jsuk

    also i dident know how to tahg now i do thank you :) i also could use pastebin but oh well

    1 last thing u put in the loop thingy u used arenas and that does give an error...

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

    xTrollxDudex

    apple2114
    Holy crap. Lrn2Edit. Learn to talk like a normal person instead of lik txting 2 some1 lik dis. Being a tutorial, you can edit this on your own, equalsIgnoreCase can be changed at your own discretion.
     
    JPG2000 likes this.
  11. Offline

    calebbfmv

  12. Offline

    apple2114

    haha. Do you have a fix for the arenas section in your code you sent me?

    also i noticed a fatle error in the arena manager code which i cant fix the error is line 116 which is the line for(String s: arena.getPlayers()){//Loop through every player in the arena that error only accers the 2nd time i play the arena the first time it works great

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

    sockmonkey1

    apple2114
    Your line 116 is different from probably everyone's line 116. Please post the arenaManager file inside the [syntax = java] So we can read it instead of spamming the forum wit all your code un-numberd and very spread out.

    If line 116 is the end arena and the error is a concurent one, that is caused by that methood removing players from the list then checking the list agian. I noticed the error apon using this class to. I corrected the problem by chaning it to:

    Code:java
    1. public void endArena(String arenaName) {
    2.  
    3. if (getArena(arenaName) != null) {
    4. Arena arena = getArena(arenaName);
    5. arena.sendMessage("§cThe arena has ended");
    6. ArrayList<String> players = new ArrayList<String>(
    7. arena.getPlayers());
    8. for (String s : players) {
    9. Player player = Bukkit.getPlayer(s);
    10. player.getInventory().clear();
    11. player.teleport(arena.getJoinLocation());
    12. player.setGameMode(GameMode.SURVIVAL);
    13. player.setSaturation(100000);
    14. player.setHealth(20.0);
    15. player.setFireTicks(0);
    16. arena.getPlayers().remove(s);
    17. }
    18. arena.setInGame(false);
    19. }
    20. }

    note the "[syntax = java]", and the tag...
    ;P

    EDIT: Even if this isn't you line 116, you probably should fix this. As I'm sure you'll come across this error anyway.
     
  14. Offline

    apple2114

    see i used a different way to end the game i did 2 lines ArenaManager.getArena(arenaName).getPlayers().clear();
    and ArenaManager.getArena(arenaName).setInGame(false); thow i dont have a teleportation thing added but for my minigame its not a big deal

    thow if you want players to be teleported heres how you would do it
    Code:java
    1. for(final Player online : Bukkit.getServer().getOnlinePlayers()){
    2. if(ArenaManager.getArena(arenaName).getPlayers().contains(online.getName())){
    3. online.teleport(ArenaManager.getArena(arenaName).getEndLocation());


    Does anyone know how to stop a repeating task for one arena like this. instead of stopping every other arenas task also.
    Code:java
    1. static int timer;
    2.  
    3. public void onTest(Player player){
    4. Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(public, new Runnable(){ public void run(){ Bukkit.getServer().getScheduler().cancelTask(timer);}}, 50L);
    5. }


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

    sockmonkey1

    The answer is here Mr.NoTags, apple2114.

    I wouldn't suggest doing it this way. Waste of memory. You don't need to go through EVERY player in the server and see if they are a small group in this arena. In the Arena.java there is a getPlayers() fuction for that reason. You can get just the players that you need, not all of them.

    EDIT: Thanks for using the syntax=java.

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

    apple2114

    alright :) thank you sooooo much my color match custom plugin should now work 100%

    so in this line
    Code:java
    1. BukkitTask task = new ExampleSelfCancelingTask(this.plugin, 5).runTaskTimer(this.plugin, 10, 20);
    is the 5 telling it to run 5 times then stop?

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

    JPG2000

    Hello guys,

    I've been AFK for a while, and probably won't be back. I've decided to stop creating bukkit plugins.

    Anyways i've seen this thread has grown a lot, and thank you all to the people responding the the abundant questions.
     
  18. Offline

    SuperOmegaCow

    apple2114 too dangerous to google alone. It is better to google together.
     
  19. Offline

    apple2114

    lol most of the things you have for tutorials arnt all that hard except this one, atleast i think otherwise thank you for your help :)
     
  20. Offline

    sockmonkey1

    Yes and no. It depends on what you have in your run method. I think the selfCancellingTask from the example I sent uses a counter to cancel the plugin. If you want the run method to cancel, you'll have to find your own way to cancel it. apple2114


    JPG2000
    Welcome back! I just want to say that your tutorials have made me a better plugin developer. Thank you so much.
     
  21. Offline

    PatoTheBest

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

    Location endLocation = new Location(world, endX, endY, endZ);

    int maxPlayers = fc.getInt("arenas." + keys + ".maxPlayers");
     
  22. Offline

    ItsLeoFTW

    This is awesome!!!!

    How would I load the configuration file "config.yml" with the "FileConfiguration fc" code? Can't seem to get it

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

    PatoTheBest

    FileConfiguration fc = Main.getConfig()
     
  24. Offline

    sockmonkey1

  25. Offline

    ItsLeoFTW

    One other thing-- would it be possible to join arenas through signs? I've seen other servers do this, but I don't know how.
     
  26. Offline

    Windy Day

    Listen for when a player right clicks a sign. If the first line is something like [gamename] then get another line either 2,3, or 4 which should be set as an arena name. Then if you are using his ArenaManager do arenamanger.getArenaManager().getArena(LineFromSignThatIsAnArenaName) and add the player that clicked the sign.
     
    ItsLeoFTW likes this.
  27. Offline

    apple2114

    go to your main class add this to it
    Code:
    public static MAINCLASS plugin;
     
    @Override
    public void onEnable(){
      plugin = this;
    }
    then go to the ArenaManager class and add this
    Code:
        public static MAINCLASS plugin;
           
        public ArenaManager(MAINCLASS instance)
        {
          plugin = instance;
        }
    and replace all the public then_something with public static something
     
  28. Offline

    ever_x

    I know it's probably quite basic and I'm simply screwing something up, but I can't seem to be able to save the arenas to a config. I've created the Main Class statically in the ArenaManager and then done
    Code:java
    1. plugin.getConfig();
    and
    Code:java
    1. plugin.saveConfig();
    but it won't save the arenas to a file! Is there anything basic that I might be doing wrong?

    Edit:
    I was experimenting and found out you could do
    Code:java
    1. fc.save();

    instead of
    Code:java
    1. plugin.saveConfig();

    Is this the right way to do it and if so how would you create a file (it takes in a file, not a FileConfiguration)? Thank you for any help!
     
  29. Offline

    sockmonkey1

    I suggest this. I use it all the time.
     
  30. Offline

    ever_x

    Thank you very much I shall try this and see if it works!
     
Thread Status:
Not open for further replies.

Share This Page