vminecraft.java 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. import java.util.logging.Level;
  2. public class vminecraft extends Plugin {
  3. @Override
  4. public void disable() {
  5. //throw new UnsupportedOperationException("Not supported yet.");
  6. }
  7. @Override
  8. public void enable() {
  9. //throw new UnsupportedOperationException("Not supported yet.");
  10. }
  11. public boolean onChat(Player player, String message){
  12. String playerb = player.getName();
  13. String temp2 = "<" + etc.getInstance().getUserColor(playerb) + player.getName() + Colors.White +"> ";
  14. String adminchat = Colors.LightGreen + "{" + etc.getInstance().getUserColor(playerb) + player.getName() + Colors.LightGreen +"}" + Colors.White + " ";
  15. String message2 = "";
  16. String check = temp2+message;
  17. if (message.startsWith("@") && (etc.getInstance().isUserInGroup(player, "mods") || etc.getInstance().isUserInGroup(player, "admins") || etc.getInstance().isUserInGroup(player, "superadmins"))) {
  18. for (Player p : etc.getServer().getPlayerList()) {
  19. if (p != null) {
  20. if (etc.getInstance().isUserInGroup(p, "mods") || (etc.getInstance().isUserInGroup(p, "admins")) || (etc.getInstance().isUserInGroup(p, "superadmins"))) {
  21. String blaa = "";
  22. for ( int x = 1; x< message.length(); x++) {
  23. blaa+=message.charAt(x);
  24. }
  25. p.sendMessage(adminchat+blaa);
  26. id.a.log(Level.INFO, "@"+message);
  27. }
  28. }
  29. }
  30. return true;
  31. }
  32. if (message.startsWith(">")) {
  33. message = Colors.LightGreen + message;
  34. message2 = temp2 + message;
  35. other.gmsg(message2);
  36. id.a.log(Level.INFO, message2);
  37. return true;
  38. }
  39. if (message.startsWith("FFF")) {
  40. message = Colors.Red + message;
  41. message2 = temp2 + message;
  42. other.gmsg(message2);
  43. id.a.log(Level.INFO, message2);
  44. return true;
  45. }
  46. if(message.length()>2 && lengthCheck(check)) {
  47. String temp = "";
  48. for(int x = 0; x< message.length(); x++)
  49. {
  50. if(message.charAt(x)=='^'&&x!=message.length()-1)
  51. {
  52. temp+=colorChange(message.charAt(x+1));
  53. x+=1;
  54. }
  55. else{
  56. temp+=message.charAt(x);
  57. }
  58. }
  59. message = temp2 + temp + " ";
  60. for (Player p : etc.getServer().getPlayerList()) {
  61. if (p != null) {
  62. other.gmsg(message);
  63. id.a.log(Level.INFO, message);
  64. return true;
  65. }
  66. }
  67. }
  68. return false;
  69. } //end of onchat
  70. public boolean onCommand(Player player, String[] split) {
  71. if (!etc.getInstance().canUseCommand(player.getName(), split[0])) {
  72. return false;
  73. }
  74. if (split[0].equalsIgnoreCase("/fabulous")) {
  75. etc.getInstance().addCommand("/fabulous", "/fabulous <message>");
  76. if (split.length == 1) {return false;}
  77. String temp = "";
  78. String str = "";
  79. //str = paramString.substring(paramString.indexOf(" ")).trim();
  80. str = id.combineSplit(1, split, " ");
  81. String temp2 = "<" + player.getName() + "> "+str;
  82. String[] rainbow = new String[] {Colors.Red, Colors.Rose, Colors.Yellow, Colors.Green, Colors.Blue, Colors.LightPurple, Colors.Purple};
  83. int counter=0;
  84. if(lengthCheck(temp2))
  85. {
  86. for(int x=0; x<str.length(); x++)
  87. {
  88. temp+=rainbow[counter]+str.charAt(x);
  89. counter++;
  90. if(str.charAt(x)==' ') { counter--;}
  91. if(counter==-1){counter = 6; }
  92. if(counter==7){counter = 0; }
  93. }
  94. str = temp+" ";
  95. String message = "<" + etc.getInstance().getUserColor(player.getName()) + player.getName() + Colors.White + "> " + str;
  96. id.a.log(Level.INFO, "[F]"+str);
  97. other.gmsg(message);
  98. } else {
  99. player.sendMessage(Colors.Rose + "Message is too long");
  100. }
  101. }
  102. else if (split[0].equalsIgnoreCase("/promote")) {
  103. User user2 = etc.getInstance().getUser(split[1]);
  104. if (split.length < 2) {
  105. player.sendMessage(Colors.Rose + "Usage is /promote [player]");
  106. }
  107. if(user2 == null) {
  108. player.sendMessage(Colors.Rose + "Player does not exist.");
  109. return false;
  110. }
  111. //ea player = match(split[1]);
  112. User user = etc.getInstance().getUser(split[1]);
  113. boolean newUser = false;
  114. if (user == null) {
  115. player.sendMessage(Colors.Rose + "Adding new user.");
  116. newUser = true;
  117. user = new User();
  118. user.Name = split[1];
  119. user.Administrator = false;
  120. user.CanModifyWorld = true;
  121. user.IgnoreRestrictions = false;
  122. user.Commands = new String[]{""};
  123. user.Prefix = "";
  124. return false;
  125. }
  126. if (etc.getInstance().isUserInGroup(split[1], "admins") && (etc.getInstance().isUserInGroup(player, "admins") || etc.getInstance().isUserInGroup(player, "superadmins"))) {
  127. player.sendMessage(Colors.Rose + "You cannot promote " + split[1] + " any higher.");
  128. } else if (etc.getInstance().isUserInGroup(split[1], "mods") && etc.getInstance().isUserInGroup(player, "superadmins")) {
  129. user.Groups = ranks.Admins;
  130. etc.getInstance().getDataSource().modifyUser(user);
  131. String message = Colors.Yellow + split[1] + " was promoted to" + Colors.Rose + " Admin";
  132. other.gmsg(message);
  133. } else if (etc.getInstance().isUserInGroup(split[1], "trusted") && etc.getInstance().isUserInGroup(player, "admins")) {
  134. user.Groups = ranks.Mods;
  135. etc.getInstance().getDataSource().modifyUser(user);
  136. String message = Colors.Yellow + split[1] + " was promoted to" + Colors.DarkPurple + " Mods";
  137. other.gmsg(message);
  138. } else if (etc.getInstance().isUserInGroup(split[1], "default") && etc.getInstance().isUserInGroup(player, "mods")) {
  139. user.Groups = ranks.Trusted;
  140. etc.getInstance().getDataSource().modifyUser(user);
  141. String message = Colors.Yellow + split[1] + " was promoted to" + Colors.LightGreen + " Trusted";
  142. other.gmsg(message);
  143. } else player.sendMessage(Colors.Rose + "That didn't work");
  144. if (newUser) {
  145. etc.getInstance().getDataSource().addUser(user);
  146. } else {
  147. etc.getInstance().getDataSource().modifyUser(user);
  148. }
  149. }
  150. else if (split[0].equalsIgnoreCase("/demote")) {
  151. etc.getInstance().addCommand("/demote", "/demote [user]");
  152. if (split.length < 2) {
  153. player.sendMessage(Colors.Rose + "Usage is /demote [player]");
  154. }
  155. if(player == null) {
  156. player.sendMessage(Colors.Rose + "Player does not exist.");
  157. return false;
  158. }
  159. User user = etc.getInstance().getUser(split[1]);
  160. boolean newUser = false;
  161. if (user == null) {
  162. player.sendMessage(Colors.Rose + "Adding new user.");
  163. newUser = true;
  164. user = new User();
  165. user.Name = split[1];
  166. user.Administrator = false;
  167. user.CanModifyWorld = true;
  168. user.IgnoreRestrictions = false;
  169. user.Commands = new String[]{""};
  170. user.Prefix = "";
  171. }
  172. if (etc.getInstance().isUserInGroup(split[1], "admins")&& etc.getInstance().isUserInGroup(player, "superadmins")) {
  173. user.Groups = ranks.Mods;
  174. etc.getInstance().getDataSource().modifyUser(user);
  175. String message = Colors.Yellow + split[1] + " was demoted to" + Colors.DarkPurple + " Mod";
  176. other.gmsg(message);
  177. } else if (etc.getInstance().isUserInGroup(split[1], "mods")&& etc.getInstance().isUserInGroup(player, "admins")) {
  178. user.Groups = ranks.Trusted;
  179. etc.getInstance().getDataSource().modifyUser(user);
  180. String message = Colors.Yellow + split[1] + " was demoted to" + Colors.LightGreen + " Trusted";
  181. other.gmsg(message);
  182. } else if (etc.getInstance().isUserInGroup(split[1], "trusted")&& etc.getInstance().isUserInGroup(player, "mods")) {
  183. user.Groups = ranks.Def;
  184. etc.getInstance().getDataSource().modifyUser(user);
  185. String message = Colors.Yellow + split[1] + " was demoted to" + Colors.White + " Default";
  186. other.gmsg(message);
  187. } else if (etc.getInstance().isUserInGroup(split[1], "default")) {
  188. player.sendMessage(Colors.Rose + "You cannot demote " + split[1] + " any lower.");
  189. } else player.sendMessage(Colors.Rose + "That didn't work");
  190. if (newUser) {
  191. etc.getInstance().getDataSource().addUser(user);
  192. } else {
  193. etc.getInstance().getDataSource().modifyUser(user);
  194. }
  195. }
  196. else {
  197. return false;
  198. }
  199. return true;
  200. }
  201. private boolean lengthCheck(String str)
  202. {
  203. int length = 0;
  204. for(int x = 0; x<str.length(); x++)
  205. {
  206. if("i;,.:|!".indexOf(str.charAt(x)) != -1)
  207. {
  208. length+=2;
  209. }
  210. else if("l'".indexOf(str.charAt(x)) != -1)
  211. {
  212. length+=3;
  213. }
  214. else if("tI[]".indexOf(str.charAt(x)) != -1)
  215. {
  216. length+=4;
  217. }
  218. else if("kf{}<>\"*()".indexOf(str.charAt(x)) != -1)
  219. {
  220. length+=5;
  221. }
  222. else if("hequcbrownxjmpsvazydgTHEQUCKBROWNFXJMPSVLAZYDG1234567890#\\/?$%-=_+&".indexOf(str.charAt(x)) != -1)
  223. {
  224. length+=6;
  225. }
  226. else if("@~".indexOf(str.charAt(x)) != -1)
  227. {
  228. length+=7;
  229. }
  230. else if(str.charAt(x)==' ')
  231. {
  232. length+=4;
  233. }
  234. }
  235. if(length<=316)
  236. {
  237. return true;
  238. } else { return false; }
  239. }
  240. private String colorChange(char colour)
  241. {
  242. String color = "";
  243. switch(colour)
  244. {
  245. case '0':
  246. color = Colors.Black;
  247. break;
  248. case '1':
  249. color = Colors.Navy;
  250. break;
  251. case '2':
  252. color = Colors.Green;
  253. break;
  254. case '3':
  255. color = Colors.Blue;
  256. break;
  257. case '4':
  258. color = Colors.Red;
  259. break;
  260. case '5':
  261. color = Colors.Purple;
  262. break;
  263. case '6':
  264. color = Colors.Gold;
  265. break;
  266. case '7':
  267. color = Colors.LightGray;
  268. break;
  269. case '8':
  270. color = Colors.Gray;
  271. break;
  272. case '9':
  273. color = Colors.DarkPurple;
  274. break;
  275. case 'a':
  276. color = Colors.LightGreen;
  277. break;
  278. case 'b':
  279. color = Colors.LightBlue;
  280. break;
  281. case 'c':
  282. color = Colors.Rose;
  283. break;
  284. case 'd':
  285. color = Colors.LightPurple;
  286. break;
  287. case 'e':
  288. color = Colors.Yellow;
  289. break;
  290. case 'f':
  291. color = Colors.White;
  292. break;
  293. case 'A':
  294. color = Colors.LightGreen;
  295. break;
  296. case 'B':
  297. color = Colors.LightBlue;
  298. break;
  299. case 'C':
  300. color = Colors.Rose;
  301. break;
  302. case 'D':
  303. color = Colors.LightPurple;
  304. break;
  305. case 'E':
  306. color = Colors.Yellow;
  307. break;
  308. case 'F':
  309. color = Colors.White;
  310. break;
  311. default:
  312. color = Colors.White;
  313. break;
  314. }
  315. return color;
  316. }
  317. }