use of net.minecraft.text.LiteralText in project fabric-name-history-lookup by Woolyenough.
the class MojangAPI method get_player_name_history.
public static LiteralText get_player_name_history(String name, String uuid) {
List<String> playerNameHistory = new ArrayList<>(Arrays.asList(get_raw_response("user/profiles/" + uuid + "/names").split("[\\[\\]{}\",:]")));
playerNameHistory.removeAll(Arrays.asList("", null, " ", ":"));
LiteralText output = new LiteralText("");
for (int i = 0; i < playerNameHistory.size(); i++) {
switch(playerNameHistory.get(i)) {
case "name":
{
i++;
// If the person has used their current name in previous name changes, this prevents them from also turning green
if (playerNameHistory.get(i).toLowerCase().equals(name.toLowerCase()) && (i >= playerNameHistory.size() - 3)) {
if (i == 1) {
output.append(new LiteralText("§r§l" + playerNameHistory.get(i)).styled(style -> style.withColor(TextColor.fromRgb(0x6ED878))).append(new LiteralText("§r (Original name)").styled(style -> style.withColor(TextColor.fromRgb(0xBFB8D5)))));
} else
output.append(new LiteralText("\n§r§l" + playerNameHistory.get(i)).styled(style -> style.withColor(TextColor.fromRgb(0x6ED878))));
} else {
if (i == 1) {
// First name in list
output.append(new LiteralText("§r" + playerNameHistory.get(i)).styled(style -> style.withColor(TextColor.fromRgb(0x67AAEC))).append(new LiteralText("§r (Original name)").styled(style -> style.withColor(TextColor.fromRgb(0xBFB8D5)))));
} else {
output.append(new LiteralText("\n§r" + playerNameHistory.get(i)).styled(style -> style.withColor(TextColor.fromRgb(0x67AAEC))));
}
}
break;
}
case "changedToAt":
{
i++;
DateFormat simple = new SimpleDateFormat("dd.MM.yyyy • HH:mm");
Date result = new Date(Long.parseLong(playerNameHistory.get(i)));
output.append(new LiteralText(" §r§o" + simple.format(result)).styled(style -> style.withColor(TextColor.fromRgb(0x4A143F))));
break;
}
}
}
return output;
}
use of net.minecraft.text.LiteralText in project UniversalGraves by Patbox.
the class Commands method listOthers.
private static int listOthers(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
ServerPlayerEntity player = context.getSource().getPlayer();
List<GameProfile> profiles = new ArrayList(context.getArgument("player", GameProfileArgumentType.GameProfileArgument.class).getNames(context.getSource()));
if (profiles.size() == 0) {
context.getSource().sendFeedback(new LiteralText("This player doesn't exist!"), false);
return 0;
} else if (profiles.size() > 1) {
context.getSource().sendFeedback(new LiteralText("Only one player can be selected!"), false);
return 0;
}
try {
new GraveListGui(player, profiles.get(0)).open();
} catch (Exception e) {
e.printStackTrace();
}
return 0;
}
use of net.minecraft.text.LiteralText in project UniversalGraves by Patbox.
the class GraveInfo method getPlaceholders.
public Map<String, Text> getPlaceholders() {
Config config = ConfigManager.getConfig();
long currentTime = System.currentTimeMillis() / 1000;
long protectionTime = config.configData.protectionTime > -1 ? config.configData.protectionTime - currentTime + this.creationTime : Long.MAX_VALUE;
long breakTime = config.configData.breakingTime > -1 ? config.configData.breakingTime - currentTime + this.creationTime : Long.MAX_VALUE;
Map<String, Text> values = new HashMap<>();
values.put("player", new LiteralText(this.gameProfile != null ? this.gameProfile.getName() : "<No player!>"));
values.put("protection_time", new LiteralText("" + (config.configData.protectionTime > -1 ? config.getFormattedTime(protectionTime) : "∞")));
values.put("break_time", new LiteralText("" + (config.configData.breakingTime > -1 ? config.getFormattedTime(breakTime) : "∞")));
values.put("xp", new LiteralText("" + this.xp));
values.put("item_count", new LiteralText("" + this.itemCount));
values.put("position", new LiteralText("" + this.position.toShortString()));
values.put("world", new LiteralText(GraveUtils.toWorldName(this.world)));
values.put("death_cause", this.deathCause);
return values;
}
use of net.minecraft.text.LiteralText in project meteor-rejects by AntiCope.
the class CoordLogger method formatMessage.
public BaseText formatMessage(String message, Vec3d coords) {
BaseText text = new LiteralText(message);
text.append(ChatUtils.formatCoords(coords));
text.append(Formatting.GRAY.toString() + ".");
return text;
}
use of net.minecraft.text.LiteralText in project meteor-rejects by AntiCope.
the class HeadScreen method createHeadStack.
private ItemStack createHeadStack(String uuid, String value, String name) {
ItemStack head = Items.PLAYER_HEAD.getDefaultStack();
NbtCompound tag = new NbtCompound();
NbtCompound skullOwner = new NbtCompound();
skullOwner.putUuid("Id", UUID.fromString(uuid));
NbtCompound properties = new NbtCompound();
NbtList textures = new NbtList();
NbtCompound Value = new NbtCompound();
Value.putString("Value", value);
textures.add(Value);
properties.put("textures", textures);
skullOwner.put("Properties", properties);
tag.put("SkullOwner", skullOwner);
head.setNbt(tag);
head.setCustomName(new LiteralText(name));
return head;
}
Aggregations