diff --git a/src/main/java/com/sakurarealm/playerrisk/PlayerRisk.java b/src/main/java/com/sakurarealm/playerrisk/PlayerRisk.java index 312af99..451351b 100644 --- a/src/main/java/com/sakurarealm/playerrisk/PlayerRisk.java +++ b/src/main/java/com/sakurarealm/playerrisk/PlayerRisk.java @@ -13,6 +13,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; import java.util.*; @@ -21,6 +22,13 @@ public final class PlayerRisk extends JavaPlugin implements Listener { PlayerRiskManager playerRiskManager = null; + //假设的方法,您需要根据实际情况来实现它 + private String getCurrentBiome(Player player) { + //实现获取玩家当前所在生物群系的逻辑 + return player.getLocation().getBlock().getBiome().name(); + } + + public PlayerRiskManager getPlayerRiskManager() { if (playerRiskManager == null) { throw new NullPointerException("PlayerRisk plugin is not initialized."); @@ -52,6 +60,16 @@ public final class PlayerRisk extends JavaPlugin implements Listener { // Plugin shutdown logic } + /** + * 玩家退出游戏后从map集合中移出 + * @param event + */ + @EventHandler + public void playerOffOnline(PlayerQuitEvent event){ + Player player = event.getPlayer(); + playerRiskManager.removePlayerLevel(player.getName()); + getLogger().info(ChatColor.GREEN+player.getName()+"退出了游戏"); + } /** * TODO: 当玩家进入城镇时, 危险度不再增加. @@ -63,7 +81,7 @@ public final class PlayerRisk extends JavaPlugin implements Listener { //当玩家进入城镇后,移出map集合并且清零 Player player = event.getPlayer(); playerRiskManager.removePlayerLevel(player.getName()); - throw new NotImplementedException("Not implemented yet."); + } /** @@ -76,11 +94,10 @@ public final class PlayerRisk extends JavaPlugin implements Listener { //当玩家离开城镇后,把玩家姓名放入mao中 Player player = event.getPlayer(); - //此处应该有一个方法,用来获取生物群系的姓名或者id,在方法中默认只有一个群系,用字符a代替 - playerRiskManager.addPlayerToMap(player.getName(),"a"); + playerRiskManager.addPlayerToMap(player.getName(),getCurrentBiome(player)); + - throw new NotImplementedException("Not implemented yet."); } /** @@ -92,7 +109,7 @@ public final class PlayerRisk extends JavaPlugin implements Listener { public void onPlayerDeath(PlayerDeathEvent event) { Player player = event.getEntity(); playerRiskManager.removePlayerLevel(player.getName()); - throw new NotImplementedException("Not implemented yet."); + } // TODO: Add any other event handlers needed to manage player risk.