Merge branch 'main' into vote_mute

This commit is contained in:
Teriuihi 2025-01-02 00:36:36 +01:00
commit 3275db13d0
12 changed files with 53 additions and 84 deletions

20
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,20 @@
pipeline {
agent any
stages {
stage('Gradle') {
steps {
sh './gradlew build'
}
}
stage('Archive') {
steps {
archiveArtifacts artifacts: 'build/libs/', followSymlinks: false
}
}
stage('discord') {
steps {
discordSend description: "Build: ${BUILD_NUMBER}", showChangeset: true, result: currentBuild.currentResult, title: currentBuild.fullProjectName, webhookURL: env.discordwebhook
}
}
}
}

View File

@ -3,7 +3,7 @@ plugins {
} }
dependencies { dependencies {
compileOnly("com.alttd:Galaxy-API:1.19.2-R0.1-SNAPSHOT") { compileOnly("com.alttd:Galaxy-API:1.21-R0.1-SNAPSHOT") {
// exclude("net.kyori") // exclude("net.kyori")
} }
compileOnly("org.spongepowered:configurate-yaml:4.1.2") // Configurate compileOnly("org.spongepowered:configurate-yaml:4.1.2") // Configurate

View File

@ -32,7 +32,7 @@ public final class Config {
public static File CONFIGPATH; public static File CONFIGPATH;
public static void init() { public static void init() {
CONFIGPATH = new File(System.getProperty("user.home") + File.separator + "share" + File.separator + "configs" + File.separator + "ChatPlugin"); CONFIGPATH = new File(File.separator + "mnt" + File.separator + "configs" + File.separator + "ChatPlugin");
CONFIG_FILE = new File(CONFIGPATH, "config.yml"); CONFIG_FILE = new File(CONFIGPATH, "config.yml");
configLoader = YamlConfigurationLoader.builder() configLoader = YamlConfigurationLoader.builder()
.file(CONFIG_FILE) .file(CONFIG_FILE)

View File

@ -1,25 +1,12 @@
plugins { plugins {
`java-library` `java-library`
id("com.github.johnrengelman.shadow") version "7.1.0" id("io.github.goooler.shadow") version "8.1.8"
} }
allprojects { allprojects {
group = "com.alttd.chat" group = "com.alttd.chat"
version = "2.0.0-SNAPSHOT" version = "2.0.0-SNAPSHOT"
description = "All in one minecraft chat plugin" description = "All in one minecraft chat plugin"
// repositories {
// mavenCentral()
// maven("https://repo.destro.xyz/snapshots") // Altitude - Galaxy
// maven("https://oss.sonatype.org/content/groups/public/") // Adventure
// maven("https://oss.sonatype.org/content/repositories/snapshots/") // Minimessage
// maven("https://oss.sonatype.org/content/repositories/") // Minimessage
// maven("https://nexus.velocitypowered.com/repository/") // Velocity
// maven("https://nexus.velocitypowered.com/repository/maven-public/") // Velocity
// maven("https://repo.spongepowered.org/maven") // Configurate
// maven("https://repo.extendedclip.com/content/repositories/placeholderapi/") // Papi
// maven("https://jitpack.io")
// }
} }
subprojects { subprojects {
@ -27,7 +14,7 @@ subprojects {
java { java {
toolchain { toolchain {
languageVersion.set(JavaLanguageVersion.of(17)) languageVersion.set(JavaLanguageVersion.of(21))
} }
} }

View File

@ -1,58 +1,24 @@
import java.io.FileOutputStream
import java.net.URL
plugins { plugins {
`maven-publish` `maven-publish`
id("com.github.johnrengelman.shadow") id("io.github.goooler.shadow")
id("xyz.jpenilla.run-paper") version "1.0.6"
} }
dependencies { dependencies {
implementation(project(":api")) // API implementation(project(":api")) // API
compileOnly("com.alttd:Galaxy-API:1.20.4-R0.1-SNAPSHOT") // Galaxy compileOnly("com.alttd:Galaxy-API:1.21-R0.1-SNAPSHOT") // Galaxy
compileOnly("com.gitlab.ruany:LiteBansAPI:0.3.5") // move to proxy compileOnly("com.gitlab.ruany:LiteBansAPI:0.3.5") // move to proxy
compileOnly("org.apache.commons:commons-lang3:3.12.0") // needs an alternative, already removed from upstream api and will be removed in server compileOnly("org.apache.commons:commons-lang3:3.12.0") // needs an alternative, already removed from upstream api and will be removed in server
compileOnly("net.luckperms:api:5.3") // Luckperms compileOnly("net.luckperms:api:5.3") // Luckperms
compileOnly(files("../libs/CMI.jar"))
} }
tasks { tasks {
shadowJar { shadowJar {
archiveFileName.set("${rootProject.name}-${project.name}-${project.version}.jar") archiveFileName.set("${rootProject.name}-${project.name}-${project.version}.jar")
// minimize()
} }
build { build {
// setBuildDir("${rootProject.buildDir}")
dependsOn(shadowJar) dependsOn(shadowJar)
} }
runServer {
val dir = File(System.getProperty("user.home") + "/share/devserver/");
if (!dir.parentFile.exists()) {
dir.parentFile.mkdirs()
}
runDirectory.set(dir)
val fileName = "/galaxy.jar"
var file = File(dir.path + fileName)
if (!file.parentFile.exists()) {
file.parentFile.mkdirs()
}
if (!file.exists()) {
download("https://repo.destro.xyz/snapshots/com/alttd/Galaxy-Server/Galaxy-paperclip-1.19.2-R0.1-SNAPSHOT-reobf.jar", file)
}
serverJar(file)
minecraftVersion("1.19.2")
}
}
fun download(link: String, path: File) {
URL(link).openStream().use { input ->
FileOutputStream(path).use { output ->
input.copyTo(output)
}
}
} }

View File

@ -82,11 +82,6 @@ public class ChatListener implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
Set<Player> receivers = event.viewers().stream().filter(audience -> audience instanceof Player)
.map(audience -> (Player) audience)
.filter(receiver -> !ChatUserManager.getChatUser(receiver.getUniqueId()).getIgnoredPlayers().contains(player.getUniqueId()))
.collect(Collectors.toSet());
Component input = event.message().colorIfAbsent(NamedTextColor.WHITE); Component input = event.message().colorIfAbsent(NamedTextColor.WHITE);
ModifiableString modifiableString = new ModifiableString(input); ModifiableString modifiableString = new ModifiableString(input);
@ -112,6 +107,11 @@ public class ChatListener implements Listener {
return; // the message was blocked return; // the message was blocked
} }
Set<Player> receivers = event.viewers().stream().filter(audience -> audience instanceof Player)
.map(audience -> (Player) audience)
.filter(receiver -> !ChatUserManager.getChatUser(receiver.getUniqueId()).getIgnoredPlayers().contains(player.getUniqueId()))
.collect(Collectors.toSet());
Set<Player> playersToPing = new HashSet<>(); Set<Player> playersToPing = new HashSet<>();
pingPlayers(playersToPing, modifiableString, player); pingPlayers(playersToPing, modifiableString, player);
@ -136,11 +136,12 @@ public class ChatListener implements Listener {
Pattern nickPattern = Pattern.compile("\\b(?<!\\\\)" + nickName + "\\b", Pattern.CASE_INSENSITIVE); Pattern nickPattern = Pattern.compile("\\b(?<!\\\\)" + nickName + "\\b", Pattern.CASE_INSENSITIVE);
// Pattern escapedNickPattern = Pattern.compile("\\b\\\\" + nickName + "\\b", Pattern.CASE_INSENSITIVE); // Pattern escapedNickPattern = Pattern.compile("\\b\\\\" + nickName + "\\b", Pattern.CASE_INSENSITIVE);
ChatUser onlinePlayerUser = ChatUserManager.getChatUser(onlinePlayer.getUniqueId());
if (namePattern.matcher(modifiableString.string()).find()) { if (namePattern.matcher(modifiableString.string()).find()) {
modifiableString.replace(TextReplacementConfig.builder() modifiableString.replace(TextReplacementConfig.builder()
.once() .once()
.match(namePattern) .match(namePattern)
.replacement(mention.append(onlinePlayer.displayName())) .replacement(mention.append(onlinePlayerUser.getDisplayName()))
.build()); .build());
//TODO replace all instances of \name with just name but using the match result so the capitalization doesn't change //TODO replace all instances of \name with just name but using the match result so the capitalization doesn't change
// modifiableString.replace(TextReplacementConfig.builder() // modifiableString.replace(TextReplacementConfig.builder()
@ -156,7 +157,7 @@ public class ChatListener implements Listener {
modifiableString.replace(TextReplacementConfig.builder() modifiableString.replace(TextReplacementConfig.builder()
.once() .once()
.match(nickPattern) .match(nickPattern)
.replacement(mention.append(onlinePlayer.displayName())) .replacement(mention.append(onlinePlayerUser.getDisplayName()))
.build()); .build());
if (!ChatUserManager.getChatUser(onlinePlayer.getUniqueId()).getIgnoredPlayers().contains(player.getUniqueId())) if (!ChatUserManager.getChatUser(onlinePlayer.getUniqueId()).getIgnoredPlayers().contains(player.getUniqueId()))
playersToPing.add(onlinePlayer); playersToPing.add(onlinePlayer);

View File

@ -17,6 +17,7 @@ import net.kyori.adventure.text.format.TextColor;
import net.kyori.adventure.text.format.TextDecoration; import net.kyori.adventure.text.format.TextDecoration;
import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -49,8 +50,8 @@ public class PlayerListener implements Listener {
UUID uuid = player.getUniqueId(); UUID uuid = player.getUniqueId();
Toggleable.disableToggles(uuid); Toggleable.disableToggles(uuid);
if (serverConfig.FIRST_JOIN_MESSAGES && System.currentTimeMillis() - player.getFirstPlayed() < TimeUnit.SECONDS.toMillis(10)) { if (serverConfig.FIRST_JOIN_MESSAGES && (!player.hasPlayedBefore() || System.currentTimeMillis() - player.getFirstPlayed() < TimeUnit.SECONDS.toMillis(10))) {
player.getServer().sendMessage(MiniMessage.miniMessage().deserialize(Config.FIRST_JOIN, Placeholder.parsed("player", player.getName()))); Bukkit.broadcast(MiniMessage.miniMessage().deserialize(Config.FIRST_JOIN, Placeholder.parsed("player", player.getName())));
} }
ChatUser user = ChatUserManager.getChatUser(uuid); ChatUser user = ChatUserManager.getChatUser(uuid);

View File

@ -1,7 +1,5 @@
package com.alttd.chat.nicknames; package com.alttd.chat.nicknames;
import com.Zrips.CMI.CMI;
import com.Zrips.CMI.Containers.CMIUser;
import com.alttd.chat.ChatAPI; import com.alttd.chat.ChatAPI;
import com.alttd.chat.ChatPlugin; import com.alttd.chat.ChatPlugin;
import com.alttd.chat.config.Config; import com.alttd.chat.config.Config;
@ -13,7 +11,6 @@ import com.alttd.chat.objects.Nick;
import com.alttd.chat.util.Utility; import com.alttd.chat.util.Utility;
import com.google.common.io.ByteArrayDataOutput; import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams; import com.google.common.io.ByteStreams;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver; import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import net.luckperms.api.LuckPerms; import net.luckperms.api.LuckPerms;
@ -384,7 +381,7 @@ public class Nicknames implements CommandExecutor, TabCompleter {
ChatUser user = ChatUserManager.getChatUser(player.getUniqueId()); ChatUser user = ChatUserManager.getChatUser(player.getUniqueId());
user.setDisplayName(player.getName()); user.setDisplayName(player.getName());
player.displayName(user.getDisplayName()); player.displayName(user.getDisplayName());
updateCMIUser(player, null); // updateCMIUser(player, null);
} }
public String getNick(final Player player) { public String getNick(final Player player) {
@ -399,25 +396,25 @@ public class Nicknames implements CommandExecutor, TabCompleter {
ChatUser user = ChatUserManager.getChatUser(player.getUniqueId()); ChatUser user = ChatUserManager.getChatUser(player.getUniqueId());
user.setDisplayName(nickName); user.setDisplayName(nickName);
player.displayName(user.getDisplayName()); player.displayName(user.getDisplayName());
updateCMIUser(player, nickName); // updateCMIUser(player, nickName);
} }
// public static String format(final String m) { // public static String format(final String m) {
// return NickUtilities.applyColor(m); // return NickUtilities.applyColor(m);
// } // }
public void updateCMIUser(Player player, String nickName) { // public void updateCMIUser(Player player, String nickName) {
if (!isCMIEnabled()) // if (!isCMIEnabled())
return; // return;
//
CMIUser cmiUser = CMI.getInstance().getPlayerManager().getUser(player); // CMIUser cmiUser = CMI.getInstance().getPlayerManager().getUser(player);
if (nickName == null){ // if (nickName == null){
cmiUser.setNickName(null, true); // cmiUser.setNickName(null, true);
} else { // } else {
cmiUser.setNickName(NickUtilities.applyColor(nickName), true); // cmiUser.setNickName(NickUtilities.applyColor(nickName), true);
} // }
cmiUser.updateDisplayName(); // cmiUser.updateDisplayName();
} // }
private Boolean isCMIEnabled = null; private Boolean isCMIEnabled = null;
private Boolean isCMIEnabled() { private Boolean isCMIEnabled() {

View File

@ -1,12 +1,8 @@
package com.alttd.chat.nicknames; package com.alttd.chat.nicknames;
import com.Zrips.CMI.commands.list.colorlimits;
import com.Zrips.CMI.utils.Util;
import com.alttd.chat.ChatPlugin; import com.alttd.chat.ChatPlugin;
import com.alttd.chat.config.Config; import com.alttd.chat.config.Config;
import com.alttd.chat.database.Queries; import com.alttd.chat.database.Queries;
import com.alttd.chat.managers.ChatUserManager;
import com.alttd.chat.objects.ChatUser;
import com.alttd.chat.objects.Nick; import com.alttd.chat.objects.Nick;
import com.alttd.chat.util.ALogger; import com.alttd.chat.util.ALogger;
import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteArrayDataInput;

View File

@ -41,6 +41,7 @@ public class ToggleableForCustomChannel extends Toggleable {
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
ALogger.info(String.format("%s sent %s message: %s", player.getName(), customChannel.getChannelName(), message));
ChatPlugin.getInstance().getChatHandler().chatChannel(player, customChannel, message); ChatPlugin.getInstance().getChatHandler().chatChannel(player, customChannel, message);
} }
}.runTaskAsynchronously(ChatPlugin.getInstance()); }.runTaskAsynchronously(ChatPlugin.getInstance());

Binary file not shown.

View File

@ -1,6 +1,6 @@
plugins { plugins {
`maven-publish` `maven-publish`
id("com.github.johnrengelman.shadow") id("io.github.goooler.shadow")
} }
dependencies { dependencies {