MCPcopy Create free account
hub / github.com/5zig/The-5zig-Mod / shortenToWidth

Method shortenToWidth

Minecraft-Utils/1.13/src/Variables.java:186–202  ·  view source on GitHub ↗
(String string, int width)

Source from the content-addressed store, hash-verified

184 }
185
186 @Override
187 public String shortenToWidth(String string, int width) {
188 if (StringUtils.isEmpty(string))
189 return string;
190 Validate.isTrue(width > 0);
191
192 boolean changed = false;
193 if (getStringWidth(string) > width) {
194 while (getStringWidth(string + "...") > width && !string.isEmpty()) {
195 string = string.substring(0, string.length() - 1);
196 changed = true;
197 }
198 }
199 if (changed)
200 string += "...";
201 return string;
202 }
203
204 @Override
205 public IButton createButton(int id, int x, int y, String label) {

Callers

nothing calls this directly

Calls 3

getStringWidthMethod · 0.95
isEmptyMethod · 0.80
lengthMethod · 0.45

Tested by

no test coverage detected