Merge branch '2.1' into feat/miniplaceholders

This commit is contained in:
Adrian committed 2023-04-13 20:50:13 -05:00
commit 0ad5b1d66c
7 files changed
+66 -7

No files matched your search

+19 -2
View File
@@ -2,7 +2,7 @@ name: Build
on:
push:
branches: [ "**" ]
tags-ignore: [ "**" ]
tags: [ "v**" ]
pull_request:
release:
types: [ released ]
@@ -10,7 +10,7 @@ on:
jobs:
build:
# Only run on PRs if the source branch is on someone else's repo
if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}
if: ${{ (github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name) && (github.event.name != 'push' || !startsWith(github.event.push.base_ref, 'refs/tags/') || contains(github.event.push.base_ref, '+beta.')) }}
runs-on: ubuntu-latest
strategy:
matrix:
@@ -54,6 +54,23 @@ jobs:
env:
ORG_GRADLE_PROJECT_parksUsername: "${{ secrets.CI_USER }}"
ORG_GRADLE_PROJECT_parksPassword: "${{ secrets.CI_PASS }}"
- name: Parse tag
if: "${{ github.event_name == 'push' && contains(github.event.push.base_ref, '+beta.') }}"
id: vars
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
- name: Create release and changelog
if: "${{ github.event_name == 'push' && contains(github.event.push.base_ref, '+beta.') }}"
uses: MC-Machinations/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: CarbonChat ${{ steps.vars.outputs.tag }}
pre-release: true
- name: "Publish Release to Hangar"
if: "${{ env.STATUS == 'release' && (github.event_name == 'release' || (github.event_name == 'push' && contains(github.event.push.base_ref, '+beta.'))) }}"
run: ./gradlew publishAllPublicationsToHangar
env:
HANGAR_UPLOAD_KEY: "${{ secrets.HANGAR_UPLOAD_KEY }}"
RELEASE_NOTES: "${{ github.event.release.body }}"
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
@@ -2,8 +2,12 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import net.kyori.indra.git.IndraGitExtension
import org.gradle.accessors.dm.LibrariesForLibs
import org.gradle.api.Project
import org.gradle.api.provider.Provider
import org.gradle.kotlin.dsl.the
val Project.releaseNotes: Provider<String>
get() = providers.environmentVariable("RELEASE_NOTES")
/**
* Relocate a package into the `net.draycia.carbon.libs` namespace.
*/
+28
View File
@@ -1,8 +1,36 @@
import io.papermc.hangarpublishplugin.model.Platforms
plugins {
id("carbon.build-logic")
id("io.papermc.hangar-publish-plugin")
}
group = "net.draycia"
description = "CarbonChat - A modern chat plugin"
val projectVersion: String by project // get from gradle.properties
version = projectVersion
hangarPublish.publications.register("plugin") {
version.set(projectVersion)
owner.set("Vicarious")
slug.set("Carbon")
channel.set(if (projectVersion.contains("+beta.")) "Beta" else "Release")
changelog.set(releaseNotes)
apiKey.set(providers.environmentVariable("HANGAR_UPLOAD_KEY"))
platforms.register(Platforms.PAPER) {
jar.set(project(":carbonchat-paper").the<CarbonPlatformExtension>().jarTask.flatMap { it.archiveFile })
platformVersions.add("1.19.4")
dependencies {
url("LuckPerms", "https://luckperms.net/")
url("EssentialsDiscord", "https://essentialsx.net/") {
required.set(false)
}
url("DiscordSRV", "https://www.spigotmc.org/resources/discordsrv.18494/") {
required.set(false)
}
url("PlaceholderAPI", "https://www.spigotmc.org/resources/placeholderapi.6245/") {
required.set(false)
}
}
}
}
@@ -79,7 +79,8 @@ public class PingHandler {
}
return message.replaceText(TextReplacementConfig.builder()
.match(Pattern.compile(String.format("\\B(@%s|@%s)\\b", recipient.username(), displayName), Pattern.CASE_INSENSITIVE))
// \B(@Username|@Displayname)\b
.match(Pattern.compile(String.format("\\B(%1$2s%2$2s|%1$2s%3$2s)\\b", prefix, recipient.username(), displayName), Pattern.CASE_INSENSITIVE))
.replacement(matchedText -> {
if (this.configFactory.primaryConfig().pings().playSound()) {
recipient.playSound(this.configFactory.primaryConfig().pings().sound());
+1
View File
@@ -7,6 +7,7 @@ plugins:
net.kyori.blossom: 1.3.0
org.spongepowered.gradle.plugin: 2.1.1
xyz.jpenilla.run-paper: 2.0.1
io.papermc.hangar-publish-plugin: 0.0.5
versions:
indra: 3.0.1
@@ -40,7 +40,7 @@ import net.draycia.carbon.paper.users.CarbonPlayerPaper;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextReplacementConfig;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
@@ -79,7 +79,7 @@ public class DSRVChatHook implements ChatHook {
renderedMessage = renderer.render(carbonPlayer, carbonPlayer, renderedMessage, renderedMessage);
}
final var messageContents = PlainTextComponentSerializer.plainText().serialize(renderedMessage);
final var messageContents = LegacyComponentSerializer.legacySection().serialize(renderedMessage);
Component eventMessage = ConfigChatChannel.parseMessageTags(carbonPlayer, messageContents);
if (carbonPlayer.hasPermission("carbon.chatlinks")) {
@@ -92,7 +92,7 @@ public class DSRVChatHook implements ChatHook {
DiscordSRV.debug(Debug.MINECRAFT_TO_DISCORD, "Received a CarbonChatEvent (player: " + carbonPlayer.username() + ")");
final @Nullable Player player = ((CarbonPlayerPaper) carbonPlayer).bukkitPlayer();
final String message = PlainTextComponentSerializer.plainText().serialize(eventMessage);
final String message = LegacyComponentSerializer.legacySection().serialize(eventMessage);
if (player != null) {
DiscordSRV.getPlugin().processChatMessage(player, message, chatChannel.commandName(), event.result().cancelled());
@@ -30,6 +30,7 @@ import net.draycia.carbon.api.events.CarbonChatEvent;
import net.draycia.carbon.api.users.CarbonPlayer;
import net.draycia.carbon.api.util.KeyedRenderer;
import net.draycia.carbon.common.channels.ConfigChatChannel;
import net.draycia.carbon.common.messages.CarbonMessages;
import net.draycia.carbon.common.messaging.packets.ChatMessagePacket;
import net.draycia.carbon.paper.CarbonChatPaper;
import net.kyori.adventure.audience.Audience;
@@ -57,13 +58,15 @@ public final class PaperChatListener implements Listener {
private final CarbonChatPaper carbonChat;
private final ChannelRegistry registry;
private final CarbonMessages carbonMessages;
private static final Pattern DEFAULT_URL_PATTERN = Pattern.compile("(?:(https?)://)?([-\\w_.]+\\.\\w{2,})(/\\S*)?");
@Inject
public PaperChatListener(final CarbonChat carbonChat, final ChannelRegistry registry) {
public PaperChatListener(final CarbonChat carbonChat, final ChannelRegistry registry, final CarbonMessages carbonMessages) {
this.carbonChat = (CarbonChatPaper) carbonChat;
this.registry = registry;
this.carbonMessages = carbonMessages;
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
@@ -101,6 +104,11 @@ public final class PaperChatListener implements Listener {
}
}
if (sender.leftChannels().contains(channel.key())) {
sender.joinChannel(channel);
this.carbonMessages.channelJoined(sender);
}
final var renderers = new ArrayList<KeyedRenderer>();
renderers.add(keyedRenderer(key("carbon", "default"), channel));