Merge changes from magma branch (except downgrade)
This commit is contained in:
@@ -12,6 +12,7 @@ public enum EnumTargetGoal {
|
||||
NEAREST_BOT("Locate the nearest bot."),
|
||||
NEAREST_BOT_DIFFER("Locate the nearest bot with a different username."),
|
||||
NEAREST_BOT_DIFFER_ALPHA("Locate the nearest bot with a different username after filtering out non-alpha characters."),
|
||||
CUSTOM_LIST("Locate only the mob types specified in the custom list of mobs"),
|
||||
PLAYER("Target a single player. Defaults to NEAREST_VULNERABLE_PLAYER if no player found."),
|
||||
NONE("No target goal.");
|
||||
|
||||
@@ -26,6 +27,7 @@ public enum EnumTargetGoal {
|
||||
this.put("nearestbot", NEAREST_BOT);
|
||||
this.put("nearestbotdiffer", NEAREST_BOT_DIFFER);
|
||||
this.put("nearestbotdifferalpha", NEAREST_BOT_DIFFER_ALPHA);
|
||||
this.put("customlist", CUSTOM_LIST);
|
||||
this.put("player", PLAYER);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -56,6 +56,9 @@ public class LegacyAgent extends Agent {
|
||||
private double regionWeightX;
|
||||
private double regionWeightY;
|
||||
private double regionWeightZ;
|
||||
|
||||
public static final Set<EntityType> CUSTOM_TYPES_LIST = new HashSet<>();
|
||||
public static boolean areCustomTypesHostile = false;
|
||||
|
||||
public LegacyAgent(BotManager manager, Plugin plugin) {
|
||||
super(manager, plugin);
|
||||
@@ -1456,7 +1459,7 @@ public class LegacyAgent extends Agent {
|
||||
|
||||
case NEAREST_HOSTILE: {
|
||||
for (LivingEntity entity : bot.getBukkitEntity().getWorld().getLivingEntities()) {
|
||||
if (entity instanceof Monster && validateCloserEntity(entity, loc, result)) {
|
||||
if ((entity instanceof Monster || (areCustomTypesHostile && CUSTOM_TYPES_LIST.contains(entity.getType()))) && validateCloserEntity(entity, loc, result)) {
|
||||
result = entity;
|
||||
}
|
||||
}
|
||||
@@ -1476,7 +1479,7 @@ public class LegacyAgent extends Agent {
|
||||
|
||||
case NEAREST_MOB: {
|
||||
for (LivingEntity entity : bot.getBukkitEntity().getWorld().getLivingEntities()) {
|
||||
if (entity instanceof Mob && validateCloserEntity(entity, loc, result)) {
|
||||
if ((entity instanceof Mob || CUSTOM_TYPES_LIST.contains(entity.getType())) && validateCloserEntity(entity, loc, result)) {
|
||||
result = entity;
|
||||
}
|
||||
}
|
||||
@@ -1526,15 +1529,29 @@ public class LegacyAgent extends Agent {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case PLAYER: { //Target a single player. Defaults to NEAREST_VULNERABLE_PLAYER if no player found.
|
||||
|
||||
case CUSTOM_LIST: {
|
||||
for (LivingEntity entity : bot.getBukkitEntity().getWorld().getLivingEntities()) {
|
||||
if (CUSTOM_TYPES_LIST.contains(entity.getType()) && validateCloserEntity(entity, loc, result)) {
|
||||
result = entity;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case PLAYER: {
|
||||
if (bot.getTargetPlayer() != null) {
|
||||
Player player = Bukkit.getPlayer(bot.getTargetPlayer());
|
||||
if (player != null && !botsInPlayerList.contains(player) && validateCloserEntity(player, loc, null)) {
|
||||
return player;
|
||||
result = player;
|
||||
}
|
||||
}
|
||||
return locateTarget(bot, loc, EnumTargetGoal.NEAREST_VULNERABLE_PLAYER);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
TerminatorLocateTargetEvent event = new TerminatorLocateTargetEvent(bot, result);
|
||||
|
||||
@@ -176,7 +176,7 @@ public class LegacyBlockCheck {
|
||||
|
||||
// Blocks before must all be pass-through
|
||||
Material type = below.getBlock().getType();
|
||||
if (type.isSolid() || LegacyMats.canStandOn(type))
|
||||
if (LegacyMats.isSolid(type) || LegacyMats.canStandOn(type))
|
||||
return false;
|
||||
below = below.clone();
|
||||
}
|
||||
@@ -192,7 +192,7 @@ public class LegacyBlockCheck {
|
||||
Block next = itr.next().getBlock();
|
||||
boolean placeable = nether ? LegacyMats.canPlaceTwistingVines(next)
|
||||
: LegacyMats.canPlaceWater(next, Optional.absent());
|
||||
if (placeable || (!next.getType().isSolid() && !LegacyMats.canStandOn(next.getType())))
|
||||
if (placeable || (!LegacyMats.isSolid(next.getType()) && !LegacyMats.canStandOn(next.getType())))
|
||||
itr.remove();
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ public class LegacyMats {
|
||||
Material.JUNGLE_SIGN, Material.JUNGLE_SLAB, Material.JUNGLE_STAIRS, Material.JUNGLE_TRAPDOOR, Material.JUNGLE_WALL_SIGN, Material.JUNGLE_WOOD,
|
||||
Material.SPRUCE_PLANKS, Material.SPRUCE_DOOR, Material.SPRUCE_FENCE, Material.SPRUCE_FENCE_GATE, Material.SPRUCE_LOG,
|
||||
Material.SPRUCE_SIGN, Material.SPRUCE_SLAB, Material.SPRUCE_STAIRS, Material.SPRUCE_TRAPDOOR, Material.SPRUCE_WALL_SIGN, Material.SPRUCE_WOOD,
|
||||
Material.MANGROVE_PLANKS, Material.MANGROVE_DOOR, Material.MANGROVE_FENCE, Material.MANGROVE_FENCE_GATE, Material.MANGROVE_LOG,
|
||||
Material.MANGROVE_PLANKS, Material.MANGROVE_DOOR, Material.MANGROVE_FENCE, Material.MANGROVE_FENCE_GATE, Material.MANGROVE_LOG,
|
||||
Material.MANGROVE_SIGN, Material.MANGROVE_SLAB, Material.MANGROVE_STAIRS, Material.MANGROVE_TRAPDOOR, Material.MANGROVE_WALL_SIGN, Material.MANGROVE_WOOD,
|
||||
Material.CRIMSON_PLANKS, Material.CRIMSON_DOOR, Material.CRIMSON_FENCE, Material.CRIMSON_FENCE_GATE, Material.CRIMSON_STEM,
|
||||
Material.CRIMSON_SIGN, Material.CRIMSON_SLAB, Material.CRIMSON_STAIRS, Material.CRIMSON_TRAPDOOR, Material.CRIMSON_WALL_SIGN,
|
||||
@@ -319,7 +319,7 @@ public class LegacyMats {
|
||||
}
|
||||
|
||||
public static boolean canPlaceWater(Block block, Optional<Double> entityYPos) {
|
||||
if (block.getType().isSolid()) {
|
||||
if (isSolid(block.getType())) {
|
||||
if (block.getType() == Material.CHAIN && ((Chain)block.getBlockData()).getAxis() == Axis.Y
|
||||
&& !((Chain)block.getBlockData()).isWaterlogged())
|
||||
return false;
|
||||
@@ -381,7 +381,7 @@ public class LegacyMats {
|
||||
}
|
||||
|
||||
public static boolean canPlaceTwistingVines(Block block) {
|
||||
if (block.getType().isSolid()) {
|
||||
if (isSolid(block.getType())) {
|
||||
if (block.getType().data == Leaves.class)
|
||||
return false;
|
||||
if (block.getType().name().endsWith("_CORAL_FAN") || block.getType().name().endsWith("_CORAL")
|
||||
@@ -515,4 +515,13 @@ public class LegacyMats {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This set stores solid materials that are added by mods.
|
||||
*/
|
||||
public static final Set<Material> SOLID_MATERIALS = new HashSet<>();
|
||||
|
||||
public static boolean isSolid(Material mat) {
|
||||
return mat.isSolid() || SOLID_MATERIALS.contains(mat);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
import net.nuggetmc.tplus.api.agent.legacyagent.LegacyMats;
|
||||
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
@@ -53,7 +55,7 @@ public class PlayerUtils {
|
||||
boolean check = false;
|
||||
|
||||
for (int i = 0; i <= amount; i++) {
|
||||
if (loc.clone().add(0, i, 0).getBlock().getType().isSolid()) {
|
||||
if (LegacyMats.isSolid(loc.clone().add(0, i, 0).getBlock().getType())) {
|
||||
check = true;
|
||||
break;
|
||||
}
|
||||
@@ -76,7 +78,7 @@ public class PlayerUtils {
|
||||
break;
|
||||
}
|
||||
|
||||
if (check.getBlock().getType().isSolid()) {
|
||||
if (LegacyMats.isSolid(check.getBlock().getType())) {
|
||||
return check.add(0, 1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user