Skip to content

Commit a4f49cf

Browse files
committed
Remove color in name and add for sending word labels
1 parent 5a5850c commit a4f49cf

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

src/main/java/me/ricglz/discoords/DiscoordsCommandExecutor.java

+16-18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package me.ricglz.discoords;
22

3+
import org.bukkit.ChatColor;
34
import org.bukkit.Location;
45
import org.bukkit.command.Command;
56
import org.bukkit.command.CommandExecutor;
@@ -15,28 +16,25 @@ public class DiscoordsCommandExecutor implements CommandExecutor {
1516
this.channel = channel;
1617
}
1718

19+
private void sendError(CommandSender sender, String error) {
20+
sender.sendMessage(ChatColor.RED + String.format("[Error] %s", error));
21+
}
22+
1823
@Override
1924
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
20-
if (args.length > 1) {
21-
sender.sendMessage("[Error] The command doesn't accept as many arguments");
22-
return false;
23-
}
2425
if (!(sender instanceof Player)) {
25-
sender.sendMessage("[Error] You must be a player!");
26-
return true;
26+
sendError(sender, "You must be a player!");
27+
} else if (channel == null) {
28+
sendError(sender, "Discord is not available");
29+
} else {
30+
Player player = (Player) sender;
31+
Location loc = player.getLocation();
32+
String coordinateValues = String.join(" ", args);
33+
String locString = String.format("(%d, %d, %d)", (int) loc.getX(), (int) loc.getY(), (int) loc.getZ());
34+
String msg = coordinateValues.isEmpty() ? locString : String.format("%s - %s", locString, coordinateValues);
35+
sender.sendMessage(msg);
36+
sendLocation(msg, ChatColor.stripColor(player.getDisplayName()));
2737
}
28-
if (channel == null) {
29-
sender.sendMessage("[Error] Discoord is not available");
30-
return true;
31-
}
32-
33-
Player player = (Player) sender;
34-
Location loc = player.getLocation();
35-
String locString = String.format("(%d, %d, %d)", (int) loc.getX(), (int) loc.getY(), (int) loc.getZ());
36-
String msg = args.length == 0 ? locString : String.format("%s - %s", locString, args[0]);
37-
sender.sendMessage(msg);
38-
sendLocation(msg, player.getDisplayName());
39-
4038
return true;
4139
}
4240

0 commit comments

Comments
 (0)