11package com .perceivedev .clicktpa ;
22
3+ import me .rayzr522 .jsonmessage .JSONMessage ;
34import org .bukkit .Bukkit ;
45import org .bukkit .ChatColor ;
56import org .bukkit .configuration .file .FileConfiguration ;
@@ -55,46 +56,44 @@ public void run() {
5556 }
5657 }
5758
58- private JSONMessage getLine (Player player , String configPath ) {
59+ private void sendClickableMessage (Player player ) {
5960 FileConfiguration config = getConfig ();
60- boolean useDisplayName = config .getBoolean ("message.use-display-name" );
61+ String configMessage = config .getString ("message.line" , "" );
62+ if (configMessage .isEmpty ()) {
63+ return ;
64+ }
65+
6166 JSONMessage message = JSONMessage .create ();
62- if (config .getString ("message." + configPath ) != "" ) {
63- String [] words = config .getString ("message." + configPath ).split (" " );
64- for (int i = 0 ; i < words .length ; i ++) {
65- String word = trans (words [i ].replace ("%player%" , useDisplayName ? player .getDisplayName () : player .getName ()));
66- if (word .equalsIgnoreCase ("%accept%" )) {
67- message .then (trans (config .getString ("message.accept" ))).runCommand ("/tpaccept" );
68- } else if (word .equalsIgnoreCase ("%deny%" )) {
69- message .then (trans (config .getString ("message.deny" ))).runCommand ("/tpdeny" );
70- } else {
71- message .then (word ).color (ChatColor .GOLD );
72- }
73- message .then (" " );
67+ boolean useDisplayName = config .getBoolean ("message.use-display-name" );
68+ for (String word : configMessage .split (" " )) {
69+ if (word .equalsIgnoreCase ("%accept%" )) {
70+ message .then (colorize (config .getString ("message.accept" ))).runCommand ("/tpaccept" );
71+ } else if (word .equalsIgnoreCase ("%deny%" )) {
72+ message .then (colorize (config .getString ("message.deny" ))).runCommand ("/tpdeny" );
73+ } else {
74+ message .then (colorize (word .replace ("%player%" , useDisplayName ? player .getDisplayName () : player .getName ()))).color (ChatColor .GOLD );
7475 }
76+ message .then (" " );
7577 }
76- return message ;
78+ message . send ( player ) ;
7779 }
7880
7981 private void sendMessages (Player player ) {
80- String spacer = getConfig ().getString ("message.spacer" );
81- sendSpacer (player , spacer );
82- getLine (player , "line" ).send (player );
83- sendSpacer (player , spacer );
82+ sendSpacer (player );
83+ sendClickableMessage (player );
84+ sendSpacer (player );
8485 }
8586
86- private void sendSpacer (Player player , String spacer ) {
87- if (spacer .equals ("" )) {
88- return ;
89- } else if (spacer .equals ("bar" )) {
87+ private void sendSpacer (Player player ) {
88+ String spacer = getConfig ().getString ("message.spacer" , "" );
89+ if (spacer .equals ("bar" )) {
9090 JSONMessage .create ().bar ().send (player );
91- } else {
92- player .sendMessage (trans (spacer ));
91+ } else if (! spacer . isEmpty ()) {
92+ player .sendMessage (colorize (spacer ));
9393 }
9494 }
9595
96- private String trans (String string ) {
96+ private String colorize (String string ) {
9797 return ChatColor .translateAlternateColorCodes ('&' , string );
9898 }
99-
10099}
0 commit comments