add coloring to /geo
sorry for low effort today
This commit is contained in:
		
					parent
					
						
							
								883ce366d1
							
						
					
				
			
			
				commit
				
					
						1efd8cb091
					
				
			
		
					 1 changed files with 15 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -9,7 +9,9 @@ import org.bukkit.entity.Player;
 | 
			
		|||
 | 
			
		||||
import eu.m724.realweather.GlobalConstants;
 | 
			
		||||
import eu.m724.wtapi.object.Coordinates;
 | 
			
		||||
import net.md_5.bungee.api.ChatColor;
 | 
			
		||||
import net.md_5.bungee.api.chat.BaseComponent;
 | 
			
		||||
import net.md_5.bungee.api.chat.ComponentBuilder;
 | 
			
		||||
import net.md_5.bungee.api.chat.TextComponent;
 | 
			
		||||
 | 
			
		||||
public class GeoCommand implements CommandExecutor {
 | 
			
		||||
| 
						 | 
				
			
			@ -22,8 +24,13 @@ public class GeoCommand implements CommandExecutor {
 | 
			
		|||
			if (player != null)  {
 | 
			
		||||
				Location location = player.getLocation();
 | 
			
		||||
				Coordinates coordinates = GlobalConstants.getMapper().locationToCoordinates(location);
 | 
			
		||||
				String text = String.format("Position: %f %f %f\nGeolocation: %f %f", location.getX(), location.getY(), location.getZ(), coordinates.latitude, coordinates.longitude);
 | 
			
		||||
				BaseComponent component = TextComponent.fromLegacy(text); // TODO add color
 | 
			
		||||
				
 | 
			
		||||
				BaseComponent[] component = new ComponentBuilder("\nGeolocation: ").color(ChatColor.GOLD)
 | 
			
		||||
						.append(String.format("lat: %f, lon: %f\n", coordinates.latitude, coordinates.longitude)).color(ChatColor.AQUA)
 | 
			
		||||
						.append("Position: ").color(ChatColor.GRAY)
 | 
			
		||||
						.append(String.format("x: %f, z: %f\n", location.getX(), location.getZ())).color(ChatColor.DARK_AQUA)
 | 
			
		||||
						.create(); // TODO improve readability
 | 
			
		||||
				
 | 
			
		||||
				player.spigot().sendMessage(component);
 | 
			
		||||
			} else {
 | 
			
		||||
				sender.sendMessage("Add arguments to use this command in console");
 | 
			
		||||
| 
						 | 
				
			
			@ -35,8 +42,12 @@ public class GeoCommand implements CommandExecutor {
 | 
			
		|||
			Coordinates coordinates = new Coordinates(latitude, longitude);
 | 
			
		||||
			Location location = GlobalConstants.getMapper().coordinatesToLocation(player.getWorld(), coordinates);
 | 
			
		||||
			
 | 
			
		||||
			String text = String.format("Position: %f %f %f\nGeolocation: %f %f", location.getX(), location.getY(), location.getZ(), coordinates.latitude, coordinates.longitude);
 | 
			
		||||
			BaseComponent component = TextComponent.fromLegacy(text);
 | 
			
		||||
			BaseComponent[] component = new ComponentBuilder("\nPosition: ").color(ChatColor.GOLD)
 | 
			
		||||
					.append(String.format("x: %f, z: %f\n", location.getX(), location.getZ())).color(ChatColor.AQUA)
 | 
			
		||||
					.append("Geolocation: ").color(ChatColor.GRAY)
 | 
			
		||||
					.append(String.format("lat: %f, lon: %f\n", coordinates.latitude, coordinates.longitude)).color(ChatColor.DARK_AQUA)
 | 
			
		||||
					.create();
 | 
			
		||||
			
 | 
			
		||||
			player.spigot().sendMessage(component);
 | 
			
		||||
			
 | 
			
		||||
			if (args.length == 3) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue