PageRenderTime 67ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/TravelGates/src/com/ghomerr/travelgates/listeners/TravelGatesCommandExecutor.java

https://github.com/Ghomerr/TravelGates
Java | 724 lines | 615 code | 58 blank | 51 comment | 139 complexity | d8823cb23f61aa26e48504809e63f094 MD5 | raw file
  1. package com.ghomerr.travelgates.listeners;
  2. import java.util.logging.Logger;
  3. import org.bukkit.ChatColor;
  4. import org.bukkit.Location;
  5. import org.bukkit.World;
  6. import org.bukkit.command.Command;
  7. import org.bukkit.command.CommandExecutor;
  8. import org.bukkit.command.CommandSender;
  9. import org.bukkit.entity.Player;
  10. import com.ghomerr.travelgates.TravelGates;
  11. import com.ghomerr.travelgates.constants.TravelGatesConstants;
  12. import com.ghomerr.travelgates.enums.TravelGatesCommands;
  13. import com.ghomerr.travelgates.enums.TravelGatesOptions;
  14. import com.ghomerr.travelgates.enums.TravelGatesPermissionsNodes;
  15. import com.ghomerr.travelgates.messages.TravelGatesMessages;
  16. import com.ghomerr.travelgates.objects.TravelGatesOptionsContainer;
  17. import com.ghomerr.travelgates.utils.TravelGatesUtils;
  18. public class TravelGatesCommandExecutor implements CommandExecutor
  19. {
  20. private static final Logger _LOGGER = Logger.getLogger(TravelGatesConstants.MINECRAFT);
  21. private final TravelGates _plugin;
  22. private final String _optionPrefixe = "-";
  23. // private final int _targetRangeMax = 6;
  24. public TravelGatesCommandExecutor(final TravelGates plugin)
  25. {
  26. _plugin = plugin;
  27. }
  28. @Override
  29. public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] split)
  30. {
  31. boolean result = false;
  32. if (_plugin.isPluginEnabled())
  33. {
  34. if (!(sender instanceof Player))
  35. {
  36. result = false;
  37. }
  38. else
  39. {
  40. final Player player = (Player) sender;
  41. // /tg ...
  42. if (TravelGatesCommands.TRAVELGATES.has(label))
  43. {
  44. if (_plugin.isDebugEnabled())
  45. {
  46. _LOGGER.info(TravelGatesConstants.DEBUG_TAG + " Player issuing travelgates command : " + split);
  47. }
  48. if (split.length > 0)
  49. {
  50. // first arg
  51. final String arg1 = split[0];
  52. // /tg add ...
  53. if (TravelGatesCommands.ADD.has(arg1))
  54. {
  55. if (_plugin.hasPermission(player, TravelGatesPermissionsNodes.ADD))
  56. {
  57. if (split.length > 1)
  58. {
  59. // dest name
  60. final String destination = split[1];
  61. // /tg add <destination>
  62. if (destination.matches(TravelGatesConstants.DESTINATION_NAME_PATTERN))
  63. {
  64. String inputOptions = null;
  65. // /tg add <destination> [-options]
  66. if (split.length > 2)
  67. {
  68. inputOptions = split[2];
  69. }
  70. final Location playerLoc = player.getLocation();
  71. final TravelGatesOptionsContainer container = _plugin.createDestinationOptions(destination, inputOptions);
  72. Location destinationLocation = null;
  73. if (container.has(TravelGatesOptions.POSITION))
  74. {
  75. destinationLocation = _plugin.getLocationFromPosition(player, playerLoc, container.getPosition());
  76. }
  77. else
  78. {
  79. destinationLocation = playerLoc;
  80. }
  81. if (destinationLocation != null)
  82. {
  83. if (!_plugin.hasDestination(destination) && !_plugin.hasLocation(destinationLocation))
  84. {
  85. _plugin.addDestination(player, destination, destinationLocation, container);
  86. if (_plugin.hasDestination(destination))
  87. {
  88. player.sendMessage(ChatColor.GREEN
  89. + _plugin.getMessage(TravelGatesMessages.DESTINATION_ADDED, ChatColor.AQUA + destination
  90. + ChatColor.GREEN));
  91. }
  92. else
  93. {
  94. player.sendMessage(ChatColor.RED
  95. + _plugin.getMessage(TravelGatesMessages.DESTINATION_ADD_FAIL, ChatColor.AQUA
  96. + destination + ChatColor.RED));
  97. }
  98. }
  99. else
  100. {
  101. player.sendMessage(_plugin.getMessage(TravelGatesMessages.DESTINATION_ALREADY_EXISTS, ChatColor.AQUA
  102. + destination + ChatColor.RED));
  103. }
  104. }
  105. }
  106. else
  107. {
  108. player.sendMessage(_plugin.getMessage(TravelGatesMessages.DESTINATION_PATTERN_ERROR));
  109. }
  110. }
  111. else
  112. {
  113. player.sendMessage(ChatColor.YELLOW + _plugin.getMessage(TravelGatesMessages.SHORT_HELP));
  114. }
  115. }
  116. }
  117. // /tg del ...
  118. else if (TravelGatesCommands.DEL.has(arg1))
  119. {
  120. if (_plugin.hasPermission(player, TravelGatesPermissionsNodes.DEL))
  121. {
  122. if (split.length > 1)
  123. {
  124. final String destination = split[1];
  125. // /tg del <destination>
  126. if (destination.matches(TravelGatesConstants.DESTINATION_NAME_PATTERN))
  127. {
  128. if (_plugin.hasDestination(destination))
  129. {
  130. boolean save = false;
  131. // /tg del <destination> -s
  132. if (split.length > 2)
  133. {
  134. final String options = split[2];
  135. if (TravelGatesUtils.stringIsNotBlank(options)
  136. && options.contains(_optionPrefixe + TravelGatesOptions.SAVE.value()))
  137. {
  138. save = true;
  139. }
  140. }
  141. _plugin.deleteDestination(destination, save, player);
  142. player.sendMessage(ChatColor.GREEN
  143. + _plugin.getMessage(TravelGatesMessages.DESTINATION_DEL, ChatColor.AQUA + destination
  144. + ChatColor.GREEN));
  145. }
  146. else
  147. {
  148. player.sendMessage(ChatColor.RED
  149. + _plugin.getMessage(TravelGatesMessages.DESTINATION_DOESNT_EXIST, ChatColor.AQUA + destination
  150. + ChatColor.RED));
  151. }
  152. }
  153. else
  154. {
  155. player.sendMessage(_plugin.getMessage(TravelGatesMessages.DESTINATION_PATTERN_ERROR));
  156. }
  157. }
  158. else
  159. {
  160. player.sendMessage(ChatColor.YELLOW + _plugin.getMessage(TravelGatesMessages.SHORT_HELP));
  161. }
  162. }
  163. else
  164. {
  165. player.sendMessage(ChatColor.RED + _plugin.getMessage(TravelGatesMessages.USER_NOT_ALLOWED));
  166. }
  167. }
  168. // tg restrict <destination>
  169. else if (TravelGatesCommands.RESTRICT.has(arg1))
  170. {
  171. if (_plugin.hasPermission(player, TravelGatesPermissionsNodes.RESTRICT))
  172. {
  173. if (split.length > 1)
  174. {
  175. // destination's name
  176. final String destination = split[1];
  177. // /tg restrict <destination>
  178. if (destination.matches(TravelGatesConstants.DESTINATION_NAME_PATTERN))
  179. {
  180. if (_plugin.hasDestination(destination))
  181. {
  182. player.sendMessage(ChatColor.YELLOW + _plugin.getRestrictionsList(destination));
  183. }
  184. else
  185. {
  186. player.sendMessage(ChatColor.RED
  187. + _plugin.getMessage(TravelGatesMessages.DESTINATION_DOESNT_EXIST, ChatColor.AQUA + destination
  188. + ChatColor.RED));
  189. }
  190. }
  191. else
  192. {
  193. player.sendMessage(_plugin.getMessage(TravelGatesMessages.DESTINATION_PATTERN_ERROR));
  194. }
  195. }
  196. else
  197. {
  198. player.sendMessage(ChatColor.YELLOW + _plugin.getMessage(TravelGatesMessages.SHORT_HELP));
  199. }
  200. }
  201. }
  202. // tg loc <destination>
  203. else if (TravelGatesCommands.LOC.has(arg1))
  204. {
  205. if (_plugin.hasPermission(player, TravelGatesPermissionsNodes.LOC))
  206. {
  207. if (split.length > 1)
  208. {
  209. // destination's name
  210. final String destination = split[1];
  211. // /tg loc <destination>
  212. if (destination.matches(TravelGatesConstants.DESTINATION_NAME_PATTERN))
  213. {
  214. if (_plugin.hasDestination(destination))
  215. {
  216. player.sendMessage(ChatColor.YELLOW
  217. + _plugin.getMessage(TravelGatesMessages.DESTINATION_LOCATION, destination) + ChatColor.AQUA
  218. + _plugin.getShortLoc(destination));
  219. }
  220. else
  221. {
  222. player.sendMessage(ChatColor.RED
  223. + _plugin.getMessage(TravelGatesMessages.DESTINATION_DOESNT_EXIST, destination));
  224. }
  225. }
  226. else
  227. {
  228. player.sendMessage(_plugin.getMessage(TravelGatesMessages.DESTINATION_PATTERN_ERROR));
  229. }
  230. }
  231. else
  232. {
  233. player.sendMessage(ChatColor.YELLOW + _plugin.getMessage(TravelGatesMessages.SHORT_HELP));
  234. }
  235. }
  236. }
  237. // /tg update ...
  238. else if (TravelGatesCommands.UPDATE.has(arg1))
  239. {
  240. // /tg options|update <destinnations> ...
  241. if (_plugin.hasPermission(player, TravelGatesPermissionsNodes.UPDATE))
  242. {
  243. if (split.length > 1)
  244. {
  245. final String destination = split[1];
  246. if (destination.matches(TravelGatesConstants.DESTINATION_NAME_PATTERN))
  247. {
  248. String options = null;
  249. if (split.length > 2)
  250. {
  251. options = split[2];
  252. }
  253. // /tg update <destination> [-options]
  254. if (options != null && options.startsWith(_optionPrefixe))
  255. {
  256. final TravelGatesOptionsContainer container = _plugin.createDestinationOptions(destination, options);
  257. final boolean updated = _plugin.updateDestination(destination.toLowerCase(), container, player);
  258. if (updated)
  259. {
  260. player.sendMessage(ChatColor.GREEN + _plugin.getMessage(TravelGatesMessages.OPTIONS_UPDATE_DONE));
  261. player.sendMessage(ChatColor.YELLOW + _plugin.getDestinationDetails(destination));
  262. }
  263. else
  264. {
  265. player.sendMessage(ChatColor.RED + _plugin.getMessage(TravelGatesMessages.OPTIONS_UPDATE_FAILED));
  266. }
  267. }
  268. else
  269. {
  270. player.sendMessage(ChatColor.RED + _plugin.getMessage(TravelGatesMessages.OPTIONS_ERROR));
  271. }
  272. }
  273. else
  274. {
  275. player.sendMessage(ChatColor.RED + _plugin.getMessage(TravelGatesMessages.DESTINATION_PATTERN_ERROR));
  276. }
  277. }
  278. else
  279. {
  280. player.sendMessage(ChatColor.YELLOW + _plugin.getMessage(TravelGatesMessages.SHORT_HELP));
  281. }
  282. }
  283. }
  284. // /tg list
  285. else if (TravelGatesCommands.LIST.has(arg1))
  286. {
  287. if (_plugin.hasPermission(player, TravelGatesPermissionsNodes.LIST))
  288. {
  289. player.sendMessage(ChatColor.YELLOW + _plugin.getDestinationsList());
  290. }
  291. }
  292. // /tg config
  293. else if (TravelGatesCommands.CONFIG.has(arg1))
  294. {
  295. if (_plugin.hasPermission(player, TravelGatesPermissionsNodes.CONFIG))
  296. {
  297. player.sendMessage(_plugin.getCurrentConfiguration());
  298. }
  299. }
  300. // /tg perms
  301. else if (TravelGatesCommands.PERMS.has(arg1))
  302. {
  303. if (_plugin.hasPermission(player, TravelGatesPermissionsNodes.PERMS))
  304. {
  305. boolean permissionsEnabled = _plugin.togglePermissionsState();
  306. if (permissionsEnabled)
  307. {
  308. player.sendMessage(ChatColor.GREEN + _plugin.getMessage(TravelGatesMessages.PERMS_ENABLED));
  309. }
  310. else
  311. {
  312. player.sendMessage(ChatColor.RED + _plugin.getMessage(TravelGatesMessages.PERMS_DISABLED));
  313. }
  314. }
  315. }
  316. // /tg signtp
  317. else if (TravelGatesCommands.SIGNTP.has(arg1))
  318. {
  319. if (_plugin.hasPermission(player, TravelGatesPermissionsNodes.SIGNTP))
  320. {
  321. boolean signTeleportEnabled = _plugin.toggleSignTeleportState();
  322. if (signTeleportEnabled)
  323. {
  324. player.sendMessage(ChatColor.GREEN + _plugin.getMessage(TravelGatesMessages.SIGNTP_ENABLED));
  325. }
  326. else
  327. {
  328. player.sendMessage(ChatColor.RED + _plugin.getMessage(TravelGatesMessages.SIGNTP_DISABLED));
  329. }
  330. }
  331. }
  332. // /tg portaltp
  333. else if (TravelGatesCommands.PORTALTP.has(arg1))
  334. {
  335. if (_plugin.hasPermission(player, TravelGatesPermissionsNodes.PORTALTP))
  336. {
  337. boolean portalTeleportEnabled = _plugin.togglePortalTeleportState();
  338. if (portalTeleportEnabled)
  339. {
  340. player.sendMessage(ChatColor.GREEN + _plugin.getMessage(TravelGatesMessages.PORTALTP_ENABLED));
  341. }
  342. else
  343. {
  344. player.sendMessage(ChatColor.RED + _plugin.getMessage(TravelGatesMessages.PORTALTP_DISABLED));
  345. }
  346. }
  347. }
  348. // /tg clearallinv
  349. else if (TravelGatesCommands.CLEARALLINV.has(arg1))
  350. {
  351. if (_plugin.hasPermission(player, TravelGatesPermissionsNodes.CLEARALLINV))
  352. {
  353. boolean clearAllInventoryEnabled = _plugin.toggleClearAllInventoryState();
  354. if (clearAllInventoryEnabled)
  355. {
  356. player.sendMessage(ChatColor.GREEN + _plugin.getMessage(TravelGatesMessages.CLEARALLINV_ENABLED));
  357. }
  358. else
  359. {
  360. player.sendMessage(ChatColor.RED + _plugin.getMessage(TravelGatesMessages.CLEARALLINV_DISABLED));
  361. }
  362. }
  363. }
  364. // /tg protectadmininv
  365. else if (TravelGatesCommands.PROECTADMININV.has(arg1))
  366. {
  367. if (_plugin.hasPermission(player, TravelGatesPermissionsNodes.PROTECTADMININV))
  368. {
  369. boolean clearAllInventoryEnabled = _plugin.toggleProtectAdminInventoryState();
  370. if (clearAllInventoryEnabled)
  371. {
  372. player.sendMessage(ChatColor.GREEN + _plugin.getMessage(TravelGatesMessages.PROTECTADMININV_ENABLED));
  373. }
  374. else
  375. {
  376. player.sendMessage(ChatColor.RED + _plugin.getMessage(TravelGatesMessages.PROTECTADMININV_DISABLED));
  377. }
  378. }
  379. }
  380. // /tg autosave
  381. else if (TravelGatesCommands.AUTOSAVE.has(arg1))
  382. {
  383. if (_plugin.hasPermission(player, TravelGatesPermissionsNodes.AUTOSAVE))
  384. {
  385. boolean clearAllInventoryEnabled = _plugin.toggleAutoSaveState();
  386. if (clearAllInventoryEnabled)
  387. {
  388. player.sendMessage(ChatColor.GREEN + _plugin.getMessage(TravelGatesMessages.AUTOSAVE_ENABLED));
  389. }
  390. else
  391. {
  392. player.sendMessage(ChatColor.RED + _plugin.getMessage(TravelGatesMessages.AUTOSAVE_DISABLED));
  393. }
  394. }
  395. }
  396. // /tg details ...
  397. else if (TravelGatesCommands.DETAILS.has(arg1))
  398. {
  399. String arg2 = null;
  400. if (split.length > 1)
  401. {
  402. arg2 = split[1];
  403. }
  404. if (_plugin.hasPermission(player, TravelGatesPermissionsNodes.DETAILS))
  405. {
  406. // tg details
  407. if (arg2 == null)
  408. {
  409. player.sendMessage(ChatColor.YELLOW + _plugin.getDestinationsDetailsList());
  410. }
  411. // tg details <dest>
  412. else
  413. {
  414. if (arg2.matches(TravelGatesConstants.DESTINATION_NAME_PATTERN))
  415. {
  416. player.sendMessage(ChatColor.YELLOW + _plugin.getDestinationDetails(arg2));
  417. }
  418. else
  419. {
  420. player.sendMessage(ChatColor.RED + _plugin.getMessage(TravelGatesMessages.DESTINATION_PATTERN_ERROR));
  421. }
  422. }
  423. }
  424. }
  425. // tg tpblock ...
  426. else if (TravelGatesCommands.TPBLOCK.has(arg1))
  427. {
  428. if (_plugin.hasPermission(player, TravelGatesPermissionsNodes.TPBLOCK))
  429. {
  430. String tpblock = null;
  431. if (split.length > 1)
  432. {
  433. tpblock = split[1];
  434. }
  435. boolean tpBlockEnabled = false;
  436. // tg tpblock
  437. if (TravelGatesUtils.stringIsBlank(tpblock))
  438. {
  439. tpBlockEnabled = _plugin.toggleTeleportBlockState();
  440. }
  441. // tg tpblock xxx[,xxx]
  442. else
  443. {
  444. tpBlockEnabled = _plugin.configTeleportBlock(tpblock, true);
  445. }
  446. if (tpBlockEnabled)
  447. {
  448. player.sendMessage(ChatColor.GREEN
  449. + _plugin.getMessage(TravelGatesMessages.TPBLOCK_ENABLED, ChatColor.YELLOW
  450. + _plugin.getTeleportBlock().toString()));
  451. }
  452. else
  453. {
  454. player.sendMessage(ChatColor.RED + _plugin.getMessage(TravelGatesMessages.TPBLOCK_DISABLED));
  455. }
  456. }
  457. }
  458. // /tg worlds...
  459. else if (TravelGatesCommands.WORLDS.has(arg1))
  460. {
  461. if (_plugin.hasPermission(player, TravelGatesPermissionsNodes.WORLDS))
  462. {
  463. String arg2 = null;
  464. if (split.length > 1)
  465. {
  466. arg2 = split[1];
  467. // /tg worlds (<world>|*) ...
  468. if (arg2 != null)
  469. {
  470. String arg3 = null;
  471. if (split.length > 2)
  472. {
  473. arg3 = split[2];
  474. }
  475. // /tg worlds <world> ...
  476. if (arg3 != null && arg3.startsWith(TravelGatesConstants.OPTION_PREFIX))
  477. {
  478. if (arg2.matches(TravelGatesConstants.DESTINATION_NAME_PATTERN))
  479. {
  480. final TravelGatesOptions option = TravelGatesOptions.get(arg3.substring(1, 2));
  481. if (option != null)
  482. {
  483. switch (option)
  484. {
  485. // /tg worlds -l ...
  486. case LOADWORLD:
  487. String type = null;
  488. // /tg worlds <world> -l [type]
  489. if (split.length > 3)
  490. {
  491. type = split[3];
  492. }
  493. final World loadedWorld = _plugin.loadWorld(arg2, type);
  494. player.sendMessage(_plugin.getWorldState(loadedWorld, arg2));
  495. break;
  496. // /tg worlds <world> -u
  497. case UNLOADWORLD:
  498. final World unloadedWorld = _plugin.unloadWorld(arg2);
  499. if (unloadedWorld != null)
  500. {
  501. final String number = String.valueOf(unloadedWorld.getPlayers().size());
  502. player.sendMessage(ChatColor.RED
  503. + _plugin.getMessage(TravelGatesMessages.CANNOT_UNLOAD_WORLD_WITH_PLAYERS,
  504. ChatColor.AQUA + arg2 + ChatColor.RED, ChatColor.AQUA + number
  505. + ChatColor.RED));
  506. }
  507. player.sendMessage(_plugin.getWorldState(unloadedWorld, arg2));
  508. break;
  509. default:
  510. player.sendMessage(ChatColor.RED + _plugin.getMessage(TravelGatesMessages.UNKNOWN_OPTION));
  511. }
  512. }
  513. else
  514. {
  515. player.sendMessage(ChatColor.RED + _plugin.getMessage(TravelGatesMessages.UNKNOWN_OPTION));
  516. }
  517. }
  518. else
  519. {
  520. player.sendMessage(ChatColor.RED + _plugin.getMessage(TravelGatesMessages.WORLD_PATTERN_ERROR));
  521. }
  522. }
  523. // tg worlds (<world>|*)
  524. else
  525. {
  526. // /tg worlds <world>
  527. if (arg2.matches(TravelGatesConstants.DESTINATION_NAME_PATTERN))
  528. {
  529. player.sendMessage(_plugin.getWorldState(arg2));
  530. }
  531. // /tg worlds *
  532. else if (arg2.equals(TravelGatesConstants.WILDCARD))
  533. {
  534. player.sendMessage(_plugin.getAllWorldsFromServerDirectory());
  535. }
  536. else
  537. {
  538. player.sendMessage(ChatColor.RED + _plugin.getMessage(TravelGatesMessages.WORLD_PATTERN_ERROR));
  539. }
  540. }
  541. }
  542. }
  543. // /tg worlds
  544. else
  545. {
  546. player.sendMessage(_plugin.getListOfWorlds());
  547. }
  548. }
  549. }
  550. // /tg name
  551. else if (TravelGatesCommands.NAME.has(arg1))
  552. {
  553. if (_plugin.hasPermission(player, TravelGatesPermissionsNodes.NAME))
  554. {
  555. final String destination = _plugin.getDestination(player.getLocation());
  556. if (destination != null)
  557. {
  558. player.sendMessage(ChatColor.YELLOW
  559. + _plugin.getMessage(TravelGatesMessages.YOU_ARE_AT, ChatColor.AQUA + destination));
  560. }
  561. else
  562. {
  563. player.sendMessage(ChatColor.RED + _plugin.getMessage(TravelGatesMessages.NO_STANDING_ON_DESTINATION));
  564. }
  565. }
  566. }
  567. // /tg save
  568. else if (TravelGatesCommands.SAVE.has(arg1))
  569. {
  570. if (_plugin.hasPermission(player, TravelGatesPermissionsNodes.SAVE))
  571. {
  572. final boolean saved = _plugin.saveAll();
  573. if (saved)
  574. {
  575. player.sendMessage(ChatColor.GREEN + _plugin.getMessage(TravelGatesMessages.SAVE_DONE));
  576. }
  577. else
  578. {
  579. player.sendMessage(ChatColor.RED + _plugin.getMessage(TravelGatesMessages.SAVE_FAILED));
  580. }
  581. }
  582. }
  583. // /tg help
  584. else if (TravelGatesCommands.HELP.has(arg1))
  585. {
  586. if (_plugin.hasPermission(player, TravelGatesPermissionsNodes.HELP))
  587. {
  588. player.sendMessage(ChatColor.YELLOW + _plugin.getMessage(TravelGatesMessages.SHORT_HELP));
  589. }
  590. }
  591. // /tg version
  592. else if (TravelGatesCommands.VERSION.has(arg1))
  593. {
  594. if (_plugin.hasPermission(player, TravelGatesPermissionsNodes.VERSION))
  595. {
  596. player.sendMessage(ChatColor.YELLOW + _plugin.getDescription().getVersion());
  597. }
  598. }
  599. // /tg debug
  600. else if (TravelGatesCommands.DEBUG.has(arg1))
  601. {
  602. if (_plugin.hasPermission(player, TravelGatesPermissionsNodes.DEBUG))
  603. {
  604. _plugin.toggleDebugState();
  605. if (_plugin.isDebugEnabled())
  606. {
  607. player.sendMessage(ChatColor.GREEN + _plugin.getMessage(TravelGatesMessages.DEBUG_ENABLED));
  608. }
  609. else
  610. {
  611. player.sendMessage(ChatColor.RED + _plugin.getMessage(TravelGatesMessages.DEBUG_DISABLED));
  612. }
  613. }
  614. }
  615. // /tg displayteleportmessage
  616. else if (TravelGatesCommands.DISPLAYTELEPORTMESSAGE.has(arg1))
  617. {
  618. if (_plugin.hasPermission(player, TravelGatesPermissionsNodes.DISPLAYTELEPORTMESSAGE))
  619. {
  620. if (_plugin.toggleDisplayTeleportMessage())
  621. {
  622. player.sendMessage(ChatColor.GREEN + _plugin.getMessage(TravelGatesMessages.DISPLAY_TELEPORT_MESSAGE_ENABLED));
  623. }
  624. else
  625. {
  626. player.sendMessage(ChatColor.RED + _plugin.getMessage(TravelGatesMessages.DISPLAY_TELEPORT_MESSAGE_DISABLED));
  627. }
  628. }
  629. }
  630. // /tg <destination> ...
  631. else if (arg1.matches(TravelGatesConstants.DESTINATION_NAME_PATTERN))
  632. {
  633. if (_plugin.hasPermission(player, TravelGatesPermissionsNodes.TELEPORT_CMD))
  634. {
  635. String ignoreOption = null;
  636. boolean ignorePlayerLocation = false;
  637. if (split.length > 1)
  638. {
  639. ignoreOption = split[1];
  640. if ((_optionPrefixe + TravelGatesOptions.FORCETP.value()).equalsIgnoreCase(ignoreOption))
  641. {
  642. if (_plugin.hasPermission(player, TravelGatesPermissionsNodes.FORCETP))
  643. {
  644. ignorePlayerLocation = true;
  645. }
  646. }
  647. }
  648. _plugin.teleportPlayerToDest(arg1, player, false, ignorePlayerLocation, null);
  649. }
  650. }
  651. else
  652. {
  653. player.sendMessage(ChatColor.YELLOW + _plugin.getMessage(TravelGatesMessages.SHORT_HELP));
  654. }
  655. }
  656. // /tg
  657. else
  658. {
  659. player.sendMessage(ChatColor.YELLOW + _plugin.getMessage(TravelGatesMessages.SHORT_HELP));
  660. }
  661. }
  662. }
  663. }
  664. return result;
  665. }
  666. }