More econ event moves
This commit is contained in:
parent
f22ea3300f
commit
c6739c4aa9
@ -7,8 +7,9 @@ import org.bukkit.ChatColor;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.massivecraft.factions.event.FactionsEventLeave;
|
|
||||||
import com.massivecraft.factions.event.FactionsEventLandClaim;
|
import com.massivecraft.factions.event.FactionsEventLandClaim;
|
||||||
|
import com.massivecraft.factions.event.FactionsEventMembershipChange;
|
||||||
|
import com.massivecraft.factions.event.FactionsEventMembershipChange.MembershipChangeReason;
|
||||||
import com.massivecraft.factions.iface.EconomyParticipator;
|
import com.massivecraft.factions.iface.EconomyParticipator;
|
||||||
import com.massivecraft.factions.iface.RelationParticipator;
|
import com.massivecraft.factions.iface.RelationParticipator;
|
||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.integration.Econ;
|
||||||
@ -674,17 +675,10 @@ public class FPlayer extends SenderEntity<FPlayer> implements EconomyParticipato
|
|||||||
public void leave(boolean makePay)
|
public void leave(boolean makePay)
|
||||||
{
|
{
|
||||||
Faction myFaction = this.getFaction();
|
Faction myFaction = this.getFaction();
|
||||||
makePay = makePay && Econ.isEnabled() && ! this.isUsingAdminMode();
|
|
||||||
|
|
||||||
if (myFaction == null)
|
boolean permanent = myFaction.getFlag(FFlag.PERMANENT);
|
||||||
{
|
|
||||||
resetFactionData();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean perm = myFaction.getFlag(FFlag.PERMANENT);
|
if (!permanent && this.getRole() == Rel.LEADER && myFaction.getFPlayers().size() > 1)
|
||||||
|
|
||||||
if (!perm && this.getRole() == Rel.LEADER && myFaction.getFPlayers().size() > 1)
|
|
||||||
{
|
{
|
||||||
msg("<b>You must give the admin role to someone else first.");
|
msg("<b>You must give the admin role to someone else first.");
|
||||||
return;
|
return;
|
||||||
@ -696,15 +690,10 @@ public class FPlayer extends SenderEntity<FPlayer> implements EconomyParticipato
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if economy is enabled and they're not on the bypass list, make sure they can pay
|
// Event
|
||||||
if (makePay && ! Econ.hasAtLeast(this, ConfServer.econCostLeave, "to leave your faction.")) return;
|
FactionsEventMembershipChange membershipChangeEvent = new FactionsEventMembershipChange(sender, this, myFaction, MembershipChangeReason.LEAVE);
|
||||||
|
membershipChangeEvent.run();
|
||||||
FactionsEventLeave leaveEvent = new FactionsEventLeave(sender, this, myFaction, FactionsEventLeave.PlayerLeaveReason.LEAVE);
|
if (membershipChangeEvent.isCancelled()) return;
|
||||||
leaveEvent.run();
|
|
||||||
if (leaveEvent.isCancelled()) return;
|
|
||||||
|
|
||||||
// then make 'em pay (if applicable)
|
|
||||||
if (makePay && ! Econ.modifyMoney(this, -ConfServer.econCostLeave, "leave your faction")) return;
|
|
||||||
|
|
||||||
// Am I the last one in the faction?
|
// Am I the last one in the faction?
|
||||||
if (myFaction.getFPlayers().size() == 1)
|
if (myFaction.getFPlayers().size() == 1)
|
||||||
@ -727,7 +716,7 @@ public class FPlayer extends SenderEntity<FPlayer> implements EconomyParticipato
|
|||||||
|
|
||||||
this.resetFactionData();
|
this.resetFactionData();
|
||||||
|
|
||||||
if (myFaction.isNormal() && !perm && myFaction.getFPlayers().isEmpty())
|
if (myFaction.isNormal() && !permanent && myFaction.getFPlayers().isEmpty())
|
||||||
{
|
{
|
||||||
// Remove this faction
|
// Remove this faction
|
||||||
for (FPlayer fplayer : FPlayerColl.get().getAllOnline())
|
for (FPlayer fplayer : FPlayerColl.get().getAllOnline())
|
||||||
|
@ -10,8 +10,9 @@ import com.massivecraft.factions.FactionColl;
|
|||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
import com.massivecraft.factions.Perm;
|
import com.massivecraft.factions.Perm;
|
||||||
import com.massivecraft.factions.Rel;
|
import com.massivecraft.factions.Rel;
|
||||||
import com.massivecraft.factions.event.FactionsEventJoin;
|
|
||||||
import com.massivecraft.factions.event.FactionsEventCreate;
|
import com.massivecraft.factions.event.FactionsEventCreate;
|
||||||
|
import com.massivecraft.factions.event.FactionsEventMembershipChange;
|
||||||
|
import com.massivecraft.factions.event.FactionsEventMembershipChange.MembershipChangeReason;
|
||||||
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
||||||
|
|
||||||
public class CmdFactionsCreate extends FCommand
|
public class CmdFactionsCreate extends FCommand
|
||||||
@ -66,7 +67,7 @@ public class CmdFactionsCreate extends FCommand
|
|||||||
fme.setRole(Rel.LEADER);
|
fme.setRole(Rel.LEADER);
|
||||||
fme.setFaction(faction);
|
fme.setFaction(faction);
|
||||||
|
|
||||||
FactionsEventJoin joinEvent = new FactionsEventJoin(sender, fme, faction, FactionsEventJoin.PlayerJoinReason.CREATE);
|
FactionsEventMembershipChange joinEvent = new FactionsEventMembershipChange(sender, fme, faction, MembershipChangeReason.CREATE);
|
||||||
joinEvent.run();
|
joinEvent.run();
|
||||||
// NOTE: join event cannot be cancelled or you'll have an empty faction
|
// NOTE: join event cannot be cancelled or you'll have an empty faction
|
||||||
|
|
||||||
|
@ -2,13 +2,15 @@ package com.massivecraft.factions.cmd;
|
|||||||
|
|
||||||
import com.massivecraft.factions.ConfServer;
|
import com.massivecraft.factions.ConfServer;
|
||||||
import com.massivecraft.factions.cmd.arg.ARFaction;
|
import com.massivecraft.factions.cmd.arg.ARFaction;
|
||||||
import com.massivecraft.factions.event.FactionsEventLeave;
|
|
||||||
import com.massivecraft.factions.event.FactionsEventDisband;
|
import com.massivecraft.factions.event.FactionsEventDisband;
|
||||||
|
import com.massivecraft.factions.event.FactionsEventMembershipChange;
|
||||||
|
import com.massivecraft.factions.event.FactionsEventMembershipChange.MembershipChangeReason;
|
||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.integration.Econ;
|
||||||
import com.massivecraft.factions.FFlag;
|
import com.massivecraft.factions.FFlag;
|
||||||
import com.massivecraft.factions.FPerm;
|
import com.massivecraft.factions.FPerm;
|
||||||
import com.massivecraft.factions.FPlayerColl;
|
import com.massivecraft.factions.FPlayerColl;
|
||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
|
import com.massivecraft.factions.FactionColl;
|
||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
import com.massivecraft.factions.Perm;
|
import com.massivecraft.factions.Perm;
|
||||||
@ -53,8 +55,8 @@ public class CmdFactionsDisband extends FCommand
|
|||||||
// Send FPlayerLeaveEvent for each player in the faction
|
// Send FPlayerLeaveEvent for each player in the faction
|
||||||
for (FPlayer fplayer : faction.getFPlayers())
|
for (FPlayer fplayer : faction.getFPlayers())
|
||||||
{
|
{
|
||||||
FactionsEventLeave leaveEvent = new FactionsEventLeave(sender, fplayer, faction, FactionsEventLeave.PlayerLeaveReason.DISBAND);
|
FactionsEventMembershipChange membershipChangeEvent = new FactionsEventMembershipChange(sender, fplayer, FactionColl.get().getNone(), MembershipChangeReason.DISBAND);
|
||||||
leaveEvent.run();
|
membershipChangeEvent.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inform all players
|
// Inform all players
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.ConfServer;
|
import com.massivecraft.factions.ConfServer;
|
||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
import com.massivecraft.factions.FPlayerColl;
|
|
||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
import com.massivecraft.factions.Perm;
|
import com.massivecraft.factions.Perm;
|
||||||
import com.massivecraft.factions.cmd.arg.ARFPlayer;
|
import com.massivecraft.factions.cmd.arg.ARFPlayer;
|
||||||
import com.massivecraft.factions.cmd.arg.ARFaction;
|
import com.massivecraft.factions.cmd.arg.ARFaction;
|
||||||
import com.massivecraft.factions.event.FactionsEventJoin;
|
import com.massivecraft.factions.event.FactionsEventMembershipChange;
|
||||||
|
import com.massivecraft.factions.event.FactionsEventMembershipChange.MembershipChangeReason;
|
||||||
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
||||||
|
|
||||||
public class CmdFactionsJoin extends FCommand
|
public class CmdFactionsJoin extends FCommand
|
||||||
@ -28,6 +26,7 @@ public class CmdFactionsJoin extends FCommand
|
|||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform()
|
||||||
{
|
{
|
||||||
|
// Args
|
||||||
Faction faction = this.arg(0, ARFaction.get());
|
Faction faction = this.arg(0, ARFaction.get());
|
||||||
if (faction == null) return;
|
if (faction == null) return;
|
||||||
|
|
||||||
@ -36,6 +35,7 @@ public class CmdFactionsJoin extends FCommand
|
|||||||
|
|
||||||
boolean samePlayer = fplayer == fme;
|
boolean samePlayer = fplayer == fme;
|
||||||
|
|
||||||
|
// Validate
|
||||||
if (!samePlayer && ! Perm.JOIN_OTHERS.has(sender, false))
|
if (!samePlayer && ! Perm.JOIN_OTHERS.has(sender, false))
|
||||||
{
|
{
|
||||||
msg("<b>You do not have permission to move other players into a faction.");
|
msg("<b>You do not have permission to move other players into a faction.");
|
||||||
@ -70,30 +70,33 @@ public class CmdFactionsJoin extends FCommand
|
|||||||
{
|
{
|
||||||
msg("<i>This faction requires invitation.");
|
msg("<i>This faction requires invitation.");
|
||||||
if (samePlayer)
|
if (samePlayer)
|
||||||
|
{
|
||||||
faction.msg("%s<i> tried to join your faction.", fplayer.describeTo(faction, true));
|
faction.msg("%s<i> tried to join your faction.", fplayer.describeTo(faction, true));
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// trigger the join event (cancellable)
|
// Event
|
||||||
FactionsEventJoin joinEvent = new FactionsEventJoin(FPlayerColl.get().get(me),faction,FactionsEventJoin.PlayerJoinReason.JOIN);
|
FactionsEventMembershipChange membershipChangeEvent = new FactionsEventMembershipChange(sender, fme, faction, MembershipChangeReason.JOIN);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(joinEvent);
|
membershipChangeEvent.run();
|
||||||
if (joinEvent.isCancelled()) return;
|
if (membershipChangeEvent.isCancelled()) return;
|
||||||
|
|
||||||
// then make 'em pay (if applicable)
|
|
||||||
if (samePlayer && ! payForCommand(ConfServer.econCostJoin)) return;
|
|
||||||
|
|
||||||
|
// Inform
|
||||||
if (!samePlayer)
|
if (!samePlayer)
|
||||||
|
{
|
||||||
fplayer.msg("<i>%s moved you into the faction %s.", fme.describeTo(fplayer, true), faction.getTag(fplayer));
|
fplayer.msg("<i>%s moved you into the faction %s.", fme.describeTo(fplayer, true), faction.getTag(fplayer));
|
||||||
|
}
|
||||||
faction.msg("<i>%s joined your faction.", fplayer.describeTo(faction, true));
|
faction.msg("<i>%s joined your faction.", fplayer.describeTo(faction, true));
|
||||||
fme.msg("<i>%s successfully joined %s.", fplayer.describeTo(fme, true), faction.getTag(fme));
|
fme.msg("<i>%s successfully joined %s.", fplayer.describeTo(fme, true), faction.getTag(fme));
|
||||||
|
|
||||||
|
// Apply
|
||||||
fplayer.resetFactionData();
|
fplayer.resetFactionData();
|
||||||
fplayer.setFaction(faction);
|
fplayer.setFaction(faction);
|
||||||
fme.setRole(ConfServer.factionRankDefault); // They have just joined a faction, start them out on the lowest rank (default config).
|
fme.setRole(ConfServer.factionRankDefault); // They have just joined a faction, start them out on the lowest rank (default config).
|
||||||
|
|
||||||
faction.deinvite(fplayer);
|
faction.setInvited(fplayer, false);
|
||||||
|
|
||||||
|
|
||||||
|
// Derplog
|
||||||
if (ConfServer.logFactionJoin)
|
if (ConfServer.logFactionJoin)
|
||||||
{
|
{
|
||||||
if (samePlayer)
|
if (samePlayer)
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.ConfServer;
|
import com.massivecraft.factions.ConfServer;
|
||||||
import com.massivecraft.factions.FPerm;
|
import com.massivecraft.factions.FPerm;
|
||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
|
import com.massivecraft.factions.FactionColl;
|
||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
import com.massivecraft.factions.Perm;
|
import com.massivecraft.factions.Perm;
|
||||||
import com.massivecraft.factions.Rel;
|
import com.massivecraft.factions.Rel;
|
||||||
import com.massivecraft.factions.cmd.arg.ARFPlayer;
|
import com.massivecraft.factions.cmd.arg.ARFPlayer;
|
||||||
import com.massivecraft.factions.event.FactionsEventLeave;
|
import com.massivecraft.factions.event.FactionsEventMembershipChange;
|
||||||
|
import com.massivecraft.factions.event.FactionsEventMembershipChange.MembershipChangeReason;
|
||||||
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
||||||
|
|
||||||
public class CmdFactionsKick extends FCommand
|
public class CmdFactionsKick extends FCommand
|
||||||
@ -28,55 +28,59 @@ public class CmdFactionsKick extends FCommand
|
|||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform()
|
||||||
{
|
{
|
||||||
FPlayer you = this.arg(1, ARFPlayer.getStartAny());
|
// Arg
|
||||||
if (you == null) return;
|
FPlayer fplayer = this.arg(1, ARFPlayer.getStartAny());
|
||||||
|
if (fplayer == null) return;
|
||||||
|
|
||||||
if (fme == you)
|
// Validate
|
||||||
|
if (fme == fplayer)
|
||||||
{
|
{
|
||||||
msg("<b>You cannot kick yourself.");
|
msg("<b>You cannot kick yourself.");
|
||||||
msg("<i>You might want to: %s", Factions.get().getOuterCmdFactions().cmdFactionsLeave.getUseageTemplate(false));
|
msg("<i>You might want to: %s", Factions.get().getOuterCmdFactions().cmdFactionsLeave.getUseageTemplate(false));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (you.getRole() == Rel.LEADER && !(this.senderIsConsole || fme.isUsingAdminMode()))
|
if (fplayer.getRole() == Rel.LEADER && !(this.senderIsConsole || fme.isUsingAdminMode()))
|
||||||
{
|
{
|
||||||
msg("<b>The leader can not be kicked.");
|
msg("<b>The leader can not be kicked.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! ConfServer.canLeaveWithNegativePower && you.getPower() < 0)
|
if ( ! ConfServer.canLeaveWithNegativePower && fplayer.getPower() < 0)
|
||||||
{
|
{
|
||||||
msg("<b>You cannot kick that member until their power is positive.");
|
msg("<b>You cannot kick that member until their power is positive.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Faction yourFaction = you.getFaction();
|
// FPerm
|
||||||
|
Faction fplayerFaction = fplayer.getFaction();
|
||||||
|
if (!FPerm.KICK.has(sender, fplayerFaction)) return;
|
||||||
|
|
||||||
if (fme != null && ! FPerm.KICK.has(fme, yourFaction)) return;
|
// Event
|
||||||
|
FactionsEventMembershipChange event = new FactionsEventMembershipChange(sender, fplayer, FactionColl.get().getNone(), MembershipChangeReason.KICK);
|
||||||
// trigger the leave event (cancellable) [reason:kicked]
|
event.run();
|
||||||
FactionsEventLeave event = new FactionsEventLeave(you, you.getFaction(), FactionsEventLeave.PlayerLeaveReason.KICKED);
|
|
||||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
|
|
||||||
// then make 'em pay (if applicable)
|
// Inform
|
||||||
if (!payForCommand(ConfServer.econCostKick)) return;
|
fplayerFaction.msg("%s<i> kicked %s<i> from the faction! :O", fme.describeTo(fplayerFaction, true), fplayer.describeTo(fplayerFaction, true));
|
||||||
|
fplayer.msg("%s<i> kicked you from %s<i>! :O", fme.describeTo(fplayer, true), fplayerFaction.describeTo(fplayer));
|
||||||
yourFaction.msg("%s<i> kicked %s<i> from the faction! :O", fme.describeTo(yourFaction, true), you.describeTo(yourFaction, true));
|
if (fplayerFaction != myFaction)
|
||||||
you.msg("%s<i> kicked you from %s<i>! :O", fme.describeTo(you, true), yourFaction.describeTo(you));
|
|
||||||
if (yourFaction != myFaction)
|
|
||||||
{
|
{
|
||||||
fme.msg("<i>You kicked %s<i> from the faction %s<i>!", you.describeTo(fme), yourFaction.describeTo(fme));
|
fme.msg("<i>You kicked %s<i> from the faction %s<i>!", fplayer.describeTo(fme), fplayerFaction.describeTo(fme));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfServer.logFactionKick)
|
if (ConfServer.logFactionKick)
|
||||||
Factions.get().log((senderIsConsole ? "A console command" : fme.getName())+" kicked "+you.getName()+" from the faction: "+yourFaction.getTag());
|
{
|
||||||
|
Factions.get().log((senderIsConsole ? "A console command" : fme.getName())+" kicked "+fplayer.getName()+" from the faction: "+fplayerFaction.getTag());
|
||||||
|
}
|
||||||
|
|
||||||
if (you.getRole() == Rel.LEADER)
|
// Apply
|
||||||
yourFaction.promoteNewLeader();
|
if (fplayer.getRole() == Rel.LEADER)
|
||||||
|
{
|
||||||
yourFaction.deinvite(you);
|
fplayerFaction.promoteNewLeader();
|
||||||
you.resetFactionData();
|
}
|
||||||
|
fplayerFaction.setInvited(fplayer, false);
|
||||||
|
fplayer.resetFactionData();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,8 @@ import com.massivecraft.factions.Perm;
|
|||||||
import com.massivecraft.factions.Rel;
|
import com.massivecraft.factions.Rel;
|
||||||
import com.massivecraft.factions.cmd.arg.ARFPlayer;
|
import com.massivecraft.factions.cmd.arg.ARFPlayer;
|
||||||
import com.massivecraft.factions.cmd.arg.ARFaction;
|
import com.massivecraft.factions.cmd.arg.ARFaction;
|
||||||
import com.massivecraft.factions.event.FactionsEventJoin;
|
import com.massivecraft.factions.event.FactionsEventMembershipChange;
|
||||||
|
import com.massivecraft.factions.event.FactionsEventMembershipChange.MembershipChangeReason;
|
||||||
import com.massivecraft.factions.util.RelationUtil;
|
import com.massivecraft.factions.util.RelationUtil;
|
||||||
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
||||||
import com.massivecraft.mcore.util.Txt;
|
import com.massivecraft.mcore.util.Txt;
|
||||||
@ -65,7 +66,7 @@ public class CmdFactionsLeader extends FCommand
|
|||||||
// only perform a FPlayerJoinEvent when newLeader isn't actually in the faction
|
// only perform a FPlayerJoinEvent when newLeader isn't actually in the faction
|
||||||
if (newLeader.getFaction() != targetFaction)
|
if (newLeader.getFaction() != targetFaction)
|
||||||
{
|
{
|
||||||
FactionsEventJoin event = new FactionsEventJoin(sender, newLeader, targetFaction, FactionsEventJoin.PlayerJoinReason.LEADER);
|
FactionsEventMembershipChange event = new FactionsEventMembershipChange(sender, newLeader, targetFaction, MembershipChangeReason.LEADER);
|
||||||
event.run();
|
event.run();
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
}
|
}
|
||||||
|
@ -58,10 +58,4 @@ public abstract class FCommand extends MCommand
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if economy is enabled and they're not on the bypass list, make 'em pay; returns true unless person can't afford the cost
|
|
||||||
/*public boolean payForCommand(double cost)
|
|
||||||
{
|
|
||||||
return Econ.payForAction(cost, sender, this.getDesc());
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
@ -1,53 +0,0 @@
|
|||||||
package com.massivecraft.factions.event;
|
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.FPlayer;
|
|
||||||
import com.massivecraft.factions.Faction;
|
|
||||||
|
|
||||||
public class FactionsEventJoin extends FactionsEventAbstractSender
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// REQUIRED EVENT CODE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
@Override public HandlerList getHandlers() { return handlers; }
|
|
||||||
public static HandlerList getHandlerList() { return handlers; }
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// FIELDS
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private final FPlayer fplayer;
|
|
||||||
public FPlayer getFPlayer() { return this.fplayer; }
|
|
||||||
|
|
||||||
private final Faction faction;
|
|
||||||
public Faction getFaction() { return this.faction; }
|
|
||||||
|
|
||||||
private final PlayerJoinReason reason;
|
|
||||||
public PlayerJoinReason getReason() { return reason; }
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public FactionsEventJoin(CommandSender sender, FPlayer fplayer, Faction faction, PlayerJoinReason reason)
|
|
||||||
{
|
|
||||||
super(sender);
|
|
||||||
this.fplayer = fplayer;
|
|
||||||
this.faction = faction;
|
|
||||||
this.reason = reason;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// INTERNAL ENUM
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public enum PlayerJoinReason
|
|
||||||
{
|
|
||||||
CREATE, LEADER, JOIN
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -6,7 +6,7 @@ import org.bukkit.event.HandlerList;
|
|||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
|
|
||||||
public class FactionsEventLeave extends FactionsEventAbstractSender
|
public class FactionsEventMembershipChange extends FactionsEventAbstractSender
|
||||||
{
|
{
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// REQUIRED EVENT CODE
|
// REQUIRED EVENT CODE
|
||||||
@ -23,31 +23,28 @@ public class FactionsEventLeave extends FactionsEventAbstractSender
|
|||||||
@Override
|
@Override
|
||||||
public void setCancelled(boolean cancelled)
|
public void setCancelled(boolean cancelled)
|
||||||
{
|
{
|
||||||
if (this.reason == PlayerLeaveReason.DISBAND || this.reason == PlayerLeaveReason.RESET)
|
if (!this.reason.isCancellable()) cancelled = false;
|
||||||
{
|
|
||||||
cancelled = false;
|
|
||||||
}
|
|
||||||
super.setCancelled(cancelled);
|
super.setCancelled(cancelled);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final FPlayer fplayer;
|
private final FPlayer fplayer;
|
||||||
public FPlayer getFPlayer() { return this.fplayer; }
|
public FPlayer getFPlayer() { return this.fplayer; }
|
||||||
|
|
||||||
private final Faction faction;
|
private final Faction newFaction;
|
||||||
public Faction getFaction() { return this.faction; }
|
public Faction getNewFaction() { return this.newFaction; }
|
||||||
|
|
||||||
private final PlayerLeaveReason reason;
|
private final MembershipChangeReason reason;
|
||||||
public PlayerLeaveReason getReason() { return this.reason; }
|
public MembershipChangeReason getReason() { return this.reason; }
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// CONSTRUCT
|
// CONSTRUCT
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public FactionsEventLeave(CommandSender sender, FPlayer fplayer, Faction faction, PlayerLeaveReason reason)
|
public FactionsEventMembershipChange(CommandSender sender, FPlayer fplayer, Faction newFaction, MembershipChangeReason reason)
|
||||||
{
|
{
|
||||||
super(sender);
|
super(sender);
|
||||||
this.fplayer = fplayer;
|
this.fplayer = fplayer;
|
||||||
this.faction = faction;
|
this.newFaction = newFaction;
|
||||||
this.reason = reason;
|
this.reason = reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,9 +52,28 @@ public class FactionsEventLeave extends FactionsEventAbstractSender
|
|||||||
// INTERNAL ENUM
|
// INTERNAL ENUM
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public enum PlayerLeaveReason
|
public enum MembershipChangeReason
|
||||||
{
|
{
|
||||||
KICKED, DISBAND, RESET, JOINOTHER, LEAVE
|
// Join
|
||||||
|
JOIN (true),
|
||||||
|
CREATE (false),
|
||||||
|
LEADER (true),
|
||||||
|
|
||||||
|
// Leave
|
||||||
|
LEAVE (true),
|
||||||
|
//JOINOTHER (true),
|
||||||
|
KICK (true),
|
||||||
|
DISBAND (false),
|
||||||
|
//RESET (false),
|
||||||
|
;
|
||||||
|
|
||||||
|
private final boolean cancellable;
|
||||||
|
public boolean isCancellable() { return this.cancellable; }
|
||||||
|
|
||||||
|
private MembershipChangeReason(boolean cancellable)
|
||||||
|
{
|
||||||
|
this.cancellable = cancellable;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -13,6 +13,8 @@ import com.massivecraft.factions.event.FactionsEventDescriptionChange;
|
|||||||
import com.massivecraft.factions.event.FactionsEventHomeChange;
|
import com.massivecraft.factions.event.FactionsEventHomeChange;
|
||||||
import com.massivecraft.factions.event.FactionsEventHomeTeleport;
|
import com.massivecraft.factions.event.FactionsEventHomeTeleport;
|
||||||
import com.massivecraft.factions.event.FactionsEventInvitedChange;
|
import com.massivecraft.factions.event.FactionsEventInvitedChange;
|
||||||
|
import com.massivecraft.factions.event.FactionsEventMembershipChange;
|
||||||
|
import com.massivecraft.factions.event.FactionsEventMembershipChange.MembershipChangeReason;
|
||||||
import com.massivecraft.factions.event.FactionsEventOpenChange;
|
import com.massivecraft.factions.event.FactionsEventOpenChange;
|
||||||
import com.massivecraft.factions.event.FactionsEventRelationChange;
|
import com.massivecraft.factions.event.FactionsEventRelationChange;
|
||||||
import com.massivecraft.factions.event.FactionsEventTagChange;
|
import com.massivecraft.factions.event.FactionsEventTagChange;
|
||||||
@ -110,4 +112,32 @@ public class FactionsListenerEcon implements Listener
|
|||||||
payForCommand(event, ConfServer.econCostHome, Factions.get().getOuterCmdFactions().cmdFactionsHome);
|
payForCommand(event, ConfServer.econCostHome, Factions.get().getOuterCmdFactions().cmdFactionsHome);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
|
public void payForCommand(FactionsEventMembershipChange event)
|
||||||
|
{
|
||||||
|
Double cost = null;
|
||||||
|
MCommand command = null;
|
||||||
|
|
||||||
|
if (event.getReason() == MembershipChangeReason.JOIN)
|
||||||
|
{
|
||||||
|
cost = ConfServer.econCostJoin;
|
||||||
|
command = Factions.get().getOuterCmdFactions().cmdFactionsJoin;
|
||||||
|
}
|
||||||
|
else if (event.getReason() == MembershipChangeReason.LEAVE)
|
||||||
|
{
|
||||||
|
cost = ConfServer.econCostLeave;
|
||||||
|
command = Factions.get().getOuterCmdFactions().cmdFactionsLeave;
|
||||||
|
}
|
||||||
|
else if (event.getReason() == MembershipChangeReason.KICK)
|
||||||
|
{
|
||||||
|
cost = ConfServer.econCostKick;
|
||||||
|
command = Factions.get().getOuterCmdFactions().cmdFactionsKick;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
payForCommand(event, cost, command);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user