From a9c9979b1c12d0a88c771ee4584d15f3661df4f1 Mon Sep 17 00:00:00 2001 From: Video Date: Tue, 10 Aug 2021 04:06:41 -0600 Subject: [PATCH 1/3] FS-218 --- .../totalfreedommod/LoginProcess.java | 17 +++++++++++++++++ .../totalfreedommod/config/ConfigEntry.java | 1 + src/main/resources/config.yml | 6 ++++++ 3 files changed, 24 insertions(+) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java b/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java index 015cb064..6b655a59 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java @@ -19,6 +19,7 @@ import org.bukkit.event.player.AsyncPlayerPreLoginEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.scheduler.BukkitTask; public class LoginProcess extends FreedomService { @@ -190,6 +191,22 @@ public class LoginProcess extends FreedomService final FPlayer fPlayer = plugin.pl.getPlayer(player); final PlayerData playerData = plugin.pl.getData(player); + // Sends a message to the player if they have never joined before (or simply lack player data). + if (!event.getPlayer().hasPlayedBefore()) + { + final BukkitTask runnable = new BukkitRunnable() + { + @Override + public void run() + { + for (String line : ConfigEntry.FIRST_JOIN_INFO.getStringList()) + { + player.sendMessage(FUtil.colorize(line)); + } + } + }.runTaskLater(plugin, 20); + } + player.sendTitle(FUtil.colorize(ConfigEntry.SERVER_LOGIN_TITLE.getString()), FUtil.colorize(ConfigEntry.SERVER_LOGIN_SUBTITLE.getString()), 20, 100, 60); player.setOp(true); diff --git a/src/main/java/me/totalfreedom/totalfreedommod/config/ConfigEntry.java b/src/main/java/me/totalfreedom/totalfreedommod/config/ConfigEntry.java index 05051905..2eca28be 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/config/ConfigEntry.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/config/ConfigEntry.java @@ -165,6 +165,7 @@ public enum ConfigEntry ADMIN_INFO(List.class, "admininfo"), VOTING_INFO(List.class, "votinginfo"), MASTER_BUILDER_INFO(List.class, "masterbuilderinfo"), + FIRST_JOIN_INFO(List.class, "first_join_info"), AUTO_ENTITY_WIPE(Boolean.class, "auto_wipe"), TOGGLE_CHAT(Boolean.class, "toggle_chat"), DEVELOPER_MODE(Boolean.class, "developer_mode"), diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 3780220d..4c2a39ba 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -590,6 +590,12 @@ masterbuilderinfo: - ' &2- Template:' - '&9https://forum.totalfreedom.me/d/336-master-builder-application-process' +# What new players will see upon joining for the first time. +first_join_info: + - "&6Welcome to TotalFreedom -- the original Free-OP server!" + - "&eThe server's name doesn't mean we have no rules. Do &6/rules &efor a list of them." + - "&aNeed help getting started? Do &2/help &aor a list of commands!" + # Famous players - cannot be banned by username famous_players: - honeydew From 871acc2eeb929423f3e4a7fda253da6642497546 Mon Sep 17 00:00:00 2001 From: Video Date: Tue, 10 Aug 2021 04:13:23 -0600 Subject: [PATCH 2/3] Actually, let's make it possible to disable it if needed --- .../me/totalfreedom/totalfreedommod/LoginProcess.java | 2 +- .../totalfreedom/totalfreedommod/config/ConfigEntry.java | 3 ++- src/main/resources/config.yml | 8 +++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java b/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java index 6b655a59..0a1f56dd 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java @@ -192,7 +192,7 @@ public class LoginProcess extends FreedomService final PlayerData playerData = plugin.pl.getData(player); // Sends a message to the player if they have never joined before (or simply lack player data). - if (!event.getPlayer().hasPlayedBefore()) + if (!event.getPlayer().hasPlayedBefore() && ConfigEntry.FIRST_JOIN_INFO_ENABLED.getBoolean()) { final BukkitTask runnable = new BukkitRunnable() { diff --git a/src/main/java/me/totalfreedom/totalfreedommod/config/ConfigEntry.java b/src/main/java/me/totalfreedom/totalfreedommod/config/ConfigEntry.java index 2eca28be..021f30f1 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/config/ConfigEntry.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/config/ConfigEntry.java @@ -165,7 +165,8 @@ public enum ConfigEntry ADMIN_INFO(List.class, "admininfo"), VOTING_INFO(List.class, "votinginfo"), MASTER_BUILDER_INFO(List.class, "masterbuilderinfo"), - FIRST_JOIN_INFO(List.class, "first_join_info"), + FIRST_JOIN_INFO(List.class, "first_join_info.text"), + FIRST_JOIN_INFO_ENABLED(Boolean.class, "first_join_info.enabled"), AUTO_ENTITY_WIPE(Boolean.class, "auto_wipe"), TOGGLE_CHAT(Boolean.class, "toggle_chat"), DEVELOPER_MODE(Boolean.class, "developer_mode"), diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 4c2a39ba..bba2c44a 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -592,9 +592,11 @@ masterbuilderinfo: # What new players will see upon joining for the first time. first_join_info: - - "&6Welcome to TotalFreedom -- the original Free-OP server!" - - "&eThe server's name doesn't mean we have no rules. Do &6/rules &efor a list of them." - - "&aNeed help getting started? Do &2/help &aor a list of commands!" + enabled: true + text: + - "&6Welcome to TotalFreedom -- the original Free-OP server!" + - "&eThe server's name doesn't mean we have no rules. Do &6/rules &efor a list of them." + - "&aNeed help getting started? Do &2/help &aor a list of commands!" # Famous players - cannot be banned by username famous_players: From 3f89f3f48e578705f5c516e2af039e2bf4c7d7af Mon Sep 17 00:00:00 2001 From: Video Date: Tue, 10 Aug 2021 06:58:04 -0600 Subject: [PATCH 3/3] Shut the fuck up Codacy --- src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java b/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java index 0a1f56dd..64700e61 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java @@ -194,7 +194,7 @@ public class LoginProcess extends FreedomService // Sends a message to the player if they have never joined before (or simply lack player data). if (!event.getPlayer().hasPlayedBefore() && ConfigEntry.FIRST_JOIN_INFO_ENABLED.getBoolean()) { - final BukkitTask runnable = new BukkitRunnable() + new BukkitRunnable() { @Override public void run()