From 0c089e65a622c22b32822d18fd611bf26c5cdc2e Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Mon, 27 Jan 2020 01:49:31 +0100 Subject: [PATCH] Add reward API --- .../erethon/dungeonsxl/api/DungeonsAPI.java | 7 ++++ .../de/erethon/dungeonsxl/api/Reward.java | 34 +++++++++++++++++++ .../dungeonsxl/api/player/PlayerGroup.java | 24 +++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 api/src/main/java/de/erethon/dungeonsxl/api/Reward.java diff --git a/api/src/main/java/de/erethon/dungeonsxl/api/DungeonsAPI.java b/api/src/main/java/de/erethon/dungeonsxl/api/DungeonsAPI.java index f0aa9c83..b179905e 100644 --- a/api/src/main/java/de/erethon/dungeonsxl/api/DungeonsAPI.java +++ b/api/src/main/java/de/erethon/dungeonsxl/api/DungeonsAPI.java @@ -60,6 +60,13 @@ public interface DungeonsAPI extends Plugin { */ Registry> getTriggerRegistry(); + /** + * Returns a {@link Registry} of the reward types. + * + * @return a {@link Registry} of the reward types + */ + Registry> getRewardRegistry(); + /* Object initialization */ /** * Creates a new group. diff --git a/api/src/main/java/de/erethon/dungeonsxl/api/Reward.java b/api/src/main/java/de/erethon/dungeonsxl/api/Reward.java new file mode 100644 index 00000000..eecd88c3 --- /dev/null +++ b/api/src/main/java/de/erethon/dungeonsxl/api/Reward.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2014-2020 Daniel Saukel + * + * This library is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNULesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with + * this program. If not, see . + */ +package de.erethon.dungeonsxl.api; + +import org.bukkit.entity.Player; + +/** + * Something players are given when they successfully finish a {@link de.erethon.dungeonsxl.api.Dungeon}. + *

+ * @see de.erethon.dungeonsxl.api.player.PlayerGroup#getRewards() + * @author Daniel Saukel + */ +public interface Reward { + + /** + * Gives the reward to the given player. + * + * @param player the player + */ + void giveTo(Player player); + +} diff --git a/api/src/main/java/de/erethon/dungeonsxl/api/player/PlayerGroup.java b/api/src/main/java/de/erethon/dungeonsxl/api/player/PlayerGroup.java index 6e9007c4..e2d44468 100644 --- a/api/src/main/java/de/erethon/dungeonsxl/api/player/PlayerGroup.java +++ b/api/src/main/java/de/erethon/dungeonsxl/api/player/PlayerGroup.java @@ -20,7 +20,10 @@ import de.erethon.commons.chat.MessageUtil; import de.erethon.commons.compatibility.Version; import de.erethon.commons.player.PlayerCollection; import de.erethon.dungeonsxl.api.Dungeon; +import de.erethon.dungeonsxl.api.Reward; import de.erethon.dungeonsxl.api.world.GameWorld; +import java.util.List; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.DyeColor; import org.bukkit.entity.Player; @@ -309,6 +312,27 @@ public interface PlayerGroup { */ boolean isPlaying(); + /** + * Returns the rewards that are memorized for the group. These are given when the game is finished. + * + * @return the rewards + */ + List getRewards(); + + /** + * Memorizes the given reward for the group. These are given when the game is finished. + * + * @param reward the reward + */ + void addReward(Reward reward); + + /** + * Removes the given reward. + * + * @param reward the reward + */ + void removeReward(Reward reward); + /** * Returns the initial amount of lives or -1 if group lives are not used. *