Skip to content

Commit

Permalink
feat: update to event-impl-gen 8 release
Browse files Browse the repository at this point in the history
  • Loading branch information
gabizou committed Jan 1, 2025
1 parent 80b3328 commit 0a341e3
Show file tree
Hide file tree
Showing 27 changed files with 149 additions and 31 deletions.
1 change: 1 addition & 0 deletions .checkstyle/checkstyle-suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
<suppress checks="MethodTypeParameterName"/>
<suppress checks="CommentsIndentation"/>
<suppress checks="InterfaceTypeParameterName"/>
<suppress files="[\\/]generated[\\/]" checks="[a-zA-Z0-9]*"/>
</suppressions>
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ dependency-reduced-pom.xml
!.checkstyle/
# We exclude the generated events from git to avoid
# temptation to edit said generated files.
src/main/generated/
src/generated/

# Compiled #
############
Expand Down
23 changes: 20 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import net.ltgt.gradle.errorprone.errorprone
import org.jetbrains.gradle.ext.delegateActions
import org.jetbrains.gradle.ext.settings
import org.jetbrains.gradle.ext.taskTriggers


plugins {
Expand All @@ -18,7 +17,7 @@ plugins {

// Enable event generation to be considered part of
// the main source set
val generatedEventSourcesDir = project.file("src/main/generated")
val generatedEventSourcesDir = project.file("src/generated/java")
val javaTarget: String by project
val ap by sourceSets.registering {
compileClasspath += sourceSets.main.get().compileClasspath + sourceSets.main.get().output
Expand All @@ -44,7 +43,9 @@ tasks {

sourceSets {
main {
java.srcDirs(generatedEventSourcesDir)
java {
srcDirs(generatedEventSourcesDir)
}
}
}

Expand Down Expand Up @@ -145,6 +146,13 @@ dependencies {
testImplementation(libs.mockito)
}

spotless {
java {
target("src/main/java/**/*.java")
targetExclude("src/gen/java/**/*.java")
}
}

tasks {

compileJava {
Expand All @@ -170,6 +178,15 @@ tasks {
indraGit.applyVcsInformationToManifest(this)
}
}
checkstyleMain {
dependsOn(compileJava)
}
spotlessJava {
dependsOn(compileJava)
}
sourcesJar {
dependsOn(compileJava)
}

withType(JavaCompile::class).configureEach {
options.apply {
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ guice = { module = "com.google.inject:guice", version.ref = "guice" }
log4j-api = { module = "org.apache.logging.log4j:log4j-api", version.ref = "log4j" }
math = { module = "org.spongepowered:math", version.ref = "math" }
pluginSpi = { module = "org.spongepowered:plugin-spi", version.ref = "pluginSpi" }
eventImplGen-processor = {module = "org.spongepowered:event-impl-gen", version = "8.0.0-SNAPSHOT"}
eventImplGen-annotations = { module = "org.spongepowered:event-impl-gen-annotations", version = "8.0.0-SNAPSHOT"}
eventImplGen-processor = {module = "org.spongepowered:event-impl-gen", version = "8.0.0"}
eventImplGen-annotations = { module = "org.spongepowered:event-impl-gen-annotations", version = "8.0.0"}

# build-time/annotations

Expand Down
50 changes: 46 additions & 4 deletions gradle/verification-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
<configuration>
<verify-metadata>true</verify-metadata>
<verify-signatures>false</verify-signatures>
<trusted-artifacts>
<trust group="org.spongepowered" name="event-impl-gen" reason="SNAPSHOT"/>
<trust group="org.spongepowered" name="event-impl-gen-annotations" reason="SNAPSHOT"/>
</trusted-artifacts>
</configuration>
<components>
<component group="aopalliance" name="aopalliance" version="1.0">
Expand Down Expand Up @@ -272,6 +268,14 @@
<sha256 value="5cb60843f46bbccf97bd832d5490d26ab192af2e663fad7e5971969bf20fb94e" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.google.dagger" name="dagger" version="2.54">
<artifact name="dagger-2.54.jar">
<sha256 value="7ab0d8278a532888de19025dc6ee70a80ecd4567778a6a7e7ec256a2073e40a3" origin="Generated by Gradle"/>
</artifact>
<artifact name="dagger-2.54.pom">
<sha256 value="af43413fd91fc49532884ca32191ab31bec609c344d4939aece9d3efef699f81" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.google.errorprone" name="error_prone_annotation" version="2.24.1">
<artifact name="error_prone_annotation-2.24.1.jar">
<sha256 value="dc202da451680aa8cdda7c68d959f27c112dca8f8fdeaf7c597de73cb2b1a0a6" origin="Generated by Gradle"/>
Expand Down Expand Up @@ -569,6 +573,14 @@
<sha256 value="9acf56a8579c05bedd819d99232363e2bf327e8f73c67598dbd9885a845a3c69" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.palantir.javapoet" name="javapoet" version="0.6.0">
<artifact name="javapoet-0.6.0.jar">
<sha256 value="1c8dd1cc4404b9eeb5c54fef8a1cf2be7a138a42783b9460fbae9caf85ed5b2f" origin="Generated by Gradle"/>
</artifact>
<artifact name="javapoet-0.6.0.pom">
<sha256 value="f6e34a26ac09a3a68a91cc9235cb1f8c7736b07fe89db59a324acd8d57d9e797" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.puppycrawl.tools" name="checkstyle" version="10.12.7">
<artifact name="checkstyle-10.12.7.jar">
<sha256 value="767cc2393169f0abe4292e59c3b62317149f900a472cd6b01f74346f6bdae581" origin="Generated by Gradle"/>
Expand Down Expand Up @@ -1552,6 +1564,9 @@
<artifact name="checker-qual-3.19.0.module">
<sha256 value="53e1899dde3c513ca1efd376abffac0e6907e8e84abd5f966242634c95e4d157" origin="Generated by Gradle"/>
</artifact>
<artifact name="checker-qual-3.19.0.pom">
<sha256 value="29ba9c5ce1a94b700bd823c4ed612f5827b590f19a49775fd7eb8f997f8aa371" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.checkerframework" name="checker-qual" version="3.33.0">
<artifact name="checker-qual-3.33.0.jar">
Expand Down Expand Up @@ -1810,6 +1825,14 @@
<sha256 value="33b8c22f2424c2903241a7fea258fc41ab0c4d6889776576c519047562ee43a5" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.jspecify" name="jspecify" version="1.0.0">
<artifact name="jspecify-1.0.0.jar">
<sha256 value="1fad6e6be7557781e4d33729d49ae1cdc8fdda6fe477bb0cc68ce351eafdfbab" origin="Generated by Gradle"/>
</artifact>
<artifact name="jspecify-1.0.0.module">
<sha256 value="d307ca77a54e18ac1ef1aaed4e5bbe014bd2f49f29e1d2f813e47c278283195b" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.junit" name="junit-bom" version="5.10.0">
<artifact name="junit-bom-5.10.0.module">
<sha256 value="eb3ee6127608010694a898056e7407d117296003aba5f5db801df430b9887fcf" origin="Generated by Gradle"/>
Expand Down Expand Up @@ -2134,6 +2157,25 @@
<sha256 value="b68149d290f328b6b54d0f7f7d304adab5148cedd6ae18dc3baae8bf9f1757c6" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.spongepowered" name="event-impl-gen" version="8.0.0">
<artifact name="event-impl-gen-8.0.0.jar">
<sha256 value="6e26ff9a8d9f5a9fe39fe3e64781061bf068405c04095d78c044719ac2918992" origin="Generated by Gradle"/>
</artifact>
<artifact name="event-impl-gen-8.0.0.module">
<sha256 value="5b919469a6bead6b6107212e4bf441c7576fc52f0b590db4bc13f742ebbfd983" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.spongepowered" name="event-impl-gen-annotations" version="8.0.0">
<artifact name="event-impl-gen-annotations-8.0.0-javadoc.jar">
<sha256 value="6f4b8d62436da73bedb9baf543180f5068e99b77d38f15fbd463d4df7251d4d9" origin="Generated by Gradle"/>
</artifact>
<artifact name="event-impl-gen-annotations-8.0.0.jar">
<sha256 value="278e01efedb92a95be74714ea2bec08d29326b4893f6e957aa3bd39a15840776" origin="Generated by Gradle"/>
</artifact>
<artifact name="event-impl-gen-annotations-8.0.0.module">
<sha256 value="b0fddddd441038c0889450e8c0ebac970f0d606b246db99fd59c23c73e7ba534" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.spongepowered" name="math" version="2.0.1">
<artifact name="math-2.0.1-javadoc.jar">
<sha256 value="eef4d1e6421cd975ebdb7ae6be8632c0e89c0e8b671ee0fb542d8e6ddad2df12" origin="Generated by Gradle"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
import org.spongepowered.api.data.value.Value;
import org.spongepowered.api.data.value.ValueContainer;
import org.spongepowered.api.entity.Entity;
import org.spongepowered.eventgen.annotations.TransformWith;
import org.spongepowered.api.world.World;
import org.spongepowered.eventgen.annotations.TransformWith;

import java.util.Arrays;
import java.util.Objects;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public interface Zombie extends Monster {
*
* @return Whether this zombie is an adult or not
*/
@Override
default Value.Mutable<Boolean> adult() {
return this.requireValue(Keys.IS_ADULT).asMutable();
}
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/org/spongepowered/api/event/CompositeEvent.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
/*
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
*
* Copyright (c) SpongePowered <https://www.spongepowered.org>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.api.event;

import org.spongepowered.api.event.impl.AbstractCompositeEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import org.spongepowered.api.entity.Entity;
import org.spongepowered.api.event.Cancellable;
import org.spongepowered.api.event.Event;
import org.spongepowered.eventgen.annotations.NoFactoryMethod;
import org.spongepowered.api.world.server.ServerLocation;
import org.spongepowered.eventgen.annotations.NoFactoryMethod;

/**
* Fired when an {@link Entity} or {@link BlockSnapshot} collide with each other.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
import org.spongepowered.api.item.inventory.ItemStack;
import org.spongepowered.api.util.Direction;
import org.spongepowered.api.util.Tristate;
import org.spongepowered.api.world.server.ServerLocation;
import org.spongepowered.eventgen.annotations.GenerateFactoryMethod;
import org.spongepowered.eventgen.annotations.ImplementedBy;
import org.spongepowered.api.world.server.ServerLocation;
import org.spongepowered.math.vector.Vector3d;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* Fired when a {@link ScheduledUpdate scheduled block update}
* is being proposed to the engine.
*/
public interface ScheduleBlockUpdateEvent<T extends Object> extends GenericEvent<T>, Cancellable {
public interface ScheduleBlockUpdateEvent<T> extends GenericEvent<T>, Cancellable {

/**
* Gets a list of the {@link ScheduleUpdateTicket}s for this event.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
import org.spongepowered.api.event.Event;
import org.spongepowered.api.event.Order;
import org.spongepowered.api.event.impl.entity.AbstractAffectEntityEvent;
import org.spongepowered.api.world.explosion.Explosion;
import org.spongepowered.api.world.server.ServerLocation;
import org.spongepowered.eventgen.annotations.ImplementedBy;
import org.spongepowered.eventgen.annotations.NoFactoryMethod;
import org.spongepowered.eventgen.annotations.PropertySettings;
import org.spongepowered.api.world.explosion.Explosion;
import org.spongepowered.api.world.server.ServerLocation;

import java.util.List;
import java.util.function.Predicate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@
import org.spongepowered.api.item.inventory.ItemStack;
import org.spongepowered.api.item.inventory.ItemStackSnapshot;
import org.spongepowered.api.util.Tuple;
import org.spongepowered.eventgen.annotations.ImplementedBy;
import org.spongepowered.eventgen.annotations.PropertySettings;
import org.spongepowered.api.world.World;
import org.spongepowered.api.world.difficulty.Difficulties;
import org.spongepowered.api.world.difficulty.Difficulty;
import org.spongepowered.eventgen.annotations.ImplementedBy;
import org.spongepowered.eventgen.annotations.PropertySettings;

import java.util.List;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import org.spongepowered.api.entity.Entity;
import org.spongepowered.api.event.Cancellable;
import org.spongepowered.api.event.Event;
import org.spongepowered.eventgen.annotations.AbsoluteSortPosition;
import org.spongepowered.api.world.server.ServerWorld;
import org.spongepowered.eventgen.annotations.AbsoluteSortPosition;

/**
* Called when an {@link Entity} is changing {@link ServerWorld worlds}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@
import org.spongepowered.api.item.ItemTypes;
import org.spongepowered.api.item.inventory.ItemStack;
import org.spongepowered.api.util.Tuple;
import org.spongepowered.eventgen.annotations.ImplementedBy;
import org.spongepowered.eventgen.annotations.PropertySettings;
import org.spongepowered.api.world.World;
import org.spongepowered.api.world.difficulty.Difficulties;
import org.spongepowered.api.world.difficulty.Difficulty;
import org.spongepowered.eventgen.annotations.ImplementedBy;
import org.spongepowered.eventgen.annotations.PropertySettings;

import java.util.List;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
import org.spongepowered.api.event.Cancellable;
import org.spongepowered.api.event.message.AudienceMessageEvent;
import org.spongepowered.api.event.message.MessageCancellable;
import org.spongepowered.eventgen.annotations.GenerateFactoryMethod;
import org.spongepowered.api.world.gamerule.GameRules;
import org.spongepowered.eventgen.annotations.GenerateFactoryMethod;

/**
* An event where the {@link Entity} is being either removed usually due to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
import org.spongepowered.api.entity.Entity;
import org.spongepowered.api.event.Cancellable;
import org.spongepowered.api.event.Event;
import org.spongepowered.api.world.portal.PortalLogic;
import org.spongepowered.eventgen.annotations.AbsoluteSortPosition;
import org.spongepowered.eventgen.annotations.GenerateFactoryMethod;
import org.spongepowered.eventgen.annotations.NoFactoryMethod;
import org.spongepowered.api.world.portal.PortalLogic;
import org.spongepowered.math.vector.Vector3d;

import java.util.Optional;
Expand Down Expand Up @@ -59,6 +60,7 @@ public interface InvokePortalEvent extends Event {
* Called when entering a portal.
* Cancel to prevent portal effects.
*/
@GenerateFactoryMethod
interface Enter extends InvokePortalEvent, Cancellable {

/**
Expand Down Expand Up @@ -88,6 +90,7 @@ interface Enter extends InvokePortalEvent, Cancellable {
* Canceling resets the portal transition time
* Setting custom portal logic can change the teleport behaviour.
*/
@GenerateFactoryMethod
interface Prepare extends InvokePortalEvent, Cancellable {

/**
Expand All @@ -102,6 +105,7 @@ interface Prepare extends InvokePortalEvent, Cancellable {
* Called after a {@link PortalLogic} calculated and found or generated the portal exit.
* Note that {@link ChangeEntityWorldEvent} still fire after this.
*/
@GenerateFactoryMethod
interface Execute extends InvokePortalEvent, ChangeEntityWorldEvent.Reposition, RotateEntityEvent {

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
/*
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
*
* Copyright (c) SpongePowered <https://www.spongepowered.org>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.api.event.impl;

import org.spongepowered.api.event.Cancellable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@

import org.spongepowered.api.event.impl.entity.AbstractAffectEntityEvent;
import org.spongepowered.api.event.world.ExplosionEvent;
import org.spongepowered.eventgen.annotations.UseField;
import org.spongepowered.api.world.server.ServerLocation;
import org.spongepowered.eventgen.annotations.UseField;

import java.util.Collections;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.spongepowered.api.event.Cancellable;
import org.spongepowered.api.event.Cause;
import org.spongepowered.api.registry.RegistryReference;
import org.spongepowered.eventgen.annotations.NoFactoryMethod;

import java.util.Optional;
import java.util.function.Predicate;
Expand Down
Loading

0 comments on commit 0a341e3

Please sign in to comment.