@@ -1499,6 +1499,10 @@ public List<TilePosition> getStartLocations() {
1499
1499
return startLocations ;
1500
1500
}
1501
1501
1502
+ private String formatString (final String string , final Text ... colors ) {
1503
+ return colors .length > 0 ? String .format (string , Arrays .stream (colors ).map (c -> c .id ).toArray ()) : string ;
1504
+ }
1505
+
1502
1506
/**
1503
1507
* Prints text to the screen as a notification. This function allows text
1504
1508
* formatting using {@link Text#formatText}.
@@ -1507,8 +1511,9 @@ public List<TilePosition> getStartLocations() {
1507
1511
*
1508
1512
* @param string String to print.
1509
1513
*/
1510
- public void printf (final String string ) {
1511
- addCommand (Printf , client .addString (string ), 0 );
1514
+ public void printf (final String string , final Text ... colors ) {
1515
+ final String formatted = formatString (string , colors );
1516
+ addCommand (Printf , client .addString (formatted ), 0 );
1512
1517
}
1513
1518
1514
1519
/**
@@ -1739,34 +1744,35 @@ public List<Player> observers() {
1739
1744
return observers ;
1740
1745
}
1741
1746
1742
- public void drawText (final CoordinateType ctype , final int x , final int y , final String string ) {
1743
- final int stringId = client .addString (string );
1747
+ public void drawText (final CoordinateType ctype , final int x , final int y , final String string , final Text ... colors ) {
1748
+ final String formatted = formatString (string , colors );
1749
+ final int stringId = client .addString (formatted );
1744
1750
addShape (ShapeType .Text , ctype , x , y , 0 , 0 , stringId , textSize .id , 0 , false );
1745
1751
}
1746
1752
1747
- public void drawTextMap (final int x , final int y , final String string ) {
1748
- drawText (CoordinateType .Map , x , y , string );
1753
+ public void drawTextMap (final int x , final int y , final String string , final Text ... colors ) {
1754
+ drawText (CoordinateType .Map , x , y , string , colors );
1749
1755
}
1750
1756
1751
- public void drawTextMap (final Position p , final String string ) {
1752
- drawTextMap (p .x , p .y , string );
1757
+ public void drawTextMap (final Position p , final String string , final Text ... colors ) {
1758
+ drawTextMap (p .x , p .y , string , colors );
1753
1759
}
1754
1760
1755
- public void drawTextMouse (final int x , final int y , final String string ) {
1756
- drawText (CoordinateType .Mouse , x , y , string );
1761
+ public void drawTextMouse (final int x , final int y , final String string , final Text ... colors ) {
1762
+ drawText (CoordinateType .Mouse , x , y , string , colors );
1757
1763
}
1758
1764
1759
- public void drawTextMouse (final Position p , final String string ) {
1760
- drawTextMouse (p .x , p .y , string );
1765
+ public void drawTextMouse (final Position p , final String string , final Text ... colors ) {
1766
+ drawTextMouse (p .x , p .y , string , colors );
1761
1767
1762
1768
}
1763
1769
1764
- public void drawTextScreen (final int x , final int y , final String string ) {
1765
- drawText (CoordinateType .Screen , x , y , string );
1770
+ public void drawTextScreen (final int x , final int y , final String string , final Text ... colors ) {
1771
+ drawText (CoordinateType .Screen , x , y , string , colors );
1766
1772
}
1767
1773
1768
- public void drawTextScreen (final Position p , final String string ) {
1769
- drawTextScreen (p .x , p .y , string );
1774
+ public void drawTextScreen (final Position p , final String string , final Text ... colors ) {
1775
+ drawTextScreen (p .x , p .y , string , colors );
1770
1776
}
1771
1777
1772
1778
public void drawBox (final CoordinateType ctype , final int left , final int top , final int right , final int bottom , final Color color ) {
0 commit comments