Advertisement
Guest User

CB Code 2

a guest
Apr 24th, 2015
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.06 KB | None | 0 0
  1. public class Main extends JavaPlugin implements Listener {
  2.    
  3.     Localization messages;
  4.     Config config;
  5.    
  6.     public void onEnable() {
  7.         Bukkit.getServer().getPluginManager().registerEvents(this, this);
  8.        
  9.         CSCoreLibLoader loader = new CSCoreLibLoader(this);
  10.        
  11.         if (loader.load()) {
  12.            
  13.             PluginUtils utils = new PluginUtils(this);
  14.             utils.setupConfig();
  15.             config = utils.getConfig();
  16.             utils.setupLocalization();
  17.             messages = utils.getLocalization();
  18.            
  19.             // utils.setupUpdater(91167, getFile());
  20.            
  21.             messages.setDefault("blocked-message", "&cYou cannot perform {CMD}!");
  22.             messages.save();
  23.         }
  24.     }
  25.    
  26.     @EventHandler(priority = EventPriority.HIGHEST)
  27.     public void onCommandPreprocess(PlayerCommandPreprocessEvent e) {
  28.         Player p = e.getPlayer();
  29.         String c = e.getMessage();
  30.        
  31.         if (p.hasPermission("commandblocker.bypass")) return;
  32.         for (String l : config.getStringList("blocked-commands")) {
  33.             if (c.contains(l)) {
  34.                 messages.sendTranslation(p, "blocked-message", false, new Variable("{CMD}", c));
  35.                 e.setCancelled(true);
  36.             }
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement