Temporary fix for displaying login messages on join

This commit is contained in:
Telesphoreo 2024-04-28 12:52:21 -05:00
parent 357683a0f6
commit 068dd28fd4
2 changed files with 66 additions and 1 deletions

View file

@ -109,7 +109,6 @@ public class Plex extends JavaPlugin
commands.load(false);
sqlConnection = new SQLConnection();
// mongoConnection = new MongoConnection();
redisConnection = new RedisConnection();
playerCache = new PlayerCache();
@ -153,6 +152,13 @@ public class Plex extends JavaPlugin
PlexLog.debug("Not hooking into Prism");
}
if (PlexUtils.hasVanishPlugin())
{
PlexLog.log("Hooked into SuperVanish / PremiumVanish!");
} else {
PlexLog.debug("Not hooking into SuperVanish / PremiumVanish");
}
updateChecker = new UpdateChecker();
PlexLog.log("Update checking enabled");

View file

@ -0,0 +1,59 @@
package dev.plex.command.impl;
import com.google.common.collect.ImmutableList;
import dev.plex.cache.DataUtils;
import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.exception.PlayerNotFoundException;
import dev.plex.command.source.RequiredCommandSource;
import dev.plex.meta.PlayerMeta;
import dev.plex.player.PlexPlayer;
import dev.plex.util.PlexUtils;
import net.kyori.adventure.text.Component;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
@CommandPermissions(permission = "plex.broadcastloginmessage", source = RequiredCommandSource.ANY)
@CommandParameters(name = "bcastloginmessage", usage = "/<command> <player>", description = "Broadcast your login message (for vanish support)", aliases = "bcastlm")
public class BcastLoginMessageCMD extends PlexCommand
{
@Override
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
{
if (args.length == 0)
{
return usage();
}
PlexPlayer plexPlayer = DataUtils.getPlayer(args[0]);
if (plexPlayer == null)
{
throw new PlayerNotFoundException();
}
String loginMessage = PlayerMeta.getLoginMessage(plexPlayer);
if (!loginMessage.isEmpty())
{
PlexUtils.broadcast(PlexUtils.stringToComponent(loginMessage));
PlexUtils.broadcast(mmString("<yellow>" + plexPlayer.getName() + " joined the game"));
}
else
{
return mmString("<red>This player does not have a login message.");
}
return null;
}
@Override
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
{
return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? PlexUtils.getPlayerNameList() : ImmutableList.of();
}
}