重新修改了主框架,区分了每个生物群系的危险度,但是因为没有具体的方法和生物群系的id或者名称,所以用a代替了

This commit is contained in:
yuyu 2024-03-16 09:36:18 +08:00
parent 67757b58b0
commit 76f5c3f9a5

View File

@ -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.