mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-27 11:14:44 +02:00
Added party alliances
Adds the following commands: `/party alliance` `/party alliance invite <target>` `/party alliance accept` Allies will share party chat and will not be able to harm eachother. Item and XP sharing is limitied to a single party. Allowing two parties to team up without sharing resources and XP. Closes #1009
This commit is contained in:
@ -0,0 +1,90 @@
|
||||
package com.gmail.nossr50.events.party;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
public class McMMOPartyAllianceChangeEvent extends PlayerEvent implements Cancellable {
|
||||
private String oldAlly;
|
||||
private String newAlly;
|
||||
private EventReason reason;
|
||||
private boolean cancelled;
|
||||
|
||||
public McMMOPartyAllianceChangeEvent(Player player, String oldAlly, String newAlly, EventReason reason) {
|
||||
super(player);
|
||||
|
||||
if (newAlly != null) {
|
||||
newAlly = newAlly.replace(":", ".");
|
||||
}
|
||||
|
||||
this.oldAlly = oldAlly;
|
||||
this.newAlly = newAlly;
|
||||
this.reason = reason;
|
||||
this.cancelled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The party being left, or null if the player was not in a party
|
||||
*/
|
||||
public String getOldAlly() {
|
||||
return oldAlly;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The party being joined, or null if the player is not joining a new party
|
||||
*/
|
||||
public String getNewAlly() {
|
||||
return newAlly;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The reason for the event being fired
|
||||
*/
|
||||
public EventReason getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
/**
|
||||
* A list of reasons why the event may have been fired
|
||||
*/
|
||||
public enum EventReason {
|
||||
/**
|
||||
* Formed an alliance for the first time.
|
||||
*/
|
||||
FORMED_ALLIANCE,
|
||||
|
||||
/**
|
||||
* Left a party and did not join a new one.
|
||||
*/
|
||||
DISBAND_ALLIANCE,
|
||||
|
||||
/**
|
||||
* Any reason that doesn't fit elsewhere.
|
||||
*/
|
||||
CUSTOM;
|
||||
}
|
||||
|
||||
/** Following are required for Cancellable **/
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
/** Rest of file is required boilerplate for custom events **/
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user