Solved How do i send a message to all users WITHOUT a permission.

Discussion in 'Plugin Development' started by SleepyDog, Oct 19, 2014.

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

    SleepyDog

    I am creating a simple 'Clear The Chat' plugin for my server, however i need to have a command that will clear the chat of all users unless they have the permission 'ClearTheChat.bypass'

    It will work like this;

    if player sends command 'command'{
    for players without permission 'ClearTheChat.bypass'{
    bukkit.broadcast(" ")

    }
    for players with permission 'ClearTheChat.bypass'{

    }
    bukkit.broadcast(''message'')

    }


    I know this will not work, just an example of what i want it to do, can you help?

    thanks -sleepy
     
  2. Offline

    CraftCreeper6

    SleepyDog
    Loop through all the online players with a for loop.
    Check if the player has permission.

    If they do {
    do this...
    }else {
    do this...
    }
     
  3. Offline

    SleepyDog

    This is my second plugin, is there some demo code i can see? Honestly i just make the plugins for the point of making them, coding just gives you that feeling that you can do anything.
     
  4. Offline

    VG.Developments

    Just doing this off the top of my head, probably mistakes:
    For(player play : bukkit.getOnlinePlayers)
    If(play.haspermission("chat bypass"){
    //stuff
    }else if(!play.haspermission(chat.bypass)){
    //stuff

    Typed on ipad aswell :p
    SleepyDog
     
  5. Offline

    CraftCreeper6

    SleepyDog
    Lol, in a way yes, but I am not spoonfeeding you. You are not going to learn by people spoonfeeding you, trust me. Do you know what a for loop is? If not just click here
    It's just a tutorial on for loops.

    To check if the player has permission you can easily utilise Bukkit' methods:
    player.hasPermission("MyPermission");

    If the player does then you can
    do this...
    else
    do that...

    It's really simple :) If you need more help just ask and I'll link you to some of the things on the Bukkit Wiki.
     
  6. Offline

    mrCookieSlime

    SleepyDog
    Please don't post on my Profile just to point me to a Thread you need help with.
    If you have a problem, feel free to PM me saying you need help with something and I will help you.

    There are enough people on Bukkit which can help you, just because no one answers in 10 minutes, there is no need to post a message on someone's profile for this.

    And as you have been told before, just loop through all Players, check if they have permission, if they do send them a Message.
     
  7. Offline

    SleepyDog

    so far, i have this:
    [​IMG]
    This does not do anything ingame though.
     
  8. Offline

    CraftCreeper6

    SleepyDog
    *Facepalm*
    Firstly, you cannot use "sender" is must be Player.
    Secondly, Bukkit is not capitalised properly.
    Thirdly, what's the error on getConfig();?
    Lastly, exporting a plugin with an error...
     
    VG.Developments likes this.
  9. Offline

    FerusGrim

    SleepyDog Of course it doesn't do anything in-game. Does that even compile?
     
  10. Offline

    SleepyDog

    Like i said, i am very new to this.

    Yes, it does. Without any errors.

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

    FerusGrim

    No, it can't. It literally cannot compile. The class 'sender' doesn't even exist. It's Sender, and yes, the capitalization matters. On top of all the other errors that CraftCreeper6 pointed out.

    If you think that compiled without any errors, you're mistaken, and something is fundamentally wrong.
     
    mrCookieSlime and CraftCreeper6 like this.
  12. Offline

    SleepyDog

    The errors are that the imports are not working, all of this works in-game, http://i.gyazo.com/fbef2fb2451dc8d74c8c5421ffbd3716.png
     
  13. Offline

    CraftCreeper6

    SleepyDog
    Do you even have Bukkit in your build path?
     
  14. Offline

    Rocoty

    SleepyDog Before you try to run your code make sure it compiles properly. I can tell right off the bat that your code does in fact not compile properly. That's what the red underlines are; compile time errors. Fix those before you run your plugin, or you are bound to get problems.

    When you have done that, and if it still does not work, please post your code along with a description of your problem and we will be more than willing to help you.
     
  15. Offline

    SleepyDog

    Yes, http://i.gyazo.com/708a05e319f3d111b28fe610099608a5.png

    The errors where not there when i made this plugin, i then came back a month or so later and they where there.

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

    Rocoty

    SleepyDog And what do they say when you hover over them?
     
  17. Offline

    SleepyDog


    [​IMG]
     
  18. Offline

    FerusGrim

    Guys, stop. We can't do this.

    No one here could explain how to properly setup a workstation, or the basic fundamentals of Java (such as compiling your program), better than the thousands of very well documented websites dedicated purely to introducing people to the principles of Java.

    SleepyDog We're here to support developers for programming against the API. You're literally at a point where you should not be focusing on the API, if you cannot properly compile a program. That's not what we're here for, and that's not what we all spend a lot of time volunteering for. Please, look up a documentation or essay on some sort of introduction to Java, or pick up one of the many books available, geared specifically for new developers.

    We will not help you on such a low level.
     
  19. Offline

    SleepyDog

    This was working fine, I cant look up a solution till I know the problem. That is why i am here.
     
  20. Offline

    FerusGrim

    The problem, as already stated by CraftCreeper6, is that Bukkit is not in your class path.

    Look up a tutorial on how to add Libraries to Eclipse.

    EDIT: Scratch that, goddamn it. My desire to assist you is too strong. xD Do NOT look that up. You shouldn't be fumbling around in the dark, only looking up a problem when you come across it. You should read an Introduction to Java. LEARN what you're DOING.

    When you get to the point that you can actually utilize Google to find an issue because you know enough about what you're doing that you can accurately describe your issue, then start looking up problems when you come across them.
     
  21. Offline

    Rocoty

    SleepyDog So evidently you haven't imported CommandSender or you don't even have Bukkit in your classpath. With the Java knowledge you are assumed to have at this point this should be a no-brainer to fix.

    If you do not have basic knowledge of how Java works you should learn that before continuing with Bukkit Plugin Development.

    If you want a forum where you can ask Java questions the Java Ranch is a good place. Good luck.
     
  22. Offline

    SleepyDog

    Fixed, I find it sad that you gave up on me so quick. The problem, which is not the reason i made this thread, is that i moved the external jar. Now that that is fixed I will have to find another place to help me with sending a message to all player without a permission. Thankyou. Bye.

    Edit: FerusGrim Sorry i missed that, thanks for the help. I will look on gifthub for some code that will do what i need it to. Thankyou.
     
  23. Offline

    FerusGrim

    SleepyDog

    No one gave up on you. We didn't tell you to never attempt to program again. We just insisted that you seek a proper introductory education for Java. It'll make your experience with the language, and subsequently Bukkit, that much more enjoyable.

    Regardless of how inane the actual problem was, the fact of the matter is that you should have known exactly what the issue was. And as soon as you knew what the issue was, you should have been able to, on your own, come up with a number of steps to check in order to solve this problem. It was simple; Basic.

    Don't give up, that's not the message we're trying to give you. Just... don't jump straight into working with an API. It will be the bottleneck in your Java education.
     
  24. Offline

    SleepyDog

    Read the edit in my last post, and thanks. I know you can do Bukkit.Broadcast("Message", "Permission") but i want to broadcast to people without that permission.
     
  25. Offline

    TheCodingCat

    you can do this SleepyDog Loop through all online players, check if they don't have the permission you want, then send them a message
     
  26. Offline

    FerusGrim

    Code:java
    1.  
    2. for (Player player : Bukkit.getServer().getOnlinePlayers()) {
    3. player.sendMessage("message");
    4. }
    5.  
     
  27. Offline

    SleepyDog

    Okay, *DrumRoll* , This may work!
    [​IMG]

    if (player.!hasPermission("permission"){

    }

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

    TheCodingCat

    :mad:no its
    if (!player.hasPermission("permission")) {
    }
    SleepyDog don't you know java?
     
  29. Offline

    SleepyDog

    I don't know how to answer that, i would say... I know how to follow a tutorial, i am not ready to post a pubic plugin and someone showed you that once? I am very new to java and have never had to use '!' before.

    TheCodingCat, is this normal or an error i have to fix?
    [​IMG]

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

    TheCodingCat

    if its depregation just add a suppress warnings but it should work fine
     
Thread Status:
Not open for further replies.

Share This Page