[Closed] I gotta figure it out on my own now, thanks for your help!

Discussion in 'Plugin Development' started by calebbfmv, Jul 28, 2012.

?

Do I post too much?

Yes. Figure it out on your own loser. -_- 5 vote(s) 33.3%
No, we like the question and the more people learning Java, the better. 10 vote(s) 66.7%
  1. Offline

    calebbfmv

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    OK, title may not be of use, but here it is: I am thinking about (depending on difficulty and time) that when someone asks "Can I be OP?" The server says Nope! then kicks the player. Possible hard?
  2. Offline

    turqmelon

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Code:
    @EventHandler
    public void onPlayerChat(PlayerChatEvent event){
        
        String m = event.getMessage();
        String mlow = m.toLowerCase();
     
        if (mlow.contains("Can I be OP?")){
            // Do Stuff
        }
    }
    
    Simple enough :p

    This post has been edited 2 times. It was last edited by turqmelon Jul 28, 2012.
  3. Offline

    travja

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Code:java
    1. @EventHandler
    2. public void onPlayerChat(PlayerChatEvent event){
    3. String msg = event.getMessage().toLowerCase();
    4. if(msg.contains("Can I be OP"){
    5. event.getPlayer().kick("No!");
    6. }
    7. }


    I think that's how you would do it.
  4. Offline

    calebbfmv

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    just a little fix:
    @EventHandler
    public void onPlayerChat(PlayerChatEvent event){
    String msg = event.getMessage().toLowerCase();
    if(msg.contains("Can I be OP")}{
    event.getPlayer().kick("No!");
    }
    }
    :)
    That works now I need to define .kick hmmm this is new to me
  5. Offline

    calebbfmv

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Who just said "yes" on the poll?
  6. Offline

    V10lator

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    @np98765 ^^
  7. Online

    np98765 43210 Moderator BukkitDev Staff

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    What? I can't help with this.... At all. -_- Sorry.

    Although I can say that NoobResponse does this. :p But I have no idea how to code this, sorry.

    This post has been edited 2 times. It was last edited by np98765 Jul 28, 2012.
  8. Offline

    V10lator

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Next time think bevore you vote if you see "Your vote will be publicly visible." :p
  9. Offline

    calebbfmv

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    It was meant as a joke :p
  10. Offline

    calebbfmv

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Lol, could you help out with the topic though?
  11. Online

    np98765 43210 Moderator BukkitDev Staff

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Oh, the poll! Yeah.. Google chrome isn't the easiest to use on iPhone. I've accidently voted wrong on another poll a few days ago, too, I think -_-

    But no, please -- ask questions. I reference here to answer my own questions. :p

    EDIT: Editing on iOS devices is so much harder... I despise using Bukkit on here. -_-

    This post has been edited 1 time. It was last edited by np98765 Jul 28, 2012.
  12. Offline

    calebbfmv

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Sureeeeee :p! Anyway, I need to kick someone when they ask for OP, now I think NoobRepsonse does it, but, I like making my own plugins :), So what should I do?
    @EventHandler
    public void onPlayerChat(PlayerChatEvent event){
    String msg = event.getMessage().toLowerCase();
    if(msg.contains("Can I be OP")){
    event.getPlayer().kick("No!");
    }

    }
    }

    (Besides all the onEnable/Disable things and the imports)
    but event is screwy and when I change it to Event getMessgae is screwy, am I being a total blonde right now?
  13. Offline

    V10lator

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Sure: change kick to kickPlayer ;)
  14. Offline

    Snipes01

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Tapatalk is great for viewing forums on iOS. http://tapatalk.com/
  15. Offline

    calebbfmv

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    It doesn't work! Nothing happens when the player type Can I be OP
  16. Offline

    V10lator

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Cause you're converting the message to lowercase and then compare it to a sentence with uppercase characters... ;)
  17. Offline

    calebbfmv

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Nope that doesn't work.....
  18. Offline

    V10lator

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    What doesn't work? What I meand was:
    String msg = event.getMessage().toLowerCase();
    this converts the message the player wrote to lowercase...
    if(msg.contains("Can I be OP"){
    these characters aren't lowercase, so the if will always return false as "can i be op" != "Can I be OP"...
  19. Offline

    calebbfmv

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    @EventHandler
    public void onPlayerChat(PlayerChatEvent event){
    String msg = event.getMessage();
    if(msg.contains("Can I be OP")){
    event.getPlayer().kickPlayer("No! We are not run by total noobs:)");
    }
    }

    }
  20. Offline

    V10lator

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    @calebbfmv Did you registerthe event? And why did you remove the toLowerCase() instead of checking against a lowercase sentence? Now I can write "can I be op" for example...
  21. Offline

    calebbfmv

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Misunderstood :D. Changed it! Now registering events? how would I do that? Sorry if I seem like a noob.
  22. Offline

    V10lator

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
  23. Offline

    calebbfmv

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    public class myPlyaerlistener extends JavaPlugin implements Listener {
    public void onEnable() {
    getServer().getPluginManager().registerEvents(new myPlyaerlistener(), this);
    }
    @EventHandler
    public void onPlayerChat(PlayerChatEvent event){
    String msg = event.getMessage().toLowerCase();
    if(msg.contains("can i be op")){
    event.getPlayer().kickPlayer("No! We are not run by total noobs:)");
    }
    }

    }
    ?
  24. Offline

    V10lator

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Almost:
    Code:java
    1. public class myPlugin extends JavaPlugin implements Listener
    2. {
    3. public void onEnable()
    4. {
    5. getServer().getPluginManager().registerEvents(this, this);
    6. }
    7.  
    8. @EventHandler
    9. public void onPlayerChat(PlayerChatEvent event)
    10. {
    11. String msg = event.getMessage().toLowerCase();
    12. if(msg.contains("can i be op"))
    13. event.getPlayer().kickPlayer("No! We are not run by total noobs:)");
    14. }
    15. }
  25. Offline

    calebbfmv

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Sweet I was close!!! Level Up!
  26. Offline

    calebbfmv

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Now for config changing the message it says when it kicks you, and what words are said to be kicked
  27. Offline

    calebbfmv

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    And exemptioning
  28. Offline

    calebbfmv

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Still nothing happens... do I have to do something else?
  29. Offline

    V10lator

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    If this is the only class you have (which is what main in your plugin.yml points to): No.
  30. Offline

    calebbfmv

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    YES IT WORKS!!! :D :D :D :D!!! Now to add config support for groups and what the message is!
    EDIT :O This seems hard

    This post has been edited 1 time. It was last edited by calebbfmv Jul 28, 2012.

Share This Page