Help,confusion of the masses(or just me :)

Discussion in 'Plugin Development' started by blankpurple, Dec 22, 2011.

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

    blankpurple

    My question is how do i create a statement that says if player name is in join2 then he cannot use command Heres what i have:



    Class : Npluginjoin1

    package me.pd109.Nplugin;

    import java.util.HashMap;
    import java.util.Map;

    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;

    public class Npluginjoin1 implements CommandExecutor{
    public Map<Integer, String> team1 = new HashMap<Integer, String>();
    public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    Player player = (Player) sender;
    if (commandLabel.equalsIgnoreCase("join1")) {
    if HashMap join2.containsKey(player.getName()) //errrors here
    team1.put(Integer.parseInt(args[0]), player.getName());
    }
    return true;
    }
    }

    Class: Npluginjoin2

    package me.pd109.Nplugin;

    import java.util.HashMap;
    import java.util.Map;

    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;

    public class Npluginjoin2 implements CommandExecutor{

    public Map<Integer, String> team2 = new HashMap<Integer, String>();
    public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    Player player = (Player) sender;
    if (commandLabel.equalsIgnoreCase("join2")) {
    team2.put(Integer.parseInt(args[0]), player.getName());
    }
    return true;
    }


    }
     
  2. Offline

    Sagacious_Zed Bukkit Docs

    @blankpurple
    I suggest you learn Java before you start programming plugins.
    Code:
    if HashMap join2.containsKey(player.getName())
    is not valid java syntax.

    The following what you want to write. Please not however, your IDE will complain that it cannot find join2 the variable until you declare it.
    Code:
    join2.containsKey(player.getName())
     
  3. Offline

    blankpurple

    The problem is it keeps not recognizing join2 so how do i connect it to the other class file
     
  4. Offline

    unicode21B9

    1. You should not start two threads for the same issue.
    2. I posted the answer on your other thread.
     
Thread Status:
Not open for further replies.

Share This Page