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">
<code_scheme name="Plexus Code Style" version="1">
<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>
<code_scheme name="Plexus Code Style" version="173">
<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="CLASS_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="CATCH_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="DOWHILE_BRACE_FORCE" value="3" />
<option name="WHILE_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>
</code_scheme>
</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
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 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.
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.
- 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.
## Requirements for a PR
- The issue must be marked as approved
- 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.
## 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 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.

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/)
The Guilds module for Plex

View File

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

Binary file not shown.

View File

@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
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
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

12
gradlew vendored
View File

@ -85,9 +85,6 @@ done
APP_BASE_NAME=${0##*/}
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.
MAX_FD=maximum
@ -133,10 +130,13 @@ location of your Java installation."
fi
else
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
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
@ -197,6 +197,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

View File

@ -4,14 +4,11 @@ import dev.plex.command.GuildCommand;
import dev.plex.config.ModuleConfig;
import dev.plex.data.SQLGuildManager;
import dev.plex.data.SQLManager;
import dev.plex.guild.Guild;
import dev.plex.guild.GuildHolder;
import dev.plex.module.PlexModule;
import dev.plex.storage.StorageType;
import dev.plex.util.PlexLog;
import lombok.Getter;
//TODO: Implement mongodb
@Getter
public class Guilds extends PlexModule
{
@ -32,13 +29,6 @@ public class Guilds extends PlexModule
@Override
public void enable()
{
if (Plex.get().getStorageType() == StorageType.MONGODB)
{
Plex.get().getMongoConnection().getDatastore().getMapper().map(Guild.class);
Plex.get().getMongoConnection().getDatastore().ensureIndexes();
}
else
{
SQLManager.makeTables();
sqlGuildManager = new SQLGuildManager();
@ -48,7 +38,6 @@ public class Guilds extends PlexModule
guilds.forEach(guildHolder::addGuild);
this.registerCommand(new GuildCommand());
});
}
//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.source.RequiredCommandSource;
import dev.plex.command.sub.*;
import dev.plex.rank.enums.Rank;
import dev.plex.util.GuildUtil;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickEvent;
@ -22,7 +21,7 @@ import java.util.List;
import java.util.Locale;
@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
{
private final List<PlexCommand> subCommands = Lists.newArrayList();
@ -42,7 +41,8 @@ public class GuildCommand extends PlexCommand
this.registerSubCommand(new HomeSubCommand());
this.registerSubCommand(new OwnerSubCommand());
this.registerSubCommand(new InviteSubCommand());
} catch (Exception e)
}
catch (Exception 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>Description: <yellow>" + subCommand.getDescription())).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()));
}
PlexCommand subCommand = getSubCommand(args[0]);
@ -91,7 +90,7 @@ public class GuildCommand extends PlexCommand
return messageComponent("noPermissionConsole");
}
checkRank(player, permissions.level(), permissions.permission());
checkPermission(player, permissions.permission());
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.source.RequiredCommandSource;
import dev.plex.guild.data.Member;
import dev.plex.rank.enums.Rank;
import dev.plex.util.PlexLog;
import net.kyori.adventure.text.Component;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
@ -20,7 +18,7 @@ import org.jetbrains.annotations.Nullable;
import java.util.Objects;
@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 ChatSubCommand()

View File

@ -6,7 +6,6 @@ import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.source.RequiredCommandSource;
import dev.plex.guild.Guild;
import dev.plex.rank.enums.Rank;
import net.kyori.adventure.text.Component;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.CommandSender;
@ -15,13 +14,14 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@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 CreateSubCommand()
{
super(false);
}
@Override
protected Component execute(@NotNull CommandSender commandSender, @Nullable Player player, @NotNull String[] args)
{
@ -34,7 +34,8 @@ public class CreateSubCommand extends PlexCommand
{
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);
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.CommandPermissions;
import dev.plex.command.source.RequiredCommandSource;
import dev.plex.rank.enums.Rank;
import net.kyori.adventure.text.Component;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@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 HomeSubCommand()
{
super(false);
}
@Override
protected Component execute(@NotNull CommandSender commandSender, @Nullable Player player, @NotNull String[] args)
{
assert player != null;
Guilds.get().getGuildHolder().getGuild(player.getUniqueId()).ifPresentOrElse(guild -> {
Guilds.get().getGuildHolder().getGuild(player.getUniqueId()).ifPresentOrElse(guild ->
{
if (guild.getHome() == null)
{
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.CommandPermissions;
import dev.plex.command.source.RequiredCommandSource;
import dev.plex.rank.enums.Rank;
import net.kyori.adventure.text.Component;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.CommandSender;
@ -17,10 +16,9 @@ import org.jetbrains.annotations.Nullable;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
@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 InfoSubCommand()
@ -43,7 +41,8 @@ public class InfoSubCommand extends PlexCommand
try
{
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..."));
}

View File

@ -9,7 +9,6 @@ import dev.plex.command.source.RequiredCommandSource;
import dev.plex.guild.Guild;
import dev.plex.guild.GuildHolder;
import dev.plex.guild.data.Member;
import dev.plex.rank.enums.Rank;
import dev.plex.util.PlexLog;
import net.kyori.adventure.text.Component;
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
@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 InviteSubCommand()
@ -68,7 +67,8 @@ public class InviteSubCommand extends PlexCommand
send(player, messageComponent("guildDisbandNeeded"));
continueCheck.set(false);
return;
} else
}
else
{
Guilds.get().getSqlGuildManager().deleteGuild(guild1.getGuildUuid()).whenComplete((unused, throwable) ->
{
@ -118,8 +118,14 @@ public class InviteSubCommand extends PlexCommand
@Override
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 (args.length == 0) return ImmutableList.of();
if (!(sender instanceof Player player))
{
return ImmutableList.of();
}
if (args.length == 0)
{
return ImmutableList.of();
}
if (args[0].equalsIgnoreCase("accept") && args.length == 2)
{
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.guild.data.Member;
import dev.plex.player.PlexPlayer;
import dev.plex.rank.enums.Rank;
import net.kyori.adventure.text.Component;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -16,7 +15,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@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 OwnerSubCommand()

View File

@ -5,14 +5,8 @@ import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions;
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 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.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -20,13 +14,14 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@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 PrefixSubCommand()
{
super(false);
}
@Override
protected Component execute(@NotNull CommandSender commandSender, @Nullable Player player, @NotNull String[] args)
{
@ -35,7 +30,8 @@ public class PrefixSubCommand extends PlexCommand
return usage();
}
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()))
{
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.CommandPermissions;
import dev.plex.command.source.RequiredCommandSource;
import dev.plex.rank.enums.Rank;
import dev.plex.util.CustomLocation;
import net.kyori.adventure.text.Component;
import org.bukkit.command.CommandSender;
@ -14,10 +13,9 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@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 SetHomeSubCommand()
{
super(false);

View File

@ -5,9 +5,7 @@ import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.source.RequiredCommandSource;
import dev.plex.rank.enums.Rank;
import dev.plex.util.CustomLocation;
import dev.plex.util.minimessage.SafeMiniMessage;
import net.kyori.adventure.text.Component;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.CommandSender;
@ -16,17 +14,16 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
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")
@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 SetWarpSubCommand()
{
super(false);
}
@Override
protected Component execute(@NotNull CommandSender commandSender, @Nullable Player player, @NotNull String[] args)
{
@ -35,7 +32,8 @@ public class SetWarpSubCommand extends PlexCommand
return usage();
}
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()))
{
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.source.RequiredCommandSource;
import dev.plex.guild.Guild;
import dev.plex.rank.enums.Rank;
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.entity.Player;
import org.jetbrains.annotations.NotNull;
@ -20,7 +17,7 @@ import java.util.List;
import java.util.Set;
@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 WarpListSubCommand()

View File

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

View File

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

View File

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

View File

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

View File

@ -20,7 +20,9 @@ public class GuildHolder
if (PENDING_INVITES.containsKey(uuid))
{
PENDING_INVITES.get(uuid).add(guild);
} else {
}
else
{
PENDING_INVITES.put(uuid, Lists.newArrayList(guild));
}
return true;

View File

@ -3,14 +3,12 @@ package dev.plex.handler;
import dev.plex.Guilds;
import dev.plex.Plex;
import dev.plex.guild.data.Member;
import dev.plex.hook.VaultHook;
import dev.plex.player.PlexPlayer;
import dev.plex.util.PlexUtils;
import dev.plex.util.minimessage.SafeMiniMessage;
import io.papermc.paper.chat.ChatRenderer;
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.text.Component;
import net.kyori.adventure.text.TextReplacementConfig;
@ -25,6 +23,10 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.jetbrains.annotations.NotNull;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
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();
@ -66,7 +68,7 @@ public class ChatHandlerImpl
String text = PlexUtils.getTextFromComponent(message);
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);
AtomicReference<Component> component = new AtomicReference<>(Component.empty());

View File

@ -10,6 +10,7 @@ public class CustomLocation
private final String worldName;
private final double x, y, z;
private final float yaw, pitch;
public static CustomLocation fromLocation(Location location)
{
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
main: dev.plex.Guilds
description: The guilds module for Plex
version: 1.3
version: 1.4-SNAPSHOT