mirror of
https://gitlab.com/SamB440/rpgregions-2.git
synced 2025-12-28 19:29:16 +00:00
Add a welcome message on install
This commit is contained in:
@@ -75,6 +75,7 @@ import org.bukkit.potion.PotionEffect;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.logging.Level;
|
||||
@@ -107,6 +108,8 @@ public final class RPGRegions extends JavaPlugin implements IRPGRegionsAPI {
|
||||
|
||||
private Translator translator;
|
||||
|
||||
private boolean firstTimeSetup;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
this.adventure = BukkitAudiences.create(this);
|
||||
@@ -180,11 +183,22 @@ public final class RPGRegions extends JavaPlugin implements IRPGRegionsAPI {
|
||||
}
|
||||
|
||||
private void createConfig() {
|
||||
final File setupFile = firstTimeSetupFile();
|
||||
firstTimeSetup = !setupFile.exists();
|
||||
|
||||
saveDefaultConfig(); // Moved to config.yml
|
||||
saveResource("integrations/lands.yml", false);
|
||||
saveResource("integrations/custom-structures.yml", false);
|
||||
}
|
||||
|
||||
public File firstTimeSetupFile() {
|
||||
return new File(this.getDataFolder() + File.separator + "integration" + File.separator + ".setup");
|
||||
}
|
||||
|
||||
public boolean isFirstTimeSetup() {
|
||||
return firstTimeSetup;
|
||||
}
|
||||
|
||||
private void registerListeners() {
|
||||
PluginManager pm = Bukkit.getPluginManager();
|
||||
pm.registerEvents(new ServerReloadListener(this), this);
|
||||
|
||||
@@ -2,6 +2,13 @@ package net.islandearth.rpgregions.listener;
|
||||
|
||||
import net.islandearth.rpgregions.RPGRegions;
|
||||
import net.islandearth.rpgregions.managers.data.account.RPGRegionsAccount;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -22,6 +29,43 @@ public record ConnectionListener(RPGRegions plugin) implements Listener {
|
||||
final Player player = event.getPlayer();
|
||||
if (!plugin.getManagers().getStorageManager().getCachedAccounts().synchronous().asMap().containsKey(player.getUniqueId())) {
|
||||
player.kickPlayer(ChatColor.RED + "Player user data not present! Please contact an administrator.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.isFirstTimeSetup() || plugin.getConfig().getBoolean("dev.always", true)) {
|
||||
final MiniMessage miniMessage = plugin.miniMessage();
|
||||
final Audience audience = plugin.adventure().player(player);
|
||||
// Don't know if this works with the programs used to remove this stuff
|
||||
// Don't care, just making an attempt, as I don't want people who haven't purchased the plugin to see the welcome screen.
|
||||
char[] obfChars = new char[]{'%', '%', '_', '_', 'U', 'S', 'E', 'R', '_', '_', '%', '%'};
|
||||
boolean valid = !String.valueOf(obfChars).equals("%%__USER__%%");
|
||||
if (valid) {
|
||||
if (!plugin.isFirstTimeSetup()) return;
|
||||
audience.sendMessage(Component.text("Welcome to RPGRegions v" + plugin.getDescription().getVersion() + "!", NamedTextColor.GOLD));
|
||||
audience.sendMessage(Component.text("Thank you for purchasing the plugin, your support is appreciated.", NamedTextColor.GREEN));
|
||||
audience.sendMessage(Component.empty());
|
||||
audience.sendMessage(miniMessage.deserialize(
|
||||
"<gradient:gold:yellow>As the plugin has been newly installed, you will need to:"));
|
||||
audience.sendMessage(miniMessage.deserialize("" +
|
||||
"<gradient:gold:yellow> - Set the correct region implementation you wish to use in the config.yml."));
|
||||
audience.sendMessage(miniMessage.deserialize(
|
||||
"<gradient:gold:yellow> - Setup a database if you will be dealing with high player counts." +
|
||||
" <red><bold>Note: Migration is currently not possible."));
|
||||
audience.sendMessage(Component.empty());
|
||||
audience.sendMessage(Component.text("If you have any questions, join our Discord for help: ", NamedTextColor.GOLD)
|
||||
.append(Component.text("https://discord.gg/fh62mxU", NamedTextColor.YELLOW, TextDecoration.UNDERLINED))
|
||||
.hoverEvent(HoverEvent.showText(Component.text("Click to open!", NamedTextColor.WHITE)))
|
||||
.clickEvent(ClickEvent.openUrl("https://discord.gg/fh62mxU")));
|
||||
audience.sendMessage(Component.text("This message will not show again after a restart.", NamedTextColor.GREEN));
|
||||
return;
|
||||
}
|
||||
|
||||
audience.sendMessage(Component.text("Welcome to RPGRegions v" + plugin.getDescription().getVersion() + "!", NamedTextColor.GOLD));
|
||||
audience.sendMessage(Component.text("The plugin is running in a development environment.", NamedTextColor.RED));
|
||||
if (!plugin.debug()) {
|
||||
plugin.getConfig().set("settings.dev.debug", true);
|
||||
plugin.markDebugDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ settings:
|
||||
dev:
|
||||
debug: false # Enables debug output. Will spam console!
|
||||
disable-slow-storage-warn: false # Should we send a warning if storage response times are slow?
|
||||
always: true
|
||||
integration:
|
||||
name: RPGRegions # Name of the integration: WorldGuard, Residence, GriefPrevention, GriefDefender, UltraRegions, Lands, RPGRegions
|
||||
external:
|
||||
|
||||
Reference in New Issue
Block a user