PageRenderTime 40ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/src/id.java

https://github.com/kpfile/Minecraft-Server-Mod
Java | 1113 lines | 989 code | 92 blank | 32 comment | 456 complexity | 2578634569bccf564c8ce3466269ee7f MD5 | raw file
  1. import java.net.SocketAddress;
  2. import java.util.ArrayList;
  3. import java.util.Calendar;
  4. import java.util.Date;
  5. import java.util.HashMap;
  6. import java.util.List;
  7. import java.util.Map;
  8. import java.util.Map.Entry;
  9. import java.util.logging.Level;
  10. import java.util.logging.Logger;
  11. import net.minecraft.server.MinecraftServer;
  12. public class id extends ej
  13. implements ef {
  14. public static Logger a = Logger.getLogger("Minecraft");
  15. public bb b;
  16. public boolean c = false;
  17. private MinecraftServer d;
  18. private ea e;
  19. private int f = 0;
  20. private double g;
  21. private double h;
  22. private double i;
  23. private boolean j = true;
  24. private gp k = null;
  25. private List<String> onlyOneUseKits = new ArrayList<String>();
  26. public id(MinecraftServer paramMinecraftServer, bb parambb, ea paramea) {
  27. this.d = paramMinecraftServer;
  28. this.b = parambb;
  29. parambb.a(this);
  30. this.e = paramea;
  31. paramea.a = this;
  32. }
  33. public void a() {
  34. this.b.a();
  35. if (this.f++ % 20 == 0) {
  36. this.b.a(new iz());
  37. }
  38. }
  39. public void c(String paramString) {
  40. this.b.a(new io(paramString));
  41. this.b.c();
  42. this.d.f.c(this.e);
  43. this.c = true;
  44. }
  45. public void a(gf paramgf) {
  46. double d1;
  47. if (!this.j) {
  48. d1 = paramgf.b - this.h;
  49. if ((paramgf.a == this.g) && (d1 * d1 < 0.01D) && (paramgf.c == this.i)) {
  50. this.j = true;
  51. }
  52. }
  53. if (this.j) {
  54. this.g = this.e.l;
  55. this.h = this.e.m;
  56. this.i = this.e.n;
  57. d1 = this.e.l;
  58. double d2 = this.e.m;
  59. double d3 = this.e.n;
  60. float f1 = this.e.r;
  61. float f2 = this.e.s;
  62. if (paramgf.h) {
  63. d1 = paramgf.a;
  64. d2 = paramgf.b;
  65. d3 = paramgf.c;
  66. double d4 = paramgf.d - paramgf.b;
  67. if ((d4 > 1.65D) || (d4 < 0.1D)) {
  68. c("Illegal stance");
  69. a.warning(this.e.aq + " had an illegal stance: " + d4);
  70. }
  71. this.e.ai = paramgf.d;
  72. }
  73. if (paramgf.i) {
  74. f1 = paramgf.e;
  75. f2 = paramgf.f;
  76. }
  77. this.e.i();
  78. this.e.M = 0.0F;
  79. this.e.b(this.g, this.h, this.i, f1, f2);
  80. double d4 = d1 - this.e.l;
  81. double d5 = d2 - this.e.m;
  82. double d6 = d3 - this.e.n;
  83. float f3 = 0.0625F;
  84. int m = this.d.e.a(this.e, this.e.v.b().e(f3, f3, f3)).size() == 0 ? 1 : 0;
  85. this.e.c(d4, d5, d6);
  86. d4 = d1 - this.e.l;
  87. d5 = d2 - this.e.m;
  88. if ((d5 > -0.5D) || (d5 < 0.5D)) {
  89. d5 = 0.0D;
  90. }
  91. d6 = d3 - this.e.n;
  92. double d7 = d4 * d4 + d5 * d5 + d6 * d6;
  93. int n = 0;
  94. if (d7 > 0.0625D) {
  95. n = 1;
  96. a.warning(this.e.aq + " moved wrongly!");
  97. }
  98. this.e.b(d1, d2, d3, f1, f2);
  99. int i1 = this.d.e.a(this.e, this.e.v.b().e(f3, f3, f3)).size() == 0 ? 1 : 0;
  100. if ((m != 0) && ((n != 0) || (i1 == 0))) {
  101. a(this.g, this.h, this.i, f1, f2);
  102. return;
  103. }
  104. this.e.w = paramgf.g;
  105. this.d.f.b(this.e);
  106. }
  107. }
  108. public void a(double paramDouble1, double paramDouble2, double paramDouble3, float paramFloat1, float paramFloat2) {
  109. this.j = false;
  110. this.g = paramDouble1;
  111. this.h = paramDouble2;
  112. this.i = paramDouble3;
  113. this.e.b(paramDouble1, paramDouble2, paramDouble3, paramFloat1, paramFloat2);
  114. this.e.a.b(new dq(paramDouble1, paramDouble2 + 1.620000004768372D, paramDouble2, paramDouble3, paramFloat1, paramFloat2, false));
  115. }
  116. //Destroy function
  117. public void a(hd paramhd) {
  118. this.e.aj.a[this.e.aj.d] = this.k;
  119. boolean bool = this.d.e.z = (this.d.f.g(this.e.aq) || etc.getInstance().isAdmin(e));
  120. int m = 0;
  121. if (paramhd.e == 0) {
  122. m = 1;
  123. }
  124. if (paramhd.e == 1) {
  125. m = 1;
  126. }
  127. if (m != 0) {
  128. double d1 = this.e.m;
  129. this.e.m = this.e.ai;
  130. fr localfr = this.e.a(4.0D, 1.0F);
  131. this.e.m = d1;
  132. if (localfr == null) {
  133. return;
  134. }
  135. if ((localfr.b != paramhd.a) || (localfr.c != paramhd.b) || (localfr.d != paramhd.c) || (localfr.e != paramhd.d)) {
  136. return;
  137. }
  138. }
  139. int n = paramhd.a;
  140. int i1 = paramhd.b;
  141. int i2 = paramhd.c;
  142. int i3 = paramhd.d;
  143. int i4 = (int) gj.e(n - this.d.e.n);
  144. int i5 = (int) gj.e(i2 - this.d.e.p);
  145. if (i4 > i5) {
  146. i5 = i4;
  147. }
  148. if (paramhd.e == 0) {
  149. if (!etc.getInstance().canBuild(e)) {
  150. return;
  151. }
  152. if (i5 > etc.getInstance().spawnProtectionSize || bool) {
  153. if (!(Boolean)etc.getInstance().getLoader().callHook(PluginLoader.Hook.BLOCK_DESTROYED, new Object[] {e, etc.getServer().getBlockAt(n, i1, i2)}))
  154. this.e.ad.a(n, i1, i2);
  155. }
  156. } else if (paramhd.e == 2) {
  157. this.e.ad.a();
  158. } else if (paramhd.e == 1) {
  159. if (!etc.getInstance().canBuild(e)) {
  160. return;
  161. }
  162. if (i5 > etc.getInstance().spawnProtectionSize || bool) {
  163. if (!(Boolean)etc.getInstance().getLoader().callHook(PluginLoader.Hook.BLOCK_DESTROYED, new Object[] {e, etc.getServer().getBlockAt(n, i1, i2)}))
  164. this.e.ad.a(n, i1, i2, i3);
  165. }
  166. } else if (paramhd.e == 3) {
  167. double d2 = this.e.l - (n + 0.5D);
  168. double d3 = this.e.m - (i1 + 0.5D);
  169. double d4 = this.e.n - (i2 + 0.5D);
  170. double d5 = d2 * d2 + d3 * d3 + d4 * d4;
  171. if (d5 < 256.0D) {
  172. this.e.a.b(new et(n, i1, i2, this.d.e));
  173. }
  174. }
  175. this.d.e.z = false;
  176. }
  177. //Build function
  178. public void a(fe paramfe) {
  179. if (!etc.getInstance().canBuild(e)) {
  180. return;
  181. }
  182. boolean bool = this.d.e.z = (this.d.f.g(this.e.aq) || etc.getInstance().isAdmin(e));
  183. int m = paramfe.b;
  184. int n = paramfe.c;
  185. int i1 = paramfe.d;
  186. int i2 = paramfe.e;
  187. int i3 = (int) gj.e(m - this.d.e.n);
  188. int i4 = (int) gj.e(i1 - this.d.e.p);
  189. if (i3 > i4) {
  190. i4 = i3;
  191. }
  192. if (i4 > etc.getInstance().spawnProtectionSize || bool) {
  193. gp localgp = paramfe.a >= 0 ? new gp(paramfe.a) : null;
  194. Block blockPlaced = new Block(localgp != null ? localgp.c : paramfe.a, m, n, i1);
  195. if (paramfe.e == 0)
  196. blockPlaced.setY(blockPlaced.getY() - 1);
  197. else if(paramfe.e == 1)
  198. blockPlaced.setY(blockPlaced.getY() + 1);
  199. else if(paramfe.e == 2)
  200. blockPlaced.setZ(blockPlaced.getZ() - 1);
  201. else if(paramfe.e == 3)
  202. blockPlaced.setZ(blockPlaced.getZ() + 1);
  203. else if(paramfe.e == 4)
  204. blockPlaced.setX(blockPlaced.getX() - 1);
  205. else if(paramfe.e == 5)
  206. blockPlaced.setX(blockPlaced.getX() + 1);
  207. Block blockClicked = new Block(etc.getServer().getBlockIdAt(m, n, i1), m, n, i1);
  208. if (!(Boolean)etc.getInstance().getLoader().callHook(PluginLoader.Hook.BLOCK_CREATED, new Object[] {e, blockPlaced, blockClicked, paramfe.a})) {
  209. if (localgp != null) {
  210. if (!etc.getInstance().isOnItemBlacklist(localgp.c) || bool) {
  211. this.e.ad.a(this.e, this.d.e, localgp, m, n, i1, i2);
  212. }
  213. } else {
  214. // is this right?
  215. this.e.ad.a(this.e, this.d.e, localgp, m, n, i1, i2);
  216. }
  217. }
  218. }
  219. this.e.a.b(new et(m, n, i1, this.d.e));
  220. this.d.e.z = false;
  221. }
  222. public void a(String paramString) {
  223. etc.getInstance().getLoader().callHook(PluginLoader.Hook.DISCONNECT, new Object[] { e });
  224. a.info(this.e.aq + " lost connection: " + paramString);
  225. this.d.f.c(this.e);
  226. this.c = true;
  227. }
  228. public void a(hp paramhp) {
  229. a.warning(getClass() + " wasn't prepared to deal with a " + paramhp.getClass());
  230. c("Protocol error, unexpected packet");
  231. }
  232. public void b(hp paramhp) {
  233. this.b.a(paramhp);
  234. }
  235. public void a(fv paramfv) {
  236. int m = paramfv.b;
  237. this.e.aj.d = (this.e.aj.a.length - 1);
  238. if (m == 0) {
  239. this.k = null;
  240. } else {
  241. this.k = new gp(m);
  242. }
  243. this.e.aj.a[this.e.aj.d] = this.k;
  244. this.d.k.a(this.e, new fv(this.e.c, m));
  245. }
  246. public void a(k paramk) {
  247. double d1 = paramk.b / 32.0D;
  248. double d2 = paramk.c / 32.0D;
  249. double d3 = paramk.d / 32.0D;
  250. fn localfn = new fn(this.d.e, d1, d2, d3, new gp(paramk.h, paramk.i));
  251. localfn.o = (paramk.e / 128.0D);
  252. localfn.p = (paramk.f / 128.0D);
  253. localfn.q = (paramk.g / 128.0D);
  254. localfn.ad = 10;
  255. this.d.e.a(localfn);
  256. }
  257. public void a(ba paramba) {
  258. String str = paramba.a;
  259. if (str.length() > 100) {
  260. b("Chat message too long");
  261. return;
  262. }
  263. str = str.trim();
  264. for (int k = 0; k < str.length(); ++k) {
  265. if (" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_'abcdefghijklmnopqrstuvwxyz{|}~¦ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜø£Ø׃áíóúñѪº¿®¬½¼¡«»".indexOf(str.charAt(k)) < 0) {
  266. b("Illegal characters in chat");
  267. return;
  268. }
  269. }
  270. if (str.startsWith("/")) {
  271. d(str);
  272. } else {
  273. if (etc.getInstance().isMuted(e)) {
  274. msg(Colors.Rose + "You are currently muted.");
  275. return;
  276. }
  277. if ((Boolean)etc.getInstance().getLoader().callHook(PluginLoader.Hook.CHAT, new Object[]{e, str}))
  278. return;
  279. String message = "<" + etc.getInstance().getUserColor(e.aq) + this.e.aq + Colors.White + "> " + str;
  280. a.log(Level.INFO, "<" + e.aq + "> " + str);
  281. this.d.f.a(new ba(message));
  282. }
  283. }
  284. private ea match(String name) {
  285. ea player = null;
  286. boolean found = false;
  287. if (("`" + this.d.f.c().toUpperCase() + "`").split(name.toUpperCase()).length == 2) {
  288. for (int i = 0; i < this.d.f.b.size() && !found; ++i) {
  289. ea localea = (ea) this.d.f.b.get(i);
  290. if (("`" + localea.aq.toUpperCase() + "`").split(name.toUpperCase()).length == 2) {
  291. player = localea;
  292. found = true;
  293. }
  294. }
  295. } else if (("`" + this.d.f.c() + "`").split(name).length > 2) {
  296. // Too many partial matches.
  297. for (int i = 0; i < this.d.f.b.size() && !found; ++i) {
  298. ea localea = (ea) this.d.f.b.get(i);
  299. if (localea.aq.equalsIgnoreCase(name)) {
  300. player = localea;
  301. found = true;
  302. }
  303. }
  304. }
  305. return player;
  306. }
  307. /**
  308. * Combines the string array into a string at the specified start with the
  309. * separator separating each string.
  310. * @param startIndex
  311. * @param string
  312. * @param seperator
  313. * @return
  314. */
  315. public static String combineSplit(int startIndex, String[] string, String seperator) {
  316. StringBuilder builder = new StringBuilder();
  317. for (int i = startIndex; i < string.length; i++) {
  318. builder.append(string[i]);
  319. builder.append(seperator);
  320. }
  321. builder.deleteCharAt(builder.length() - seperator.length()); // remove the extra
  322. // seperator
  323. return builder.toString();
  324. }
  325. /**
  326. * Returns true if this player has control over the other player
  327. * @param player
  328. * @return
  329. */
  330. public boolean hasControlOver(ea player) {
  331. boolean isInGroup = false;
  332. if (etc.getInstance().getUser(player.aq) != null) {
  333. for (String str : etc.getInstance().getUser(player.aq).Groups) {
  334. if (etc.getInstance().isUserInGroup(e, str)) {
  335. isInGroup = true;
  336. }
  337. }
  338. } else {
  339. return true;
  340. }
  341. return isInGroup;
  342. }
  343. /**
  344. * Sends a message to the player
  345. * @param msg
  346. */
  347. public void msg(String msg) {
  348. b(new ba(msg));
  349. }
  350. private void d(String paramString) {
  351. try {
  352. if (etc.getInstance().isLogging()) {
  353. a.info("Command used by " + e.aq + " " + paramString);
  354. }
  355. String[] split = paramString.split(" ");
  356. if ((Boolean)etc.getInstance().getLoader().callHook(PluginLoader.Hook.COMMAND, new Object[]{e, split})) {
  357. return; //No need to go on, commands were parsed.
  358. }
  359. if (!etc.getInstance().canUseCommand(e.aq, split[0]) && !split[0].startsWith("/#")) {
  360. msg(Colors.Rose + "Unknown command.");
  361. return;
  362. }
  363. if (split[0].equalsIgnoreCase("/help")) {
  364. //Meh, not the greatest way, but not the worst either.
  365. List<String> availableCommands = new ArrayList<String>();
  366. for (Entry<String, String> entry : etc.getInstance().commands.entrySet()) {
  367. if (etc.getInstance().canUseCommand(e.aq, entry.getKey())) {
  368. if (entry.getKey().equals("/kit") && !etc.getInstance().getDataSource().hasKits()) {
  369. continue;
  370. }
  371. if (entry.getKey().equals("/listwarps") && !etc.getInstance().getDataSource().hasWarps()) {
  372. continue;
  373. }
  374. availableCommands.add(entry.getKey() + " " + entry.getValue());
  375. }
  376. }
  377. msg(Colors.Blue + "Available commands (Page " + (split.length == 2 ? split[1] : "1") + " of " + (int) Math.ceil((double) availableCommands.size() / (double) 7) + ") [] = required <> = optional:");
  378. if (split.length == 2) {
  379. try {
  380. int amount = Integer.parseInt(split[1]);
  381. if (amount > 0) {
  382. amount = (amount - 1) * 7;
  383. } else {
  384. amount = 0;
  385. }
  386. for (int i = amount; i < amount + 7; i++) {
  387. if (availableCommands.size() > i) {
  388. msg(Colors.Rose + availableCommands.get(i));
  389. }
  390. }
  391. } catch (NumberFormatException ex) {
  392. msg(Colors.Rose + "Not a valid page number.");
  393. }
  394. } else {
  395. for (int i = 0; i < 7; i++) {
  396. if (availableCommands.size() > i) {
  397. msg(Colors.Rose + availableCommands.get(i));
  398. }
  399. }
  400. }
  401. } else if (split[0].equalsIgnoreCase("/reload")) {
  402. etc.getInstance().load();
  403. etc.getInstance().loadData();
  404. a.info("Reloaded config");
  405. msg("Successfuly reloaded config");
  406. } else if ((split[0].equalsIgnoreCase("/modify") || split[0].equalsIgnoreCase("/mp"))) {
  407. if (split.length < 4) {
  408. msg(Colors.Rose + "Usage is: /modify [player] [key] [value]");
  409. msg(Colors.Rose + "Keys:");
  410. msg(Colors.Rose + "prefix: only the letter the color represents");
  411. msg(Colors.Rose + "commands: list seperated by comma");
  412. msg(Colors.Rose + "groups: list seperated by comma");
  413. msg(Colors.Rose + "ignoresrestrictions: true or false");
  414. msg(Colors.Rose + "admin: true or false");
  415. msg(Colors.Rose + "modworld: true or false");
  416. return;
  417. }
  418. ea player = match(split[1]);
  419. if (player == null) {
  420. msg(Colors.Rose + "Player does not exist.");
  421. return;
  422. }
  423. String key = split[2];
  424. String value = split[3];
  425. User user = etc.getInstance().getUser(player.aq);
  426. boolean newUser = false;
  427. if (user == null) {
  428. if (!key.equalsIgnoreCase("groups") && !key.equalsIgnoreCase("g")) {
  429. msg(Colors.Rose + "When adding a new user, set their group(s) first.");
  430. return;
  431. }
  432. msg(Colors.Rose + "Adding new user.");
  433. newUser = true;
  434. user = new User();
  435. user.Name = split[1];
  436. user.Administrator = false;
  437. user.CanModifyWorld = true;
  438. user.IgnoreRestrictions = false;
  439. user.Commands = new String[]{""};
  440. user.Prefix = "";
  441. }
  442. if (key.equalsIgnoreCase("prefix") || key.equalsIgnoreCase("p")) {
  443. user.Prefix = value;
  444. } else if (key.equalsIgnoreCase("commands") || key.equalsIgnoreCase("c")) {
  445. user.Commands = value.split(",");
  446. } else if (key.equalsIgnoreCase("groups") || key.equalsIgnoreCase("g")) {
  447. user.Groups = value.split(",");
  448. } else if (key.equalsIgnoreCase("ignoresrestrictions") || key.equalsIgnoreCase("ir")) {
  449. user.IgnoreRestrictions = value.equalsIgnoreCase("true") || value.equals("1");
  450. } else if (key.equalsIgnoreCase("admin") || key.equalsIgnoreCase("a")) {
  451. user.Administrator = value.equalsIgnoreCase("true") || value.equals("1");
  452. } else if (key.equalsIgnoreCase("modworld") || key.equalsIgnoreCase("mw")) {
  453. user.CanModifyWorld = value.equalsIgnoreCase("true") || value.equals("1");
  454. }
  455. if (newUser) {
  456. etc.getInstance().getDataSource().addUser(user);
  457. } else {
  458. etc.getInstance().getDataSource().modifyUser(user);
  459. }
  460. msg(Colors.Rose + "Modified user.");
  461. a.info("Modifed user " + split[1] + ". " + key + " => " + value + " by " + e.aq);
  462. } else if (split[0].equalsIgnoreCase("/whitelist")) {
  463. if (split.length < 2) {
  464. msg(Colors.Rose + "whitelist [operation (toggle, add or remove)] <player>");
  465. return;
  466. }
  467. if (split[1].equalsIgnoreCase("toggle")) {
  468. msg(Colors.Rose + (etc.getInstance().toggleWhitelist() ? "Whitelist enabled" : "Whitelist disabled"));
  469. } else if(split.length == 3) {
  470. if (split[1].equalsIgnoreCase("add")) {
  471. etc.getInstance().getDataSource().addToWhitelist(split[2]);
  472. msg(Colors.Rose + split[2] + " added to whitelist");
  473. } else if (split[1].equalsIgnoreCase("remove")) {
  474. etc.getInstance().getDataSource().removeFromWhitelist(split[2]);
  475. msg(Colors.Rose + split[2] + " removed from whitelist");
  476. } else {
  477. msg(Colors.Rose + "Invalid operation.");
  478. }
  479. } else {
  480. msg(Colors.Rose + "Invalid operation.");
  481. }
  482. } else if (split[0].equalsIgnoreCase("/reservelist")) {
  483. if (split.length != 3) {
  484. msg(Colors.Rose + "reservelist [operation (add or remove)] [player]");
  485. return;
  486. }
  487. if (split[1].equalsIgnoreCase("add")) {
  488. etc.getInstance().getDataSource().addToReserveList(split[2]);
  489. msg(Colors.Rose + split[2] + " added to reservelist");
  490. } else if (split[1].equalsIgnoreCase("remove")) {
  491. etc.getInstance().getDataSource().removeFromReserveList(split[2]);
  492. msg(Colors.Rose + split[2] + " removed from reservelist");
  493. } else {
  494. msg(Colors.Rose + "Invalid operation.");
  495. }
  496. } else if (split[0].equalsIgnoreCase("/mute")) {
  497. if (split.length != 2) {
  498. msg(Colors.Rose + "Correct usage is: /mute [player]");
  499. return;
  500. }
  501. ea player = match(split[1]);
  502. if (player != null) {
  503. if (etc.getInstance().toggleMute(player)) {
  504. msg(Colors.Rose + "player was muted");
  505. } else {
  506. msg(Colors.Rose + "player was unmuted");
  507. }
  508. } else {
  509. msg(Colors.Rose + "Can't find player " + split[1]);
  510. }
  511. } else if ((split[0].equalsIgnoreCase("/msg") || split[0].equalsIgnoreCase("/tell")) || split[0].equalsIgnoreCase("/m")) {
  512. if (split.length < 3) {
  513. msg(Colors.Rose + "Correct usage is: /msg [player] [message]");
  514. return;
  515. }
  516. if (etc.getInstance().isMuted(e)) {
  517. msg(Colors.Rose + "You are currently muted.");
  518. return;
  519. }
  520. ea player = match(split[1]);
  521. if (player != null) {
  522. if (player.aq.equals(e.aq)) {
  523. msg(Colors.Rose + "You can't message yourself!");
  524. return;
  525. }
  526. String prefix = etc.getInstance().getUserColor(e.aq);
  527. player.a.msg("(MSG) " + prefix + "<" + e.aq + "> " + Colors.White + combineSplit(2, split, " "));
  528. msg("(MSG) " + prefix + "<" + e.aq + "> " + Colors.White + combineSplit(2, split, " "));
  529. } else {
  530. msg(Colors.Rose + "Couldn't find player " + split[1]);
  531. }
  532. } else if (split[0].equalsIgnoreCase("/kit") && etc.getInstance().getDataSource().hasKits()) {
  533. if (split.length != 2 && split.length != 3) {
  534. msg(Colors.Rose + "Available kits" + Colors.White + ": " + etc.getInstance().getDataSource().getKitNames(e.aq));
  535. return;
  536. }
  537. ea toGive = e;
  538. if (split.length > 2 && etc.getInstance().canIgnoreRestrictions(e)) {
  539. toGive = match(split[1]);
  540. }
  541. Kit kit = etc.getInstance().getDataSource().getKit(split[1]);
  542. if (toGive != null) {
  543. if (kit != null) {
  544. if (!etc.getInstance().isUserInGroup(e, kit.Group) && !kit.Group.equals("")) {
  545. msg(Colors.Rose + "That kit does not exist.");
  546. } else if (onlyOneUseKits.contains(kit.Name)) {
  547. msg(Colors.Rose + "You can only get this kit once per login.");
  548. } else if (MinecraftServer.b.containsKey(this.e.aq + " " + kit.Name)) {
  549. msg(Colors.Rose + "You can't get this kit again for a while.");
  550. } else {
  551. if (!etc.getInstance().canIgnoreRestrictions(e)) {
  552. if (kit.Delay >= 0) {
  553. MinecraftServer.b.put(this.e.aq + " " + kit.Name, kit.Delay);
  554. } else {
  555. onlyOneUseKits.add(kit.Name);
  556. }
  557. }
  558. a.info(this.e.aq + " got a kit!");
  559. toGive.a.msg(Colors.Rose + "Enjoy this kit!");
  560. for (Map.Entry<String, Integer> entry : kit.IDs.entrySet()) {
  561. try {
  562. int itemId = 0;
  563. try {
  564. itemId = Integer.parseInt(entry.getKey());
  565. } catch (NumberFormatException n) {
  566. itemId = etc.getInstance().getDataSource().getItem(entry.getKey());
  567. }
  568. int temp = kit.IDs.get(entry.getKey());
  569. do {
  570. if (temp - 64 >= 64) {
  571. toGive.a(new gp(itemId, 64));
  572. } else {
  573. toGive.a(new gp(itemId, temp));
  574. }
  575. temp -= 64;
  576. } while (temp >= 64);
  577. } catch (Exception e1) {
  578. a.info("Got an exception while giving out a kit (Kit name \"" + kit.Name + "\"). Are you sure all the Ids are numbers?");
  579. msg(Colors.Rose + "The server encountered a problem while giving the kit :(");
  580. }
  581. }
  582. }
  583. } else {
  584. msg(Colors.Rose + "That kit does not exist.");
  585. }
  586. } else {
  587. msg(Colors.Rose + "That user does not exist.");
  588. }
  589. } else if (split[0].equalsIgnoreCase("/tp")) {
  590. if (split.length < 2) {
  591. msg(Colors.Rose + "Correct usage is: /tp [player]");
  592. return;
  593. }
  594. ea player = match(split[1]);
  595. if (this.e.aq.equalsIgnoreCase(split[1])) {
  596. msg(Colors.Rose + "You're already here!");
  597. return;
  598. }
  599. if (player != null) {
  600. a.info(this.e.aq + " teleported to " + player.aq);
  601. a(player.l, player.m, player.n, player.r, player.s);
  602. } else {
  603. msg(Colors.Rose + "Can't find user " + split[1] + ".");
  604. }
  605. } else if ((split[0].equalsIgnoreCase("/tphere") || split[0].equalsIgnoreCase("/s"))) {
  606. if (split.length < 2) {
  607. msg(Colors.Rose + "Correct usage is: /tphere [player]");
  608. return;
  609. }
  610. ea player = match(split[1]);
  611. if (this.e.aq.equalsIgnoreCase(split[1])) {
  612. msg(Colors.Rose + "Wow look at that! You teleported yourself to yourself!");
  613. return;
  614. }
  615. if (player != null) {
  616. a.info(this.e.aq + " teleported " + player.aq + " to their self.");
  617. player.a.a(e.l, e.m, e.n, e.r, e.s);
  618. } else {
  619. msg(Colors.Rose + "Can't find user " + split[1] + ".");
  620. }
  621. } else if (split[0].equalsIgnoreCase("/playerlist") || split[0].equalsIgnoreCase("/who")) {
  622. msg(Colors.Rose + "Player list (" + d.f.b.size() + "/" + etc.getInstance().playerLimit + "): " + Colors.White + d.f.c());
  623. } else if (split[0].equalsIgnoreCase("/item") || split[0].equalsIgnoreCase("/i") || split[0].equalsIgnoreCase("/give")) {
  624. if (split.length < 2) {
  625. if (etc.getInstance().canIgnoreRestrictions(e)) {
  626. msg(Colors.Rose + "Correct usage is: /item [itemid] <amount> <player> (optional)");
  627. } else {
  628. msg(Colors.Rose + "Correct usage is: /item [itemid] <amount>");
  629. }
  630. return;
  631. }
  632. ea toGive = e;
  633. if (split.length == 4 && etc.getInstance().canIgnoreRestrictions(e)) {
  634. toGive = match(split[3]);
  635. }
  636. if (toGive != null) {
  637. try {
  638. int i2 = 0;
  639. try {
  640. i2 = Integer.parseInt(split[1]);
  641. } catch (NumberFormatException n) {
  642. i2 = etc.getInstance().getDataSource().getItem(split[1]);
  643. }
  644. int i3 = 1;
  645. if (split.length > 2) {
  646. i3 = Integer.parseInt(split[2]);
  647. }
  648. String i2str = Integer.toString(i2);
  649. if (i3 == -1 && etc.getInstance().isAdmin(e)) {
  650. i3 = 255;
  651. } else if (i3 <= 0) {
  652. i3 = 1;
  653. }
  654. if (i3 > 64 && !etc.getInstance().canIgnoreRestrictions(this.e)) {
  655. i3 = 64;
  656. }
  657. boolean allowedItem = false;
  658. if (!etc.getInstance().allowedItems[0].equals("") && (!etc.getInstance().canIgnoreRestrictions(this.e))) {
  659. for (String str : etc.getInstance().allowedItems) {
  660. if (i2str.equals(str)) {
  661. allowedItem = true;
  662. }
  663. }
  664. } else {
  665. allowedItem = true;
  666. }
  667. if (!etc.getInstance().disallowedItems[0].equals("") && !etc.getInstance().canIgnoreRestrictions(this.e)) {
  668. for (String str : etc.getInstance().disallowedItems) {
  669. if (i2str.equals(str)) {
  670. allowedItem = false;
  671. }
  672. }
  673. }
  674. if (i2 < ez.c.length) {
  675. if (ez.c[i2] != null && (allowedItem || etc.getInstance().canIgnoreRestrictions(this.e))) {
  676. a.log(Level.INFO, "Giving " + toGive.aq + " some " + i2);
  677. if (i3 == 255) {
  678. toGive.a(new gp(i2, 255));
  679. } else {
  680. int temp = i3;
  681. do {
  682. if (temp - 64 >= 64) {
  683. toGive.a(new gp(i2, 64));
  684. } else {
  685. toGive.a(new gp(i2, temp));
  686. }
  687. temp -= 64;
  688. } while (temp >= 64);
  689. }
  690. if (toGive == this.e) {
  691. msg(Colors.Rose + "There you go c:");
  692. } else {
  693. msg(Colors.Rose + "Gift given! :D");
  694. toGive.a.msg(Colors.Rose + "Enjoy your gift! :D");
  695. }
  696. } else if ((!allowedItem) && (ez.c[i2] != null) && !etc.getInstance().canIgnoreRestrictions(this.e)) {
  697. msg(Colors.Rose + "You are not allowed to spawn that item.");
  698. } else {
  699. msg(Colors.Rose + "No item with ID " + split[1]);
  700. }
  701. } else {
  702. msg(Colors.Rose + "No item with ID " + split[1]);
  703. }
  704. } catch (NumberFormatException localNumberFormatException) {
  705. msg(Colors.Rose + "Improper ID and/or amount.");
  706. }
  707. } else {
  708. msg(Colors.Rose + "Can't find user " + split[3]);
  709. }
  710. } else if (split[0].equalsIgnoreCase("/tempban")) {
  711. // /tempban MINUTES HOURS DAYS
  712. if (split.length == 1) {
  713. //TODO;
  714. return;
  715. }
  716. int minutes = 0, hours = 0, days = 0;
  717. if (split.length >= 2) {
  718. minutes = Integer.parseInt(split[1]);
  719. }
  720. if (split.length >= 3) {
  721. hours = Integer.parseInt(split[2]);
  722. }
  723. if (split.length >= 4) {
  724. days = Integer.parseInt(split[3]);
  725. }
  726. Date date = new Date();
  727. //date.
  728. } else if (split[0].equalsIgnoreCase("/banlist")) {
  729. byte type = 0;
  730. if (split.length == 2) {
  731. if (split[1].equalsIgnoreCase("ips")) {
  732. type = 1;
  733. }
  734. }
  735. if (type == 0) { //Regular user bans
  736. msg(Colors.Blue + "Ban list:" + Colors.White + " " + d.f.getBans());
  737. } else { //IP bans
  738. msg(Colors.Blue + "IP Ban list:" + Colors.White + " " + d.f.getBans());
  739. }
  740. } else if (split[0].equalsIgnoreCase("/banip")) {
  741. if (split.length < 2) {
  742. msg(Colors.Rose + "Correct usage is: /banip [player] <reason> (optional) NOTE: this permabans IPs.");
  743. return;
  744. }
  745. ea player = match(split[1]);
  746. if (player != null) {
  747. if (!hasControlOver(player)) {
  748. msg(Colors.Rose + "You can't ban that user.");
  749. return;
  750. }
  751. // adds player to ban list
  752. this.d.f.c(player.a.b.b().toString().split(":")[0].substring(1));
  753. etc.getInstance().getLoader().callHook(PluginLoader.Hook.IPBAN, new Object[]{e, split.length > 2 ? split[1] : ""});
  754. a.log(Level.INFO, "IP Banning " + player.aq + " (IP: " + player.a.b.b().toString() + ")");
  755. msg(Colors.Rose + "IP Banning " + player.aq + " (IP: " + player.a.b.b().toString() + ")");
  756. if (split.length > 2) {
  757. player.a.c("IP Banned by " + e.aq + ": " + combineSplit(2, split, " "));
  758. } else {
  759. player.a.c("IP Banned by " + e.aq + ".");
  760. }
  761. } else {
  762. msg(Colors.Rose + "Can't find user " + split[1] + ".");
  763. }
  764. } else if (split[0].equalsIgnoreCase("/ban")) {
  765. if (split.length < 2) {
  766. msg(Colors.Rose + "Correct usage is: /ban [player] <reason> (optional)");
  767. return;
  768. }
  769. ea player = match(split[1]);
  770. if (player != null) {
  771. if (!hasControlOver(player)) {
  772. msg(Colors.Rose + "You can't ban that user.");
  773. return;
  774. }
  775. // adds player to ban list
  776. this.d.f.a(player.aq);
  777. etc.getInstance().getLoader().callHook(PluginLoader.Hook.BAN, new Object[]{e, split.length > 2 ? split[1] : ""});
  778. if (split.length > 2) {
  779. player.a.c("Banned by " + e.aq + ": " + combineSplit(2, split, " "));
  780. } else {
  781. player.a.c("Banned by " + e.aq + ".");
  782. }
  783. a.log(Level.INFO, "Banning " + player.aq);
  784. msg(Colors.Rose + "Banning " + player.aq);
  785. } else {
  786. msg(Colors.Rose + "Can't find user " + split[1] + ".");
  787. }
  788. } else if (split[0].equalsIgnoreCase("/unban")) {
  789. if (split.length != 2) {
  790. msg(Colors.Rose + "Correct usage is: /unban [player]");
  791. return;
  792. }
  793. this.d.f.b(split[1]);
  794. msg(Colors.Rose + "Unbanned " + split[1]);
  795. } else if (split[0].equalsIgnoreCase("/unbanip")) {
  796. if (split.length != 2) {
  797. msg(Colors.Rose + "Correct usage is: /unbanip [ip]");
  798. return;
  799. }
  800. this.d.f.d(split[1]);
  801. msg(Colors.Rose + "Unbanned " + split[1]);
  802. } else if (split[0].equalsIgnoreCase("/kick")) {
  803. if (split.length < 2) {
  804. msg(Colors.Rose + "Correct usage is: /kick [player] <reason> (optional)");
  805. return;
  806. }
  807. ea player = match(split[1]);
  808. if (player != null) {
  809. if (!hasControlOver(player)) {
  810. msg(Colors.Rose + "You can't kick that user.");
  811. return;
  812. }
  813. etc.getInstance().getLoader().callHook(PluginLoader.Hook.KICK, new Object[]{e, split.length > 2 ? split[1] : ""});
  814. if (split.length > 2) {
  815. player.a.c("Kicked by " + e.aq + ": " + combineSplit(2, split, " "));
  816. } else {
  817. player.a.c("Kicked by " + e.aq + ".");
  818. }
  819. a.log(Level.INFO, "Kicking " + player.aq);
  820. msg(Colors.Rose + "Kicking " + player.aq);
  821. } else {
  822. msg(Colors.Rose + "Can't find user " + split[1] + ".");
  823. }
  824. } else if (split[0].equalsIgnoreCase("/me")) {
  825. if (etc.getInstance().isMuted(e)) {
  826. msg(Colors.Rose + "You are currently muted.");
  827. return;
  828. }
  829. if (split.length == 1)
  830. return;
  831. String prefix = etc.getInstance().getUserColor(e.aq);
  832. String paramString2 = "* " + prefix + this.e.aq + Colors.White + " " + paramString.substring(paramString.indexOf(" ")).trim();
  833. a.info("* " + this.e.aq + " " + paramString.substring(paramString.indexOf(" ")).trim());
  834. this.d.f.a(new ba(paramString2));
  835. } else if (split[0].equalsIgnoreCase("/sethome")) {
  836. // player.k, player.l, player.m
  837. // x, y, z
  838. Location loc = new Location();
  839. loc.x = e.l;
  840. loc.y = e.m;
  841. loc.z = e.n;
  842. loc.rotX = e.r;
  843. loc.rotY = e.s;
  844. Warp home = new Warp();
  845. home.Location = loc;
  846. home.Group = ""; //no group neccessary, lol.
  847. home.Name = e.aq;
  848. etc.getInstance().changeHome(home);
  849. msg(Colors.Rose + "Your home has been set.");
  850. } else if (split[0].equalsIgnoreCase("/spawn")) {
  851. int m = this.d.e.d(this.d.e.n, this.d.e.p);
  852. a(this.d.e.n + 0.5D, m + 1.5D, this.d.e.p + 0.5D, 0.0F, 0.0F);
  853. } else if (split[0].equalsIgnoreCase("/setspawn")) {
  854. this.d.e.n = (int) Math.ceil(e.l);
  855. //Too lazy to actually update this considering it's not even used anyways.
  856. //this.d.e.n = (int) Math.ceil(e.m); //Not that the Y axis really matters since it tries to get the highest point iirc.
  857. this.d.e.p = (int) Math.ceil(e.n);
  858. a.info("Spawn position changed.");
  859. msg(Colors.Rose + "You have set the spawn to your current position.");
  860. } else if (split[0].equalsIgnoreCase("/home")) {
  861. Warp home = null;
  862. if (split.length > 1 && etc.getInstance().isAdmin(e)) {
  863. home = etc.getInstance().getDataSource().getHome(split[1]);
  864. } else {
  865. home = etc.getInstance().getDataSource().getHome(e.aq);
  866. }
  867. if (home != null) {
  868. a(home.Location.x, home.Location.y, home.Location.z, home.Location.rotX, home.Location.rotY);
  869. } else if (split.length > 1 && etc.getInstance().isAdmin(e)) {
  870. msg(Colors.Rose + "That player home does not exist");
  871. } else {
  872. int m = this.d.e.d(this.d.e.n, this.d.e.p);
  873. a(this.d.e.n + 0.5D, m + 1.5D, this.d.e.p + 0.5D, 0.0F, 0.0F);
  874. }
  875. } else if (split[0].equalsIgnoreCase("/warp")) {
  876. if (split.length < 2) {
  877. msg(Colors.Rose + "Correct usage is: /warp [warpname]");
  878. return;
  879. }
  880. ea toWarp = e;
  881. Warp warp = null;
  882. if (split.length == 3 && etc.getInstance().canIgnoreRestrictions(e)) {
  883. warp = etc.getInstance().getDataSource().getWarp(split[1]);
  884. toWarp = match(split[2]);
  885. } else {
  886. warp = etc.getInstance().getDataSource().getWarp(split[1]);
  887. }
  888. if (toWarp != null) {
  889. if (warp != null) {
  890. if (!etc.getInstance().isUserInGroup(e, warp.Group) && !warp.Group.equals("")) {
  891. msg(Colors.Rose + "Warp not found.");
  892. } else {
  893. toWarp.a.a(warp.Location.x, warp.Location.y, warp.Location.z, warp.Location.rotX, warp.Location.rotY);
  894. toWarp.a.msg(Colors.Rose + "Woosh!");
  895. }
  896. } else {
  897. msg(Colors.Rose + "Warp not found");
  898. }
  899. } else {
  900. msg(Colors.Rose + "Player not found.");
  901. }
  902. } else if (split[0].equalsIgnoreCase("/listwarps") && etc.getInstance().getDataSource().hasWarps()) {
  903. if (split.length != 2 && split.length != 3) {
  904. msg(Colors.Rose + "Available warps: " + Colors.White + etc.getInstance().getDataSource().getWarpNames(e.aq));
  905. return;
  906. }
  907. } else if (split[0].equalsIgnoreCase("/setwarp")) {
  908. if (split.length < 2) {
  909. if (etc.getInstance().canIgnoreRestrictions(e)) {
  910. msg(Colors.Rose + "Correct usage is: /setwarp [warpname] [group]");
  911. } else {
  912. msg(Colors.Rose + "Correct usage is: /setwarp [warpname]");
  913. }
  914. return;
  915. }
  916. Location loc = new Location();
  917. loc.x = e.l;
  918. loc.y = e.m;
  919. loc.z = e.n;
  920. loc.rotX = e.r;
  921. loc.rotY = e.s;
  922. Warp warp = new Warp();
  923. warp.Name = split[1];
  924. warp.Location = loc;
  925. if (split.length == 3) {
  926. warp.Group = split[2];
  927. } else {
  928. warp.Group = "";
  929. }
  930. etc.getInstance().setWarp(warp);
  931. msg(Colors.Rose + "Created warp point " + split[1] + ".");
  932. } else if (split[0].equalsIgnoreCase("/removewarp")) {
  933. if (split.length < 2) {
  934. msg(Colors.Rose + "Correct usage is: /removewarp [warpname]");
  935. return;
  936. }
  937. Warp warp = etc.getInstance().getDataSource().getWarp(split[1]);
  938. if (warp != null) {
  939. etc.getInstance().getDataSource().removeWarp(warp);
  940. msg(Colors.Blue + "Warp removed.");
  941. } else {
  942. msg(Colors.Rose + "That warp does not exist");
  943. }
  944. } else if (split[0].equalsIgnoreCase("/lighter")) {
  945. if (MinecraftServer.b.containsKey(this.e.aq + " lighter")) {
  946. a.info(this.e.aq + " failed to iron!");
  947. msg(Colors.Rose + "You can't create another lighter again so soon");
  948. } else {
  949. if (!etc.getInstance().canIgnoreRestrictions(e)) {
  950. MinecraftServer.b.put(this.e.aq + " lighter", Integer.valueOf(6000));
  951. }
  952. a.info(this.e.aq + " created a lighter!");
  953. this.e.a(new gp(259, 1));
  954. }
  955. } else if ((paramString.startsWith("/#")) && (this.d.f.g(this.e.aq))) {
  956. String str = paramString.substring(2);
  957. a.info(this.e.aq + " issued server command: " + str);
  958. this.d.a(str, this);
  959. } else if (split[0].equalsIgnoreCase("/time")) {
  960. if (split.length != 2) {
  961. msg(Colors.Rose + "Correct usage is: /time [time|day|night]");
  962. return;
  963. }
  964. if (split[1].equalsIgnoreCase("day")) {
  965. this.d.e.c = 0;
  966. } else if (split[1].equalsIgnoreCase("night")) {
  967. this.d.e.c = 13000;
  968. } else {
  969. try {
  970. this.d.e.c = Long.parseLong(split[1]);
  971. } catch (NumberFormatException e) {
  972. msg(Colors.Rose + "Please enter numbers, not letters.");
  973. }
  974. }
  975. } else if (split[0].equalsIgnoreCase("/getpos")) {
  976. msg("Pos X: " + e.l + " Y: " + e.m + " Z " + e.n);
  977. msg("Rotation X: " + e.r + " Y: " + e.s);
  978. double degreeRotation = ((e.r - 90) % 360);
  979. if (degreeRotation < 0) {
  980. degreeRotation += 360.0;
  981. }
  982. msg("Compass: " + etc.getCompassPointForDirection(degreeRotation) + " (" + (Math.round(degreeRotation * 10) / 10.0) + ")");
  983. } else if (split[0].equalsIgnoreCase("/listplugins")) {
  984. msg(Colors.Rose + "Plugins" + Colors.White + ": " + etc.getInstance().getLoader().getPluginList());
  985. } else if (split[0].equalsIgnoreCase("/reloadplugin")) {
  986. if (split.length < 2) {
  987. msg(Colors.Rose + "Correct usage is: /reloadplugin [plugin]");
  988. return;
  989. }
  990. etc.getInstance().getLoader().reload(split[1]);
  991. msg(Colors.Rose + "Plugin reloaded.");
  992. } else if (split[0].equalsIgnoreCase("/enableplugin")) {
  993. if (split.length < 2) {
  994. msg(Colors.Rose + "Correct usage is: /enableplugin [plugin]");
  995. return;
  996. }
  997. etc.getInstance().getLoader().enablePlugin(split[1]);
  998. msg(Colors.Rose + "Plugin enabled.");
  999. } else if (split[0].equalsIgnoreCase("/disableplugin")) {
  1000. if (split.length < 2) {
  1001. msg(Colors.Rose + "Correct usage is: /enableplugin [plugin]");
  1002. return;
  1003. }
  1004. etc.getInstance().getLoader().disablePlugin(split[1]);
  1005. msg(Colors.Rose + "Plugin disabled.");
  1006. } else if (split[0].equalsIgnoreCase("/compass")) {
  1007. double degreeRotation = ((e.r - 90) % 360);
  1008. if (degreeRotation < 0) {
  1009. degreeRotation += 360.0;
  1010. }
  1011. msg(Colors.Rose + "Compass: " + etc.getCompassPointForDirection(degreeRotation));
  1012. } else if (split[0].equalsIgnoreCase("/motd")) {
  1013. for (String str : etc.getInstance().motd) {
  1014. msg(str);
  1015. }
  1016. } else {
  1017. a.info(this.e.aq + " tried command " + paramString);
  1018. msg(Colors.Rose + "Unknown command");
  1019. }
  1020. } catch (Exception ex) {
  1021. a.log(Level.SEVERE, "Exception in command handler (Report this