mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-04 03:56:41 +00:00
Use wrappers for the Format-type components
This commit is contained in:
@ -19,18 +19,30 @@
|
||||
|
||||
package com.sk89q.worldedit.util.formatting.component;
|
||||
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
|
||||
/**
|
||||
* Represents a fragment representing a command that is to be typed.
|
||||
*/
|
||||
public class Code extends TextComponentProducer {
|
||||
public class CodeFormat extends TextComponentProducer {
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*/
|
||||
public Code(String message) {
|
||||
getBuilder().content(message).color(TextColor.AQUA);
|
||||
private CodeFormat() {
|
||||
getBuilder().content("").color(TextColor.AQUA);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a CodeFormat with the given message.
|
||||
*
|
||||
* @param texts The text
|
||||
* @return The Component
|
||||
*/
|
||||
public static Component wrap(String ... texts) {
|
||||
CodeFormat code = new CodeFormat();
|
||||
for (String text: texts) {
|
||||
code.append(text);
|
||||
}
|
||||
|
||||
return code.create();
|
||||
}
|
||||
}
|
@ -19,7 +19,6 @@
|
||||
|
||||
package com.sk89q.worldedit.util.formatting.component;
|
||||
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
|
||||
import com.sk89q.worldedit.util.formatting.text.event.HoverEvent;
|
||||
@ -44,7 +43,7 @@ public class CommandListBox extends MessageBox {
|
||||
|
||||
public CommandListBox appendCommand(String alias, String description, String insertion) {
|
||||
if (!first) {
|
||||
getContents().append(Component.newline());
|
||||
getContents().newline();
|
||||
}
|
||||
TextComponent commandName = TextComponent.of(alias, TextColor.GOLD);
|
||||
if (insertion != null) {
|
||||
@ -53,7 +52,7 @@ public class CommandListBox extends MessageBox {
|
||||
.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to select")));
|
||||
}
|
||||
getContents().append(commandName.append(TextComponent.of(": ")));
|
||||
getContents().append(TextComponent.of(description));
|
||||
getContents().append(description);
|
||||
first = false;
|
||||
return this;
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ import com.sk89q.worldedit.util.command.Description;
|
||||
import com.sk89q.worldedit.util.command.Dispatcher;
|
||||
import com.sk89q.worldedit.util.command.PrimaryAliasComparator;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -88,20 +87,20 @@ public class CommandUsageBox extends TextComponentProducer {
|
||||
TextComponentProducer contents = new TextComponentProducer();
|
||||
|
||||
if (description.getUsage() != null) {
|
||||
contents.append(new Label("Usage: ").create());
|
||||
contents.append(TextComponent.of(description.getUsage()));
|
||||
contents.append(LabelFormat.wrap("Usage: "));
|
||||
contents.append(description.getUsage());
|
||||
} else {
|
||||
contents.append(new Subtle("Usage information is not available.").create());
|
||||
contents.append(SubtleFormat.wrap("Usage information is not available."));
|
||||
}
|
||||
|
||||
contents.append(Component.newline());
|
||||
|
||||
if (description.getHelp() != null) {
|
||||
contents.append(TextComponent.of(description.getHelp()));
|
||||
contents.append(description.getHelp());
|
||||
} else if (description.getDescription() != null) {
|
||||
contents.append(TextComponent.of(description.getDescription()));
|
||||
contents.append(description.getDescription());
|
||||
} else {
|
||||
contents.append(new Subtle("No further help is available.").create());
|
||||
contents.append(SubtleFormat.wrap("No further help is available."));
|
||||
}
|
||||
|
||||
MessageBox box = new MessageBox("Help for " + commandString, contents);
|
||||
|
@ -19,18 +19,33 @@
|
||||
|
||||
package com.sk89q.worldedit.util.formatting.component;
|
||||
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
|
||||
/**
|
||||
* Represents a fragment representing an error.
|
||||
*/
|
||||
public class Error extends TextComponentProducer {
|
||||
public class ErrorFormat extends TextComponentProducer {
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*/
|
||||
public Error(String message) {
|
||||
getBuilder().content(message).color(TextColor.RED);
|
||||
private ErrorFormat() {
|
||||
getBuilder().content("").color(TextColor.RED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an ErrorFormat with the given message.
|
||||
*
|
||||
* @param texts The text
|
||||
* @return The Component
|
||||
*/
|
||||
public static Component wrap(String ... texts) {
|
||||
ErrorFormat error = new ErrorFormat();
|
||||
for (String component : texts) {
|
||||
error.append(component);
|
||||
}
|
||||
|
||||
return error.create();
|
||||
}
|
||||
}
|
@ -19,18 +19,33 @@
|
||||
|
||||
package com.sk89q.worldedit.util.formatting.component;
|
||||
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
|
||||
/**
|
||||
* Represents a fragment representing a label.
|
||||
*/
|
||||
public class Label extends TextComponentProducer {
|
||||
public class LabelFormat extends TextComponentProducer {
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*/
|
||||
public Label(String message) {
|
||||
getBuilder().content(message).color(TextColor.YELLOW);
|
||||
private LabelFormat() {
|
||||
getBuilder().content("").color(TextColor.YELLOW);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a LabelFormat with the given message.
|
||||
*
|
||||
* @param texts The text
|
||||
* @return The Component
|
||||
*/
|
||||
public static Component wrap(String ... texts) {
|
||||
LabelFormat label = new LabelFormat();
|
||||
for (String component : texts) {
|
||||
label.append(component);
|
||||
}
|
||||
|
||||
return label.create();
|
||||
}
|
||||
}
|
@ -47,12 +47,12 @@ public class MessageBox extends TextComponentProducer {
|
||||
append(TextComponent.of(createBorder(leftSide), TextColor.YELLOW));
|
||||
}
|
||||
append(Component.space());
|
||||
append(TextComponent.of(title));
|
||||
append(title);
|
||||
append(Component.space());
|
||||
if (rightSide > 0) {
|
||||
append(TextComponent.of(createBorder(rightSide), TextColor.YELLOW));
|
||||
}
|
||||
append(Component.newline());
|
||||
newline();
|
||||
this.contents = contents;
|
||||
}
|
||||
|
||||
|
@ -19,18 +19,33 @@
|
||||
|
||||
package com.sk89q.worldedit.util.formatting.component;
|
||||
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
|
||||
/**
|
||||
* Represents a subtle part of the message.
|
||||
*/
|
||||
public class Subtle extends TextComponentProducer {
|
||||
public class SubtleFormat extends TextComponentProducer {
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*/
|
||||
public Subtle(String message) {
|
||||
getBuilder().color(TextColor.GRAY).content(message);
|
||||
private SubtleFormat() {
|
||||
getBuilder().content("").color(TextColor.GRAY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a SubtleFormat with the given message.
|
||||
*
|
||||
* @param texts The text
|
||||
* @return The Component
|
||||
*/
|
||||
public static Component wrap(String ... texts) {
|
||||
SubtleFormat subtle = new SubtleFormat();
|
||||
for (String component : texts) {
|
||||
subtle.append(component);
|
||||
}
|
||||
|
||||
return subtle.create();
|
||||
}
|
||||
}
|
@ -31,7 +31,7 @@ public class TextComponentProducer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a component as a child to this Producer
|
||||
* Adds a component as a child to this Producer.
|
||||
*
|
||||
* @param component The component
|
||||
* @return The producer, for chaining
|
||||
@ -41,6 +41,27 @@ public class TextComponentProducer {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a string as a child to this Producer.
|
||||
*
|
||||
* @param string The text
|
||||
* @return The producer, for chaining
|
||||
*/
|
||||
public TextComponentProducer append(String string) {
|
||||
getBuilder().append(TextComponent.of(string));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a newline as a child to this Producer.
|
||||
*
|
||||
* @return The producer, for chaining
|
||||
*/
|
||||
public TextComponentProducer newline() {
|
||||
getBuilder().append(Component.newline());
|
||||
return this;
|
||||
}
|
||||
|
||||
public TextComponent create() {
|
||||
return builder.build();
|
||||
}
|
||||
|
Reference in New Issue
Block a user