Guest User

Untitled

a guest
Jun 2nd, 2017
78
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package me.CreepersGamingMc.motd;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.ChatColor;
  5. import org.bukkit.command.Command;
  6. import org.bukkit.command.CommandSender;
  7. import org.bukkit.entity.Player;
  8. import org.bukkit.event.EventHandler;
  9. import org.bukkit.event.Listener;
  10. import org.bukkit.event.player.PlayerJoinEvent;
  11. import org.bukkit.plugin.java.JavaPlugin;
  12.  
  13. public class main extends JavaPlugin implements Listener {
  14.  
  15. @EventHandler
  16. public void onPlayerJoin(PlayerJoinEvent e) {
  17. Player p = e.getPlayer();
  18. p.sendMessage(ChatColor.GREEN + getConfig().getString("message"));
  19. }
  20.  
  21. public void onEnable() {
  22. getConfig().options().copyDefaults(true);
  23. Bukkit.getServer().getPluginManager().registerEvents(this, this);
  24. }
  25.  
  26. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
  27. if (cmd.getName().equalsIgnoreCase("motd")) {
  28. sender.sendMessage(getConfig().getString("message"));
  29. return true;
  30. }
  31.  
  32. if (cmd.getName().equalsIgnoreCase("setmotd")) {
  33. if (!sender.hasPermission("creepermotd.set")) {
  34. sender.sendMessage(ChatColor.DARK_RED + "You are not permitted to set the motd!");
  35. return true;
  36. if (args.length == 0) {
  37. sender.sendMessage(ChatColor.RED + "Please Specify A MOTD");
  38. return true;
  39. }
  40. StringBuilder str = new StringBuilder();
  41. for (int i = 0; i < args.length; i++ ) {
  42. str.append(args[i] + " ");
  43. }
  44. String motd = str.toString();
  45. getConfig().set("message", motd);
  46. saveConfig();
  47. sender.sendMessage(ChatColor.GREEN + "Motd set to:" + motd);
  48. return true;
  49. }
  50. return true;
  51. }
  52. }
  53.  
  54.  
  55. //When I am about to finish it on the last } it says please add another } but when I add another } this whole thing screws up if (args.length == 0) {
  56. sender.sendMessage(ChatColor.RED + "Please Specify A MOTD");
  57. return true;
  58. }
RAW Paste Data