2011-10-09 21:57:43 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
2011-10-08 23:22:02 +02:00
|
|
|
|
2013-04-16 11:05:49 +02:00
|
|
|
import com.massivecraft.factions.Rel;
|
2013-04-24 15:14:15 +02:00
|
|
|
import com.massivecraft.factions.entity.MPlayer;
|
2013-04-22 17:59:51 +02:00
|
|
|
import com.massivecraft.factions.entity.UPlayer;
|
2013-04-22 09:37:53 +02:00
|
|
|
import com.massivecraft.factions.entity.Faction;
|
2013-04-16 09:48:57 +02:00
|
|
|
import com.massivecraft.mcore.cmd.MCommand;
|
2013-04-16 11:05:49 +02:00
|
|
|
import com.massivecraft.mcore.util.Txt;
|
2011-10-08 23:22:02 +02:00
|
|
|
|
2013-04-16 09:48:57 +02:00
|
|
|
public abstract class FCommand extends MCommand
|
2011-10-08 23:22:02 +02:00
|
|
|
{
|
2013-04-24 15:14:15 +02:00
|
|
|
public MPlayer mme;
|
2013-04-22 17:59:51 +02:00
|
|
|
public UPlayer fme;
|
2011-10-09 18:35:39 +02:00
|
|
|
public Faction myFaction;
|
2013-04-10 10:00:40 +02:00
|
|
|
|
2011-10-09 21:57:43 +02:00
|
|
|
@Override
|
2013-04-16 09:48:57 +02:00
|
|
|
public void fixSenderVars()
|
2011-10-08 23:22:02 +02:00
|
|
|
{
|
2013-04-24 15:14:15 +02:00
|
|
|
this.mme = MPlayer.get(sender);
|
2013-04-22 17:59:51 +02:00
|
|
|
this.fme = UPlayer.get(this.sender);
|
2013-04-16 09:48:57 +02:00
|
|
|
this.myFaction = this.fme.getFaction();
|
2011-10-08 23:22:02 +02:00
|
|
|
}
|
2013-04-16 11:05:49 +02:00
|
|
|
|
|
|
|
// -------------------------------------------- //
|
|
|
|
// COMMONLY USED LOGIC
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
2013-04-22 17:59:51 +02:00
|
|
|
public boolean canIAdministerYou(UPlayer i, UPlayer you)
|
2013-04-16 11:05:49 +02:00
|
|
|
{
|
|
|
|
if ( ! i.getFaction().equals(you.getFaction()))
|
|
|
|
{
|
|
|
|
i.sendMessage(Txt.parse("%s <b>is not in the same faction as you.",you.describeTo(i, true)));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i.getRole().isMoreThan(you.getRole()) || i.getRole().equals(Rel.LEADER) )
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (you.getRole().equals(Rel.LEADER))
|
|
|
|
{
|
2013-04-19 15:32:16 +02:00
|
|
|
i.sendMessage(Txt.parse("<b>Only the faction leader can do that."));
|
2013-04-16 11:05:49 +02:00
|
|
|
}
|
|
|
|
else if (i.getRole().equals(Rel.OFFICER))
|
|
|
|
{
|
|
|
|
if ( i == you )
|
|
|
|
{
|
|
|
|
return true; //Moderators can control themselves
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
i.sendMessage(Txt.parse("<b>Moderators can't control each other..."));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
i.sendMessage(Txt.parse("<b>You must be a faction moderator to do that."));
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2011-10-08 23:22:02 +02:00
|
|
|
}
|