Added /sethome suggestion to jump message
This commit is contained in:
parent
3cfb3ad192
commit
8d4fd1e327
9 changed files with 39 additions and 28 deletions
|
@ -248,10 +248,6 @@ public class Commons {
|
|||
|
||||
public static void addChatMessage(final ICommandSender commandSender, @Nonnull final ITextComponent textComponent) {
|
||||
final String message = textComponent.getFormattedText();
|
||||
addChatMessage(commandSender, message);
|
||||
}
|
||||
|
||||
public static void addChatMessage(final ICommandSender commandSender, @Nonnull final String message) {
|
||||
if (commandSender == null) {
|
||||
WarpDrive.logger.error(String.format("Unable to send message to NULL sender: %s",
|
||||
message));
|
||||
|
@ -264,23 +260,28 @@ public class Commons {
|
|||
}
|
||||
|
||||
final String[] lines = updateEscapeCodes(message).split("\n");
|
||||
String formatNextLine = "";
|
||||
for (final String line : lines) {
|
||||
commandSender.sendMessage(new TextComponentString(formatNextLine + line));
|
||||
if (lines.length == 1) {
|
||||
commandSender.sendMessage(textComponent);
|
||||
|
||||
// compute remaining format
|
||||
int index = 0;
|
||||
while (index < line.length()) {
|
||||
if (line.charAt(index) == (char) 167 && index + 1 < line.length()) {
|
||||
index++;
|
||||
final char charFormat = line.charAt(index);
|
||||
if (charFormat == 'r') {
|
||||
formatNextLine = CHAR_FORMATTING + charFormat;
|
||||
} else {
|
||||
formatNextLine += CHAR_FORMATTING + charFormat;
|
||||
} else {
|
||||
String formatNextLine = "";
|
||||
for (final String line : lines) {
|
||||
commandSender.sendMessage(new TextComponentString(formatNextLine + line));
|
||||
|
||||
// compute remaining format
|
||||
int index = 0;
|
||||
while (index < line.length()) {
|
||||
if (line.charAt(index) == (char) 167 && index + 1 < line.length()) {
|
||||
index++;
|
||||
final char charFormat = line.charAt(index);
|
||||
if (charFormat == 'r') {
|
||||
formatNextLine = CHAR_FORMATTING + charFormat;
|
||||
} else {
|
||||
formatNextLine += CHAR_FORMATTING + charFormat;
|
||||
}
|
||||
}
|
||||
index++;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,10 +28,20 @@ public class WarpDriveText extends TextComponentString {
|
|||
super("");
|
||||
|
||||
final ITextComponent textComponent = new TextComponentTranslation(translationKey, args);
|
||||
if (style != null) {
|
||||
textComponent.setStyle(style);
|
||||
final String textRaw = textComponent.getUnformattedText();
|
||||
if (textRaw.startsWith("[") && textRaw.endsWith("]")) {
|
||||
final ITextComponent textComponentNested = ITextComponent.Serializer.jsonToComponent(textRaw);
|
||||
if (textComponentNested != null) {
|
||||
append(textComponentNested);
|
||||
} else {
|
||||
append(textComponent);
|
||||
}
|
||||
} else {
|
||||
if (style != null) {
|
||||
textComponent.setStyle(style);
|
||||
}
|
||||
append(textComponent);
|
||||
}
|
||||
append(textComponent);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
|
|
@ -947,7 +947,7 @@ warpdrive.ship.guide.not_enough_space_after_adjustment=Not enough space after ad
|
|||
warpdrive.ship.guide.entering_hyperspace=Entering hyperspace...
|
||||
warpdrive.ship.guide.leaving_hyperspace=Leaving hyperspace...
|
||||
warpdrive.ship.guide.engaging_jumpgate_x=Engaging jumpgate towards %1$s!
|
||||
warpdrive.ship.guide.jumping_xyz=Jumping of %1$d blocks (XYZ %2$d %3$d %4$d)
|
||||
warpdrive.ship.guide.jumping_xyz=[{"text": "Jumping of %1$d blocks (XYZ %2$d %3$d %4$d). "}, {"text": "Click to update home.", "color": "blue", "clickEvent": { "action": "run_command", "value": "/sethome -o" }}]
|
||||
warpdrive.ship.guide.turning_right=Turning to the right
|
||||
warpdrive.ship.guide.turning_back=Turning back
|
||||
warpdrive.ship.guide.turning_left=Turning to the left
|
||||
|
|
|
@ -953,7 +953,7 @@ warpdrive.ship.guide.not_enough_space_after_adjustment=Not enough space after ad
|
|||
warpdrive.ship.guide.entering_hyperspace=Entering hyperspace...
|
||||
warpdrive.ship.guide.leaving_hyperspace=Leaving hyperspace...
|
||||
warpdrive.ship.guide.engaging_jumpgate_x=Engaging jumpgate towards %1$s!
|
||||
warpdrive.ship.guide.jumping_xyz=Jumping of %1$d blocks (XYZ %2$d %3$d %4$d)
|
||||
warpdrive.ship.guide.jumping_xyz=[{"text": "Jumping of %1$d blocks (XYZ %2$d %3$d %4$d). "}, {"text": "Click to update home.", "color": "blue", "clickEvent": { "action": "run_command", "value": "/sethome -o" }}]
|
||||
warpdrive.ship.guide.turning_right=Turning to the right
|
||||
warpdrive.ship.guide.turning_back=Turning back
|
||||
warpdrive.ship.guide.turning_left=Turning to the left
|
||||
|
|
|
@ -953,7 +953,7 @@ warpdrive.ship.guide.not_enough_space_after_adjustment=Not enough space after ad
|
|||
warpdrive.ship.guide.entering_hyperspace=Entering hyperspace...
|
||||
warpdrive.ship.guide.leaving_hyperspace=Leaving hyperspace...
|
||||
warpdrive.ship.guide.engaging_jumpgate_x=Engaging jumpgate towards %1$s!
|
||||
warpdrive.ship.guide.jumping_xyz=Jumping of %1$d blocks (XYZ %2$d %3$d %4$d)
|
||||
warpdrive.ship.guide.jumping_xyz=[{"text": "Jumping of %1$d blocks (XYZ %2$d %3$d %4$d). "}, {"text": "Click to update home.", "color": "blue", "clickEvent": { "action": "run_command", "value": "/sethome -o" }}]
|
||||
warpdrive.ship.guide.turning_right=Turning to the right
|
||||
warpdrive.ship.guide.turning_back=Turning back
|
||||
warpdrive.ship.guide.turning_left=Turning to the left
|
||||
|
|
|
@ -952,7 +952,7 @@ warpdrive.ship.guide.not_enough_space_after_adjustment=Not enough space after ad
|
|||
warpdrive.ship.guide.entering_hyperspace=Entering hyperspace...
|
||||
warpdrive.ship.guide.leaving_hyperspace=Leaving hyperspace...
|
||||
warpdrive.ship.guide.engaging_jumpgate_x=Engaging jumpgate towards %1$s!
|
||||
warpdrive.ship.guide.jumping_xyz=Jumping of %1$d blocks (XYZ %2$d %3$d %4$d)
|
||||
warpdrive.ship.guide.jumping_xyz=[{"text": "Jumping of %1$d blocks (XYZ %2$d %3$d %4$d). "}, {"text": "Click to update home.", "color": "blue", "clickEvent": { "action": "run_command", "value": "/sethome -o" }}]
|
||||
warpdrive.ship.guide.turning_right=Turning to the right
|
||||
warpdrive.ship.guide.turning_back=Turning back
|
||||
warpdrive.ship.guide.turning_left=Turning to the left
|
||||
|
|
|
@ -953,7 +953,7 @@ warpdrive.ship.guide.not_enough_space_after_adjustment=Not enough space after ad
|
|||
warpdrive.ship.guide.entering_hyperspace=Entering hyperspace...
|
||||
warpdrive.ship.guide.leaving_hyperspace=Leaving hyperspace...
|
||||
warpdrive.ship.guide.engaging_jumpgate_x=Engaging jumpgate towards %1$s!
|
||||
warpdrive.ship.guide.jumping_xyz=Jumping of %1$d blocks (XYZ %2$d %3$d %4$d)
|
||||
warpdrive.ship.guide.jumping_xyz=[{"text": "Jumping of %1$d blocks (XYZ %2$d %3$d %4$d). "}, {"text": "Click to update home.", "color": "blue", "clickEvent": { "action": "run_command", "value": "/sethome -o" }}]
|
||||
warpdrive.ship.guide.turning_right=Turning to the right
|
||||
warpdrive.ship.guide.turning_back=Turning back
|
||||
warpdrive.ship.guide.turning_left=Turning to the left
|
||||
|
|
|
@ -953,7 +953,7 @@ warpdrive.ship.guide.not_enough_space_after_adjustment=调整后空间不足。
|
|||
warpdrive.ship.guide.entering_hyperspace=正在进入超空间……
|
||||
warpdrive.ship.guide.leaving_hyperspace=正在离开超空间……
|
||||
warpdrive.ship.guide.engaging_jumpgate_x=向 %1$s 启动跃迁门!
|
||||
warpdrive.ship.guide.jumping_xyz=正在跃迁 %1$d 格 (XYZ %2$d %3$d %4$d)
|
||||
warpdrive.ship.guide.jumping_xyz=[{"text": "正在跃迁 %1$d 格 (XYZ %2$d %3$d %4$d). "}, {"text": "Click to update home.", "color": "blue", "clickEvent": { "action": "run_command", "value": "/sethome -o" }}]
|
||||
warpdrive.ship.guide.turning_right=右转
|
||||
warpdrive.ship.guide.turning_back=向后转
|
||||
warpdrive.ship.guide.turning_left=左转
|
||||
|
|
|
@ -952,7 +952,7 @@ warpdrive.ship.guide.not_enough_space_after_adjustment=Not enough space after ad
|
|||
warpdrive.ship.guide.entering_hyperspace=Entering hyperspace...
|
||||
warpdrive.ship.guide.leaving_hyperspace=Leaving hyperspace...
|
||||
warpdrive.ship.guide.engaging_jumpgate_x=Engaging jumpgate towards %1$s!
|
||||
warpdrive.ship.guide.jumping_xyz=Jumping of %1$d blocks (XYZ %2$d %3$d %4$d)
|
||||
warpdrive.ship.guide.jumping_xyz=[{"text": "Jumping of %1$d blocks (XYZ %2$d %3$d %4$d). "}, {"text": "Click to update home.", "color": "blue", "clickEvent": { "action": "run_command", "value": "/sethome -o" }}]
|
||||
warpdrive.ship.guide.turning_right=Turning to the right
|
||||
warpdrive.ship.guide.turning_back=Turning back
|
||||
warpdrive.ship.guide.turning_left=Turning to the left
|
||||
|
|
Loading…
Reference in a new issue