Add ThingGroup.

Introduces a group of Things as a construct for bundling Things that
should constitute a single unit for whatever reason.

One reason could be to make an _item set_ an atomic reward, e.g. a set
of diamond tools for beating the `workshop` arena. Instead of having to
spread the rewards out into multiple waves or use a different plugin to
create item groups, this component allows MobArena to support that kind
of intent natively.

Note that nothing is wired up in this commit, so really this commit is
just introducing unused code.
This commit is contained in:
Andreas Troelsen 2020-08-22 15:00:11 +02:00
parent 4f11889549
commit e1784552de

View File

@ -0,0 +1,39 @@
package com.garbagemule.MobArena.things;
import org.bukkit.entity.Player;
import java.util.List;
import java.util.stream.Collectors;
public class ThingGroup implements Thing {
private final List<Thing> things;
public ThingGroup(List<Thing> things) {
this.things = things;
}
@Override
public boolean giveTo(Player player) {
things.forEach(thing -> thing.giveTo(player));
return true;
}
@Override
public boolean takeFrom(Player player) {
return false;
}
@Override
public boolean heldBy(Player player) {
return false;
}
@Override
public String toString() {
return things.stream()
.map(Thing::toString)
.collect(Collectors.joining(" and "));
}
}