Messagem from player for admins online.

Discussion in 'Plugin Development' started by Aquamen, Dec 26, 2016.

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

    Aquamen

    Hiii, i want to know,

    What code, for the player to type / report, and this report be sent to the admins online?
     
  2. Offline

    tg95

    on send report you can do this:
    PHP:
            for(Player pop Bukkit.getOnlinePlayers()) {
                if(
    pop.isOp()) {
                    
    pop.sendMessage("player a send report!");
                }
            }
     
  3. Offline

    Zombie_Striker

    @tg95
    Don't spoonfeed. That really does not help since there is a lot of things we don't know, and a lot of things your code does not do. Not only that, but you did not provide any documentation or comments explaining what each line does, nor how to use it.

    @Aquamen
    What do you mean by admins? Do you mean ops, or admins as in ranks? Also, what have you set up so far? Have you set up the command?
     
  4. Offline

    Aquamen

    @Zombie_Striker, I want the player to enter /report, and the admins with a certain permission, receive the name of the player that denounced, which he denounced. You do not have to know who he reported, I've already packed it.
    I have this question for the start my code.
     
  5. Offline

    mythbusterma

    @Aquamen

    What do you have already? Also, all you have to do is send the player a message from the server.
     
  6. Offline

    DeCraizq

    Do you mean something like this?
    Code:
    // Method for this:
    // msg = The message sent to admins
    void sendReportMessage(String msg) {
      // Loop through all online players
      for(Player p : Bukkit.getOnlinePlayers()) {
        // And check if they are permitted
        if(p.hasPermission("yourPlugin.seeReports")) {
          // If they are, send them the message:
          p.sendMessage(msg);
        }
      ]
    }
    And then you just call e.g. sendReportMessage("Some player just reported another player with haaax");
    in your Command Class ;)
     
    Aquamen likes this.
  7. Offline

    Aquamen

    I want to make plugin a send message for admins, for exemple:

    /say Hey, admin, i have a question.

    and, show for admins this:
    Player say Hey, admin, i have a question.

    I know it's simple, but I'm in doubt.

    Thank very much.
     
  8. Offline

    Zombie_Striker

    @Aquamen
    What do you have currently? Is this a request or is that that you want to make this plugin?
     
  9. Offline

    Aquamen

    No, i want to make this plugin. I want to know, how to send message for admins, with code, example:
    /say Admin talk with me.
     
  10. Offline

    timtower Administrator Administrator Moderator

    Merged threads.
     
  11. Offline

    Aquamen

    Thanks!
     
  12. Offline

    ipodtouch0218

    Bukkit.broadcast(String message, String [or Permission] perm);

    Ex.
    Code:
    Bukkit.broadcast(sender + " >> " + chat, "report.getreports");
     
    Last edited: Jan 3, 2017
  13. Offline

    DoggyCode™

    PHP:
    public class MyPluginCommandExecutor implements CommandExecutor {

    private 
    MyPlugin plugin// pointer to your main class, unrequired if you don't need methods from the main class

      // Constructor
      
    public MyPluginCommandExecutor(MyPlugin plugin) {
        
    this.plugin plugin;
      }

      public 
    boolean onCommand(CommandSender senderCommand cmdString labelString[] args) {
      
        
    // This would be the executer of the command (you should know this)
        
    Player exec = (Player)sender;

        
    // We need to build a String, use StringBuilder
        
    StringBuilder sb = new StringBuilder();
        
    // Loop through the exec's args after /command arg0 arg1 arg2 (...)
        
    for(int i 0args.lengthi++) {
          
    // Append the argument to the StringBuilder which we created
          
    sb.append(args[i]).append(" ");
        }
        
    // Building finished. Transfer it to a String and trim it for nicer output
        
    String reason sb.toString().trim();
        
    // Are there any admins online?
        
    boolean found false;
        
    // Loop thorugh all players online on the server
        
    for(Player admin Bukkit.getOnlinePlayers()) {
          
    // Check if player is 1. Op; or 2. has the permission "reports.see"
          
    if(admin.isOp() || admin.hasPermission("reports.see")) {
            
    // If this criteria ^ is true, send the message to the Admins
            
    admin.sendMessage("[Reports] " exec.getName() + " > " reason);
            
    // We found at least one admin
            
    found true;
          }
        }
        
    // Did we find an admin?
        
    if(found) {
          
    // Notify the player that the admins have recieved their message
          
    exec.sendMessage("[Reports] " "The Admins will be in touch shorty regarding your message (\"" reason + \"");
        
    // No admins were found
        
    } else {
          
    // Notify the player that there are no Admins online (to be found)
          
    exec.sendMessage("[Reports] " "Sorry, there are no Admins online at the moment. Try again at a later time!");
        }
      }
    }
     
    Last edited: Jan 10, 2017
    ipodtouch0218 and DinosaurKappa like this.
  14. Offline

    DinosaurKappa

    You would want to create a permission. I reccomend "report.admin" or along those lines. You would then loop through all online players and send them a message that says the sender's name, who they're reporting, and why they're reporting them.
     
Thread Status:
Not open for further replies.

Share This Page