From fc86c5e9991c66bea17a607d0d1080de7c193f03 Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Sat, 25 Apr 2020 15:09:19 +0200 Subject: [PATCH] Add new reward event --- .../player/GlobalPlayerRewardPayOutEvent.java | 69 ++++++++++++ .../instance/game/DGamePlayerEvent.java | 40 ------- .../instance/game/DGamePlayerRewardEvent.java | 104 ------------------ 3 files changed, 69 insertions(+), 144 deletions(-) create mode 100644 api/src/main/java/de/erethon/dungeonsxl/api/event/player/GlobalPlayerRewardPayOutEvent.java delete mode 100644 core/src/main/java/de/erethon/dungeonsxl/event/dplayer/instance/game/DGamePlayerEvent.java delete mode 100644 core/src/main/java/de/erethon/dungeonsxl/event/dplayer/instance/game/DGamePlayerRewardEvent.java diff --git a/api/src/main/java/de/erethon/dungeonsxl/api/event/player/GlobalPlayerRewardPayOutEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/player/GlobalPlayerRewardPayOutEvent.java new file mode 100644 index 00000000..d05a6475 --- /dev/null +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/player/GlobalPlayerRewardPayOutEvent.java @@ -0,0 +1,69 @@ +/* + * 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.event.player; + +import de.erethon.dungeonsxl.api.Reward; +import de.erethon.dungeonsxl.api.player.GlobalPlayer; +import java.util.List; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; + +/** + * Fired when a player gets his {@link Reward}s after finishing a game. + *

+ * @see GlobalPlayer#setRewardItems(java.util.List) + * @author Daniel Saukel + */ +public class GlobalPlayerRewardPayOutEvent extends GlobalPlayerEvent implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); + private boolean cancelled; + + private final List rewards; + + public GlobalPlayerRewardPayOutEvent(GlobalPlayer globalPlayer, List rewards) { + super(globalPlayer); + this.rewards = rewards; + } + + /** + * Returns a list of the rewards the player will get. + * + * @return a list of the rewards the player will get + */ + public List getRewards() { + return rewards; + } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } + + @Override + public boolean isCancelled() { + return cancelled; + } + + @Override + public void setCancelled(boolean cancelled) { + this.cancelled = cancelled; + } + +} diff --git a/core/src/main/java/de/erethon/dungeonsxl/event/dplayer/instance/game/DGamePlayerEvent.java b/core/src/main/java/de/erethon/dungeonsxl/event/dplayer/instance/game/DGamePlayerEvent.java deleted file mode 100644 index 76a5df86..00000000 --- a/core/src/main/java/de/erethon/dungeonsxl/event/dplayer/instance/game/DGamePlayerEvent.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2012-2020 Frank Baumann - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package de.erethon.dungeonsxl.event.dplayer.instance.game; - -import de.erethon.dungeonsxl.event.dplayer.DPlayerEvent; -import de.erethon.dungeonsxl.player.DGamePlayer; - -/** - * @author Daniel Saukel - */ -public abstract class DGamePlayerEvent extends DPlayerEvent { - - public DGamePlayerEvent(DGamePlayer dPlayer) { - super(dPlayer); - } - - @Override - public DGamePlayer getDPlayer() { - return (DGamePlayer) dPlayer; - } - - public void setDPlayer(DGamePlayer dPlayer) { - this.dPlayer = dPlayer; - } - -} diff --git a/core/src/main/java/de/erethon/dungeonsxl/event/dplayer/instance/game/DGamePlayerRewardEvent.java b/core/src/main/java/de/erethon/dungeonsxl/event/dplayer/instance/game/DGamePlayerRewardEvent.java deleted file mode 100644 index 510ac7d9..00000000 --- a/core/src/main/java/de/erethon/dungeonsxl/event/dplayer/instance/game/DGamePlayerRewardEvent.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (C) 2012-2020 Frank Baumann - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package de.erethon.dungeonsxl.event.dplayer.instance.game; - -import de.erethon.dungeonsxl.api.Reward; -import de.erethon.dungeonsxl.player.DGamePlayer; -import java.util.ArrayList; -import java.util.List; -import org.bukkit.entity.Player; -import org.bukkit.event.Cancellable; -import org.bukkit.event.HandlerList; - -/** - * @author Daniel Saukel - */ -public class DGamePlayerRewardEvent extends DGamePlayerEvent implements Cancellable { - - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; - - private List rewards = new ArrayList<>(); - private List excludedPlayers = new ArrayList<>(); - - public DGamePlayerRewardEvent(DGamePlayer dPlayer) { - super(dPlayer); - this.rewards = dPlayer.getGroup().getRewards(); - } - - /** - * @return the rewards - */ - public List getRewards() { - return rewards; - } - - /** - * @param reward the reward to add - */ - public void addRewards(Reward reward) { - rewards.add(reward); - } - - /** - * @param reward the reward to remove - */ - public void removeRewards(Reward reward) { - rewards.remove(reward); - } - - /** - * @return the excludedPlayers - */ - public List getExcludedPlayers() { - return excludedPlayers; - } - - /** - * @param player the player to add - */ - public void addExcludedPlayer(Player player) { - excludedPlayers.add(player); - } - - /** - * @param player the player to remove - */ - public void removeExcludedPlayer(Player player) { - excludedPlayers.remove(player); - } - - @Override - public HandlerList getHandlers() { - return handlers; - } - - public static HandlerList getHandlerList() { - return handlers; - } - - @Override - public boolean isCancelled() { - return cancelled; - } - - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } - -}