Skip to content

Commit 411ee3a

Browse files
committed
📝 Fix
1 parent 379f729 commit 411ee3a

4 files changed

Lines changed: 28 additions & 4 deletions

File tree

API/src/main/java/fr/maxlego08/essentials/api/worldedit/WorldEditTask.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,18 @@ public void calculatePrice(Consumer<BigDecimal> consumer) {
7272
this.loadBlocks();
7373

7474
// Process the blocks in batches and calculate the total price
75-
processNextBatch(blocks.stream().filter(b -> worldeditManager.hasPermission(user.getPlayer(), b)).map(b -> new BlockInfo(b, null, BigDecimal.ZERO)).collect(Collectors.toList()), 0, this.worldeditManager.getBatchSize(), () -> {
75+
processNextBatch(blocks.stream().map(b -> new BlockInfo(b, null, BigDecimal.ZERO)).collect(Collectors.toList()), 0, this.worldeditManager.getBatchSize(), () -> {
7676

7777
this.totalPrice = this.blockInfos.stream().map(BlockInfo::price).reduce(BigDecimal.ZERO, BigDecimal::add);
7878
this.materials = this.blockInfos.stream().collect(Collectors.groupingBy(BlockInfo::newMaterial, Collectors.counting()));
7979
this.worldeditStatus = WorldeditStatus.WAITING_RESPONSE_PRICE;
8080

8181
consumer.accept(totalPrice);
82-
}, blocks -> blocks.forEach(block -> this.processBlock(block.block())));
82+
}, batchBlocks -> batchBlocks.forEach(block -> {
83+
if (worldeditManager.hasPermission(user.getPlayer(), block.block())) {
84+
this.processBlock(block.block());
85+
}
86+
}));
8387
});
8488
}
8589

src/main/java/fr/maxlego08/essentials/ZEssentialsPlugin.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -862,5 +862,8 @@ private void loadHooks() {
862862
this.getLogger().info("Register MythicMobsHook.");
863863
});
864864
}
865+
866+
this.permissionCheckers.add(new fr.maxlego08.essentials.hooks.BukkitEventPermissionChecker());
867+
this.getLogger().info("Register Bukkit Event Permission Checker.");
865868
}
866869
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package fr.maxlego08.essentials.hooks;
2+
3+
import fr.maxlego08.essentials.api.permission.PermissionChecker;
4+
import org.bukkit.Bukkit;
5+
import org.bukkit.block.Block;
6+
import org.bukkit.entity.Player;
7+
import org.bukkit.event.block.BlockBreakEvent;
8+
9+
public class BukkitEventPermissionChecker implements PermissionChecker {
10+
11+
@Override
12+
public boolean hasPermission(Player player, Block block) {
13+
BlockBreakEvent event = new BlockBreakEvent(block, player);
14+
Bukkit.getPluginManager().callEvent(event);
15+
return !event.isCancelled();
16+
}
17+
}

src/main/java/fr/maxlego08/essentials/module/modules/chat/ChatModule.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public class ChatModule extends ZModule {
5151
private final List<ShowItem> showItems = new ArrayList<>();
5252
private final List<ChatDisplay> chatDisplays = new ArrayList<>();
5353
private final ExpiringCache<UUID, List<ChatMessageDTO>> chatMessagesCache = new ExpiringCache<>(1000 * 60);
54-
private final Pattern urlPattern = Pattern.compile("(https?://[\\w-\\.]+(\\:[0-9]+)?(/[\\w- ./?%&=]*)?)", Pattern.CASE_INSENSITIVE);
54+
private final Pattern urlPattern = Pattern.compile("(https?://[\\w-\\.]+(\\:[0-9]+)?(/[\\w-./?%&=~+#]*)?)", Pattern.CASE_INSENSITIVE);
5555
private final List<ChatCooldown> chatCooldowns = new ArrayList<>();
5656
private final List<ChatFormat> chatFormats = new ArrayList<>();
5757
private final List<ChatPlaceholder> chatPlaceholders = new ArrayList<>();
@@ -299,7 +299,7 @@ private String transformUrlsToMiniMessage(String input) {
299299
StringBuilder result = new StringBuilder();
300300
while (matcher.find()) {
301301
String url = matcher.group(1);
302-
matcher.appendReplacement(result, getMessage(this.linkTransform, "%url%", url));
302+
matcher.appendReplacement(result, Matcher.quoteReplacement(getMessage(this.linkTransform, "%url%", url)));
303303
}
304304
matcher.appendTail(result);
305305

0 commit comments

Comments
 (0)