Advertisement
Guest User

LMS Class

a guest
Jul 5th, 2014
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.13 KB | None | 0 0
  1. package me.LYSwitch.lms;
  2.  
  3. import me.LYSwitch.main.main;
  4.  
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.ChatColor;
  7. import org.bukkit.Location;
  8. import org.bukkit.command.Command;
  9. import org.bukkit.command.CommandExecutor;
  10. import org.bukkit.command.CommandSender;
  11. import org.bukkit.entity.Player;
  12.  
  13. public class LMS implements CommandExecutor {
  14. public main plugin;
  15.  
  16. public LMS(main instance) {
  17. plugin = instance;
  18.  
  19. }
  20.  
  21. public boolean onCommand(CommandSender sender, Command cmd, String label,
  22. String[] args) {
  23. final Player p = (Player) sender;
  24. if (label.equalsIgnoreCase("lms")) {
  25. if (args.length == 0) {
  26. sender.sendMessage(ChatColor.WHITE + "[" + ChatColor.RED
  27. + "EliteFights" + ChatColor.WHITE + "] " + "Usage:");
  28. sender.sendMessage("<command> : join <rank> : Administrator");
  29. sender.sendMessage("<command> : host <rank> : Default");
  30. return true;
  31. }
  32. if (args.length > 0) {
  33. if (args[0].equalsIgnoreCase("join")) {
  34. if (sender.hasPermission("default.lms.join")) {
  35. if (plugin.lmshost.size() == 1) {
  36. if (!plugin.lmsjoin.contains(p.getName())) {
  37. if (!plugin.lmsarena.contains(p.getName())) {
  38. // If there's a host then,
  39. Bukkit.getServer().broadcastMessage(
  40. ChatColor.WHITE + "["
  41. + ChatColor.RED
  42. + "EliteFights"
  43. + ChatColor.WHITE + "] "
  44. + sender.getName()
  45. + " has joined the LMS");
  46. plugin.lmsjoin.add(p.getName());
  47. } else { // If there isn't a host then,
  48. p.sendMessage(ChatColor.WHITE
  49. + "["
  50. + ChatColor.RED
  51. + "EliteFights"
  52. + ChatColor.WHITE
  53. + "] "
  54. + ChatColor.RED
  55. + "An LMS is not being hosted at the moment.");
  56. }
  57.  
  58. }
  59. }
  60. }
  61. } else if (args[0].equalsIgnoreCase("host")) {
  62. if (sender.hasPermission("admin.lms.host")) {
  63. if (!plugin.lmshost.contains(p.getName())) {
  64. if (!plugin.lmsjoin.contains(p.getName())) {
  65. Bukkit.getServer().broadcastMessage(
  66. ChatColor.WHITE + "[" + ChatColor.RED
  67. + "EliteFights"
  68. + ChatColor.WHITE + "] "
  69. + p.getName()
  70. + " has started an LMS.");
  71. Bukkit.getServer()
  72. .broadcastMessage(
  73. ChatColor.WHITE
  74. + "["
  75. + ChatColor.RED
  76. + "EliteFights"
  77. + ChatColor.WHITE
  78. + "] "
  79. + "LMS is starting in 30 seconds.");
  80. sender.sendMessage(ChatColor.WHITE + "["
  81. + ChatColor.RED + "EliteFights"
  82. + ChatColor.WHITE + "] "
  83. + ChatColor.WHITE + "You have also"
  84. + ChatColor.ITALIC + " joined"
  85. + ChatColor.WHITE + " the LMS");
  86. plugin.lmshost.add(p.getName());
  87. plugin.lmsjoin.add(p.getName());
  88. }
  89. } else {
  90. p.sendMessage(ChatColor.WHITE + "[" + ChatColor.RED
  91. + "EliteFights" + ChatColor.WHITE + "] "
  92. + "You're already hosting an LMS.");
  93. }
  94. if (plugin.lmsjoin.size() > 1) {
  95. Bukkit.getServer()
  96. // TODO: Time between /lms host and when
  97. // they're
  98. // tp'd
  99. .getScheduler()
  100. .scheduleSyncDelayedTask(plugin,
  101. new Runnable() {
  102. public void run() {
  103. Double x = 1000.00;
  104. Double y = 10.00;
  105. Double z = 1000.00;
  106. Location loc = new Location(
  107. p.getWorld(), x, y,
  108. z);
  109. p.teleport(loc);
  110. p.sendMessage(ChatColor.WHITE
  111. + "["
  112. + ChatColor.RED
  113. + "EliteFights"
  114. + ChatColor.WHITE
  115. + "] "
  116. + "You've been teleported, prepare to fight.");
  117. plugin.lmsarena.add(p
  118. .getName());
  119. plugin.lmshost.remove(p
  120. .getName());
  121. plugin.lmsjoin.remove(p
  122. .getName());
  123.  
  124. }
  125. }, 600);
  126.  
  127. // Syntaxes.
  128. }
  129. }
  130. }
  131. }
  132. return false;
  133. }
  134. return false;
  135. }
  136. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement