添加了MM怪物刷新的代码

This commit is contained in:
yuyu 2024-04-07 21:10:04 +08:00
parent f2e77098e9
commit 76d2724786
7 changed files with 278 additions and 0 deletions

View File

@ -0,0 +1,111 @@
package com.yuyu.srwildentity.conditionCheck;
import com.yuyu.srwildentity.config.condition.EntityCondition;
import com.yuyu.srwildentity.config.condition.EntitySite;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
/**
* @BelongsProject: SrWildEntity
* @BelongsPackage: com.yuyu.srwildentity.conditionCheck
* @FileName: ConditionCheck
* @Author:
* @Date: 2024/4/4-14:50
* @Version: 1.0
* @Description: 用于检查是否通过
*/
public class ConditionCheck {
/**
* 检查entity生成位置是否符合
* 1.位置
* 2.亮度
* 3.刷新的世界的时间
* 4.高度
* @param world
* @param location
* @param entityCondition
* @return
*/
public static boolean checkEntityRefresh(World world, Location location, EntityCondition entityCondition){
return checkLocation(world,location,entityCondition.getEntitySite())
&& checkLight(world,location,entityCondition.getLight())
&& checkTimed(world,entityCondition.getStartTiming(), entityCondition.getEndTimeing())
&& checkY(location,entityCondition.getyMax(), entityCondition.getyMin());
}
/**
* 检查刷新位置
* @param world
* @param location
* @param entitySite
* @return
*/
public static boolean checkLocation(World world, Location location, EntitySite entitySite){
if (entitySite == null || world == null || location == null){
throw new RuntimeException("checkLocation接收的参数错误");
}
if (entitySite == EntitySite.ON_GROUND){
Block blockAt = world.getBlockAt(location);
return blockAt.getType().name().equals(Material.AIR.name());
}
if (entitySite == EntitySite.NULL){
return true;
}
if (entitySite == EntitySite.ON_WATER){
Block blockAt = world.getBlockAt(location);
return blockAt.getType().name().equals(Material.WATER.name());
}
if (entitySite == EntitySite.ON_MAGMA){
Block blockAt = world.getBlockAt(location);
return blockAt.getType().name().equals(Material.MAGMA.name());
}
if (entitySite == EntitySite.UNDER_GROUND){
Block blockAt = world.getBlockAt(location);
Block block = world.getBlockAt(new Location(world,location.getX(),location.getY()+1,location.getZ()));
return blockAt.getType().name().equals(Material.AIR.name()) && block.getType().name().equals(Material.AIR.name());
}
return false;
}
/**
* 检查亮度
* @param world
* @param location
* @param light
* @return
*/
public static boolean checkLight(World world, Location location, int light){
if (world == null || location == null || location == null){
throw new RuntimeException("checkLight接收的参数错误");
}
Block blockAt = world.getBlockAt(location);
int lightLevel = blockAt.getLightLevel();
return lightLevel <= light;//若方块位置的亮度小于或者等于设定值则通过
}
public static boolean checkTimed(World world ,long stimed,long etimed){
if (world == null ){
throw new RuntimeException("checkTime参数错误");
}
long time = world.getTime();
return time > stimed && time < etimed;
}
public static boolean checkY(Location location,int yMax,int yMin){
if (location == null){
throw new RuntimeException("checkY接收参数错误");
}
int blockY = location.getBlockY();
return blockY >= yMin && blockY <= yMax;
}
}

View File

@ -0,0 +1,24 @@
package com.yuyu.srwildentity.config.condition;
public enum SpawnEntityType {
PROTOGENESIS(0),//mc原生实体
MMENTITY(1),//MM怪物
GERMENTITY(2),
NULL(199999);//萌芽怪物
private final int id;
public int getId() {
return id;
}
SpawnEntityType(int id) {
this.id = id;
}
public static SpawnEntityType fromId(int id) {
for (SpawnEntityType type : SpawnEntityType.values()) {
if (type.getId() == id) {
return type;
}
}
return NULL;
}
}

View File

@ -0,0 +1,54 @@
package com.yuyu.srwildentity.pojo;
import java.util.List;
import java.util.UUID;
/**
* @BelongsProject: SrWildEntity
* @BelongsPackage: com.yuyu.srwildentity.pojo
* @FileName: PlayerRefreshinfo
* @Author:
* @Date: 2024/4/4-17:35
* @Version: 1.0
* @Description: 储存玩家相关的刷新信息
*/
public class PlayerRefreshinfo {
private final String playerName;
private Integer nums;
private List<UUID> entityList;
public void addEntityList(UUID uuid){
this.entityList.add(uuid);
}
public void delEntityList(UUID uuid){
this.entityList.remove(uuid);
}
public String getPlayerName() {
return playerName;
}
public Integer getNums() {
return nums;
}
public void setNums(Integer nums) {
this.nums = nums;
}
public List<UUID> getEntityList() {
return entityList;
}
public void setEntityList(List<UUID> entityList) {
this.entityList = entityList;
}
public PlayerRefreshinfo(String playerName, Integer nums,List<UUID> uuids) {
this.playerName = playerName;
this.nums = nums;
this.entityList = uuids;
}
}

63
target/classes/biome.yml Normal file
View File

@ -0,0 +1,63 @@
biome:
- OCEAN
- PLAINS
- DESERT
- EXTREME_HILLS
- FOREST
- TAIGA
- SWAMPLAND
- RIVER
- HELL
- SKY
- FROZEN_OCEAN
- FROZEN_RIVER
- ICE_FLATS
- ICE_MOUNTAINS
- MUSHROOM_ISLAND
- MUSHROOM_ISLAND_SHORE
- BEACHES
- DESERT_HILLS
- FOREST_HILLS
- TAIGA_HILLS
- SMALLER_EXTREME_HILLS
- JUNGLE
- JUNGLE_HILLS
- JUNGLE_EDGE
- DEEP_OCEAN
- STONE_BEACH
- COLD_BEACH
- BIRCH_FOREST
- BIRCH_FOREST_HILLS
- ROOFED_FOREST
- TAIGA_COLD
- TAIGA_COLD_HILLS
- REDWOOD_TAIGA
- REDWOOD_TAIGA_HILLS
- EXTREME_HILLS_WITH_TREES
- SAVANNA
- SAVANNA_ROCK
- MESA
- MESA_ROCK
- MESA_CLEAR_ROCK
- VOID
- MUTATED_PLAINS
- MUTATED_DESERT
- MUTATED_EXTREME_HILLS
- MUTATED_FOREST
- MUTATED_TAIGA
- MUTATED_SWAMPLAND
- MUTATED_ICE_FLATS
- MUTATED_JUNGLE
- MUTATED_JUNGLE_EDGE
- MUTATED_BIRCH_FOREST
- MUTATED_BIRCH_FOREST_HILLS
- MUTATED_ROOFED_FOREST
- MUTATED_TAIGA_COLD
- MUTATED_REDWOOD_TAIGA
- MUTATED_REDWOOD_TAIGA_HILLS
- MUTATED_EXTREME_HILLS_WITH_TREES
- MUTATED_SAVANNA
- MUTATED_SAVANNA_ROCK
- MUTATED_MESA
- MUTATED_MESA_ROCK
- MUTATED_MESA_CLEAR_ROCK

View File

@ -0,0 +1,6 @@
DESERT: #群系名称,下方标出该群系需要刷新的entity
ENTITY: [ZOMBIE,PIG_ZOMBIE] #该群系刷新的entity,具体的怪物刷新配置需要去entityConfig.yml中配置,!!注意此处的实体配置一定要在实体配置文件中存在,否则会不会刷新!
ROOFED_FOREST: #群系名称,下方标出该群系需要刷新的entity
ENTITY: [ZOMBIE,PIG_ZOMBIE] #该群系刷新的entity,具体的怪物刷新配置需要去entityConfig.yml中配置,!!注意此处的实体配置一定要在实体配置文件中存在,否则会不会刷新!

View File

@ -0,0 +1,3 @@
RefreshTime: 10 #刷新时间单位为s
total: 12 #每个玩家每次刷新的实体数量
num: 4 #单次刷新的数量每RefreshTime秒刷新的数量

17
target/classes/plugin.yml Normal file
View File

@ -0,0 +1,17 @@
name: SrWildEntity
version: '1.0-SNAPSHOT'
main: com.yuyu.srwildentity.SrWildEntity
description: 实体刷新插件
authors: [Yuyu]
commands:
despawn:
usage: /<command>
aliases: [dsp]
description: 只有op能使用的插件
permission: op
permission-message: 你没有使用权限!
srwildentity:
usage: /<command>
description: 只有op能使用的插件
permission: op
permission-message: 你没有使用权限!