From e1784552dea900c33ee6220fba48085a50567b50 Mon Sep 17 00:00:00 2001 From: Andreas Troelsen Date: Sat, 22 Aug 2020 15:00:11 +0200 Subject: [PATCH] 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. --- .../MobArena/things/ThingGroup.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/main/java/com/garbagemule/MobArena/things/ThingGroup.java diff --git a/src/main/java/com/garbagemule/MobArena/things/ThingGroup.java b/src/main/java/com/garbagemule/MobArena/things/ThingGroup.java new file mode 100644 index 0000000..c5575ce --- /dev/null +++ b/src/main/java/com/garbagemule/MobArena/things/ThingGroup.java @@ -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 things; + + public ThingGroup(List 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 ")); + } + +}