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.0 (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
gmitch215 committed May 4, 2024
2 parents 10b1530 + cdf4c46 commit bba72d4
Show file tree
Hide file tree
Showing 67 changed files with 4,561 additions and 154 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: gradle/wrapper-validation-action@v3
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'
cache: 'gradle'
- name: Change Permissions
run: chmod +x ./gradlew
Expand All @@ -34,7 +34,7 @@ jobs:

strategy:
matrix:
java-version: [17, 18, 19]
java-version: [8, 11, 16, 17, 21]

name: Build Java ${{ matrix.java-version }}
steps:
Expand All @@ -58,10 +58,10 @@ jobs:
name: Test Project
steps:
- uses: actions/checkout@v4
- name: Setup JDK 17
- name: Setup JDK 21
uses: actions/setup-java@v4
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
cache: 'gradle'
- name: Change Permissions
Expand All @@ -77,11 +77,11 @@ jobs:
name: Create Artifacts
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'
cache: 'gradle'
- name: Change Permissions
run: chmod +x ./gradlew
Expand All @@ -108,11 +108,11 @@ jobs:
if: ${{ github.event_name != 'pull_request' && github.ref_name == 'master' }}
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'
cache: 'gradle'
- name: Change Permissions
run: chmod +x ./gradlew
Expand Down Expand Up @@ -150,4 +150,4 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./gradlew clean assemble sonar --info
run: ./gradlew clean assemble sonar --info
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ default void clearPathfinders(Mob mob, boolean target) {
getGoals(mob, target).forEach(w -> removePathfinder(w.getPathfinder(), target));
}

default void addPathfinders(Collection<? extends WrappedPathfinder> c, boolean target) {
default void addPathfinders(Collection<WrappedPathfinder> c, boolean target) {
for (WrappedPathfinder p : c) addPathfinder(p.getPathfinder(), p.getPriority(), target);
}

Expand Down Expand Up @@ -178,7 +178,7 @@ static Class<?>[] getArgTypes(Object... args) {
return types;
}

static String bukkitToCraftBukkkit() {
static String bukkitToCraftBukkit() {
String bukkit = Bukkit.getServer().getBukkitVersion().split("-")[0];
switch (bukkit) {
case "1.20.1":
Expand All @@ -188,6 +188,8 @@ static String bukkitToCraftBukkkit() {
case "1.20.3":
case "1.20.4":
return "1_20_R3";
case "1.20.5":
return "1_20_R4";
default:
throw new AssertionError("Invalid Version: " + bukkit);
}
Expand All @@ -198,7 +200,7 @@ static String getServerVersion() {
return Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3].substring(1);
} catch (IndexOutOfBoundsException e) {
// Using CraftBukkit Relocation
return bukkitToCraftBukkkit();
return bukkitToCraftBukkit();
}
}

Expand All @@ -217,7 +219,8 @@ static ChipUtil getWrapper() {

static void printStackTrace(Throwable e) {
Bukkit.getLogger().severe(e.getClass().getName() + ": " + e.getMessage());
for (StackTraceElement s : e.getStackTrace()) Bukkit.getLogger().severe(" " + s.toString());
for (StackTraceElement s : e.getStackTrace())
Bukkit.getLogger().severe(s.toString());
if (e.getCause() != null) {
Bukkit.getLogger().severe("Caused by:");
printStackTrace(e.getCause());
Expand Down
4 changes: 4 additions & 0 deletions base/src/main/java/me/gamercoder215/mobchip/EntityBody.java
Original file line number Diff line number Diff line change
Expand Up @@ -505,13 +505,17 @@ default void addCollideExemptions(@NotNull Iterable<Entity> entities) throws Ill
/**
* Fetches the maximum block height this entity can walk up without jumping.
* @return Maximum step height
* @deprecated Exposed in Minecraft 1.20.5 via Attribute#STEP_HEIGHT
*/
@Deprecated
float getMaxUpStep();

/**
* Sets the maximum block height this entity can walk up without jumping.
* @param maxUpStep Maximum step height
* @deprecated Exposed in Minecraft 1.20.5 via Attribute#STEP_HEIGHT
*/
@Deprecated
void setMaxUpStep(float maxUpStep);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ public abstract class BehaviorResult {
return Status.STOPPED;
}
@Override
public void stop() {}
public void stop() {
// Do nothing
}
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected CustomPathfinder(@NotNull Mob m) {
* // public class LavaFloat extends CustomPathfinder {
*
* // This Pathfinder Goal will involve movement and jumping, so we have to add it as a flag
* public Set PathfinderFlag> getFlags() {
* getFlags() {
* return new PathfinderFlag[] { PathfinderFlag.MOVEMENT, PathfinderFlag.JUMPING; }
* }
* </pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public PathfinderBeg(@NotNull Wolf w) {
*/
public PathfinderBeg(@NotNull Wolf w, float lookRange) {
super(w);
this.lookRange = lookRange;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ public PathfinderFollowFishLeader(@NotNull Fish f) {

@Override
public String getInternalName() {
return "FollowFlockLeaderGoal";
return "PathfinderGoalFishSchool";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,10 @@ public void setItems(@NotNull Iterable<? extends ItemStack> items) throws Illega
* @param items Array of Items to use
* @throws IllegalArgumentException if Items are null or empty
*/
public void setItems(@NotNull ItemStack... items) throws IllegalArgumentException
{ if (items == null) throw new IllegalArgumentException("Items cannot be null"); setItems(Arrays.asList(items)); }
public void setItems(@NotNull ItemStack... items) throws IllegalArgumentException {
if (items == null) throw new IllegalArgumentException("Items cannot be null");
setItems(Arrays.asList(items));
}

@Override
public double getSpeedModifier() {
Expand Down
9 changes: 3 additions & 6 deletions base/src/main/java/me/gamercoder215/mobchip/bosses/Boss.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.*;

/**
* Represents a Boss Entity.
Expand All @@ -51,7 +48,7 @@ public abstract class Boss<T extends Mob> {
private float pitch;

private double health = DEFAULT_HEALTH;
private final Map<EquipmentSlot, ItemStack> equipment = new HashMap<>();
private final Map<EquipmentSlot, ItemStack> equipment = new EnumMap<>(EquipmentSlot.class);

private final Map<AttributeInstance, Double> attributes = new HashMap<>();

Expand Down Expand Up @@ -237,7 +234,7 @@ public void run() {
Bukkit.getLogger().severe(e.getCause().getMessage());
for (StackTraceElement s : e.getCause().getStackTrace()) Bukkit.getLogger().severe(s.toString());
} catch (Exception e) {
Bukkit.getLogger().severe(e.getMessage());
Bukkit.getLogger().severe(e.getMessage());
for (StackTraceElement s : e.getStackTrace()) Bukkit.getLogger().severe(s.toString());
}
}
Expand Down
14 changes: 5 additions & 9 deletions base/src/main/java/me/gamercoder215/mobchip/util/Position.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ public double distance(@NotNull Entity en) {
* @return distance squared
*/
public double distanceSquared(@NotNull Position node) {
double x = this.x - node.x;
double y = this.y - node.y;
double z = this.z - node.z;
int x = this.x - node.x;
int y = this.y - node.y;
int z = this.z - node.z;

return x * x + y * y + z * z;
return (x * x) + (y * y) + (z * z);
}

/**
Expand Down Expand Up @@ -309,10 +309,6 @@ public Position setZ(int z) {

@Override
public Position clone() {
try {
return (Position) super.clone();
} catch (CloneNotSupportedException e) {
throw new Error(e);
}
return new Position(x, y, z);
}
}
47 changes: 47 additions & 0 deletions base/src/main/java/me/gamercoder215/mobchip/util/Registration.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package me.gamercoder215.mobchip.util;

import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;

/**
* 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.
* 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.
*/
public final class Registration {

private static String version = "unknown";

private Registration() { throw new UnsupportedOperationException("This class cannot be instantiated."); }

/**
* Gets the version for registration.
* @return The version.
*/
@NotNull
public static String getVersion() {
return version;
}

/**
* Sets the version for registration.
* @param version The version to set.
*/
public static void setVersion(@NotNull String version) {
if (version == null) throw new IllegalArgumentException("Version cannot be null.");
Registration.version = version;
}

/**
* Use the plugin version for registration.
* @param plugin The plugin to use.
*/
public static void usePlugin(@NotNull Plugin plugin) {
if (plugin == null) throw new IllegalArgumentException("Plugin cannot be null.");
setVersion(plugin.getDescription().getVersion());
}

}
31 changes: 12 additions & 19 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

plugins {
id("org.sonarqube") version "4.0.0.2929"
id("com.github.johnrengelman.shadow") version "8.1.1" apply false
id("io.github.goooler.shadow") version "8.1.7" apply false
kotlin("jvm") version "1.9.23"

java
Expand All @@ -14,15 +14,15 @@ plugins {
}

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

val github = "$pAuthor/MobChip"

sonarqube {
properties {
property("sonar.projectKey", "${pAuthor}_MobChip")
property("sonar.organization", "gamercoder215")
property("sonar.projectKey", "GamerCoder215_MobChip")
property("sonar.organization", "gmitch215")
property("sonar.host.url", "https://sonarcloud.io")
}
}
Expand Down Expand Up @@ -102,9 +102,8 @@ allprojects {
developer {
id.set(pAuthor)
roles.add("Owner")
email.set("gamer@gamercoder.me")
email.set("me@gmitch215.xyz")
organization.set("Team Inceptus")
organizationUrl.set("https://teaminceptus.us")
}
}

Expand Down Expand Up @@ -152,7 +151,7 @@ subprojects {
apply<JacocoPlugin>()
apply(plugin = "org.jetbrains.kotlin.jvm")
apply(plugin = "org.sonarqube")
apply(plugin = "com.github.johnrengelman.shadow")
apply(plugin = "io.github.goooler.shadow")

dependencies {
testImplementation("org.mockito:mockito-core:5.11.0")
Expand All @@ -171,6 +170,10 @@ subprojects {
}

tasks {
clean {
delete("logs")
}

compileJava {
options.encoding = "UTF-8"
options.isDeprecation = false
Expand Down Expand Up @@ -202,16 +205,6 @@ subprojects {
finalizedBy(jacocoTestReport)
}

jacocoTestReport {
reports {
xml.required.set(false)
csv.required.set(false)

html.required.set(true)
html.outputLocation.set(layout.buildDirectory.dir("jacocoHtml"))
}
}

javadoc {
enabled = false

Expand Down Expand Up @@ -246,4 +239,4 @@ subprojects {
artifacts {
add("default", tasks.getByName<ShadowJar>("shadowJar"))
}
}
}
Loading

0 comments on commit bba72d4

Please sign in to comment.