Factions/src/main/java/com/massivecraft/factions/cmd/FactionsCommand.java

78 lines
1.8 KiB
Java
Raw Normal View History

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 09:37:53 +02:00
import com.massivecraft.factions.entity.Faction;
2014-06-04 14:02:23 +02:00
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.util.Txt;
2011-10-08 23:22:02 +02:00
2014-09-18 13:41:20 +02:00
public abstract class FactionsCommand extends MassiveCommand
2011-10-08 23:22:02 +02:00
{
2013-11-11 09:31:04 +01:00
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
public MPlayer msender;
2014-09-18 13:41:20 +02:00
public Faction msenderFaction;
2013-04-10 10:00:40 +02:00
2013-11-11 09:31:04 +01:00
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
2011-10-09 21:57:43 +02:00
@Override
public void fixSenderVars()
2011-10-08 23:22:02 +02:00
{
this.msender = MPlayer.get(sender);
2014-09-18 13:41:20 +02:00
this.msenderFaction = this.msender.getFaction();
2011-10-08 23:22:02 +02:00
}
2013-04-16 11:05:49 +02:00
2014-09-13 00:50:33 +02:00
@Override
public void unsetSenderVars()
{
this.msender = null;
2014-09-18 13:41:20 +02:00
this.msenderFaction = null;
2014-09-13 00:50:33 +02:00
}
2013-04-16 11:05:49 +02:00
// -------------------------------------------- //
// COMMONLY USED LOGIC
// -------------------------------------------- //
public boolean canIAdministerYou(MPlayer i, MPlayer 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))
{
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>Officers can't control each other..."));
2013-04-16 11:05:49 +02:00
}
}
else
{
i.sendMessage(Txt.parse("<b>You must be a faction officer to do that."));
2013-04-16 11:05:49 +02:00
}
return false;
}
2013-11-11 09:31:04 +01:00
2011-10-08 23:22:02 +02:00
}