Search in sources :

Example 1 with I18n

use of org.cubeengine.libcube.service.i18n.I18n in project core by CubeEngine.

the class ConfirmManager method requestConfirmation.

public static void requestConfirmation(I18n i18n, Text msg, CommandSource source, Runnable run) {
    Text confirm = i18n.translate(source, NONE, "Confirm");
    Text cancel = i18n.translate(source, NONE, "Cancel");
    UUID uuid = UUID.randomUUID();
    confirm = confirm.toBuilder().color(TextColors.GOLD).onClick(TextActions.executeCallback(s -> confirm(i18n, source, uuid, run))).build();
    cancel = cancel.toBuilder().color(TextColors.GOLD).onClick(TextActions.executeCallback(s -> cancel(i18n, source, uuid))).build();
    times.put(uuid, System.currentTimeMillis());
    source.sendMessage(msg.toBuilder().append(Text.of(" ")).append(confirm).append(Text.of(" ")).append(cancel).build());
}
Also used : TextActions(org.spongepowered.api.text.action.TextActions) NONE(org.cubeengine.libcube.service.i18n.formatter.MessageType.NONE) Text(org.spongepowered.api.text.Text) I18n(org.cubeengine.libcube.service.i18n.I18n) CommandSource(org.spongepowered.api.command.CommandSource) Map(java.util.Map) HashMap(java.util.HashMap) UUID(java.util.UUID) NEGATIVE(org.cubeengine.libcube.service.i18n.formatter.MessageType.NEGATIVE) POSITIVE(org.cubeengine.libcube.service.i18n.formatter.MessageType.POSITIVE) TextColors(org.spongepowered.api.text.format.TextColors) Text(org.spongepowered.api.text.Text) UUID(java.util.UUID)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 UUID (java.util.UUID)1 I18n (org.cubeengine.libcube.service.i18n.I18n)1 NEGATIVE (org.cubeengine.libcube.service.i18n.formatter.MessageType.NEGATIVE)1 NONE (org.cubeengine.libcube.service.i18n.formatter.MessageType.NONE)1 POSITIVE (org.cubeengine.libcube.service.i18n.formatter.MessageType.POSITIVE)1 CommandSource (org.spongepowered.api.command.CommandSource)1 Text (org.spongepowered.api.text.Text)1 TextActions (org.spongepowered.api.text.action.TextActions)1 TextColors (org.spongepowered.api.text.format.TextColors)1