vMinecraftCommands.java 47 KB

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