mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-24 11:37:05 +01:00
Basic implementation of old events
This commit is contained in:
parent
007f65c103
commit
29d8f75568
@ -1,18 +1,16 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2020 Frank Baumann
|
||||
* Copyright (C) 2014-2020 Daniel Saukel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* This library is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNULesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <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.api.event;
|
||||
|
||||
|
@ -17,7 +17,6 @@ package de.erethon.dungeonsxl.api.event.group;
|
||||
import de.erethon.dungeonsxl.api.Reward;
|
||||
import de.erethon.dungeonsxl.api.player.GamePlayer;
|
||||
import de.erethon.dungeonsxl.api.player.PlayerGroup;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
|
@ -1,18 +1,16 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2020 Frank Baumann
|
||||
* Copyright (C) 2014-2020 Daniel Saukel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* This library is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNULesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <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.api.event.group;
|
||||
|
||||
|
@ -1,18 +1,16 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2020 Frank Baumann
|
||||
* Copyright (C) 2014-2020 Daniel Saukel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* This library is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNULesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <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.api.event.player;
|
||||
|
||||
|
@ -1,28 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2020 Frank Baumann
|
||||
* Copyright (C) 2014-2020 Daniel Saukel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* This library is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNULesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <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.api.event.world;
|
||||
|
||||
import de.erethon.dungeonsxl.api.dungeon.Game;
|
||||
import de.erethon.dungeonsxl.api.world.GameWorld;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Fired when the game starts, that means when all players have triggered the ready sign.
|
||||
*
|
||||
* @author Daniel Saukel
|
||||
*/
|
||||
public class GameWorldStartGameEvent extends GameWorldEvent implements Cancellable {
|
||||
@ -31,9 +30,8 @@ public class GameWorldStartGameEvent extends GameWorldEvent implements Cancellab
|
||||
private boolean cancelled;
|
||||
|
||||
private Game game;
|
||||
private Location startLocation;
|
||||
|
||||
public GameWorldStartGameEvent(GameWorld gameWorld, Game game, Location location) {
|
||||
public GameWorldStartGameEvent(GameWorld gameWorld, Game game) {
|
||||
super(gameWorld, gameWorld.getDungeon());
|
||||
this.game = game;
|
||||
}
|
||||
@ -47,28 +45,6 @@ public class GameWorldStartGameEvent extends GameWorldEvent implements Cancellab
|
||||
return game;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the location where the players are teleported.
|
||||
*
|
||||
* @return the location where the players are teleported
|
||||
*/
|
||||
public Location getStartLocation() {
|
||||
return startLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the location where the players are teleported.
|
||||
*
|
||||
* @param startLocation a location in the game world
|
||||
* @throws IllegalArgumentException if the given location is not in the game world.
|
||||
*/
|
||||
public void setStartLocation(Location startLocation) {
|
||||
if (startLocation.getWorld() != getGameWorld().getWorld()) {
|
||||
throw new IllegalArgumentException("Location " + startLocation + " is not in world " + getGameWorld().getWorld());
|
||||
}
|
||||
this.startLocation = startLocation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
|
@ -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));
|
||||
|
@ -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()) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user