use of net.kyori.text.Component in project VoxelGamesLibv2 by VoxelGamesLib.
the class HibernatePersistenceProvider method getTop.
@Override
public List<Pair<Component, Double>> getTop(Trackable type, int amount) {
return session(session -> {
Query query = session.createQuery("select user.displayName, stat.val from StatInstance stat, UserData user\n" + "where user.uuid = stat.uuid\n" + "and stat.statType = :type\n" + "order by stat.val desc");
query.setParameter("type", type);
query.setMaxResults(amount);
List<Pair<Component, Double>> result = new ArrayList<>();
// noinspection unchecked
for (Object[] row : (List<Object[]>) query.getResultList()) {
result.add(new Pair<>((Component) row[0], (Double) row[1]));
}
return result;
});
}
use of net.kyori.text.Component in project LuckPerms by lucko.
the class TreeCommand method execute.
@Override
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
String selection = ".";
String player = null;
if (!args.isEmpty()) {
selection = args.get(0);
}
if (args.size() > 1) {
player = args.get(1);
}
User user;
if (player != null) {
UUID u = Uuids.parseNullable(player);
if (u != null) {
user = plugin.getUserManager().getIfLoaded(u);
} else {
user = plugin.getUserManager().getByUsername(player);
}
if (user == null) {
Message.USER_NOT_ONLINE.send(sender, player);
return CommandResult.STATE_ERROR;
}
} else {
user = null;
}
TreeView view = new TreeView(plugin.getPermissionVault(), selection);
if (!view.hasData()) {
Message.TREE_EMPTY.send(sender);
return CommandResult.FAILURE;
}
Message.TREE_UPLOAD_START.send(sender);
PermissionCache permissionData = user == null ? null : user.getCachedData().getPermissionData(plugin.getContextForUser(user).orElse(plugin.getContextManager().getStaticContexts()));
String id = view.uploadPasteData(sender, user, permissionData);
String url = plugin.getConfiguration().get(ConfigKeys.TREE_VIEWER_URL_PATTERN) + "?" + id;
Message.TREE_URL.send(sender);
Component message = TextComponent.builder(url).color(TextColor.AQUA).clickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, String.valueOf(url))).hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to open the tree view.").color(TextColor.GRAY))).build();
sender.sendMessage(message);
return CommandResult.SUCCESS;
}
use of net.kyori.text.Component in project LuckPerms by lucko.
the class VerboseCommand method execute.
@Override
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
if (args.isEmpty()) {
sendUsage(sender, label);
return CommandResult.INVALID_ARGS;
}
String mode = args.get(0).toLowerCase();
if (mode.equals("on") || mode.equals("true") || mode.equals("record")) {
List<String> filters = new ArrayList<>();
if (args.size() != 1) {
filters.addAll(args.subList(1, args.size()));
}
String filter = filters.isEmpty() ? "" : filters.stream().collect(Collectors.joining(" "));
VerboseFilter parsedFilter;
try {
parsedFilter = VerboseFilter.parse(filter);
} catch (InvalidFilterException e) {
e.printStackTrace();
Message.VERBOSE_INVALID_FILTER.send(sender, filter);
return CommandResult.FAILURE;
}
boolean notify = !mode.equals("record");
plugin.getVerboseHandler().registerListener(sender, parsedFilter, notify);
if (notify) {
if (!filter.equals("")) {
Message.VERBOSE_ON_QUERY.send(sender, filter);
} else {
Message.VERBOSE_ON.send(sender);
}
} else {
if (!filter.equals("")) {
Message.VERBOSE_RECORDING_ON_QUERY.send(sender, filter);
} else {
Message.VERBOSE_RECORDING_ON.send(sender);
}
}
return CommandResult.SUCCESS;
}
if (mode.equals("off") || mode.equals("false") || mode.equals("paste") || mode.equals("upload")) {
VerboseListener listener = plugin.getVerboseHandler().unregisterListener(sender.getUuid());
if (mode.equals("paste") || mode.equals("upload")) {
if (listener == null) {
Message.VERBOSE_OFF.send(sender);
} else {
Message.VERBOSE_UPLOAD_START.send(sender);
String id = listener.uploadPasteData();
String url = plugin.getConfiguration().get(ConfigKeys.VERBOSE_VIEWER_URL_PATTERN) + "?" + id;
Message.VERBOSE_RESULTS_URL.send(sender);
Component message = TextComponent.builder(url).color(TextColor.AQUA).clickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, String.valueOf(url))).hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to open the results page.").color(TextColor.GRAY))).build();
sender.sendMessage(message);
return CommandResult.SUCCESS;
}
} else {
Message.VERBOSE_OFF.send(sender);
}
return CommandResult.SUCCESS;
}
sendUsage(sender, label);
return CommandResult.INVALID_ARGS;
}
use of net.kyori.text.Component in project LuckPerms by lucko.
the class DebugCommand method execute.
@Override
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
Message.DEBUG_START.send(sender);
StringBuilder sb = new StringBuilder();
sb.append("LuckPerms Debug Output\n\n\n");
BiConsumer<String, JObject> builder = (name, content) -> {
sb.append("-- ").append(name).append(" --\n");
sb.append(GSON.toJson(content.toJson()));
sb.append("\n\n");
};
builder.accept("platform.json", getPlatformData(plugin));
builder.accept("storage.json", getStorageData(plugin));
builder.accept("context.json", getContextData(plugin));
builder.accept("players.json", getPlayersData(plugin));
Pastebin.Paste paste = StandardPastebin.HASTEBIN.postPlain(sb.toString());
Message.DEBUG_URL.send(sender);
Component message = TextComponent.builder(paste.url()).color(TextColor.AQUA).clickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, String.valueOf(paste.url()))).hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to open the debugging data.").color(TextColor.GRAY))).build();
sender.sendMessage(message);
return CommandResult.SUCCESS;
}
use of net.kyori.text.Component in project LuckPerms by lucko.
the class HolderEditor method execute.
@Override
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, T holder, List<String> args, String label) {
if (ArgumentPermissions.checkViewPerms(plugin, sender, getPermission().get(), holder)) {
Message.COMMAND_NO_PERMISSION.send(sender);
return CommandResult.NO_PERMISSION;
}
Message.EDITOR_START.send(sender);
// form the payload data
JsonObject payload = WebEditor.formPayload(Collections.singletonList(holder), sender, label, plugin);
// upload the payload data to gist
String pasteId = StandardPastebin.BYTEBIN.postJson(payload, true).id();
if (pasteId == null) {
Message.EDITOR_UPLOAD_FAILURE.send(sender);
return CommandResult.STATE_ERROR;
}
// form a url for the editor
String url = plugin.getConfiguration().get(ConfigKeys.WEB_EDITOR_URL_PATTERN) + "?" + pasteId;
Message.EDITOR_URL.send(sender);
Component message = TextComponent.builder(url).color(TextColor.AQUA).clickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, url)).hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to open the editor.").color(TextColor.GRAY))).build();
sender.sendMessage(message);
return CommandResult.SUCCESS;
}
Aggregations