Merge pull request #776 from DRE2N/events; resolves #661

New event API
This commit is contained in:
Daniel Saukel 2020-04-25 21:52:13 +02:00 committed by GitHub
commit e7f1c3cf6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
76 changed files with 2018 additions and 2190 deletions

View File

@ -1,26 +1,26 @@
/*
* 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 <http://www.gnu.org/licenses/>.
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.erethon.dungeonsxl.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 {

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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.event.Cancellable;
import org.bukkit.event.HandlerList;
/**
* Fired when a group collects a reward.
* <p>
* 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 GamePlayer collector;
private Reward reward;
public GroupCollectRewardEvent(PlayerGroup group, GamePlayer collector, Reward reward) {
super(group);
this.collector = collector;
this.reward = reward;
}
/**
* Returns the player who collected the reward.
* <p>
* 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 GamePlayer 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;
}
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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 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 GlobalPlayer creator;
private Cause cause;
public GroupCreateEvent(PlayerGroup group, GlobalPlayer 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 GlobalPlayer 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;
}
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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 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 GlobalPlayer disbander;
private Cause cause;
public GroupDisbandEvent(PlayerGroup group, Cause cause) {
super(group);
this.cause = cause;
}
public GroupDisbandEvent(PlayerGroup group, GlobalPlayer disbander, Cause cause) {
super(group);
this.disbander = disbander;
this.cause = cause;
}
/**
* The player who disbanded the group.
* <p>
* 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 GlobalPlayer 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;
}
}

View File

@ -12,31 +12,31 @@
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.erethon.dungeonsxl.api.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;
}
}

View File

@ -0,0 +1,70 @@
/*
* Copyright (C) 2014-2020 Daniel Saukel
*
* This library is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNULesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.erethon.dungeonsxl.api.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.
* <p>
* 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
*/
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;
}
}

View File

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

View File

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

View File

@ -0,0 +1,98 @@
/*
* Copyright (C) 2014-2020 Daniel Saukel
*
* This library is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNULesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.erethon.dungeonsxl.api.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;
/**
* @author Daniel Saukel
*/
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
}
private static final HandlerList handlers = new HandlerList();
private boolean cancelled;
private GlobalPlayer player;
private Cause cause;
public GroupPlayerKickEvent(PlayerGroup group, GlobalPlayer player, Cause cause) {
super(group);
this.player = player;
this.cause = 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;
}
@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;
}
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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 leaves a group.
*
* @author Daniel Saukel
*/
public class GroupPlayerLeaveEvent extends GroupEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancelled;
private GlobalPlayer player;
public GroupPlayerLeaveEvent(PlayerGroup group, GlobalPlayer player) {
super(group);
this.player = player;
}
/**
* Returns the player who left the group.
*
* @return the player who left the group
*/
public GlobalPlayer 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;
}
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
package de.erethon.dungeonsxl.api.event.group;
import de.erethon.dungeonsxl.api.player.GamePlayer;
import de.erethon.dungeonsxl.api.player.PlayerGroup;
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 GamePlayer scorer;
private PlayerGroup loserGroup;
public GroupScoreEvent(PlayerGroup group, GamePlayer scorer, PlayerGroup loserGroup) {
super(group);
this.scorer = scorer;
this.loserGroup = loserGroup;
}
/**
* Returns the player who scored.
*
* @return the player who scored
*/
public GamePlayer 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;
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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
*/

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
package de.erethon.dungeonsxl.api.event.player;
import de.erethon.dungeonsxl.api.player.GamePlayer;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
/**
* Fired when a player finishs a game.
* <p>
* 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 GamePlayerFinishEvent extends GamePlayerEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancelled;
private boolean hasToWait;
public GamePlayerFinishEvent(GamePlayer gamePlayer, boolean hasToWait) {
super(gamePlayer);
this.hasToWait = 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;
}
@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;
}
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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.
* <p>
* @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<Reward> rewards;
public GlobalPlayerRewardPayOutEvent(GlobalPlayer globalPlayer, List<Reward> 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<Reward> 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;
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
package de.erethon.dungeonsxl.api.event.world;
import de.erethon.dungeonsxl.api.dungeon.Game;
import de.erethon.dungeonsxl.api.world.GameWorld;
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 {
private static final HandlerList handlers = new HandlerList();
private boolean cancelled;
private Game game;
public GameWorldStartGameEvent(GameWorld gameWorld, Game game) {
super(gameWorld, gameWorld.getDungeon());
this.game = game;
}
/**
* Returns the game.
*
* @return the game
*/
public Game getGame() {
return game;
}
@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;
}
}

View File

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

View File

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

View File

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

View File

@ -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));

View File

@ -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()) {

View File

@ -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;
}

View File

@ -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);

View File

@ -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;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,81 +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 <http://www.gnu.org/licenses/>.
*/
package de.erethon.dungeonsxl.event.dplayer;
import de.erethon.dungeonsxl.player.DGlobalPlayer;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
/**
* @author Daniel Saukel
*/
public class DPlayerKickEvent extends DPlayerEvent implements Cancellable {
public enum Cause {
COMMAND,
DEATH,
OFFLINE,
TIME_EXPIRED,
CUSTOM
}
private static final HandlerList handlers = new HandlerList();
private boolean cancelled;
private Cause cause;
public DPlayerKickEvent(DGlobalPlayer dPlayer, Cause cause) {
super(dPlayer);
this.cause = cause;
}
/**
* @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;
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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 DGamePlayerFinishEvent extends DGamePlayerEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancelled;
private boolean hasToWait;
public DGamePlayerFinishEvent(DGamePlayer dPlayer, boolean hasToWait) {
super(dPlayer);
this.hasToWait = hasToWait;
}
/**
* @return the hasToWait
*/
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;
}
public static HandlerList getHandlerList() {
return handlers;
}
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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<Reward> rewards = new ArrayList<>();
private List<Player> excludedPlayers = new ArrayList<>();
public DGamePlayerRewardEvent(DGamePlayer dPlayer) {
super(dPlayer);
this.rewards = dPlayer.getGroup().getRewards();
}
/**
* @return the rewards
*/
public List<Reward> 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<Player> 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;
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
package de.erethon.dungeonsxl.event.gameworld;
import de.erethon.dungeonsxl.dungeon.DGame;
import de.erethon.dungeonsxl.world.DGameWorld;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
/**
* @author Daniel Saukel
*/
public class GameWorldStartGameEvent extends GameWorldEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancelled;
private DGame game;
public GameWorldStartGameEvent(DGameWorld gameWorld, DGame game) {
super(gameWorld);
this.game = game;
}
/**
* @return the game
*/
public DGame getGame() {
return game;
}
/**
* @param game the game to set
*/
public void setGame(DGame game) {
this.game = game;
}
@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;
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -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;
}

View File

@ -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<Reward> 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();
}
}

View File

@ -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<Reward> ruleRewards, List<Reward> groupRewards) {
public void giveLoot(Dungeon dungeon, List<Reward> 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;

View File

@ -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;
}

View File

@ -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();
}

View File

@ -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;

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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);
}
}
}