ChatClear

Jul 16, 2017
ChatClear
  • Download this plugin : https://www.spigotmc.org/resources/chatclear-1-8x-1-9x-1-10x-1-11-2.28068/

    DONATION: https://paypal.me/viktortoth

    Code:
    Main.java
    Code (Text):
    package com.unicum.ChatClear;

    import java.util.logging.Logger;
    import org.bukkit.Bukkit;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.event.Listener;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;

    public class main
      extends JavaPlugin
      implements Listener
    {
      Logger log = Logger.getLogger("Minecraft");
      FileConfiguration cfg;

      public main(FileConfiguration config) {
       
          this.cfg = config;
     
    }
      public void onEnable()
      {
        saveDefaultConfig();
        getConfig().options().copyDefaults(true);
     
        saveConfig();
        PluginManager pm = Bukkit.getServer().getPluginManager();
        pm.registerEvents(this, this);
        Bukkit.getServer().getPluginManager().registerEvents(this, this);
        Bukkit.getServer().getConsoleSender().sendMessage(this.cfg.getString("onStar1").replace('&', '§'));
        Bukkit.getServer().getConsoleSender().sendMessage(this.cfg.getString("onStar2").replace('&', '§'));
        Bukkit.getServer().getConsoleSender().sendMessage(this.cfg.getString("onStar3").replace('&', '§'));
        Bukkit.getServer().getConsoleSender().sendMessage(this.cfg.getString("onStar4").replace('&', '§'));
     
        Bukkit.getServer().getConsoleSender().sendMessage(this.cfg.getString("VersionMessage").replace('&', '§').replaceAll("%version%", this.getServer().getVersion()));
      }

      public void onDisable()
      {
        Bukkit.getServer().getConsoleSender().sendMessage(getConfig().getString("onStop1").replace('&', '§'));
        Bukkit.getServer().getConsoleSender().sendMessage(getConfig().getString("onStop2").replace('&', '§'));
        Bukkit.getServer().getConsoleSender().sendMessage(getConfig().getString("onStop3").replace('&', '§'));
        Bukkit.getServer().getConsoleSender().sendMessage(getConfig().getString("onStop4").replace('&', '§'));
      }

      public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
      {
        config();
        getCommand("chatclear").setExecutor(new chatclearcommand(getConfig()));
        getCommand("ccmy").setExecutor(new mychat(getConfig()));
        getCommand("cc_help").setExecutor(new helpcommand(getConfig()));
        getCommand("cco").setExecutor(new otherplayer(getConfig()));
        getCommand("ccperm").setExecutor(new permcommand(getConfig()));
        return false;
      }

      public void config()
      {
        getConfig().addDefault("chatclear message", "[>]  &2Chat has been cleared by: &3%player%! ");
        getConfig().addDefault("my clear message", "[>]  &6You chat has been cleared!");
        getConfig().addDefault("#Title messages:", "");
        getConfig().addDefault("GobalChatClearTitle", "[>]  &2Chat has been cleared ");
        getConfig().addDefault("permission message", "[>]  &4You don't have permission.");
        getConfig().addDefault("OfflinePlayerMessage", "[>]  &c%player% &4is not online! ");
        getConfig().addDefault("OtherClearMessage", "[>]  &aYour Chat has been cleared");
        getConfig().addDefault("chatclear usage message:", "[>]  &4Usage: &c/chatclear");
        getConfig().addDefault("VersionMessage", "[>]  &4Usage: &c/chatclear");
        getConfig().addDefault("chatclear console message", "[>]  &3Only for player command!");
        getConfig().addDefault("#Help page", "");
        getConfig().addDefault("- help line1", "[>]  &e--===-===- &6ChatClear &e-===-===--");
        getConfig().addDefault("- help line2", "[>]  &7/cc_help &8| &eChatclear help page ");
        getConfig().addDefault("- help line3", "[>]  &7/ccmy &8| &eMy chat clear");
        getConfig().addDefault("- help line4", "[>]  &7/chatclear &8| &eChatclear command ");
        getConfig().addDefault("- help line5", "[>]  &7/cco <player> &8| &eother player chatclear ");
        getConfig().addDefault("- help line6", "[>]  &e--===-===- &6ChatClear &e-===-===--");
        getConfig().addDefault("#Permissions page", "");
        getConfig().addDefault("- perm line1", "[>]  &e--===-===- &6ChatClear Perm's &e-===-===--");
        getConfig().addDefault("- perm line2", "[>]  &7/cc_help &8| &echatclear.use.help");
        getConfig().addDefault("- perm line3", "[>]  &7/ccmy &8| &echatclear.use.self");
        getConfig().addDefault("- perm line4", "[>]  &7/chatclear &8| &echatclear.use.global");
        getConfig().addDefault("- perm line5", "[>]  &7/ccperm &8| &echatclear.use.perm");
        getConfig().addDefault("- perm line6", "[>]  &7/cco <player> &8| &echatclear.use.other");
        getConfig().addDefault("- perm line7", "[>]  &e--===-===- &6ChatClear Perm's &e-===-===--");
        getConfig().addDefault("#OnStart with console", "");
        getConfig().addDefault("- onStart1", "&e--===-===- &6ChatClear &e-===-===--");
        getConfig().addDefault("- onStart2", "&aPlugin has been enabled!");
        getConfig().addDefault("- onStart3", "&bPlugin by: &6Unicum");
        getConfig().addDefault("- onStart4", "&e--===-===- &6ChatClear &e-===-===--");
        getConfig().addDefault("#OnStop with console", "");
        getConfig().addDefault("- onStop1", "&e--===-===- &6ChatClear &e-===-===--");
        getConfig().addDefault("- onStop2", "&cPlugin has been disabled!");
        getConfig().addDefault("- onStop3", "&bPlugin by: &6Unicum");
        getConfig().addDefault("- onStop4", "&e--===-===- &6ChatClear &e-===-===--");
        getConfig().options().copyDefaults(true);
        saveConfig();
      }
    }
     
    helpcommand.java
    Code (Text):
    package com.unicum.ChatClear;

    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.configuration.MemorySection;
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.entity.Player;

    public class helpcommand
      implements CommandExecutor
    {
      public helpcommand(FileConfiguration config) {
            // TODO Auto-generated constructor stub
        }
    public boolean onCommand(CommandSender sender, Command cmd, String CommandLabel, String[] args)
      {
        Player p = (Player)sender;
        String perm = "chatclear.use.help";
        if (sender.hasPermission(perm)) {}
        sender.sendMessage(getConfig().getString("- help line1:").replace('&', '§').replace("[>]", "➢").replace("%player%", p.getName()));
        sender.sendMessage(getConfig().getString("- help line2:").replace('&', '§').replace("[>]", "➢").replace("%player%", p.getName()));
        sender.sendMessage(getConfig().getString("- help line3:").replace('&', '§').replace("[>]", "➢").replace("%player%", p.getName()));
        sender.sendMessage(getConfig().getString("- help line4:").replace('&', '§').replace("[>]", "➢").replace("%player%", p.getName()));
        sender.sendMessage(getConfig().getString("- help line5:").replace('&', '§').replace("[>]", "➢").replace("%player%", p.getName()));
        sender.sendMessage(getConfig().getString("- help line6:").replace('&', '§').replace("[>]", "➢").replace("%player%", p.getName()));
        return false;
      }
      private MemorySection getConfig() {
            saveDefaultConfig();
            ((FileConfiguration) getConfig()).options().copyDefaults(true);
            return null;
        }

        private void saveDefaultConfig() {
            // TODO Auto-generated method stub
         
        }

    }
     
    chatclearcommand.java
    Code (Text):
    package com.unicum.ChatClear;

    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.entity.Player;

    public class chatclearcommand implements CommandExecutor {
     
        FileConfiguration cfg;
       
          public chatclearcommand(FileConfiguration config) {
           
              this.cfg = config;
                   
          }


        @SuppressWarnings("deprecation")
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
          {
            if ((sender instanceof Player))
            {
              Player p = (Player)sender;
              if (args.length == 0)
              {
                String perm = "chatclear.use.global";
                if (p.hasPermission(perm))
                {
                  for (int i = 0; i < 200; i++) {
                      Bukkit.broadcastMessage("");
                      String global = this.cfg.getString("GobalChatClearTitle").replace("%player%", p.getName());
                        p.sendTitle(ChatColor.translateAlternateColorCodes('&', (global)), global);
                  }
              }
              else
           
                p.sendMessage(this.cfg.getString("chatclear usage message:").replace('&', '§').replace("[>]", "➢").replace("%player%", p.getName()));
             
              }
              Bukkit.broadcastMessage(this.cfg.getString("chatclear message:").replace('&', '§').replace("[>]", "➢").replace("%player%", p.getName()));
            }
            else
            {
              sender.sendMessage(this.cfg.getString("chatclear console message:").replace('&', '§').replace("[>]", "➢").replace("[<3]", "♥"));
            }
            return true;
          }
        }
    mychat.java
    Code (Text):
    package com.unicum.ChatClear;

    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.entity.Player;

    public class mychat implements CommandExecutor {

        public static String java;
        private FileConfiguration cfg;
        private String cctitle;

        public mychat(FileConfiguration config) {
         
            this.cfg = config;
        }

        @SuppressWarnings("deprecation")
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String CommadLabel, String[] args) {
              Player p = (Player) sender;
              String perm = "chatclear.use.self";
              if(sender.hasPermission(perm))
              for(int i=0; i<200; i++)
              p.sendMessage("");
              p.sendTitle("§c➢ §7Your chat has been cleared!", cctitle);
       
           
            p.sendMessage(this.cfg.getString("my clear message:").replace('&', '§').replace("[>]", "➢").replace("%player%", p.getName()));
            return false;
        }


    }
     
    otherplayer.java
    Code (Text):
    package com.unicum.ChatClear;

    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.entity.Player;

    public class otherplayer implements CommandExecutor {

        FileConfiguration cfg;
       
          public otherplayer(FileConfiguration config) {
           
              this.cfg = config;
         
        }

     
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
         
            Player target = sender.getServer().getPlayer(args[0]);
            if (target == null) {
                sender.sendMessage(this.cfg.getString("OfflinePlayerMessage:").replace('&', '§').replace("[>]", "➢").replace("%player%", args[0]));
                return true;
            }
            for(int i=0; i<200; i++)
            target.sendMessage("");
            target.sendMessage(this.cfg.getString("OtherClearMessage:").replace('&', '§').replace("[>]", "➢").replace("%player%", target.getPlayer().getName()));
        return false;
    }
    }
     
    permcommand.java
    Code (Text):
    package com.unicum.ChatClear;

    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.entity.Player;


    public class permcommand implements CommandExecutor {

        FileConfiguration cfg;
       
          public permcommand(FileConfiguration config) {
           
              this.cfg = config;
        }

        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
         
            Player p=(Player)sender;
            String perm = "chatclear.use.perm";
            if(sender.hasPermission(perm)) {
                sender.sendMessage(this.cfg.getString("- perm line1:").replace('&', '§').replace("[>]", "➢").replace("%player%", p.getName()));
                sender.sendMessage(this.cfg.getString("- perm line2:").replace('&', '§').replace("[>]", "➢").replace("%player%", p.getName()));
                sender.sendMessage(this.cfg.getString("- perm line3:").replace('&', '§').replace("[>]", "➢").replace("%player%", p.getName()));
                sender.sendMessage(this.cfg.getString("- perm line4:").replace('&', '§').replace("[>]", "➢").replace("%player%", p.getName()));
                sender.sendMessage(this.cfg.getString("- perm line5:").replace('&', '§').replace("[>]", "➢").replace("%player%", p.getName()));
                sender.sendMessage(this.cfg.getString("- perm line6:").replace('&', '§').replace("[>]", "➢").replace("%player%", p.getName()));
                sender.sendMessage(this.cfg.getString("- perm line7:").replace('&', '§').replace("[>]", "➢").replace("%player%", p.getName()));
                return true;
            }
                else {
                p.sendMessage(cfg.getString("permission message:"));
            }
                if(args.length == 1);
                sender.sendMessage(cfg.getString("chatclear usage message:"));
             
         
            return false;
     
         
        }

    }
     
    Plugin.yml
    Code (Text):
    name: ChatClear
    main: com.unicum.ChatClear.main
    version: 2.0.2
    author: Unicum

    commands:
       chatclear:
          aliases: [cc]
          permission-message: You don't have permission <permission>
          permission: chatclear.use.global
          description: Chat cleaner command
       cc_help:
          aliases: [cc_help]
          permission-message: You don't have permission <permission>
          permission: chatclear.use.help
          description: ChatClear Help page
       ccmy:
          aliases: [chatclearmy]
          permission-message: You don't have permission <permission>
          permission: chatclear.use.self
          description: My chat clear command
       ccperm:
          aliases: [c_perm]
          permission-message: You don't have permission <permission>
          permission: chatclear.use.perm
          description: see you permission's list
       cco:
          aliases: [c_other]
          permission-message: You don't have permission <permission>
          permission: chatclear.use.other
          description: other player chatclear command
     
     
    Download this plugin : https://www.spigotmc.org/resources/chatclear-1-8x-1-9x-1-10x-1-11-2.28068/
  • Loading...
  • Loading...