Fix spacing

This commit is contained in:
Draycia committed 2020-09-09 20:20:45 -07:00
1 parent a8788c7d3d
commit a47ff4e7b2
74 files changed
+5000 -4927

No files matched your search

@@ -49,93 +49,93 @@ import java.util.List;
public final class CarbonUtils {
private static final @NonNull String @NonNull [] colors;
private static final @NonNull String @NonNull [] colors;
static {
List<String> colorList = new ArrayList<>();
static {
List<String> colorList = new ArrayList<>();
for (NamedTextColor color : NamedTextColor.values()) {
colorList.add(color.toString());
}
colors = colorList.toArray(new String[0]);
for (NamedTextColor color : NamedTextColor.values()) {
colorList.add(color.toString());
}
@NonNull
public static Component createComponent(@NonNull final Player player) {
if (!FunctionalityConstants.HAS_HOVER_EVENT_METHOD) {
return net.kyori.adventure.text.TextComponent.empty();
}
colors = colorList.toArray(new String[0]);
}
final ItemStack itemStack = player.getInventory().getItemInMainHand();
if (itemStack.getType().isAir()) {
return net.kyori.adventure.text.TextComponent.empty();
}
Content content = Bukkit.getItemFactory().hoverContentOf(itemStack);
HoverEvent event = new HoverEvent(HoverEvent.Action.SHOW_ITEM, content);
ComponentBuilder component = new ComponentBuilder();
component.event(event); // Let this be inherited by all coming components.
component.color(ChatColor.WHITE).append("[");
if (itemStack.getItemMeta().hasDisplayName()) {
component.append(TextComponent.fromLegacyText(itemStack.getItemMeta().getDisplayName()));
} else {
String name = itemStack.getItemMeta().hasDisplayName()
? itemStack.getItemMeta().getDisplayName()
: "item.minecraft." + itemStack.getType().name().toLowerCase(); // As of 1.13, Material is 1:1 with MC's names
component.append(new TranslatableComponent(name));
}
component.color(ChatColor.WHITE).append("]");
return BungeeCordComponentSerializer.get().deserialize(component.create());
@NonNull
public static Component createComponent(@NonNull final Player player) {
if (!FunctionalityConstants.HAS_HOVER_EVENT_METHOD) {
return net.kyori.adventure.text.TextComponent.empty();
}
@Nullable
public static TextColor parseColor(@Nullable String input) {
return parseColor(null, input);
final ItemStack itemStack = player.getInventory().getItemInMainHand();
if (itemStack.getType().isAir()) {
return net.kyori.adventure.text.TextComponent.empty();
}
@Nullable
public static TextColor parseColor(@Nullable ChatUser user, @Nullable String input) {
if (input == null) {
input = "white";
}
Content content = Bukkit.getItemFactory().hoverContentOf(itemStack);
HoverEvent event = new HoverEvent(HoverEvent.Action.SHOW_ITEM, content);
if (user != null && user.isOnline()) {
input = PlaceholderAPI.setPlaceholders(user.asPlayer(), input);
}
ComponentBuilder component = new ComponentBuilder();
component.event(event); // Let this be inherited by all coming components.
component.color(ChatColor.WHITE).append("[");
for (NamedTextColor namedColor : NamedTextColor.values()) {
if (namedColor.toString().equalsIgnoreCase(input)) {
return namedColor;
}
}
if (input.contains("&") || input.contains("§")) {
input = input.replace("&", "§");
return LegacyComponentSerializer.legacySection().deserialize(input).color();
}
return TextColor.fromCSSHexString(input);
if (itemStack.getItemMeta().hasDisplayName()) {
component.append(TextComponent.fromLegacyText(itemStack.getItemMeta().getDisplayName()));
} else {
String name = itemStack.getItemMeta().hasDisplayName()
? itemStack.getItemMeta().getDisplayName()
: "item.minecraft." + itemStack.getType().name().toLowerCase(); // As of 1.13, Material is 1:1 with MC's names
component.append(new TranslatableComponent(name));
}
@NonNull
public static Argument onlineChatUserArgument() {
return new CustomArgument<>((input) -> {
CarbonChat carbonChat = (CarbonChat) Bukkit.getPluginManager().getPlugin("CarbonChat");
component.color(ChatColor.WHITE).append("]");
Player player = Bukkit.getPlayer(input);
return BungeeCordComponentSerializer.get().deserialize(component.create());
}
if (player == null) {
throw new CustomArgument.CustomArgumentException("Invalid player for input (" + input + ")");
}
@Nullable
public static TextColor parseColor(@Nullable String input) {
return parseColor(null, input);
}
return carbonChat.getUserService().wrap(player);
@Nullable
public static TextColor parseColor(@Nullable ChatUser user, @Nullable String input) {
if (input == null) {
input = "white";
}
if (user != null && user.isOnline()) {
input = PlaceholderAPI.setPlaceholders(user.asPlayer(), input);
}
for (NamedTextColor namedColor : NamedTextColor.values()) {
if (namedColor.toString().equalsIgnoreCase(input)) {
return namedColor;
}
}
if (input.contains("&") || input.contains("§")) {
input = input.replace("&", "§");
return LegacyComponentSerializer.legacySection().deserialize(input).color();
}
return TextColor.fromCSSHexString(input);
}
@NonNull
public static Argument onlineChatUserArgument() {
return new CustomArgument<>((input) -> {
CarbonChat carbonChat = (CarbonChat) Bukkit.getPluginManager().getPlugin("CarbonChat");
Player player = Bukkit.getPlayer(input);
if (player == null) {
throw new CustomArgument.CustomArgumentException("Invalid player for input (" + input + ")");
}
return carbonChat.getUserService().wrap(player);
// }).overrideSuggestions((sender, args) -> {
// ArrayList<String> players = new ArrayList<>();
//
@@ -144,15 +144,15 @@ public final class CarbonUtils {
// }
//
// return players.toArray(new String[0]);
});
}
});
}
@NonNull
public static Argument chatUserArgument() {
return new CustomArgument<>((input) -> {
CarbonChat carbonChat = (CarbonChat) Bukkit.getPluginManager().getPlugin("CarbonChat");
@NonNull
public static Argument chatUserArgument() {
return new CustomArgument<>((input) -> {
CarbonChat carbonChat = (CarbonChat) Bukkit.getPluginManager().getPlugin("CarbonChat");
return carbonChat.getUserService().wrap(input);
return carbonChat.getUserService().wrap(input);
// }).overrideSuggestions((sender, args) -> {
// ArrayList<String> players = new ArrayList<>();
//
@@ -161,34 +161,34 @@ public final class CarbonUtils {
// }
//
// return players.toArray(new String[0]);
});
}
});
}
@NonNull
public static Argument textColorArgument() {
return new CustomArgument<>((input) -> {
TextColor color = parseColor(input);
@NonNull
public static Argument textColorArgument() {
return new CustomArgument<>((input) -> {
TextColor color = parseColor(input);
if (color == null) {
throw new CustomArgument.CustomArgumentException("Invalid color for input (" + input + ")");
}
if (color == null) {
throw new CustomArgument.CustomArgumentException("Invalid color for input (" + input + ")");
}
return color;
}).overrideSuggestions(colors);
}
return color;
}).overrideSuggestions(colors);
}
@NonNull
public static Argument channelArgument() {
return new CustomArgument<>((input) -> {
CarbonChat carbonChat = (CarbonChat) Bukkit.getPluginManager().getPlugin("CarbonChat");
@NonNull
public static Argument channelArgument() {
return new CustomArgument<>((input) -> {
CarbonChat carbonChat = (CarbonChat) Bukkit.getPluginManager().getPlugin("CarbonChat");
ChatChannel channel = carbonChat.getChannelManager().getRegistry().get(input);
ChatChannel channel = carbonChat.getChannelManager().getRegistry().get(input);
if (channel == null) {
throw new CustomArgument.CustomArgumentException("Invalid channel for input (" + input + ")");
}
if (channel == null) {
throw new CustomArgument.CustomArgumentException("Invalid channel for input (" + input + ")");
}
return channel;
return channel;
// }).overrideSuggestions((sender, args) -> {
// CarbonChat carbonChat = (CarbonChat) Bukkit.getPluginManager().getPlugin("CarbonChat");
//
@@ -199,12 +199,12 @@ public final class CarbonUtils {
// }
//
// return channels.toArray(new String[0]);
});
}
});
}
@NonNull
public static Argument usableChannelArgument() {
throw new NotImplementedException("Not implemented yet.");
}
@NonNull
public static Argument usableChannelArgument() {
throw new NotImplementedException("Not implemented yet.");
}
}
}