mirror of
https://github.com/DiscordSRV/Ascension.git
synced 2024-12-25 17:08:27 +01:00
Advancement/achievement fixes, event changes, updated gradle
This commit is contained in:
parent
045e863dde
commit
6b9606ddd7
@ -40,10 +40,10 @@ jar {
|
||||
from sourceSets.ap.output
|
||||
}
|
||||
|
||||
license {
|
||||
// Overwrite the default
|
||||
header = rootProject.file('buildscript/license/API_LICENSE_HEADER')
|
||||
}
|
||||
//license {
|
||||
// // Overwrite the default
|
||||
// header = rootProject.file('buildscript/license/API_LICENSE_HEADER')
|
||||
//}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
|
@ -26,6 +26,7 @@ package com.discordsrv.api.discord.entity.message;
|
||||
import com.discordsrv.api.component.GameTextBuilder;
|
||||
import com.discordsrv.api.discord.entity.interaction.component.actionrow.MessageActionRow;
|
||||
import com.discordsrv.api.discord.entity.message.impl.SendableDiscordMessageImpl;
|
||||
import com.discordsrv.api.placeholder.provider.SinglePlaceholder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
@ -270,6 +271,14 @@ public interface SendableDiscordMessage {
|
||||
@NotNull
|
||||
Formatter addContext(Object... context);
|
||||
|
||||
default Formatter addPlaceholder(String placeholder, Object replacement) {
|
||||
return addContext(new SinglePlaceholder(placeholder, replacement));
|
||||
}
|
||||
|
||||
default Formatter addPlaceholder(String placeholder, Supplier<Object> replacementSupplier) {
|
||||
return addContext(new SinglePlaceholder(placeholder, replacementSupplier));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
default Formatter addReplacement(String target, Object replacement) {
|
||||
return addReplacement(Pattern.compile(target, Pattern.LITERAL), replacement);
|
||||
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* This file is part of the DiscordSRV API, licensed under the MIT License
|
||||
* Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.discordsrv.api.event.events.message.forward.game;
|
||||
|
||||
import com.discordsrv.api.discord.entity.message.ReceivedDiscordMessageCluster;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AwardMessageForwardedEvent extends AbstractGameMessageForwardedEvent {
|
||||
|
||||
public AwardMessageForwardedEvent(@NotNull ReceivedDiscordMessageCluster discordMessage) {
|
||||
super(discordMessage);
|
||||
}
|
||||
}
|
@ -23,28 +23,24 @@
|
||||
|
||||
package com.discordsrv.api.event.events.message.receive.game;
|
||||
|
||||
import com.discordsrv.api.component.MinecraftComponent;
|
||||
import com.discordsrv.api.event.events.Cancellable;
|
||||
import com.discordsrv.api.event.events.Processable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public abstract class AbstractGameMessageReceiveEvent implements Processable, Cancellable {
|
||||
|
||||
private final MinecraftComponent message;
|
||||
private final Object triggeringEvent;
|
||||
private boolean cancelled;
|
||||
private boolean processed;
|
||||
|
||||
public AbstractGameMessageReceiveEvent(
|
||||
@NotNull MinecraftComponent message,
|
||||
boolean cancelled
|
||||
) {
|
||||
this.message = message;
|
||||
public AbstractGameMessageReceiveEvent(@Nullable Object triggeringEvent, boolean cancelled) {
|
||||
this.triggeringEvent = triggeringEvent;
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public MinecraftComponent getMessage() {
|
||||
return message;
|
||||
@Nullable
|
||||
public Object getTriggeringEvent() {
|
||||
return triggeringEvent;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* This file is part of the DiscordSRV API, licensed under the MIT License
|
||||
* Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.discordsrv.api.event.events.message.receive.game;
|
||||
|
||||
import com.discordsrv.api.channel.GameChannel;
|
||||
import com.discordsrv.api.component.MinecraftComponent;
|
||||
import com.discordsrv.api.player.DiscordSRVPlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class AwardMessageReceiveEvent extends AbstractGameMessageReceiveEvent {
|
||||
|
||||
private final DiscordSRVPlayer player;
|
||||
private MinecraftComponent name;
|
||||
private MinecraftComponent title;
|
||||
private GameChannel gameChannel;
|
||||
|
||||
public AwardMessageReceiveEvent(
|
||||
@Nullable Object triggeringEvent,
|
||||
@NotNull DiscordSRVPlayer player,
|
||||
@Nullable MinecraftComponent name,
|
||||
@Nullable MinecraftComponent title,
|
||||
@Nullable GameChannel gameChannel,
|
||||
boolean cancelled
|
||||
) {
|
||||
super(triggeringEvent, cancelled);
|
||||
this.player = player;
|
||||
this.name = name;
|
||||
this.title = title;
|
||||
this.gameChannel = gameChannel;
|
||||
}
|
||||
|
||||
public DiscordSRVPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public MinecraftComponent getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(@Nullable MinecraftComponent name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public MinecraftComponent getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(@Nullable MinecraftComponent title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public GameChannel getGameChannel() {
|
||||
return gameChannel;
|
||||
}
|
||||
|
||||
public void setGameChannel(GameChannel gameChannel) {
|
||||
this.gameChannel = gameChannel;
|
||||
}
|
||||
}
|
@ -32,15 +32,18 @@ import org.jetbrains.annotations.Nullable;
|
||||
public class DeathMessageReceiveEvent extends AbstractGameMessageReceiveEvent {
|
||||
|
||||
private final DiscordSRVPlayer player;
|
||||
private MinecraftComponent message;
|
||||
private GameChannel gameChannel;
|
||||
|
||||
public DeathMessageReceiveEvent(
|
||||
@NotNull Object triggeringEvent,
|
||||
@NotNull DiscordSRVPlayer player,
|
||||
@Nullable MinecraftComponent message,
|
||||
@Nullable GameChannel gameChannel,
|
||||
@NotNull MinecraftComponent message,
|
||||
boolean cancelled) {
|
||||
super(message, cancelled);
|
||||
super(triggeringEvent, cancelled);
|
||||
this.player = player;
|
||||
this.message = message;
|
||||
this.gameChannel = gameChannel;
|
||||
}
|
||||
|
||||
@ -49,6 +52,15 @@ public class DeathMessageReceiveEvent extends AbstractGameMessageReceiveEvent {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public MinecraftComponent getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(@Nullable MinecraftComponent message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GameChannel getGameChannel() {
|
||||
return gameChannel;
|
||||
|
@ -28,27 +28,41 @@ import com.discordsrv.api.component.MinecraftComponent;
|
||||
import com.discordsrv.api.event.events.PlayerEvent;
|
||||
import com.discordsrv.api.player.DiscordSRVPlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class GameChatMessageReceiveEvent extends AbstractGameMessageReceiveEvent implements PlayerEvent {
|
||||
|
||||
private final DiscordSRVPlayer player;
|
||||
private MinecraftComponent message;
|
||||
private GameChannel gameChannel;
|
||||
|
||||
public GameChatMessageReceiveEvent(
|
||||
@Nullable Object triggeringEvent,
|
||||
@NotNull DiscordSRVPlayer player,
|
||||
@NotNull GameChannel gameChannel,
|
||||
@NotNull MinecraftComponent message,
|
||||
@NotNull GameChannel gameChannel,
|
||||
boolean cancelled) {
|
||||
super(message, cancelled);
|
||||
super(triggeringEvent, cancelled);
|
||||
this.player = player;
|
||||
this.message = message;
|
||||
this.gameChannel = gameChannel;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public MinecraftComponent getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(@NotNull MinecraftComponent message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public GameChannel getGameChannel() {
|
||||
return gameChannel;
|
||||
}
|
||||
|
||||
public void setGameChannel(GameChannel gameChannel) {
|
||||
public void setGameChannel(@NotNull GameChannel gameChannel) {
|
||||
this.gameChannel = gameChannel;
|
||||
}
|
||||
|
||||
|
@ -32,17 +32,20 @@ import org.jetbrains.annotations.Nullable;
|
||||
public class JoinMessageReceiveEvent extends AbstractGameMessageReceiveEvent {
|
||||
|
||||
private final DiscordSRVPlayer player;
|
||||
private MinecraftComponent message;
|
||||
private GameChannel gameChannel;
|
||||
private final boolean firstJoin;
|
||||
|
||||
public JoinMessageReceiveEvent(
|
||||
@Nullable Object triggeringEvent,
|
||||
@NotNull DiscordSRVPlayer player,
|
||||
@Nullable MinecraftComponent message,
|
||||
@Nullable GameChannel gameChannel,
|
||||
@NotNull MinecraftComponent message,
|
||||
boolean firstJoin,
|
||||
boolean cancelled) {
|
||||
super(message, cancelled);
|
||||
super(triggeringEvent, cancelled);
|
||||
this.player = player;
|
||||
this.message = message;
|
||||
this.gameChannel = gameChannel;
|
||||
this.firstJoin = firstJoin;
|
||||
}
|
||||
@ -52,6 +55,15 @@ public class JoinMessageReceiveEvent extends AbstractGameMessageReceiveEvent {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public MinecraftComponent getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(@Nullable MinecraftComponent message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GameChannel getGameChannel() {
|
||||
return gameChannel;
|
||||
|
@ -32,15 +32,18 @@ import org.jetbrains.annotations.Nullable;
|
||||
public class LeaveMessageReceiveEvent extends AbstractGameMessageReceiveEvent {
|
||||
|
||||
private final DiscordSRVPlayer player;
|
||||
private MinecraftComponent message;
|
||||
private GameChannel gameChannel;
|
||||
|
||||
public LeaveMessageReceiveEvent(
|
||||
@Nullable Object triggeringEvent,
|
||||
@NotNull DiscordSRVPlayer player,
|
||||
@Nullable GameChannel gameChannel,
|
||||
@NotNull MinecraftComponent message,
|
||||
@Nullable GameChannel gameChannel,
|
||||
boolean cancelled) {
|
||||
super(message, cancelled);
|
||||
super(triggeringEvent, cancelled);
|
||||
this.player = player;
|
||||
this.message = message;
|
||||
this.gameChannel = gameChannel;
|
||||
}
|
||||
|
||||
@ -49,6 +52,15 @@ public class LeaveMessageReceiveEvent extends AbstractGameMessageReceiveEvent {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public MinecraftComponent getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(@Nullable MinecraftComponent message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GameChannel getGameChannel() {
|
||||
return gameChannel;
|
||||
|
@ -26,17 +26,35 @@ package com.discordsrv.api.event.events.message.receive.game;
|
||||
import com.discordsrv.api.component.MinecraftComponent;
|
||||
import com.discordsrv.api.player.DiscordSRVPlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class ServerSwitchMessageReceiveEvent extends AbstractGameMessageReceiveEvent {
|
||||
|
||||
private final DiscordSRVPlayer player;
|
||||
private MinecraftComponent message;
|
||||
|
||||
public ServerSwitchMessageReceiveEvent(DiscordSRVPlayer player, @NotNull MinecraftComponent message, boolean cancelled) {
|
||||
super(message, cancelled);
|
||||
public ServerSwitchMessageReceiveEvent(
|
||||
@Nullable Object triggeringEvent,
|
||||
@NotNull DiscordSRVPlayer player,
|
||||
@Nullable MinecraftComponent message,
|
||||
boolean cancelled
|
||||
) {
|
||||
super(triggeringEvent, cancelled);
|
||||
this.player = player;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public DiscordSRVPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public MinecraftComponent getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(@Nullable MinecraftComponent message) {
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.discordsrv.common.placeholder.provider;
|
||||
package com.discordsrv.api.placeholder.provider;
|
||||
|
||||
import com.discordsrv.api.placeholder.PlaceholderLookupResult;
|
||||
import com.discordsrv.api.placeholder.annotation.Placeholder;
|
@ -0,0 +1,37 @@
|
||||
package com.discordsrv.api.placeholder.provider;
|
||||
|
||||
import com.discordsrv.api.placeholder.PlaceholderLookupResult;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class SinglePlaceholder implements PlaceholderProvider {
|
||||
|
||||
private final String matchPlaceholder;
|
||||
private final Supplier<Object> resultProvider;
|
||||
|
||||
public SinglePlaceholder(String placeholder, Object result) {
|
||||
this(placeholder, () -> result);
|
||||
}
|
||||
|
||||
public SinglePlaceholder(String placeholder, Supplier<Object> resultProvider) {
|
||||
this.matchPlaceholder = placeholder;
|
||||
this.resultProvider = resultProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull PlaceholderLookupResult lookup(@NotNull String placeholder, @NotNull Set<Object> context) {
|
||||
if (!placeholder.equals(matchPlaceholder)) {
|
||||
return PlaceholderLookupResult.UNKNOWN_PLACEHOLDER;
|
||||
}
|
||||
|
||||
try {
|
||||
return PlaceholderLookupResult.success(
|
||||
resultProvider.get()
|
||||
);
|
||||
} catch (Throwable ignored) {
|
||||
return PlaceholderLookupResult.LOOKUP_FAILED;
|
||||
}
|
||||
}
|
||||
}
|
25
build.gradle
25
build.gradle
@ -13,7 +13,7 @@ subprojects {
|
||||
apply plugin: 'java-library'
|
||||
apply plugin: 'idea'
|
||||
apply plugin: 'com.github.johnrengelman.shadow'
|
||||
apply plugin: 'org.cadixdev.licenser'
|
||||
//apply plugin: 'org.cadixdev.licenser'
|
||||
apply plugin: 'net.kyori.indra.git'
|
||||
apply plugin: 'dev.vankka.dependencydownload.plugin'
|
||||
|
||||
@ -37,6 +37,7 @@ subprojects {
|
||||
|
||||
generateRuntimeDownloadResourceForRuntimeDownloadOnly {
|
||||
file = 'dependencies/runtimeDownload-' + project.name + '.txt'
|
||||
includeShadowJarRelocations = false
|
||||
}
|
||||
|
||||
repositories {
|
||||
@ -73,7 +74,6 @@ subprojects {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
dependencies {
|
||||
// Test dependencies
|
||||
testImplementation(libs.jupiter.api)
|
||||
@ -97,7 +97,7 @@ subprojects {
|
||||
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
||||
|
||||
// If CI then check that licenses are correct, otherwise automatically apply licenses on build
|
||||
dependsOn (System.getenv('CI') === 'true' ? licenseCheck : licenseFormat)
|
||||
// dependsOn (System.getenv('CI') === 'true' ? licenseCheck : licenseFormat)
|
||||
// Always run shadowJar
|
||||
finalizedBy shadowJar
|
||||
|
||||
@ -145,14 +145,15 @@ subprojects {
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
}
|
||||
|
||||
license {
|
||||
header = rootProject.file('buildscript/license/LICENSE_HEADER')
|
||||
properties {
|
||||
var inception = '2016'
|
||||
var currentYear = String.valueOf(Calendar.getInstance().get(Calendar.YEAR))
|
||||
|
||||
year = inception == currentYear ? currentYear : inception + '-' + currentYear
|
||||
}
|
||||
include '**/*.java' // only java files
|
||||
}
|
||||
// license {
|
||||
// header = rootProject.file('buildscript/license/LICENSE_HEADER')
|
||||
// properties {
|
||||
// var inception = '2016'
|
||||
// var currentYear = String.valueOf(Calendar.getInstance().get(Calendar.YEAR))
|
||||
//
|
||||
// year = inception == currentYear ? currentYear : inception + '-' + currentYear
|
||||
// }
|
||||
// include '**/*.java' // only java files
|
||||
// }
|
||||
}
|
||||
|
@ -1,74 +1,75 @@
|
||||
// Relocations
|
||||
|
||||
[
|
||||
// JDA, WS
|
||||
'net.dv8tion.jda',
|
||||
'com.iwebpp',
|
||||
'com.neovisionaries.ws',
|
||||
|
||||
// Trove
|
||||
'gnu.trove',
|
||||
|
||||
// Jackson
|
||||
'com.fasterxml.jackson',
|
||||
|
||||
// okhttp
|
||||
'okhttp3',
|
||||
'okio',
|
||||
|
||||
// DependencyDownload
|
||||
'dev.vankka.dependencydownload',
|
||||
'dev.vankka.mcdependencydownload',
|
||||
'me.lucko.jarrelocator',
|
||||
'org.objectweb.asm',
|
||||
|
||||
// Configurate, geantyref, yaml
|
||||
'org.spongepowered.configurate',
|
||||
'io.leangen.geantyref',
|
||||
'org.yaml.snakeyaml',
|
||||
|
||||
// HikariCP
|
||||
'com.zaxxer.hikari',
|
||||
|
||||
// MinecraftAuth lib (& it's dependencies)
|
||||
'me.minecraftauth.lib',
|
||||
'com.github.kevinsawicki.http',
|
||||
'org.json.simple',
|
||||
'alexh',
|
||||
|
||||
// Adventure (API isn't relocated always)
|
||||
'net.kyori.adventure.platform',
|
||||
'net.kyori.adventure.text.serializer',
|
||||
|
||||
// EnhancedLegacyText, MCDiscordReserializer
|
||||
'dev.vankka.enhancedlegacytext',
|
||||
'dev.vankka.mcdiscordreserializer',
|
||||
'dev.vankka.simpleast',
|
||||
|
||||
// Caffeine
|
||||
'com.github.benmanes.caffeine',
|
||||
|
||||
// Commons
|
||||
'org.apache.commons',
|
||||
|
||||
// SLF4J
|
||||
'org.slf4j',
|
||||
|
||||
// Checker Framework
|
||||
'org.checkerframework',
|
||||
|
||||
// Gson, Google error prone annotations
|
||||
'com.google.gson',
|
||||
'com.google.errorprone.annotations',
|
||||
|
||||
// Webhooks
|
||||
'club.minnced',
|
||||
'org.json',
|
||||
].each {
|
||||
tasks.shadowJar.relocate it, 'com.discordsrv.dependencies.' + it
|
||||
tasks.generateRuntimeDownloadResourceForRuntimeDownloadOnly.relocate it, 'com.discordsrv.dependencies.' + it
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
[
|
||||
// JDA, WS
|
||||
'net.dv8tion.jda',
|
||||
'com.iwebpp',
|
||||
'com.neovisionaries.ws',
|
||||
|
||||
// Trove
|
||||
'gnu.trove',
|
||||
|
||||
// Jackson
|
||||
'com.fasterxml.jackson',
|
||||
|
||||
// okhttp
|
||||
'okhttp3',
|
||||
'okio',
|
||||
|
||||
// DependencyDownload
|
||||
'dev.vankka.dependencydownload',
|
||||
'dev.vankka.mcdependencydownload',
|
||||
'me.lucko.jarrelocator',
|
||||
'org.objectweb.asm',
|
||||
|
||||
// Configurate, geantyref, yaml
|
||||
'org.spongepowered.configurate',
|
||||
'io.leangen.geantyref',
|
||||
'org.yaml.snakeyaml',
|
||||
|
||||
// HikariCP
|
||||
'com.zaxxer.hikari',
|
||||
|
||||
// MinecraftAuth lib (& it's dependencies)
|
||||
'me.minecraftauth.lib',
|
||||
'com.github.kevinsawicki.http',
|
||||
'org.json.simple',
|
||||
'alexh',
|
||||
|
||||
// Adventure (API isn't relocated always)
|
||||
'net.kyori.adventure.platform',
|
||||
'net.kyori.adventure.text.serializer',
|
||||
|
||||
// EnhancedLegacyText, MCDiscordReserializer
|
||||
'dev.vankka.enhancedlegacytext',
|
||||
'dev.vankka.mcdiscordreserializer',
|
||||
'dev.vankka.simpleast',
|
||||
|
||||
// Caffeine
|
||||
'com.github.benmanes.caffeine',
|
||||
|
||||
// Commons
|
||||
'org.apache.commons',
|
||||
|
||||
// SLF4J
|
||||
'org.slf4j',
|
||||
|
||||
// Checker Framework
|
||||
'org.checkerframework',
|
||||
|
||||
// Gson, Google error prone annotations
|
||||
'com.google.gson',
|
||||
'com.google.errorprone.annotations',
|
||||
|
||||
// Webhooks
|
||||
'club.minnced',
|
||||
'org.json',
|
||||
].each {
|
||||
relocate it, 'com.discordsrv.dependencies.' + it
|
||||
}
|
||||
|
||||
// Unrelocate package, in case a platform uses something we normally relocate
|
||||
relocate('com.discordsrv.unrelocate.', '')
|
||||
}
|
||||
|
@ -1,17 +1,16 @@
|
||||
import dev.vankka.dependencydownload.task.GenerateDependencyDownloadResourceTask
|
||||
|
||||
[
|
||||
'net.kyori',
|
||||
'me.lucko.commodore'
|
||||
].each {
|
||||
tasks.shadowJar.relocate it, 'com.discordsrv.dependencies.' + it
|
||||
tasks.generateRuntimeDownloadResourceForRuntimeDownloadOnly.relocate it, 'com.discordsrv.dependencies.' + it
|
||||
}
|
||||
// More relocations in buildscript/relocations.gradle
|
||||
|
||||
shadowJar {
|
||||
archiveFileName = 'bukkit.jarinjar'
|
||||
|
||||
configure {
|
||||
[
|
||||
'net.kyori',
|
||||
'me.lucko.commodore'
|
||||
].each {
|
||||
relocate it, 'com.discordsrv.dependencies.' + it
|
||||
}
|
||||
}
|
||||
// More relocations in buildscript/relocations.gradle
|
||||
}
|
||||
|
||||
apply from: rootProject.file('buildscript/runtime.gradle')
|
||||
@ -100,6 +99,7 @@ dependencies {
|
||||
compileOnly(libs.venturechat)
|
||||
}
|
||||
|
||||
|
||||
processResources {
|
||||
dependsOn(generateResourceForCommodore)
|
||||
}
|
||||
}
|
@ -1,3 +1,21 @@
|
||||
/*
|
||||
* This file is part of DiscordSRV, licensed under the GPLv3 License
|
||||
* Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.discordsrv.bukkit.listener.award;
|
||||
|
||||
import com.discordsrv.common.DiscordSRV;
|
||||
|
@ -1,3 +1,21 @@
|
||||
/*
|
||||
* This file is part of DiscordSRV, licensed under the GPLv3 License
|
||||
* Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.discordsrv.bukkit.listener.award;
|
||||
|
||||
import com.discordsrv.common.DiscordSRV;
|
||||
@ -60,11 +78,11 @@ public class BukkitAdvancementListener extends AbstractBukkitAwardListener {
|
||||
}
|
||||
|
||||
forwarder.publishEvent(
|
||||
event,
|
||||
event.getPlayer(),
|
||||
data.nameJson != null ? ComponentUtil.toAPI(BukkitComponentSerializer.gson().deserialize(data.nameJson)) : null,
|
||||
data.titleJson != null ? ComponentUtil.toAPI(BukkitComponentSerializer.gson().deserialize(data.titleJson)) : null,
|
||||
false
|
||||
);
|
||||
data.nameJson != null ? ComponentUtil.toAPI(BukkitComponentSerializer.gson().deserialize(data.nameJson)) : null,
|
||||
false);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
logger.debug("Failed to get advancement data", e);
|
||||
}
|
||||
|
@ -1,8 +1,26 @@
|
||||
/*
|
||||
* This file is part of DiscordSRV, licensed under the GPLv3 License
|
||||
* Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.discordsrv.bukkit.listener.award;
|
||||
|
||||
import com.discordsrv.api.component.MinecraftComponent;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface IBukkitAwardForwarder {
|
||||
void publishEvent(Player player, MinecraftComponent message, MinecraftComponent name, boolean cancelled);
|
||||
void publishEvent(Object triggeringEvent, Player player, MinecraftComponent name, MinecraftComponent message, boolean cancelled);
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ public class PaperComponentHandle<T> {
|
||||
if (handle != null) {
|
||||
Object unrelocated = null;
|
||||
try {
|
||||
unrelocated = handle.invokeExact(target);
|
||||
unrelocated = handle.invoke(target);
|
||||
} catch (Throwable ignored) {}
|
||||
if (unrelocated != null) {
|
||||
MinecraftComponent component = discordSRV.componentFactory().empty();
|
||||
@ -78,6 +78,10 @@ public class PaperComponentHandle<T> {
|
||||
}
|
||||
}
|
||||
|
||||
if (legacy == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String legacyOutput = legacy.apply(target);
|
||||
return legacyOutput != null
|
||||
? ComponentUtil.toAPI(BukkitComponentSerializer.legacy().deserialize(legacyOutput))
|
||||
|
@ -1,3 +1,21 @@
|
||||
/*
|
||||
* This file is part of DiscordSRV, licensed under the GPLv3 License
|
||||
* Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.discordsrv.bukkit.listener.award;
|
||||
|
||||
import com.discordsrv.api.component.MinecraftComponent;
|
||||
@ -50,6 +68,6 @@ public class PaperModernAdvancementListener extends AbstractBukkitAwardListener
|
||||
|
||||
MinecraftComponent message = MESSAGE_HANDLE.getComponent(discordSRV, event);
|
||||
MinecraftComponent displayName = DISPLAY_NAME_HANDLE.getComponent(discordSRV, advancement);
|
||||
forwarder.publishEvent(event.getPlayer(), message, displayName, false);
|
||||
forwarder.publishEvent(event, event.getPlayer(), displayName, message, false);
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,28 @@
|
||||
/*
|
||||
* This file is part of DiscordSRV, licensed under the GPLv3 License
|
||||
* Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.discordsrv.bukkit.listener.chat;
|
||||
|
||||
import com.discordsrv.api.component.MinecraftComponent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
public interface IBukkitChatForwarder {
|
||||
|
||||
void publishEvent(Player player, MinecraftComponent component, boolean cancelled);
|
||||
void publishEvent(Event event, Player player, MinecraftComponent component, boolean cancelled);
|
||||
}
|
||||
|
@ -49,6 +49,6 @@ public class PaperChatListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onAsyncChat(AsyncChatEvent event) {
|
||||
MinecraftComponent component = COMPONENT_HANDLE.getComponent(discordSRV, event);
|
||||
listener.publishEvent(event.getPlayer(), component, event.isCancelled());
|
||||
listener.publishEvent(event, event.getPlayer(), component, event.isCancelled());
|
||||
}
|
||||
}
|
||||
|
@ -79,9 +79,10 @@ public class ChattyChatIntegration extends PluginIntegration<BukkitDiscordSRV> i
|
||||
|
||||
discordSRV.scheduler().run(() -> discordSRV.eventBus().publish(
|
||||
new GameChatMessageReceiveEvent(
|
||||
event,
|
||||
discordSRV.playerProvider().player(player),
|
||||
new ChattyChannel(chat),
|
||||
component,
|
||||
new ChattyChannel(chat),
|
||||
false
|
||||
)
|
||||
));
|
||||
|
@ -87,9 +87,10 @@ public class LunaChatIntegration extends PluginIntegration<BukkitDiscordSRV> imp
|
||||
|
||||
discordSRV.scheduler().run(() -> discordSRV.eventBus().publish(
|
||||
new GameChatMessageReceiveEvent(
|
||||
event,
|
||||
discordSRV.playerProvider().player(player),
|
||||
new LunaChatChannel(channel),
|
||||
component,
|
||||
new LunaChatChannel(channel),
|
||||
event.isCancelled()
|
||||
)
|
||||
));
|
||||
|
@ -81,9 +81,10 @@ public class TownyChatIntegration extends PluginIntegration<BukkitDiscordSRV> im
|
||||
|
||||
discordSRV.scheduler().run(() -> discordSRV.eventBus().publish(
|
||||
new GameChatMessageReceiveEvent(
|
||||
event,
|
||||
discordSRV.playerProvider().player(player),
|
||||
new TownyChatChannel(channel),
|
||||
component,
|
||||
new TownyChatChannel(channel),
|
||||
event.isCancelled()
|
||||
)
|
||||
));
|
||||
|
@ -89,9 +89,10 @@ public class VentureChatIntegration extends PluginIntegration<BukkitDiscordSRV>
|
||||
|
||||
discordSRV.scheduler().run(() -> discordSRV.eventBus().publish(
|
||||
new GameChatMessageReceiveEvent(
|
||||
event,
|
||||
discordSRV.playerProvider().player(player),
|
||||
new VentureChatChannel(channel),
|
||||
component,
|
||||
new VentureChatChannel(channel),
|
||||
false
|
||||
)
|
||||
));
|
||||
|
@ -76,6 +76,6 @@ public class BukkitDeathListener implements Listener {
|
||||
|
||||
boolean wasCancelled = cancelled;
|
||||
discordSRV.scheduler().run(() -> discordSRV.eventBus().publish(
|
||||
new DeathMessageReceiveEvent(player, null, component, wasCancelled)));
|
||||
new DeathMessageReceiveEvent(event, player, component, null, wasCancelled)));
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ public class BukkitStatusMessageListener implements Listener {
|
||||
boolean firstJoin = !event.getPlayer().hasPlayedBefore();
|
||||
|
||||
discordSRV.scheduler().run(() -> discordSRV.eventBus().publish(
|
||||
new JoinMessageReceiveEvent(player, null, component, firstJoin, false)
|
||||
new JoinMessageReceiveEvent(event, player, component, null, firstJoin, false)
|
||||
));
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ public class BukkitStatusMessageListener implements Listener {
|
||||
MinecraftComponent component = QUIT_HANDLE.getComponent(discordSRV, event);
|
||||
|
||||
discordSRV.scheduler().run(() -> discordSRV.eventBus().publish(
|
||||
new LeaveMessageReceiveEvent(player, null, component, false)
|
||||
new LeaveMessageReceiveEvent(event, player, component, null, false)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,21 @@
|
||||
/*
|
||||
* This file is part of DiscordSRV, licensed under the GPLv3 License
|
||||
* Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.discordsrv.bukkit.listener.award;
|
||||
|
||||
import com.discordsrv.api.component.MinecraftComponent;
|
||||
@ -21,6 +39,6 @@ public class BukkitAchievementListener extends AbstractBukkitAwardListener {
|
||||
}
|
||||
|
||||
MinecraftComponent name = ComponentUtil.toAPI(BukkitComponentSerializer.legacy().deserialize(event.getAchievement().name()));
|
||||
forwarder.publishEvent(event.getPlayer(), null, name, event.isCancelled());
|
||||
forwarder.publishEvent(event, event.getPlayer(), name, null, event.isCancelled());
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,27 @@
|
||||
/*
|
||||
* This file is part of DiscordSRV, licensed under the GPLv3 License
|
||||
* Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.discordsrv.bukkit.listener.award;
|
||||
|
||||
import com.discordsrv.api.component.MinecraftComponent;
|
||||
import com.discordsrv.api.event.events.message.receive.game.AwardMessageReceiveEvent;
|
||||
import com.discordsrv.bukkit.BukkitDiscordSRV;
|
||||
import com.discordsrv.common.player.IPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
@ -28,7 +48,17 @@ public class BukkitAwardForwarder implements IBukkitAwardForwarder {
|
||||
this.discordSRV = discordSRV;
|
||||
}
|
||||
|
||||
public void publishEvent(Player player, MinecraftComponent message, MinecraftComponent advancementName, boolean cancelled) {
|
||||
// TODO
|
||||
public void publishEvent(Object triggeringEvent, Player player, MinecraftComponent advancementName, MinecraftComponent message, boolean cancelled) {
|
||||
IPlayer srvPlayer = discordSRV.playerProvider().player(player);
|
||||
discordSRV.scheduler().run(() -> discordSRV.eventBus().publish(
|
||||
new AwardMessageReceiveEvent(
|
||||
triggeringEvent,
|
||||
srvPlayer,
|
||||
advancementName,
|
||||
message,
|
||||
null,
|
||||
cancelled
|
||||
)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import com.discordsrv.bukkit.BukkitDiscordSRV;
|
||||
import com.discordsrv.bukkit.component.PaperComponentHandle;
|
||||
import com.discordsrv.common.channel.GlobalChannel;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public class BukkitChatForwarder implements IBukkitChatForwarder {
|
||||
@ -45,12 +46,13 @@ public class BukkitChatForwarder implements IBukkitChatForwarder {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void publishEvent(Player player, MinecraftComponent component, boolean cancelled) {
|
||||
public void publishEvent(Event event, Player player, MinecraftComponent component, boolean cancelled) {
|
||||
discordSRV.scheduler().run(() -> discordSRV.eventBus().publish(
|
||||
new GameChatMessageReceiveEvent(
|
||||
event,
|
||||
discordSRV.playerProvider().player(player),
|
||||
new GlobalChannel(discordSRV),
|
||||
component,
|
||||
new GlobalChannel(discordSRV),
|
||||
cancelled
|
||||
)
|
||||
));
|
||||
|
@ -1,3 +1,21 @@
|
||||
/*
|
||||
* This file is part of DiscordSRV, licensed under the GPLv3 License
|
||||
* Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.discordsrv.bukkit.listener.chat;
|
||||
|
||||
import com.discordsrv.api.component.MinecraftComponent;
|
||||
@ -20,6 +38,6 @@ public class BukkitChatListener implements Listener {
|
||||
MinecraftComponent component = ComponentUtil.toAPI(
|
||||
BukkitComponentSerializer.legacy().deserialize(event.getMessage()));
|
||||
|
||||
forwarder.publishEvent(event.getPlayer(), component, event.isCancelled());
|
||||
forwarder.publishEvent(event, event.getPlayer(), component, event.isCancelled());
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ package com.discordsrv.common;
|
||||
import com.discordsrv.common.bootstrap.IBootstrap;
|
||||
import com.discordsrv.common.config.connection.ConnectionConfig;
|
||||
import com.discordsrv.common.config.main.MainConfig;
|
||||
import com.discordsrv.common.messageforwarding.game.AwardMessageModule;
|
||||
import com.discordsrv.common.messageforwarding.game.DeathMessageModule;
|
||||
import com.discordsrv.common.player.ServerPlayerProvider;
|
||||
import com.discordsrv.common.scheduler.ServerScheduler;
|
||||
@ -45,6 +46,7 @@ public abstract class ServerDiscordSRV<B extends IBootstrap, C extends MainConfi
|
||||
protected void enable() throws Throwable {
|
||||
super.enable();
|
||||
|
||||
registerModule(AwardMessageModule::new);
|
||||
registerModule(DeathMessageModule::new);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* This file is part of DiscordSRV, licensed under the GPLv3 License
|
||||
* Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.discordsrv.common.config.main.channels;
|
||||
|
||||
import com.discordsrv.api.discord.entity.message.DiscordMessageEmbed;
|
||||
import com.discordsrv.api.discord.entity.message.SendableDiscordMessage;
|
||||
import com.discordsrv.common.config.annotation.Untranslated;
|
||||
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
|
||||
import org.spongepowered.configurate.objectmapping.meta.Comment;
|
||||
|
||||
@ConfigSerializable
|
||||
public class AwardMessageConfig implements IMessageConfig {
|
||||
|
||||
@Comment("Enable achievement/advancement message forwarding")
|
||||
public boolean enabled = true;
|
||||
|
||||
@Untranslated(Untranslated.Type.VALUE)
|
||||
public SendableDiscordMessage.Builder format = SendableDiscordMessage.builder()
|
||||
.addEmbed(
|
||||
DiscordMessageEmbed.builder()
|
||||
.setAuthor(
|
||||
"%award_title|text_{player_name} made the achievement {award_name}%",
|
||||
null,
|
||||
"%player_avatar_url%"
|
||||
)
|
||||
.setColor(1)
|
||||
.build()
|
||||
);
|
||||
|
||||
@Override
|
||||
public boolean enabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SendableDiscordMessage.Builder format() {
|
||||
return format;
|
||||
}
|
||||
}
|
@ -19,6 +19,7 @@
|
||||
package com.discordsrv.common.config.main.channels.base.server;
|
||||
|
||||
import com.discordsrv.common.config.annotation.Order;
|
||||
import com.discordsrv.common.config.main.channels.AwardMessageConfig;
|
||||
import com.discordsrv.common.config.main.channels.DeathMessageConfig;
|
||||
import com.discordsrv.common.config.main.channels.base.BaseChannelConfig;
|
||||
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
|
||||
@ -29,6 +30,9 @@ public class ServerBaseChannelConfig extends BaseChannelConfig {
|
||||
@Order(1)
|
||||
public ServerJoinMessageConfig joinMessages = new ServerJoinMessageConfig();
|
||||
|
||||
@Order(3)
|
||||
public AwardMessageConfig awardMessages = new AwardMessageConfig();
|
||||
|
||||
@Order(3)
|
||||
public DeathMessageConfig deathMessages = new DeathMessageConfig();
|
||||
|
||||
|
@ -27,10 +27,8 @@ import com.discordsrv.api.discord.entity.message.ReceivedDiscordMessage;
|
||||
import com.discordsrv.api.discord.entity.message.ReceivedDiscordMessageCluster;
|
||||
import com.discordsrv.api.discord.entity.message.SendableDiscordMessage;
|
||||
import com.discordsrv.api.event.events.message.receive.game.AbstractGameMessageReceiveEvent;
|
||||
import com.discordsrv.api.placeholder.FormattedText;
|
||||
import com.discordsrv.api.player.DiscordSRVPlayer;
|
||||
import com.discordsrv.common.DiscordSRV;
|
||||
import com.discordsrv.common.component.util.ComponentUtil;
|
||||
import com.discordsrv.common.config.main.channels.IMessageConfig;
|
||||
import com.discordsrv.common.config.main.channels.base.BaseChannelConfig;
|
||||
import com.discordsrv.common.config.main.channels.base.IChannelConfig;
|
||||
@ -135,11 +133,9 @@ public abstract class AbstractGameMessageModule<T extends IMessageConfig, E exte
|
||||
return CompletableFuture.completedFuture(null);
|
||||
}
|
||||
|
||||
Component component = event != null ? ComponentUtil.fromAPI(event.getMessage()) : null;
|
||||
String message = component != null ? convertMessage(moduleConfig, component) : null;
|
||||
Map<CompletableFuture<ReceivedDiscordMessage>, DiscordMessageChannel> messageFutures;
|
||||
messageFutures = sendMessageToChannels(
|
||||
moduleConfig, format, messageChannels, message, player,
|
||||
moduleConfig, player, format, messageChannels, event,
|
||||
// Context
|
||||
config, player
|
||||
);
|
||||
@ -185,22 +181,25 @@ public abstract class AbstractGameMessageModule<T extends IMessageConfig, E exte
|
||||
});
|
||||
}
|
||||
|
||||
public String convertMessage(OrDefault<T> config, Component component) {
|
||||
public String convertComponent(OrDefault<T> config, Component component) {
|
||||
return discordSRV.componentFactory().discordSerializer().serialize(component);
|
||||
}
|
||||
|
||||
public Map<CompletableFuture<ReceivedDiscordMessage>, DiscordMessageChannel> sendMessageToChannels(
|
||||
OrDefault<T> config,
|
||||
IPlayer player,
|
||||
SendableDiscordMessage.Builder format,
|
||||
List<DiscordMessageChannel> channels,
|
||||
String message,
|
||||
IPlayer player,
|
||||
E event,
|
||||
Object... context
|
||||
) {
|
||||
SendableDiscordMessage discordMessage = format.toFormatter()
|
||||
SendableDiscordMessage.Formatter formatter = format.toFormatter()
|
||||
.addContext(context)
|
||||
.addReplacement("%message%", new FormattedText(message))
|
||||
.applyPlaceholderService()
|
||||
.applyPlaceholderService();
|
||||
|
||||
setPlaceholders(config, event, formatter);
|
||||
|
||||
SendableDiscordMessage discordMessage = formatter
|
||||
.build();
|
||||
|
||||
Map<CompletableFuture<ReceivedDiscordMessage>, DiscordMessageChannel> futures = new LinkedHashMap<>();
|
||||
@ -210,4 +209,6 @@ public abstract class AbstractGameMessageModule<T extends IMessageConfig, E exte
|
||||
|
||||
return futures;
|
||||
}
|
||||
|
||||
public abstract void setPlaceholders(OrDefault<T> config, E event, SendableDiscordMessage.Formatter formatter);
|
||||
}
|
||||
|
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* This file is part of DiscordSRV, licensed under the GPLv3 License
|
||||
* Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.discordsrv.common.messageforwarding.game;
|
||||
|
||||
import com.discordsrv.api.component.MinecraftComponent;
|
||||
import com.discordsrv.api.discord.entity.message.ReceivedDiscordMessageCluster;
|
||||
import com.discordsrv.api.discord.entity.message.SendableDiscordMessage;
|
||||
import com.discordsrv.api.event.bus.EventPriority;
|
||||
import com.discordsrv.api.event.bus.Subscribe;
|
||||
import com.discordsrv.api.event.events.message.forward.game.AwardMessageForwardedEvent;
|
||||
import com.discordsrv.api.event.events.message.receive.game.AwardMessageReceiveEvent;
|
||||
import com.discordsrv.common.DiscordSRV;
|
||||
import com.discordsrv.common.component.util.ComponentUtil;
|
||||
import com.discordsrv.common.config.main.channels.AwardMessageConfig;
|
||||
import com.discordsrv.common.config.main.channels.base.BaseChannelConfig;
|
||||
import com.discordsrv.common.config.main.channels.base.server.ServerBaseChannelConfig;
|
||||
import com.discordsrv.common.function.OrDefault;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
public class AwardMessageModule extends AbstractGameMessageModule<AwardMessageConfig, AwardMessageReceiveEvent> {
|
||||
|
||||
public AwardMessageModule(DiscordSRV discordSRV) {
|
||||
super(discordSRV, "AWARD_MESSAGES");
|
||||
}
|
||||
|
||||
@Subscribe(priority = EventPriority.LAST)
|
||||
public void onAwardMessageReceive(AwardMessageReceiveEvent event) {
|
||||
if (checkCancellation(event) || checkProcessor(event)) {
|
||||
return;
|
||||
}
|
||||
|
||||
process(event, event.getPlayer(), event.getGameChannel());
|
||||
event.markAsProcessed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrDefault<AwardMessageConfig> mapConfig(OrDefault<BaseChannelConfig> channelConfig) {
|
||||
return channelConfig.map(cfg -> ((ServerBaseChannelConfig) cfg).awardMessages);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postClusterToEventBus(ReceivedDiscordMessageCluster cluster) {
|
||||
discordSRV.eventBus().publish(new AwardMessageForwardedEvent(cluster));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlaceholders(OrDefault<AwardMessageConfig> config, AwardMessageReceiveEvent event, SendableDiscordMessage.Formatter formatter) {
|
||||
MinecraftComponent nameComponent = event.getName();
|
||||
Component name = nameComponent != null ? ComponentUtil.fromAPI(nameComponent) : null;
|
||||
|
||||
MinecraftComponent titleComponent = event.getTitle();
|
||||
Component title = titleComponent != null ? ComponentUtil.fromAPI(titleComponent) : null;
|
||||
|
||||
formatter
|
||||
.addPlaceholder("award_name", name)
|
||||
.addPlaceholder("award_title", title);
|
||||
}
|
||||
}
|
@ -18,12 +18,16 @@
|
||||
|
||||
package com.discordsrv.common.messageforwarding.game;
|
||||
|
||||
import com.discordsrv.api.component.MinecraftComponent;
|
||||
import com.discordsrv.api.discord.entity.message.ReceivedDiscordMessageCluster;
|
||||
import com.discordsrv.api.discord.entity.message.SendableDiscordMessage;
|
||||
import com.discordsrv.api.event.bus.EventPriority;
|
||||
import com.discordsrv.api.event.bus.Subscribe;
|
||||
import com.discordsrv.api.event.events.message.forward.game.DeathMessageForwardedEvent;
|
||||
import com.discordsrv.api.event.events.message.receive.game.DeathMessageReceiveEvent;
|
||||
import com.discordsrv.api.placeholder.FormattedText;
|
||||
import com.discordsrv.common.DiscordSRV;
|
||||
import com.discordsrv.common.component.util.ComponentUtil;
|
||||
import com.discordsrv.common.config.main.channels.DeathMessageConfig;
|
||||
import com.discordsrv.common.config.main.channels.base.BaseChannelConfig;
|
||||
import com.discordsrv.common.config.main.channels.base.server.ServerBaseChannelConfig;
|
||||
@ -36,7 +40,7 @@ public class DeathMessageModule extends AbstractGameMessageModule<DeathMessageCo
|
||||
}
|
||||
|
||||
@Subscribe(priority = EventPriority.LAST)
|
||||
public void onDeathReceive(DeathMessageReceiveEvent event) {
|
||||
public void onDeathMessageReceive(DeathMessageReceiveEvent event) {
|
||||
if (checkCancellation(event) || checkProcessor(event)) {
|
||||
return;
|
||||
}
|
||||
@ -54,4 +58,17 @@ public class DeathMessageModule extends AbstractGameMessageModule<DeathMessageCo
|
||||
public void postClusterToEventBus(ReceivedDiscordMessageCluster cluster) {
|
||||
discordSRV.eventBus().publish(new DeathMessageForwardedEvent(cluster));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlaceholders(
|
||||
OrDefault<DeathMessageConfig> config,
|
||||
DeathMessageReceiveEvent event,
|
||||
SendableDiscordMessage.Formatter formatter
|
||||
) {
|
||||
MinecraftComponent messageComponent = event.getMessage();
|
||||
String message = messageComponent != null ? convertComponent(config, ComponentUtil.fromAPI(messageComponent)) : null;
|
||||
|
||||
formatter.addPlaceholder("message", new FormattedText(message));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,12 +18,16 @@
|
||||
|
||||
package com.discordsrv.common.messageforwarding.game;
|
||||
|
||||
import com.discordsrv.api.component.MinecraftComponent;
|
||||
import com.discordsrv.api.discord.entity.message.ReceivedDiscordMessageCluster;
|
||||
import com.discordsrv.api.discord.entity.message.SendableDiscordMessage;
|
||||
import com.discordsrv.api.event.bus.EventPriority;
|
||||
import com.discordsrv.api.event.bus.Subscribe;
|
||||
import com.discordsrv.api.event.events.message.forward.game.JoinMessageForwardedEvent;
|
||||
import com.discordsrv.api.event.events.message.receive.game.JoinMessageReceiveEvent;
|
||||
import com.discordsrv.api.placeholder.FormattedText;
|
||||
import com.discordsrv.common.DiscordSRV;
|
||||
import com.discordsrv.common.component.util.ComponentUtil;
|
||||
import com.discordsrv.common.config.main.channels.IMessageConfig;
|
||||
import com.discordsrv.common.config.main.channels.base.BaseChannelConfig;
|
||||
import com.discordsrv.common.function.OrDefault;
|
||||
@ -35,12 +39,13 @@ public class JoinMessageModule extends AbstractGameMessageModule<IMessageConfig,
|
||||
}
|
||||
|
||||
@Subscribe(priority = EventPriority.LAST)
|
||||
public void onStatusMessageReceive(JoinMessageReceiveEvent event) {
|
||||
public void onJoinMessageReceive(JoinMessageReceiveEvent event) {
|
||||
if (checkCancellation(event) || checkProcessor(event)) {
|
||||
return;
|
||||
}
|
||||
|
||||
process(event, event.getPlayer(), event.getGameChannel());
|
||||
event.markAsProcessed();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -59,4 +64,16 @@ public class JoinMessageModule extends AbstractGameMessageModule<IMessageConfig,
|
||||
public void postClusterToEventBus(ReceivedDiscordMessageCluster cluster) {
|
||||
discordSRV.eventBus().publish(new JoinMessageForwardedEvent(cluster));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlaceholders(
|
||||
OrDefault<IMessageConfig> config,
|
||||
JoinMessageReceiveEvent event,
|
||||
SendableDiscordMessage.Formatter formatter
|
||||
) {
|
||||
MinecraftComponent messageComponent = event.getMessage();
|
||||
String message = messageComponent != null ? convertComponent(config, ComponentUtil.fromAPI(messageComponent)) : null;
|
||||
|
||||
formatter.addPlaceholder("message", new FormattedText(message));
|
||||
}
|
||||
}
|
||||
|
@ -18,12 +18,16 @@
|
||||
|
||||
package com.discordsrv.common.messageforwarding.game;
|
||||
|
||||
import com.discordsrv.api.component.MinecraftComponent;
|
||||
import com.discordsrv.api.discord.entity.message.ReceivedDiscordMessageCluster;
|
||||
import com.discordsrv.api.discord.entity.message.SendableDiscordMessage;
|
||||
import com.discordsrv.api.event.bus.EventPriority;
|
||||
import com.discordsrv.api.event.bus.Subscribe;
|
||||
import com.discordsrv.api.event.events.message.forward.game.LeaveMessageForwardedEvent;
|
||||
import com.discordsrv.api.event.events.message.receive.game.LeaveMessageReceiveEvent;
|
||||
import com.discordsrv.api.placeholder.FormattedText;
|
||||
import com.discordsrv.common.DiscordSRV;
|
||||
import com.discordsrv.common.component.util.ComponentUtil;
|
||||
import com.discordsrv.common.config.main.channels.LeaveMessageConfig;
|
||||
import com.discordsrv.common.config.main.channels.base.BaseChannelConfig;
|
||||
import com.discordsrv.common.function.OrDefault;
|
||||
@ -35,12 +39,13 @@ public class LeaveMessageModule extends AbstractGameMessageModule<LeaveMessageCo
|
||||
}
|
||||
|
||||
@Subscribe(priority = EventPriority.LAST)
|
||||
public void onStatusMessageReceive(LeaveMessageReceiveEvent event) {
|
||||
public void onLeaveMessageReceive(LeaveMessageReceiveEvent event) {
|
||||
if (checkCancellation(event) || checkProcessor(event)) {
|
||||
return;
|
||||
}
|
||||
|
||||
process(event, event.getPlayer(), event.getGameChannel());
|
||||
event.markAsProcessed();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -52,4 +57,16 @@ public class LeaveMessageModule extends AbstractGameMessageModule<LeaveMessageCo
|
||||
public void postClusterToEventBus(ReceivedDiscordMessageCluster cluster) {
|
||||
discordSRV.eventBus().publish(new LeaveMessageForwardedEvent(cluster));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlaceholders(
|
||||
OrDefault<LeaveMessageConfig> config,
|
||||
LeaveMessageReceiveEvent event,
|
||||
SendableDiscordMessage.Formatter formatter
|
||||
) {
|
||||
MinecraftComponent messageComponent = event.getMessage();
|
||||
String message = messageComponent != null ? convertComponent(config, ComponentUtil.fromAPI(messageComponent)) : null;
|
||||
|
||||
formatter.addPlaceholder("message", new FormattedText(message));
|
||||
}
|
||||
}
|
||||
|
@ -18,12 +18,16 @@
|
||||
|
||||
package com.discordsrv.common.messageforwarding.game;
|
||||
|
||||
import com.discordsrv.api.component.MinecraftComponent;
|
||||
import com.discordsrv.api.discord.entity.message.ReceivedDiscordMessageCluster;
|
||||
import com.discordsrv.api.discord.entity.message.SendableDiscordMessage;
|
||||
import com.discordsrv.api.event.bus.EventPriority;
|
||||
import com.discordsrv.api.event.bus.Subscribe;
|
||||
import com.discordsrv.api.event.events.message.forward.game.ServerSwitchMessageForwardedEvent;
|
||||
import com.discordsrv.api.event.events.message.receive.game.ServerSwitchMessageReceiveEvent;
|
||||
import com.discordsrv.api.placeholder.FormattedText;
|
||||
import com.discordsrv.common.DiscordSRV;
|
||||
import com.discordsrv.common.component.util.ComponentUtil;
|
||||
import com.discordsrv.common.config.main.channels.ServerSwitchMessageConfig;
|
||||
import com.discordsrv.common.config.main.channels.base.BaseChannelConfig;
|
||||
import com.discordsrv.common.config.main.channels.base.proxy.ProxyBaseChannelConfig;
|
||||
@ -36,7 +40,7 @@ public class ServerSwitchMessageModule extends AbstractGameMessageModule<ServerS
|
||||
}
|
||||
|
||||
@Subscribe(priority = EventPriority.LAST)
|
||||
public void onServerSwitchReceive(ServerSwitchMessageReceiveEvent event) {
|
||||
public void onServerSwitchMessageReceive(ServerSwitchMessageReceiveEvent event) {
|
||||
if (checkCancellation(event) || checkProcessor(event)) {
|
||||
return;
|
||||
}
|
||||
@ -54,4 +58,16 @@ public class ServerSwitchMessageModule extends AbstractGameMessageModule<ServerS
|
||||
public void postClusterToEventBus(ReceivedDiscordMessageCluster cluster) {
|
||||
discordSRV.eventBus().publish(new ServerSwitchMessageForwardedEvent(cluster));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlaceholders(
|
||||
OrDefault<ServerSwitchMessageConfig> config,
|
||||
ServerSwitchMessageReceiveEvent event,
|
||||
SendableDiscordMessage.Formatter formatter
|
||||
) {
|
||||
MinecraftComponent messageComponent = event.getMessage();
|
||||
String message = messageComponent != null ? convertComponent(config, ComponentUtil.fromAPI(messageComponent)) : null;
|
||||
|
||||
formatter.addPlaceholder("message", new FormattedText(message));
|
||||
}
|
||||
}
|
||||
|
@ -56,18 +56,21 @@ public class StartMessageModule extends AbstractGameMessageModule<StartMessageCo
|
||||
@Override
|
||||
public Map<CompletableFuture<ReceivedDiscordMessage>, DiscordMessageChannel> sendMessageToChannels(
|
||||
OrDefault<StartMessageConfig> config,
|
||||
IPlayer player,
|
||||
SendableDiscordMessage.Builder format,
|
||||
List<DiscordMessageChannel> channels,
|
||||
String message,
|
||||
IPlayer player,
|
||||
AbstractGameMessageReceiveEvent event,
|
||||
Object... context
|
||||
) {
|
||||
if (!config.get(cfg -> cfg.enabled, false)) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
return super.sendMessageToChannels(config, format, channels, message, player, context);
|
||||
return super.sendMessageToChannels(config, player, format, channels, event, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlaceholders(OrDefault<StartMessageConfig> config, AbstractGameMessageReceiveEvent event, SendableDiscordMessage.Formatter formatter) {}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
process(null, null, null);
|
||||
|
@ -59,18 +59,21 @@ public class StopMessageModule extends AbstractGameMessageModule<StopMessageConf
|
||||
@Override
|
||||
public Map<CompletableFuture<ReceivedDiscordMessage>, DiscordMessageChannel> sendMessageToChannels(
|
||||
OrDefault<StopMessageConfig> config,
|
||||
IPlayer player,
|
||||
SendableDiscordMessage.Builder format,
|
||||
List<DiscordMessageChannel> channels,
|
||||
String message,
|
||||
IPlayer player,
|
||||
AbstractGameMessageReceiveEvent event,
|
||||
Object... context
|
||||
) {
|
||||
if (!config.get(cfg -> cfg.enabled, false)) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
return super.sendMessageToChannels(config, format, channels, message, player, context);
|
||||
return super.sendMessageToChannels(config, player, format, channels, event, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlaceholders(OrDefault<StopMessageConfig> config, AbstractGameMessageReceiveEvent event, SendableDiscordMessage.Formatter formatter) {}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
try {
|
||||
|
@ -35,6 +35,7 @@ import com.discordsrv.api.placeholder.DiscordPlaceholders;
|
||||
import com.discordsrv.api.placeholder.FormattedText;
|
||||
import com.discordsrv.api.placeholder.util.Placeholders;
|
||||
import com.discordsrv.common.DiscordSRV;
|
||||
import com.discordsrv.common.component.util.ComponentUtil;
|
||||
import com.discordsrv.common.config.main.channels.MinecraftToDiscordChatConfig;
|
||||
import com.discordsrv.common.config.main.channels.base.BaseChannelConfig;
|
||||
import com.discordsrv.common.function.OrDefault;
|
||||
@ -79,7 +80,7 @@ public class MinecraftToDiscordChatModule extends AbstractGameMessageModule<Mine
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convertMessage(OrDefault<MinecraftToDiscordChatConfig> config, Component component) {
|
||||
public String convertComponent(OrDefault<MinecraftToDiscordChatConfig> config, Component component) {
|
||||
DiscordSerializer discordSerializer = discordSRV.componentFactory().discordSerializer();
|
||||
String content = discordSerializer.serialize(component, discordSerializer.getDefaultOptions().withEscapeMarkdown(false));
|
||||
|
||||
@ -93,10 +94,10 @@ public class MinecraftToDiscordChatModule extends AbstractGameMessageModule<Mine
|
||||
@Override
|
||||
public Map<CompletableFuture<ReceivedDiscordMessage>, DiscordMessageChannel> sendMessageToChannels(
|
||||
OrDefault<MinecraftToDiscordChatConfig> config,
|
||||
IPlayer player,
|
||||
SendableDiscordMessage.Builder format,
|
||||
List<DiscordMessageChannel> channels,
|
||||
String message,
|
||||
IPlayer player,
|
||||
GameChatMessageReceiveEvent event,
|
||||
Object... context
|
||||
) {
|
||||
Map<DiscordGuild, Set<DiscordMessageChannel>> channelMap = new LinkedHashMap<>();
|
||||
@ -112,6 +113,9 @@ public class MinecraftToDiscordChatModule extends AbstractGameMessageModule<Mine
|
||||
.add(channel);
|
||||
}
|
||||
|
||||
Component component = ComponentUtil.fromAPI(event.getMessage());
|
||||
String message = convertComponent(config, component);
|
||||
|
||||
Map<CompletableFuture<ReceivedDiscordMessage>, DiscordMessageChannel> futures = new LinkedHashMap<>();
|
||||
|
||||
// Format messages per-Guild
|
||||
@ -127,6 +131,9 @@ public class MinecraftToDiscordChatModule extends AbstractGameMessageModule<Mine
|
||||
return futures;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlaceholders(OrDefault<MinecraftToDiscordChatConfig> config, GameChatMessageReceiveEvent event, SendableDiscordMessage.Formatter formatter) {}
|
||||
|
||||
private final Pattern MENTION_PATTERN = Pattern.compile("@\\S+");
|
||||
|
||||
private CompletableFuture<SendableDiscordMessage> getMessageForGuild(
|
||||
@ -228,7 +235,7 @@ public class MinecraftToDiscordChatModule extends AbstractGameMessageModule<Mine
|
||||
return format.setAllowedMentions(allowedMentions)
|
||||
.toFormatter()
|
||||
.addContext(context)
|
||||
.addReplacement("%message%", () -> {
|
||||
.addPlaceholder("message", () -> {
|
||||
String finalMessage = channelMessagePlaceholders.toString();
|
||||
if (DiscordPlaceholders.MAPPING_STATE.get() != DiscordPlaceholders.MappingState.NORMAL) {
|
||||
return preventEveryoneMentions(everyone, finalMessage, false);
|
||||
|
@ -26,7 +26,7 @@ import com.discordsrv.api.placeholder.annotation.PlaceholderRemainder;
|
||||
import com.discordsrv.api.placeholder.mapper.PlaceholderResultMapper;
|
||||
import com.discordsrv.common.DiscordSRV;
|
||||
import com.discordsrv.common.placeholder.provider.AnnotationPlaceholderProvider;
|
||||
import com.discordsrv.common.placeholder.provider.PlaceholderProvider;
|
||||
import com.discordsrv.api.placeholder.provider.PlaceholderProvider;
|
||||
import com.github.benmanes.caffeine.cache.CacheLoader;
|
||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
@ -20,6 +20,7 @@ package com.discordsrv.common.placeholder.provider;
|
||||
|
||||
import com.discordsrv.api.placeholder.PlaceholderLookupResult;
|
||||
import com.discordsrv.api.placeholder.annotation.Placeholder;
|
||||
import com.discordsrv.api.placeholder.provider.PlaceholderProvider;
|
||||
import com.discordsrv.common.placeholder.provider.util.PlaceholderMethodUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
|
||||
networkTimeout=10000
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
25
gradlew
vendored
25
gradlew
vendored
@ -55,7 +55,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
@ -80,13 +80,10 @@ do
|
||||
esac
|
||||
done
|
||||
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
APP_NAME="Gradle"
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
@ -143,12 +140,16 @@ fi
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
@ -193,6 +194,10 @@ if "$cygwin" || "$msys" ; then
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
@ -205,6 +210,12 @@ set -- \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
|
15
gradlew.bat
vendored
15
gradlew.bat
vendored
@ -14,7 +14,7 @@
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@ -25,7 +25,8 @@
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
@ -10,7 +10,7 @@ dependencyResolutionManagement {
|
||||
versionCatalogs {
|
||||
libs {
|
||||
// Buildscript
|
||||
plugin('shadow', 'com.github.johnrengelman.shadow').version('7.1.1')
|
||||
plugin('shadow', 'com.github.johnrengelman.shadow').version('8.1.1')
|
||||
plugin('licenser', 'org.cadixdev.licenser').version('0.6.1')
|
||||
plugin('blossom', 'net.kyori.blossom').version('1.2.0')
|
||||
plugin('indra-git', 'net.kyori.indra.git').version('2.1.1')
|
||||
|
Loading…
Reference in New Issue
Block a user