use custom join messages
This commit is contained in:
@ -1,10 +1,7 @@
|
||||
package cc.fascinated.account;
|
||||
|
||||
import cc.fascinated.Aetheria;
|
||||
import cc.fascinated.config.Config;
|
||||
import cc.fascinated.config.Lang;
|
||||
import cc.fascinated.playercolor.PlayerColor;
|
||||
import cc.fascinated.utils.DiscordWebhook;
|
||||
import cc.fascinated.utils.Style;
|
||||
import lombok.Getter;
|
||||
import lombok.SneakyThrows;
|
||||
@ -18,7 +15,6 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
@Getter @Log4j2
|
||||
public class Account {
|
||||
|
@ -86,30 +86,32 @@ public class AccountManager extends Manager {
|
||||
@Override
|
||||
public void onPlayerJoin(Account account, PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (player.hasPlayedBefore()) {
|
||||
return;
|
||||
String joinMessage = Lang.JOIN_MESSAGE.getAsString();
|
||||
|
||||
if (!player.hasPlayedBefore()) {
|
||||
joinMessage = Lang.FIRST_JOIN_MESSAGE.getAsString();
|
||||
|
||||
// Send a notification to the discord log channel
|
||||
Aetheria.EXECUTOR.execute(() -> {
|
||||
// todo: re-code this it's so ugly
|
||||
DiscordWebhook discordWebhook = new DiscordWebhook(Config.DISCORD_LOG_WEBHOOK.getAsString());
|
||||
DiscordWebhook.EmbedObject embed = new DiscordWebhook.EmbedObject();
|
||||
embed.setTitle("New Player Joined");
|
||||
embed.addField("Name", player.getName(), true);
|
||||
embed.addField("UUID", player.getUniqueId().toString(), true);
|
||||
|
||||
discordWebhook.addEmbed(embed);
|
||||
try {
|
||||
discordWebhook.execute();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
event.joinMessage(null); // Remove the join message so we can send our own
|
||||
Bukkit.broadcast(Style.getMiniMessage().deserialize(Lang.FIRST_JOIN_MESSAGE.getAsString()
|
||||
event.joinMessage(Style.getMiniMessage().deserialize(joinMessage
|
||||
.replace("%player%", player.getName())
|
||||
.replace("player-color", account.getPlayerColorProfile().getColor().toString())
|
||||
));
|
||||
|
||||
Aetheria.EXECUTOR.execute(() -> {
|
||||
// todo: re-code this it's so ugly
|
||||
DiscordWebhook discordWebhook = new DiscordWebhook(Config.DISCORD_LOG_WEBHOOK.getAsString());
|
||||
DiscordWebhook.EmbedObject embed = new DiscordWebhook.EmbedObject();
|
||||
embed.setTitle("New Player Joined");
|
||||
embed.addField("Name", player.getName(), true);
|
||||
embed.addField("UUID", player.getUniqueId().toString(), true);
|
||||
|
||||
discordWebhook.addEmbed(embed);
|
||||
try {
|
||||
discordWebhook.execute();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -123,9 +125,13 @@ public class AccountManager extends Manager {
|
||||
|
||||
@Override
|
||||
public void onPlayerQuit(Account account, PlayerQuitEvent event) {
|
||||
account.save(true);
|
||||
account.save(true); // Save the account
|
||||
|
||||
ACCOUNTS.remove(account.getUuid());
|
||||
event.quitMessage(Style.getMiniMessage().deserialize(Lang.QUIT_MESSAGE.getAsString()
|
||||
.replace("%player%", event.getPlayer().getName())
|
||||
.replace("player-color", account.getPlayerColorProfile().getColor().toString())
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -26,7 +26,9 @@ public enum Lang {
|
||||
BLOCKED_MESSAGE("blocked-message"),
|
||||
BLOCKED_MESSAGE_ALERT("blocked-message-alert"),
|
||||
CHAT_FORMAT("chat-format"),
|
||||
FIRST_JOIN_MESSAGE("first-join-message");
|
||||
FIRST_JOIN_MESSAGE("first-join-message"),
|
||||
JOIN_MESSAGE("join-message"),
|
||||
QUIT_MESSAGE("quit-message");
|
||||
|
||||
/**
|
||||
* The path of the lang in the lang.yml file.
|
||||
|
@ -5,7 +5,9 @@ chat-format: "<<%chatcolor%>%name%</%chatcolor%>> <hover:show_text:Click to mess
|
||||
blocked-message: "<prefix><hover:show_text:%reason%><red>Your message has been blocked."
|
||||
blocked-message-alert: "<admin-prefix><red>%player% <grey>tried to send a blocked message: <white>%message%"
|
||||
|
||||
first-join-message: "<yellow>%player% <white>joined for the first time!"
|
||||
first-join-message: "<player-color>%player% <yellow>joined for the first time!"
|
||||
join-message: "<player-color>%player% <yellow>joined the game"
|
||||
quit-message: "<player-color>%player% <yellow>left the game"
|
||||
|
||||
help-command:
|
||||
- "<prefix>Commands:"
|
||||
|
Reference in New Issue
Block a user