plugin.yml HELP!?!?

Discussion in 'Plugin Development' started by Bobfan, Aug 10, 2012.

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

    Bobfan

    How would I put this command in the plugin.yml?
    Code:
    String QuestName;
        HashMap <String, Boolean> Sign = new HashMap <String, Boolean> ();
       
        public boolean onCommand(CommandSender sender1, Command command, String commandLabel, String[] args) {
            Player p = (Player) sender1;
           
            if(command.getName().equalsIgnoreCase("New Quest " + QuestName)) {
     
  2. What is the command you want?? you just give me a piece of code i can't do anything with, if you want an answer you have to ask a little bit better questions xD
     
  3. Offline

    Firefly

    Commands can't have more than one word. Commands work like this: The first word is the command itself (what you put in plugin.yml) all the words after that are stored in the String[] args.

    I suggest reading the plugin tutorial if you are still confused.
     
    blackwolf12333 likes this.
  4. Offline

    pzxc

    You could put the command "new" as a command for your plugin, then check if (args[0].equals("quest")) and lookup args[1] to see if it is a valid quest name.
     
  5. Offline

    Bobfan

    I think I fixed it:
    Code:
    package me.Bobfan.RPG;
     
    import java.io.File;
    import java.util.HashMap;
    import java.util.Map;
     
    import org.bukkit.Material;
    import org.bukkit.World;
    import org.bukkit.block.Block;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Fireball;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.plugin.java.JavaPlugin;
     
    @SuppressWarnings("unused")
    public class QuestMaker extends JavaPlugin {
     
        String QuestName;
        HashMap <String, Boolean> Sign = new HashMap <String, Boolean> ();
     
        public boolean onCommand(CommandSender sender1, Command command, String commandLabel, String[] args) {
            Player p = (Player) sender1;
       
            if(command.getName().equalsIgnoreCase("NewQuest ")) {
                if (args.length == 1) {
                if (Sign.containsKey(p.getName())) {
                    Sign.remove(p.getName());
                } else {
                    p.sendMessage("You need to set a name first");
                }
                } else {
                    Sign.put(p.getName(), true);
                    p.sendMessage("Click your sign you want for the quest");
                }
                return true;
            }
            return false;
        }
     
        @EventHandler
        public void onInteractEvent(PlayerInteractEvent event) {
            Player p = event.getPlayer();
            if(Sign.containsKey(p.getName())) {
            if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
                Block b = event.getClickedBlock();
                if(b.getType() == Material.SIGN_POST || b.getType() == Material.WALL_SIGN) {
                    int x = event.getClickedBlock().getX();
                    int y = event.getClickedBlock().getY();
                    int z = event.getClickedBlock().getZ();
                    Sign.put(p.getName(), false);
               
                    p.sendMessage("Your quest is created, edit it in any text edit");
               
                    //File file3 = new File(getDataFolder() + File.separator + "" + QuestName + ".yml");
                    }
                }
            }
        }
    }
    
    How would you put that command into my plugin.yml?

    -edit, still working on the separate folder thing, I know how to do it, just haven't got to it yet
     
Thread Status:
Not open for further replies.

Share This Page