[URGENT]Have a message be sent to an admin

Discussion in 'Plugin Development' started by XgXXSnipz, Oct 12, 2014.

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

    XgXXSnipz

    AdamQpzm I shoudlve re phrased that, I meant Im gonna leave once I get this done Walruski fireblast709
    Code:java
    1. if ((!(sender instanceof Player)))
    2. return true;
    3. {
    4.  
    5. if(cmd.getName().equalsIgnoreCase("harras"))
    6. if (args.length == 0) {
    7. p.sendMessage(ChatColor.YELLOW + "[" + ChatColor.BLUE + "Harrasment" + ChatColor.YELLOW + "]" + ChatColor.RED + "Error: You must specifiy a player and your reason for reporting him");
    8. return true;
    9.  
    10.  
    11. }
    12. Player target = Bukkit.getServer().getPlayer(args[0]);
    13.  
    14.  
    15.  
    16. if (target == null) {
    17. p.sendMessage(ChatColor.YELLOW + "[" + ChatColor.BLUE + "Harassment" + ChatColor.YELLOW + "]" + ChatColor.RED + "Error: could not find " + args[0] + "!");
    18. return true;
    19. }
    20.  
    21.  
    22.  
    23. StringBuilder message = new StringBuilder("");
    24. for (String part : args) {
    25. if (!message.toString().equals(""))
    26. message.append("");
    27. message.append(part);
    28. }
    29.  
    30.  
    31. p.sendMessage(ChatColor.YELLOW + "[" + ChatColor.BLUE + "Harrasment" + ChatColor.YELLOW + "]" + ChatColor.GREEN + "Sucess, You have reported " + ChatColor.RED + target.getName() + ChatColor.YELLOW + "For " + message);
    32. target.playSound(target.getLocation(), Sound.BAT_DEATH, 1, 1);
    33. target.sendMessage(ChatColor.RED + sender.getName() + ChatColor.GREEN + " Just reported you for harrasing him/her" + ChatColor.RED + " Because: " + message);
    34. for(World w : getServer().getWorlds()){
    35. for(Player player: w.getPlayers()){
    36. if(p.hasPermission("admin.harrass")){
    37. p.sendMessage(ChatColor.AQUA + sender.getName() + ChatColor.AQUA + " Was harrased by " + ChatColor.RED + target.getName() + ChatColor.YELLOW + " Reason: " + ChatColor.RED + message);
    38. }
    39. }
    40. }
    41. return false;
    42. }
    43. }
    44. }
     
  2. Offline

    WesJD

    XgXXSnipz Just saying, in my opinion, this is the easiest thing in the world. Listen to AdamQpzm and everyone else stating you need to lean the BukkitAPI and basic Java skills. Being rude to them will get you no where, unless you're looking to get rude replies back.

    Oh, and for a 'hint', everything you're doing here is mostly unneeded.
     
    AdamQpzm likes this.
  3. Offline

    XgXXSnipz

    WesJD Do you mind helping me? like pesudo code or some sort
     
  4. Offline

    fireblast709

  5. Offline

    XgXXSnipz

    Code:java
    1. String myString = ""; //we're going to store the arguments here
    2.  
    3. for(int i = 0; i < args.length; i++){ //loop threw all the arguments
    4. String arg = args[i] + " "; //get the argument, and add a space so that the words get spaced out
    5. myString = myString + arg;[/i]


    fireblast709 ah ok I almost got it, theres just 1 PROBLEM, it keeps including the freaking player in the reason as well

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

    fireblast709

    XgXXSnipz now start at index 1, and you are done :3.
     
  7. Offline

    XgXXSnipz

  8. Offline

    XgXXSnipz

    fireblast709 Ok so now im entering a new era, I want to be able to output this data into a config, like putting who got harassed and who harassed them and their reason, code:
    Code:java
    1. config.addDefault("Player.Reason.ReportedPlayer", "test");
    2.  
    3. config.options().copyDefaults(true);
    4. saveConfig();
    5. }
    Code:java
    1. getConfig().addDefault(myString, sender.getName() + target.getName());


    Already tried, generates config puts in my first config,addDefault but doesnt seem to put in my addDefault
     
  9. Offline

    fireblast709

    XgXXSnipz instead of addDefault, use set(path, value)
     
  10. Offline

    XgXXSnipz

    fireblast709 yea still doesn't work :( I tried using bukkit's api but its sorta confusing
     
  11. Offline

    fireblast709

  12. Offline

    XgXXSnipz

Thread Status:
Not open for further replies.

Share This Page