Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

Commit

Permalink
Update to v1.10.1 (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
gmitch215 committed May 27, 2024
2 parents 80d5f16 + 51d53dc commit bffcc51
Show file tree
Hide file tree
Showing 120 changed files with 531 additions and 331 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Contributing
Contributing guidelines for the MobChip Project. We appreciate your help in helping us to improve the project.

## Pull Requeset Process
## Pull Request Process
1. Ensure that the pull request is at the correct branch you want to merge in.
2. Ensure that your new code has been tested on a Maven Compiler, your specified Minecraft Version(s) and JDK 8.
3. Confirm that the code is ready to be merged along with any documentation you intend to include.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ AI into your own plugins for simple use.
## ❓ Why?

- **Simple**: MobChip has documentation, API usage, and other utilities to help ease the experience of working with Entity AI.
- **Flexible**: MobChip uses Reflection and Abstraction to help create flexibility, in order to ensure modern functionality on older versions. We also providing an easy-to-read API and JavaDocs to access important fields and methods.
- **Flexible**: MobChip uses Reflection and Abstraction to help create flexibility, in order to ensure modern functionality on older versions. We also provide an easy-to-read API and JavaDocs to access important fields and methods.
- **Compatibility**: MobChip uses Abstraction to create compatibility on multiple versions of Minecraft. We also provide a version checker to ensure that your plugin is running on a compatible version.
- **Transparent**: MobChip is completely open source.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ BehaviorResult run(String behaviorName, Object... args) {
}

@Override
public BehaviorResult backupIfClose(int min, float speedMod) {
public @NotNull BehaviorResult backupIfClose(int min, float speedMod) {
return run("BehaviorRetreat", min, speedMod);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public interface VillagerBrain extends EntityBrain {
EntityGossipContainer getGossipContainer();

@Override
@NotNull
Villager getEntity();

}
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,13 @@ public void serverTick() {}

public void clientTick() {}

public void onCrystalDestroyed(EnderCrystal c, EntityDamageEvent.DamageCause cause, @Nullable Player p) {}
public void onCrystalDestroyed(EnderCrystal c, EntityDamageEvent.DamageCause cause, @Nullable Player p) {
DragonPhase.super.onCrystalDestroyed(c, cause, p);
}

public float onDamage(EntityDamageEvent.DamageCause cause, float amount) { return amount; }
public float onDamage(EntityDamageEvent.DamageCause cause, float amount) {
return DragonPhase.super.onDamage(cause, amount);
}

public boolean isSitting() {
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package me.gamercoder215.mobchip.ai.goal;

import org.bukkit.entity.Mob;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;

/**
Expand Down Expand Up @@ -111,7 +112,7 @@ public void stop() {}
/**
* @deprecated Internal Use only
*/
@Deprecated
@ApiStatus.Internal
public String getInternalName() {
return "CustomPathfinder";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public void setFilter(@NotNull Class<T> clazz) {
}

@Override
public Creature getEntity() { return (Creature) entity; }
public @NotNull Creature getEntity() { return (Creature) entity; }

@Override
public @NotNull PathfinderFlag[] getFlags() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/
public final class PathfinderBeg extends Pathfinder implements Ranged {

private float lookRange = DEFAULT_LOOK_RANGE;
private float lookRange;

/**
* Constructs a PathfinderBeg with the default look range.
Expand All @@ -29,7 +29,7 @@ public PathfinderBeg(@NotNull Wolf w, float lookRange) {
}

@Override
public Wolf getEntity() { return (Wolf) entity; }
public @NotNull Wolf getEntity() { return (Wolf) entity; }

/**
* Get the look range of this PathfinderBeg.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public PathfinderBreathAir(@NotNull Creature c) {
}

@Override
public Creature getEntity() { return (Creature) entity; }
public @NotNull Creature getEntity() { return (Creature) entity; }

@Override
public @NotNull PathfinderFlag[] getFlags() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public PathfinderBreed(@NotNull Animals m, double speedMod) {
}

@Override
public Animals getEntity() { return (Animals) entity; }
public @NotNull Animals getEntity() { return (Animals) entity; }

@Override
public double getSpeedModifier() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package me.gamercoder215.mobchip.ai.goal;

import org.jetbrains.annotations.ApiStatus;

/**
* Represents information about a Pathfinder
*/
Expand All @@ -17,6 +19,7 @@ default String getName() {
* Returns the NMS Internal Name.
* @return Internal Name
*/
@ApiStatus.Internal
String getInternalName();

}
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ private EntityMemory(Class<T> bukkit, String key) {
* @return Bukkit Class
*/
@Override
@NotNull
public Class<T> getBukkitClass() {
return this.bukkit;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* <p>
* A Memory being registered means that the memory is present in the Minecraft Registry, and is supported by the mob type. All native memories, such as the ones listed in this class, are all
* registered in the Minecraft Registry by default, but can be unregistered at any time. However, custom memories are not registered in the Minecraft Registry, and thus, would not be able to be present in the brain.
*
* <p>
* Additionally, not all mobs support the same memory, making them unregistered when applicable. Passive Mobs do not have {@link EntityMemory#ANGRY_AT} registered in their Brain, and Wardens are the only ones with {@link EntityMemory#DISTURBANCE_LOCATION} registered.
* </p>
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public final int getScanRate() {
}

@Override
public final Class<T> getEntityClass() {
public final @NotNull Class<T> getEntityClass() {
return entityClass;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@ public final Sound getSpawnSound() {
* Sets the Death Sound.
* @param s New Death Sound, or Null to reset
*/
@NotNull
public final void setSpawnSound(@Nullable Sound s) {
if (s == null) this.spawnSound = s; else this.spawnSound = Sound.ENTITY_WITHER_SPAWN;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ public final class Minion<T extends Mob> {

private final Class<T> entityClazz;
private double health;
private Map<EquipmentSlot, ItemStack> equipment;
private final Map<EquipmentSlot, ItemStack> equipment;

private Map<AttributeInstance, Double> attributes;
private final Map<AttributeInstance, Double> attributes;

/**
* Creates a Minion.
Expand Down
11 changes: 7 additions & 4 deletions base/src/main/java/me/gamercoder215/mobchip/nbt/NBTSection.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package me.gamercoder215.mobchip.nbt;

import org.bukkit.*;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.NamespacedKey;
import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle;
Expand Down Expand Up @@ -552,7 +555,7 @@ default List<String> getStringList(@Nullable String key) {
*/
@Nullable
default List<String> getStringList(@Nullable String key, @Nullable List<String> def) {
if (getList(key) == null) return def;
if (getList(key).isEmpty()) return def;
return getStringList(key);
}

Expand All @@ -563,7 +566,7 @@ default List<String> getStringList(@Nullable String key, @Nullable List<String>
*/
@NotNull
default List<Integer> getIntegerList(@Nullable String key) {
if (getList(key) == null) return null;
if (getList(key).isEmpty()) return null;
return getList(key).stream().map(Object::toString).map(s -> { try { return Integer.parseInt(s); } catch (NumberFormatException e) { return null; } }).filter(Objects::nonNull).collect(Collectors.toList());
}

Expand All @@ -575,7 +578,7 @@ default List<Integer> getIntegerList(@Nullable String key) {
*/
@Nullable
default List<Integer> getIntegerList(@Nullable String key, @Nullable List<Integer> def) {
if (getList(key) == null) return def;
if (getList(key).isEmpty()) return def;
return getIntegerList(key);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* Represents registration under a specific context.
* <br><br>
* Minecraft 1.20.5 introduced new changes to how registering new items (e.g. attributes, sensors, etc) work.
* Minecraft 1.20.5 introduced new changes to how registering new items (e.g. attributes, sensors, etc.) work.
* You are now required to pass a namespace, key, and version, as opposed to just a namespace and key.
* There is no functional difference if this is not provided, so MobChip will default to "unknown" for the version.
* You can provide custom parameters here for improved native interoperability with the registry.
Expand Down
11 changes: 6 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
@file:Suppress("UnstableApiUsage")

import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
id("org.sonarqube") version "4.0.0.2929"
Expand All @@ -14,7 +13,7 @@ plugins {
}

val pGroup = "me.gamercoder215"
val pVersion = "1.10.0-SNAPSHOT"
val pVersion = "1.10.1-SNAPSHOT"
val pAuthor = "gmitch215"

val github = "$pAuthor/MobChip"
Expand Down Expand Up @@ -178,11 +177,13 @@ subprojects {
options.encoding = "UTF-8"
options.isDeprecation = false
options.isWarnings = false
options.compilerArgs.addAll(listOf("-Xlint:all", "-Xlint:-processing"))
options.compilerArgs.addAll(listOf("-Xlint:all", "-Xlint:-processing", "-Xlint:-options"))
}

compileKotlin {
kotlinOptions.jvmTarget = jvmVersion.toString()
compilerOptions {
jvmTarget.set(JvmTarget.JVM_1_8)
}
}

jacocoTestReport {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ public static EntityAttribute getAttribute(@Nullable NamespacedKey key) {
* @param key Key of the Attribute
* @return true if attribute exists, else false
*/
@Nullable
public static boolean exists(@Nullable NamespacedKey key) {
return getAttribute(key) != null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ final class BukkitAI implements EntityAI {

private final Mob m;

protected BukkitAI(Mob m, boolean target) {
BukkitAI(Mob m, boolean target) {
this.target = target;
this.m = m;
updateMap();
Expand Down Expand Up @@ -66,7 +66,7 @@ public boolean contains(Object o) {
}

@Override
public boolean contains(Pathfinder value) {
public boolean contains(@NotNull Pathfinder value) {
return wrapper.getGoals(m, target).stream().map(WrappedPathfinder::getPathfinder).collect(Collectors.toList()).contains(value);
}

Expand All @@ -88,7 +88,7 @@ public boolean remove(@NotNull Pathfinder p) {
}

@Override
public boolean isRunning(Pathfinder p) {
public boolean isRunning(@NotNull Pathfinder p) {
return wrapper.getRunningGoals(m, target).stream().map(WrappedPathfinder::getPathfinder).collect(Collectors.toList()).contains(p);
}

Expand All @@ -100,12 +100,12 @@ public Iterator<WrappedPathfinder> iterator() {

@NotNull
@Override
public WrappedPathfinder[] toArray() {
public WrappedPathfinder @NotNull [] toArray() {
return goals.toArray(new WrappedPathfinder[0]);
}

@Override
public <T> T[] toArray(@NotNull T[] a) {
public <T> T @NotNull [] toArray(@NotNull T @NotNull [] a) {
return a;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ class BukkitVillagerBrain extends BukkitBrain implements VillagerBrain {
}

@Override
public EntityGossipContainer getGossipContainer() {
public @NotNull EntityGossipContainer getGossipContainer() {
return w.getGossipContainer(v);
}

@Override
public Villager getEntity() {
public @NotNull Villager getEntity() {
return v;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package me.gamercoder215.mobchip.ai.memories

/**
* Registeres this [Memory] to the Memory Registry.
* Registers this [Memory] to the Memory Registry.
* @throws IllegalStateException if this [Memory] is already registered.
*/
@Throws(IllegalStateException::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import me.gamercoder215.mobchip.combat.CombatLocation;
import me.gamercoder215.mobchip.combat.EntityCombatTracker;
import me.gamercoder215.mobchip.nbt.EntityNBT;
import me.gamercoder215.mobchip.util.Position;
import net.minecraft.server.v1_13_R1.*;
import org.bukkit.World;
import org.bukkit.*;
Expand Down Expand Up @@ -1154,4 +1155,8 @@ public EnderCrystal getNearestCrystal(EnderDragon d) {
if (nms.currentEnderCrystal == null) return null;
return (EnderCrystal) nms.currentEnderCrystal.getBukkitEntity();
}

public static Position fromNMS(PathPoint point) {
return new Position(point.a, point.b, point.c);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@
final class EntityNBT1_13_R1 extends NBTSection1_13_R1 implements EntityNBT {

private final Mob mob;
private final EntityInsentient handle;

private final NBTTagCompound root;

public EntityNBT1_13_R1(Mob m) {
super(m);
this.mob = m;
this.handle = ChipUtil1_13_R1.toNMS(m);
this.root = new NBTTagCompound();
EntityInsentient handle = ChipUtil1_13_R1.toNMS(m);
NBTTagCompound root = new NBTTagCompound();
handle.d(root);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ public void set(@Nullable String key, @Nullable Object value) {

@Override
public boolean isSet(@Nullable String key) {
return false;
return tag.hasKey(key);
}

@Override
Expand Down
Loading

0 comments on commit bffcc51

Please sign in to comment.