Advertisement
Guest User

Untitled

a guest
Sep 30th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. package fr.inoxs.clearlag;
  2.  
  3. import java.util.List;
  4.  
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.World;
  7. import org.bukkit.configuration.file.FileConfiguration;
  8. import org.bukkit.entity.Entity;
  9. import org.bukkit.entity.Item;
  10. import org.bukkit.entity.Monster;
  11. import org.bukkit.event.Listener;
  12. import org.bukkit.plugin.java.JavaPlugin;
  13.  
  14. public class ClearLag extends JavaPlugin implements Listener {
  15.  
  16. public static FileConfiguration config;
  17.  
  18. public void onEnable() {
  19.  
  20. getCommand("lagclear").setExecutor(new CommandsManager());
  21. ClearLag.config = getConfig();
  22. ClearLag.config.options().copyDefaults(true);
  23. saveDefaultConfig();
  24. final String prefix = ClearLag.config.getString("prefix").replace('&', '§');
  25. Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
  26. private int a = 300;
  27.  
  28. public void run() {
  29. switch (a) {
  30. case 180:
  31. Bukkit.broadcastMessage(prefix + config.getString("message").replace('&', '§').replace("%x%", "3"));
  32. break;
  33. case 60:
  34. Bukkit.broadcastMessage(prefix + config.getString("message").replace('&', '§').replace("%x%", "1"));
  35. break;
  36.  
  37. case 0:
  38. World world = getServer().getWorld("world");
  39. List<Entity> entList = world.getEntities();
  40. int count = 0;
  41. for (Entity current : entList) {
  42. if (current instanceof Item) {
  43. current.remove();
  44. count++;
  45. }
  46. if (current instanceof Monster) {
  47. current.remove();
  48. count++;
  49. }
  50. }
  51. Bukkit.broadcastMessage(prefix + ClearLag.config.getString("delete_message").replace('&', '§')
  52. .replace("%count%", count + ""));
  53. }
  54. if (a == 0) {
  55. a = 300;
  56. }
  57. a -= 1;
  58.  
  59. }
  60. }, 20L, 20L);
  61. }
  62.  
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement