Skip to content

Commit

Permalink
#102: Restructured events
Browse files Browse the repository at this point in the history
  • Loading branch information
Sataniel98 committed Jul 28, 2016
1 parent 0da5d76 commit a3590ff
Show file tree
Hide file tree
Showing 11 changed files with 282 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerEscapeEvent;
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerLeaveDGroupEvent;
import io.github.dre2n.dungeonsxl.event.dplayer.instance.edit.DEditPlayerEscapeEvent;
import io.github.dre2n.dungeonsxl.player.DEditPlayer;
import io.github.dre2n.dungeonsxl.player.DGlobalPlayer;
import io.github.dre2n.dungeonsxl.player.DGroup;
Expand Down Expand Up @@ -67,7 +67,7 @@ public void onExecute(String[] args, CommandSender sender) {
return;
}

DPlayerEscapeEvent dPlayerEscapeEvent = new DPlayerEscapeEvent(dPlayer);
DEditPlayerEscapeEvent dPlayerEscapeEvent = new DEditPlayerEscapeEvent((DEditPlayer) dPlayer);
plugin.getServer().getPluginManager().callEvent(dPlayerEscapeEvent);
DPlayerLeaveDGroupEvent dPlayerLeaveDGroupEvent = new DPlayerLeaveDGroupEvent(dPlayer, dGroup);
plugin.getServer().getPluginManager().callEvent(dPlayerLeaveDGroupEvent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public enum Cause {
COMMAND,
DUNGEON_FINISHED,
GROUP_IS_EMPTY,
LOST,
CUSTOM

}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* Copyright (C) 2012-2016 Frank Baumann
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package io.github.dre2n.dungeonsxl.event.dgroup;

import io.github.dre2n.dungeonsxl.player.DGroup;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;

/**
* @author Daniel Saukel
*/
public class DGroupScoreEvent extends DGroupEvent implements Cancellable {

private static final HandlerList handlers = new HandlerList();
private boolean cancelled;

private Player scorer;
private DGroup loserGroup;

public DGroupScoreEvent(DGroup dGroup, Player scorer, DGroup loserGroup) {
super(dGroup);
this.scorer = scorer;
this.loserGroup = loserGroup;
}

/**
* @return the creator
*/
public Player getScorer() {
return scorer;
}

/**
* @param scorer
* the scoerer to set
*/
public void setCreator(Player scorer) {
this.scorer = scorer;
}

/**
* @return the group that lost a score to the scorers
*/
public DGroup getLoserGroup() {
return loserGroup;
}

/**
* @param loserGroup
* the group that lost a score to the scorers to set
*/
public void setLoserGroup(DGroup loserGroup) {
this.loserGroup = loserGroup;
}

@Override
public HandlerList getHandlers() {
return handlers;
}

public static HandlerList getHandlerList() {
return handlers;
}

@Override
public boolean isCancelled() {
return cancelled;
}

@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (C) 2012-2016 Frank Baumann
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package io.github.dre2n.dungeonsxl.event.dplayer.instance;

import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerEvent;
import io.github.dre2n.dungeonsxl.player.DInstancePlayer;

/**
* @author Daniel Saukel
*/
public abstract class DInstancePlayerEvent extends DPlayerEvent {

public DInstancePlayerEvent(DInstancePlayer dPlayer) {
super(dPlayer);
}

@Override
public DInstancePlayer getDPlayer() {
return (DInstancePlayer) dPlayer;
}

public void setDPlayer(DInstancePlayer dPlayer) {
this.dPlayer = dPlayer;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@
* 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 io.github.dre2n.dungeonsxl.event.dplayer;
package io.github.dre2n.dungeonsxl.event.dplayer.instance;

import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerEvent;
import io.github.dre2n.dungeonsxl.player.DInstancePlayer;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;

/**
* @author Daniel Saukel
*/
public class DPlayerUpdateEvent extends DPlayerEvent implements Cancellable {
public class DInstancePlayerUpdateEvent extends DPlayerEvent implements Cancellable {

private static final HandlerList handlers = new HandlerList();
private boolean cancelled;
Expand All @@ -35,7 +36,7 @@ public class DPlayerUpdateEvent extends DPlayerEvent implements Cancellable {
private boolean kick;
private boolean triggerAllInDistance;

public DPlayerUpdateEvent(DInstancePlayer dPlayer, boolean locationValid, boolean teleportWolf, boolean respawnInventory, boolean offline, boolean kick, boolean triggerAllInDistance) {
public DInstancePlayerUpdateEvent(DInstancePlayer dPlayer, boolean locationValid, boolean teleportWolf, boolean respawnInventory, boolean offline, boolean kick, boolean triggerAllInDistance) {
super(dPlayer);
this.locationValid = locationValid;
this.teleportWolf = teleportWolf;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright (C) 2012-2016 Frank Baumann
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package io.github.dre2n.dungeonsxl.event.dplayer.instance.edit;

import io.github.dre2n.dungeonsxl.player.DEditPlayer;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;

/**
* @author Daniel Saukel
*/
public class DEditPlayerEscapeEvent extends DEditPlayerEvent implements Cancellable {

private static final HandlerList handlers = new HandlerList();
private boolean cancelled;

public DEditPlayerEscapeEvent(DEditPlayer dPlayer) {
super(dPlayer);
}

@Override
public HandlerList getHandlers() {
return handlers;
}

public static HandlerList getHandlerList() {
return handlers;
}

@Override
public boolean isCancelled() {
return cancelled;
}

@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (C) 2012-2016 Frank Baumann
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package io.github.dre2n.dungeonsxl.event.dplayer.instance.edit;

import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerEvent;
import io.github.dre2n.dungeonsxl.player.DEditPlayer;

/**
* @author Daniel Saukel
*/
public abstract class DEditPlayerEvent extends DPlayerEvent {

public DEditPlayerEvent(DEditPlayer dPlayer) {
super(dPlayer);
}

@Override
public DEditPlayer getDPlayer() {
return (DEditPlayer) dPlayer;
}

public void setDPlayer(DEditPlayer dPlayer) {
this.dPlayer = dPlayer;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
* 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 io.github.dre2n.dungeonsxl.event.dplayer;
package io.github.dre2n.dungeonsxl.event.dplayer.instance.game;

import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerEvent;
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
Expand All @@ -24,15 +25,15 @@
/**
* @author Daniel Saukel
*/
public class DPlayerDeathEvent extends DPlayerEvent implements Cancellable {
public class DGamePlayerDeathEvent extends DPlayerEvent implements Cancellable {

private static final HandlerList handlers = new HandlerList();
private boolean cancelled;

private PlayerDeathEvent bukkitEvent;
private int lostLives;

public DPlayerDeathEvent(DGamePlayer dPlayer, PlayerDeathEvent bukkitEvent, int lostLives) {
public DGamePlayerDeathEvent(DGamePlayer dPlayer, PlayerDeathEvent bukkitEvent, int lostLives) {
super(dPlayer);
this.bukkitEvent = bukkitEvent;
this.lostLives = lostLives;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@
* 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 io.github.dre2n.dungeonsxl.event.dplayer;
package io.github.dre2n.dungeonsxl.event.dplayer.instance.game;

import io.github.dre2n.dungeonsxl.player.DGlobalPlayer;
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;

/**
* @author Daniel Saukel
*/
public class DPlayerEscapeEvent extends DPlayerEvent implements Cancellable {
public class DGamePlayerEscapeEvent extends DGamePlayerEvent implements Cancellable {

private static final HandlerList handlers = new HandlerList();
private boolean cancelled;

public DPlayerEscapeEvent(DGlobalPlayer dPlayer) {
public DGamePlayerEscapeEvent(DGamePlayer dPlayer) {
super(dPlayer);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (C) 2012-2016 Frank Baumann
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package io.github.dre2n.dungeonsxl.event.dplayer.instance.game;

import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerEvent;
import io.github.dre2n.dungeonsxl.player.DGamePlayer;

/**
* @author Daniel Saukel
*/
public abstract class DGamePlayerEvent extends DPlayerEvent {

public DGamePlayerEvent(DGamePlayer dPlayer) {
super(dPlayer);
}

@Override
public DGamePlayer getDPlayer() {
return (DGamePlayer) dPlayer;
}

public void setDPlayer(DGamePlayer dPlayer) {
this.dPlayer = dPlayer;
}

}
Loading

0 comments on commit a3590ff

Please sign in to comment.