vMinecraftCommands.java 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252
  1. import java.io.IOException;
  2. import java.lang.reflect.InvocationTargetException;
  3. import java.lang.reflect.Method;
  4. import java.util.ArrayList;
  5. import java.util.logging.Level;
  6. import java.util.logging.Logger;
  7. //=====================================================================
  8. //Class: vMinecraftCommands
  9. //Use: Encapsulates all commands added by this mod
  10. //Author: nos, trapalice, cerevisiae
  11. //=====================================================================
  12. public class vMinecraftCommands{
  13. //Log output
  14. protected static final Logger log = Logger.getLogger("Minecraft");
  15. static final int EXIT_FAIL = 0,
  16. EXIT_SUCCESS = 1,
  17. EXIT_CONTINUE = 2;
  18. //The list of commands for vMinecraft
  19. public static commandList cl = new commandList();
  20. //=====================================================================
  21. //Function: loadCommands
  22. //Input: None
  23. //Output: None
  24. //Use: Imports all the commands into the command list
  25. //=====================================================================
  26. public static void loadCommands(){
  27. //If we had commands we would add them here.
  28. //register
  29. //String: The command that will be used
  30. //String: The name of the function that will be called when
  31. // the command is used
  32. //String(Optional): The help menu description
  33. cl.register("/tp", "teleport");
  34. cl.register("/prefix", "prefix");
  35. cl.register("/vminecraft", "vminecrafthelp");
  36. cl.register("/colors", "colors");
  37. cl.register("/masstp", "masstp", "Teleports those with lower permissions to you");
  38. cl.register("/reload", "reload");
  39. cl.register("/rules", "rules", "Displays the rules");
  40. cl.register("/fabulous", "fabulous", "makes text SUUUPER");
  41. cl.register("/whois", "whois", "/whois [user]");
  42. cl.register("/who", "who");
  43. cl.register("/say", "say");
  44. cl.register("/slay", "slay", "Kill target player");
  45. cl.register("/ezmodo", "invuln", "Toggle invulnerability");
  46. cl.register("/ezlist", "ezlist", "List invulnerable players");
  47. cl.register("/heal", "heal", "heal yourself or other players");
  48. cl.register("/suicide", "suicide", "Kill yourself... you loser");
  49. cl.register("/a", "adminChatToggle", "Toggle admin chat for every message");
  50. cl.register("/modify", "modifySplit");
  51. cl.register("/me", "me");
  52. cl.register("/msg", "message", "Send a message to a player /msg [Player] [Message]");
  53. cl.register("/reply", "reply", "Reply to a player /reply [Message], Alias: /r");
  54. cl.register("/ignore", "addIgnored", "Adds a user to your ignore list");
  55. cl.register("/unignore", "removeIgnored", "Removes a user from your ignore list");
  56. //registerAlias
  57. //String: The command that this will be called by
  58. //String: The message that will be called when the first is entered
  59. // Can be modified with %# to have it insert a player
  60. // argument into that position.
  61. // EX: Aliased command is
  62. // cl.registerAlias("/test", "/i %0 100")
  63. // Player uses /test wood
  64. // The %0 will be replaced with wood for this instance
  65. // and Player will be given 100 wood.
  66. cl.registerAlias("/playerlist", "/who");
  67. cl.registerAlias("/vhelp", "/vminecraft");
  68. cl.registerAlias("/r", "/reply");
  69. cl.registerAlias("/t", "/msg");
  70. cl.registerAlias("/tell", "/msg");
  71. cl.registerAlias("/wrists", "/suicide");
  72. cl.registerAlias("/kill", "/suicide");
  73. cl.registerAlias("/ci", "/clearinventory");
  74. //registerMessage
  75. //String: The command it will run on
  76. //String: What will be displayed
  77. // %p is the player calling the command
  78. // %# is the argument number of the command.
  79. // %#p is an argument number that will be required to be
  80. // an online player
  81. //String: The color the message will be
  82. //int: The number of arguments required for the message to appear
  83. //boolean: If the message should only display for admins
  84. cl.registerMessage("/kick", "%p has kicked %0p", Colors.Blue, 1, false);
  85. cl.registerMessage("/ban", "%p has banned %0p", Colors.Blue, 1, false);
  86. cl.registerMessage("/ipban", "%p has IP banned %0p", Colors.Blue, 1, false);
  87. cl.registerMessage("/time", "Time change thanks to %p", Colors.Blue, 1, true);
  88. cl.registerMessage("/tp", "%p has teleported to %0p", Colors.Blue, 1, true);
  89. }
  90. //=====================================================================
  91. //Function: vminecrafthelp (/vhelp or /vminecraft)
  92. //Input: Player player: The player using the command
  93. //Output: int: Exit Code
  94. //Use: Displays the current status of most vMinecraft settings
  95. // and provides some useful tips.
  96. //=====================================================================
  97. public static int vminecrafthelp(Player player, String[] args){
  98. vMinecraftChat.sendMessage(player, player, Colors.Yellow + "Chat Settings");
  99. vMinecraftChat.sendMessage(player, player, Colors.DarkPurple + "Admin Chat: " + vMinecraftSettings.getInstance().adminchat());
  100. vMinecraftChat.sendMessage(player, player, Colors.DarkPurple + "FFF turns red: " + vMinecraftSettings.getInstance().FFF());
  101. vMinecraftChat.sendMessage(player, player, Colors.DarkPurple + "Greentext After >: " + vMinecraftSettings.getInstance().greentext());
  102. vMinecraftChat.sendMessage(player, player, Colors.DarkPurple + "Quake Color Script: " + vMinecraftSettings.getInstance().quakeColors());
  103. vMinecraftChat.sendMessage(player, player, Colors.Yellow + "Enabled Commands are TRUE, disabled are FALSE");
  104. vMinecraftChat.sendMessage(player, player, Colors.DarkPurple + "Command /ezmodo: " + vMinecraftSettings.getInstance().cmdEzModo());
  105. vMinecraftChat.sendMessage(player, player, Colors.DarkPurple + "Command /fabulous: " + vMinecraftSettings.getInstance().cmdFabulous());
  106. vMinecraftChat.sendMessage(player, player, Colors.DarkPurple + "Command /rules: " + vMinecraftSettings.getInstance().cmdRules());
  107. vMinecraftChat.sendMessage(player, player, Colors.DarkPurple + "Command /heal: " + vMinecraftSettings.getInstance().cmdHeal());
  108. vMinecraftChat.sendMessage(player, player, Colors.DarkPurple + "Command /masstp: " + vMinecraftSettings.getInstance().cmdMasstp());
  109. vMinecraftChat.sendMessage(player, player, Colors.DarkPurple + "Command /say: " + vMinecraftSettings.getInstance().cmdSay());
  110. vMinecraftChat.sendMessage(player, player, Colors.DarkPurple + "Command /suicide: " + vMinecraftSettings.getInstance().cmdSuicide());
  111. vMinecraftChat.sendMessage(player, player, Colors.DarkPurple + "Command /whois: " + vMinecraftSettings.getInstance().cmdWhoIs());
  112. vMinecraftChat.sendMessage(player, player, Colors.DarkPurple + "Command /tp won't work on higher ranked players: " + vMinecraftSettings.getInstance().cmdTp());
  113. vMinecraftChat.sendMessage(player, player, Colors.DarkPurple + "Command /tphere won't work on higher ranked players: " + vMinecraftSettings.getInstance().cmdTphere());
  114. vMinecraftChat.sendMessage(player, player, Colors.Yellow + "Other Settings");
  115. vMinecraftChat.sendMessage(player, player, Colors.DarkPurple + "Command /who: " + vMinecraftSettings.getInstance().cmdWho());
  116. vMinecraftChat.sendMessage(player, player, Colors.DarkPurple + "COLORED PLAYER LIST IS DEPENDENT ON /who BEING TRUE!");
  117. vMinecraftChat.sendMessage(player, player, Colors.DarkPurple + "Global Messages: " + vMinecraftSettings.getInstance().globalmessages());
  118. return EXIT_SUCCESS;
  119. }
  120. //=====================================================================
  121. //Function: prefix (/prefix)
  122. //Input: Player player: The player using the command
  123. //Output: int: Exit Code
  124. //Use: Changes your name color and prefix
  125. //=====================================================================
  126. public static int prefix(Player player, String[] args){
  127. if(!player.canUseCommand("/prefix")){
  128. return EXIT_FAIL;
  129. }
  130. if(args.length <= 1){
  131. vMinecraftChat.sendMessage(player, player, Colors.Rose + "Usage is /prefix [name color code] <prefix>");
  132. vMinecraftChat.sendMessage(player, player, Colors.DarkPurple + "Example: /prefix e ^0[^a<3^0]");
  133. vMinecraftChat.sendMessage(player, player, Colors.DarkPurple + "This would produce a name like... " + Colors.Black + "[" + Colors.LightGreen + "<3" + Colors.Black + "]" + Colors.Yellow + player.getName());
  134. return EXIT_SUCCESS;
  135. }
  136. if(args.length >= 2 && args[1] != null){
  137. player.setPrefix("§" + args[1]);
  138. if(args.length >= 3 && args[2] != null){
  139. vMinecraftUsers.players.findProfile(player).setTag(args[2]);
  140. return EXIT_SUCCESS;
  141. }
  142. }
  143. return EXIT_SUCCESS;
  144. }
  145. //=====================================================================
  146. //Function: colors (/colors)
  147. //Input: Player player: The player using the command
  148. //Output: int: Exit Code
  149. //Use: Displays a list of all colors and color codes
  150. //=====================================================================
  151. public static int colors(Player player, String[] args){
  152. vMinecraftChat.sendMessage(player, player, Colors.Rose + "You use these color codes like in quake or MW2, ^4 would make text red, ^a would make it light green.");
  153. vMinecraftChat.sendMessage(player, player,
  154. Colors.Black + "0"
  155. + Colors.Navy + "1"
  156. + Colors.Green + "2"
  157. + Colors.Blue + "3"
  158. + Colors.Red + "4"
  159. + Colors.Purple + "5"
  160. + Colors.Gold + "6"
  161. + Colors.LightGray + "7"
  162. + Colors.Gray + "8"
  163. + Colors.DarkPurple + "9"
  164. + Colors.LightGreen + "a"
  165. + Colors.LightBlue + "b"
  166. + Colors.Rose + "c"
  167. + Colors.LightPurple + "d"
  168. + Colors.White + "f");
  169. return EXIT_SUCCESS;
  170. }
  171. //=====================================================================
  172. //Function: me (/me)
  173. //Input: Player player: The player using the command
  174. // String[] args: Will contain the message the player sends
  175. //Output: int: Exit Code
  176. //Use: The player uses this to emote, but now its colorful.
  177. //=====================================================================
  178. public static int me(Player player, String[] args)
  179. {
  180. String str = etc.combineSplit(0, args, " ");
  181. if (args.length < 1) {return EXIT_FAIL;}
  182. vMinecraftChat.emote(player, str);
  183. return EXIT_SUCCESS;
  184. }
  185. //=====================================================================
  186. //Function: message (/msg, /w, /whisper)
  187. //Input: Player player: The player using the command
  188. // String[] args: Will contain the target player name and
  189. // message the player sends
  190. //Output: int: Exit Code
  191. //Use: Send a message to a player
  192. //=====================================================================
  193. public static int message(Player player, String[] args)
  194. {
  195. if (args.length > 1) {
  196. String msg = etc.combineSplit(1, args, " ");
  197. Player toPlayer = etc.getServer().matchPlayer(args[0]);
  198. if (toPlayer != null && args.length > 0) {
  199. //Send the message to the targeted player and the sender
  200. vMinecraftChat.sendMessage(player, toPlayer,
  201. Colors.LightGreen + "[From:" + vMinecraftChat.getName(player)
  202. + Colors.LightGreen + "] " + msg);
  203. vMinecraftChat.sendMessage(player, player,
  204. Colors.LightGreen + "[To:" + vMinecraftChat.getName(toPlayer)
  205. + Colors.LightGreen + "] " + msg);
  206. //Set the last massager for each player
  207. vMinecraftUsers.players.findProfile(player).setMessage(toPlayer);
  208. vMinecraftUsers.players.findProfile(toPlayer).setMessage(player);
  209. //Display the message to the log
  210. log.log(Level.INFO, player.getName() + " whispered to " + toPlayer.getName()
  211. + ": " + msg);
  212. } else {
  213. vMinecraftChat.sendMessage(player, player, Colors.Rose
  214. + "No player by the name of " + args[0] + " could be found.");
  215. }
  216. } else {
  217. vMinecraftChat.sendMessage(player, player, Colors.Rose
  218. + "Usage is /msg [player] [message]");
  219. }
  220. return EXIT_SUCCESS;
  221. }
  222. //=====================================================================
  223. //Function: reply (/r, /reply)
  224. //Input: Player player: The player using the command
  225. // String[] args: Will contain the message the player sends
  226. //Output: int: Exit Code
  227. //Use: Send a message to a player
  228. //=====================================================================
  229. public static int reply(Player player, String[] args)
  230. {
  231. //If the profile exists for the player
  232. if(vMinecraftUsers.players.findProfile(player) != null )
  233. {
  234. Player toPlayer = vMinecraftUsers.players.findProfile(player).getMessage();
  235. if (toPlayer != null && args.length > 0) {
  236. String msg = etc.combineSplit(0, args, " ");
  237. //Send the message to the targeted player and the sender
  238. vMinecraftChat.sendMessage(player, toPlayer,
  239. Colors.LightGreen + "[From:" + vMinecraftChat.getName(player)
  240. + Colors.LightGreen + "] " + msg);
  241. vMinecraftChat.sendMessage(player, player,
  242. Colors.LightGreen + "[To:" + vMinecraftChat.getName(toPlayer)
  243. + Colors.LightGreen + "] " + msg);
  244. //Set the last messager for each player
  245. vMinecraftUsers.players.findProfile(player).setMessage(toPlayer);
  246. vMinecraftUsers.players.findProfile(toPlayer).setMessage(player);
  247. //Display the message to the log
  248. log.log(Level.INFO, player.getName() + " whispered to " + toPlayer.getName()
  249. + ": " + msg);
  250. } else {
  251. vMinecraftChat.sendMessage(player, player,
  252. Colors.Rose + "The person you last message has logged off");
  253. }
  254. }
  255. return EXIT_SUCCESS;
  256. }
  257. //=====================================================================
  258. //Function: addIgnored (/ignore)
  259. //Input: Player player: The player using the command
  260. // String[] args: The name of the player to ignore
  261. //Output: int: Exit Code
  262. //Use: Adds a player to the ignore list
  263. //=====================================================================
  264. public static int addIgnored(Player player, String[] args)
  265. {
  266. //Make sure the player gave you a user to ignore
  267. if(args.length > 0)
  268. {
  269. //Find the player and make sure they exist
  270. Player ignore = etc.getServer().matchPlayer(args[0]);
  271. if(ignore != null)
  272. {
  273. //Don't let the player ignore themselves
  274. if(!ignore.getName().equalsIgnoreCase(player.getName()))
  275. {
  276. //Attempt to ignore the player and report accordingly
  277. if(vMinecraftUsers.players.findProfile(player).addIgnore(ignore))
  278. vMinecraftChat.sendMessage(player, player,
  279. Colors.Rose + ignore.getName()+ " has been successfuly " +
  280. "ignored.");
  281. else
  282. vMinecraftChat.sendMessage(player, player,
  283. Colors.Rose + "You are already ignoring " + ignore.getName());
  284. } else
  285. vMinecraftChat.sendMessage(player, player,
  286. Colors.Rose + "You cannot ignore yourself");
  287. }
  288. else
  289. vMinecraftChat.sendMessage(player, player,
  290. Colors.Rose + "The person you tried to ignore is not logged in.");
  291. }
  292. else
  293. vMinecraftChat.sendMessage(player, player,
  294. Colors.Rose + "Usage: /ignore [Player]");
  295. return EXIT_SUCCESS;
  296. }
  297. //=====================================================================
  298. //Function: removeIgnored (/unignore)
  299. //Input: Player player: The player using the command
  300. // String[] args: The name of the player to stop ignoring
  301. //Output: int: Exit Code
  302. //Use: Removes a player from the ignore list
  303. //=====================================================================
  304. public static int removeIgnored(Player player, String[] args)
  305. {
  306. //Make sure the player gave you a user to ignore
  307. if(args.length > 0)
  308. {
  309. //Find the player and make sure they exist
  310. Player ignore = etc.getServer().matchPlayer(args[0]);
  311. if(ignore != null)
  312. {
  313. //Attempt to ignore the player and report accordingly
  314. if(vMinecraftUsers.players.findProfile(player).removeIgnore(ignore))
  315. vMinecraftChat.sendMessage(player, player,
  316. Colors.Rose + ignore.getName()+ " has been successfuly " +
  317. "unignored.");
  318. else
  319. vMinecraftChat.sendMessage(player, player,
  320. Colors.Rose + "You are not currently ignoring " + ignore.getName());
  321. }
  322. else
  323. vMinecraftChat.sendMessage(player, player,
  324. Colors.Rose + "The person you tried to unignore is not logged in.");
  325. }
  326. else
  327. vMinecraftChat.sendMessage(player, player,
  328. Colors.Rose + "Usage: /unignore [Player]");
  329. return EXIT_SUCCESS;
  330. }
  331. //=====================================================================
  332. //Function: adminChatToggle (/a)
  333. //Input: Player player: The player using the command
  334. // String[] args: Ignored
  335. //Output: int: Exit Code
  336. //Use: Toggles the player into admin chat. Every message they
  337. // send will be piped to admin chat.
  338. //=====================================================================
  339. public static int adminChatToggle(Player player, String[] args)
  340. {
  341. //Make sure the user has access to the command
  342. if(!player.canUseCommand("/a")) {
  343. return EXIT_FAIL;
  344. }
  345. if(vMinecraftSettings.getInstance().adminChatToggle())
  346. {
  347. //If the player is already toggled for admin chat, remove them
  348. if (vMinecraftSettings.getInstance().isAdminToggled(player.getName())) {
  349. player.sendMessage(Colors.Red + "Admin Chat Toggle = off");
  350. vMinecraftSettings.getInstance().removeAdminToggled(player.getName());
  351. //Otherwise include them
  352. } else {
  353. player.sendMessage(Colors.Blue + "Admin Chat Toggled on");
  354. vMinecraftSettings.getInstance().addAdminToggled(player.getName());
  355. }
  356. return EXIT_SUCCESS;
  357. }
  358. return EXIT_FAIL;
  359. }
  360. //=====================================================================
  361. //Function: heal (/heal)
  362. //Input: Player player: The player using the command
  363. // String[] args: The arguments for the command. Should be a
  364. // player name or blank
  365. //Output: int: Exit Code
  366. //Use: Heals yourself or a specified player.
  367. //=====================================================================
  368. public static int heal(Player player, String[] args)
  369. {
  370. //Make sure the user has access to the command
  371. if(!player.canUseCommand("/heal")) {
  372. return EXIT_FAIL;
  373. }
  374. if(vMinecraftSettings.getInstance().cmdHeal())
  375. {
  376. //If a target wasn't specified, heal the user.
  377. if (args.length < 1){
  378. player.setHealth(20);
  379. player.sendMessage("Your health is restored");
  380. //If a target was specified, try to find them and then heal them
  381. //Otherwise report the error
  382. } else if (args.length > 0){
  383. Player playerTarget = etc.getServer().matchPlayer(args[0]);
  384. if (playerTarget != null){
  385. playerTarget.setHealth(20);
  386. player.sendMessage(Colors.Blue + "You have healed " + vMinecraftChat.getName(playerTarget));
  387. playerTarget.sendMessage(Colors.Blue + "You have been healed by " + vMinecraftChat.getName(player));
  388. }
  389. else if (playerTarget == null){
  390. player.sendMessage(Colors.Rose + "Couldn't find that player");
  391. }
  392. }
  393. return EXIT_SUCCESS;
  394. }
  395. return EXIT_FAIL;
  396. }
  397. //=====================================================================
  398. //Function: suicide (/suicide, /wrists)
  399. //Input: Player player: The player using the command
  400. // String[] args: Ignored
  401. //Output: int: Exit Code
  402. //Use: Kills yourself
  403. //=====================================================================
  404. public static int suicide(Player player, String[] args)
  405. {
  406. //Make sure the user has access to the command
  407. if(!player.canUseCommand("/suicide")) {
  408. return EXIT_FAIL;
  409. }
  410. if(vMinecraftSettings.getInstance().cmdSuicide())
  411. {
  412. //Set your health to 0. Not much to it.
  413. player.setHealth(0);
  414. return EXIT_SUCCESS;
  415. }
  416. return EXIT_FAIL;
  417. }
  418. //=====================================================================
  419. //Function: teleport (/tp)
  420. //Input: Player player: The player using the command
  421. // String[] args: The arguments for the command. Should be a
  422. // player name
  423. //Output: int: Exit Code
  424. //Use: Teleports the user to another player
  425. //=====================================================================
  426. public static int teleport(Player player, String[] args)
  427. {
  428. //Make sure the user has access to the command
  429. if(!player.canUseCommand("/tp")) {
  430. return EXIT_FAIL;
  431. }
  432. //Get if the command is enabled
  433. if(vMinecraftSettings.getInstance().cmdTp())
  434. {
  435. //Make sure a player has been specified and return an error if not
  436. if (args.length < 1) {
  437. player.sendMessage(Colors.Rose + "Correct usage is: /tp [player]");
  438. } else {
  439. //Find the player by name
  440. Player playerTarget = etc.getServer().matchPlayer(args[0]);
  441. //Target player isn't found
  442. if(playerTarget == null)
  443. player.sendMessage(Colors.Rose + "Can't find user "
  444. + args[0] + ".");
  445. //If it's you, return witty message
  446. else if (player.getName().equalsIgnoreCase(args[0]))
  447. player.sendMessage(Colors.Rose + "You're already here!");
  448. //If the player is higher rank than you, inform the user
  449. else if (!player.hasControlOver(playerTarget))
  450. player.sendMessage(Colors.Red +
  451. "That player has higher permissions than you.");
  452. //If the player exists transport the user to the player
  453. else {
  454. log.log(Level.INFO, player.getName() + " teleported to " +
  455. playerTarget.getName());
  456. player.teleportTo(playerTarget);
  457. //Otherwise inform the user that the player doesn't exist
  458. }
  459. }
  460. return EXIT_SUCCESS;
  461. }
  462. return EXIT_FAIL;
  463. }
  464. //=====================================================================
  465. //Function: masstp (/masstp)
  466. //Input: Player player: The player using the command
  467. // String[] args: Should be empty or is ignored
  468. //Output: int: Exit Code
  469. //Use: Teleports all players to the user
  470. //=====================================================================
  471. public static int masstp(Player player, String[] args)
  472. {
  473. //Make sure the user has access to the command
  474. if(!player.canUseCommand("/masstp")) {
  475. return EXIT_FAIL;
  476. }
  477. //If the command is enabled
  478. if(vMinecraftSettings.getInstance().cmdMasstp()) {
  479. //Go through all players and move them to the user
  480. for (Player p : etc.getServer().getPlayerList()) {
  481. if (!p.hasControlOver(player)) {
  482. p.teleportTo(player);
  483. }
  484. }
  485. //Inform the user that the command has executed successfully
  486. player.sendMessage(Colors.Blue+"Summoning successful.");
  487. return EXIT_SUCCESS;
  488. }
  489. return EXIT_FAIL;
  490. }
  491. //=====================================================================
  492. //Function: tphere (/tphere)
  493. //Input: Player player: The player using the command
  494. // String[] args: The arguments for the command. Should be a
  495. // player name
  496. //Output: int: Exit Code
  497. //Use: Teleports the user to another player
  498. //=====================================================================
  499. public static int tphere(Player player, String[] args)
  500. {
  501. //Make sure the user has access to the command
  502. if(!player.canUseCommand("/tphere")) {
  503. return EXIT_FAIL;
  504. }
  505. //Check if the command is enabled.
  506. if (vMinecraftSettings.getInstance().cmdTphere()) {
  507. //Make sure a player is specified
  508. if (args.length < 1) {
  509. player.sendMessage(Colors.Rose + "Correct usage is: /tphere [player]");
  510. } else {
  511. //Get the player by name
  512. Player playerTarget = etc.getServer().matchPlayer(args[0]);
  513. //If the target doesn't exist
  514. if(playerTarget == null)
  515. player.sendMessage(Colors.Rose + "Can't find user " + args[0] + ".");
  516. //If the player has a higher rank than the user, return error
  517. else if (!player.hasControlOver(playerTarget))
  518. player.sendMessage(Colors.Red + "That player has higher permissions than you.");
  519. //If the user teleports themselves, mock them
  520. else if (player.getName().equalsIgnoreCase(args[0]))
  521. player.sendMessage(Colors.Rose + "Wow look at that! You teleported yourself to yourself!");
  522. //If the target exists, teleport them to the user
  523. else {
  524. log.log(Level.INFO, player.getName() + " teleported " + player.getName() + " to their self.");
  525. playerTarget.teleportTo(player);
  526. }
  527. }
  528. return EXIT_SUCCESS;
  529. }
  530. return EXIT_FAIL;
  531. }
  532. //=====================================================================
  533. //Function: reload (/reload)
  534. //Input: Player player: The player using the command
  535. // String[] args: Ignored
  536. //Output: int: Exit Code
  537. //Use: Reloads the settings for vMinecraft
  538. //=====================================================================
  539. public static int reload(Player player, String[] args)
  540. {
  541. //Make sure the user has access to the command
  542. if(!player.canUseCommand("/reload")) {
  543. return EXIT_FAIL;
  544. }
  545. vMinecraftSettings.getInstance().loadSettings();
  546. return EXIT_FAIL;
  547. }
  548. //=====================================================================
  549. //Function: rules (/rules)
  550. //Input: Player player: The player using the command
  551. // String[] args: Ignored
  552. //Output: int: Exit Code
  553. //Use: Lists the rules
  554. //=====================================================================
  555. public static int rules(Player player, String[] args)
  556. {
  557. //If the rules exist
  558. if(vMinecraftSettings.getInstance().cmdRules()
  559. && vMinecraftSettings.getInstance().getRules().length > 0) {
  560. //Apply QuakeCode Colors to the rules
  561. String[] rules = vMinecraftChat.applyColors(
  562. vMinecraftSettings.getInstance().getRules());
  563. //Display them
  564. for (String str : rules ) {
  565. if(!str.isEmpty())
  566. player.sendMessage(Colors.Blue + str);
  567. else
  568. player.sendMessage(Colors.Blue + "!!!The Rules Have Not Been Set!!!");
  569. }
  570. return EXIT_SUCCESS;
  571. }
  572. return EXIT_FAIL;
  573. }
  574. //=====================================================================
  575. //Function: fabulous (/fabulous)
  576. //Input: Player player: The player using the command
  577. // String[] args: The message to apply the effect to
  578. //Output: int: Exit Code
  579. //Use: Makes the text rainbow colored
  580. //=====================================================================
  581. public static int fabulous(Player player, String[] args)
  582. {
  583. //If the command is enabled
  584. if(vMinecraftSettings.getInstance().cmdFabulous()) {
  585. //Format the name
  586. String playerName = Colors.White + "<"
  587. + vMinecraftChat.getName(player) + Colors.White +"> ";
  588. //Make sure a message has been specified
  589. if (args.length < 1) {return EXIT_FAIL;}
  590. String str = " ";
  591. //Merge the message again
  592. str = etc.combineSplit(0, args, " ");
  593. //Output for server
  594. log.log(Level.INFO, player.getName()+" fabulously said \""+ str+"\"");
  595. //Prepend the player name and cut into lines.
  596. vMinecraftChat.gmsg(player, playerName + vMinecraftChat.rainbow(str));
  597. return EXIT_SUCCESS;
  598. }
  599. return EXIT_FAIL;
  600. }
  601. //=====================================================================
  602. //Function: whois (/whois)
  603. //Input: Player player: The player using the command
  604. // String[] args: The player to find info on
  605. //Output: int: Exit Code
  606. //Use: Displays information about the player specified
  607. //=====================================================================
  608. public static int whois(Player player, String[] args)
  609. {
  610. //Make sure the user has access to the command
  611. if(!player.canUseCommand("/whois")) {
  612. return EXIT_FAIL;
  613. }
  614. //If the command is enabled
  615. if (vMinecraftSettings.getInstance().cmdWhoIs()) {
  616. //If a player is specified
  617. if (args.length < 1)
  618. player.sendMessage(Colors.Rose + "Usage is /whois [player]");
  619. else {
  620. //Get the player by name
  621. Player playerTarget = etc.getServer().matchPlayer(args[0]);
  622. //If the player exists
  623. if (playerTarget != null){
  624. //Displaying the information
  625. player.sendMessage(Colors.Blue + "Whois results for " +
  626. vMinecraftChat.getName(playerTarget));
  627. //Group
  628. for(String group: playerTarget.getGroups())
  629. player.sendMessage(Colors.Blue + "Groups: " + group);
  630. //Admin
  631. player.sendMessage(Colors.Blue+"Admin: " +
  632. String.valueOf(playerTarget.isAdmin()));
  633. //IP
  634. player.sendMessage(Colors.Blue+"IP: " + playerTarget.getIP());
  635. //Restrictions
  636. player.sendMessage(Colors.Blue+"Can ignore restrictions: " +
  637. String.valueOf(playerTarget.canIgnoreRestrictions()));
  638. //Give the user an error if the player doesn't exist
  639. } else {
  640. player.sendMessage(Colors.Rose+"Player not found.");
  641. }
  642. }
  643. return EXIT_SUCCESS;
  644. }
  645. return EXIT_SUCCESS;
  646. }
  647. //=====================================================================
  648. //Function: who (/who)
  649. //Input: Player player: The player using the command
  650. // String[] args: Ignored
  651. //Output: int: Exit Code
  652. //Use: Displays the connected players
  653. //=====================================================================
  654. public static int who(Player player, String[] args)
  655. {
  656. //If the command is enabled
  657. if (vMinecraftSettings.getInstance().cmdWho()) {
  658. //Loop through all players counting them and adding to the list
  659. int count=0;
  660. String tempList = "";
  661. for( Player p : etc.getServer().getPlayerList())
  662. {
  663. if(p != null){
  664. if(count == 0)
  665. tempList += vMinecraftChat.getName(p);
  666. else
  667. tempList += Colors.White + ", " + vMinecraftChat.getName(p);
  668. count++;
  669. }
  670. }
  671. //Get the max players from the config
  672. PropertiesFile server = new PropertiesFile("server.properties");
  673. try {
  674. server.load();
  675. } catch (IOException e) {
  676. e.printStackTrace();
  677. }
  678. int maxPlayers = server.getInt("max-players");
  679. //Output the player list
  680. vMinecraftChat.sendMessage(player, player, Colors.Rose + "Player List ("
  681. + count + "/" + maxPlayers +"): " + tempList);
  682. return EXIT_SUCCESS;
  683. }
  684. return EXIT_FAIL;
  685. }
  686. //=====================================================================
  687. //Function: say (/say)
  688. //Input: Player player: The player using the command
  689. // String[] args: The message to apply the effect to
  690. //Output: int: Exit Code
  691. //Use: Announces the message to all players
  692. //=====================================================================
  693. public static int say(Player player, String[] args)
  694. {
  695. //Make sure the user has access to the command
  696. if(!player.canUseCommand("/say")) {
  697. return EXIT_FAIL;
  698. }
  699. //If the command is enabled
  700. if (vMinecraftSettings.getInstance().cmdSay()) {
  701. //Make sure a message is supplied or output an error
  702. if (args.length < 1) {
  703. player.sendMessage(Colors.Rose + "Usage is /say [message]");
  704. }
  705. //Display the message globally
  706. vMinecraftChat.gmsg(player, Colors.Yellow + etc.combineSplit(0, args, " "));
  707. return EXIT_SUCCESS;
  708. }
  709. return EXIT_FAIL;
  710. }
  711. //=====================================================================
  712. //Function: slay (/slay)
  713. //Input: Player player: The player using the command
  714. // String[] args: The target for the command
  715. //Output: int: Exit Code
  716. //Use: Kill the target player
  717. //=====================================================================
  718. public static int slay(Player player, String[] args)
  719. {
  720. //Make sure the user has access to the command
  721. if(!player.canUseCommand("/slay")) {
  722. return EXIT_FAIL;
  723. }
  724. //Check if the command is enabled
  725. if(vMinecraftSettings.getInstance().cmdEzModo()) {
  726. //Get the player by name
  727. Player playerTarget = etc.getServer().matchPlayer(args[0]);
  728. //If the player doesn't exist don't run
  729. if(playerTarget == null)
  730. return EXIT_FAIL;
  731. //If the player isn't invulnerable kill them
  732. if (!vMinecraftSettings.getInstance().isEzModo(playerTarget.getName())) {
  733. playerTarget.setHealth(0);
  734. vMinecraftChat.gmsg(player, vMinecraftChat.getName(player)
  735. + Colors.LightBlue + " has slain "
  736. + vMinecraftChat.getName(playerTarget));
  737. //Otherwise output error to the user
  738. } else {
  739. player.sendMessage(Colors.Rose + "That player is currently in ezmodo! Hahahaha");
  740. }
  741. return EXIT_SUCCESS;
  742. }
  743. return EXIT_FAIL;
  744. }
  745. //=====================================================================
  746. //Function: invuln (/ezmodo)
  747. //Input: Player player: The player using the command
  748. // String[] args: The target for the command
  749. //Output: int: Exit Code
  750. //Use: Kill the target player
  751. //=====================================================================
  752. public static int invuln(Player player, String[] args)
  753. {
  754. //Make sure the user has access to the command
  755. if(!player.canUseCommand("/ezmodo")) {
  756. return EXIT_FAIL;
  757. }
  758. //If the command is enabled
  759. if (vMinecraftSettings.getInstance().cmdEzModo()) {
  760. //If the player is already invulnerable, turn ezmodo off.
  761. if (vMinecraftSettings.getInstance().isEzModo(player.getName())) {
  762. player.sendMessage(Colors.Red + "ezmodo = off");
  763. vMinecraftSettings.getInstance().removeEzModo(player.getName());
  764. //Otherwise make them invulnerable
  765. } else {
  766. player.sendMessage(Colors.LightBlue + "eh- maji? ezmodo!?");
  767. player.sendMessage(Colors.Rose + "kimo-i");
  768. player.sendMessage(Colors.LightBlue + "Easy Mode ga yurusareru no wa shougakusei made dayo ne");
  769. player.sendMessage(Colors.Red + "**Laughter**");
  770. vMinecraftSettings.getInstance().addEzModo(player.getName());
  771. }
  772. return EXIT_SUCCESS;
  773. }
  774. return EXIT_FAIL;
  775. }
  776. //=====================================================================
  777. //Function: ezlist (/ezlist)
  778. //Input: Player player: The player using the command
  779. // String[] args: Ignored
  780. //Output: int: Exit Code
  781. //Use: List all invulnerable players
  782. //=====================================================================
  783. public static int ezlist(Player player, String[] args)
  784. {
  785. //Make sure the user has access to the command
  786. if(!player.canUseCommand("/ezmodo")) {
  787. return EXIT_FAIL;
  788. }
  789. //If the feature is enabled list the players
  790. if(vMinecraftSettings.getInstance().cmdEzModo()) {
  791. player.sendMessage("Ezmodo: " + vMinecraftSettings.getInstance().ezModoList());
  792. return EXIT_SUCCESS;
  793. }
  794. return EXIT_FAIL;
  795. }
  796. //=====================================================================
  797. //Function: modifySplit (/modify)
  798. //Input: Player player: The player using the command
  799. // String[] args: Player, Command, Arguments
  800. //Output: int: Exit Code
  801. //Use: List all invulnerable players
  802. //=====================================================================
  803. public static int modifySplit(Player player, String[] args)
  804. {
  805. //Exploit fix for people giving themselves commands
  806. if(args[2].equals("commands")){
  807. return EXIT_FAIL;
  808. }
  809. return EXIT_CONTINUE;
  810. }
  811. //=====================================================================
  812. //Function: Time Reverse
  813. //Input: long time: The time to reverse to.
  814. //Output: int: Exit Code
  815. //Use: List all invulnerable players
  816. //=====================================================================
  817. public static int timeReverse(long tarTime)
  818. {
  819. long curTime = etc.getServer().getRelativeTime();
  820. //if(cur)
  821. return EXIT_SUCCESS;
  822. }
  823. }
  824. //=====================================================================
  825. //Class: commandList
  826. //Use: The list of commands that will be checked for
  827. //Author: cerevisiae
  828. //=====================================================================
  829. class commandList {
  830. ArrayList<command> commands;
  831. protected static final Logger log = Logger.getLogger("Minecraft");
  832. static final int EXIT_FAIL = 0,
  833. EXIT_SUCCESS = 1,
  834. EXIT_CONTINUE = 2;
  835. //=====================================================================
  836. //Function: commandList
  837. //Input: None
  838. //Output: None
  839. //Use: Initialize the array of commands
  840. //=====================================================================
  841. public commandList(){
  842. commands = new ArrayList<command>();
  843. }
  844. //=====================================================================
  845. //Function: register
  846. //Input: String name: The name of the command
  847. // String func: The function to be called
  848. //Output: boolean: Whether the command was input successfully or not
  849. //Use: Registers a command to the command list for checking later
  850. //=====================================================================
  851. public boolean register(String name, String func)
  852. {
  853. //Check to make sure the command doesn't already exist
  854. for(command temp : commands)
  855. if(temp.getName().equalsIgnoreCase(name))
  856. return false;
  857. //Add the new function to the list
  858. commands.add(new command(name, func));
  859. //exit successfully
  860. return true;
  861. }
  862. //=====================================================================
  863. //Function: register
  864. //Input: String name: The name of the command
  865. // String func: The function to be called
  866. // String info: The information for the command to put in help
  867. //Output: boolean: Whether the command was input successfully or not
  868. //Use: Registers a command to the command list for checking later
  869. //=====================================================================
  870. public boolean register(String name, String func, String info){
  871. //Add to the /help list
  872. etc.getInstance().addCommand(name, info);
  873. //Finish registering
  874. return register(name, func);
  875. }
  876. //=====================================================================
  877. //Function: register
  878. //Input: String name: The name of the command
  879. // String func: The function to be called
  880. //Output: boolean: Whether the command was input successfully or not
  881. //Use: Registers a command to the command list for checking later
  882. //=====================================================================
  883. public boolean registerAlias(String name, String com)
  884. {
  885. //Check to make sure the command doesn't already exist
  886. for(command temp : commands)
  887. if(temp.getName().equalsIgnoreCase(name))
  888. return false;
  889. //Add the new function to the list
  890. commands.add(new commandRef(name, com));
  891. //exit successfully
  892. return true;
  893. }
  894. //=====================================================================
  895. //Function: registerMessage
  896. //Input: String name: The name of the command
  897. // String msg: The message to be displayed
  898. // boolean admin: If the message is displayed to admins only
  899. //Output: boolean: Whether the command was input successfully or not
  900. //Use: Registers a command to the command list for checking later
  901. //=====================================================================
  902. public boolean registerMessage(String name, String msg, String clr, int args, boolean admin)
  903. {
  904. //Check to make sure the command doesn't already exist
  905. for(command temp : commands)
  906. if(temp.getName().equalsIgnoreCase(name))
  907. return false;
  908. //Add the new function to the list
  909. commands.add(new commandAnnounce(name, msg, clr, args, admin));
  910. //exit successfully
  911. return true;
  912. }
  913. //=====================================================================
  914. //Function: call
  915. //Input: String name: The name of the command to be run
  916. //Output: boolean: If the command was called successfully
  917. //Use: Attempts to call a command
  918. //=====================================================================
  919. public int call(String name, Player player, String[] arg){
  920. //Search for the command
  921. for(command cmd : commands)
  922. {
  923. //When found
  924. if(cmd.getName().equalsIgnoreCase(name))
  925. {
  926. try {
  927. //Call the command and return results
  928. return cmd.call(player, arg);
  929. } catch (SecurityException e) {
  930. log.log(Level.SEVERE, "Exception while running command", e);
  931. } catch (IllegalArgumentException e) {
  932. log.log(Level.SEVERE, "The Command Entered Doesn't Exist", e);
  933. return EXIT_FAIL;
  934. }
  935. }
  936. }
  937. //Something went wrong
  938. return EXIT_FAIL;
  939. }
  940. //=====================================================================
  941. //Class: command
  942. //Use: The specific command
  943. //Author: cerevisiae
  944. //=====================================================================
  945. private class command
  946. {
  947. private String commandName;
  948. private String function;
  949. //=====================================================================
  950. //Function: command
  951. //Input: None
  952. //Output: None
  953. //Use: Initialize the command
  954. //=====================================================================
  955. public command(String name, String func){
  956. commandName = name;
  957. function = func;
  958. }
  959. //=====================================================================
  960. //Function: getName
  961. //Input: None
  962. //Output: String: The command name
  963. //Use: Returns the command name
  964. //=====================================================================
  965. public String getName(){return commandName;}
  966. //=====================================================================
  967. //Function: call
  968. //Input: String[] arg: The arguments for the command
  969. //Output: boolean: If the command was called successfully
  970. //Use: Attempts to call the command
  971. //=====================================================================
  972. int call(Player player, String[] arg)
  973. {
  974. Method m;
  975. try {
  976. m = vMinecraftCommands.class.getMethod(function, Player.class, String[].class);
  977. m.setAccessible(true);
  978. return (Integer) m.invoke(null, player, arg);
  979. } catch (SecurityException e) {
  980. e.printStackTrace();
  981. } catch (NoSuchMethodException e) {
  982. e.printStackTrace();
  983. } catch (IllegalArgumentException e) {
  984. e.printStackTrace();
  985. } catch (IllegalAccessException e) {
  986. e.printStackTrace();
  987. } catch (InvocationTargetException e) {
  988. e.printStackTrace();
  989. }
  990. return 1;
  991. }
  992. }
  993. //=====================================================================
  994. //Class: commandRef
  995. //Use: A command referencing another command
  996. //Author: cerevisiae
  997. //=====================================================================
  998. private class commandRef extends command
  999. {
  1000. private String reference;
  1001. private String[] args;
  1002. //=====================================================================
  1003. //Function: command
  1004. //Input: String name: The command name
  1005. // String com: The command to run
  1006. //Output: None
  1007. //Use: Initialize the command
  1008. //=====================================================================
  1009. public commandRef(String name, String com){
  1010. super(name, "");
  1011. //Get the reference name
  1012. String[]temp = com.split(" ");
  1013. reference = temp[0];
  1014. //Get the arguments
  1015. args = new String[temp.length - 1];
  1016. System.arraycopy(temp, 1, args, 0, temp.length - 1);
  1017. }
  1018. //=====================================================================
  1019. //Function: call
  1020. //Input: String[] arg: The arguments for the command
  1021. //Output: boolean: If the command was called successfully
  1022. //Use: Attempts to call the command
  1023. //=====================================================================
  1024. int call(Player player, String[] arg)
  1025. {
  1026. String[] temp = new String[0];
  1027. int lastSet = 0,
  1028. argCount = 0;
  1029. //If there are args set with the function
  1030. if(args != null && args.length > 0) {
  1031. temp = new String[args.length];
  1032. System.arraycopy(args, 0, temp, 0, args.length);
  1033. //Insert the arguments into the pre-set arguments
  1034. for(String argument : temp)
  1035. {
  1036. if(argument.startsWith("%") && argument.length() > 1)
  1037. {
  1038. int argNum = Integer.parseInt(argument.substring(1));
  1039. if( argNum < arg.length )
  1040. {
  1041. temp[lastSet] = arg[argNum];
  1042. argCount++;
  1043. }
  1044. }
  1045. lastSet++;
  1046. }
  1047. }
  1048. //If there are args being input
  1049. if(arg.length > 0) {
  1050. //Append the rest of the arguments to the argument array
  1051. if(lastSet < temp.length + arg.length - argCount)
  1052. {
  1053. String[] temp2 = new String[temp.length + arg.length - argCount];
  1054. System.arraycopy(temp, 0, temp2, 0, temp.length);
  1055. System.arraycopy(arg, argCount, temp2,
  1056. temp.length, arg.length - argCount);
  1057. temp = temp2;
  1058. }
  1059. log.log(Level.INFO, reference + " " + etc.combineSplit(0, temp, " "));
  1060. //Call the referenced command
  1061. player.command(reference + " " + etc.combineSplit(0, temp, " "));
  1062. } else
  1063. player.command(reference);
  1064. return EXIT_SUCCESS;
  1065. }
  1066. }
  1067. //=====================================================================
  1068. //Class: commandAnnounce
  1069. //Use: Announces when a command is used
  1070. //Author: cerevisiae
  1071. //=====================================================================
  1072. private class commandAnnounce extends command
  1073. {
  1074. private String message;
  1075. private boolean admin;
  1076. private int minArgs;
  1077. private String color;
  1078. //=====================================================================
  1079. //Function: commandAnnounce
  1080. //Input: String name: The command name
  1081. // String msg: The message to announce
  1082. //Output: None
  1083. //Use: Initialize the command
  1084. //=====================================================================
  1085. public commandAnnounce(String name, String msg, String clr, int args, boolean admn){
  1086. super(name, "");
  1087. message = msg;
  1088. admin = admn;
  1089. minArgs = args;
  1090. color = clr;
  1091. }
  1092. //=====================================================================
  1093. //Function: call
  1094. //Input: String[] arg: The arguments for the command
  1095. //Output: boolean: If the command was called successfully
  1096. //Use: Attempts to call the command
  1097. //=====================================================================
  1098. int call(Player player, String[] arg)
  1099. {
  1100. //Make sure the player can use the command first
  1101. if(!player.canUseCommand(super.commandName))
  1102. return EXIT_FAIL;
  1103. //Make sure the command is long enough to fire
  1104. if(minArgs < arg.length)
  1105. return EXIT_FAIL;
  1106. if(vMinecraftSettings.getInstance().globalmessages())
  1107. {
  1108. //Split up the message
  1109. String[] temp = message.split(" ");
  1110. //Insert the arguments into the message
  1111. int i = 0;
  1112. for(String argument : temp)
  1113. {
  1114. if(argument.startsWith("%") && argument.length() > 1)
  1115. {
  1116. char position = argument.charAt(1);
  1117. //Replace %p with the player name
  1118. if(position == 'p')
  1119. temp[i] = vMinecraftChat.getName(player) + color;
  1120. else if( Character.isDigit(position) && Character.getNumericValue(position) < arg.length )
  1121. {
  1122. //If the argument is specified to be a player insert it if the
  1123. //player is found or exit if they aren't
  1124. if(argument.length() > 2 && argument.charAt(2) == 'p')
  1125. {
  1126. Player targetName = etc.getServer().matchPlayer(arg[Character.getNumericValue(position)]);
  1127. if(targetName != null)
  1128. temp[i] = vMinecraftChat.getName(targetName) + color;
  1129. else
  1130. return EXIT_FAIL;
  1131. }
  1132. //Replace %# with the argument at position #
  1133. else
  1134. temp[i] = arg[Character.getNumericValue(position)];
  1135. }
  1136. }
  1137. i++;
  1138. }
  1139. message = etc.combineSplit(0, temp, " ");
  1140. //If it's an admin message only
  1141. if(admin)
  1142. {
  1143. for (Player p: etc.getServer().getPlayerList()) {
  1144. //If p is not null
  1145. if (p != null) {
  1146. //And if p is an admin or has access to adminchat send message
  1147. if (p.isAdmin()) {
  1148. vMinecraftChat.sendMessage(player, p, color + message);
  1149. }
  1150. }
  1151. }
  1152. } else
  1153. vMinecraftChat.gmsg(player, message);
  1154. }
  1155. return EXIT_FAIL;
  1156. }
  1157. }
  1158. }