revert the GameEvent::setSourceId removal

xenodron mentionned that one of the use of setSourceId is to more easily find the Event that use non-standard
sourceId.

So reverting the change made in a previous commit.

It was a non-functional change meant to ease new
BatchEvent sharing sourceId, but I'll use setSourceId
instead there.
This commit is contained in:
Susucre 2024-04-30 11:51:11 +02:00
parent 00556c4cf6
commit 95adcf0e9a
26 changed files with 88 additions and 63 deletions

View file

@ -25,9 +25,10 @@ public abstract class BatchEvent<T extends GameEvent> extends GameEvent {
* @param firstEvent added to initialize the batch (batch is never empty)
*/
protected BatchEvent(EventType eventType, boolean singleTargetId, boolean singleSourceId, T firstEvent) {
super(eventType, (singleTargetId ? firstEvent.getTargetId() : null), (singleSourceId ? firstEvent.getSourceId() : null), null);
super(eventType, (singleTargetId ? firstEvent.getTargetId() : null), null, null);
this.singleTargetId = singleTargetId;
this.singleSourceId = singleSourceId;
this.setSourceId(singleSourceId ? firstEvent.getSourceId() : null);
if (firstEvent instanceof BatchEvent) { // sanity check, if you need it then think twice and research carefully
throw new UnsupportedOperationException("Wrong code usage: nesting batch events not supported");
}
@ -38,7 +39,7 @@ public abstract class BatchEvent<T extends GameEvent> extends GameEvent {
* For alternate event structure logic used by ZoneChangeBatchEvent, list of events starts empty.
*/
protected BatchEvent(EventType eventType) {
super(eventType, null, (UUID) null, null);
super(eventType, null, null, null);
this.singleTargetId = false;
this.singleSourceId = false;
}