Username Verification/ Test For A Username

Discussion in 'Plugin Development' started by WadetheStealth, Sep 1, 2014.

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


    Hey guys, I have a problem. I am trying to make it to where only if i right click it does an effect, but it doesn't work if i don't comment out the username. I also would like to know how I could implement a config file to change the person it works for.
    1. package com.frozenbattles.ExtraPriv;
    3. import org.bukkit.Effect;
    4. import org.bukkit.entity.Player;
    5. import org.bukkit.event.EventHandler;
    6. import org.bukkit.event.Listener;
    7. import org.bukkit.event.block.Action;
    8. import org.bukkit.event.player.PlayerInteractEvent;
    9. import;
    11. public class ExtraPriv extends JavaPlugin implements Listener{
    13. public void onEnable(){
    14. getLogger().info("ExtraPriv Enabled! :)");
    15. getServer().getPluginManager().registerEvents(this, this);
    16. }
    18. public void onDisable(){
    19. getLogger().info("ExtraPriv Disenabled! :(");
    20. }
    22. @EventHandler
    23. public void PlayerInteractEvent(PlayerInteractEvent event) {
    24. if(event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR){
    25. Player player = event.getPlayer();
    26. String playerName = player.getPlayerListName();
    28. //if(playerName == "WadetheStealth"){
    29. player.getLocation().getWorld().playEffect(player.getLocation().add(0, -1, 0), Effect.MOBSPAWNER_FLAMES, 1);
    30. player.sendMessage(playerName);
    31. //}
    32. }
    33. }
    34. }
  2. Offline


    hintss likes this.
  3. Offline


    String line "foo";
    line.equals("foo") {
    System.out.println("line equals foo !!!");
    as Totom3 said you cannot compare a string using equal operator, you need to use the built in method .equals()
  4. Offline


    That's one of the five very first things you learn when you learn java.... Seems like you still have to learn java!
    Don't try to make bukkit plugins without java knowledge.
    hintss and Totom3 like this.
  5. Offline


    Try creating a String and set it to the value within getConfig().getString("<String Path>").

    From there, create a Player and set it to the value of the clicker using event.getPlayer().getName().

    Here is what I use for one of my custom development plugins:

    public void onInteract(PlayerInteractEvent event){
    String player = event.getPlayer().getName();
    String allowed = getConfig().getString("Server.emergency");
    if(!(player.equalsIgnoreCase(allowed))) return;
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 10, 2016
  6. Offline


    RenditionsRule Zupsub Jace_oio Totom3
    Everyone on here thanks for the help and yeah my java knowledge isn't the best i really haven't worked with thing like this.

    btw a forum is for helping someone not putting them down

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


    He was just saying that you should probably know java before attempting to do bukkit plugins...
Thread Status:
Not open for further replies.

Share This Page