Advertisement
MiniRoger123

Untitled

Oct 28th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. @EventHandler(priority = EventPriority.HIGHEST)
  2. public void onPlayerCommandPreprocessEvent(PlayerCommandPreprocessEvent event) {
  3. boolean Command = plugin.getConfig().getBoolean("Actions.CommandDetector.enabled");
  4. if (!(event.getPlayer() instanceof Player)) {
  5. return;
  6. }
  7.  
  8. if (!Command) {
  9. return;
  10. }
  11. Player p = event.getPlayer();
  12. List<String> cmds = plugin.getConfig().getStringList("Actions.CommandDetector.Command-BlackList");
  13. for (String command : cmds) {
  14. if (!event.getMessage().toLowerCase().startsWith("/" + command)) {
  15. continue;
  16. } else if (!event.getMessage().toLowerCase().startsWith(command)) {
  17. continue;
  18. }
  19. if (p.hasPermission("EpicLocks.command.bypass")) {
  20. String pr = plugin.getConfig().getString("messages.prefix", "");
  21. String bp = plugin.getConfig().getString("messages.bypass-command", "");
  22. pr = pr.replace("&", "§");
  23. bp = bp.replace("&", "§");
  24. bp = bp.replace("%command%", event.getMessage());
  25. Bukkit.getServer().getConsoleSender().sendMessage(pr + bp);
  26.  
  27. return;
  28. } else {
  29. String cant = plugin.getConfig().getString("messages.error-command", "");
  30. String prefix = plugin.getConfig().getString("messages.prefix-CommandDetector", "");
  31. cant = cant.replace("&", "§");
  32. prefix = prefix.replace("&", "§");
  33.  
  34. p.sendMessage(prefix + cant);
  35. String efe = plugin.getConfig().getString("sounds.blacklist");
  36. event.setCancelled(true);
  37. p.getWorld().playSound(p.getLocation(), Sound.valueOf(efe), 5, 1);
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement