Skip to content

Commit

Permalink
Add PreDisbandClanEvent (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
SrBedrock authored Aug 26, 2024
1 parent 6cb7e0d commit a28cbe1
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main/java/net/sacredlabyrinth/phaed/simpleclans/Clan.java
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ public String getTag() {
public void setTag(String tag) {
this.tag = tag;
}

/**
* Returns the first color in the clan's tag
*
Expand Down Expand Up @@ -1389,6 +1390,11 @@ private boolean sendBbTime(Player player, String msg) {
* @param force should it be force disbanded?
*/
public void disband(@Nullable CommandSender sender, boolean announce, boolean force) {
if (!new PreDisbandClanEvent(sender, this).callEvent()) {
ChatBlock.sendMessage(sender, RED + lang("error.event.cancelled", sender));
return;
}

Collection<ClanPlayer> clanPlayers = SimpleClans.getInstance().getClanManager().getAllClanPlayers();
List<Clan> clans = SimpleClans.getInstance().getClanManager().getClans();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package net.sacredlabyrinth.phaed.simpleclans.events;

import net.sacredlabyrinth.phaed.simpleclans.Clan;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;

/**
* @author ThiagoROX
*/
public class PreDisbandClanEvent extends Event {

private static final HandlerList handlers = new HandlerList();
private final CommandSender sender;
private final Clan clan;
private boolean cancelled;

public PreDisbandClanEvent(CommandSender sender, Clan clan) {
if (sender == null) {
sender = Bukkit.getConsoleSender();
}
this.sender = sender;
this.clan = clan;
}

public Clan getClan() {
return this.clan;
}

public CommandSender getSender() {
return sender;
}

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

public static HandlerList getHandlerList() {
return handlers;
}

public boolean isCancelled() {
return cancelled;
}

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

0 comments on commit a28cbe1

Please sign in to comment.