Solved How can I send a player a message? And make permissions?

Discussion in 'Plugin Development' started by Brevoort, Oct 18, 2016.

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

    Brevoort

    So I was wondering how would I go setting up a /message system?
    I can't seem to find the events/commands I need.
    (Obviously I'm new to this)





    Also how would you set a permission for a command?
     
  2. Offline

    mehboss

    @Brevoort
    To broadcast a message to everyone on the server do:
    Code:
            Bukkit.broadcastMessage("this is the message");
    To broadcast a message to everyone with a certain permission do:
    Code:
            Bukkit.broadcast(message, permission)
    To broadcast a message to a target try:
    Code:
                    Player player = player.getPlayer();
                                player.sendMessage("this is the message");
    To broadcast a message to the sender do:
    Code:
            sender.sendMessage("this is the message");
    Example permission:
    Code:
                    if (sender.hasPermission("example.permission")) {
                     //your code here
        }
     
  3. Offline

    Zombie_Striker

    @Brevoort
    /message is a command, so use an onCommand to listen for that command. When the commend is sent, build all the "args" to make a single string.

    As for permission, use Player.hasPermission("perm") to test for perms.
     
  4. Offline

    Brevoort

    Okay so is that how I would make a custom permission? using Player.hasPermission() or is that just checking for the perm
     
  5. Offline

    Zombie_Striker

    @Brevoort
    Use that method.

    [edit] How can you check for the perm without using that method? That method is the way to check.
     
  6. Offline

    mehboss

    @Brevoort
    Example permission:
    Code:
    if (sender.hasPermission("example.permission")) {
    //your code here
    }
     
  7. Offline

    Brevoort

    thanks
     
  8. Offline

    Zombie_Striker

    @Brevoort
    If your problem has been solved, mark this thread as solved.
     
Thread Status:
Not open for further replies.

Share This Page