2011-03-19 13:00:03 +01:00
|
|
|
package com.bukkit.mcteam.factions.commands;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import com.bukkit.mcteam.factions.Conf;
|
|
|
|
import com.bukkit.mcteam.factions.FPlayer;
|
|
|
|
import com.bukkit.mcteam.factions.Faction;
|
|
|
|
|
2011-03-22 15:45:41 +01:00
|
|
|
public class FCommandJoin extends FBaseCommand {
|
2011-03-19 13:00:03 +01:00
|
|
|
|
|
|
|
public FCommandJoin() {
|
|
|
|
requiredParameters = new ArrayList<String>();
|
|
|
|
optionalParameters = new ArrayList<String>();
|
|
|
|
requiredParameters.add("faction name");
|
|
|
|
|
|
|
|
permissions = "";
|
|
|
|
|
|
|
|
senderMustBePlayer = true;
|
|
|
|
|
|
|
|
helpDescription = "Join a faction";
|
|
|
|
}
|
|
|
|
|
|
|
|
public void perform() {
|
|
|
|
String factionName = parameters.get(0);
|
|
|
|
|
|
|
|
Faction faction = findFaction(factionName);
|
|
|
|
if (faction == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-03-22 17:20:21 +01:00
|
|
|
if (faction == me.getFaction()) {
|
2011-03-19 13:00:03 +01:00
|
|
|
sendMessage("You are already a member of "+faction.getTag(me));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (me.hasFaction()) {
|
|
|
|
sendMessage("You must leave your current faction first.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( ! faction.getOpen() && ! faction.isInvited(me)) {
|
|
|
|
sendMessage("This guild requires invitation.");
|
|
|
|
faction.sendMessage(me.getNameAndRelevant(faction)+Conf.colorSystem+" tried to join your faction.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
me.sendMessage(Conf.colorSystem+"You successfully joined "+faction.getTag(me));
|
|
|
|
faction.sendMessage(me.getNameAndRelevant(faction)+Conf.colorSystem+" joined your faction.");
|
|
|
|
|
|
|
|
me.resetFactionData();
|
2011-03-22 17:20:21 +01:00
|
|
|
me.setFaction(faction);
|
|
|
|
faction.deinvite(me);
|
2011-03-19 13:00:03 +01:00
|
|
|
FPlayer.save();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|