use of com.plotsquared.core.configuration.caption.TranslatableCaption in project PlotSquared by IntellectualSites.
the class Debug method onCommand.
@Override
public boolean onCommand(PlotPlayer<?> player, String[] args) {
if (args.length == 0) {
player.sendMessage(TranslatableCaption.of("commandconfig.command_syntax"), Template.of("value", "/plot debug <loadedchunks | player | debug-players | entitytypes | msg>"));
}
if (args.length > 0) {
if ("player".equalsIgnoreCase(args[0])) {
for (Map.Entry<String, Object> meta : player.getMeta().entrySet()) {
player.sendMessage(StaticCaption.of("Key: " + meta.getKey() + " Value: " + meta.getValue().toString() + " , "));
}
return true;
}
}
if (args.length > 0 && "loadedchunks".equalsIgnoreCase(args[0])) {
final long start = System.currentTimeMillis();
player.sendMessage(TranslatableCaption.of("debug.fetching_loaded_chunks"));
TaskManager.runTaskAsync(() -> player.sendMessage(StaticCaption.of("Loaded chunks: " + this.worldUtil.getChunkChunks(player.getLocation().getWorldName()).size() + " (" + (System.currentTimeMillis() - start) + "ms) using thread: " + Thread.currentThread().getName())));
return true;
}
if (args.length > 0 && "uuids".equalsIgnoreCase(args[0])) {
final Collection<UUIDMapping> mappings = PlotSquared.get().getImpromptuUUIDPipeline().getAllImmediately();
player.sendMessage(TranslatableCaption.of("debug.cached_uuids"), Template.of("value", String.valueOf(mappings.size())));
return true;
}
if (args.length > 0 && "debug-players".equalsIgnoreCase(args[0])) {
player.sendMessage(TranslatableCaption.of("debug.player_in_debugmode"));
for (final PlotPlayer<?> pp : PlotPlayer.getDebugModePlayers()) {
player.sendMessage(TranslatableCaption.of("debug.player_in_debugmode_list"), Template.of("value", pp.getName()));
}
return true;
}
if (args.length > 0 && "entitytypes".equalsIgnoreCase(args[0])) {
EntityCategories.init();
player.sendMessage(TranslatableCaption.of("debug.entity_categories"));
EntityCategory.REGISTRY.forEach(category -> {
final StringBuilder builder = new StringBuilder("§7- §6").append(category.getId()).append("§7: §6");
for (final EntityType entityType : category.getAll()) {
builder.append(entityType.getId()).append(" ");
}
player.sendMessage(StaticCaption.of("<prefix>" + builder));
});
EntityType.REGISTRY.values().stream().sorted(Comparator.comparing(EntityType::getId)).forEach(entityType -> {
long categoryCount = EntityCategory.REGISTRY.values().stream().filter(category -> category.contains(entityType)).count();
if (categoryCount > 0) {
return;
}
player.sendMessage(StaticCaption.of("<prefix>" + entityType.getName() + " is in " + categoryCount + " categories"));
});
return true;
}
Set<TranslatableCaption> captions = PlotSquared.get().getCaptionMap(TranslatableCaption.DEFAULT_NAMESPACE).getCaptions();
TextComponent.Builder information = Component.text();
Component header = MINI_MESSAGE.parse(TranslatableCaption.of("debug.debug_header").getComponent(player) + "\n");
String line = TranslatableCaption.of("debug.debug_line").getComponent(player) + "\n";
String section = TranslatableCaption.of("debug.debug_section").getComponent(player) + "\n";
information.append(header);
information.append(MINI_MESSAGE.parse(section, Template.of("val", "PlotArea")));
information.append(MINI_MESSAGE.parse(line, Template.of("var", "Plot Worlds"), Template.of("val", StringMan.join(this.plotAreaManager.getAllPlotAreas(), ", "))));
information.append(MINI_MESSAGE.parse(line, Template.of("var", "Owned Plots"), Template.of("val", String.valueOf(PlotQuery.newQuery().allPlots().count()))));
information.append(MINI_MESSAGE.parse(section, Template.of("val", "Messages")));
information.append(MINI_MESSAGE.parse(line, Template.of("var", "Total Messages"), Template.of("val", String.valueOf(captions.size()))));
player.sendMessage(StaticCaption.of(MINI_MESSAGE.serialize(information.build())));
return true;
}
Aggregations