Add reward API

This commit is contained in:
Daniel Saukel 2020-01-27 01:49:31 +01:00
parent c5d95d1788
commit 0c089e65a6
3 changed files with 65 additions and 0 deletions

View File

@ -60,6 +60,13 @@ public interface DungeonsAPI extends Plugin {
*/
Registry<String, Class<? extends Trigger>> getTriggerRegistry();
/**
* Returns a {@link Registry} of the reward types.
*
* @return a {@link Registry} of the reward types
*/
Registry<String, Class<? extends Reward>> getRewardRegistry();
/* Object initialization */
/**
* Creates a new group.

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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}.
* <p>
* @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);
}

View File

@ -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<Reward> 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.
*