From a3590fff1ee65938fec7aae118df52361d0666f9 Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Thu, 28 Jul 2016 23:53:02 +0200 Subject: [PATCH] #102: Restructured events --- .../dungeonsxl/command/LeaveCommand.java | 4 +- .../event/dgroup/DGroupDisbandEvent.java | 1 + .../event/dgroup/DGroupScoreEvent.java | 90 +++++++++++++++++++ .../instance/DInstancePlayerEvent.java | 40 +++++++++ .../DInstancePlayerUpdateEvent.java} | 7 +- .../instance/edit/DEditPlayerEscapeEvent.java | 54 +++++++++++ .../instance/edit/DEditPlayerEvent.java | 40 +++++++++ .../game/DGamePlayerDeathEvent.java} | 7 +- .../game/DGamePlayerEscapeEvent.java} | 8 +- .../instance/game/DGamePlayerEvent.java | 40 +++++++++ .../game/DGamePlayerFinishEvent.java} | 6 +- 11 files changed, 282 insertions(+), 15 deletions(-) create mode 100644 core/src/main/java/io/github/dre2n/dungeonsxl/event/dgroup/DGroupScoreEvent.java create mode 100644 core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/instance/DInstancePlayerEvent.java rename core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/{DPlayerUpdateEvent.java => instance/DInstancePlayerUpdateEvent.java} (90%) create mode 100644 core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/instance/edit/DEditPlayerEscapeEvent.java create mode 100644 core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/instance/edit/DEditPlayerEvent.java rename core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/{DPlayerDeathEvent.java => instance/game/DGamePlayerDeathEvent.java} (87%) rename core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/{DPlayerEscapeEvent.java => instance/game/DGamePlayerEscapeEvent.java} (83%) create mode 100644 core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/instance/game/DGamePlayerEvent.java rename core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/{DPlayerFinishEvent.java => instance/game/DGamePlayerFinishEvent.java} (89%) diff --git a/core/src/main/java/io/github/dre2n/dungeonsxl/command/LeaveCommand.java b/core/src/main/java/io/github/dre2n/dungeonsxl/command/LeaveCommand.java index ab290a7e..a717c3e2 100644 --- a/core/src/main/java/io/github/dre2n/dungeonsxl/command/LeaveCommand.java +++ b/core/src/main/java/io/github/dre2n/dungeonsxl/command/LeaveCommand.java @@ -20,8 +20,8 @@ import io.github.dre2n.commons.util.messageutil.MessageUtil; import io.github.dre2n.dungeonsxl.DungeonsXL; import io.github.dre2n.dungeonsxl.config.DMessages; -import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerEscapeEvent; import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerLeaveDGroupEvent; +import io.github.dre2n.dungeonsxl.event.dplayer.instance.edit.DEditPlayerEscapeEvent; import io.github.dre2n.dungeonsxl.player.DEditPlayer; import io.github.dre2n.dungeonsxl.player.DGlobalPlayer; import io.github.dre2n.dungeonsxl.player.DGroup; @@ -67,7 +67,7 @@ public void onExecute(String[] args, CommandSender sender) { return; } - DPlayerEscapeEvent dPlayerEscapeEvent = new DPlayerEscapeEvent(dPlayer); + DEditPlayerEscapeEvent dPlayerEscapeEvent = new DEditPlayerEscapeEvent((DEditPlayer) dPlayer); plugin.getServer().getPluginManager().callEvent(dPlayerEscapeEvent); DPlayerLeaveDGroupEvent dPlayerLeaveDGroupEvent = new DPlayerLeaveDGroupEvent(dPlayer, dGroup); plugin.getServer().getPluginManager().callEvent(dPlayerLeaveDGroupEvent); diff --git a/core/src/main/java/io/github/dre2n/dungeonsxl/event/dgroup/DGroupDisbandEvent.java b/core/src/main/java/io/github/dre2n/dungeonsxl/event/dgroup/DGroupDisbandEvent.java index d4095dda..db058c68 100644 --- a/core/src/main/java/io/github/dre2n/dungeonsxl/event/dgroup/DGroupDisbandEvent.java +++ b/core/src/main/java/io/github/dre2n/dungeonsxl/event/dgroup/DGroupDisbandEvent.java @@ -31,6 +31,7 @@ public enum Cause { COMMAND, DUNGEON_FINISHED, GROUP_IS_EMPTY, + LOST, CUSTOM } diff --git a/core/src/main/java/io/github/dre2n/dungeonsxl/event/dgroup/DGroupScoreEvent.java b/core/src/main/java/io/github/dre2n/dungeonsxl/event/dgroup/DGroupScoreEvent.java new file mode 100644 index 00000000..177ac98e --- /dev/null +++ b/core/src/main/java/io/github/dre2n/dungeonsxl/event/dgroup/DGroupScoreEvent.java @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2012-2016 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 io.github.dre2n.dungeonsxl.event.dgroup; + +import io.github.dre2n.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/io/github/dre2n/dungeonsxl/event/dplayer/instance/DInstancePlayerEvent.java b/core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/instance/DInstancePlayerEvent.java new file mode 100644 index 00000000..82b5b6c8 --- /dev/null +++ b/core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/instance/DInstancePlayerEvent.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2012-2016 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 io.github.dre2n.dungeonsxl.event.dplayer.instance; + +import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerEvent; +import io.github.dre2n.dungeonsxl.player.DInstancePlayer; + +/** + * @author Daniel Saukel + */ +public abstract class DInstancePlayerEvent extends DPlayerEvent { + + public DInstancePlayerEvent(DInstancePlayer dPlayer) { + super(dPlayer); + } + + @Override + public DInstancePlayer getDPlayer() { + return (DInstancePlayer) dPlayer; + } + + public void setDPlayer(DInstancePlayer dPlayer) { + this.dPlayer = dPlayer; + } + +} diff --git a/core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/DPlayerUpdateEvent.java b/core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/instance/DInstancePlayerUpdateEvent.java similarity index 90% rename from core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/DPlayerUpdateEvent.java rename to core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/instance/DInstancePlayerUpdateEvent.java index b66554ea..5728e029 100644 --- a/core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/DPlayerUpdateEvent.java +++ b/core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/instance/DInstancePlayerUpdateEvent.java @@ -14,8 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package io.github.dre2n.dungeonsxl.event.dplayer; +package io.github.dre2n.dungeonsxl.event.dplayer.instance; +import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerEvent; import io.github.dre2n.dungeonsxl.player.DInstancePlayer; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; @@ -23,7 +24,7 @@ /** * @author Daniel Saukel */ -public class DPlayerUpdateEvent extends DPlayerEvent implements Cancellable { +public class DInstancePlayerUpdateEvent extends DPlayerEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancelled; @@ -35,7 +36,7 @@ public class DPlayerUpdateEvent extends DPlayerEvent implements Cancellable { private boolean kick; private boolean triggerAllInDistance; - public DPlayerUpdateEvent(DInstancePlayer dPlayer, boolean locationValid, boolean teleportWolf, boolean respawnInventory, boolean offline, boolean kick, boolean triggerAllInDistance) { + public DInstancePlayerUpdateEvent(DInstancePlayer dPlayer, boolean locationValid, boolean teleportWolf, boolean respawnInventory, boolean offline, boolean kick, boolean triggerAllInDistance) { super(dPlayer); this.locationValid = locationValid; this.teleportWolf = teleportWolf; diff --git a/core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/instance/edit/DEditPlayerEscapeEvent.java b/core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/instance/edit/DEditPlayerEscapeEvent.java new file mode 100644 index 00000000..e97cbfdc --- /dev/null +++ b/core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/instance/edit/DEditPlayerEscapeEvent.java @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2012-2016 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 io.github.dre2n.dungeonsxl.event.dplayer.instance.edit; + +import io.github.dre2n.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/io/github/dre2n/dungeonsxl/event/dplayer/instance/edit/DEditPlayerEvent.java b/core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/instance/edit/DEditPlayerEvent.java new file mode 100644 index 00000000..0990eff9 --- /dev/null +++ b/core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/instance/edit/DEditPlayerEvent.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2012-2016 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 io.github.dre2n.dungeonsxl.event.dplayer.instance.edit; + +import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerEvent; +import io.github.dre2n.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; + } + +} diff --git a/core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/DPlayerDeathEvent.java b/core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/instance/game/DGamePlayerDeathEvent.java similarity index 87% rename from core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/DPlayerDeathEvent.java rename to core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/instance/game/DGamePlayerDeathEvent.java index 7bf80bdb..7fc55ed2 100644 --- a/core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/DPlayerDeathEvent.java +++ b/core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/instance/game/DGamePlayerDeathEvent.java @@ -14,8 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package io.github.dre2n.dungeonsxl.event.dplayer; +package io.github.dre2n.dungeonsxl.event.dplayer.instance.game; +import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerEvent; import io.github.dre2n.dungeonsxl.player.DGamePlayer; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; @@ -24,7 +25,7 @@ /** * @author Daniel Saukel */ -public class DPlayerDeathEvent extends DPlayerEvent implements Cancellable { +public class DGamePlayerDeathEvent extends DPlayerEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancelled; @@ -32,7 +33,7 @@ public class DPlayerDeathEvent extends DPlayerEvent implements Cancellable { private PlayerDeathEvent bukkitEvent; private int lostLives; - public DPlayerDeathEvent(DGamePlayer dPlayer, PlayerDeathEvent bukkitEvent, int lostLives) { + public DGamePlayerDeathEvent(DGamePlayer dPlayer, PlayerDeathEvent bukkitEvent, int lostLives) { super(dPlayer); this.bukkitEvent = bukkitEvent; this.lostLives = lostLives; diff --git a/core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/DPlayerEscapeEvent.java b/core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/instance/game/DGamePlayerEscapeEvent.java similarity index 83% rename from core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/DPlayerEscapeEvent.java rename to core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/instance/game/DGamePlayerEscapeEvent.java index 354d86a1..ea9df568 100644 --- a/core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/DPlayerEscapeEvent.java +++ b/core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/instance/game/DGamePlayerEscapeEvent.java @@ -14,21 +14,21 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package io.github.dre2n.dungeonsxl.event.dplayer; +package io.github.dre2n.dungeonsxl.event.dplayer.instance.game; -import io.github.dre2n.dungeonsxl.player.DGlobalPlayer; +import io.github.dre2n.dungeonsxl.player.DGamePlayer; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; /** * @author Daniel Saukel */ -public class DPlayerEscapeEvent extends DPlayerEvent implements Cancellable { +public class DGamePlayerEscapeEvent extends DGamePlayerEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancelled; - public DPlayerEscapeEvent(DGlobalPlayer dPlayer) { + public DGamePlayerEscapeEvent(DGamePlayer dPlayer) { super(dPlayer); } diff --git a/core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/instance/game/DGamePlayerEvent.java b/core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/instance/game/DGamePlayerEvent.java new file mode 100644 index 00000000..12fe140c --- /dev/null +++ b/core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/instance/game/DGamePlayerEvent.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2012-2016 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 io.github.dre2n.dungeonsxl.event.dplayer.instance.game; + +import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerEvent; +import io.github.dre2n.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/io/github/dre2n/dungeonsxl/event/dplayer/DPlayerFinishEvent.java b/core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/instance/game/DGamePlayerFinishEvent.java similarity index 89% rename from core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/DPlayerFinishEvent.java rename to core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/instance/game/DGamePlayerFinishEvent.java index 0e07ff1d..aea65090 100644 --- a/core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/DPlayerFinishEvent.java +++ b/core/src/main/java/io/github/dre2n/dungeonsxl/event/dplayer/instance/game/DGamePlayerFinishEvent.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package io.github.dre2n.dungeonsxl.event.dplayer; +package io.github.dre2n.dungeonsxl.event.dplayer.instance.game; import io.github.dre2n.dungeonsxl.player.DGamePlayer; import org.bukkit.event.Cancellable; @@ -23,7 +23,7 @@ /** * @author Daniel Saukel */ -public class DPlayerFinishEvent extends DPlayerEvent implements Cancellable { +public class DGamePlayerFinishEvent extends DGamePlayerEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancelled; @@ -31,7 +31,7 @@ public class DPlayerFinishEvent extends DPlayerEvent implements Cancellable { private boolean first; private boolean hasToWait; - public DPlayerFinishEvent(DGamePlayer dPlayer, boolean first, boolean hasToWait) { + public DGamePlayerFinishEvent(DGamePlayer dPlayer, boolean first, boolean hasToWait) { super(dPlayer); this.first = first; this.hasToWait = hasToWait;