|
3 | 3 | import net.kyori.adventure.text.Component; |
4 | 4 | import net.milkbowl.vault.economy.Economy; |
5 | 5 | import net.thenextlvl.service.api.economy.currency.Currency; |
| 6 | +import org.jetbrains.annotations.Unmodifiable; |
6 | 7 | import org.jspecify.annotations.NullMarked; |
| 8 | +import org.jspecify.annotations.Nullable; |
7 | 9 |
|
8 | 10 | import java.util.Locale; |
| 11 | +import java.util.Map; |
9 | 12 | import java.util.Optional; |
| 13 | +import java.util.OptionalInt; |
10 | 14 | import java.util.function.Consumer; |
11 | 15 |
|
12 | 16 | @NullMarked |
@@ -51,4 +55,71 @@ public int getFractionalDigits() { |
51 | 55 | public boolean editCurrency(Consumer<Builder> consumer) { |
52 | 56 | return false; |
53 | 57 | } |
| 58 | + |
| 59 | + @Override |
| 60 | + public Builder toBuilder() { |
| 61 | + return new NoOpBuilder(economy); |
| 62 | + } |
| 63 | + |
| 64 | + private record NoOpBuilder(Economy economy) implements Builder { |
| 65 | + @Override |
| 66 | + public Builder name(String name) { |
| 67 | + return this; |
| 68 | + } |
| 69 | + |
| 70 | + @Override |
| 71 | + public String name() { |
| 72 | + return economy.getName(); |
| 73 | + } |
| 74 | + |
| 75 | + @Override |
| 76 | + public @Unmodifiable Map<Locale, Component> displayNamesSingular() { |
| 77 | + return Map.of(); |
| 78 | + } |
| 79 | + |
| 80 | + @Override |
| 81 | + public Builder displayNameSingular(Locale locale, @Nullable Component name) { |
| 82 | + return this; |
| 83 | + } |
| 84 | + |
| 85 | + @Override |
| 86 | + public Optional<Component> displayNameSingular(Locale locale) { |
| 87 | + return Optional.empty(); |
| 88 | + } |
| 89 | + |
| 90 | + @Override |
| 91 | + public @Unmodifiable Map<Locale, Component> displayNamesPlural() { |
| 92 | + return Map.of(); |
| 93 | + } |
| 94 | + |
| 95 | + @Override |
| 96 | + public Builder displayNamePlural(Locale locale, @Nullable Component name) { |
| 97 | + return this; |
| 98 | + } |
| 99 | + |
| 100 | + @Override |
| 101 | + public Optional<Component> displayNamePlural(Locale locale) { |
| 102 | + return Optional.empty(); |
| 103 | + } |
| 104 | + |
| 105 | + @Override |
| 106 | + public Builder symbol(@Nullable Component symbol) { |
| 107 | + return this; |
| 108 | + } |
| 109 | + |
| 110 | + @Override |
| 111 | + public Optional<Component> symbol() { |
| 112 | + return Optional.empty(); |
| 113 | + } |
| 114 | + |
| 115 | + @Override |
| 116 | + public Builder fractionalDigits(@Nullable Integer fractionalDigits) throws IllegalArgumentException { |
| 117 | + return this; |
| 118 | + } |
| 119 | + |
| 120 | + @Override |
| 121 | + public OptionalInt fractionalDigits() { |
| 122 | + return OptionalInt.of(economy.fractionalDigits()); |
| 123 | + } |
| 124 | + } |
54 | 125 | } |
0 commit comments