Need help with plugin

Discussion in 'Plugin Development' started by Ad237, May 7, 2013.

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

    Ad237

    I am currently having a bit of trouble with a plugin and I would appreciate it if you could take time out of your day to help me. Thank you.

    I am fairly new to making plugins and I have used tutorials to teach myself the basics. As a first project I set myself the task to create a Team Death match style plugin. Where two teams spawn in a base and fight to the death. I am currently trying to complete the team selection part. I currently have it set up so when a player types /team and then either red or blue they get teleported to that teams base and there spawn is set. However I believe this is a very bad way of doing it. For starters a player is able to change teams whenever they want (Something I don't want) and they are also able to kill members of their team. I also need a way for the server to tell if a team is full.

    Please could you help me fix these problems .

    Needed:
    Way to lock a command once used (/team)
    Way to disable pvp to members of team.
    Way to show that a team is full.

    I don't think the current code of my plugin is needed but if it is needed I will post it.

    Once again thank you for taking your time to read this and help me.

    Sorry for bump I know there quite annoying but I have waited the last 3 hours without reply and I am really hoping for some help. Thanks.

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

    Ad237

    Can anyone help?
     
  3. Offline

    Burnett1

    Add players to hash map when they choose a team with there name and the arena name (if there's more than one arena, if not just use a list) and then do a check along with the cmd.getName() to see if there ! in the hash map or list.
     
  4. Offline

    Ad237

    Ok thanks. I am going to add a HashMap to the plugin and I will edit my post if it works or not. Thanks.

    Sorry about this but after trying for around 3 hours I can't get it to work. I have tried using Hashmaps and lists but neither work. I would post the code but I stupidly deleted the file out of frustration. Is there any chance someone could give me an example of what I need to do. That would be great. Thanks.

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

    Burnett1

    Show me your code.
     
  6. Offline

    Ad237

    Ok I quickly re-wrote the code from earlier. This is what I have at the moment and it does not work. /join you then tell the server you want to start and then server assigns you to team. There is not much code for team selection at the moment cause I just want to get the basics to work before I move onto the more complicated stuff.
    Code:
    package me.Ad237.TDM;
     
    import java.util.ArrayList;
    import java.util.List;
    import java.util.logging.Logger;
     
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class tdm extends JavaPlugin{
        public final Logger logger = Logger.getLogger("Minecraft)");
        public static tdm plugin;
        List<String> red = new ArrayList<String>();
        List<String> blue = new ArrayList<String>();
     
        public void onDisable() {
            PluginDescriptionFile pdfFile = this.getDescription();
            this.logger.info(pdfFile.getName() + "Has been disabled!");
        }
     
        public void onEnable() {
            PluginDescriptionFile pdfFile = this.getDescription();
            this.logger.info(pdfFile.getName() + pdfFile.getVersion() + "Has been enabled!");
         
     
        }
     
        public boolean onCommand (CommandSender sender, Command cmd, String commandLabel, String [] args){
            Player player = (Player) sender;
            if(commandLabel.equalsIgnoreCase("join"))
                if(blue.size() == 0 || red.size() == 0)
                    blue.add(player.getName());
            return false;
     
        }
     
  7. Offline

    Burnett1

    Do you know any java?
     
  8. Offline

    Ad237

    I admit I am new to java but I have made other plugins successfully. Please don't insult my understanding of the language I am only asking for some help.
     
  9. Offline

    Burnett1

  10. Offline

    ktar5

    I agree, if you cant use a hashmap or list right, id suggest going back to the tutorials. (Btw its better to store the player not their name)
     
  11. Offline

    Ad237

    Ok thank you. I am now going through those videos Burnett1 sent me one by one to try and learn Java. Thanks for the help guys.
     
  12. Offline

    Burnett1

    ktar5 Just no. Never store a player. Always store there name it can cause memory leaks storing the player.
     
  13. Offline

    ktar5

    Burnett1 its never caused an issue for me
     
  14. Offline

    Burnett1

    Its always better to store the players names (unless you need to store the player for something). You only need there name.

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

    ktar5

    Well yeah, thats what i was having to do xD
     
  16. Offline

    Burnett1

    ktar5
    May i ask what you were doing with it?
     
  17. Offline

    ktar5

    I forget, it was something that had to do with teleporting (which i could have also used a string but i guess didnt feel like)
     
  18. Offline

    Paris Sky Fuja

    HAVE FUN CODING Also, ive made a few plugins of mah own (Not on bukkit) Ill try and get a working version out soon -- HAV FUN CODIN PPLZ
     
Thread Status:
Not open for further replies.

Share This Page