use of org.cubeengine.module.vigil.report.block.BlockReport.CauseType in project modules-extra by CubeEngine.
the class Recall method cause.
public static Text cause(List<Map<String, Object>> list) {
if (list.size() > 6) {
list = list.subList(0, 6);
}
Text text = Text.of("?");
Iterator<Map<String, Object>> it = list.iterator();
if (!list.isEmpty()) {
Map<String, Object> elem = it.next();
CauseType type = CauseType.valueOf(elem.get(CAUSE_TYPE).toString());
text = cause(elem, text, type);
}
while (it.hasNext()) {
Map<String, Object> elem = it.next();
text = text.toBuilder().append(Text.of("…").toBuilder().onHover(TextActions.showText(Text.of(text, "←", cause(elem, Text.of(), CauseType.valueOf(elem.get(CAUSE_TYPE).toString()))))).build()).build();
}
return text;
}
use of org.cubeengine.module.vigil.report.block.BlockReport.CauseType in project modules-extra by CubeEngine.
the class Recall method cause.
private static Text cause(Map<String, Object> source, Text text, CauseType type) {
Object causeName = source.get(CAUSE_NAME);
switch(type) {
case CAUSE_PLAYER:
text = Text.of(DARK_GREEN, causeName).toBuilder().onHover(TextActions.showText(Text.of(YELLOW, source.get(CAUSE_PLAYER_UUID)))).build();
break;
case CAUSE_BLOCK:
Optional<BlockType> bType = Sponge.getRegistry().getType(BlockType.class, causeName.toString());
if (!bType.isPresent()) {
// TODO translate
text = Text.of(TextColors.GOLD, "unknown Block");
} else {
if (bType.get() == BlockTypes.LAVA || bType.get() == BlockTypes.FLOWING_LAVA || bType.get() == BlockTypes.FIRE) {
text = Text.of(TextColors.RED, bType.get().getTranslation());
} else {
text = Text.of(TextColors.GOLD, bType.get().getTranslation());
}
}
break;
case CAUSE_TNT:
// TODO translatable
text = Text.of(TextColors.RED, "TNT");
if (source.get(CAUSE_PLAYER_UUID) == null) {
text = text.toBuilder().append(Text.of(" (", Text.of(TextColors.GOLD, causeName), ")")).build();
} else {
text = text.toBuilder().append(Text.of(" (", Text.of(DARK_GREEN, causeName).toBuilder().onHover(TextActions.showText(Text.of(YELLOW, source.get(CAUSE_PLAYER_UUID)))).build(), ")")).build();
}
break;
case CAUSE_DAMAGE:
text = Text.of(TextColors.GOLD, causeName);
break;
case CAUSE_ENTITY:
text = Text.of(TextColors.GOLD, Sponge.getRegistry().getType(EntityType.class, causeName.toString()).map(EntityType::getTranslation).map(Translation::get).orElse(causeName.toString()));
// TODO translation
if (source.containsKey(CAUSE_TARGET)) {
Map<String, Object> sourceTarget = ((Map<String, Object>) source.get(CAUSE_TARGET));
CauseType targetType = CauseType.valueOf(sourceTarget.get(CAUSE_TYPE).toString());
text = text.toBuilder().append(Text.of("…").toBuilder().onHover(TextActions.showText(Text.of(text, "◎", cause(sourceTarget, Text.of("?"), targetType)))).build()).build();
}
break;
}
return text;
}
Aggregations