Compatibility with newer versions of Plex

This commit is contained in:
Telesphoreo 2023-09-08 17:40:39 -05:00
parent 3929141fff
commit c1d1be2987
27 changed files with 109 additions and 138 deletions

View file

@ -1,33 +1,8 @@
<component name="ProjectCodeStyleConfiguration"> <component name="ProjectCodeStyleConfiguration">
<code_scheme name="Plexus Code Style" version="1"> <code_scheme name="Plexus Code Style" version="173">
<JavaCodeStyleSettings>
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="20" />
<option name="IMPORT_LAYOUT_TABLE">
<value>
<package name="" withSubpackages="true" static="false" />
<package name="" withSubpackages="true" static="true" />
</value>
</option>
</JavaCodeStyleSettings>
<JetCodeStyleSettings>
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
<value>
<package name="java.util" alias="false" withSubpackages="false" />
<package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
<package name="io.ktor" alias="false" withSubpackages="true" />
</value>
</option>
<option name="PACKAGES_IMPORT_LAYOUT">
<value>
<package name="" alias="false" withSubpackages="true" />
<package name="java" alias="false" withSubpackages="true" />
<package name="javax" alias="false" withSubpackages="true" />
<package name="kotlin" alias="false" withSubpackages="true" />
<package name="" alias="true" withSubpackages="true" />
</value>
</option>
</JetCodeStyleSettings>
<codeStyleSettings language="JAVA"> <codeStyleSettings language="JAVA">
<option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
<option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" />
<option name="BRACE_STYLE" value="2" /> <option name="BRACE_STYLE" value="2" />
<option name="CLASS_BRACE_STYLE" value="2" /> <option name="CLASS_BRACE_STYLE" value="2" />
<option name="METHOD_BRACE_STYLE" value="2" /> <option name="METHOD_BRACE_STYLE" value="2" />
@ -36,14 +11,10 @@
<option name="WHILE_ON_NEW_LINE" value="true" /> <option name="WHILE_ON_NEW_LINE" value="true" />
<option name="CATCH_ON_NEW_LINE" value="true" /> <option name="CATCH_ON_NEW_LINE" value="true" />
<option name="FINALLY_ON_NEW_LINE" value="true" /> <option name="FINALLY_ON_NEW_LINE" value="true" />
<option name="SPACE_AFTER_TYPE_CAST" value="true" />
<option name="IF_BRACE_FORCE" value="3" /> <option name="IF_BRACE_FORCE" value="3" />
<option name="DOWHILE_BRACE_FORCE" value="3" /> <option name="DOWHILE_BRACE_FORCE" value="3" />
<option name="WHILE_BRACE_FORCE" value="3" /> <option name="WHILE_BRACE_FORCE" value="3" />
<option name="FOR_BRACE_FORCE" value="3" /> <option name="FOR_BRACE_FORCE" value="3" />
<option name="BLANK_LINES_AFTER_CLASS_HEADER" value="0" />
<option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" />
<option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
</codeStyleSettings> </codeStyleSettings>
</code_scheme> </code_scheme>
</component> </component>

View file

@ -1,24 +1,37 @@
For those who are wanting to contribute, we fully encourage doing so. There are a few rules we require following when contributing however. For those who are wanting to contribute, we fully encourage doing so. There are a few rules we require following when
contributing however.
## Steps ## Steps
1. Make an issue and get feedback. It's important to know if your idea will be accepted before writing any code. 1. Make an issue and get feedback. It's important to know if your idea will be accepted before writing any code.
- If it is a feature request, describe the feature and be extremely specific. - If it is a feature request, describe the feature and be extremely specific.
- If it is a bug report, ensure you include how to reproduce the bug and the expected outcome - If it is a bug report, ensure you include how to reproduce the bug and the expected outcome
- If it is an enhancement, describe your proposed changes. Ensure you are extremely specific. - If it is an enhancement, describe your proposed changes. Ensure you are extremely specific.
2. Fork this project 2. Fork this project
3. Create a new branch that describes the new feature, enhancement, or bug fix. For example, this is good: `feature/add-xyz`. This is bad: `fix-this-lol`. 3. Create a new branch that describes the new feature, enhancement, or bug fix. For example, this is
good: `feature/add-xyz`. This is bad: `fix-this-lol`.
4. Write the code that addresses your change. 4. Write the code that addresses your change.
- Keep in mind that it **must** be formatted correctly. If you are using IntelliJ, there is a `codeStyle.xml` file that tells IntelliJ how to format your code. Check this link for information on how to use the file: https://www.jetbrains.com/help/idea/configuring-code-style.html#import-export-schemes
- If you are not using IntelliJ, that is fine. We use the Plexus Code Style (which is almost the same as Allman) so please format your code accordingly. - Keep in mind that it **must** be formatted correctly. If you are using IntelliJ, there is a `codeStyle.xml` file that
tells IntelliJ how to format your code. Check this link for information on how to use the
file: https://www.jetbrains.com/help/idea/configuring-code-style.html#import-export-schemes
- If you are not using IntelliJ, that is fine. We use the Plexus Code Style (which is almost the same as Allman) so
please format your code accordingly.
6. Push your changes to your new branch and make a PR based off of that branch. 6. Push your changes to your new branch and make a PR based off of that branch.
## Requirements for a PR ## Requirements for a PR
- The issue must be marked as approved - The issue must be marked as approved
- It must only address each specific issue. Don't make one PR for multiple issues. - It must only address each specific issue. Don't make one PR for multiple issues.
- Your PR must compile and work. If it does not compile or work, your PR will most likely be rejected. - Your PR must compile and work. If it does not compile or work, your PR will most likely be rejected.
## Code requirements ## Code requirements
- Most importantly, your code must be efficient. Your pull request may be rejected if your code is deemed inefficient or sloppy.
- Most importantly, your code must be efficient. Your pull request may be rejected if your code is deemed inefficient or
sloppy.
- Do not repeat yourself. Create functions as needed if you're using large blocks of code over and over again. - Do not repeat yourself. Create functions as needed if you're using large blocks of code over and over again.
- Do not use an excessive amount of commits when making your PR. It makes the master branch look messy. - Do not use an excessive amount of commits when making your PR. It makes the master branch look messy.
- Your code must be consistent with Plex's codebase. If a function already exists, use it. - Your code must be consistent with Plex's codebase. If a function already exists, use it.

View file

@ -1,2 +1,3 @@
# Module-Guilds [![Build Status](https://ci.plex.us.org/job/Module-Guilds/badge/icon)](https://ci.plex.us.org/job/Module-Guilds/) # Module-Guilds [![Build Status](https://ci.plex.us.org/job/Module-Guilds/badge/icon)](https://ci.plex.us.org/job/Module-Guilds/)
The Guilds module for Plex The Guilds module for Plex

View file

@ -20,14 +20,13 @@ dependencies {
annotationProcessor("org.projectlombok:lombok:1.18.28") annotationProcessor("org.projectlombok:lombok:1.18.28")
compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT") compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")
implementation("org.apache.commons:commons-lang3:3.12.0") implementation("org.apache.commons:commons-lang3:3.12.0")
compileOnly("dev.plex:server:1.3") compileOnly("dev.plex:server:1.4-SNAPSHOT")
compileOnly("dev.morphia.morphia:morphia-core:2.3.5")
compileOnly("org.json:json:20230618") compileOnly("org.json:json:20230618")
implementation("org.jetbrains:annotations:24.0.1") implementation("org.jetbrains:annotations:24.0.1")
} }
group = "dev.plex" group = "dev.plex"
version = "1.3" version = "1.4-SNAPSHOT"
description = "The Guilds module for Plex" description = "The Guilds module for Plex"
java { java {
@ -43,7 +42,7 @@ publishing {
} }
tasks.getByName<Jar>("jar") { tasks.getByName<Jar>("jar") {
archiveBaseName.set("Plex-Guilds") archiveBaseName.set("Module-Guilds")
archiveVersion.set("") archiveVersion.set("")
} }

Binary file not shown.

View file

@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
networkTimeout=10000 networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

12
gradlew vendored
View file

@ -85,9 +85,6 @@ done
APP_BASE_NAME=${0##*/} APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# 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"'
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum MAX_FD=maximum
@ -133,10 +130,13 @@ location of your Java installation."
fi fi
else else
JAVACMD=java JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the Please set the JAVA_HOME variable in your environment to match the
location of your Java installation." location of your Java installation."
fi
fi fi
# Increase the maximum file descriptors if we can. # Increase the maximum file descriptors if we can.
@ -197,6 +197,10 @@ if "$cygwin" || "$msys" ; then
done done
fi 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; # Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in # shell script including quotes and variable substitutions, so put them in

View file

@ -4,14 +4,11 @@ import dev.plex.command.GuildCommand;
import dev.plex.config.ModuleConfig; import dev.plex.config.ModuleConfig;
import dev.plex.data.SQLGuildManager; import dev.plex.data.SQLGuildManager;
import dev.plex.data.SQLManager; import dev.plex.data.SQLManager;
import dev.plex.guild.Guild;
import dev.plex.guild.GuildHolder; import dev.plex.guild.GuildHolder;
import dev.plex.module.PlexModule; import dev.plex.module.PlexModule;
import dev.plex.storage.StorageType;
import dev.plex.util.PlexLog; import dev.plex.util.PlexLog;
import lombok.Getter; import lombok.Getter;
//TODO: Implement mongodb
@Getter @Getter
public class Guilds extends PlexModule public class Guilds extends PlexModule
{ {
@ -33,22 +30,14 @@ public class Guilds extends PlexModule
@Override @Override
public void enable() public void enable()
{ {
if (Plex.get().getStorageType() == StorageType.MONGODB) SQLManager.makeTables();
sqlGuildManager = new SQLGuildManager();
sqlGuildManager.getGuilds().whenComplete((guilds, throwable) ->
{ {
Plex.get().getMongoConnection().getDatastore().getMapper().map(Guild.class); PlexLog.debug("Finished loading {0} guilds", guilds.size());
Plex.get().getMongoConnection().getDatastore().ensureIndexes(); guilds.forEach(guildHolder::addGuild);
} this.registerCommand(new GuildCommand());
else });
{
SQLManager.makeTables();
sqlGuildManager = new SQLGuildManager();
sqlGuildManager.getGuilds().whenComplete((guilds, throwable) ->
{
PlexLog.debug("Finished loading {0} guilds", guilds.size());
guilds.forEach(guildHolder::addGuild);
this.registerCommand(new GuildCommand());
});
}
//Plex.get().setChat(new ChatHandlerImpl()); //Plex.get().setChat(new ChatHandlerImpl());

View file

@ -6,7 +6,6 @@ import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions; import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.source.RequiredCommandSource; import dev.plex.command.source.RequiredCommandSource;
import dev.plex.command.sub.*; import dev.plex.command.sub.*;
import dev.plex.rank.enums.Rank;
import dev.plex.util.GuildUtil; import dev.plex.util.GuildUtil;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.event.ClickEvent;
@ -22,7 +21,7 @@ import java.util.List;
import java.util.Locale; import java.util.Locale;
@CommandParameters(name = "guild", description = "Guild menu", aliases = "guilds,g") @CommandParameters(name = "guild", description = "Guild menu", aliases = "guilds,g")
@CommandPermissions(level = Rank.OP, permission = "plex.guilds.guild") @CommandPermissions(permission = "plex.guilds.guild")
public class GuildCommand extends PlexCommand public class GuildCommand extends PlexCommand
{ {
private final List<PlexCommand> subCommands = Lists.newArrayList(); private final List<PlexCommand> subCommands = Lists.newArrayList();
@ -42,7 +41,8 @@ public class GuildCommand extends PlexCommand
this.registerSubCommand(new HomeSubCommand()); this.registerSubCommand(new HomeSubCommand());
this.registerSubCommand(new OwnerSubCommand()); this.registerSubCommand(new OwnerSubCommand());
this.registerSubCommand(new InviteSubCommand()); this.registerSubCommand(new InviteSubCommand());
} catch (Exception e) }
catch (Exception e)
{ {
GuildUtil.throwExceptionSync(e); GuildUtil.throwExceptionSync(e);
} }
@ -71,7 +71,6 @@ public class GuildCommand extends PlexCommand
.append(mmString("<gold>Command Aliases: <yellow>" + StringUtils.join(subCommand.getAliases(), ", "))).append(Component.newline()) .append(mmString("<gold>Command Aliases: <yellow>" + StringUtils.join(subCommand.getAliases(), ", "))).append(Component.newline())
.append(mmString("<gold>Description: <yellow>" + subCommand.getDescription())).append(Component.newline()) .append(mmString("<gold>Description: <yellow>" + subCommand.getDescription())).append(Component.newline())
.append(mmString("<gold>Permission: <yellow>" + permissions.permission())).append(Component.newline()) .append(mmString("<gold>Permission: <yellow>" + permissions.permission())).append(Component.newline())
.append(mmString("<gold>Required Rank: <yellow>" + permissions.level().name())).append(Component.newline())
.append(mmString("<gold>Required Source: <yellow>" + permissions.source().name())); .append(mmString("<gold>Required Source: <yellow>" + permissions.source().name()));
} }
PlexCommand subCommand = getSubCommand(args[0]); PlexCommand subCommand = getSubCommand(args[0]);
@ -91,7 +90,7 @@ public class GuildCommand extends PlexCommand
return messageComponent("noPermissionConsole"); return messageComponent("noPermissionConsole");
} }
checkRank(player, permissions.level(), permissions.permission()); checkPermission(player, permissions.permission());
return subCommand.execute(commandSender, player, Arrays.copyOfRange(args, 1, args.length)); return subCommand.execute(commandSender, player, Arrays.copyOfRange(args, 1, args.length));
} }

View file

@ -6,8 +6,6 @@ import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions; import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.source.RequiredCommandSource; import dev.plex.command.source.RequiredCommandSource;
import dev.plex.guild.data.Member; import dev.plex.guild.data.Member;
import dev.plex.rank.enums.Rank;
import dev.plex.util.PlexLog;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -20,7 +18,7 @@ import org.jetbrains.annotations.Nullable;
import java.util.Objects; import java.util.Objects;
@CommandParameters(name = "chat", usage = "/guild <command> [message]", description = "Toggles guild chat or sends a guild chat message") @CommandParameters(name = "chat", usage = "/guild <command> [message]", description = "Toggles guild chat or sends a guild chat message")
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.chat") @CommandPermissions(source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.chat")
public class ChatSubCommand extends PlexCommand public class ChatSubCommand extends PlexCommand
{ {
public ChatSubCommand() public ChatSubCommand()

View file

@ -6,7 +6,6 @@ import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions; import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.source.RequiredCommandSource; import dev.plex.command.source.RequiredCommandSource;
import dev.plex.guild.Guild; import dev.plex.guild.Guild;
import dev.plex.rank.enums.Rank;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -15,13 +14,14 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@CommandParameters(name = "create", aliases = "make", usage = "/guild <command> <name>", description = "Creates a guild with a specified name") @CommandParameters(name = "create", aliases = "make", usage = "/guild <command> <name>", description = "Creates a guild with a specified name")
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.create") @CommandPermissions(source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.create")
public class CreateSubCommand extends PlexCommand public class CreateSubCommand extends PlexCommand
{ {
public CreateSubCommand() public CreateSubCommand()
{ {
super(false); super(false);
} }
@Override @Override
protected Component execute(@NotNull CommandSender commandSender, @Nullable Player player, @NotNull String[] args) protected Component execute(@NotNull CommandSender commandSender, @Nullable Player player, @NotNull String[] args)
{ {
@ -34,7 +34,8 @@ public class CreateSubCommand extends PlexCommand
{ {
return messageComponent("alreadyInGuild"); return messageComponent("alreadyInGuild");
} }
Guilds.get().getSqlGuildManager().insertGuild(Guild.create(player, StringUtils.join(args, " "))).whenComplete((guild, throwable) -> { Guilds.get().getSqlGuildManager().insertGuild(Guild.create(player, StringUtils.join(args, " "))).whenComplete((guild, throwable) ->
{
Guilds.get().getGuildHolder().addGuild(guild); Guilds.get().getGuildHolder().addGuild(guild);
send(player, mmString("Created guild named " + guild.getName())); send(player, mmString("Created guild named " + guild.getName()));
}); });

View file

@ -5,27 +5,27 @@ import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters; import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions; import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.source.RequiredCommandSource; import dev.plex.command.source.RequiredCommandSource;
import dev.plex.rank.enums.Rank;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@CommandParameters(name = "home", aliases = "spawn", usage = "/guild <command>", description = "Teleports to the guild home") @CommandParameters(name = "home", aliases = "spawn", usage = "/guild <command>", description = "Teleports to the guild home")
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.home") @CommandPermissions(source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.home")
public class HomeSubCommand extends PlexCommand public class HomeSubCommand extends PlexCommand
{ {
public HomeSubCommand() public HomeSubCommand()
{ {
super(false); super(false);
} }
@Override @Override
protected Component execute(@NotNull CommandSender commandSender, @Nullable Player player, @NotNull String[] args) protected Component execute(@NotNull CommandSender commandSender, @Nullable Player player, @NotNull String[] args)
{ {
assert player != null; assert player != null;
Guilds.get().getGuildHolder().getGuild(player.getUniqueId()).ifPresentOrElse(guild -> { Guilds.get().getGuildHolder().getGuild(player.getUniqueId()).ifPresentOrElse(guild ->
{
if (guild.getHome() == null) if (guild.getHome() == null)
{ {
send(player, messageComponent("guildHomeNotFound")); send(player, messageComponent("guildHomeNotFound"));

View file

@ -6,7 +6,6 @@ import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters; import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions; import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.source.RequiredCommandSource; import dev.plex.command.source.RequiredCommandSource;
import dev.plex.rank.enums.Rank;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -17,10 +16,9 @@ import org.jetbrains.annotations.Nullable;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.List; import java.util.List;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
@CommandParameters(name = "info", aliases = "information", usage = "/guild <command>", description = "Shows the guild's information") @CommandParameters(name = "info", aliases = "information", usage = "/guild <command>", description = "Shows the guild's information")
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.info") @CommandPermissions(source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.info")
public class InfoSubCommand extends PlexCommand public class InfoSubCommand extends PlexCommand
{ {
public InfoSubCommand() public InfoSubCommand()
@ -43,7 +41,8 @@ public class InfoSubCommand extends PlexCommand
try try
{ {
send(player, mmString("<gold>Owner: <yellow>" + DataUtils.getPlayer(guild.getOwner().getUuid(), false).getName())); send(player, mmString("<gold>Owner: <yellow>" + DataUtils.getPlayer(guild.getOwner().getUuid(), false).getName()));
} catch (NullPointerException e) }
catch (NullPointerException e)
{ {
send(player, mmString("<gold>Owner: <yellow>Unable to load cache...")); send(player, mmString("<gold>Owner: <yellow>Unable to load cache..."));
} }

View file

@ -9,7 +9,6 @@ import dev.plex.command.source.RequiredCommandSource;
import dev.plex.guild.Guild; import dev.plex.guild.Guild;
import dev.plex.guild.GuildHolder; import dev.plex.guild.GuildHolder;
import dev.plex.guild.data.Member; import dev.plex.guild.data.Member;
import dev.plex.rank.enums.Rank;
import dev.plex.util.PlexLog; import dev.plex.util.PlexLog;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -27,7 +26,7 @@ import java.util.stream.Collectors;
// TODO: 5/9/2022 deny members from inviting themselves or existing members in the current guild // TODO: 5/9/2022 deny members from inviting themselves or existing members in the current guild
@CommandParameters(name = "invite", aliases = "inv", usage = "/guild <command> <player name>", description = "Invites a player to the guild") @CommandParameters(name = "invite", aliases = "inv", usage = "/guild <command> <player name>", description = "Invites a player to the guild")
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.invite") @CommandPermissions(source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.invite")
public class InviteSubCommand extends PlexCommand public class InviteSubCommand extends PlexCommand
{ {
public InviteSubCommand() public InviteSubCommand()
@ -68,7 +67,8 @@ public class InviteSubCommand extends PlexCommand
send(player, messageComponent("guildDisbandNeeded")); send(player, messageComponent("guildDisbandNeeded"));
continueCheck.set(false); continueCheck.set(false);
return; return;
} else }
else
{ {
Guilds.get().getSqlGuildManager().deleteGuild(guild1.getGuildUuid()).whenComplete((unused, throwable) -> Guilds.get().getSqlGuildManager().deleteGuild(guild1.getGuildUuid()).whenComplete((unused, throwable) ->
{ {
@ -118,8 +118,14 @@ public class InviteSubCommand extends PlexCommand
@Override @Override
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
{ {
if (!(sender instanceof Player player)) return ImmutableList.of(); if (!(sender instanceof Player player))
if (args.length == 0) return ImmutableList.of(); {
return ImmutableList.of();
}
if (args.length == 0)
{
return ImmutableList.of();
}
if (args[0].equalsIgnoreCase("accept") && args.length == 2) if (args[0].equalsIgnoreCase("accept") && args.length == 2)
{ {
if (!GuildHolder.PENDING_INVITES.containsKey(player.getUniqueId())) if (!GuildHolder.PENDING_INVITES.containsKey(player.getUniqueId()))

View file

@ -8,7 +8,6 @@ import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.source.RequiredCommandSource; import dev.plex.command.source.RequiredCommandSource;
import dev.plex.guild.data.Member; import dev.plex.guild.data.Member;
import dev.plex.player.PlexPlayer; import dev.plex.player.PlexPlayer;
import dev.plex.rank.enums.Rank;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -16,7 +15,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@CommandParameters(name = "owner", aliases = "setowner", usage = "/guild <command> <player name>", description = "Sets the guild owner") @CommandParameters(name = "owner", aliases = "setowner", usage = "/guild <command> <player name>", description = "Sets the guild owner")
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.owner") @CommandPermissions(source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.owner")
public class OwnerSubCommand extends PlexCommand public class OwnerSubCommand extends PlexCommand
{ {
public OwnerSubCommand() public OwnerSubCommand()

View file

@ -5,14 +5,8 @@ import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters; import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions; import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.source.RequiredCommandSource; import dev.plex.command.source.RequiredCommandSource;
import dev.plex.guild.Guild;
import dev.plex.rank.enums.Rank;
import dev.plex.util.PlexUtils;
import dev.plex.util.minimessage.SafeMiniMessage; import dev.plex.util.minimessage.SafeMiniMessage;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import net.kyori.adventure.text.minimessage.tag.standard.StandardTags;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -20,13 +14,14 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@CommandParameters(name = "prefix", aliases = "tag,settag,setprefix", usage = "/guild <command> <prefix>", description = "Sets the guild's default prefix") @CommandParameters(name = "prefix", aliases = "tag,settag,setprefix", usage = "/guild <command> <prefix>", description = "Sets the guild's default prefix")
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.prefix") @CommandPermissions(source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.prefix")
public class PrefixSubCommand extends PlexCommand public class PrefixSubCommand extends PlexCommand
{ {
public PrefixSubCommand() public PrefixSubCommand()
{ {
super(false); super(false);
} }
@Override @Override
protected Component execute(@NotNull CommandSender commandSender, @Nullable Player player, @NotNull String[] args) protected Component execute(@NotNull CommandSender commandSender, @Nullable Player player, @NotNull String[] args)
{ {
@ -35,7 +30,8 @@ public class PrefixSubCommand extends PlexCommand
return usage(); return usage();
} }
assert player != null; assert player != null;
Guilds.get().getGuildHolder().getGuild(player.getUniqueId()).ifPresentOrElse(guild -> { Guilds.get().getGuildHolder().getGuild(player.getUniqueId()).ifPresentOrElse(guild ->
{
if (!guild.getOwner().getUuid().equals(player.getUniqueId())) if (!guild.getOwner().getUuid().equals(player.getUniqueId()))
{ {
send(player, messageComponent("guildNotOwner")); send(player, messageComponent("guildNotOwner"));

View file

@ -5,7 +5,6 @@ import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters; import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions; import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.source.RequiredCommandSource; import dev.plex.command.source.RequiredCommandSource;
import dev.plex.rank.enums.Rank;
import dev.plex.util.CustomLocation; import dev.plex.util.CustomLocation;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -14,10 +13,9 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@CommandParameters(name = "sethome", aliases = "setspawn", usage = "/guild <command>", description = "Sets the guild's home") @CommandParameters(name = "sethome", aliases = "setspawn", usage = "/guild <command>", description = "Sets the guild's home")
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.sethome") @CommandPermissions(source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.sethome")
public class SetHomeSubCommand extends PlexCommand public class SetHomeSubCommand extends PlexCommand
{ {
public SetHomeSubCommand() public SetHomeSubCommand()
{ {
super(false); super(false);

View file

@ -5,9 +5,7 @@ import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters; import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions; import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.source.RequiredCommandSource; import dev.plex.command.source.RequiredCommandSource;
import dev.plex.rank.enums.Rank;
import dev.plex.util.CustomLocation; import dev.plex.util.CustomLocation;
import dev.plex.util.minimessage.SafeMiniMessage;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -16,17 +14,16 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.Locale; import java.util.Locale;
import java.util.regex.Pattern;
@CommandParameters(name = "setwarp", aliases = "makewarp,createwarp", usage = "/guild <command> <name>", description = "Creates a new warp at player's location with a specified name") @CommandParameters(name = "setwarp", aliases = "makewarp,createwarp", usage = "/guild <command> <name>", description = "Creates a new warp at player's location with a specified name")
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.setwarp") @CommandPermissions(source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.setwarp")
public class SetWarpSubCommand extends PlexCommand public class SetWarpSubCommand extends PlexCommand
{ {
public SetWarpSubCommand() public SetWarpSubCommand()
{ {
super(false); super(false);
} }
@Override @Override
protected Component execute(@NotNull CommandSender commandSender, @Nullable Player player, @NotNull String[] args) protected Component execute(@NotNull CommandSender commandSender, @Nullable Player player, @NotNull String[] args)
{ {
@ -35,7 +32,8 @@ public class SetWarpSubCommand extends PlexCommand
return usage(); return usage();
} }
assert player != null; assert player != null;
Guilds.get().getGuildHolder().getGuild(player.getUniqueId()).ifPresentOrElse(guild -> { Guilds.get().getGuildHolder().getGuild(player.getUniqueId()).ifPresentOrElse(guild ->
{
if (!guild.getOwner().getUuid().equals(player.getUniqueId())) if (!guild.getOwner().getUuid().equals(player.getUniqueId()))
{ {
send(player, messageComponent("guildNotOwner")); send(player, messageComponent("guildNotOwner"));

View file

@ -7,10 +7,7 @@ import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions; import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.source.RequiredCommandSource; import dev.plex.command.source.RequiredCommandSource;
import dev.plex.guild.Guild; import dev.plex.guild.Guild;
import dev.plex.rank.enums.Rank;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -20,7 +17,7 @@ import java.util.List;
import java.util.Set; import java.util.Set;
@CommandParameters(name = "warps", aliases = "listwarps", usage = "/guild <command>", description = "Displays a clickable list of warps") @CommandParameters(name = "warps", aliases = "listwarps", usage = "/guild <command>", description = "Displays a clickable list of warps")
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.warps") @CommandPermissions(source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.warps")
public class WarpListSubCommand extends PlexCommand public class WarpListSubCommand extends PlexCommand
{ {
public WarpListSubCommand() public WarpListSubCommand()

View file

@ -5,8 +5,6 @@ import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters; import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions; import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.source.RequiredCommandSource; import dev.plex.command.source.RequiredCommandSource;
import dev.plex.rank.enums.Rank;
import dev.plex.util.CustomLocation;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -15,13 +13,14 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@CommandParameters(name = "warp", aliases = "goto", usage = "/guild <command> <name>", description = "Warps to a specified guild warp") @CommandParameters(name = "warp", aliases = "goto", usage = "/guild <command> <name>", description = "Warps to a specified guild warp")
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.warp") @CommandPermissions(source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.warp")
public class WarpSubCommand extends PlexCommand public class WarpSubCommand extends PlexCommand
{ {
public WarpSubCommand() public WarpSubCommand()
{ {
super(false); super(false);
} }
@Override @Override
protected Component execute(@NotNull CommandSender commandSender, @Nullable Player player, @NotNull String[] args) protected Component execute(@NotNull CommandSender commandSender, @Nullable Player player, @NotNull String[] args)
{ {
@ -30,7 +29,8 @@ public class WarpSubCommand extends PlexCommand
return usage(); return usage();
} }
assert player != null; assert player != null;
Guilds.get().getGuildHolder().getGuild(player.getUniqueId()).ifPresentOrElse(guild -> { Guilds.get().getGuildHolder().getGuild(player.getUniqueId()).ifPresentOrElse(guild ->
{
String warpName = StringUtils.join(args, " "); String warpName = StringUtils.join(args, " ");
if (!guild.getWarps().containsKey(warpName.toLowerCase())) if (!guild.getWarps().containsKey(warpName.toLowerCase()))
{ {

View file

@ -55,7 +55,8 @@ public class SQLGuildManager
statement.setBoolean(14, guild.isPublic()); statement.setBoolean(14, guild.isPublic());
statement.execute(); statement.execute();
return guild; return guild;
} catch (SQLException e) }
catch (SQLException e)
{ {
GuildUtil.throwExceptionSync(e); GuildUtil.throwExceptionSync(e);
return null; return null;
@ -72,7 +73,8 @@ public class SQLGuildManager
PreparedStatement statement = connection.prepareStatement(DELETE_GUILD); PreparedStatement statement = connection.prepareStatement(DELETE_GUILD);
statement.setString(1, uuid.toString()); statement.setString(1, uuid.toString());
statement.execute(); statement.execute();
} catch (SQLException e) }
catch (SQLException e)
{ {
GuildUtil.throwExceptionSync(e); GuildUtil.throwExceptionSync(e);
} }
@ -101,7 +103,8 @@ public class SQLGuildManager
statement.setString(13, guild.getGuildUuid().toString()); statement.setString(13, guild.getGuildUuid().toString());
statement.executeUpdate(); statement.executeUpdate();
return guild; return guild;
} catch (SQLException e) }
catch (SQLException e)
{ {
GuildUtil.throwExceptionSync(e); GuildUtil.throwExceptionSync(e);
return null; return null;
@ -143,7 +146,8 @@ public class SQLGuildManager
guild.setPublic(set.getBoolean("isPublic")); guild.setPublic(set.getBoolean("isPublic"));
guilds.add(guild); guilds.add(guild);
} }
} catch (SQLException e) }
catch (SQLException e)
{ {
GuildUtil.throwExceptionSync(e); GuildUtil.throwExceptionSync(e);
} }

View file

@ -1,7 +1,6 @@
package dev.plex.data; package dev.plex.data;
import dev.plex.Plex; import dev.plex.Plex;
import dev.plex.storage.StorageType;
import java.sql.Connection; import java.sql.Connection;
import java.sql.SQLException; import java.sql.SQLException;
@ -10,11 +9,6 @@ public class SQLManager
{ {
public static void makeTables() public static void makeTables()
{ {
if (Plex.get().getStorageType() == StorageType.MONGODB)
{
return;
}
try (Connection connection = Plex.get().getSqlConnection().getCon()) try (Connection connection = Plex.get().getSqlConnection().getCon())
{ {
connection.prepareStatement( connection.prepareStatement(
@ -36,10 +30,10 @@ public class SQLManager
"PRIMARY KEY (`guildUuid`)" + "PRIMARY KEY (`guildUuid`)" +
");" ");"
).execute(); ).execute();
} catch (SQLException e) }
catch (SQLException e)
{ {
e.printStackTrace(); e.printStackTrace();
} }
} }
} }

View file

@ -2,8 +2,6 @@ package dev.plex.guild;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import dev.morphia.annotations.Entity;
import dev.morphia.annotations.Transient;
import dev.plex.Plex; import dev.plex.Plex;
import dev.plex.guild.data.Member; import dev.plex.guild.data.Member;
import dev.plex.guild.data.Rank; import dev.plex.guild.data.Rank;
@ -15,10 +13,11 @@ import org.bukkit.entity.Player;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.util.*; import java.util.List;
import java.util.Map;
import java.util.UUID;
@Data @Data
@Entity("guilds")
public class Guild public class Guild
{ {
private final UUID guildUuid; private final UUID guildUuid;

View file

@ -20,7 +20,9 @@ public class GuildHolder
if (PENDING_INVITES.containsKey(uuid)) if (PENDING_INVITES.containsKey(uuid))
{ {
PENDING_INVITES.get(uuid).add(guild); PENDING_INVITES.get(uuid).add(guild);
} else { }
else
{
PENDING_INVITES.put(uuid, Lists.newArrayList(guild)); PENDING_INVITES.put(uuid, Lists.newArrayList(guild));
} }
return true; return true;
@ -38,7 +40,7 @@ public class GuildHolder
public Optional<Guild> getGuild(UUID uuid) public Optional<Guild> getGuild(UUID uuid)
{ {
return GUILDS.stream().filter(guild -> (guild.getOwner() != null && guild.getOwner().getUuid().equals(uuid)) || guild.getMembers().stream().map(Member::getUuid).toList().contains(uuid)).findFirst(); return GUILDS.stream().filter(guild -> (guild.getOwner() != null && guild.getOwner().getUuid().equals(uuid)) || guild.getMembers().stream().map(Member::getUuid).toList().contains(uuid)).findFirst();
} }
public Collection<Guild> getGuilds() public Collection<Guild> getGuilds()

View file

@ -3,14 +3,12 @@ package dev.plex.handler;
import dev.plex.Guilds; import dev.plex.Guilds;
import dev.plex.Plex; import dev.plex.Plex;
import dev.plex.guild.data.Member; import dev.plex.guild.data.Member;
import dev.plex.hook.VaultHook;
import dev.plex.player.PlexPlayer; import dev.plex.player.PlexPlayer;
import dev.plex.util.PlexUtils; import dev.plex.util.PlexUtils;
import dev.plex.util.minimessage.SafeMiniMessage; import dev.plex.util.minimessage.SafeMiniMessage;
import io.papermc.paper.chat.ChatRenderer; import io.papermc.paper.chat.ChatRenderer;
import io.papermc.paper.event.player.AsyncChatEvent; import io.papermc.paper.event.player.AsyncChatEvent;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import net.kyori.adventure.audience.Audience; import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextReplacementConfig; import net.kyori.adventure.text.TextReplacementConfig;
@ -25,6 +23,10 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
public class ChatHandlerImpl public class ChatHandlerImpl
{ {
private final static TextReplacementConfig URL_REPLACEMENT_CONFIG = TextReplacementConfig.builder().match("(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]").replacement((matchResult, builder) -> Component.empty().content(matchResult.group()).clickEvent(ClickEvent.openUrl(matchResult.group()))).build(); private final static TextReplacementConfig URL_REPLACEMENT_CONFIG = TextReplacementConfig.builder().match("(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]").replacement((matchResult, builder) -> Component.empty().content(matchResult.group()).clickEvent(ClickEvent.openUrl(matchResult.group()))).build();
@ -66,7 +68,7 @@ public class ChatHandlerImpl
String text = PlexUtils.getTextFromComponent(message); String text = PlexUtils.getTextFromComponent(message);
PlexPlayer plexPlayer = Plex.get().getPlayerCache().getPlexPlayerMap().get(source.getUniqueId()); PlexPlayer plexPlayer = Plex.get().getPlayerCache().getPlexPlayerMap().get(source.getUniqueId());
Component prefix = Plex.get().getRankManager().getPrefix(plexPlayer); Component prefix = VaultHook.getPrefix(plexPlayer);
AtomicBoolean guildPrefix = new AtomicBoolean(false); AtomicBoolean guildPrefix = new AtomicBoolean(false);
AtomicReference<Component> component = new AtomicReference<>(Component.empty()); AtomicReference<Component> component = new AtomicReference<>(Component.empty());

View file

@ -10,6 +10,7 @@ public class CustomLocation
private final String worldName; private final String worldName;
private final double x, y, z; private final double x, y, z;
private final float yaw, pitch; private final float yaw, pitch;
public static CustomLocation fromLocation(Location location) public static CustomLocation fromLocation(Location location)
{ {
return new CustomLocation(location.getWorld().getName(), location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); return new CustomLocation(location.getWorld().getName(), location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());

View file

@ -1,4 +1,4 @@
name: Module-Guilds name: Module-Guilds
main: dev.plex.Guilds main: dev.plex.Guilds
description: The guilds module for Plex description: The guilds module for Plex
version: 1.3 version: 1.4-SNAPSHOT