From b800ceea8d5525f79348c0a666024c7bcb4c9f5e Mon Sep 17 00:00:00 2001
From: tianyu <32282861@qq.com>
Date: Wed, 24 Jul 2024 06:22:55 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=89=88?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.gitignore | 40 +++++++++++
pom.xml | 42 ++++++++++++
src/main/java/me/Demon/DemonJoinPro/Main.java | 43 ++++++++++++
.../DemonJoinPro/listener/PlayerJoin.java | 67 +++++++++++++++++++
.../me/Demon/DemonJoinPro/util/ConfigYml.java | 62 +++++++++++++++++
src/main/resources/config.yml | 32 +++++++++
src/main/resources/plugin.yml | 7 ++
7 files changed, 293 insertions(+)
create mode 100644 .gitignore
create mode 100644 pom.xml
create mode 100644 src/main/java/me/Demon/DemonJoinPro/Main.java
create mode 100644 src/main/java/me/Demon/DemonJoinPro/listener/PlayerJoin.java
create mode 100644 src/main/java/me/Demon/DemonJoinPro/util/ConfigYml.java
create mode 100644 src/main/resources/config.yml
create mode 100644 src/main/resources/plugin.yml
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..c037f46
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,40 @@
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### IntelliJ IDEA ###
+.idea/modules.xml
+.idea/jarRepositories.xml
+.idea/compiler.xml
+.idea/libraries/
+*.iws
+*.iml
+*.ipr
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
+/.idea/
+/out/
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..82e5eed
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,42 @@
+
+
+ 4.0.0
+
+ org.example
+ DemonJoinPro
+ 1.0-SNAPSHOT
+
+
+ 8
+ 8
+ UTF-8
+
+
+
+
+ public-rpg
+ https://repo.aurora-pixels.com/repository/public-rpg/
+
+
+
+
+
+ org.spigotmc
+ spigot-api
+ 1.12.2
+
+
+ me.clip.placeholderapi
+ PlaceholderAPI
+ 2.9.2
+
+
+ me.Demon.DemonPlugin
+ DemonAPI
+ 1.2.0
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/me/Demon/DemonJoinPro/Main.java b/src/main/java/me/Demon/DemonJoinPro/Main.java
new file mode 100644
index 0000000..f435fc7
--- /dev/null
+++ b/src/main/java/me/Demon/DemonJoinPro/Main.java
@@ -0,0 +1,43 @@
+package me.Demon.DemonJoinPro;
+
+import me.Demon.DemonJoinPro.listener.PlayerJoin;
+import me.Demon.DemonJoinPro.util.ConfigYml;
+import org.bukkit.Bukkit;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+import org.bukkit.plugin.java.JavaPlugin;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Main extends JavaPlugin {
+
+ public static String pluginName = "DemonJoinPro";
+ public static Main plugin;
+ public static String prefix = "§7[§6战争领域§7] §f";
+ public static List Today_Motd = new ArrayList<>();
+
+ @Override
+ public void onEnable() {
+ plugin = this;
+ saveDefaultConfig();
+ ConfigYml.init(getConfig());
+ Bukkit.getServer().getPluginManager().registerEvents(new PlayerJoin(), plugin);
+ Bukkit.getConsoleSender().sendMessage("§6[" + Main.pluginName + "] §f插件加載成功!");
+ Bukkit.getConsoleSender().sendMessage("§6[" + Main.pluginName + "] §f作者QQ:1763917516");
+ }
+
+ @Override
+ public void onDisable() {
+ Bukkit.getConsoleSender().sendMessage("§6[" + Main.pluginName + "] §f插件已安全卸載!");
+ }
+
+ public boolean onCommand(CommandSender sender, Command cmd, String Command, String[] args) {
+ if (Command.equalsIgnoreCase("djoin") && sender.isOp()) {
+ if (args.length == 0) {
+
+ }
+ }
+ return false;
+ }
+}
diff --git a/src/main/java/me/Demon/DemonJoinPro/listener/PlayerJoin.java b/src/main/java/me/Demon/DemonJoinPro/listener/PlayerJoin.java
new file mode 100644
index 0000000..5c03757
--- /dev/null
+++ b/src/main/java/me/Demon/DemonJoinPro/listener/PlayerJoin.java
@@ -0,0 +1,67 @@
+package me.Demon.DemonJoinPro.listener;
+
+import me.Demon.DemonJoinPro.Main;
+import me.Demon.DemonJoinPro.util.ConfigYml;
+import me.Demon.DemonPlugin.DemonAPI;
+import me.clip.placeholderapi.PlaceholderAPI;
+import org.bukkit.Bukkit;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.player.PlayerJoinEvent;
+import org.bukkit.event.player.PlayerQuitEvent;
+
+import java.util.List;
+
+public class PlayerJoin implements Listener {
+
+ @EventHandler
+ public void onjoin(PlayerJoinEvent e){
+ Player player = e.getPlayer();
+ e.setJoinMessage(null);
+ if (ConfigYml.firstjoin_enabled){
+ if (!player.hasPlayedBefore()) {
+ String message = ConfigYml.firstjoin_actions;
+ message = PlaceholderAPI.setPlaceholders(player, message);
+ Bukkit.broadcastMessage(message.replace("&", "§"));
+
+ Bukkit.getScheduler().runTaskLater(Main.plugin, () -> {
+ player.performCommand("spawn");
+ }, (long) 10L);
+ }
+ }
+
+ if(ConfigYml.motds_enabled){
+ if(!Main.Today_Motd.contains(player.getName())) {
+ Main.Today_Motd.add(player.getName());
+ List motds_List = ConfigYml.motds_actions;
+ for (String message : motds_List) {
+ player.sendMessage(message.replace("&", "§"));
+ }
+ }
+ }
+
+ if(ConfigYml.join_enabled){
+ String message = ConfigYml.join_actions;
+ message = PlaceholderAPI.setPlaceholders(player, message);
+ for (Player all : Bukkit.getOnlinePlayers()) {
+ DemonAPI.sendActionBar(all,message.replace("&", "§"));
+ }
+ }
+
+ }
+
+ @EventHandler
+ public void onLeave(PlayerQuitEvent e){
+ Player player = e.getPlayer();
+ e.setQuitMessage(null);
+ if(ConfigYml.leave_enabled){
+ String message = ConfigYml.leave_actions;
+ message = PlaceholderAPI.setPlaceholders(player, message);
+ for (Player all : Bukkit.getOnlinePlayers()) {
+ DemonAPI.sendActionBar(all,message.replace("&", "§"));
+ }
+ }
+ }
+
+}
diff --git a/src/main/java/me/Demon/DemonJoinPro/util/ConfigYml.java b/src/main/java/me/Demon/DemonJoinPro/util/ConfigYml.java
new file mode 100644
index 0000000..4d0ac79
--- /dev/null
+++ b/src/main/java/me/Demon/DemonJoinPro/util/ConfigYml.java
@@ -0,0 +1,62 @@
+package me.Demon.DemonJoinPro.util;
+
+import org.bukkit.configuration.file.FileConfiguration;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ConfigYml {
+
+ private static FileConfiguration yml;
+
+ public static boolean join_enabled;
+ public static boolean leave_enabled;
+ public static boolean firstjoin_enabled;
+ public static boolean motds_enabled;
+ public static String join_actions;
+ public static String leave_actions;
+ public static String firstjoin_actions;
+ public static List motds_actions;
+
+
+ public static void init(FileConfiguration config) {
+ yml = config;
+ join_enabled = yml.getBoolean("join.enabled");
+ if(join_enabled){
+ String message = yml.getString("join.actions");
+ if(message != null) {
+ join_actions = message.replace("&", "§");
+ }else{
+ join_actions = "";
+ }
+ }
+ leave_enabled = yml.getBoolean("leave.enabled");
+ if(leave_enabled){
+ String message = yml.getString("leave.actions");
+ if(message != null) {
+ leave_actions = message.replace("&", "§");
+ }else{
+ leave_actions = "";
+ }
+ }
+ firstjoin_enabled = yml.getBoolean("firstjoin.enabled");
+ if(firstjoin_enabled){
+ String message = yml.getString("firstjoin.actions");
+ if(message != null) {
+ firstjoin_actions = message.replace("&", "§");
+ }else{
+ firstjoin_actions = "";
+ }
+ }
+ motds_enabled = yml.getBoolean("motds.enabled");
+ if(motds_enabled){
+ String message = yml.getString("motds.actions");
+ if(message != null) {
+ motds_actions = yml.getStringList("motds.actions");
+ }else{
+ motds_actions = new ArrayList<>();
+ }
+ }
+ }
+
+}
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
new file mode 100644
index 0000000..8a3ad2c
--- /dev/null
+++ b/src/main/resources/config.yml
@@ -0,0 +1,32 @@
+join:
+ enabled: true
+ actions: '§7[§a§L●§7] %vault_prefix%§f%player_name%'
+leave:
+ enabled: true
+ actions: '§7[§c§L●§7] %vault_prefix%§f%player_name%'
+firstjoin:
+ enabled: true
+ actions:
+ - '§7[§c§L迎新公告§7] §f欢迎 %vault_prefix%§f%player_name% §f第一次进入帝国战争Mix伺服器~!'
+motds:
+ enabled: true
+ actions:
+ - '§6§l帝国战争§C§lMix'
+ - '§7'
+ - '§7*欢迎忧患帝国战争服务器。'
+ - '§7'
+ - '§7服务器规则:'
+ - '§c1.禁止在伺服器里向任何玩家乞讨'
+ - '§c2.禁止在服务器引起骂战/嘴炮'
+ - '§c3.禁止使用外挂端进行游玩'
+ - '§c4.禁止抢/偷其他玩家的物品'
+ - '§c5.禁止发现Bug而没有回报给管理员'
+ - '§c6.禁止在伺服器里宣传其他伺服器'
+ - '§c7.禁止在别家服务器宣传我们服务器'
+ - '§c8.禁止开分身账号刷取物品'
+ - '§c9.禁止在服务器里制作连闪器'
+ - '§c10.禁止在副本里刻意抢他人怪物'
+ - '§c11.禁止骚扰其他玩家及乱杀其他玩家'
+ - '§4§l如违反以上规则,违重者永久ban处理.'
+ - '§c'
+ - '§7*有任何问题可以找在线管理员。'
\ No newline at end of file
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
new file mode 100644
index 0000000..44582ba
--- /dev/null
+++ b/src/main/resources/plugin.yml
@@ -0,0 +1,7 @@
+name: DemonJoinPro
+main: me.Demon.DemonJoinPro.Main
+version: 1.0.1
+depend:
+ - PlaceholderAPI
+commands:
+ djoin:
\ No newline at end of file