From 3083f98cf6ea0c8584a2aa56cdc2ce0f1fee92bf Mon Sep 17 00:00:00 2001 From: yaohunya <1763917516@qq.com> Date: Sun, 10 Aug 2025 04:06:13 +0800 Subject: [PATCH] 2.0.2 --- src/main/java/com/yaohun/pvpprotect/PvpMain.java | 3 ++- .../com/yaohun/pvpprotect/api/ProtectAPI.java | 16 ++++++++++++++++ .../com/yaohun/pvpprotect/config/Config.java | 4 ++-- .../pvpprotect/listener/PlayerListener.java | 2 ++ src/main/resources/plugin.yml | 2 +- 5 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/yaohun/pvpprotect/api/ProtectAPI.java diff --git a/src/main/java/com/yaohun/pvpprotect/PvpMain.java b/src/main/java/com/yaohun/pvpprotect/PvpMain.java index 910d20b..7f69cb8 100644 --- a/src/main/java/com/yaohun/pvpprotect/PvpMain.java +++ b/src/main/java/com/yaohun/pvpprotect/PvpMain.java @@ -26,9 +26,10 @@ public class PvpMain extends JavaPlugin { getServer().getPluginManager().registerEvents(new OperateGui(), this); getServer().getPluginManager().registerEvents(new PlayerListener(), this); - Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> { + /*Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> { getPlayerManager().carryOutCheckTime(); },100L,20L * 60); + */ DataRefreshUtil.createRefreshDataRecord("PvpProtectDaily"); } diff --git a/src/main/java/com/yaohun/pvpprotect/api/ProtectAPI.java b/src/main/java/com/yaohun/pvpprotect/api/ProtectAPI.java new file mode 100644 index 0000000..3142674 --- /dev/null +++ b/src/main/java/com/yaohun/pvpprotect/api/ProtectAPI.java @@ -0,0 +1,16 @@ +package com.yaohun.pvpprotect.api; + +import com.yaohun.pvpprotect.PvpMain; +import com.yaohun.pvpprotect.manage.PlayerManager; + +public class ProtectAPI { + + // 判断玩家是否开启竞技保护 + public static boolean hasPvpProtect(String playerName) { + PlayerManager playerManager = PvpMain.getPlayerManager(); + if (playerManager.isPlayerOpened(playerName)) { + return true; + } + return false; + } +} diff --git a/src/main/java/com/yaohun/pvpprotect/config/Config.java b/src/main/java/com/yaohun/pvpprotect/config/Config.java index 2b65684..bd185e7 100644 --- a/src/main/java/com/yaohun/pvpprotect/config/Config.java +++ b/src/main/java/com/yaohun/pvpprotect/config/Config.java @@ -12,7 +12,7 @@ import java.util.HashMap; public class Config { - public static int default_hour = 12; + public static final int default_hour = 24; public static LangData langData; private static HashMap guiItemDataMap = new HashMap<>(); @@ -22,7 +22,7 @@ public class Config { plugin.reloadConfig(); plugin.saveConfig(); FileConfiguration config = plugin.getConfig(); - default_hour = config.getInt("DefaultHour",12); + // default_hour = config.getInt("DefaultHour",12); loadGuiItemData(config); } diff --git a/src/main/java/com/yaohun/pvpprotect/listener/PlayerListener.java b/src/main/java/com/yaohun/pvpprotect/listener/PlayerListener.java index 2f1f960..0d939f0 100644 --- a/src/main/java/com/yaohun/pvpprotect/listener/PlayerListener.java +++ b/src/main/java/com/yaohun/pvpprotect/listener/PlayerListener.java @@ -59,6 +59,7 @@ public class PlayerListener implements Listener { } } + /* @EventHandler public void onBossDiscover(EntityDamageByEntityEvent e) { if (!(e.getDamager() instanceof Player)) { @@ -82,4 +83,5 @@ public class PlayerListener implements Listener { } } } + */ } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index f628fab..58b84a4 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: DemonPvpProtect main: com.yaohun.pvpprotect.PvpMain -version: 2.0.0 +version: 2.0.2 author: yaohun commands: pvp: \ No newline at end of file