Basic implementation of old events

This commit is contained in:
Daniel Saukel 2020-04-25 21:49:44 +02:00
parent 007f65c103
commit 29d8f75568
20 changed files with 173 additions and 186 deletions

View File

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

View File

@ -17,7 +17,6 @@ package de.erethon.dungeonsxl.api.event.group;
import de.erethon.dungeonsxl.api.Reward; import de.erethon.dungeonsxl.api.Reward;
import de.erethon.dungeonsxl.api.player.GamePlayer; import de.erethon.dungeonsxl.api.player.GamePlayer;
import de.erethon.dungeonsxl.api.player.PlayerGroup; import de.erethon.dungeonsxl.api.player.PlayerGroup;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;

View File

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

View File

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

View File

@ -1,28 +1,27 @@
/* /*
* Copyright (C) 2012-2020 Frank Baumann * Copyright (C) 2014-2020 Daniel Saukel
* *
* This program is free software: you can redistribute it and/or modify * This library is free software: you can redistribute it and/or modify it under the
* it under the terms of the GNU General Public License as published by * terms of the GNU Lesser General Public License as published by the Free Software
* the Free Software Foundation, either version 3 of the License, or * Foundation, either version 3 of the License, or (at your option) any later version.
* (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful, but WITHOUT ANY
* but WITHOUT ANY WARRANTY; without even the implied warranty of * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * PARTICULAR PURPOSE. See the GNULesser General Public License for more details.
* GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU Lesser General Public License along with
* along with this program. If not, see <http://www.gnu.org/licenses/>. * this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.erethon.dungeonsxl.api.event.world; package de.erethon.dungeonsxl.api.event.world;
import de.erethon.dungeonsxl.api.dungeon.Game; import de.erethon.dungeonsxl.api.dungeon.Game;
import de.erethon.dungeonsxl.api.world.GameWorld; import de.erethon.dungeonsxl.api.world.GameWorld;
import org.bukkit.Location;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
/** /**
* Fired when the game starts, that means when all players have triggered the ready sign.
*
* @author Daniel Saukel * @author Daniel Saukel
*/ */
public class GameWorldStartGameEvent extends GameWorldEvent implements Cancellable { public class GameWorldStartGameEvent extends GameWorldEvent implements Cancellable {
@ -31,9 +30,8 @@ public class GameWorldStartGameEvent extends GameWorldEvent implements Cancellab
private boolean cancelled; private boolean cancelled;
private Game game; private Game game;
private Location startLocation;
public GameWorldStartGameEvent(GameWorld gameWorld, Game game, Location location) { public GameWorldStartGameEvent(GameWorld gameWorld, Game game) {
super(gameWorld, gameWorld.getDungeon()); super(gameWorld, gameWorld.getDungeon());
this.game = game; this.game = game;
} }
@ -47,28 +45,6 @@ public class GameWorldStartGameEvent extends GameWorldEvent implements Cancellab
return game; return game;
} }
/**
* Returns the location where the players are teleported.
*
* @return the location where the players are teleported
*/
public Location getStartLocation() {
return startLocation;
}
/**
* Sets the location where the players are teleported.
*
* @param startLocation a location in the game world
* @throws IllegalArgumentException if the given location is not in the game world.
*/
public void setStartLocation(Location startLocation) {
if (startLocation.getWorld() != getGameWorld().getWorld()) {
throw new IllegalArgumentException("Location " + startLocation + " is not in world " + getGameWorld().getWorld());
}
this.startLocation = startLocation;
}
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;

View File

@ -20,9 +20,9 @@ import de.erethon.commons.chat.DefaultFontInfo;
import de.erethon.commons.chat.MessageUtil; import de.erethon.commons.chat.MessageUtil;
import de.erethon.dungeonsxl.DungeonsXL; import de.erethon.dungeonsxl.DungeonsXL;
import de.erethon.dungeonsxl.api.dungeon.Dungeon; 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.api.player.PlayerGroup.Color;
import de.erethon.dungeonsxl.config.DMessage; import de.erethon.dungeonsxl.config.DMessage;
import de.erethon.dungeonsxl.event.dgroup.DGroupCreateEvent;
import de.erethon.dungeonsxl.player.DGroup; import de.erethon.dungeonsxl.player.DGroup;
import de.erethon.dungeonsxl.util.GUIUtil; import de.erethon.dungeonsxl.util.GUIUtil;
import java.io.File; import java.io.File;
@ -368,7 +368,7 @@ public class Announcer {
} }
} else if (dGroup == null && pGroup == null) { } 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); Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
dGroups.set(buttons.indexOf(button), new DGroup(plugin, player, color)); 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.commons.chat.MessageUtil;
import de.erethon.dungeonsxl.DungeonsXL; 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.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.DGroup;
import de.erethon.dungeonsxl.player.DPermission; import de.erethon.dungeonsxl.player.DPermission;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -123,7 +122,7 @@ public class GroupCommand extends DCommand {
} }
DGroup dGroup = new DGroup(plugin, args[2], player); 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); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
@ -148,7 +147,7 @@ public class GroupCommand extends DCommand {
return; 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); Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
@ -224,7 +223,7 @@ public class GroupCommand extends DCommand {
Player toKick = Bukkit.getPlayer(args[2]); Player toKick = Bukkit.getPlayer(args[2]);
if (toKick != null) { 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); Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {

View File

@ -19,14 +19,11 @@ package de.erethon.dungeonsxl.command;
import de.erethon.commons.chat.MessageUtil; import de.erethon.commons.chat.MessageUtil;
import de.erethon.dungeonsxl.DungeonsXL; import de.erethon.dungeonsxl.DungeonsXL;
import de.erethon.dungeonsxl.api.dungeon.Game; 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.api.player.PlayerGroup;
import de.erethon.dungeonsxl.config.DMessage; 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.DEditPlayer;
import de.erethon.dungeonsxl.player.DGamePlayer;
import de.erethon.dungeonsxl.player.DGlobalPlayer; import de.erethon.dungeonsxl.player.DGlobalPlayer;
import de.erethon.dungeonsxl.player.DGroup;
import de.erethon.dungeonsxl.player.DInstancePlayer; import de.erethon.dungeonsxl.player.DInstancePlayer;
import de.erethon.dungeonsxl.player.DPermission; import de.erethon.dungeonsxl.player.DPermission;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -66,17 +63,9 @@ public class LeaveCommand extends DCommand {
return; return;
} }
if (dPlayer instanceof DGamePlayer) { GroupPlayerLeaveEvent groupPlayerLeaveEvent = new GroupPlayerLeaveEvent(dGroup, dPlayer);
DGamePlayerEscapeEvent dPlayerEscapeEvent = new DGamePlayerEscapeEvent((DGamePlayer) dPlayer); Bukkit.getPluginManager().callEvent(groupPlayerLeaveEvent);
Bukkit.getPluginManager().callEvent(dPlayerEscapeEvent); if (groupPlayerLeaveEvent.isCancelled()) {
if (dPlayerEscapeEvent.isCancelled()) {
return;
}
}
DPlayerLeaveDGroupEvent dPlayerLeaveDGroupEvent = new DPlayerLeaveDGroupEvent(dPlayer, (DGroup) dGroup);
Bukkit.getPluginManager().callEvent(dPlayerLeaveDGroupEvent);
if (dPlayerLeaveDGroupEvent.isCancelled()) {
return; return;
} }

View File

@ -19,11 +19,11 @@ package de.erethon.dungeonsxl.command;
import de.erethon.commons.chat.MessageUtil; import de.erethon.commons.chat.MessageUtil;
import de.erethon.dungeonsxl.DungeonsXL; import de.erethon.dungeonsxl.DungeonsXL;
import de.erethon.dungeonsxl.api.dungeon.Dungeon; 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.player.GlobalPlayer;
import de.erethon.dungeonsxl.api.world.GameWorld; import de.erethon.dungeonsxl.api.world.GameWorld;
import de.erethon.dungeonsxl.config.DMessage; import de.erethon.dungeonsxl.config.DMessage;
import de.erethon.dungeonsxl.dungeon.DGame; import de.erethon.dungeonsxl.dungeon.DGame;
import de.erethon.dungeonsxl.event.dgroup.DGroupCreateEvent;
import de.erethon.dungeonsxl.player.DGamePlayer; import de.erethon.dungeonsxl.player.DGamePlayer;
import de.erethon.dungeonsxl.player.DGroup; import de.erethon.dungeonsxl.player.DGroup;
import de.erethon.dungeonsxl.player.DInstancePlayer; import de.erethon.dungeonsxl.player.DInstancePlayer;
@ -69,7 +69,7 @@ public class PlayCommand extends DCommand {
return; return;
} else if (group == null) { } else if (group == null) {
group = new DGroup(plugin, player, dungeon); 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); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
plugin.getGroupCache().remove(group); 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.CompatibilityHandler;
import de.erethon.commons.compatibility.Internals; import de.erethon.commons.compatibility.Internals;
import de.erethon.dungeonsxl.DungeonsXL; import de.erethon.dungeonsxl.DungeonsXL;
import de.erethon.dungeonsxl.api.event.DataReloadEvent;
import de.erethon.dungeonsxl.api.player.InstancePlayer; import de.erethon.dungeonsxl.api.player.InstancePlayer;
import de.erethon.dungeonsxl.config.DMessage; import de.erethon.dungeonsxl.config.DMessage;
import de.erethon.dungeonsxl.event.DataReloadEvent;
import de.erethon.dungeonsxl.player.DPermission; import de.erethon.dungeonsxl.player.DPermission;
import java.util.Collection; import java.util.Collection;
import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ClickEvent;

View File

@ -20,11 +20,11 @@ import de.erethon.caliburn.mob.ExMob;
import de.erethon.caliburn.mob.VanillaMob; import de.erethon.caliburn.mob.VanillaMob;
import de.erethon.commons.compatibility.Version; import de.erethon.commons.compatibility.Version;
import de.erethon.dungeonsxl.DungeonsXL; 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.mob.DungeonMob;
import de.erethon.dungeonsxl.api.world.GameWorld; import de.erethon.dungeonsxl.api.world.GameWorld;
import de.erethon.dungeonsxl.dungeon.DGame; 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.MobTrigger;
import de.erethon.dungeonsxl.trigger.WaveTrigger; import de.erethon.dungeonsxl.trigger.WaveTrigger;
import de.erethon.dungeonsxl.world.DGameWorld; import de.erethon.dungeonsxl.world.DGameWorld;
@ -60,13 +60,10 @@ public class DMob implements DungeonMob {
entity.getEquipment().setItemInHandDropChance(0); entity.getEquipment().setItemInHandDropChance(0);
} }
} }
gameWorld.addMob(this);
DMobSpawnEvent event = new DMobSpawnEvent(this, entity); DungeonMobSpawnEvent event = new DungeonMobSpawnEvent(this);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
gameWorld.addMob(this);
}
} }
public DMob(LivingEntity entity, GameWorld gameWorld, String trigger) { public DMob(LivingEntity entity, GameWorld gameWorld, String trigger) {
@ -112,9 +109,8 @@ public class DMob implements DungeonMob {
return; return;
} }
DMobDeathEvent dMobDeathEvent = new DMobDeathEvent(this, event); DungeonMobDeathEvent dMobDeathEvent = new DungeonMobDeathEvent(this);
Bukkit.getServer().getPluginManager().callEvent(dMobDeathEvent); Bukkit.getServer().getPluginManager().callEvent(dMobDeathEvent);
if (dMobDeathEvent.isCancelled()) { if (dMobDeathEvent.isCancelled()) {
return; return;
} }

View File

@ -21,11 +21,15 @@ import de.erethon.caliburn.mob.VanillaMob;
import de.erethon.commons.chat.MessageUtil; import de.erethon.commons.chat.MessageUtil;
import de.erethon.commons.player.PlayerUtil; import de.erethon.commons.player.PlayerUtil;
import de.erethon.dungeonsxl.DungeonsXL; import de.erethon.dungeonsxl.DungeonsXL;
import de.erethon.dungeonsxl.api.Reward;
import de.erethon.dungeonsxl.api.dungeon.Game; import de.erethon.dungeonsxl.api.dungeon.Game;
import de.erethon.dungeonsxl.api.dungeon.GameGoal; import de.erethon.dungeonsxl.api.dungeon.GameGoal;
import de.erethon.dungeonsxl.api.dungeon.GameRule; import de.erethon.dungeonsxl.api.dungeon.GameRule;
import de.erethon.dungeonsxl.api.dungeon.GameRuleContainer; 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.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.mob.DungeonMob;
import de.erethon.dungeonsxl.api.player.GamePlayer; import de.erethon.dungeonsxl.api.player.GamePlayer;
import de.erethon.dungeonsxl.api.player.PlayerClass; 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.api.world.GameWorld;
import de.erethon.dungeonsxl.config.DMessage; import de.erethon.dungeonsxl.config.DMessage;
import de.erethon.dungeonsxl.dungeon.DGame; 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.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.trigger.DistanceTrigger;
import de.erethon.dungeonsxl.world.DGameWorld; import de.erethon.dungeonsxl.world.DGameWorld;
import de.erethon.dungeonsxl.world.DResourceWorld; import de.erethon.dungeonsxl.world.DResourceWorld;
import de.erethon.dungeonsxl.world.block.TeamFlag; import de.erethon.dungeonsxl.world.block.TeamFlag;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
@ -386,10 +389,12 @@ public class DGamePlayer extends DInstancePlayer implements GamePlayer {
} }
if (game != null && finished && game.hasRewards()) { if (game != null && finished && game.hasRewards()) {
DGamePlayerRewardEvent dGroupRewardEvent = new DGamePlayerRewardEvent(this); List<Reward> rewards = new ArrayList<>(dGroup.getRewards());
Bukkit.getPluginManager().callEvent(dGroupRewardEvent); rewards.addAll(rules.getState(GameRule.REWARDS));
if (!dGroupRewardEvent.isCancelled()) { GlobalPlayerRewardPayOutEvent globalPlayerPayOutRewardEvent = new GlobalPlayerRewardPayOutEvent(this, rewards);
giveLoot(getGroup().getDungeon(), rules.getState(GameRule.REWARDS), dGroup.getRewards()); Bukkit.getPluginManager().callEvent(globalPlayerPayOutRewardEvent);
if (!globalPlayerPayOutRewardEvent.isCancelled()) {
giveLoot(getGroup().getDungeon(), globalPlayerPayOutRewardEvent.getRewards());
} }
getData().logTimeLastFinished(getGroup().getDungeonName()); getData().logTimeLastFinished(getGroup().getDungeonName());
@ -456,7 +461,7 @@ public class DGamePlayer extends DInstancePlayer implements GamePlayer {
@Override @Override
public void kill() { public void kill() {
DPlayerKickEvent dPlayerKickEvent = new DPlayerKickEvent(this, DPlayerKickEvent.Cause.DEATH); GroupPlayerKickEvent dPlayerKickEvent = new GroupPlayerKickEvent(getGroup(), this, GroupPlayerKickEvent.Cause.DEATH);
Bukkit.getPluginManager().callEvent(dPlayerKickEvent); Bukkit.getPluginManager().callEvent(dPlayerKickEvent);
if (!dPlayerKickEvent.isCancelled()) { if (!dPlayerKickEvent.isCancelled()) {
@ -557,9 +562,9 @@ public class DGamePlayer extends DInstancePlayer implements GamePlayer {
hasToWait = true; hasToWait = true;
} }
DGamePlayerFinishEvent dPlayerFinishEvent = new DGamePlayerFinishEvent(this, hasToWait); GamePlayerFinishEvent gamePlayerFinishEvent = new GamePlayerFinishEvent(this, hasToWait);
Bukkit.getPluginManager().callEvent(dPlayerFinishEvent); Bukkit.getPluginManager().callEvent(gamePlayerFinishEvent);
if (dPlayerFinishEvent.isCancelled()) { if (gamePlayerFinishEvent.isCancelled()) {
finished = false; finished = false;
} }
} }
@ -589,9 +594,9 @@ public class DGamePlayer extends DInstancePlayer implements GamePlayer {
hasToWait = true; hasToWait = true;
} }
DGamePlayerFinishEvent dPlayerFinishEvent = new DGamePlayerFinishEvent(this, hasToWait); GamePlayerFinishEvent gamePlayerFinishEvent = new GamePlayerFinishEvent(this, hasToWait);
Bukkit.getPluginManager().callEvent(dPlayerFinishEvent); Bukkit.getPluginManager().callEvent(gamePlayerFinishEvent);
if (dPlayerFinishEvent.isCancelled()) { if (gamePlayerFinishEvent.isCancelled()) {
finished = false; finished = false;
} }
} }
@ -768,10 +773,10 @@ public class DGamePlayer extends DInstancePlayer implements GamePlayer {
} }
if (kick) { if (kick) {
DPlayerKickEvent dPlayerKickEvent = new DPlayerKickEvent(this, DPlayerKickEvent.Cause.OFFLINE); GroupPlayerKickEvent groupPlayerKickEvent = new GroupPlayerKickEvent(getGroup(), this, GroupPlayerKickEvent.Cause.OFFLINE);
Bukkit.getPluginManager().callEvent(dPlayerKickEvent); Bukkit.getPluginManager().callEvent(groupPlayerKickEvent);
if (!dPlayerKickEvent.isCancelled()) { if (!groupPlayerKickEvent.isCancelled()) {
leave(); 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.Dungeon;
import de.erethon.dungeonsxl.api.dungeon.GameRule; import de.erethon.dungeonsxl.api.dungeon.GameRule;
import de.erethon.dungeonsxl.api.dungeon.GameRuleContainer; 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.event.requirement.RequirementCheckEvent;
import de.erethon.dungeonsxl.api.player.GlobalPlayer; import de.erethon.dungeonsxl.api.player.GlobalPlayer;
import de.erethon.dungeonsxl.api.player.PlayerGroup; import de.erethon.dungeonsxl.api.player.PlayerGroup;
import de.erethon.dungeonsxl.api.world.GameWorld; import de.erethon.dungeonsxl.api.world.GameWorld;
import de.erethon.dungeonsxl.config.DMessage; import de.erethon.dungeonsxl.config.DMessage;
import de.erethon.dungeonsxl.dungeon.DGame; import de.erethon.dungeonsxl.dungeon.DGame;
import de.erethon.dungeonsxl.event.dgroup.DGroupCreateEvent;
import de.erethon.dungeonsxl.global.DPortal; import de.erethon.dungeonsxl.global.DPortal;
import de.erethon.dungeonsxl.util.LocationString; import de.erethon.dungeonsxl.util.LocationString;
import de.erethon.dungeonsxl.util.NBTUtil; 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(); 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)) { if (!canLoot(dungeon)) {
return; return;
} }
ruleRewards.forEach(r -> r.giveTo(player.getPlayer())); rewards.forEach(r -> r.giveTo(player.getPlayer()));
groupRewards.forEach(r -> r.giveTo(player.getPlayer()));
if (getGroup() != null && getGroup().getDungeon() != null) { if (getGroup() != null && getGroup().getDungeon() != null) {
getData().logTimeLastLoot(getGroup().getDungeon().getName()); getData().logTimeLastLoot(getGroup().getDungeon().getName());
} }
@ -534,7 +533,7 @@ public class DGlobalPlayer implements GlobalPlayer {
DGroup dGroup = new DGroup(plugin, "Tutorial", player, dungeon); 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); Bukkit.getPluginManager().callEvent(createEvent);
if (createEvent.isCancelled()) { if (createEvent.isCancelled()) {
dGroup = null; 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.Game;
import de.erethon.dungeonsxl.api.dungeon.GameRule; import de.erethon.dungeonsxl.api.dungeon.GameRule;
import de.erethon.dungeonsxl.api.dungeon.GameRuleContainer; 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.event.requirement.RequirementDemandEvent;
import de.erethon.dungeonsxl.api.player.GlobalPlayer; import de.erethon.dungeonsxl.api.player.GlobalPlayer;
import de.erethon.dungeonsxl.api.player.InstancePlayer; 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.DDungeon;
import de.erethon.dungeonsxl.dungeon.DGame; import de.erethon.dungeonsxl.dungeon.DGame;
import de.erethon.dungeonsxl.dungeon.DungeonConfig; 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.DGameWorld;
import de.erethon.dungeonsxl.world.DResourceWorld; import de.erethon.dungeonsxl.world.DResourceWorld;
import java.util.ArrayList; import java.util.ArrayList;
@ -100,8 +100,15 @@ public class DGroup implements PlayerGroup {
plugin.getGroupCache().add(name, this); plugin.getGroupCache().add(name, this);
this.name = name; this.name = name;
setLeader(player); GroupPlayerJoinEvent event = new GroupPlayerJoinEvent(this, dPlayers.get(player), true);
addMember(player); Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
setLeader(player);
addMember(player);
} else {
plugin.getGroupCache().remove(this);
return;
}
playing = false; playing = false;
floorCount = 0; floorCount = 0;
@ -124,9 +131,8 @@ public class DGroup implements PlayerGroup {
plugin.getGroupCache().add(name, this); plugin.getGroupCache().add(name, this);
this.name = name; 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); Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
this.captain = captain; this.captain = captain;
this.players.add(captain); this.players.add(captain);
@ -137,6 +143,10 @@ public class DGroup implements PlayerGroup {
addMember(player); addMember(player);
} }
} }
if (getMembers().size() == 0) {
plugin.getGroupCache().remove(this);
return;
}
setDungeon(dungeon); setDungeon(dungeon);
playing = false; playing = false;
@ -205,18 +215,17 @@ public class DGroup implements PlayerGroup {
@Override @Override
public void addMember(Player player, boolean message) { 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); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
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());
} }
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)); plugin.getGroupAdapters().forEach(a -> a.syncJoin(player));
} }
@ -235,9 +244,8 @@ public class DGroup implements PlayerGroup {
} }
if (isEmpty()) { 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); Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
delete(); delete();
return; return;
@ -421,9 +429,8 @@ public class DGroup implements PlayerGroup {
@Override @Override
public void addReward(Reward reward) { public void addReward(Reward reward) {
RewardAdditionEvent event = new RewardAdditionEvent(reward, this); GroupCollectRewardEvent event = new GroupCollectRewardEvent(this, null, reward);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;
} }
@ -586,9 +593,9 @@ public class DGroup implements PlayerGroup {
* The group finishs the dungeon. * The group finishs the dungeon.
*/ */
public void finish() { public void finish() {
DGroupFinishDungeonEvent dGroupFinishDungeonEvent = new DGroupFinishDungeonEvent((DDungeon) dungeon, this); GroupFinishDungeonEvent groupFinishDungeonEvent = new GroupFinishDungeonEvent(this, dungeon);
Bukkit.getPluginManager().callEvent(dGroupFinishDungeonEvent); Bukkit.getPluginManager().callEvent(groupFinishDungeonEvent);
if (dGroupFinishDungeonEvent.isCancelled()) { if (groupFinishDungeonEvent.isCancelled()) {
return; return;
} }
@ -621,7 +628,7 @@ public class DGroup implements PlayerGroup {
type = GameWorld.Type.END_FLOOR; 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); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
return; 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); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
return false; return false;
} }

View File

@ -18,9 +18,10 @@ package de.erethon.dungeonsxl.player;
import de.erethon.commons.chat.MessageUtil; import de.erethon.commons.chat.MessageUtil;
import de.erethon.dungeonsxl.DungeonsXL; 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.api.player.PlayerGroup;
import de.erethon.dungeonsxl.config.DMessage; import de.erethon.dungeonsxl.config.DMessage;
import de.erethon.dungeonsxl.event.dplayer.DPlayerKickEvent;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -60,15 +61,15 @@ public class TimeIsRunningTask extends BukkitRunnable {
for (Player player : group.getMembers().getOnlinePlayers()) { for (Player player : group.getMembers().getOnlinePlayers()) {
MessageUtil.sendActionBarMessage(player, DMessage.PLAYER_TIME_LEFT.getMessage(color, String.valueOf(timeLeft))); 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) { if (timeLeft > 0) {
continue; continue;
} }
DPlayerKickEvent dPlayerKickEvent = new DPlayerKickEvent(dPlayer, DPlayerKickEvent.Cause.TIME_EXPIRED); GroupPlayerKickEvent groupPlayerKickEvent = new GroupPlayerKickEvent(group, dPlayer, GroupPlayerKickEvent.Cause.TIME_EXPIRED);
Bukkit.getServer().getPluginManager().callEvent(dPlayerKickEvent); Bukkit.getServer().getPluginManager().callEvent(groupPlayerKickEvent);
if (!dPlayerKickEvent.isCancelled()) { if (!groupPlayerKickEvent.isCancelled()) {
MessageUtil.broadcastMessage(DMessage.PLAYER_TIME_KICK.getMessage(player.getName())); MessageUtil.broadcastMessage(DMessage.PLAYER_TIME_KICK.getMessage(player.getName()));
dPlayer.leave(); dPlayer.leave();
} }

View File

@ -17,11 +17,11 @@
package de.erethon.dungeonsxl.sign.button; package de.erethon.dungeonsxl.sign.button;
import de.erethon.dungeonsxl.api.DungeonsAPI; 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.sign.Button;
import de.erethon.dungeonsxl.api.world.InstanceWorld; import de.erethon.dungeonsxl.api.world.InstanceWorld;
import de.erethon.dungeonsxl.config.DMessage; 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.player.DPermission;
import de.erethon.dungeonsxl.trigger.InteractTrigger; import de.erethon.dungeonsxl.trigger.InteractTrigger;
import de.erethon.dungeonsxl.world.DGameWorld; import de.erethon.dungeonsxl.world.DGameWorld;
@ -90,16 +90,15 @@ public class LeaveSign extends Button {
@Override @Override
public boolean push(Player player) { public boolean push(Player player) {
DGamePlayer dPlayer = (DGamePlayer) api.getPlayerCache().getGamePlayer(player); GamePlayer gamePlayer = api.getPlayerCache().getGamePlayer(player);
if (dPlayer != null) { if (gamePlayer != null) {
DGamePlayerEscapeEvent event = new DGamePlayerEscapeEvent(dPlayer); GroupPlayerLeaveEvent event = new GroupPlayerLeaveEvent(gamePlayer.getGroup(), gamePlayer);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
return false; return false;
} }
dPlayer.leave(); gamePlayer.leave();
} }
return true; return true;

View File

@ -19,9 +19,9 @@ package de.erethon.dungeonsxl.world;
import de.erethon.commons.compatibility.Version; import de.erethon.commons.compatibility.Version;
import de.erethon.commons.misc.FileUtil; import de.erethon.commons.misc.FileUtil;
import de.erethon.dungeonsxl.DungeonsXL; 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.api.world.EditWorld;
import de.erethon.dungeonsxl.event.editworld.EditWorldSaveEvent;
import de.erethon.dungeonsxl.event.editworld.EditWorldUnloadEvent;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import org.bukkit.Bukkit; 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.Game;
import de.erethon.dungeonsxl.api.dungeon.GameRule; import de.erethon.dungeonsxl.api.dungeon.GameRule;
import de.erethon.dungeonsxl.api.dungeon.GameRuleContainer; 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.mob.DungeonMob;
import de.erethon.dungeonsxl.api.player.PlayerGroup; import de.erethon.dungeonsxl.api.player.PlayerGroup;
import de.erethon.dungeonsxl.api.sign.DungeonSign; import de.erethon.dungeonsxl.api.sign.DungeonSign;
import de.erethon.dungeonsxl.api.world.GameWorld; 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.button.ReadySign;
import de.erethon.dungeonsxl.sign.passive.StartSign; import de.erethon.dungeonsxl.sign.passive.StartSign;
import de.erethon.dungeonsxl.sign.windup.MobSign; 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 * Set up the instance for the game
*/ */
public void startGame() { public void startGame() {
GameWorldStartGameEvent event = new GameWorldStartGameEvent(this, (DGame) getGame()); GameWorldStartGameEvent event = new GameWorldStartGameEvent(this, getGame());
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;
@ -451,9 +450,8 @@ public class DGameWorld extends DInstanceWorld implements GameWorld {
*/ */
@Override @Override
public void delete() { public void delete() {
GameWorldUnloadEvent event = new GameWorldUnloadEvent(this); InstanceWorldUnloadEvent event = new InstanceWorldUnloadEvent(this);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;
} }

View File

@ -22,11 +22,11 @@ import de.erethon.commons.misc.FileUtil;
import de.erethon.dungeonsxl.DungeonsXL; import de.erethon.dungeonsxl.DungeonsXL;
import de.erethon.dungeonsxl.api.dungeon.Dungeon; import de.erethon.dungeonsxl.api.dungeon.Dungeon;
import de.erethon.dungeonsxl.api.dungeon.GameRuleContainer; 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.player.EditPlayer;
import de.erethon.dungeonsxl.api.world.EditWorld; import de.erethon.dungeonsxl.api.world.EditWorld;
import de.erethon.dungeonsxl.api.world.GameWorld; import de.erethon.dungeonsxl.api.world.GameWorld;
import de.erethon.dungeonsxl.api.world.ResourceWorld; import de.erethon.dungeonsxl.api.world.ResourceWorld;
import de.erethon.dungeonsxl.event.editworld.EditWorldGenerateEvent;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.lang.ref.WeakReference; 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.DungeonsXL;
import de.erethon.dungeonsxl.api.Reward; import de.erethon.dungeonsxl.api.Reward;
import de.erethon.dungeonsxl.api.dungeon.Game; 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.api.player.PlayerGroup;
import de.erethon.dungeonsxl.config.DMessage; import de.erethon.dungeonsxl.config.DMessage;
import de.erethon.dungeonsxl.player.DGamePlayer; import de.erethon.dungeonsxl.player.DGamePlayer;
@ -115,12 +117,12 @@ public class RewardChest extends GameBlock {
} }
if (block.getLocation().distance(block.getLocation()) < 1) { if (block.getLocation().distance(block.getLocation()) < 1) {
addTreasure(api.getPlayerGroup(opener)); addTreasure(api.getPlayerGroup(opener), api.getPlayerCache().getGamePlayer(opener));
used = true; used = true;
} }
} }
public void addTreasure(PlayerGroup group) { public void addTreasure(PlayerGroup group, GamePlayer collector) {
if (group == null) { if (group == null) {
return; return;
} }
@ -133,15 +135,27 @@ public class RewardChest extends GameBlock {
for (Reward reward : group.getRewards()) { for (Reward reward : group.getRewards()) {
if (reward instanceof MoneyReward) { if (reward instanceof MoneyReward) {
hasMoneyReward = true; 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) { } else if (reward instanceof LevelReward) {
hasLevelReward = true; 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) { } else if (reward instanceof ItemReward) {
hasItemReward = true; 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) { if (!hasMoneyReward) {
MoneyReward reward = new MoneyReward(econ); MoneyReward reward = new MoneyReward(econ);
reward.addMoney(moneyReward); 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) { if (!hasLevelReward) {
LevelReward reward = new LevelReward(); LevelReward reward = new LevelReward();
reward.addLevels(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) { if (!hasItemReward) {
ItemReward reward = new ItemReward(api); ItemReward reward = new ItemReward(api);
reward.addItems(itemReward); reward.addItems(itemReward);
group.addReward(reward); GroupCollectRewardEvent event = new GroupCollectRewardEvent(group, collector, reward);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
group.getRewards().add(reward);
}
} }
} }