Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5.0 Merge #17

Merged
merged 26 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
988caec
Partial untested 5.0
Emibergo02 Jun 23, 2024
87a9dc9
Partial untested 5.0 part 2
Emibergo02 Jun 24, 2024
bd64fb0
Unfinished
Emibergo02 Jul 1, 2024
4555db1
Code cleanup
Emibergo02 Jul 9, 2024
3adaf5b
Added timestamp to NewChatMessage
Emibergo02 Jul 9, 2024
29d3b3f
Refactoring Chat objects
Emibergo02 Jul 9, 2024
f7c6e05
Changing channel feature
Emibergo02 Jul 9, 2024
1ed02a1
Refactorings and new item name provider for 1.20.5+
Emibergo02 Jul 12, 2024
1834bc8
Fixed staffchat and new channel system
Emibergo02 Jul 13, 2024
c69f9df
Reworked channel system
Emibergo02 Jul 13, 2024
f14bd0e
Implemented discord hook with the new channel system
Emibergo02 Jul 14, 2024
5c8979f
New components!
Emibergo02 Jul 16, 2024
bb512da
Fixed MySQL data manager
Emibergo02 Jul 20, 2024
1ced7f5
The spy feature is not a filter anymore.
Emibergo02 Jul 21, 2024
f62b33f
AudienceType first on deserialization
Emibergo02 Jul 25, 2024
62821d5
Fixed issue with private messages sent on a 3-server setups
Emibergo02 Jul 27, 2024
a478a7b
Serialize to JSON
Emibergo02 Jul 28, 2024
98b47cc
Re-added support for 1.20.1 GUI itemstacks
Emibergo02 Aug 8, 2024
c98eed8
Fixed discord integration (Removed Discord Filter)
Emibergo02 Aug 10, 2024
dae9db2
Channel shown by default feature
Emibergo02 Aug 10, 2024
b44cdea
Getter for PlayerChannel fields
Emibergo02 Aug 10, 2024
4a79b70
Getter for PlayerChannel fields
Emibergo02 Aug 10, 2024
61ea62b
static handlerlist for ChannelGuiPopulateEvent
Emibergo02 Aug 10, 2024
a686d2a
Changed permission system for channels
Emibergo02 Aug 10, 2024
97862e0
Fixed itemshare components not showing in private messages
Emibergo02 Aug 15, 2024
045343d
Added command to change channel displayname
Emibergo02 Aug 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 36 additions & 33 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,103 +6,108 @@ plugins {


group = 'dev.unnm3d'
version = '4.6.1'
version = '5.3'


repositories {
mavenLocal()
maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots' }
maven { url 'https://repo.spicord.org/' }
maven { url 'https://jitpack.io' }
maven { url 'https://repo.papermc.io/repository/maven-public/' }
maven { url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }
maven { url 'https://repo.extendedclip.com/content/repositories/placeholderapi/' }
maven { url 'https://repo.xenondevs.xyz/releases' }
maven { url 'https://repo.maven.apache.org/maven2/' }

}

dependencies {
compileOnly 'net.kyori:adventure-text-minimessage:4.17.0'
compileOnly 'net.kyori:adventure-text-serializer-plain:4.17.0'
compileOnly 'net.kyori:adventure-text-serializer-legacy:4.17.0'
compileOnly 'net.kyori:adventure-platform-bukkit:4.3.3'
compileOnly 'com.alibaba:fastjson:2.0.52'

implementation 'com.github.Exlll.ConfigLib:configlib-paper:v4.5.0'
implementation 'xyz.xenondevs.invui:invui-core:1.31'
implementation 'xyz.xenondevs.invui:inventory-access-r7:1.31'
implementation 'xyz.xenondevs.invui:inventory-access-r9:1.31'
implementation 'xyz.xenondevs.invui:inventory-access-r11:1.31'
implementation 'xyz.xenondevs.invui:inventory-access-r14:1.31'
implementation 'xyz.xenondevs.invui:inventory-access-r15:1.31'
implementation 'xyz.xenondevs.invui:inventory-access-r16:1.31'
implementation 'xyz.xenondevs.invui:inventory-access-r17:1.31'
implementation 'xyz.xenondevs.invui:inventory-access-r18:1.31'
implementation 'xyz.xenondevs.invui:inventory-access-r19:1.31'
implementation 'dev.jorel:commandapi-bukkit-shade:9.5.0-SNAPSHOT'
implementation 'xyz.xenondevs.invui:invui-core:1.35'
implementation 'xyz.xenondevs.invui:inventory-access-r7:1.35'
implementation 'xyz.xenondevs.invui:inventory-access-r11:1.35'
implementation 'xyz.xenondevs.invui:inventory-access-r15:1.35'
implementation 'xyz.xenondevs.invui:inventory-access-r16:1.35'
implementation 'xyz.xenondevs.invui:inventory-access-r17:1.35'
implementation 'xyz.xenondevs.invui:inventory-access-r18:1.35'
implementation 'xyz.xenondevs.invui:inventory-access-r19:1.35'
implementation 'xyz.xenondevs.invui:inventory-access-r20:1.35'
implementation 'xyz.xenondevs.invui:inventory-access-r21:1.35'
implementation 'dev.jorel:commandapi-bukkit-shade:9.5.3'
implementation 'com.github.Anon8281:UniversalScheduler:0.1.6'

compileOnly 'io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT'

compileOnly 'org.spigotmc:spigot-api:1.19.4-R0.1-SNAPSHOT'
compileOnly 'me.clip:placeholderapi:2.11.3'
compileOnly 'io.lettuce:lettuce-core:6.2.5.RELEASE'
compileOnly 'org.jetbrains:annotations:24.0.1'
compileOnly 'com.zaxxer:HikariCP:5.0.1'
compileOnly 'org.mariadb.jdbc:mariadb-java-client:3.1.4'
compileOnly 'io.lettuce:lettuce-core:6.2.7.RELEASE'
compileOnly 'org.jetbrains:annotations:24.1.0'
compileOnly 'com.zaxxer:HikariCP:5.1.0'
compileOnly 'net.luckperms:api:5.4'
compileOnly 'com.github.MilkBowl:VaultAPI:1.7'
compileOnly 'com.github.oraxen:oraxen:1.162.0'
compileOnly 'com.github.LeonMangler:PremiumVanishAPI:2.8.8'
compileOnly 'org.projectlombok:lombok:1.18.32'
compileOnly 'org.projectlombok:lombok:1.18.34'
compileOnly 'com.github.Spicord.Spicord:spicord-common:v5-SNAPSHOT'
compileOnly 'net.dv8tion:JDA:5.0.0-beta.16'
compileOnly 'org.apache.commons:commons-collections4:4.4'

testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.2'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.10.2'
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.10.2'
testImplementation 'io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT'

annotationProcessor('org.projectlombok:lombok:1.18.32')
annotationProcessor 'org.projectlombok:lombok:1.18.34'
}

test {
useJUnitPlatform()
}

shadowJar {
destinationDirectory.set(file("$rootDir/target"))
archiveClassifier.set('')
dependencies {

include dependency('com.github.Exlll.ConfigLib:configlib-paper')
include dependency('com.github.Exlll.ConfigLib:configlib-yaml')
include dependency("com.github.Exlll.ConfigLib:configlib-core")
include dependency('xyz.xenondevs.invui:invui-core')
include dependency('xyz.xenondevs.invui:inventory-access')
include dependency('xyz.xenondevs.invui:inventory-access-r7')
include dependency('xyz.xenondevs.invui:inventory-access-r9')
include dependency('xyz.xenondevs.invui:inventory-access-r11')
include dependency('xyz.xenondevs.invui:inventory-access-r14')
include dependency('xyz.xenondevs.invui:inventory-access-r15')
include dependency('xyz.xenondevs.invui:inventory-access-r16')
include dependency('xyz.xenondevs.invui:inventory-access-r17')
include dependency('xyz.xenondevs.invui:inventory-access-r18')
include dependency('xyz.xenondevs.invui:inventory-access-r19')
include dependency('xyz.xenondevs.invui:inventory-access-r20')
include dependency('xyz.xenondevs.invui:inventory-access-r21')
include dependency('dev.jorel:commandapi-bukkit-shade')
include dependency('com.github.Anon8281:UniversalScheduler:0.1.6')
}

exclude 'colors.bin'


relocate 'de.exlll.configlib', 'dev.unnm3d.redischat.libraries.configlib'
relocate 'xyz.xenondevs.invui', 'dev.unnm3d.redischat.libraries.invui'
relocate 'xyz.xenondevs.inventoryaccess', 'dev.unnm3d.redischat.libraries.inventoryaccess'
relocate 'dev.jorel.commandapi', 'dev.unnm3d.redischat.libraries.commandapi'
relocate 'com.github.Anon8281.universalScheduler', 'dev.unnm3d.redischat.libraries.universalScheduler'

}

def sourceJavaVersion = 21
def sourceJavaVersion = 17
def releaseJavaVersion = 17

java {
toolchain{
toolchain {
languageVersion = JavaLanguageVersion.of(releaseJavaVersion)
sourceCompatibility = JavaLanguageVersion.of(sourceJavaVersion)
}

withSourcesJar()
withJavadocJar()

}
compileJava.options.release.set releaseJavaVersion
compileJava.options.encoding 'UTF-8'
Expand Down Expand Up @@ -131,12 +136,10 @@ publishing {
artifactId = 'redischat'
version = "$version"
artifact shadowJar
artifact javadocJar
artifact sourcesJar
}
}
}


jar.dependsOn shadowJar
clean.delete "$rootDir/target"
2 changes: 1 addition & 1 deletion docs/dev/unnm3d/redischat/channels/ChannelGUI.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
<h1 title="Class ChannelGUI" class="title">Class ChannelGUI</h1>
</div>
<div class="inheritance" title="Inheritance Tree"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">java.lang.Object</a>
<div class="inheritance">dev.unnm3d.redischat.channels.ChannelGUI</div>
<div class="inheritance">dev.unnm3d.redischat.channels.gui.ChannelGUI</div>
</div>
<section class="class-description" id="class-description">
<hr>
Expand Down
2 changes: 1 addition & 1 deletion docs/dev/unnm3d/redischat/channels/MutePublic.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ <h1 title="Class MutePublic" class="title">Class MutePublic</h1>
</div>
<div class="inheritance" title="Inheritance Tree"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">java.lang.Object</a>
<div class="inheritance">xyz.xenondevs.invui.item.impl.AbstractItem
<div class="inheritance">dev.unnm3d.redischat.channels.MutePublic</div>
<div class="inheritance">dev.unnm3d.redischat.channels.gui.MutePublic</div>
</div>
</div>
<section class="class-description" id="class-description">
Expand Down
2 changes: 1 addition & 1 deletion docs/dev/unnm3d/redischat/channels/PlayerChannel.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ <h1 title="Class PlayerChannel" class="title">Class PlayerChannel</h1>
</div>
<div class="inheritance" title="Inheritance Tree"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">java.lang.Object</a>
<div class="inheritance">xyz.xenondevs.invui.item.impl.AbstractItem
<div class="inheritance">dev.unnm3d.redischat.channels.PlayerChannel</div>
<div class="inheritance">dev.unnm3d.redischat.channels.gui.PlayerChannel</div>
</div>
</div>
<section class="class-description" id="class-description">
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/dev/unnm3d/redischat/Permissions.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public enum Permissions {
MAIL_UNREAD("redischat.mail.unread"),
IGNORE("redischat.ignore"),
IGNORE_WHITELIST("redischat.ignore_whitelist"),
BYPASS_FILTER_PREFIX("redischat.bypassfilter."),
USE_FORMATTING("redischat.useformatting"),
USE_DANGEROUS("redischat.usedangeroustags"),
USE_ITEM("redischat.showitem"),
Expand All @@ -29,10 +30,13 @@ public enum Permissions {
CHANNEL_PREFIX("redischat.channel."),
CHANNEL_PUBLIC("redischat.channel.public"),
CHANNEL_CREATE("redischat.createchannel"),
CHANNEL_CHANGE_DISPLAYNAME("redischat.changedisplayname"),
CHANNEL_DELETE("redischat.deletechannel"),
CHANNEL_TOGGLE_PLAYER("redischat.playerchannel"),
CHANNEL_LIST("redischat.listchannel"),
CHANNEL_MUTE("redischat.mutechannel"),
CHANNEL_HIDE_PREFIX("redischat.hidechannel."),
CHANNEL_SHOW_PREFIX("redischat.showchannel."),
JOIN_QUIT("redischat.joinquit"),
CHAT_COLOR("redischat.chatcolorcommand"),
SET_PLACEHOLDER("redischat.setchatplaceholder"),
Expand Down
62 changes: 53 additions & 9 deletions src/main/java/dev/unnm3d/redischat/RedisChat.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import dev.unnm3d.redischat.permission.PermissionProvider;
import dev.unnm3d.redischat.permission.VaultPermissionProvider;
import dev.unnm3d.redischat.settings.Config;
import dev.unnm3d.redischat.settings.FiltersConfig;
import dev.unnm3d.redischat.settings.GuiSettings;
import dev.unnm3d.redischat.settings.Messages;
import dev.unnm3d.redischat.task.AnnouncerManager;
Expand Down Expand Up @@ -59,9 +60,7 @@ public final class RedisChat extends JavaPlugin {
private static RedisChat instance;
@Getter
private static TaskScheduler scheduler;
public Config config;
private List<String> registeredCommands;
public Messages messages;
private List<CommandAPICommand> registeredCommands;
public GuiSettings guiSettings;
@Getter
private DataManager dataManager;
Expand Down Expand Up @@ -90,6 +89,11 @@ public final class RedisChat extends JavaPlugin {
@Getter
private MailGUIManager mailGUIManager;

public Config config;
public FiltersConfig filterSettings;
public Messages messages;


@Override
public void onLoad() {
CommandAPI.onLoad(new CommandAPIBukkitConfig(this)
Expand Down Expand Up @@ -149,6 +153,7 @@ public void onEnable() {
if (config.enableStaffChat)
loadCommandAPICommand(new StaffChatCommand(this).getCommand());


this.channelManager = new ChannelManager(this);
loadCommandAPICommand(new ChannelCommand(this).getCommand());

Expand Down Expand Up @@ -255,7 +260,28 @@ public void loadYML() throws ConfigurationException {
.charset(StandardCharsets.UTF_8)
.build()
);
this.config.validateConfig();
if (this.config.validateConfig())
YamlConfigurations.save(configFile, Config.class, this.config);

Path filtersFile = new File(getDataFolder(), "filters.yml").toPath();
this.filterSettings = YamlConfigurations.update(
filtersFile,
FiltersConfig.class,
YamlConfigurationProperties.newBuilder()
.header("""
How to configure filters:
enabled: true/false # If the filter is enabled at all
priority: 1 # The priority of the filter
audienceWhitelist: # The audience type of the filter (who is the target of the filter)
- DISCORD
- PLAYER #Private messages
- CHANNEL #Channel messages
channelWhitelist: [] # Which channels are affected by the filter, leave empty for all channels

""")
.charset(StandardCharsets.UTF_8)
.build()
);

Path messagesFile = new File(getDataFolder(), "messages.yml").toPath();
this.messages = YamlConfigurations.update(
Expand All @@ -267,7 +293,6 @@ public void loadYML() throws ConfigurationException {
.charset(StandardCharsets.UTF_8)
.build()
);
this.messages.validateConfig();

Path guiSettingsFile = new File(getDataFolder(), "guis.yml").toPath();
this.guiSettings = YamlConfigurations.update(
Expand All @@ -279,11 +304,19 @@ public void loadYML() throws ConfigurationException {
.charset(StandardCharsets.UTF_8)
.build()
);
this.guiSettings.validateConfig();
if (this.guiSettings.validateConfig())
YamlConfigurations.save(guiSettingsFile, GuiSettings.class, this.guiSettings);
}

public void saveMessages() {
YamlConfigurations.save(new File(this.getDataFolder(), "messages.yml").toPath(), Messages.class, messages);
YamlConfigurations.save(
new File(this.getDataFolder(), "messages.yml").toPath(),
Messages.class,
messages,
YamlConfigurationProperties.newBuilder()
.header("RedisChat messages")
.footer("Authors: Unnm3d")
.build());
}

public void saveGuiSettings() {
Expand All @@ -297,13 +330,24 @@ public void saveGuiSettings() {
.build());
}

public void saveFilters() {
YamlConfigurations.save(
new File(this.getDataFolder(), "filters.yml").toPath(),
FiltersConfig.class,
filterSettings,
YamlConfigurationProperties.newBuilder()
.header("RedisChat filters")
.footer("Authors: Unnm3d")
.build());
}

@Override
public void onDisable() {
getLogger().warning("RedisChat is disabling...");
if (this.dataManager != null)
this.dataManager.clearInvShareCache();

registeredCommands.forEach(command -> CommandAPI.unregister(command, true));
registeredCommands.forEach(command -> CommandAPI.unregister(command.getName(), true));
CommandAPI.onDisable();

if (this.playerListManager != null)
Expand Down Expand Up @@ -337,7 +381,7 @@ private void loadCommandAPICommand(CommandAPICommand commandAPICommand) {

CommandAPI.unregister(commandAPICommand.getName(), true);
commandAPICommand.register();
registeredCommands.add(commandAPICommand.getName());
registeredCommands.add(commandAPICommand);
getLogger().info("Command " + commandAPICommand.getName() + " registered on CommandAPI!");
}

Expand Down
17 changes: 6 additions & 11 deletions src/main/java/dev/unnm3d/redischat/api/DataManager.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package dev.unnm3d.redischat.api;

import dev.unnm3d.redischat.channels.Channel;
import dev.unnm3d.redischat.channels.PlayerChannel;
import dev.unnm3d.redischat.chat.ChatMessageInfo;
import dev.unnm3d.redischat.chat.objects.Channel;
import dev.unnm3d.redischat.chat.objects.ChatMessage;
import dev.unnm3d.redischat.mail.Mail;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.io.BukkitObjectInputStream;
import org.bukkit.util.io.BukkitObjectOutputStream;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
Expand All @@ -24,9 +22,7 @@ public interface DataManager {

void unregisterChannel(@NotNull String channelName);

CompletionStage<@Nullable String> getActivePlayerChannel(@NotNull String playerName, Map<String, Channel> registeredChannels);

CompletionStage<List<PlayerChannel>> getPlayerChannelStatuses(@NotNull String playerName, Map<String, Channel> registeredChannels);
CompletionStage<String> getActivePlayerChannel(@NotNull String playerName, Map<String, Channel> registeredChannels);

CompletionStage<List<Channel>> getChannels();

Expand Down Expand Up @@ -70,9 +66,7 @@ public interface DataManager {

CompletionStage<Boolean> deleteMail(@NotNull Mail mail);

void setPlayerChannelStatuses(@NotNull String playerName, @NotNull Map<String, String> channelStatuses);

void removePlayerChannelStatus(@NotNull String playerName, @NotNull String channelName);
void setActivePlayerChannel(String playerName, String channelName);

void setMutedEntities(@NotNull String playerName, @NotNull Set<String> mutedChannels);

Expand All @@ -82,7 +76,7 @@ public interface DataManager {

void setWhitelistEnabledPlayer(@NotNull String playerName, boolean enabled);

void sendChatMessage(@NotNull ChatMessageInfo chatMessage);
void sendChatMessage(@NotNull ChatMessage chatMessage);

void publishPlayerList(@NotNull List<String> playerNames);

Expand Down Expand Up @@ -137,4 +131,5 @@ default Map<String, String> deserializePlayerPlaceholders(String source) {
.collect(Collectors.toMap(strings -> strings[0], strings -> strings[1]));
}


}
Loading