Advertisement
diamob

Class file for sannounce

Oct 1st, 2016
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.87 KB | None | 0 0
  1. package io.github.diamob;
  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.plugin.PluginDescriptionFile;
  9. import org.bukkit.plugin.java.JavaPlugin;
  10.  
  11. public class sAnnounce extends JavaPlugin {
  12.     public PluginDescriptionFile pdfFile = getDescription();
  13.     @Override
  14.     public void onEnable() {
  15.         Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[" + pdfFile.getName() + "] Version " + pdfFile.getVersion() + " by" + ChatColor.BLUE + "DIAMOB" + ChatColor.YELLOW + " is " + ChatColor.GREEN + "enabled.");
  16.     }
  17.    
  18.     @Override
  19.     public void onDisable() {
  20.         Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[" + pdfFile.getName() + "] Version " + pdfFile.getVersion() + " by" + ChatColor.BLUE + "DIAMOB" + ChatColor.YELLOW +  " is " + ChatColor.RED + "disabled.");
  21.     }
  22.    
  23.     public boolean onCommand(CommandSender sender, Command cmd, String[] args) {
  24.         Player player = (Player) sender;
  25.         if(cmd.getName().equalsIgnoreCase("a")){
  26.     if(!(sender instanceof Player))
  27.     {
  28.        
  29.         if(!(sender instanceof org.bukkit.command.ConsoleCommandSender))
  30.         {
  31.             sender.sendMessage(ChatColor.RED + "Error: You must be a player to use this!");
  32.             return false;
  33.         }else
  34.         {
  35.             if(args.length > 1)
  36.             {
  37.                 if(player.hasPermission("sannounce.*")) {
  38.                     String text = "";
  39.                     for (int i = 0; i < args.length; i++) {
  40.                            text += args[i] + " ";
  41.                             }
  42.                      Bukkit.broadcastMessage(ChatColor.GOLD + "[Announcement] " + ChatColor.BLUE + text);
  43.                      return true;
  44.    
  45.  
  46.        
  47.     }
  48. }
  49.     }
  50.         }
  51.        
  52.     }
  53.         return false;
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement