增加了重载文件
This commit is contained in:
parent
4166d3a989
commit
73ae23840a
@ -3,7 +3,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = 'com.sakurarealm'
|
group = 'com.sakurarealm'
|
||||||
version = '1.1'
|
version = '1.2'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
@ -27,6 +27,7 @@ import java.util.*;
|
|||||||
public final class PlayerRisk extends JavaPlugin implements Listener {
|
public final class PlayerRisk extends JavaPlugin implements Listener {
|
||||||
|
|
||||||
private PlayerRiskManager playerRiskManager = null;
|
private PlayerRiskManager playerRiskManager = null;
|
||||||
|
private boolean boolLogger = false;
|
||||||
|
|
||||||
//假设的方法,您需要根据实际情况来实现它
|
//假设的方法,您需要根据实际情况来实现它
|
||||||
private String getCurrentBiome(Player player) {
|
private String getCurrentBiome(Player player) {
|
||||||
@ -83,15 +84,26 @@ public final class PlayerRisk extends JavaPlugin implements Listener {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings){
|
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings){
|
||||||
if (!commandSender.isOp()){
|
|
||||||
//不是op不能执行此命令
|
if (s.equalsIgnoreCase("playerrisk") || s.equalsIgnoreCase("pr")){
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (s.equalsIgnoreCase("playerrisk")){
|
|
||||||
if (strings.length == 0){
|
if (strings.length == 0){
|
||||||
commandSender.sendMessage(ChatColor.RED+"请输入reload重载插件!");
|
if (!commandSender.isOp()){
|
||||||
|
//不是op不能执行此命令
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
boolLogger = !boolLogger;
|
||||||
|
playerRiskManager.setBoolLogger(boolLogger);
|
||||||
|
if (boolLogger){
|
||||||
|
commandSender.sendMessage(ChatColor.GREEN+"危险度插件日志开启");
|
||||||
|
}else {
|
||||||
|
commandSender.sendMessage(ChatColor.GREEN+"危险度插件日志关闭");
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}else {
|
}else if (strings[0].equalsIgnoreCase("reload")){
|
||||||
|
if (!commandSender.isOp()){
|
||||||
|
//不是op不能执行此命令
|
||||||
|
return false;
|
||||||
|
}
|
||||||
String reload = strings[0];
|
String reload = strings[0];
|
||||||
if (reload.equalsIgnoreCase("reload")){
|
if (reload.equalsIgnoreCase("reload")){
|
||||||
//重新加载插件
|
//重新加载插件
|
||||||
@ -109,6 +121,42 @@ public final class PlayerRisk extends JavaPlugin implements Listener {
|
|||||||
commandSender.sendMessage(ChatColor.GREEN+"危险度插件重载成功");
|
commandSender.sendMessage(ChatColor.GREEN+"危险度插件重载成功");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
} else if (strings.length == 2 && strings[0].equalsIgnoreCase("query")) {
|
||||||
|
//查询玩家的危险度
|
||||||
|
Player player = Bukkit.getPlayer(strings[1]);
|
||||||
|
if (player == null){
|
||||||
|
commandSender.sendMessage(ChatColor.RED+"玩家"+strings[1]+"不存在");
|
||||||
|
}
|
||||||
|
if (player != null) {
|
||||||
|
playerRiskManager.questRiskLevel(player);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
} else if (strings[0].equalsIgnoreCase("clear")){
|
||||||
|
if (!commandSender.isOp()){
|
||||||
|
//不是op不能执行此命令
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (strings.length == 2){
|
||||||
|
//长度为2,清空某位玩家的危险度
|
||||||
|
Player player = Bukkit.getPlayer(strings[1]);
|
||||||
|
if (player == null){
|
||||||
|
commandSender.sendMessage(ChatColor.RED+strings[1]+"玩家不存在!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
playerRiskManager.removePlayerLevel(strings[1]);
|
||||||
|
}
|
||||||
|
}else if (strings.length == 3 && strings[0].equalsIgnoreCase("set")){
|
||||||
|
if (!commandSender.isOp()){
|
||||||
|
//不是op不能执行此命令
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Player player = Bukkit.getPlayer(strings[1]);
|
||||||
|
if (player == null){
|
||||||
|
commandSender.sendMessage(ChatColor.RED+strings[1]+"玩家不存在!");
|
||||||
|
}
|
||||||
|
|
||||||
|
playerRiskManager.setRisk2Player(strings[1], Integer.parseInt(strings[2]));
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
//指令错误
|
//指令错误
|
||||||
@ -129,7 +177,7 @@ public final class PlayerRisk extends JavaPlugin implements Listener {
|
|||||||
|
|
||||||
playerRiskManager.offOnlinePlayer(name);
|
playerRiskManager.offOnlinePlayer(name);
|
||||||
|
|
||||||
getLogger().info(ChatColor.GREEN+player.getName()+"退出了游戏");
|
if (boolLogger) getLogger().info(ChatColor.GREEN+player.getName()+"退出了游戏");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -140,12 +188,12 @@ public final class PlayerRisk extends JavaPlugin implements Listener {
|
|||||||
public void onPlayerJoinGame(PlayerJoinEvent event){
|
public void onPlayerJoinGame(PlayerJoinEvent event){
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
String name = player.getName();
|
String name = player.getName();
|
||||||
getLogger().info(ChatColor.AQUA+name+"进入了游戏");
|
if (boolLogger)getLogger().info(ChatColor.AQUA+name+"进入了游戏");
|
||||||
if(!playerRiskManager.playerLoginBoolean(name)){
|
if(!playerRiskManager.playerLoginBoolean(name)){
|
||||||
Location location = player.getLocation();
|
Location location = player.getLocation();
|
||||||
if (!this.playerStayTown(location)){
|
if (!this.playerStayTown(location)){
|
||||||
//为空,则在野外上线,但是map集合中又没有记录,重新开始计算
|
//为空,则在野外上线,但是map集合中又没有记录,重新开始计算
|
||||||
playerRiskManager.addPlayerToMap(player.getName(),getCurrentBiome(player));
|
playerRiskManager.addPlayerToHashMap(player.getName(),getCurrentBiome(player));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -156,7 +204,7 @@ public final class PlayerRisk extends JavaPlugin implements Listener {
|
|||||||
Location respawnLocation = event.getRespawnLocation();
|
Location respawnLocation = event.getRespawnLocation();
|
||||||
if(!this.playerStayTown(respawnLocation)){
|
if(!this.playerStayTown(respawnLocation)){
|
||||||
//重生在野外
|
//重生在野外
|
||||||
playerRiskManager.addPlayerToMap(player.getName(),getCurrentBiome(player));
|
playerRiskManager.addPlayerToHashMap(player.getName(),getCurrentBiome(player));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,7 +219,7 @@ public final class PlayerRisk extends JavaPlugin implements Listener {
|
|||||||
//当玩家进入城镇后,移出map集合并且清零
|
//当玩家进入城镇后,移出map集合并且清零
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
getLogger().info(ChatColor.AQUA+"玩家"+player.getName()+"进入了城镇 ");
|
if (boolLogger) getLogger().info(ChatColor.AQUA+"玩家"+player.getName()+"进入了城镇 ");
|
||||||
|
|
||||||
playerRiskManager.removePlayerLevel(player.getName());
|
playerRiskManager.removePlayerLevel(player.getName());
|
||||||
player.sendMessage(ChatColor.GREEN+"进入城镇,危险度归零!");
|
player.sendMessage(ChatColor.GREEN+"进入城镇,危险度归零!");
|
||||||
@ -188,9 +236,8 @@ public final class PlayerRisk extends JavaPlugin implements Listener {
|
|||||||
//当玩家离开城镇后,把玩家姓名放入map中
|
//当玩家离开城镇后,把玩家姓名放入map中
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
// getLogger().info(ChatColor.GREEN+player.getName()+"离开了城镇开始计算危险度");
|
|
||||||
|
|
||||||
playerRiskManager.addPlayerToMap(player.getName(),getCurrentBiome(player));
|
playerRiskManager.addPlayerToHashMap(player.getName(),getCurrentBiome(player));
|
||||||
player.sendMessage(ChatColor.RED+"离开城镇,开始计算危险度!");
|
player.sendMessage(ChatColor.RED+"离开城镇,开始计算危险度!");
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -204,7 +251,7 @@ public final class PlayerRisk extends JavaPlugin implements Listener {
|
|||||||
public void onPlayerDeath(PlayerDeathEvent event) {
|
public void onPlayerDeath(PlayerDeathEvent event) {
|
||||||
Player player = event.getEntity();
|
Player player = event.getEntity();
|
||||||
|
|
||||||
getLogger().info(ChatColor.GREEN+player.getName()+"死亡了,停止计算危险度");
|
if (boolLogger) getLogger().info(ChatColor.GREEN+player.getName()+"死亡了,停止计算危险度");
|
||||||
|
|
||||||
playerRiskManager.removePlayerLevel(player.getName());
|
playerRiskManager.removePlayerLevel(player.getName());
|
||||||
|
|
||||||
@ -218,7 +265,7 @@ public final class PlayerRisk extends JavaPlugin implements Listener {
|
|||||||
*/
|
*/
|
||||||
public void addRiskToOutTownPlayers(){
|
public void addRiskToOutTownPlayers(){
|
||||||
//获取所有玩家的生物群系的危险度
|
//获取所有玩家的生物群系的危险度
|
||||||
Map<String, Map<String, Integer>> playerBiomeRisk = playerRiskManager.getPlayerBiomeRisk();
|
HashMap<String, HashMap<String, Integer>> playerBiomeRisk = playerRiskManager.getPlayerBiomeRisk();
|
||||||
for (String name : playerBiomeRisk.keySet()){
|
for (String name : playerBiomeRisk.keySet()){
|
||||||
|
|
||||||
//通过玩家姓名获取所在的biome
|
//通过玩家姓名获取所在的biome
|
||||||
|
@ -3,11 +3,17 @@ package com.sakurarealm.playerrisk.api;
|
|||||||
import com.sakurarealm.playerrisk.PlayerRisk;
|
import com.sakurarealm.playerrisk.PlayerRisk;
|
||||||
import com.sakurarealm.playerrisk.hook.PlaceHolderAPIHook;
|
import com.sakurarealm.playerrisk.hook.PlaceHolderAPIHook;
|
||||||
import org.apache.commons.lang.NotImplementedException;
|
import org.apache.commons.lang.NotImplementedException;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.block.Biome;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Random;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@ -20,6 +26,7 @@ import java.util.logging.Logger;
|
|||||||
*/
|
*/
|
||||||
public class PlayerRiskManager {
|
public class PlayerRiskManager {
|
||||||
|
|
||||||
|
private boolean boolLogger = false;
|
||||||
Logger logger = Logger.getLogger("PlayerRisk");
|
Logger logger = Logger.getLogger("PlayerRisk");
|
||||||
|
|
||||||
private final PlayerRisk plugin;
|
private final PlayerRisk plugin;
|
||||||
@ -27,13 +34,13 @@ public class PlayerRiskManager {
|
|||||||
public PlayerRiskSettings settings;
|
public PlayerRiskSettings settings;
|
||||||
|
|
||||||
//用来记录在野外下线的玩家的危险度,这部分后续可以改成用数据库记录
|
//用来记录在野外下线的玩家的危险度,这部分后续可以改成用数据库记录
|
||||||
private final Map<String,Map<String,Integer>> OffOnlinePlayerBiomeRisk;
|
private final HashMap<String,HashMap<String,Integer>> OffOnlinePlayerBiomeRisk;
|
||||||
|
|
||||||
//记录玩家的总危险度
|
//记录玩家的总危险度
|
||||||
private final Map<String, Integer> playerRiskLevels;
|
private final HashMap<String, Integer> playerRiskLevels;
|
||||||
|
|
||||||
//用来记录每个玩家在每个生物群系里面的危险度
|
//用来记录每个玩家在每个生物群系里面的危险度
|
||||||
private final Map<String,Map<String,Integer>> playerBiomeRisk;
|
private final HashMap<String,HashMap<String,Integer>> playerBiomeRisk;
|
||||||
|
|
||||||
// TODO: Add any data structures needed to manage player risk.
|
// TODO: Add any data structures needed to manage player risk.
|
||||||
|
|
||||||
@ -88,23 +95,23 @@ public class PlayerRiskManager {
|
|||||||
|
|
||||||
if (playerBiomeRisk.get(playerName).get(biome) == null){
|
if (playerBiomeRisk.get(playerName).get(biome) == null){
|
||||||
playerBiomeRisk.get(playerName).put(biome,1);
|
playerBiomeRisk.get(playerName).put(biome,1);
|
||||||
logger.info(ChatColor.GOLD+playerName+"进入了新的生物去群系且社危险度为1");
|
if (boolLogger) logger.info(ChatColor.GOLD+playerName+"进入了新的生物去群系且社危险度为1");
|
||||||
}else {
|
}else {
|
||||||
if (playerBiomeRisk.get(playerName).get(biome) < settings.getLevelMax()/5) {
|
if (playerBiomeRisk.get(playerName).get(biome) < settings.getLevelMax()/5 && playerRiskLevels.get(playerName) < settings.getLevelMax()) {
|
||||||
playerBiomeRisk.get(playerName).put(biome, playerBiomeRisk.get(playerName).get(biome) + 1);
|
playerBiomeRisk.get(playerName).put(biome, playerBiomeRisk.get(playerName).get(biome) + 1);
|
||||||
}else {
|
}else {
|
||||||
logger.info(ChatColor.GOLD+playerName+"的"+biome+"的危险度为:"+playerBiomeRisk.get(playerName).get(biome));
|
if (boolLogger) logger.info(ChatColor.GOLD+playerName+"的"+biome+"的危险度为:"+playerBiomeRisk.get(playerName).get(biome));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//修改总群系的危险度
|
//修改总群系的危险度
|
||||||
addAllBiomeRisk(playerName);
|
addAllBiomeRisk(playerName);
|
||||||
|
|
||||||
logger.info(ChatColor.GOLD+playerName+"的"+biome+"的危险度:"+playerBiomeRisk.get(playerName).get(biome));
|
if (boolLogger) logger.info(ChatColor.GOLD+playerName+"的"+biome+"的危险度:"+playerBiomeRisk.get(playerName).get(biome));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 玩家死亡或者进入城镇后,通过玩家姓名将玩家从map里删除
|
* 玩家死亡或者进入城镇后,通过玩家姓名将玩家从HashMap里删除
|
||||||
* @param playerName
|
* @param playerName
|
||||||
*/
|
*/
|
||||||
public void removePlayerLevel(String playerName){
|
public void removePlayerLevel(String playerName){
|
||||||
@ -121,15 +128,15 @@ public class PlayerRiskManager {
|
|||||||
|
|
||||||
if (playerRiskLevels.get(playerName) != null) {
|
if (playerRiskLevels.get(playerName) != null) {
|
||||||
|
|
||||||
Map<String, Integer> biomeRisks = playerBiomeRisk.get(playerName);
|
HashMap<String, Integer> biomeRisks = playerBiomeRisk.get(playerName);
|
||||||
for (String biome : biomeRisks.keySet()) {
|
for (String biome : biomeRisks.keySet()) {
|
||||||
|
|
||||||
logger.info(ChatColor.AQUA+playerName+"保存的"+biome+"群系危险度:"+biomeRisks.get(biome));
|
if (boolLogger) logger.info(ChatColor.AQUA+playerName+"保存的"+biome+"群系危险度:"+biomeRisks.get(biome));
|
||||||
}
|
}
|
||||||
//下线后记录到下线的map中
|
//下线后记录到下线的HashMap中
|
||||||
OffOnlinePlayerBiomeRisk.put(playerName, biomeRisks);
|
OffOnlinePlayerBiomeRisk.put(playerName, biomeRisks);
|
||||||
|
|
||||||
logger.info(ChatColor.GOLD+playerName+"的危险度被记录了");
|
if (boolLogger) logger.info(ChatColor.GOLD+playerName+"的危险度被记录了");
|
||||||
}
|
}
|
||||||
|
|
||||||
playerRiskLevels.remove(playerName);
|
playerRiskLevels.remove(playerName);
|
||||||
@ -138,13 +145,13 @@ public class PlayerRiskManager {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 玩家离开城镇,并进入对应的biome后,将玩家放入对应的map中
|
* 玩家离开城镇,并进入对应的biome后,将玩家放入对应的HashMap中
|
||||||
* 注意此处,当玩家从1群系到2群系的时候,不能调用此方法修改map
|
* 注意此处,当玩家从1群系到2群系的时候,不能调用此方法修改HashMap
|
||||||
* @param playerName
|
* @param playerName
|
||||||
* @param biome
|
* @param biome
|
||||||
*/
|
*/
|
||||||
public void addPlayerToMap(String playerName,String biome){
|
public void addPlayerToHashMap(String playerName,String biome){
|
||||||
Map<String,Integer> biomeRisk = new HashMap<>();
|
HashMap<String,Integer> biomeRisk = new HashMap<>();
|
||||||
biomeRisk.put(biome,0);//从0开始计算
|
biomeRisk.put(biome,0);//从0开始计算
|
||||||
playerBiomeRisk.put(playerName,biomeRisk);
|
playerBiomeRisk.put(playerName,biomeRisk);
|
||||||
|
|
||||||
@ -160,25 +167,25 @@ public class PlayerRiskManager {
|
|||||||
* @param playerName 通过玩家姓名获取修改危险度
|
* @param playerName 通过玩家姓名获取修改危险度
|
||||||
*/
|
*/
|
||||||
public void addAllBiomeRisk(String playerName){
|
public void addAllBiomeRisk(String playerName){
|
||||||
Map<String, Integer> stringIntegerMap = playerBiomeRisk.get(playerName);
|
HashMap<String, Integer> stringIntegerHashMap = playerBiomeRisk.get(playerName);
|
||||||
//循环叠加每个群系的危险度
|
//循环叠加每个群系的危险度
|
||||||
Integer sumLevel = 0;
|
Integer sumLevel = 0;
|
||||||
for (String str : stringIntegerMap.keySet()){
|
for (String str : stringIntegerHashMap.keySet()){
|
||||||
sumLevel += stringIntegerMap.get(str);
|
sumLevel += stringIntegerHashMap.get(str);
|
||||||
}
|
}
|
||||||
//放入总值
|
//放入总值
|
||||||
playerRiskLevels.put(playerName,sumLevel);
|
playerRiskLevels.put(playerName,sumLevel);
|
||||||
|
|
||||||
logger.info(ChatColor.GREEN+playerName+"的总危险度:"+sumLevel);
|
if (boolLogger) logger.info(ChatColor.GREEN+playerName+"的总危险度:"+sumLevel);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Map<String, Integer>> getPlayerBiomeRisk() {
|
public HashMap<String, HashMap<String, Integer>> getPlayerBiomeRisk() {
|
||||||
return playerBiomeRisk;
|
return playerBiomeRisk;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断玩家上下时是否在野外,如果玩家记录在map集合中,则true
|
* 判断玩家上下时是否在野外,如果玩家记录在HashMap集合中,则true
|
||||||
* @param name
|
* @param name
|
||||||
*/
|
*/
|
||||||
public boolean playerLoginBoolean(String name) {
|
public boolean playerLoginBoolean(String name) {
|
||||||
@ -187,22 +194,22 @@ public class PlayerRiskManager {
|
|||||||
//不为空则玩家在野外下线
|
//不为空则玩家在野外下线
|
||||||
if (OffOnlinePlayerBiomeRisk.containsKey(name)){
|
if (OffOnlinePlayerBiomeRisk.containsKey(name)){
|
||||||
//获取之前下线前保存的生物群系集合
|
//获取之前下线前保存的生物群系集合
|
||||||
Map<String, Integer> biomeRisks = OffOnlinePlayerBiomeRisk.get(name);
|
HashMap<String, Integer> biomeRisks = OffOnlinePlayerBiomeRisk.get(name);
|
||||||
|
|
||||||
//把之前保存的生物群系危险度集合放入
|
//把之前保存的生物群系危险度集合放入
|
||||||
playerBiomeRisk.put(name,biomeRisks);
|
playerBiomeRisk.put(name,biomeRisks);
|
||||||
|
|
||||||
//计算总危险度
|
//计算总危险度
|
||||||
for (String biome : biomeRisks.keySet()){
|
for (String biome : biomeRisks.keySet()){
|
||||||
logger.info(ChatColor.RED+biome);
|
if (boolLogger) logger.info(ChatColor.RED+biome);
|
||||||
Integer level = biomeRisks.get(biome);
|
Integer level = biomeRisks.get(biome);
|
||||||
sumRiskLevel += level;
|
sumRiskLevel += level;
|
||||||
logger.info(ChatColor.GREEN+name+"登录后的"+biome+"的危险度"+level);
|
if (boolLogger) logger.info(ChatColor.GREEN+name+"登录后的"+biome+"的危险度"+level);
|
||||||
}
|
}
|
||||||
|
|
||||||
//计入总危险度
|
//计入总危险度
|
||||||
playerRiskLevels.put(name,sumRiskLevel);
|
playerRiskLevels.put(name,sumRiskLevel);
|
||||||
logger.info(ChatColor.AQUA+name+"登录后的总危险度"+sumRiskLevel);
|
if (boolLogger) logger.info(ChatColor.AQUA+name+"登录后的总危险度"+sumRiskLevel);
|
||||||
|
|
||||||
//最后删除 OffOnlinePlayerBiomeRisk 中保存的集合
|
//最后删除 OffOnlinePlayerBiomeRisk 中保存的集合
|
||||||
OffOnlinePlayerBiomeRisk.remove(name);
|
OffOnlinePlayerBiomeRisk.remove(name);
|
||||||
@ -220,4 +227,72 @@ public class PlayerRiskManager {
|
|||||||
playerBiomeRisk.clear();
|
playerBiomeRisk.clear();
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会清空玩家的危险度然后随机赋予几个群系危险度
|
||||||
|
* @param name
|
||||||
|
* @param level
|
||||||
|
*/
|
||||||
|
public void setRisk2Player(String name,int level){
|
||||||
|
if (level > 50){
|
||||||
|
level = 50;
|
||||||
|
}
|
||||||
|
|
||||||
|
HashMap<String,Integer> biomeRisk = new HashMap<>();
|
||||||
|
// HashMap<String,HashMap<String, Integer>> biomeRiskLevel = new HashMap<>();
|
||||||
|
int copyLevel = level;
|
||||||
|
Random random = new Random();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for (Biome biome : Biome.values()){
|
||||||
|
int i = random.nextInt(5);
|
||||||
|
if (i == 1){
|
||||||
|
if (copyLevel >= 10){
|
||||||
|
copyLevel -= 10;
|
||||||
|
biomeRisk.put(biome.name(),10);
|
||||||
|
}else if ( copyLevel > 0){
|
||||||
|
biomeRisk.put(biome.name(),copyLevel);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (level == 0){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
playerRiskLevels.put(name,level);
|
||||||
|
playerBiomeRisk.put(name,biomeRisk);
|
||||||
|
|
||||||
|
Player player = Bukkit.getPlayer(name);
|
||||||
|
for (String biome : biomeRisk.keySet()){
|
||||||
|
player.sendMessage(ChatColor.GREEN+biome+"群系的危险度被设置为:"+biomeRisk.get(biome));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询玩家的危险度
|
||||||
|
*/
|
||||||
|
public void questRiskLevel(Player player){
|
||||||
|
HashMap<String, Integer> biomeRisk = playerBiomeRisk.get(player.getName());
|
||||||
|
Integer level = playerRiskLevels.get(player.getName());
|
||||||
|
player.sendMessage(ChatColor.AQUA+"总危险度为:"+level);
|
||||||
|
|
||||||
|
if (biomeRisk == null){
|
||||||
|
player.sendMessage(ChatColor.GOLD+"玩家"+"危险度为:"+0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String biome : biomeRisk.keySet()){
|
||||||
|
player.sendMessage(ChatColor.GREEN+biome+"群系的危险度为:"+biomeRisk.get(biome));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isBoolLogger() {
|
||||||
|
return boolLogger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBoolLogger(boolean boolLogger) {
|
||||||
|
this.boolLogger = boolLogger;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,4 +13,5 @@ permissions:
|
|||||||
commands:
|
commands:
|
||||||
playerrisk:
|
playerrisk:
|
||||||
description: PlayerRisk command
|
description: PlayerRisk command
|
||||||
usage: /playerrisk
|
usage: /playerrisk
|
||||||
|
aliases: [pr]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user