Solved -removed-

Discussion in 'Plugin Development' started by GrandmaJam, Nov 11, 2014.

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

    GrandmaJam

    -removed-
     
    Last edited by a moderator: Jan 19, 2015
  2. Offline

    nitrousspark

    GrandmaJam
    player1 and player2 are the same player?

    try using this:
    Code:
    @EventHandler
    public void onJoin(PlayerJoinEvent event)
    {
    Player player = event.getPlayer();
    if (player.hasPermission("silent.join")) {
    event.setJoinMessage(null);
    player.sendMessage("§7Join> §c" + player.getName() + "§7 joined the game silenty.");
    }
    }
     
    GrandmaJam likes this.
  3. Offline

    GrandmaJam

    Thanks! That works perfectly now, however the join message for players who don't use silent join is broken. Code is attached.

    Code:java
    1. if (!player.isOp()) {
    2. event.setJoinMessage("§c+ §7" + player.getName());
    3. }
     
    Last edited by a moderator: Jan 19, 2015
  4. Offline

    Regablith

    Do you have the closing bracket?
     
  5. Offline

    GrandmaJam

    -removed-
     
    Last edited by a moderator: Jan 19, 2015
  6. Offline

    Regablith

    There are numerous things wrong with the code.

    First off: When you are sending the message saying that the player joined silently, you are just sending it to them. To send it to everyone who has the permission, make a for loop of all online players and check if they have the permission.

    Second: You don't need the check to see if the player is op or not. Going off what I said above, you can check the permission then make an else statement. Example:
    Code:java
    1. if(onlinePlayers.hasPermission("perm.perm")) {
    2. //Do stuff for people with the permission.
    3. }else {
    4. //Do stuff for people w/o the permission.
    5. }
     
  7. Offline

    ChipDev

    Don't call the player object 2 times :p
    Edit: Call the player object BEFORE HAND as null, and change it on join.
     
  8. Offline

    GrandmaJam

    -removed-
     
    Last edited by a moderator: Jan 19, 2015
  9. Offline

    rete25iscool

    Words of advice. Learn Java before learning Bukkit. Along with that, learn Bukkit, too. You clearly don't have a good understanding of it.

    Code:java
    1. If player has a permission set the join message to something.
    2. else set the join message to something else.
    3.  


    ^ Pseudo code.
     
    Regablith likes this.
  10. Offline

    SuperOriginal

  11. Offline

    GrandmaJam

    rete25iscool Thanks. But that still doesn't solve my problem.
     
  12. Offline

    rete25iscool

    -snip-

    EDIT: Loop through the online players, check if they have a certain permission and if they do have it, set the join message for the players with the permission you're checking for.

    Code:java
    1. for (Player player : Bukkit.getOnlinePlayers()) {
    2. if (player.hasPermission("permission.permission") {
    3. // Do stuff.
    4. }
    5. }
    6.  


    Sorry, I misread your original issue and I'm typing on an iPad currently so sorry if there are any spelling errors.
     
  13. Offline

    mythbusterma

    GrandmaJam

    Don't suppress warnings for no reason, especially when they're telling you EXACTLY why your code isn't working.
     
    Regablith likes this.
  14. Offline

    ChipDev

    Player object has hasPermission, no need to call the object.
     
  15. Offline

    Regablith

    GrandmaJam
    onlinePlayers needs to be the Player object when you make a for loop.
     
  16. Offline

    GrandmaJam

    Regablith and ChipDev like this.
  17. Offline

    ChipDev

    GrandmaJam likes this.
  18. Offline

    Regablith

Thread Status:
Not open for further replies.

Share This Page