|
33 | 33 | import org.jetbrains.annotations.NotNull; |
34 | 34 |
|
35 | 35 | import java.time.Duration; |
| 36 | +import java.util.Collection; |
36 | 37 | import java.util.List; |
37 | 38 | import java.util.Objects; |
38 | 39 | import java.util.UUID; |
@@ -106,6 +107,42 @@ private void executeQuickCreate(@NotNull CommandContext<Source> ctx) { |
106 | 107 | return; |
107 | 108 | } |
108 | 109 |
|
| 110 | + Collection<String> blacklist = settings.get().subregionTagBlacklist(); |
| 111 | + if (!blacklist.isEmpty()) { |
| 112 | + String parentId = parentRegion.region().getId(); |
| 113 | + api.getTagIdsByRegion(parentId).thenAccept(tags -> { |
| 114 | + for (String tag : tags) { |
| 115 | + if (blacklist.contains(tag)) { |
| 116 | + player.sendMessage(messages.messageFor( |
| 117 | + MessageKeys.SUBREGION_TAG_BLACKLISTED, |
| 118 | + Placeholder.unparsed("region", parentId), |
| 119 | + Placeholder.unparsed("tag", tag))); |
| 120 | + return; |
| 121 | + } |
| 122 | + } |
| 123 | + continueQuickCreate(player, parentRegion, name, price, duration, |
| 124 | + canBypass, regionManager); |
| 125 | + }).exceptionally(ex -> { |
| 126 | + Throwable cause = ex.getCause() != null ? ex.getCause() : ex; |
| 127 | + cause.printStackTrace(); |
| 128 | + player.sendMessage(messages.messageFor(MessageKeys.SUBREGION_CREATE_ERROR, |
| 129 | + Placeholder.unparsed("error", cause.getMessage()))); |
| 130 | + return null; |
| 131 | + }); |
| 132 | + return; |
| 133 | + } |
| 134 | + |
| 135 | + continueQuickCreate(player, parentRegion, name, price, duration, |
| 136 | + canBypass, regionManager); |
| 137 | + } |
| 138 | + |
| 139 | + private void continueQuickCreate(@NotNull Player player, |
| 140 | + @NotNull WorldGuardRegion parentRegion, |
| 141 | + @NotNull String name, |
| 142 | + double price, |
| 143 | + @NotNull Duration duration, |
| 144 | + boolean canBypass, |
| 145 | + @NotNull RegionManager regionManager) { |
109 | 146 | SelectionResult result = validateSelection(player, parentRegion, regionManager, |
110 | 147 | settings.get().subregionMinVolume()); |
111 | 148 | switch (result) { |
|
0 commit comments