mirror of
https://github.com/plexusorg/Module-Guilds.git
synced 2025-07-01 07:06:41 +00:00
Compatibility with newer versions of Plex
This commit is contained in:
@ -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
|
||||
{
|
||||
@ -33,22 +30,14 @@ public class Guilds extends PlexModule
|
||||
@Override
|
||||
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);
|
||||
Plex.get().getMongoConnection().getDatastore().ensureIndexes();
|
||||
}
|
||||
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());
|
||||
});
|
||||
}
|
||||
PlexLog.debug("Finished loading {0} guilds", guilds.size());
|
||||
guilds.forEach(guildHolder::addGuild);
|
||||
this.registerCommand(new GuildCommand());
|
||||
});
|
||||
|
||||
//Plex.get().setChat(new ChatHandlerImpl());
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -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()));
|
||||
});
|
||||
|
@ -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"));
|
||||
|
@ -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..."));
|
||||
}
|
||||
|
@ -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()))
|
||||
|
@ -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()
|
||||
|
@ -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"));
|
||||
|
@ -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);
|
||||
|
@ -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"));
|
||||
|
@ -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()
|
||||
|
@ -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()))
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
@ -38,7 +40,7 @@ public class GuildHolder
|
||||
|
||||
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()
|
||||
|
@ -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());
|
||||
|
@ -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());
|
||||
|
@ -1,4 +1,4 @@
|
||||
name: Module-Guilds
|
||||
main: dev.plex.Guilds
|
||||
description: The guilds module for Plex
|
||||
version: 1.3
|
||||
version: 1.4-SNAPSHOT
|
Reference in New Issue
Block a user