From 1cf83aaca623f4050ce7e557ba5421c04ad7227a Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Sat, 25 Apr 2020 00:33:42 +0200 Subject: [PATCH 01/12] Add new EditPlayer events --- .../api/event/player/EditPlayerEditEvent.java | 66 ++++++++++++++ .../api/event/player/EditPlayerEvent.java | 39 +++++++++ .../event/player/EditPlayerLeaveEvent.java | 86 +++++++++++++++++++ .../instance/edit/DEditPlayerEscapeEvent.java | 54 ------------ .../instance/edit/DEditPlayerEvent.java | 40 --------- 5 files changed, 191 insertions(+), 94 deletions(-) create mode 100644 api/src/main/java/de/erethon/dungeonsxl/api/event/player/EditPlayerEditEvent.java create mode 100644 api/src/main/java/de/erethon/dungeonsxl/api/event/player/EditPlayerEvent.java create mode 100644 api/src/main/java/de/erethon/dungeonsxl/api/event/player/EditPlayerLeaveEvent.java delete mode 100644 core/src/main/java/de/erethon/dungeonsxl/event/dplayer/instance/edit/DEditPlayerEscapeEvent.java delete mode 100644 core/src/main/java/de/erethon/dungeonsxl/event/dplayer/instance/edit/DEditPlayerEvent.java diff --git a/api/src/main/java/de/erethon/dungeonsxl/api/event/player/EditPlayerEditEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/player/EditPlayerEditEvent.java new file mode 100644 index 00000000..5382151c --- /dev/null +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/player/EditPlayerEditEvent.java @@ -0,0 +1,66 @@ +/* + * 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.player.EditPlayer; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; + +/** + * Fired when a player starts editing a dungeon map. + * + * @author Daniel Saukel + */ +public class EditPlayerEditEvent extends EditPlayerEvent implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); + private boolean cancelled; + + private boolean newlyLoaded; + + public EditPlayerEditEvent(EditPlayer editPlayer, boolean newlyLoaded) { + super(editPlayer); + this.newlyLoaded = newlyLoaded; + } + + /** + * Returns true if the edit world was not instantiated before the player edited it and false if it was. + * + * @return true if the edit world was not instantiated before the player edited it and false if it was + */ + public boolean isNewlyLoaded() { + return newlyLoaded; + } + + @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/api/src/main/java/de/erethon/dungeonsxl/api/event/player/EditPlayerEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/player/EditPlayerEvent.java new file mode 100644 index 00000000..e6f9c12e --- /dev/null +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/player/EditPlayerEvent.java @@ -0,0 +1,39 @@ +/* + * 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.player.EditPlayer; + +/** + * Superclass for events involving {@link EditPlayer}s. + * + * @author Daniel Saukel + */ +public abstract class EditPlayerEvent extends GlobalPlayerEvent { + + protected EditPlayerEvent(EditPlayer editPlayer) { + super(editPlayer); + } + + /** + * Returns the EditPlayer involved in this event + * + * @return the EditPlayer involved in this event + */ + public EditPlayer getEditPlayer() { + return (EditPlayer) globalPlayer; + } + +} diff --git a/api/src/main/java/de/erethon/dungeonsxl/api/event/player/EditPlayerLeaveEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/player/EditPlayerLeaveEvent.java new file mode 100644 index 00000000..9c2b0a8d --- /dev/null +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/player/EditPlayerLeaveEvent.java @@ -0,0 +1,86 @@ +/* + * 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.player.EditPlayer; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; + +/** + * Fired when a player stops editing a dungeon map. + * + * @author Daniel Saukel + */ +public class EditPlayerLeaveEvent extends EditPlayerEvent implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); + private boolean cancelled; + + private boolean escape; + private boolean unloadIfEmpty; + + public EditPlayerLeaveEvent(EditPlayer editPlayer, boolean escape, boolean unloadIfEmpty) { + super(editPlayer); + this.escape = escape; + this.unloadIfEmpty = unloadIfEmpty; + } + + /** + * Returns false if the edit world is saved, true if not. + * + * @return false if the edit world is saved, true if not + */ + public boolean isEscape() { + return escape; + } + + /** + * Returns if the instance shall be unloaded when it is empty after the player left. + * + * @return if the instance shall be unloaded when it is empty after the player left + */ + public boolean getUnloadIfEmpty() { + return unloadIfEmpty; + } + + /** + * Sets if the instance shall be unloaded when it is empty after the player left. + * + * @param unloadIfEmpty if the instance shall be unloaded when it is empty after the player left + */ + public void setUnloadIfEmpty(boolean unloadIfEmpty) { + this.unloadIfEmpty = unloadIfEmpty; + } + + @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/edit/DEditPlayerEscapeEvent.java b/core/src/main/java/de/erethon/dungeonsxl/event/dplayer/instance/edit/DEditPlayerEscapeEvent.java deleted file mode 100644 index 12b992e2..00000000 --- a/core/src/main/java/de/erethon/dungeonsxl/event/dplayer/instance/edit/DEditPlayerEscapeEvent.java +++ /dev/null @@ -1,54 +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.edit; - -import de.erethon.dungeonsxl.player.DEditPlayer; -import org.bukkit.event.Cancellable; -import org.bukkit.event.HandlerList; - -/** - * @author Daniel Saukel - */ -public class DEditPlayerEscapeEvent extends DEditPlayerEvent implements Cancellable { - - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; - - public DEditPlayerEscapeEvent(DEditPlayer dPlayer) { - super(dPlayer); - } - - @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/edit/DEditPlayerEvent.java b/core/src/main/java/de/erethon/dungeonsxl/event/dplayer/instance/edit/DEditPlayerEvent.java deleted file mode 100644 index a2b5794a..00000000 --- a/core/src/main/java/de/erethon/dungeonsxl/event/dplayer/instance/edit/DEditPlayerEvent.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.edit; - -import de.erethon.dungeonsxl.event.dplayer.DPlayerEvent; -import de.erethon.dungeonsxl.player.DEditPlayer; - -/** - * @author Daniel Saukel - */ -public abstract class DEditPlayerEvent extends DPlayerEvent { - - public DEditPlayerEvent(DEditPlayer dPlayer) { - super(dPlayer); - } - - @Override - public DEditPlayer getDPlayer() { - return (DEditPlayer) dPlayer; - } - - public void setDPlayer(DEditPlayer dPlayer) { - this.dPlayer = dPlayer; - } - -} From 725b09e67d47388b80c4d40ff855b6a86d7e0c5f Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Sat, 25 Apr 2020 00:34:45 +0200 Subject: [PATCH 02/12] Add new reward event --- .../event/group/GroupCollectRewardEvent.java | 92 +++++++++++++++++++ .../GroupEvent.java} | 22 ++--- .../event/reward/RewardAdditionEvent.java | 72 --------------- .../dungeonsxl/event/reward/RewardEvent.java | 47 ---------- .../event/reward/RewardRegistrationEvent.java | 54 ----------- 5 files changed, 103 insertions(+), 184 deletions(-) create mode 100644 api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupCollectRewardEvent.java rename api/src/main/java/de/erethon/dungeonsxl/api/event/{dungeon/DungeonEvent.java => group/GroupEvent.java} (63%) delete mode 100644 core/src/main/java/de/erethon/dungeonsxl/event/reward/RewardAdditionEvent.java delete mode 100644 core/src/main/java/de/erethon/dungeonsxl/event/reward/RewardEvent.java delete mode 100644 core/src/main/java/de/erethon/dungeonsxl/event/reward/RewardRegistrationEvent.java diff --git a/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupCollectRewardEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupCollectRewardEvent.java new file mode 100644 index 00000000..4c296232 --- /dev/null +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupCollectRewardEvent.java @@ -0,0 +1,92 @@ +/* + * 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.group; + +import de.erethon.dungeonsxl.api.Reward; +import de.erethon.dungeonsxl.api.player.PlayerGroup; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; + +/** + * Fired when a group collects a reward. + *

+ * In the default implementation, this happens when a player opens a reward chest. + * + * @author Daniel Saukel + */ +public class GroupCollectRewardEvent extends GroupEvent implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); + private boolean cancelled; + + private Player collector; + private Reward reward; + + public GroupCollectRewardEvent(PlayerGroup group, Player collector, Reward reward) { + super(group); + this.collector = collector; + this.reward = reward; + } + + /** + * Returns the player who collected the reward. + *

+ * Note that this may be null if addons add a way to give rewards that cannot be attributed to one collector. + * + * @return the player who collected the reward + */ + public Player getCollector() { + return collector; + } + + /** + * Returns the reward the group collected. + * + * @return the reward the group collected + */ + public Reward getReward() { + return reward; + } + + /** + * Sets the reward the group collected. + * + * @param reward the reward + */ + public void setReward(Reward reward) { + this.reward = reward; + } + + @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/api/src/main/java/de/erethon/dungeonsxl/api/event/dungeon/DungeonEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupEvent.java similarity index 63% rename from api/src/main/java/de/erethon/dungeonsxl/api/event/dungeon/DungeonEvent.java rename to api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupEvent.java index 4cf4d824..c5b8e189 100644 --- a/api/src/main/java/de/erethon/dungeonsxl/api/event/dungeon/DungeonEvent.java +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupEvent.java @@ -12,31 +12,31 @@ * 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.dungeon; +package de.erethon.dungeonsxl.api.event.group; -import de.erethon.dungeonsxl.api.dungeon.Dungeon; +import de.erethon.dungeonsxl.api.player.PlayerGroup; import org.bukkit.event.Event; /** - * Superclass for events involving {@link Dungeon}s. + * Superclass for events involving DungeonsXL groups. * * @author Daniel Saukel */ -public abstract class DungeonEvent extends Event { +public abstract class GroupEvent extends Event { - protected Dungeon dungeon; + protected PlayerGroup group; - protected DungeonEvent(Dungeon dungeon) { - this.dungeon = dungeon; + protected GroupEvent(PlayerGroup group) { + this.group = group; } /** - * Returns the dungeon involved in this event. + * Returns the group involved in this event. * - * @return the dungeon involved in this event + * @return the group involved in this event */ - public Dungeon getDungeon() { - return dungeon; + public PlayerGroup getGroup() { + return group; } } diff --git a/core/src/main/java/de/erethon/dungeonsxl/event/reward/RewardAdditionEvent.java b/core/src/main/java/de/erethon/dungeonsxl/event/reward/RewardAdditionEvent.java deleted file mode 100644 index 86b80322..00000000 --- a/core/src/main/java/de/erethon/dungeonsxl/event/reward/RewardAdditionEvent.java +++ /dev/null @@ -1,72 +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.reward; - -import de.erethon.dungeonsxl.api.Reward; -import de.erethon.dungeonsxl.player.DGroup; -import org.bukkit.event.Cancellable; -import org.bukkit.event.HandlerList; - -/** - * @author Daniel Saukel - */ -public class RewardAdditionEvent extends RewardEvent implements Cancellable { - - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; - - private DGroup dGroup; - - public RewardAdditionEvent(Reward reward, DGroup dGroup) { - super(reward); - this.dGroup = dGroup; - } - - /** - * @return the dGroup - */ - public DGroup getDGroup() { - return dGroup; - } - - /** - * @param dGroup the dGroup to set - */ - public void setDGroup(DGroup dGroup) { - this.dGroup = dGroup; - } - - @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/reward/RewardEvent.java b/core/src/main/java/de/erethon/dungeonsxl/event/reward/RewardEvent.java deleted file mode 100644 index 98f30b2a..00000000 --- a/core/src/main/java/de/erethon/dungeonsxl/event/reward/RewardEvent.java +++ /dev/null @@ -1,47 +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.reward; - -import de.erethon.dungeonsxl.api.Reward; -import org.bukkit.event.Event; - -/** - * @author Daniel Saukel - */ -public abstract class RewardEvent extends Event { - - protected Reward reward; - - public RewardEvent(Reward reward) { - this.reward = reward; - } - - /** - * @return the reward - */ - public Reward getReward() { - return reward; - } - - /** - * @param reward the reward to set - */ - public void setReward(Reward reward) { - this.reward = reward; - } - -} diff --git a/core/src/main/java/de/erethon/dungeonsxl/event/reward/RewardRegistrationEvent.java b/core/src/main/java/de/erethon/dungeonsxl/event/reward/RewardRegistrationEvent.java deleted file mode 100644 index e449141f..00000000 --- a/core/src/main/java/de/erethon/dungeonsxl/event/reward/RewardRegistrationEvent.java +++ /dev/null @@ -1,54 +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.reward; - -import de.erethon.dungeonsxl.api.Reward; -import org.bukkit.event.Cancellable; -import org.bukkit.event.HandlerList; - -/** - * @author Daniel Saukel - */ -public class RewardRegistrationEvent extends RewardEvent implements Cancellable { - - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; - - public RewardRegistrationEvent(Reward reward) { - super(reward); - } - - @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; - } - -} From cd6e6f045b2b739b30bff1c2ac6c88cd04d34aea Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Sat, 25 Apr 2020 00:38:17 +0200 Subject: [PATCH 03/12] Add DungeonMob events --- .../api/event/mob/DungeonMobDeathEvent.java | 67 +++++++++++++++++ .../api/event/mob/DungeonMobEvent.java | 52 ++++++++++++++ .../api/event/mob/DungeonMobSpawnEvent.java | 44 ++++++++++++ .../dungeonsxl/event/dmob/DMobDeathEvent.java | 72 ------------------- .../dungeonsxl/event/dmob/DMobEvent.java | 47 ------------ .../dungeonsxl/event/dmob/DMobSpawnEvent.java | 65 ----------------- 6 files changed, 163 insertions(+), 184 deletions(-) create mode 100644 api/src/main/java/de/erethon/dungeonsxl/api/event/mob/DungeonMobDeathEvent.java create mode 100644 api/src/main/java/de/erethon/dungeonsxl/api/event/mob/DungeonMobEvent.java create mode 100644 api/src/main/java/de/erethon/dungeonsxl/api/event/mob/DungeonMobSpawnEvent.java delete mode 100644 core/src/main/java/de/erethon/dungeonsxl/event/dmob/DMobDeathEvent.java delete mode 100644 core/src/main/java/de/erethon/dungeonsxl/event/dmob/DMobEvent.java delete mode 100644 core/src/main/java/de/erethon/dungeonsxl/event/dmob/DMobSpawnEvent.java diff --git a/api/src/main/java/de/erethon/dungeonsxl/api/event/mob/DungeonMobDeathEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/mob/DungeonMobDeathEvent.java new file mode 100644 index 00000000..c8d4a2ea --- /dev/null +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/mob/DungeonMobDeathEvent.java @@ -0,0 +1,67 @@ +/* + * 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.mob; + +import de.erethon.dungeonsxl.api.mob.DungeonMob; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; + +/** + * Fired when a {@link DungeonMob} dies. + * + * @author Daniel Saukel + */ +public class DungeonMobDeathEvent extends DungeonMobEvent implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); + private boolean cancelled; + + public DungeonMobDeathEvent(DungeonMob mob) { + super(mob); + } + + /** + * Returns the player who killed the mob or null if the cause of its death was not a player. + * + * @return the player who killed the mob or null if the cause of its death was not a player + */ + public Player getKiller() { + if (mob.getEntity() == null) { + return null; + } + return mob.getEntity().getKiller(); + } + + @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/api/src/main/java/de/erethon/dungeonsxl/api/event/mob/DungeonMobEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/mob/DungeonMobEvent.java new file mode 100644 index 00000000..2b67271f --- /dev/null +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/mob/DungeonMobEvent.java @@ -0,0 +1,52 @@ +/* + * 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.mob; + +import de.erethon.dungeonsxl.api.mob.DungeonMob; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.Event; + +/** + * Superclass for events involving DungeonsXL mobs. + * + * @author Daniel Saukel + */ +public abstract class DungeonMobEvent extends Event { + + protected DungeonMob mob; + + protected DungeonMobEvent(DungeonMob mob) { + this.mob = mob; + } + + /** + * Returns the DungeonMob involved in this event. + * + * @return the DungeonMob involved in this event + */ + public DungeonMob getDungeonMob() { + return mob; + } + + /** + * Returns the Bukkit LivingEntity involved in this event. + * + * @return the Bukkit LivingEntity involved in this event + */ + public LivingEntity getBukkitEntity() { + return mob.getEntity(); + } + +} diff --git a/api/src/main/java/de/erethon/dungeonsxl/api/event/mob/DungeonMobSpawnEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/mob/DungeonMobSpawnEvent.java new file mode 100644 index 00000000..41cf8fa7 --- /dev/null +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/mob/DungeonMobSpawnEvent.java @@ -0,0 +1,44 @@ +/* + * 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.mob; + +import de.erethon.dungeonsxl.api.mob.DungeonMob; +import org.bukkit.event.HandlerList; + +/** + * Fired when a spawned entity is registered as a {@link DungeonMob}. + *

+ * Use {@link org.bukkit.event.entity.CreatureSpawnEvent} if you need to prevent a mob from spawning. + * + * @author Daniel Saukel + */ +public class DungeonMobSpawnEvent extends DungeonMobEvent { + + private static final HandlerList handlers = new HandlerList(); + + public DungeonMobSpawnEvent(DungeonMob mob) { + super(mob); + } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } + +} diff --git a/core/src/main/java/de/erethon/dungeonsxl/event/dmob/DMobDeathEvent.java b/core/src/main/java/de/erethon/dungeonsxl/event/dmob/DMobDeathEvent.java deleted file mode 100644 index 219acd57..00000000 --- a/core/src/main/java/de/erethon/dungeonsxl/event/dmob/DMobDeathEvent.java +++ /dev/null @@ -1,72 +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.dmob; - -import de.erethon.dungeonsxl.mob.DMob; -import org.bukkit.event.Cancellable; -import org.bukkit.event.HandlerList; -import org.bukkit.event.entity.EntityDeathEvent; - -/** - * @author Daniel Saukel - */ -public class DMobDeathEvent extends DMobEvent implements Cancellable { - - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; - - private EntityDeathEvent bukkitEvent; - - public DMobDeathEvent(DMob dMob, EntityDeathEvent bukkitEvent) { - super(dMob); - this.bukkitEvent = bukkitEvent; - } - - /** - * @return the bukkitEvent - */ - public EntityDeathEvent getBukkitEvent() { - return bukkitEvent; - } - - /** - * @param bukkitEvent the bukkitEvent to set - */ - public void setBukkitEvent(EntityDeathEvent bukkitEvent) { - this.bukkitEvent = bukkitEvent; - } - - @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/dmob/DMobEvent.java b/core/src/main/java/de/erethon/dungeonsxl/event/dmob/DMobEvent.java deleted file mode 100644 index 29b8a263..00000000 --- a/core/src/main/java/de/erethon/dungeonsxl/event/dmob/DMobEvent.java +++ /dev/null @@ -1,47 +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.dmob; - -import de.erethon.dungeonsxl.mob.DMob; -import org.bukkit.event.Event; - -/** - * @author Daniel Saukel - */ -public abstract class DMobEvent extends Event { - - protected DMob dMob; - - public DMobEvent(DMob dMob) { - this.dMob = dMob; - } - - /** - * @return the dMob - */ - public DMob getDMob() { - return dMob; - } - - /** - * @param dMob the dMob to set - */ - public void setDMob(DMob dMob) { - this.dMob = dMob; - } - -} diff --git a/core/src/main/java/de/erethon/dungeonsxl/event/dmob/DMobSpawnEvent.java b/core/src/main/java/de/erethon/dungeonsxl/event/dmob/DMobSpawnEvent.java deleted file mode 100644 index 5713d9cb..00000000 --- a/core/src/main/java/de/erethon/dungeonsxl/event/dmob/DMobSpawnEvent.java +++ /dev/null @@ -1,65 +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.dmob; - -import de.erethon.dungeonsxl.mob.DMob; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.Cancellable; -import org.bukkit.event.HandlerList; - -/** - * @author Daniel Saukel - */ -public class DMobSpawnEvent extends DMobEvent implements Cancellable { - - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; - - private LivingEntity entity; - - public DMobSpawnEvent(DMob dMob, LivingEntity entity) { - super(dMob); - this.entity = entity; - } - - /** - * @return the mob - */ - public LivingEntity getEntity() { - return entity; - } - - @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; - } - -} From ec6df79657eba09a0f999ee25f89aacae7c87dae Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Sat, 25 Apr 2020 00:38:54 +0200 Subject: [PATCH 04/12] Move DataReloadEvent to API --- .../de/erethon/dungeonsxl/api}/event/DataReloadEvent.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) rename {core/src/main/java/de/erethon/dungeonsxl => api/src/main/java/de/erethon/dungeonsxl/api}/event/DataReloadEvent.java (93%) diff --git a/core/src/main/java/de/erethon/dungeonsxl/event/DataReloadEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/DataReloadEvent.java similarity index 93% rename from core/src/main/java/de/erethon/dungeonsxl/event/DataReloadEvent.java rename to api/src/main/java/de/erethon/dungeonsxl/api/event/DataReloadEvent.java index 46a2cc44..45f7a802 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/event/DataReloadEvent.java +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/DataReloadEvent.java @@ -14,13 +14,15 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package de.erethon.dungeonsxl.event; +package de.erethon.dungeonsxl.api.event; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; /** + * Fired when the plugin is reloaded with /dxl reload. + * * @author Daniel Saukel */ public class DataReloadEvent extends Event implements Cancellable { From 6335e63733ddaa6dd8c7e8387c7b268ee99c5b68 Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Sat, 25 Apr 2020 01:25:34 +0200 Subject: [PATCH 05/12] Add world events --- .../api/event/player/EditPlayerEvent.java | 2 +- .../api/event/player/GamePlayerEvent.java | 2 +- .../api/event/world/EditWorldEvent.java | 39 +++++++++ .../event/world/EditWorldGenerateEvent.java | 54 ++++++++++++ .../api/event/world/EditWorldSaveEvent.java | 54 ++++++++++++ .../api/event/world/EditWorldUnloadEvent.java | 74 ++++++++++++++++ .../api/event/world/GameWorldEvent.java | 52 +++++++++++ .../api/event/world/InstanceWorldEvent.java | 52 +++++++++++ .../event/world/InstanceWorldUnloadEvent.java | 54 ++++++++++++ .../world/ResourceWorldInstantiateEvent.java | 87 +++++++++++++++++++ 10 files changed, 468 insertions(+), 2 deletions(-) create mode 100644 api/src/main/java/de/erethon/dungeonsxl/api/event/world/EditWorldEvent.java create mode 100644 api/src/main/java/de/erethon/dungeonsxl/api/event/world/EditWorldGenerateEvent.java create mode 100644 api/src/main/java/de/erethon/dungeonsxl/api/event/world/EditWorldSaveEvent.java create mode 100644 api/src/main/java/de/erethon/dungeonsxl/api/event/world/EditWorldUnloadEvent.java create mode 100644 api/src/main/java/de/erethon/dungeonsxl/api/event/world/GameWorldEvent.java create mode 100644 api/src/main/java/de/erethon/dungeonsxl/api/event/world/InstanceWorldEvent.java create mode 100644 api/src/main/java/de/erethon/dungeonsxl/api/event/world/InstanceWorldUnloadEvent.java create mode 100644 api/src/main/java/de/erethon/dungeonsxl/api/event/world/ResourceWorldInstantiateEvent.java diff --git a/api/src/main/java/de/erethon/dungeonsxl/api/event/player/EditPlayerEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/player/EditPlayerEvent.java index e6f9c12e..a85e0c69 100644 --- a/api/src/main/java/de/erethon/dungeonsxl/api/event/player/EditPlayerEvent.java +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/player/EditPlayerEvent.java @@ -28,7 +28,7 @@ public abstract class EditPlayerEvent extends GlobalPlayerEvent { } /** - * Returns the EditPlayer involved in this event + * Returns the EditPlayer involved in this event. * * @return the EditPlayer involved in this event */ diff --git a/api/src/main/java/de/erethon/dungeonsxl/api/event/player/GamePlayerEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/player/GamePlayerEvent.java index 010d0d24..58bb3c19 100644 --- a/api/src/main/java/de/erethon/dungeonsxl/api/event/player/GamePlayerEvent.java +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/player/GamePlayerEvent.java @@ -28,7 +28,7 @@ public abstract class GamePlayerEvent extends GlobalPlayerEvent { } /** - * Returns the GamePlayer involved in this event + * Returns the GamePlayer involved in this event. * * @return the GamePlayer involved in this event */ diff --git a/api/src/main/java/de/erethon/dungeonsxl/api/event/world/EditWorldEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/world/EditWorldEvent.java new file mode 100644 index 00000000..5c7eba8b --- /dev/null +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/world/EditWorldEvent.java @@ -0,0 +1,39 @@ +/* + * 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.world; + +import de.erethon.dungeonsxl.api.world.EditWorld; + +/** + * Superclass for events involving DungeonsXL edit instances. + * + * @author Daniel Saukel + */ +public abstract class EditWorldEvent extends InstanceWorldEvent { + + protected EditWorldEvent(EditWorld editWorld) { + super(editWorld); + } + + /** + * Returns the EditWorld involved in this event. + * + * @return the EditWorld involved in this event + */ + public EditWorld getEditWorld() { + return (EditWorld) instance; + } + +} diff --git a/api/src/main/java/de/erethon/dungeonsxl/api/event/world/EditWorldGenerateEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/world/EditWorldGenerateEvent.java new file mode 100644 index 00000000..cca95269 --- /dev/null +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/world/EditWorldGenerateEvent.java @@ -0,0 +1,54 @@ +/* + * 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.world; + +import de.erethon.dungeonsxl.api.world.EditWorld; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; + +/** + * Fired when a dungeon world is generated. + * + * @author Daniel Saukel + */ +public class EditWorldGenerateEvent extends EditWorldEvent implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); + private boolean cancelled; + + public EditWorldGenerateEvent(EditWorld editWorld) { + super(editWorld); + } + + @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/api/src/main/java/de/erethon/dungeonsxl/api/event/world/EditWorldSaveEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/world/EditWorldSaveEvent.java new file mode 100644 index 00000000..41981324 --- /dev/null +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/world/EditWorldSaveEvent.java @@ -0,0 +1,54 @@ +/* + * 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.world; + +import de.erethon.dungeonsxl.api.world.EditWorld; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; + +/** + * Fired when an edit world is saved. + * + * @author Daniel Saukel + */ +public class EditWorldSaveEvent extends EditWorldEvent implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); + private boolean cancelled; + + public EditWorldSaveEvent(EditWorld editWorld) { + super(editWorld); + } + + @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/api/src/main/java/de/erethon/dungeonsxl/api/event/world/EditWorldUnloadEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/world/EditWorldUnloadEvent.java new file mode 100644 index 00000000..cbacea81 --- /dev/null +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/world/EditWorldUnloadEvent.java @@ -0,0 +1,74 @@ +/* + * 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.world; + +import de.erethon.dungeonsxl.api.world.EditWorld; +import org.bukkit.event.HandlerList; + +/** + * Fired when an edit world is unloaded. + * + * @author Daniel Saukel + */ +public class EditWorldUnloadEvent extends InstanceWorldUnloadEvent { + + private static final HandlerList handlers = new HandlerList(); + private boolean cancelled; + + private boolean save; + + public EditWorldUnloadEvent(EditWorld editWorld, boolean save) { + super(editWorld); + this.save = save; + } + + /** + * Returns if the world is saved. + * + * @return if the world is saved + */ + public boolean getSave() { + return save; + } + + /** + * Sets if the world shall be saved. + * + * @param save if the world shall be saved + */ + public void setSave(boolean save) { + this.save = save; + } + + @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/api/src/main/java/de/erethon/dungeonsxl/api/event/world/GameWorldEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/world/GameWorldEvent.java new file mode 100644 index 00000000..6221e11e --- /dev/null +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/world/GameWorldEvent.java @@ -0,0 +1,52 @@ +/* + * 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.world; + +import de.erethon.dungeonsxl.api.dungeon.Dungeon; +import de.erethon.dungeonsxl.api.world.GameWorld; + +/** + * Superclass for events involving DungeonsXL game instances. + * + * @author Daniel Saukel + */ +public abstract class GameWorldEvent extends InstanceWorldEvent { + + private Dungeon dungeon; + + protected GameWorldEvent(GameWorld gameWorld, Dungeon dungeon) { + super(gameWorld); + this.dungeon = dungeon; + } + + /** + * Returns the GameWorld involved in this event. + * + * @return the GameWorld involved in this event. + */ + public GameWorld getGameWorld() { + return (GameWorld) instance; + } + + /** + * Returns the dungeon the game instance is a part of. + * + * @return the dungeon the game instance is a part of + */ + public Dungeon getDungeon() { + return dungeon; + } + +} diff --git a/api/src/main/java/de/erethon/dungeonsxl/api/event/world/InstanceWorldEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/world/InstanceWorldEvent.java new file mode 100644 index 00000000..6b6f108c --- /dev/null +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/world/InstanceWorldEvent.java @@ -0,0 +1,52 @@ +/* + * 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.world; + +import de.erethon.dungeonsxl.api.world.InstanceWorld; +import org.bukkit.World; +import org.bukkit.event.Event; + +/** + * Superclass for events involving DungeonsXL instances. + * + * @author Daniel Saukel + */ +public abstract class InstanceWorldEvent extends Event { + + protected InstanceWorld instance; + + protected InstanceWorldEvent(InstanceWorld instance) { + this.instance = instance; + } + + /** + * Returns the instance involved in this event. + * + * @return the instance involved in this event + */ + public InstanceWorld getInstance() { + return instance; + } + + /** + * Returns the Bukkit world involved in this event. + * + * @return the Bukkit world involved in this event. + */ + public World getBukkitWorld() { + return instance.getWorld(); + } + +} diff --git a/api/src/main/java/de/erethon/dungeonsxl/api/event/world/InstanceWorldUnloadEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/world/InstanceWorldUnloadEvent.java new file mode 100644 index 00000000..1a1364e6 --- /dev/null +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/world/InstanceWorldUnloadEvent.java @@ -0,0 +1,54 @@ +/* + * 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.world; + +import de.erethon.dungeonsxl.api.world.InstanceWorld; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; + +/** + * Fired when an instance is unloaded. + * + * @author Daniel Saukel + */ +public class InstanceWorldUnloadEvent extends InstanceWorldEvent implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); + private boolean cancelled; + + public InstanceWorldUnloadEvent(InstanceWorld instance) { + super(instance); + } + + @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/api/src/main/java/de/erethon/dungeonsxl/api/event/world/ResourceWorldInstantiateEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/world/ResourceWorldInstantiateEvent.java new file mode 100644 index 00000000..c98e31cc --- /dev/null +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/world/ResourceWorldInstantiateEvent.java @@ -0,0 +1,87 @@ +/* + * 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.world; + +import de.erethon.dungeonsxl.api.dungeon.Dungeon; +import de.erethon.dungeonsxl.api.world.ResourceWorld; +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +/** + * Fired when a {@link ResourceWorld} is instantiated. + * + * @author Daniel Saukel + */ +public class ResourceWorldInstantiateEvent extends Event implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); + private boolean cancelled; + + private ResourceWorld resourceWorld; + private Dungeon dungeon; + + public ResourceWorldInstantiateEvent(ResourceWorld resourceWorld, Dungeon dungeon) { + this.resourceWorld = resourceWorld; + this.dungeon = dungeon; + } + + /** + * Returns the resource world that is to be instantiated. + * + * @return the resource world that is to be instantiated + */ + public ResourceWorld getResourceWorld() { + return resourceWorld; + } + + /** + * Returns the dungeon as a part of which the instance is loaded. + * + * @return the dungeon as a part of which the instance is loaded + */ + public Dungeon getDungeon() { + return dungeon; + } + + /** + * Returns if the loaded instance will be an edit world. + * + * @return if the loaded instance will be an edit world + */ + public boolean isEditInstance() { + return dungeon == null; + } + + @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; + } + +} From 42cadaf7d1eded8cb7612badd502f3396cc2942f Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Sat, 25 Apr 2020 01:27:02 +0200 Subject: [PATCH 06/12] Remove redundant non-API world events --- .../event/editworld/EditWorldEvent.java | 47 ------------ .../editworld/EditWorldGenerateEvent.java | 54 -------------- .../event/editworld/EditWorldLoadEvent.java | 70 ------------------ .../event/editworld/EditWorldSaveEvent.java | 54 -------------- .../event/editworld/EditWorldUnloadEvent.java | 71 ------------------- .../event/gameworld/GameWorldLoadEvent.java | 70 ------------------ .../event/gameworld/GameWorldUnloadEvent.java | 55 -------------- 7 files changed, 421 deletions(-) delete mode 100644 core/src/main/java/de/erethon/dungeonsxl/event/editworld/EditWorldEvent.java delete mode 100644 core/src/main/java/de/erethon/dungeonsxl/event/editworld/EditWorldGenerateEvent.java delete mode 100644 core/src/main/java/de/erethon/dungeonsxl/event/editworld/EditWorldLoadEvent.java delete mode 100644 core/src/main/java/de/erethon/dungeonsxl/event/editworld/EditWorldSaveEvent.java delete mode 100644 core/src/main/java/de/erethon/dungeonsxl/event/editworld/EditWorldUnloadEvent.java delete mode 100644 core/src/main/java/de/erethon/dungeonsxl/event/gameworld/GameWorldLoadEvent.java delete mode 100644 core/src/main/java/de/erethon/dungeonsxl/event/gameworld/GameWorldUnloadEvent.java diff --git a/core/src/main/java/de/erethon/dungeonsxl/event/editworld/EditWorldEvent.java b/core/src/main/java/de/erethon/dungeonsxl/event/editworld/EditWorldEvent.java deleted file mode 100644 index c1ddd47f..00000000 --- a/core/src/main/java/de/erethon/dungeonsxl/event/editworld/EditWorldEvent.java +++ /dev/null @@ -1,47 +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.editworld; - -import de.erethon.dungeonsxl.world.DEditWorld; -import org.bukkit.event.Event; - -/** - * @author Daniel Saukel - */ -public abstract class EditWorldEvent extends Event { - - protected DEditWorld editWorld; - - public EditWorldEvent(DEditWorld editWorld) { - this.editWorld = editWorld; - } - - /** - * @return the editWorld - */ - public DEditWorld getEditWorld() { - return editWorld; - } - - /** - * @param editWorld the editWorld to set - */ - public void setEditWorld(DEditWorld editWorld) { - this.editWorld = editWorld; - } - -} diff --git a/core/src/main/java/de/erethon/dungeonsxl/event/editworld/EditWorldGenerateEvent.java b/core/src/main/java/de/erethon/dungeonsxl/event/editworld/EditWorldGenerateEvent.java deleted file mode 100644 index a3391e41..00000000 --- a/core/src/main/java/de/erethon/dungeonsxl/event/editworld/EditWorldGenerateEvent.java +++ /dev/null @@ -1,54 +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.editworld; - -import de.erethon.dungeonsxl.world.DEditWorld; -import org.bukkit.event.Cancellable; -import org.bukkit.event.HandlerList; - -/** - * @author Daniel Saukel - */ -public class EditWorldGenerateEvent extends EditWorldEvent implements Cancellable { - - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; - - public EditWorldGenerateEvent(DEditWorld editWorld) { - super(editWorld); - } - - @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/editworld/EditWorldLoadEvent.java b/core/src/main/java/de/erethon/dungeonsxl/event/editworld/EditWorldLoadEvent.java deleted file mode 100644 index 458516f9..00000000 --- a/core/src/main/java/de/erethon/dungeonsxl/event/editworld/EditWorldLoadEvent.java +++ /dev/null @@ -1,70 +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.editworld; - -import org.bukkit.event.Cancellable; -import org.bukkit.event.Event; -import org.bukkit.event.HandlerList; - -/** - * @author Daniel Saukel - */ -public class EditWorldLoadEvent extends Event implements Cancellable { - - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; - - private String name; - - public EditWorldLoadEvent(String name) { - this.name = name; - } - - /** - * @return the name - */ - public String getName() { - return name; - } - - /** - * @param name the name to set - */ - public void setName(String name) { - this.name = name; - } - - @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/editworld/EditWorldSaveEvent.java b/core/src/main/java/de/erethon/dungeonsxl/event/editworld/EditWorldSaveEvent.java deleted file mode 100644 index e0703f5d..00000000 --- a/core/src/main/java/de/erethon/dungeonsxl/event/editworld/EditWorldSaveEvent.java +++ /dev/null @@ -1,54 +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.editworld; - -import de.erethon.dungeonsxl.world.DEditWorld; -import org.bukkit.event.Cancellable; -import org.bukkit.event.HandlerList; - -/** - * @author Daniel Saukel - */ -public class EditWorldSaveEvent extends EditWorldEvent implements Cancellable { - - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; - - public EditWorldSaveEvent(DEditWorld editWorld) { - super(editWorld); - } - - @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/editworld/EditWorldUnloadEvent.java b/core/src/main/java/de/erethon/dungeonsxl/event/editworld/EditWorldUnloadEvent.java deleted file mode 100644 index cbe32461..00000000 --- a/core/src/main/java/de/erethon/dungeonsxl/event/editworld/EditWorldUnloadEvent.java +++ /dev/null @@ -1,71 +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.editworld; - -import de.erethon.dungeonsxl.world.DEditWorld; -import org.bukkit.event.Cancellable; -import org.bukkit.event.HandlerList; - -/** - * @author Daniel Saukel - */ -public class EditWorldUnloadEvent extends EditWorldEvent implements Cancellable { - - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; - - private boolean save; - - public EditWorldUnloadEvent(DEditWorld editWorld, boolean save) { - super(editWorld); - this.save = save; - } - - /** - * @return the save - */ - public boolean getSave() { - return save; - } - - /** - * @param save the save to set - */ - public void setSave(boolean save) { - this.save = save; - } - - @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/gameworld/GameWorldLoadEvent.java b/core/src/main/java/de/erethon/dungeonsxl/event/gameworld/GameWorldLoadEvent.java deleted file mode 100644 index 0d562bb9..00000000 --- a/core/src/main/java/de/erethon/dungeonsxl/event/gameworld/GameWorldLoadEvent.java +++ /dev/null @@ -1,70 +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.gameworld; - -import org.bukkit.event.Cancellable; -import org.bukkit.event.Event; -import org.bukkit.event.HandlerList; - -/** - * @author Daniel Saukel - */ -public class GameWorldLoadEvent extends Event implements Cancellable { - - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; - - private String name; - - public GameWorldLoadEvent(String name) { - this.name = name; - } - - /** - * @return the name - */ - public String getName() { - return name; - } - - /** - * @param name the name to set - */ - public void setName(String name) { - this.name = name; - } - - @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/gameworld/GameWorldUnloadEvent.java b/core/src/main/java/de/erethon/dungeonsxl/event/gameworld/GameWorldUnloadEvent.java deleted file mode 100644 index e2741281..00000000 --- a/core/src/main/java/de/erethon/dungeonsxl/event/gameworld/GameWorldUnloadEvent.java +++ /dev/null @@ -1,55 +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.gameworld; - -import de.erethon.dungeonsxl.world.DGameWorld; -import org.bukkit.event.Cancellable; -import org.bukkit.event.HandlerList; - -/** - * @author Daniel Saukel - */ -public class GameWorldUnloadEvent extends GameWorldEvent implements Cancellable { - - private static final HandlerList handlers = new HandlerList(); - - private boolean cancelled; - - public GameWorldUnloadEvent(DGameWorld gameWorld) { - super(gameWorld); - } - - @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; - } - -} From 462db92cb863f89e3d34926385ab468769def016 Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Sat, 25 Apr 2020 14:42:53 +0200 Subject: [PATCH 07/12] Add new group event API --- .../api/event/group/GroupCreateEvent.java | 99 +++++++++++++++++ .../api/event/group/GroupDisbandEvent.java | 96 ++++++++++++++++ .../event/group/GroupFinishDungeonEvent.java | 67 +++++++++++ .../event/group/GroupFinishFloorEvent.java | 90 +++++++++++++++ .../api/event/group/GroupPlayerJoinEvent.java | 78 +++++++++++++ .../api/event/group/GroupPlayerKickEvent.java | 45 +++++--- .../event/group/GroupPlayerLeaveEvent.java | 67 +++++++++++ .../api/event/group/GroupScoreEvent.java | 78 +++++++++++++ .../api/event/group/GroupStartFloorEvent.java | 67 +++++++++++ .../event/dgroup/DGroupCreateEvent.java | 98 ----------------- .../event/dgroup/DGroupDisbandEvent.java | 104 ------------------ .../dungeonsxl/event/dgroup/DGroupEvent.java | 47 -------- .../dgroup/DGroupFinishDungeonEvent.java | 72 ------------ .../event/dgroup/DGroupFinishFloorEvent.java | 89 --------------- .../event/dgroup/DGroupScoreEvent.java | 88 --------------- .../event/dgroup/DGroupStartFloorEvent.java | 72 ------------ .../event/dplayer/DPlayerJoinDGroupEvent.java | 74 ------------- .../dplayer/DPlayerLeaveDGroupEvent.java | 65 ----------- 18 files changed, 674 insertions(+), 722 deletions(-) create mode 100644 api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupCreateEvent.java create mode 100644 api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupDisbandEvent.java create mode 100644 api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupFinishDungeonEvent.java create mode 100644 api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupFinishFloorEvent.java create mode 100644 api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupPlayerJoinEvent.java rename core/src/main/java/de/erethon/dungeonsxl/event/dplayer/DPlayerKickEvent.java => api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupPlayerKickEvent.java (59%) create mode 100644 api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupPlayerLeaveEvent.java create mode 100644 api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupScoreEvent.java create mode 100644 api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupStartFloorEvent.java delete mode 100644 core/src/main/java/de/erethon/dungeonsxl/event/dgroup/DGroupCreateEvent.java delete mode 100644 core/src/main/java/de/erethon/dungeonsxl/event/dgroup/DGroupDisbandEvent.java delete mode 100644 core/src/main/java/de/erethon/dungeonsxl/event/dgroup/DGroupEvent.java delete mode 100644 core/src/main/java/de/erethon/dungeonsxl/event/dgroup/DGroupFinishDungeonEvent.java delete mode 100644 core/src/main/java/de/erethon/dungeonsxl/event/dgroup/DGroupFinishFloorEvent.java delete mode 100644 core/src/main/java/de/erethon/dungeonsxl/event/dgroup/DGroupScoreEvent.java delete mode 100644 core/src/main/java/de/erethon/dungeonsxl/event/dgroup/DGroupStartFloorEvent.java delete mode 100644 core/src/main/java/de/erethon/dungeonsxl/event/dplayer/DPlayerJoinDGroupEvent.java delete mode 100644 core/src/main/java/de/erethon/dungeonsxl/event/dplayer/DPlayerLeaveDGroupEvent.java diff --git a/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupCreateEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupCreateEvent.java new file mode 100644 index 00000000..fef89b9e --- /dev/null +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupCreateEvent.java @@ -0,0 +1,99 @@ +/* + * 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.group; + +import de.erethon.dungeonsxl.api.player.PlayerGroup; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; + +/** + * Fired when a group is created explicitly or implicitly. + * + * @author Daniel Saukel + */ +public class GroupCreateEvent extends GroupEvent implements Cancellable { + + /** + * The reason why the group is created. + */ + public enum Cause { + + ANNOUNCER, + COMMAND, + /** + * When a group is created to mirror the state of a party plugin. + * + * @see de.erethon.dungeonsxl.api.player.GroupAdapter + */ + GROUP_ADAPTER, + GROUP_SIGN, + /** + * When a group is created by an addon. + */ + CUSTOM + + } + + private static final HandlerList handlers = new HandlerList(); + private boolean cancelled; + + private Player creator; + private Cause cause; + + public GroupCreateEvent(PlayerGroup group, Player creator, Cause cause) { + super(group); + this.creator = creator; + this.cause = cause; + } + + /** + * Returns the player who created the group. + * + * @return the player who created the group + */ + public Player getCreator() { + return creator; + } + + /** + * Returns the cause for the group creation. + * + * @return the cause for the group creation + */ + public Cause getCause() { + return cause; + } + + @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/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupDisbandEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupDisbandEvent.java new file mode 100644 index 00000000..dffa0e60 --- /dev/null +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupDisbandEvent.java @@ -0,0 +1,96 @@ +/* + * 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.group; + +import de.erethon.dungeonsxl.api.player.PlayerGroup; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; + +/** + * Fired when a group is disbanded. + * + * @author Daniel Saukel + */ +public class GroupDisbandEvent extends GroupEvent implements Cancellable { + + public enum Cause { + + COMMAND, + DUNGEON_FINISHED, + GROUP_ADAPTER, + GROUP_IS_EMPTY, + LOST, + CUSTOM + + } + + private static final HandlerList handlers = new HandlerList(); + private boolean cancelled; + + private Player disbander; + private Cause cause; + + public GroupDisbandEvent(PlayerGroup group, Cause cause) { + super(group); + this.cause = cause; + } + + public GroupDisbandEvent(PlayerGroup group, Player disbander, Cause cause) { + super(group); + this.disbander = disbander; + this.cause = cause; + } + + /** + * The player who disbanded the group. + *

+ * This is null if the cause is {@link Cause#DUNGEON_FINISHED}, {@link Cause#GROUP_ADAPTER}, {@link Cause#LOST} or {@link Cause#CUSTOM}. + * + * @return the player who disbanded the group + */ + public Player getDisbander() { + return disbander; + } + + /** + * Returns the cause for the group deletion. + * + * @return the cause for the group deletion + */ + public Cause getCause() { + return cause; + } + + @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/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupFinishDungeonEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupFinishDungeonEvent.java new file mode 100644 index 00000000..e84d8a52 --- /dev/null +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupFinishDungeonEvent.java @@ -0,0 +1,67 @@ +/* + * 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.group; + +import de.erethon.dungeonsxl.api.dungeon.Dungeon; +import de.erethon.dungeonsxl.api.player.PlayerGroup; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; + +/** + * Fired when a group finishs a {@link Dungeon}, which means the end floor of a dungeon. + * + * @author Daniel Saukel + */ +public class GroupFinishDungeonEvent extends GroupEvent implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); + private boolean cancelled; + + private Dungeon dungeon; + + public GroupFinishDungeonEvent(PlayerGroup group, Dungeon dungeon) { + super(group); + this.dungeon = dungeon; + } + + /** + * Returns the dungeon the group was playing. + * + * @return the dungeon the group was playing + */ + public Dungeon getDungeon() { + return dungeon; + } + + @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/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupFinishFloorEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupFinishFloorEvent.java new file mode 100644 index 00000000..8bd95ba2 --- /dev/null +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupFinishFloorEvent.java @@ -0,0 +1,90 @@ +/* + * 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.group; + +import de.erethon.dungeonsxl.api.player.PlayerGroup; +import de.erethon.dungeonsxl.api.world.GameWorld; +import de.erethon.dungeonsxl.api.world.ResourceWorld; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; + +/** + * Fired when a group finishs a dungeon floor. + * + * @author Daniel Saukel + */ +public class GroupFinishFloorEvent extends GroupEvent implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); + private boolean cancelled; + + private GameWorld finished; + private ResourceWorld next; + + public GroupFinishFloorEvent(PlayerGroup group, GameWorld finished, ResourceWorld next) { + super(group); + this.finished = finished; + this.next = next; + } + + /** + * Returns the game world that was just finished. + * + * @return the game world that was just finished + */ + public GameWorld getFinished() { + return finished; + } + + /** + * Returns the resource world of the next floor. + * + * @return the resource world of the next floor + */ + public ResourceWorld getNext() { + return next; + } + + /** + * Sets the next floor to load. + *

+ * If one has already been loaded because another group finished the floor earlier, this will not do anything. + * + * @param next the next floor to load + */ + public void setNext(ResourceWorld next) { + this.next = next; + } + + @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/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupPlayerJoinEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupPlayerJoinEvent.java new file mode 100644 index 00000000..d1e090da --- /dev/null +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupPlayerJoinEvent.java @@ -0,0 +1,78 @@ +/* + * 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.group; + +import de.erethon.dungeonsxl.api.player.GlobalPlayer; +import de.erethon.dungeonsxl.api.player.PlayerGroup; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; + +/** + * Fired when a player joins a DungeonsXL group. + * + * @author Daniel Saukel + */ +public class GroupPlayerJoinEvent extends GroupEvent implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); + private boolean cancelled; + + private GlobalPlayer player; + private boolean creator; + + public GroupPlayerJoinEvent(PlayerGroup group, GlobalPlayer player, boolean creator) { + super(group); + this.player = player; + this.creator = creator; + } + + /** + * Returns the player who is joining the group. + * + * @return the player who is joining the group + */ + public GlobalPlayer getPlayer() { + return player; + } + + /** + * Returns if the player is the creator of the group. + * + * @return if the player is the creator of the group + */ + public boolean isCreator() { + return creator; + } + + @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/DPlayerKickEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupPlayerKickEvent.java similarity index 59% rename from core/src/main/java/de/erethon/dungeonsxl/event/dplayer/DPlayerKickEvent.java rename to api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupPlayerKickEvent.java index 145ede46..6970abc7 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/event/dplayer/DPlayerKickEvent.java +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupPlayerKickEvent.java @@ -14,22 +14,35 @@ * 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; +package de.erethon.dungeonsxl.api.event.group; -import de.erethon.dungeonsxl.player.DGlobalPlayer; +import de.erethon.dungeonsxl.api.player.GlobalPlayer; +import de.erethon.dungeonsxl.api.player.PlayerGroup; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; /** * @author Daniel Saukel */ -public class DPlayerKickEvent extends DPlayerEvent implements Cancellable { +public class GroupPlayerKickEvent extends GroupEvent implements Cancellable { public enum Cause { COMMAND, + /** + * When the player is kicked because he does not have any lives left. + */ DEATH, + /** + * When a player is kicked from a group to mirror the state of a party plugin. + * + * @see de.erethon.dungeonsxl.api.player.GroupAdapter + */ + GROUP_ADAPTER, OFFLINE, + /** + * When the time for the group to reach a certain state expired. + */ TIME_EXPIRED, CUSTOM @@ -38,27 +51,33 @@ public class DPlayerKickEvent extends DPlayerEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancelled; + private GlobalPlayer player; private Cause cause; - public DPlayerKickEvent(DGlobalPlayer dPlayer, Cause cause) { - super(dPlayer); + public GroupPlayerKickEvent(PlayerGroup group, GlobalPlayer player, Cause cause) { + super(group); + this.player = player; this.cause = cause; } /** - * @return the cause + * Returns the player who is joining the group. + * + * @return the player who is joining the group + */ + public GlobalPlayer getPlayer() { + return player; + } + + /** + * Returns the cause of the kick. + * + * @return the cause of the kick */ public Cause getCause() { return cause; } - /** - * @param cause the cause to set - */ - public void setCause(Cause cause) { - this.cause = cause; - } - @Override public HandlerList getHandlers() { return handlers; diff --git a/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupPlayerLeaveEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupPlayerLeaveEvent.java new file mode 100644 index 00000000..0c153fe7 --- /dev/null +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupPlayerLeaveEvent.java @@ -0,0 +1,67 @@ +/* + * 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.group; + +import de.erethon.dungeonsxl.api.player.PlayerGroup; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; + +/** + * Fired when a player leaves a group. + * + * @author Daniel Saukel + */ +public class GroupPlayerLeaveEvent extends GroupEvent implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); + private boolean cancelled; + + private Player player; + + public GroupPlayerLeaveEvent(PlayerGroup group, Player player) { + super(group); + this.player = player; + } + + /** + * Returns the player who left the group. + * + * @return the player who left the group + */ + public Player getPlayer() { + return 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; + } + +} diff --git a/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupScoreEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupScoreEvent.java new file mode 100644 index 00000000..7f3f7d05 --- /dev/null +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupScoreEvent.java @@ -0,0 +1,78 @@ +/* + * 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.group; + +import de.erethon.dungeonsxl.api.player.PlayerGroup; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; + +/** + * Fired when a group scores a point. + * + * @author Daniel Saukel + */ +public class GroupScoreEvent extends GroupEvent implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); + private boolean cancelled; + + private Player scorer; + private PlayerGroup loserGroup; + + public GroupScoreEvent(PlayerGroup group, Player scorer, PlayerGroup loserGroup) { + super(group); + this.scorer = scorer; + this.loserGroup = loserGroup; + } + + /** + * Returns the player who scored. + * + * @return the player who scored + */ + public Player getScorer() { + return scorer; + } + + /** + * Returns the group that lost a score to the scorers. + * + * @return the group that lost a score to the scorers + */ + public PlayerGroup getLoserGroup() { + return loserGroup; + } + + @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/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupStartFloorEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupStartFloorEvent.java new file mode 100644 index 00000000..eeecee95 --- /dev/null +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupStartFloorEvent.java @@ -0,0 +1,67 @@ +/* + * 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.group; + +import de.erethon.dungeonsxl.api.player.PlayerGroup; +import de.erethon.dungeonsxl.api.world.GameWorld; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; + +/** + * Fired when a group starts playing a floor. + * + * @author Daniel Saukel + */ +public class GroupStartFloorEvent extends GroupEvent implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); + private boolean cancelled; + + private GameWorld gameWorld; + + public GroupStartFloorEvent(PlayerGroup group, GameWorld gameWorld) { + super(group); + this.gameWorld = gameWorld; + } + + /** + * Returns the game instance. + * + * @return the game instance + */ + public GameWorld getGameWorld() { + return gameWorld; + } + + @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/dgroup/DGroupCreateEvent.java b/core/src/main/java/de/erethon/dungeonsxl/event/dgroup/DGroupCreateEvent.java deleted file mode 100644 index 910e9e8e..00000000 --- a/core/src/main/java/de/erethon/dungeonsxl/event/dgroup/DGroupCreateEvent.java +++ /dev/null @@ -1,98 +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.dgroup; - -import de.erethon.dungeonsxl.player.DGroup; -import org.bukkit.entity.Player; -import org.bukkit.event.Cancellable; -import org.bukkit.event.HandlerList; - -/** - * @author Daniel Saukel - */ -public class DGroupCreateEvent extends DGroupEvent implements Cancellable { - - public enum Cause { - - ANNOUNCER, - COMMAND, - GROUP_SIGN, - CUSTOM - - } - - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; - - private Player creator; - - private Cause cause; - - public DGroupCreateEvent(DGroup dGroup, Player creator, Cause cause) { - super(dGroup); - this.creator = creator; - this.cause = cause; - } - - /** - * @return the creator - */ - public Player getCreator() { - return creator; - } - - /** - * @param creator the creator to set - */ - public void setCreator(Player creator) { - this.creator = creator; - } - - /** - * @return the cause - */ - public Cause getCause() { - return cause; - } - - /** - * @param cause the cause to set - */ - public void setCause(Cause cause) { - this.cause = cause; - } - - @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/dgroup/DGroupDisbandEvent.java b/core/src/main/java/de/erethon/dungeonsxl/event/dgroup/DGroupDisbandEvent.java deleted file mode 100644 index 2e564f90..00000000 --- a/core/src/main/java/de/erethon/dungeonsxl/event/dgroup/DGroupDisbandEvent.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.dgroup; - -import de.erethon.dungeonsxl.player.DGroup; -import org.bukkit.entity.Player; -import org.bukkit.event.Cancellable; -import org.bukkit.event.HandlerList; - -/** - * @author Daniel Saukel - */ -public class DGroupDisbandEvent extends DGroupEvent implements Cancellable { - - public enum Cause { - - COMMAND, - DUNGEON_FINISHED, - GROUP_IS_EMPTY, - LOST, - CUSTOM - - } - - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; - - private Player disbander; - - private Cause cause; - - public DGroupDisbandEvent(DGroup dGroup, Cause cause) { - super(dGroup); - this.cause = cause; - } - - public DGroupDisbandEvent(DGroup dGroup, Player disbander, Cause cause) { - super(dGroup); - this.disbander = disbander; - this.cause = cause; - } - - /** - * @return the disbander - */ - public Player getDisbander() { - return disbander; - } - - /** - * @param disbander the disbander to set - */ - public void setDisbander(Player disbander) { - this.disbander = disbander; - } - - /** - * @return the cause - */ - public Cause getCause() { - return cause; - } - - /** - * @param cause the cause to set - */ - public void setCause(Cause cause) { - this.cause = cause; - } - - @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/dgroup/DGroupEvent.java b/core/src/main/java/de/erethon/dungeonsxl/event/dgroup/DGroupEvent.java deleted file mode 100644 index a01c3a9d..00000000 --- a/core/src/main/java/de/erethon/dungeonsxl/event/dgroup/DGroupEvent.java +++ /dev/null @@ -1,47 +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.dgroup; - -import de.erethon.dungeonsxl.player.DGroup; -import org.bukkit.event.Event; - -/** - * @author Daniel Saukel - */ -public abstract class DGroupEvent extends Event { - - private DGroup dGroup; - - public DGroupEvent(DGroup dGroup) { - this.dGroup = dGroup; - } - - /** - * @return the dGroup - */ - public DGroup getDGroup() { - return dGroup; - } - - /** - * @param dGroup the dGroup to set - */ - public void setDGroup(DGroup dGroup) { - this.dGroup = dGroup; - } - -} diff --git a/core/src/main/java/de/erethon/dungeonsxl/event/dgroup/DGroupFinishDungeonEvent.java b/core/src/main/java/de/erethon/dungeonsxl/event/dgroup/DGroupFinishDungeonEvent.java deleted file mode 100644 index 9b64a1c2..00000000 --- a/core/src/main/java/de/erethon/dungeonsxl/event/dgroup/DGroupFinishDungeonEvent.java +++ /dev/null @@ -1,72 +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.dgroup; - -import de.erethon.dungeonsxl.dungeon.DDungeon; -import de.erethon.dungeonsxl.player.DGroup; -import org.bukkit.event.Cancellable; -import org.bukkit.event.HandlerList; - -/** - * @author Daniel Saukel - */ -public class DGroupFinishDungeonEvent extends DGroupEvent implements Cancellable { - - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; - - private DDungeon dungeon; - - public DGroupFinishDungeonEvent(DDungeon dungeon, DGroup dGroup) { - super(dGroup); - this.dungeon = dungeon; - } - - /** - * @return the dungeon - */ - public DDungeon getDungeon() { - return dungeon; - } - - /** - * @param dungeon the dungeon to set - */ - public void setDisbander(DDungeon dungeon) { - this.dungeon = dungeon; - } - - @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/dgroup/DGroupFinishFloorEvent.java b/core/src/main/java/de/erethon/dungeonsxl/event/dgroup/DGroupFinishFloorEvent.java deleted file mode 100644 index 79d95206..00000000 --- a/core/src/main/java/de/erethon/dungeonsxl/event/dgroup/DGroupFinishFloorEvent.java +++ /dev/null @@ -1,89 +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.dgroup; - -import de.erethon.dungeonsxl.player.DGroup; -import de.erethon.dungeonsxl.world.DGameWorld; -import de.erethon.dungeonsxl.world.DResourceWorld; -import org.bukkit.event.Cancellable; -import org.bukkit.event.HandlerList; - -/** - * @author Daniel Saukel - */ -public class DGroupFinishFloorEvent extends DGroupEvent implements Cancellable { - - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; - - private DGameWorld finished; - private DResourceWorld next; - - public DGroupFinishFloorEvent(DGroup dGroup, DGameWorld finished, DResourceWorld next) { - super(dGroup); - this.finished = finished; - this.next = next; - } - - /** - * @return the finished - */ - public DGameWorld getFinished() { - return finished; - } - - /** - * @param finished the name of the DGameWorld to set - */ - public void setFinished(DGameWorld finished) { - this.finished = finished; - } - - /** - * @return the next - */ - public DResourceWorld getNext() { - return next; - } - - /** - * @param next the resource to set - */ - public void setNext(DResourceWorld next) { - this.next = next; - } - - @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/dgroup/DGroupScoreEvent.java b/core/src/main/java/de/erethon/dungeonsxl/event/dgroup/DGroupScoreEvent.java deleted file mode 100644 index 7b5c54f7..00000000 --- a/core/src/main/java/de/erethon/dungeonsxl/event/dgroup/DGroupScoreEvent.java +++ /dev/null @@ -1,88 +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.dgroup; - -import de.erethon.dungeonsxl.player.DGroup; -import org.bukkit.entity.Player; -import org.bukkit.event.Cancellable; -import org.bukkit.event.HandlerList; - -/** - * @author Daniel Saukel - */ -public class DGroupScoreEvent extends DGroupEvent implements Cancellable { - - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; - - private Player scorer; - private DGroup loserGroup; - - public DGroupScoreEvent(DGroup dGroup, Player scorer, DGroup loserGroup) { - super(dGroup); - this.scorer = scorer; - this.loserGroup = loserGroup; - } - - /** - * @return the creator - */ - public Player getScorer() { - return scorer; - } - - /** - * @param scorer the scoerer to set - */ - public void setCreator(Player scorer) { - this.scorer = scorer; - } - - /** - * @return the group that lost a score to the scorers - */ - public DGroup getLoserGroup() { - return loserGroup; - } - - /** - * @param loserGroup the group that lost a score to the scorers to set - */ - public void setLoserGroup(DGroup loserGroup) { - this.loserGroup = loserGroup; - } - - @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/dgroup/DGroupStartFloorEvent.java b/core/src/main/java/de/erethon/dungeonsxl/event/dgroup/DGroupStartFloorEvent.java deleted file mode 100644 index 244320cd..00000000 --- a/core/src/main/java/de/erethon/dungeonsxl/event/dgroup/DGroupStartFloorEvent.java +++ /dev/null @@ -1,72 +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.dgroup; - -import de.erethon.dungeonsxl.player.DGroup; -import de.erethon.dungeonsxl.world.DGameWorld; -import org.bukkit.event.Cancellable; -import org.bukkit.event.HandlerList; - -/** - * @author Daniel Saukel - */ -public class DGroupStartFloorEvent extends DGroupEvent implements Cancellable { - - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; - - private DGameWorld gameWorld; - - public DGroupStartFloorEvent(DGroup dGroup, DGameWorld gameWorld) { - super(dGroup); - this.gameWorld = gameWorld; - } - - /** - * @return the gameWorld - */ - public DGameWorld getGameWorld() { - return gameWorld; - } - - /** - * @param gameWorld the gameWorld to set - */ - public void setGameWorld(DGameWorld gameWorld) { - this.gameWorld = gameWorld; - } - - @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/DPlayerJoinDGroupEvent.java b/core/src/main/java/de/erethon/dungeonsxl/event/dplayer/DPlayerJoinDGroupEvent.java deleted file mode 100644 index bfbd289e..00000000 --- a/core/src/main/java/de/erethon/dungeonsxl/event/dplayer/DPlayerJoinDGroupEvent.java +++ /dev/null @@ -1,74 +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; - -import de.erethon.dungeonsxl.player.DGlobalPlayer; -import de.erethon.dungeonsxl.player.DGroup; -import org.bukkit.event.Cancellable; -import org.bukkit.event.HandlerList; - -/** - * @author Daniel Saukel - */ -public class DPlayerJoinDGroupEvent extends DPlayerEvent implements Cancellable { - - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; - - private boolean creator; - private DGroup dGroup; - - public DPlayerJoinDGroupEvent(DGlobalPlayer dPlayer, boolean creator, DGroup dGroup) { - super(dPlayer); - this.creator = creator; - this.dGroup = dGroup; - } - - /** - * @return if the player is the creator of the group - */ - public boolean isCreator() { - return creator; - } - - /** - * @return the dGroup - */ - public DGroup getDGroup() { - return dGroup; - } - - @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/DPlayerLeaveDGroupEvent.java b/core/src/main/java/de/erethon/dungeonsxl/event/dplayer/DPlayerLeaveDGroupEvent.java deleted file mode 100644 index a7e987ee..00000000 --- a/core/src/main/java/de/erethon/dungeonsxl/event/dplayer/DPlayerLeaveDGroupEvent.java +++ /dev/null @@ -1,65 +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; - -import de.erethon.dungeonsxl.player.DGlobalPlayer; -import de.erethon.dungeonsxl.player.DGroup; -import org.bukkit.event.Cancellable; -import org.bukkit.event.HandlerList; - -/** - * @author Daniel Saukel - */ -public class DPlayerLeaveDGroupEvent extends DPlayerEvent implements Cancellable { - - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; - - private DGroup dGroup; - - public DPlayerLeaveDGroupEvent(DGlobalPlayer dPlayer, DGroup dGroup) { - super(dPlayer); - this.dGroup = dGroup; - } - - /** - * @return the dGroup - */ - public DGroup getDGroup() { - return dGroup; - } - - @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; - } - -} From fc86c5e9991c66bea17a607d0d1080de7c193f03 Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Sat, 25 Apr 2020 15:09:19 +0200 Subject: [PATCH 08/12] 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; - } - -} From 8f1dea99753f42ed90b11abf333c10757f33f138 Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Sat, 25 Apr 2020 15:12:42 +0200 Subject: [PATCH 09/12] Add new GameWorldStartGameEvent --- .../event/world}/GameWorldStartGameEvent.java | 39 +++++++++++---- .../event/gameworld/GameWorldEvent.java | 47 ------------------- 2 files changed, 29 insertions(+), 57 deletions(-) rename {core/src/main/java/de/erethon/dungeonsxl/event/gameworld => api/src/main/java/de/erethon/dungeonsxl/api/event/world}/GameWorldStartGameEvent.java (55%) delete mode 100644 core/src/main/java/de/erethon/dungeonsxl/event/gameworld/GameWorldEvent.java diff --git a/core/src/main/java/de/erethon/dungeonsxl/event/gameworld/GameWorldStartGameEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/world/GameWorldStartGameEvent.java similarity index 55% rename from core/src/main/java/de/erethon/dungeonsxl/event/gameworld/GameWorldStartGameEvent.java rename to api/src/main/java/de/erethon/dungeonsxl/api/event/world/GameWorldStartGameEvent.java index 9318aafd..7661d9c0 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/event/gameworld/GameWorldStartGameEvent.java +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/world/GameWorldStartGameEvent.java @@ -14,10 +14,11 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package de.erethon.dungeonsxl.event.gameworld; +package de.erethon.dungeonsxl.api.event.world; -import de.erethon.dungeonsxl.dungeon.DGame; -import de.erethon.dungeonsxl.world.DGameWorld; +import de.erethon.dungeonsxl.api.dungeon.Game; +import de.erethon.dungeonsxl.api.world.GameWorld; +import org.bukkit.Location; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; @@ -29,25 +30,43 @@ public class GameWorldStartGameEvent extends GameWorldEvent implements Cancellab private static final HandlerList handlers = new HandlerList(); private boolean cancelled; - private DGame game; + private Game game; + private Location startLocation; - public GameWorldStartGameEvent(DGameWorld gameWorld, DGame game) { - super(gameWorld); + public GameWorldStartGameEvent(GameWorld gameWorld, Game game, Location location) { + super(gameWorld, gameWorld.getDungeon()); this.game = game; } /** + * Returns the game. + * * @return the game */ - public DGame getGame() { + public Game getGame() { return game; } /** - * @param game the game to set + * Returns the location where the players are teleported. + * + * @return the location where the players are teleported */ - public void setGame(DGame game) { - this.game = game; + public Location getStartLocation() { + return startLocation; + } + + /** + * Sets the location where the players are teleported. + * + * @param startLocation a location in the game world + * @throws IllegalArgumentException if the given location is not in the game world. + */ + public void setStartLocation(Location startLocation) { + if (startLocation.getWorld() != getGameWorld().getWorld()) { + throw new IllegalArgumentException("Location " + startLocation + " is not in world " + getGameWorld().getWorld()); + } + this.startLocation = startLocation; } @Override diff --git a/core/src/main/java/de/erethon/dungeonsxl/event/gameworld/GameWorldEvent.java b/core/src/main/java/de/erethon/dungeonsxl/event/gameworld/GameWorldEvent.java deleted file mode 100644 index 84366416..00000000 --- a/core/src/main/java/de/erethon/dungeonsxl/event/gameworld/GameWorldEvent.java +++ /dev/null @@ -1,47 +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.gameworld; - -import de.erethon.dungeonsxl.world.DGameWorld; -import org.bukkit.event.Event; - -/** - * @author Daniel Saukel - */ -public abstract class GameWorldEvent extends Event { - - protected DGameWorld gameWorld; - - public GameWorldEvent(DGameWorld gameWorld) { - this.gameWorld = gameWorld; - } - - /** - * @return the gameWorld - */ - public DGameWorld getGameWorld() { - return gameWorld; - } - - /** - * @param gameWorld the gameWorld to set - */ - public void setGameWorld(DGameWorld gameWorld) { - this.gameWorld = gameWorld; - } - -} From 3a5d211506ea0a123cf1310b99e43980544ed584 Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Sat, 25 Apr 2020 15:21:51 +0200 Subject: [PATCH 10/12] Add new GamePlayerFinishEvent --- .../event/group/GroupFinishDungeonEvent.java | 3 ++ .../event/player/GamePlayerFinishEvent.java | 26 ++++----- .../instance/game/DGamePlayerEscapeEvent.java | 54 ------------------- 3 files changed, 16 insertions(+), 67 deletions(-) rename core/src/main/java/de/erethon/dungeonsxl/event/dplayer/instance/game/DGamePlayerFinishEvent.java => api/src/main/java/de/erethon/dungeonsxl/api/event/player/GamePlayerFinishEvent.java (62%) delete mode 100644 core/src/main/java/de/erethon/dungeonsxl/event/dplayer/instance/game/DGamePlayerEscapeEvent.java diff --git a/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupFinishDungeonEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupFinishDungeonEvent.java index e84d8a52..844d7b0f 100644 --- a/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupFinishDungeonEvent.java +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupFinishDungeonEvent.java @@ -21,6 +21,9 @@ import org.bukkit.event.HandlerList; /** * Fired when a group finishs a {@link Dungeon}, which means the end floor of a dungeon. + *

+ * Do not confuse this with {@link de.erethon.dungeonsxl.api.event.player.GamePlayerFinishEvent}. GamePlayerFinishEvent is fired when a player triggers an end + * sign, while GroupFinishDungeonEvent is triggered when all group members have triggered the ready sign and the game actually ends. * * @author Daniel Saukel */ diff --git a/core/src/main/java/de/erethon/dungeonsxl/event/dplayer/instance/game/DGamePlayerFinishEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/player/GamePlayerFinishEvent.java similarity index 62% rename from core/src/main/java/de/erethon/dungeonsxl/event/dplayer/instance/game/DGamePlayerFinishEvent.java rename to api/src/main/java/de/erethon/dungeonsxl/api/event/player/GamePlayerFinishEvent.java index b2491197..0bf11ce1 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/event/dplayer/instance/game/DGamePlayerFinishEvent.java +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/player/GamePlayerFinishEvent.java @@ -14,41 +14,41 @@ * 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; +package de.erethon.dungeonsxl.api.event.player; -import de.erethon.dungeonsxl.player.DGamePlayer; +import de.erethon.dungeonsxl.api.player.GamePlayer; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; /** + * Fired when a player finishs a game. + *

+ * Do not confuse this with {@link de.erethon.dungeonsxl.api.event.group.GroupFinishDungeonEvent}. GamePlayerFinishEvent is fired when a player triggers an end + * sign, while GroupFinishDungeonEvent is triggered when all group members have triggered the ready sign and the game actually ends. + * * @author Daniel Saukel */ -public class DGamePlayerFinishEvent extends DGamePlayerEvent implements Cancellable { +public class GamePlayerFinishEvent extends GamePlayerEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancelled; private boolean hasToWait; - public DGamePlayerFinishEvent(DGamePlayer dPlayer, boolean hasToWait) { - super(dPlayer); + public GamePlayerFinishEvent(GamePlayer gamePlayer, boolean hasToWait) { + super(gamePlayer); this.hasToWait = hasToWait; } /** - * @return the hasToWait + * Returns false if the other group members have all already triggered the end sign, true if not. + * + * @return false if the other group members have all already triggered the end sign, true if not */ public boolean getHasToWait() { return hasToWait; } - /** - * @param hasToWait the hasToWait to set - */ - public void setHasToWait(boolean hasToWait) { - this.hasToWait = hasToWait; - } - @Override public HandlerList getHandlers() { return handlers; diff --git a/core/src/main/java/de/erethon/dungeonsxl/event/dplayer/instance/game/DGamePlayerEscapeEvent.java b/core/src/main/java/de/erethon/dungeonsxl/event/dplayer/instance/game/DGamePlayerEscapeEvent.java deleted file mode 100644 index bd7d85b1..00000000 --- a/core/src/main/java/de/erethon/dungeonsxl/event/dplayer/instance/game/DGamePlayerEscapeEvent.java +++ /dev/null @@ -1,54 +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.player.DGamePlayer; -import org.bukkit.event.Cancellable; -import org.bukkit.event.HandlerList; - -/** - * @author Daniel Saukel - */ -public class DGamePlayerEscapeEvent extends DGamePlayerEvent implements Cancellable { - - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; - - public DGamePlayerEscapeEvent(DGamePlayer dPlayer) { - super(dPlayer); - } - - @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; - } - -} From 007f65c103cfa761ab8e10a758a290d7db963257 Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Sat, 25 Apr 2020 18:27:08 +0200 Subject: [PATCH 11/12] Use PlayerWrapper objects instead of Bukkit Players in player-related events --- .../api/event/group/GroupCollectRewardEvent.java | 7 ++++--- .../dungeonsxl/api/event/group/GroupCreateEvent.java | 8 ++++---- .../dungeonsxl/api/event/group/GroupDisbandEvent.java | 8 ++++---- .../dungeonsxl/api/event/group/GroupPlayerLeaveEvent.java | 8 ++++---- .../dungeonsxl/api/event/group/GroupScoreEvent.java | 8 ++++---- 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupCollectRewardEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupCollectRewardEvent.java index 4c296232..0be291f0 100644 --- a/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupCollectRewardEvent.java +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupCollectRewardEvent.java @@ -15,6 +15,7 @@ package de.erethon.dungeonsxl.api.event.group; import de.erethon.dungeonsxl.api.Reward; +import de.erethon.dungeonsxl.api.player.GamePlayer; import de.erethon.dungeonsxl.api.player.PlayerGroup; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; @@ -32,10 +33,10 @@ public class GroupCollectRewardEvent extends GroupEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancelled; - private Player collector; + private GamePlayer collector; private Reward reward; - public GroupCollectRewardEvent(PlayerGroup group, Player collector, Reward reward) { + public GroupCollectRewardEvent(PlayerGroup group, GamePlayer collector, Reward reward) { super(group); this.collector = collector; this.reward = reward; @@ -48,7 +49,7 @@ public class GroupCollectRewardEvent extends GroupEvent implements Cancellable { * * @return the player who collected the reward */ - public Player getCollector() { + public GamePlayer getCollector() { return collector; } diff --git a/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupCreateEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupCreateEvent.java index fef89b9e..6e1e5ec2 100644 --- a/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupCreateEvent.java +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupCreateEvent.java @@ -14,8 +14,8 @@ */ package de.erethon.dungeonsxl.api.event.group; +import de.erethon.dungeonsxl.api.player.GlobalPlayer; import de.erethon.dungeonsxl.api.player.PlayerGroup; -import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; @@ -50,10 +50,10 @@ public class GroupCreateEvent extends GroupEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancelled; - private Player creator; + private GlobalPlayer creator; private Cause cause; - public GroupCreateEvent(PlayerGroup group, Player creator, Cause cause) { + public GroupCreateEvent(PlayerGroup group, GlobalPlayer creator, Cause cause) { super(group); this.creator = creator; this.cause = cause; @@ -64,7 +64,7 @@ public class GroupCreateEvent extends GroupEvent implements Cancellable { * * @return the player who created the group */ - public Player getCreator() { + public GlobalPlayer getCreator() { return creator; } diff --git a/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupDisbandEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupDisbandEvent.java index dffa0e60..b0a05fb6 100644 --- a/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupDisbandEvent.java +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupDisbandEvent.java @@ -14,8 +14,8 @@ */ package de.erethon.dungeonsxl.api.event.group; +import de.erethon.dungeonsxl.api.player.GlobalPlayer; import de.erethon.dungeonsxl.api.player.PlayerGroup; -import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; @@ -40,7 +40,7 @@ public class GroupDisbandEvent extends GroupEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancelled; - private Player disbander; + private GlobalPlayer disbander; private Cause cause; public GroupDisbandEvent(PlayerGroup group, Cause cause) { @@ -48,7 +48,7 @@ public class GroupDisbandEvent extends GroupEvent implements Cancellable { this.cause = cause; } - public GroupDisbandEvent(PlayerGroup group, Player disbander, Cause cause) { + public GroupDisbandEvent(PlayerGroup group, GlobalPlayer disbander, Cause cause) { super(group); this.disbander = disbander; this.cause = cause; @@ -61,7 +61,7 @@ public class GroupDisbandEvent extends GroupEvent implements Cancellable { * * @return the player who disbanded the group */ - public Player getDisbander() { + public GlobalPlayer getDisbander() { return disbander; } diff --git a/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupPlayerLeaveEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupPlayerLeaveEvent.java index 0c153fe7..3dd33010 100644 --- a/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupPlayerLeaveEvent.java +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupPlayerLeaveEvent.java @@ -14,8 +14,8 @@ */ package de.erethon.dungeonsxl.api.event.group; +import de.erethon.dungeonsxl.api.player.GlobalPlayer; import de.erethon.dungeonsxl.api.player.PlayerGroup; -import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; @@ -29,9 +29,9 @@ public class GroupPlayerLeaveEvent extends GroupEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancelled; - private Player player; + private GlobalPlayer player; - public GroupPlayerLeaveEvent(PlayerGroup group, Player player) { + public GroupPlayerLeaveEvent(PlayerGroup group, GlobalPlayer player) { super(group); this.player = player; } @@ -41,7 +41,7 @@ public class GroupPlayerLeaveEvent extends GroupEvent implements Cancellable { * * @return the player who left the group */ - public Player getPlayer() { + public GlobalPlayer getPlayer() { return player; } diff --git a/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupScoreEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupScoreEvent.java index 7f3f7d05..e5960f10 100644 --- a/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupScoreEvent.java +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupScoreEvent.java @@ -14,8 +14,8 @@ */ package de.erethon.dungeonsxl.api.event.group; +import de.erethon.dungeonsxl.api.player.GamePlayer; import de.erethon.dungeonsxl.api.player.PlayerGroup; -import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; @@ -29,10 +29,10 @@ public class GroupScoreEvent extends GroupEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancelled; - private Player scorer; + private GamePlayer scorer; private PlayerGroup loserGroup; - public GroupScoreEvent(PlayerGroup group, Player scorer, PlayerGroup loserGroup) { + public GroupScoreEvent(PlayerGroup group, GamePlayer scorer, PlayerGroup loserGroup) { super(group); this.scorer = scorer; this.loserGroup = loserGroup; @@ -43,7 +43,7 @@ public class GroupScoreEvent extends GroupEvent implements Cancellable { * * @return the player who scored */ - public Player getScorer() { + public GamePlayer getScorer() { return scorer; } From 29d8f755685e875886b7144d9bb92fce73b5b9c8 Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Sat, 25 Apr 2020 21:49:44 +0200 Subject: [PATCH 12/12] Basic implementation of old events --- .../dungeonsxl/api/event/DataReloadEvent.java | 20 +++--- .../event/group/GroupCollectRewardEvent.java | 1 - .../api/event/group/GroupPlayerKickEvent.java | 20 +++--- .../event/player/GamePlayerFinishEvent.java | 20 +++--- .../event/world/GameWorldStartGameEvent.java | 48 ++++---------- .../dungeonsxl/announcer/Announcer.java | 4 +- .../dungeonsxl/command/GroupCommand.java | 13 ++-- .../dungeonsxl/command/LeaveCommand.java | 19 ++---- .../dungeonsxl/command/PlayCommand.java | 4 +- .../dungeonsxl/command/ReloadCommand.java | 2 +- .../java/de/erethon/dungeonsxl/mob/DMob.java | 14 ++-- .../dungeonsxl/player/DGamePlayer.java | 39 ++++++----- .../dungeonsxl/player/DGlobalPlayer.java | 9 ++- .../de/erethon/dungeonsxl/player/DGroup.java | 64 ++++++++++--------- .../dungeonsxl/player/TimeIsRunningTask.java | 11 ++-- .../dungeonsxl/sign/button/LeaveSign.java | 13 ++-- .../erethon/dungeonsxl/world/DEditWorld.java | 4 +- .../erethon/dungeonsxl/world/DGameWorld.java | 10 ++- .../dungeonsxl/world/DResourceWorld.java | 2 +- .../dungeonsxl/world/block/RewardChest.java | 42 +++++++++--- 20 files changed, 173 insertions(+), 186 deletions(-) diff --git a/api/src/main/java/de/erethon/dungeonsxl/api/event/DataReloadEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/DataReloadEvent.java index 45f7a802..79b0499c 100644 --- a/api/src/main/java/de/erethon/dungeonsxl/api/event/DataReloadEvent.java +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/DataReloadEvent.java @@ -1,18 +1,16 @@ /* - * Copyright (C) 2012-2020 Frank Baumann + * Copyright (C) 2014-2020 Daniel Saukel * - * 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 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 - * GNU General Public License for more details. + * 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 General Public License - * along with this program. If not, see . + * 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; diff --git a/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupCollectRewardEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupCollectRewardEvent.java index 0be291f0..ac1f4d9e 100644 --- a/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupCollectRewardEvent.java +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupCollectRewardEvent.java @@ -17,7 +17,6 @@ package de.erethon.dungeonsxl.api.event.group; import de.erethon.dungeonsxl.api.Reward; import de.erethon.dungeonsxl.api.player.GamePlayer; import de.erethon.dungeonsxl.api.player.PlayerGroup; -import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; diff --git a/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupPlayerKickEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupPlayerKickEvent.java index 6970abc7..2a34247c 100644 --- a/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupPlayerKickEvent.java +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/group/GroupPlayerKickEvent.java @@ -1,18 +1,16 @@ /* - * Copyright (C) 2012-2020 Frank Baumann + * Copyright (C) 2014-2020 Daniel Saukel * - * 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 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 - * GNU General Public License for more details. + * 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 General Public License - * along with this program. If not, see . + * 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.group; diff --git a/api/src/main/java/de/erethon/dungeonsxl/api/event/player/GamePlayerFinishEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/player/GamePlayerFinishEvent.java index 0bf11ce1..83338554 100644 --- a/api/src/main/java/de/erethon/dungeonsxl/api/event/player/GamePlayerFinishEvent.java +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/player/GamePlayerFinishEvent.java @@ -1,18 +1,16 @@ /* - * Copyright (C) 2012-2020 Frank Baumann + * Copyright (C) 2014-2020 Daniel Saukel * - * 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 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 - * GNU General Public License for more details. + * 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 General Public License - * along with this program. If not, see . + * 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; diff --git a/api/src/main/java/de/erethon/dungeonsxl/api/event/world/GameWorldStartGameEvent.java b/api/src/main/java/de/erethon/dungeonsxl/api/event/world/GameWorldStartGameEvent.java index 7661d9c0..9ab7a2ae 100644 --- a/api/src/main/java/de/erethon/dungeonsxl/api/event/world/GameWorldStartGameEvent.java +++ b/api/src/main/java/de/erethon/dungeonsxl/api/event/world/GameWorldStartGameEvent.java @@ -1,28 +1,27 @@ /* - * Copyright (C) 2012-2020 Frank Baumann + * Copyright (C) 2014-2020 Daniel Saukel * - * 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 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 - * GNU General Public License for more details. + * 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 General Public License - * along with this program. If not, see . + * 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.world; import de.erethon.dungeonsxl.api.dungeon.Game; import de.erethon.dungeonsxl.api.world.GameWorld; -import org.bukkit.Location; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; /** + * Fired when the game starts, that means when all players have triggered the ready sign. + * * @author Daniel Saukel */ public class GameWorldStartGameEvent extends GameWorldEvent implements Cancellable { @@ -31,9 +30,8 @@ public class GameWorldStartGameEvent extends GameWorldEvent implements Cancellab private boolean cancelled; private Game game; - private Location startLocation; - public GameWorldStartGameEvent(GameWorld gameWorld, Game game, Location location) { + public GameWorldStartGameEvent(GameWorld gameWorld, Game game) { super(gameWorld, gameWorld.getDungeon()); this.game = game; } @@ -47,28 +45,6 @@ public class GameWorldStartGameEvent extends GameWorldEvent implements Cancellab return game; } - /** - * Returns the location where the players are teleported. - * - * @return the location where the players are teleported - */ - public Location getStartLocation() { - return startLocation; - } - - /** - * Sets the location where the players are teleported. - * - * @param startLocation a location in the game world - * @throws IllegalArgumentException if the given location is not in the game world. - */ - public void setStartLocation(Location startLocation) { - if (startLocation.getWorld() != getGameWorld().getWorld()) { - throw new IllegalArgumentException("Location " + startLocation + " is not in world " + getGameWorld().getWorld()); - } - this.startLocation = startLocation; - } - @Override public HandlerList getHandlers() { return handlers; diff --git a/core/src/main/java/de/erethon/dungeonsxl/announcer/Announcer.java b/core/src/main/java/de/erethon/dungeonsxl/announcer/Announcer.java index d3093968..73faf375 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/announcer/Announcer.java +++ b/core/src/main/java/de/erethon/dungeonsxl/announcer/Announcer.java @@ -20,9 +20,9 @@ import de.erethon.commons.chat.DefaultFontInfo; import de.erethon.commons.chat.MessageUtil; import de.erethon.dungeonsxl.DungeonsXL; import de.erethon.dungeonsxl.api.dungeon.Dungeon; +import de.erethon.dungeonsxl.api.event.group.GroupCreateEvent; import de.erethon.dungeonsxl.api.player.PlayerGroup.Color; import de.erethon.dungeonsxl.config.DMessage; -import de.erethon.dungeonsxl.event.dgroup.DGroupCreateEvent; import de.erethon.dungeonsxl.player.DGroup; import de.erethon.dungeonsxl.util.GUIUtil; import java.io.File; @@ -368,7 +368,7 @@ public class Announcer { } } else if (dGroup == null && pGroup == null) { - DGroupCreateEvent event = new DGroupCreateEvent(dGroup, player, DGroupCreateEvent.Cause.ANNOUNCER); + GroupCreateEvent event = new GroupCreateEvent(dGroup, plugin.getPlayerCache().get(player), GroupCreateEvent.Cause.ANNOUNCER); Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { dGroups.set(buttons.indexOf(button), new DGroup(plugin, player, color)); diff --git a/core/src/main/java/de/erethon/dungeonsxl/command/GroupCommand.java b/core/src/main/java/de/erethon/dungeonsxl/command/GroupCommand.java index d7d63766..4c5fe1e4 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/command/GroupCommand.java +++ b/core/src/main/java/de/erethon/dungeonsxl/command/GroupCommand.java @@ -18,11 +18,10 @@ package de.erethon.dungeonsxl.command; import de.erethon.commons.chat.MessageUtil; import de.erethon.dungeonsxl.DungeonsXL; +import de.erethon.dungeonsxl.api.event.group.GroupCreateEvent; +import de.erethon.dungeonsxl.api.event.group.GroupDisbandEvent; +import de.erethon.dungeonsxl.api.event.group.GroupPlayerKickEvent; import de.erethon.dungeonsxl.config.DMessage; -import de.erethon.dungeonsxl.event.dgroup.DGroupCreateEvent; -import de.erethon.dungeonsxl.event.dgroup.DGroupDisbandEvent; -import de.erethon.dungeonsxl.event.dplayer.DPlayerKickEvent; -import de.erethon.dungeonsxl.player.DGlobalPlayer; import de.erethon.dungeonsxl.player.DGroup; import de.erethon.dungeonsxl.player.DPermission; import org.bukkit.Bukkit; @@ -123,7 +122,7 @@ public class GroupCommand extends DCommand { } DGroup dGroup = new DGroup(plugin, args[2], player); - DGroupCreateEvent event = new DGroupCreateEvent(dGroup, player, DGroupCreateEvent.Cause.COMMAND); + GroupCreateEvent event = new GroupCreateEvent(dGroup, plugin.getPlayerCache().get(player), GroupCreateEvent.Cause.COMMAND); Bukkit.getPluginManager().callEvent(event); if (event.isCancelled()) { @@ -148,7 +147,7 @@ public class GroupCommand extends DCommand { return; } - DGroupDisbandEvent event = new DGroupDisbandEvent(dGroup, player, DGroupDisbandEvent.Cause.COMMAND); + GroupDisbandEvent event = new GroupDisbandEvent(dGroup, plugin.getPlayerCache().get(player), GroupDisbandEvent.Cause.COMMAND); Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { @@ -224,7 +223,7 @@ public class GroupCommand extends DCommand { Player toKick = Bukkit.getPlayer(args[2]); if (toKick != null) { - DPlayerKickEvent event = new DPlayerKickEvent((DGlobalPlayer) dPlayers.get(toKick.getPlayer()), DPlayerKickEvent.Cause.COMMAND); + GroupPlayerKickEvent event = new GroupPlayerKickEvent(dGroup, dPlayers.get(toKick.getPlayer()), GroupPlayerKickEvent.Cause.COMMAND); Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { diff --git a/core/src/main/java/de/erethon/dungeonsxl/command/LeaveCommand.java b/core/src/main/java/de/erethon/dungeonsxl/command/LeaveCommand.java index 8c9aa84f..fd42bca5 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/command/LeaveCommand.java +++ b/core/src/main/java/de/erethon/dungeonsxl/command/LeaveCommand.java @@ -19,14 +19,11 @@ package de.erethon.dungeonsxl.command; import de.erethon.commons.chat.MessageUtil; import de.erethon.dungeonsxl.DungeonsXL; import de.erethon.dungeonsxl.api.dungeon.Game; +import de.erethon.dungeonsxl.api.event.group.GroupPlayerLeaveEvent; import de.erethon.dungeonsxl.api.player.PlayerGroup; import de.erethon.dungeonsxl.config.DMessage; -import de.erethon.dungeonsxl.event.dplayer.DPlayerLeaveDGroupEvent; -import de.erethon.dungeonsxl.event.dplayer.instance.game.DGamePlayerEscapeEvent; import de.erethon.dungeonsxl.player.DEditPlayer; -import de.erethon.dungeonsxl.player.DGamePlayer; import de.erethon.dungeonsxl.player.DGlobalPlayer; -import de.erethon.dungeonsxl.player.DGroup; import de.erethon.dungeonsxl.player.DInstancePlayer; import de.erethon.dungeonsxl.player.DPermission; import org.bukkit.Bukkit; @@ -66,17 +63,9 @@ public class LeaveCommand extends DCommand { return; } - if (dPlayer instanceof DGamePlayer) { - DGamePlayerEscapeEvent dPlayerEscapeEvent = new DGamePlayerEscapeEvent((DGamePlayer) dPlayer); - Bukkit.getPluginManager().callEvent(dPlayerEscapeEvent); - if (dPlayerEscapeEvent.isCancelled()) { - return; - } - } - - DPlayerLeaveDGroupEvent dPlayerLeaveDGroupEvent = new DPlayerLeaveDGroupEvent(dPlayer, (DGroup) dGroup); - Bukkit.getPluginManager().callEvent(dPlayerLeaveDGroupEvent); - if (dPlayerLeaveDGroupEvent.isCancelled()) { + GroupPlayerLeaveEvent groupPlayerLeaveEvent = new GroupPlayerLeaveEvent(dGroup, dPlayer); + Bukkit.getPluginManager().callEvent(groupPlayerLeaveEvent); + if (groupPlayerLeaveEvent.isCancelled()) { return; } diff --git a/core/src/main/java/de/erethon/dungeonsxl/command/PlayCommand.java b/core/src/main/java/de/erethon/dungeonsxl/command/PlayCommand.java index 90a3e769..dd2b47e1 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/command/PlayCommand.java +++ b/core/src/main/java/de/erethon/dungeonsxl/command/PlayCommand.java @@ -19,11 +19,11 @@ package de.erethon.dungeonsxl.command; import de.erethon.commons.chat.MessageUtil; import de.erethon.dungeonsxl.DungeonsXL; import de.erethon.dungeonsxl.api.dungeon.Dungeon; +import de.erethon.dungeonsxl.api.event.group.GroupCreateEvent; import de.erethon.dungeonsxl.api.player.GlobalPlayer; import de.erethon.dungeonsxl.api.world.GameWorld; import de.erethon.dungeonsxl.config.DMessage; import de.erethon.dungeonsxl.dungeon.DGame; -import de.erethon.dungeonsxl.event.dgroup.DGroupCreateEvent; import de.erethon.dungeonsxl.player.DGamePlayer; import de.erethon.dungeonsxl.player.DGroup; import de.erethon.dungeonsxl.player.DInstancePlayer; @@ -69,7 +69,7 @@ public class PlayCommand extends DCommand { return; } else if (group == null) { group = new DGroup(plugin, player, dungeon); - DGroupCreateEvent event = new DGroupCreateEvent(group, player, DGroupCreateEvent.Cause.COMMAND); + GroupCreateEvent event = new GroupCreateEvent(group, dPlayer, GroupCreateEvent.Cause.COMMAND); Bukkit.getPluginManager().callEvent(event); if (event.isCancelled()) { plugin.getGroupCache().remove(group); diff --git a/core/src/main/java/de/erethon/dungeonsxl/command/ReloadCommand.java b/core/src/main/java/de/erethon/dungeonsxl/command/ReloadCommand.java index 804e2374..69fc0f91 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/command/ReloadCommand.java +++ b/core/src/main/java/de/erethon/dungeonsxl/command/ReloadCommand.java @@ -21,9 +21,9 @@ import de.erethon.commons.chat.MessageUtil; import de.erethon.commons.compatibility.CompatibilityHandler; import de.erethon.commons.compatibility.Internals; import de.erethon.dungeonsxl.DungeonsXL; +import de.erethon.dungeonsxl.api.event.DataReloadEvent; import de.erethon.dungeonsxl.api.player.InstancePlayer; import de.erethon.dungeonsxl.config.DMessage; -import de.erethon.dungeonsxl.event.DataReloadEvent; import de.erethon.dungeonsxl.player.DPermission; import java.util.Collection; import net.md_5.bungee.api.chat.ClickEvent; diff --git a/core/src/main/java/de/erethon/dungeonsxl/mob/DMob.java b/core/src/main/java/de/erethon/dungeonsxl/mob/DMob.java index 63a56c56..74393072 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/mob/DMob.java +++ b/core/src/main/java/de/erethon/dungeonsxl/mob/DMob.java @@ -20,11 +20,11 @@ import de.erethon.caliburn.mob.ExMob; import de.erethon.caliburn.mob.VanillaMob; import de.erethon.commons.compatibility.Version; import de.erethon.dungeonsxl.DungeonsXL; +import de.erethon.dungeonsxl.api.event.mob.DungeonMobDeathEvent; +import de.erethon.dungeonsxl.api.event.mob.DungeonMobSpawnEvent; import de.erethon.dungeonsxl.api.mob.DungeonMob; import de.erethon.dungeonsxl.api.world.GameWorld; import de.erethon.dungeonsxl.dungeon.DGame; -import de.erethon.dungeonsxl.event.dmob.DMobDeathEvent; -import de.erethon.dungeonsxl.event.dmob.DMobSpawnEvent; import de.erethon.dungeonsxl.trigger.MobTrigger; import de.erethon.dungeonsxl.trigger.WaveTrigger; import de.erethon.dungeonsxl.world.DGameWorld; @@ -60,13 +60,10 @@ public class DMob implements DungeonMob { entity.getEquipment().setItemInHandDropChance(0); } } + gameWorld.addMob(this); - DMobSpawnEvent event = new DMobSpawnEvent(this, entity); + DungeonMobSpawnEvent event = new DungeonMobSpawnEvent(this); Bukkit.getPluginManager().callEvent(event); - - if (!event.isCancelled()) { - gameWorld.addMob(this); - } } public DMob(LivingEntity entity, GameWorld gameWorld, String trigger) { @@ -112,9 +109,8 @@ public class DMob implements DungeonMob { return; } - DMobDeathEvent dMobDeathEvent = new DMobDeathEvent(this, event); + DungeonMobDeathEvent dMobDeathEvent = new DungeonMobDeathEvent(this); Bukkit.getServer().getPluginManager().callEvent(dMobDeathEvent); - if (dMobDeathEvent.isCancelled()) { return; } diff --git a/core/src/main/java/de/erethon/dungeonsxl/player/DGamePlayer.java b/core/src/main/java/de/erethon/dungeonsxl/player/DGamePlayer.java index 53f0cb1a..ce7d34e7 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/player/DGamePlayer.java +++ b/core/src/main/java/de/erethon/dungeonsxl/player/DGamePlayer.java @@ -21,11 +21,15 @@ import de.erethon.caliburn.mob.VanillaMob; import de.erethon.commons.chat.MessageUtil; import de.erethon.commons.player.PlayerUtil; import de.erethon.dungeonsxl.DungeonsXL; +import de.erethon.dungeonsxl.api.Reward; import de.erethon.dungeonsxl.api.dungeon.Game; import de.erethon.dungeonsxl.api.dungeon.GameGoal; import de.erethon.dungeonsxl.api.dungeon.GameRule; import de.erethon.dungeonsxl.api.dungeon.GameRuleContainer; +import de.erethon.dungeonsxl.api.event.group.GroupPlayerKickEvent; import de.erethon.dungeonsxl.api.event.player.GamePlayerDeathEvent; +import de.erethon.dungeonsxl.api.event.player.GamePlayerFinishEvent; +import de.erethon.dungeonsxl.api.event.player.GlobalPlayerRewardPayOutEvent; import de.erethon.dungeonsxl.api.mob.DungeonMob; import de.erethon.dungeonsxl.api.player.GamePlayer; import de.erethon.dungeonsxl.api.player.PlayerClass; @@ -33,14 +37,13 @@ import de.erethon.dungeonsxl.api.player.PlayerGroup; import de.erethon.dungeonsxl.api.world.GameWorld; import de.erethon.dungeonsxl.config.DMessage; import de.erethon.dungeonsxl.dungeon.DGame; -import de.erethon.dungeonsxl.event.dplayer.DPlayerKickEvent; import de.erethon.dungeonsxl.event.dplayer.instance.DInstancePlayerUpdateEvent; -import de.erethon.dungeonsxl.event.dplayer.instance.game.DGamePlayerFinishEvent; -import de.erethon.dungeonsxl.event.dplayer.instance.game.DGamePlayerRewardEvent; import de.erethon.dungeonsxl.trigger.DistanceTrigger; import de.erethon.dungeonsxl.world.DGameWorld; import de.erethon.dungeonsxl.world.DResourceWorld; import de.erethon.dungeonsxl.world.block.TeamFlag; +import java.util.ArrayList; +import java.util.List; import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Location; @@ -386,10 +389,12 @@ public class DGamePlayer extends DInstancePlayer implements GamePlayer { } if (game != null && finished && game.hasRewards()) { - DGamePlayerRewardEvent dGroupRewardEvent = new DGamePlayerRewardEvent(this); - Bukkit.getPluginManager().callEvent(dGroupRewardEvent); - if (!dGroupRewardEvent.isCancelled()) { - giveLoot(getGroup().getDungeon(), rules.getState(GameRule.REWARDS), dGroup.getRewards()); + List rewards = new ArrayList<>(dGroup.getRewards()); + rewards.addAll(rules.getState(GameRule.REWARDS)); + GlobalPlayerRewardPayOutEvent globalPlayerPayOutRewardEvent = new GlobalPlayerRewardPayOutEvent(this, rewards); + Bukkit.getPluginManager().callEvent(globalPlayerPayOutRewardEvent); + if (!globalPlayerPayOutRewardEvent.isCancelled()) { + giveLoot(getGroup().getDungeon(), globalPlayerPayOutRewardEvent.getRewards()); } getData().logTimeLastFinished(getGroup().getDungeonName()); @@ -456,7 +461,7 @@ public class DGamePlayer extends DInstancePlayer implements GamePlayer { @Override public void kill() { - DPlayerKickEvent dPlayerKickEvent = new DPlayerKickEvent(this, DPlayerKickEvent.Cause.DEATH); + GroupPlayerKickEvent dPlayerKickEvent = new GroupPlayerKickEvent(getGroup(), this, GroupPlayerKickEvent.Cause.DEATH); Bukkit.getPluginManager().callEvent(dPlayerKickEvent); if (!dPlayerKickEvent.isCancelled()) { @@ -557,9 +562,9 @@ public class DGamePlayer extends DInstancePlayer implements GamePlayer { hasToWait = true; } - DGamePlayerFinishEvent dPlayerFinishEvent = new DGamePlayerFinishEvent(this, hasToWait); - Bukkit.getPluginManager().callEvent(dPlayerFinishEvent); - if (dPlayerFinishEvent.isCancelled()) { + GamePlayerFinishEvent gamePlayerFinishEvent = new GamePlayerFinishEvent(this, hasToWait); + Bukkit.getPluginManager().callEvent(gamePlayerFinishEvent); + if (gamePlayerFinishEvent.isCancelled()) { finished = false; } } @@ -589,9 +594,9 @@ public class DGamePlayer extends DInstancePlayer implements GamePlayer { hasToWait = true; } - DGamePlayerFinishEvent dPlayerFinishEvent = new DGamePlayerFinishEvent(this, hasToWait); - Bukkit.getPluginManager().callEvent(dPlayerFinishEvent); - if (dPlayerFinishEvent.isCancelled()) { + GamePlayerFinishEvent gamePlayerFinishEvent = new GamePlayerFinishEvent(this, hasToWait); + Bukkit.getPluginManager().callEvent(gamePlayerFinishEvent); + if (gamePlayerFinishEvent.isCancelled()) { finished = false; } } @@ -768,10 +773,10 @@ public class DGamePlayer extends DInstancePlayer implements GamePlayer { } if (kick) { - DPlayerKickEvent dPlayerKickEvent = new DPlayerKickEvent(this, DPlayerKickEvent.Cause.OFFLINE); - Bukkit.getPluginManager().callEvent(dPlayerKickEvent); + GroupPlayerKickEvent groupPlayerKickEvent = new GroupPlayerKickEvent(getGroup(), this, GroupPlayerKickEvent.Cause.OFFLINE); + Bukkit.getPluginManager().callEvent(groupPlayerKickEvent); - if (!dPlayerKickEvent.isCancelled()) { + if (!groupPlayerKickEvent.isCancelled()) { leave(); } } diff --git a/core/src/main/java/de/erethon/dungeonsxl/player/DGlobalPlayer.java b/core/src/main/java/de/erethon/dungeonsxl/player/DGlobalPlayer.java index ed51a4b3..d9c4fa87 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/player/DGlobalPlayer.java +++ b/core/src/main/java/de/erethon/dungeonsxl/player/DGlobalPlayer.java @@ -25,13 +25,13 @@ import de.erethon.dungeonsxl.api.Reward; import de.erethon.dungeonsxl.api.dungeon.Dungeon; import de.erethon.dungeonsxl.api.dungeon.GameRule; import de.erethon.dungeonsxl.api.dungeon.GameRuleContainer; +import de.erethon.dungeonsxl.api.event.group.GroupCreateEvent; import de.erethon.dungeonsxl.api.event.requirement.RequirementCheckEvent; import de.erethon.dungeonsxl.api.player.GlobalPlayer; import de.erethon.dungeonsxl.api.player.PlayerGroup; import de.erethon.dungeonsxl.api.world.GameWorld; import de.erethon.dungeonsxl.config.DMessage; import de.erethon.dungeonsxl.dungeon.DGame; -import de.erethon.dungeonsxl.event.dgroup.DGroupCreateEvent; import de.erethon.dungeonsxl.global.DPortal; import de.erethon.dungeonsxl.util.LocationString; import de.erethon.dungeonsxl.util.NBTUtil; @@ -377,12 +377,11 @@ public class DGlobalPlayer implements GlobalPlayer { return dataTime == -1 || dataTime + requirement * 1000 * 60 * 60 <= System.currentTimeMillis(); } - public void giveLoot(Dungeon dungeon, List ruleRewards, List groupRewards) { + public void giveLoot(Dungeon dungeon, List rewards) { if (!canLoot(dungeon)) { return; } - ruleRewards.forEach(r -> r.giveTo(player.getPlayer())); - groupRewards.forEach(r -> r.giveTo(player.getPlayer())); + rewards.forEach(r -> r.giveTo(player.getPlayer())); if (getGroup() != null && getGroup().getDungeon() != null) { getData().logTimeLastLoot(getGroup().getDungeon().getName()); } @@ -534,7 +533,7 @@ public class DGlobalPlayer implements GlobalPlayer { DGroup dGroup = new DGroup(plugin, "Tutorial", player, dungeon); - DGroupCreateEvent createEvent = new DGroupCreateEvent(dGroup, player, DGroupCreateEvent.Cause.GROUP_SIGN); + GroupCreateEvent createEvent = new GroupCreateEvent(dGroup, this, GroupCreateEvent.Cause.GROUP_SIGN); Bukkit.getPluginManager().callEvent(createEvent); if (createEvent.isCancelled()) { dGroup = null; diff --git a/core/src/main/java/de/erethon/dungeonsxl/player/DGroup.java b/core/src/main/java/de/erethon/dungeonsxl/player/DGroup.java index d4999201..f4f82bf8 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/player/DGroup.java +++ b/core/src/main/java/de/erethon/dungeonsxl/player/DGroup.java @@ -25,6 +25,12 @@ import de.erethon.dungeonsxl.api.dungeon.Dungeon; import de.erethon.dungeonsxl.api.dungeon.Game; import de.erethon.dungeonsxl.api.dungeon.GameRule; import de.erethon.dungeonsxl.api.dungeon.GameRuleContainer; +import de.erethon.dungeonsxl.api.event.group.GroupCollectRewardEvent; +import de.erethon.dungeonsxl.api.event.group.GroupDisbandEvent; +import de.erethon.dungeonsxl.api.event.group.GroupFinishDungeonEvent; +import de.erethon.dungeonsxl.api.event.group.GroupFinishFloorEvent; +import de.erethon.dungeonsxl.api.event.group.GroupPlayerJoinEvent; +import de.erethon.dungeonsxl.api.event.group.GroupStartFloorEvent; import de.erethon.dungeonsxl.api.event.requirement.RequirementDemandEvent; import de.erethon.dungeonsxl.api.player.GlobalPlayer; import de.erethon.dungeonsxl.api.player.InstancePlayer; @@ -37,12 +43,6 @@ import de.erethon.dungeonsxl.config.DMessage; import de.erethon.dungeonsxl.dungeon.DDungeon; import de.erethon.dungeonsxl.dungeon.DGame; import de.erethon.dungeonsxl.dungeon.DungeonConfig; -import de.erethon.dungeonsxl.event.dgroup.DGroupDisbandEvent; -import de.erethon.dungeonsxl.event.dgroup.DGroupFinishDungeonEvent; -import de.erethon.dungeonsxl.event.dgroup.DGroupFinishFloorEvent; -import de.erethon.dungeonsxl.event.dgroup.DGroupStartFloorEvent; -import de.erethon.dungeonsxl.event.dplayer.DPlayerJoinDGroupEvent; -import de.erethon.dungeonsxl.event.reward.RewardAdditionEvent; import de.erethon.dungeonsxl.world.DGameWorld; import de.erethon.dungeonsxl.world.DResourceWorld; import java.util.ArrayList; @@ -100,8 +100,15 @@ public class DGroup implements PlayerGroup { plugin.getGroupCache().add(name, this); this.name = name; - setLeader(player); - addMember(player); + GroupPlayerJoinEvent event = new GroupPlayerJoinEvent(this, dPlayers.get(player), true); + Bukkit.getPluginManager().callEvent(event); + if (!event.isCancelled()) { + setLeader(player); + addMember(player); + } else { + plugin.getGroupCache().remove(this); + return; + } playing = false; floorCount = 0; @@ -124,9 +131,8 @@ public class DGroup implements PlayerGroup { plugin.getGroupCache().add(name, this); this.name = name; - DPlayerJoinDGroupEvent event = new DPlayerJoinDGroupEvent((DGlobalPlayer) dPlayers.get(captain), true, this); + GroupPlayerJoinEvent event = new GroupPlayerJoinEvent(this, dPlayers.get(captain), true); Bukkit.getPluginManager().callEvent(event); - if (!event.isCancelled()) { this.captain = captain; this.players.add(captain); @@ -137,6 +143,10 @@ public class DGroup implements PlayerGroup { addMember(player); } } + if (getMembers().size() == 0) { + plugin.getGroupCache().remove(this); + return; + } setDungeon(dungeon); playing = false; @@ -205,18 +215,17 @@ public class DGroup implements PlayerGroup { @Override public void addMember(Player player, boolean message) { - DPlayerJoinDGroupEvent event = new DPlayerJoinDGroupEvent((DGlobalPlayer) dPlayers.getGamePlayer(player), false, this); + GroupPlayerJoinEvent event = new GroupPlayerJoinEvent(this, dPlayers.getGamePlayer(player), false); Bukkit.getPluginManager().callEvent(event); - - if (!event.isCancelled()) { - if (message) { - sendMessage(DMessage.GROUP_PLAYER_JOINED.getMessage(player.getName())); - MessageUtil.sendMessage(player, DMessage.PLAYER_JOIN_GROUP.getMessage()); - } - - players.add(player.getUniqueId()); + if (event.isCancelled()) { + return; } + if (message) { + sendMessage(DMessage.GROUP_PLAYER_JOINED.getMessage(player.getName())); + MessageUtil.sendMessage(player, DMessage.PLAYER_JOIN_GROUP.getMessage()); + } + players.add(player.getUniqueId()); plugin.getGroupAdapters().forEach(a -> a.syncJoin(player)); } @@ -235,9 +244,8 @@ public class DGroup implements PlayerGroup { } if (isEmpty()) { - DGroupDisbandEvent event = new DGroupDisbandEvent(this, player, DGroupDisbandEvent.Cause.GROUP_IS_EMPTY); + GroupDisbandEvent event = new GroupDisbandEvent(this, dPlayers.get(player), GroupDisbandEvent.Cause.GROUP_IS_EMPTY); Bukkit.getPluginManager().callEvent(event); - if (!event.isCancelled()) { delete(); return; @@ -421,9 +429,8 @@ public class DGroup implements PlayerGroup { @Override public void addReward(Reward reward) { - RewardAdditionEvent event = new RewardAdditionEvent(reward, this); + GroupCollectRewardEvent event = new GroupCollectRewardEvent(this, null, reward); Bukkit.getPluginManager().callEvent(event); - if (event.isCancelled()) { return; } @@ -586,9 +593,9 @@ public class DGroup implements PlayerGroup { * The group finishs the dungeon. */ public void finish() { - DGroupFinishDungeonEvent dGroupFinishDungeonEvent = new DGroupFinishDungeonEvent((DDungeon) dungeon, this); - Bukkit.getPluginManager().callEvent(dGroupFinishDungeonEvent); - if (dGroupFinishDungeonEvent.isCancelled()) { + GroupFinishDungeonEvent groupFinishDungeonEvent = new GroupFinishDungeonEvent(this, dungeon); + Bukkit.getPluginManager().callEvent(groupFinishDungeonEvent); + if (groupFinishDungeonEvent.isCancelled()) { return; } @@ -621,7 +628,7 @@ public class DGroup implements PlayerGroup { type = GameWorld.Type.END_FLOOR; } - DGroupFinishFloorEvent event = new DGroupFinishFloorEvent(this, (DGameWorld) gameWorld, (DResourceWorld) newFloor); + GroupFinishFloorEvent event = new GroupFinishFloorEvent(this, gameWorld, newFloor); Bukkit.getPluginManager().callEvent(event); if (event.isCancelled()) { return; @@ -706,9 +713,8 @@ public class DGroup implements PlayerGroup { } } - DGroupStartFloorEvent event = new DGroupStartFloorEvent(this, (DGameWorld) gameWorld); + GroupStartFloorEvent event = new GroupStartFloorEvent(this, gameWorld); Bukkit.getPluginManager().callEvent(event); - if (event.isCancelled()) { return false; } diff --git a/core/src/main/java/de/erethon/dungeonsxl/player/TimeIsRunningTask.java b/core/src/main/java/de/erethon/dungeonsxl/player/TimeIsRunningTask.java index 1250465f..f3ed1fbd 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/player/TimeIsRunningTask.java +++ b/core/src/main/java/de/erethon/dungeonsxl/player/TimeIsRunningTask.java @@ -18,9 +18,10 @@ package de.erethon.dungeonsxl.player; import de.erethon.commons.chat.MessageUtil; import de.erethon.dungeonsxl.DungeonsXL; +import de.erethon.dungeonsxl.api.event.group.GroupPlayerKickEvent; +import de.erethon.dungeonsxl.api.player.GamePlayer; import de.erethon.dungeonsxl.api.player.PlayerGroup; import de.erethon.dungeonsxl.config.DMessage; -import de.erethon.dungeonsxl.event.dplayer.DPlayerKickEvent; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; @@ -60,15 +61,15 @@ public class TimeIsRunningTask extends BukkitRunnable { for (Player player : group.getMembers().getOnlinePlayers()) { MessageUtil.sendActionBarMessage(player, DMessage.PLAYER_TIME_LEFT.getMessage(color, String.valueOf(timeLeft))); - DGamePlayer dPlayer = (DGamePlayer) plugin.getPlayerCache().getGamePlayer(player); + GamePlayer dPlayer = plugin.getPlayerCache().getGamePlayer(player); if (timeLeft > 0) { continue; } - DPlayerKickEvent dPlayerKickEvent = new DPlayerKickEvent(dPlayer, DPlayerKickEvent.Cause.TIME_EXPIRED); - Bukkit.getServer().getPluginManager().callEvent(dPlayerKickEvent); + GroupPlayerKickEvent groupPlayerKickEvent = new GroupPlayerKickEvent(group, dPlayer, GroupPlayerKickEvent.Cause.TIME_EXPIRED); + Bukkit.getServer().getPluginManager().callEvent(groupPlayerKickEvent); - if (!dPlayerKickEvent.isCancelled()) { + if (!groupPlayerKickEvent.isCancelled()) { MessageUtil.broadcastMessage(DMessage.PLAYER_TIME_KICK.getMessage(player.getName())); dPlayer.leave(); } diff --git a/core/src/main/java/de/erethon/dungeonsxl/sign/button/LeaveSign.java b/core/src/main/java/de/erethon/dungeonsxl/sign/button/LeaveSign.java index e9cbd84c..86e4fa96 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/sign/button/LeaveSign.java +++ b/core/src/main/java/de/erethon/dungeonsxl/sign/button/LeaveSign.java @@ -17,11 +17,11 @@ package de.erethon.dungeonsxl.sign.button; import de.erethon.dungeonsxl.api.DungeonsAPI; +import de.erethon.dungeonsxl.api.event.group.GroupPlayerLeaveEvent; +import de.erethon.dungeonsxl.api.player.GamePlayer; import de.erethon.dungeonsxl.api.sign.Button; import de.erethon.dungeonsxl.api.world.InstanceWorld; import de.erethon.dungeonsxl.config.DMessage; -import de.erethon.dungeonsxl.event.dplayer.instance.game.DGamePlayerEscapeEvent; -import de.erethon.dungeonsxl.player.DGamePlayer; import de.erethon.dungeonsxl.player.DPermission; import de.erethon.dungeonsxl.trigger.InteractTrigger; import de.erethon.dungeonsxl.world.DGameWorld; @@ -90,16 +90,15 @@ public class LeaveSign extends Button { @Override public boolean push(Player player) { - DGamePlayer dPlayer = (DGamePlayer) api.getPlayerCache().getGamePlayer(player); - if (dPlayer != null) { - DGamePlayerEscapeEvent event = new DGamePlayerEscapeEvent(dPlayer); + GamePlayer gamePlayer = api.getPlayerCache().getGamePlayer(player); + if (gamePlayer != null) { + GroupPlayerLeaveEvent event = new GroupPlayerLeaveEvent(gamePlayer.getGroup(), gamePlayer); Bukkit.getPluginManager().callEvent(event); - if (event.isCancelled()) { return false; } - dPlayer.leave(); + gamePlayer.leave(); } return true; diff --git a/core/src/main/java/de/erethon/dungeonsxl/world/DEditWorld.java b/core/src/main/java/de/erethon/dungeonsxl/world/DEditWorld.java index 67b83fdb..bb94f07d 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/world/DEditWorld.java +++ b/core/src/main/java/de/erethon/dungeonsxl/world/DEditWorld.java @@ -19,9 +19,9 @@ package de.erethon.dungeonsxl.world; import de.erethon.commons.compatibility.Version; import de.erethon.commons.misc.FileUtil; import de.erethon.dungeonsxl.DungeonsXL; +import de.erethon.dungeonsxl.api.event.world.EditWorldSaveEvent; +import de.erethon.dungeonsxl.api.event.world.EditWorldUnloadEvent; import de.erethon.dungeonsxl.api.world.EditWorld; -import de.erethon.dungeonsxl.event.editworld.EditWorldSaveEvent; -import de.erethon.dungeonsxl.event.editworld.EditWorldUnloadEvent; import java.io.File; import java.io.IOException; import org.bukkit.Bukkit; diff --git a/core/src/main/java/de/erethon/dungeonsxl/world/DGameWorld.java b/core/src/main/java/de/erethon/dungeonsxl/world/DGameWorld.java index 949ddf97..470262f7 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/world/DGameWorld.java +++ b/core/src/main/java/de/erethon/dungeonsxl/world/DGameWorld.java @@ -27,13 +27,12 @@ import de.erethon.dungeonsxl.api.dungeon.Dungeon; import de.erethon.dungeonsxl.api.dungeon.Game; import de.erethon.dungeonsxl.api.dungeon.GameRule; import de.erethon.dungeonsxl.api.dungeon.GameRuleContainer; +import de.erethon.dungeonsxl.api.event.world.GameWorldStartGameEvent; +import de.erethon.dungeonsxl.api.event.world.InstanceWorldUnloadEvent; import de.erethon.dungeonsxl.api.mob.DungeonMob; import de.erethon.dungeonsxl.api.player.PlayerGroup; import de.erethon.dungeonsxl.api.sign.DungeonSign; import de.erethon.dungeonsxl.api.world.GameWorld; -import de.erethon.dungeonsxl.dungeon.DGame; -import de.erethon.dungeonsxl.event.gameworld.GameWorldStartGameEvent; -import de.erethon.dungeonsxl.event.gameworld.GameWorldUnloadEvent; import de.erethon.dungeonsxl.sign.button.ReadySign; import de.erethon.dungeonsxl.sign.passive.StartSign; import de.erethon.dungeonsxl.sign.windup.MobSign; @@ -404,7 +403,7 @@ public class DGameWorld extends DInstanceWorld implements GameWorld { * Set up the instance for the game */ public void startGame() { - GameWorldStartGameEvent event = new GameWorldStartGameEvent(this, (DGame) getGame()); + GameWorldStartGameEvent event = new GameWorldStartGameEvent(this, getGame()); Bukkit.getPluginManager().callEvent(event); if (event.isCancelled()) { return; @@ -451,9 +450,8 @@ public class DGameWorld extends DInstanceWorld implements GameWorld { */ @Override public void delete() { - GameWorldUnloadEvent event = new GameWorldUnloadEvent(this); + InstanceWorldUnloadEvent event = new InstanceWorldUnloadEvent(this); Bukkit.getPluginManager().callEvent(event); - if (event.isCancelled()) { return; } diff --git a/core/src/main/java/de/erethon/dungeonsxl/world/DResourceWorld.java b/core/src/main/java/de/erethon/dungeonsxl/world/DResourceWorld.java index 095aa8dc..3f3d44a4 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/world/DResourceWorld.java +++ b/core/src/main/java/de/erethon/dungeonsxl/world/DResourceWorld.java @@ -22,11 +22,11 @@ import de.erethon.commons.misc.FileUtil; import de.erethon.dungeonsxl.DungeonsXL; import de.erethon.dungeonsxl.api.dungeon.Dungeon; import de.erethon.dungeonsxl.api.dungeon.GameRuleContainer; +import de.erethon.dungeonsxl.api.event.world.EditWorldGenerateEvent; import de.erethon.dungeonsxl.api.player.EditPlayer; import de.erethon.dungeonsxl.api.world.EditWorld; import de.erethon.dungeonsxl.api.world.GameWorld; import de.erethon.dungeonsxl.api.world.ResourceWorld; -import de.erethon.dungeonsxl.event.editworld.EditWorldGenerateEvent; import java.io.File; import java.io.IOException; import java.lang.ref.WeakReference; diff --git a/core/src/main/java/de/erethon/dungeonsxl/world/block/RewardChest.java b/core/src/main/java/de/erethon/dungeonsxl/world/block/RewardChest.java index 9b4a793d..66c1441d 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/world/block/RewardChest.java +++ b/core/src/main/java/de/erethon/dungeonsxl/world/block/RewardChest.java @@ -22,6 +22,8 @@ import de.erethon.commons.misc.SimpleDateUtil; import de.erethon.dungeonsxl.DungeonsXL; import de.erethon.dungeonsxl.api.Reward; import de.erethon.dungeonsxl.api.dungeon.Game; +import de.erethon.dungeonsxl.api.event.group.GroupCollectRewardEvent; +import de.erethon.dungeonsxl.api.player.GamePlayer; import de.erethon.dungeonsxl.api.player.PlayerGroup; import de.erethon.dungeonsxl.config.DMessage; import de.erethon.dungeonsxl.player.DGamePlayer; @@ -115,12 +117,12 @@ public class RewardChest extends GameBlock { } if (block.getLocation().distance(block.getLocation()) < 1) { - addTreasure(api.getPlayerGroup(opener)); + addTreasure(api.getPlayerGroup(opener), api.getPlayerCache().getGamePlayer(opener)); used = true; } } - public void addTreasure(PlayerGroup group) { + public void addTreasure(PlayerGroup group, GamePlayer collector) { if (group == null) { return; } @@ -133,15 +135,27 @@ public class RewardChest extends GameBlock { for (Reward reward : group.getRewards()) { if (reward instanceof MoneyReward) { hasMoneyReward = true; - ((MoneyReward) reward).addMoney(moneyReward); + GroupCollectRewardEvent event = new GroupCollectRewardEvent(group, collector, reward); + Bukkit.getPluginManager().callEvent(event); + if (!event.isCancelled()) { + ((MoneyReward) reward).addMoney(moneyReward); + } } else if (reward instanceof LevelReward) { hasLevelReward = true; - ((LevelReward) reward).addLevels(levelReward); + GroupCollectRewardEvent event = new GroupCollectRewardEvent(group, collector, reward); + Bukkit.getPluginManager().callEvent(event); + if (!event.isCancelled()) { + ((LevelReward) reward).addLevels(levelReward); + } } else if (reward instanceof ItemReward) { hasItemReward = true; - ((ItemReward) reward).addItems(itemReward); + GroupCollectRewardEvent event = new GroupCollectRewardEvent(group, collector, reward); + Bukkit.getPluginManager().callEvent(event); + if (!event.isCancelled()) { + ((ItemReward) reward).addItems(itemReward); + } } } @@ -150,19 +164,31 @@ public class RewardChest extends GameBlock { if (!hasMoneyReward) { MoneyReward reward = new MoneyReward(econ); reward.addMoney(moneyReward); - group.addReward(reward); + GroupCollectRewardEvent event = new GroupCollectRewardEvent(group, collector, reward); + Bukkit.getPluginManager().callEvent(event); + if (!event.isCancelled()) { + group.getRewards().add(reward); + } } if (!hasLevelReward) { LevelReward reward = new LevelReward(); reward.addLevels(levelReward); - group.addReward(reward); + GroupCollectRewardEvent event = new GroupCollectRewardEvent(group, collector, reward); + Bukkit.getPluginManager().callEvent(event); + if (!event.isCancelled()) { + group.getRewards().add(reward); + } } if (!hasItemReward) { ItemReward reward = new ItemReward(api); reward.addItems(itemReward); - group.addReward(reward); + GroupCollectRewardEvent event = new GroupCollectRewardEvent(group, collector, reward); + Bukkit.getPluginManager().callEvent(event); + if (!event.isCancelled()) { + group.getRewards().add(reward); + } } }