2012-05-09 03:24:07 +02:00
package com.massivecraft.factions.cmd ;
import java.net.URL ;
2013-04-09 12:56:29 +02:00
import com.massivecraft.factions.Perm ;
2012-05-09 03:24:07 +02:00
import com.massivecraft.factions.integration.SpoutFeatures ;
import com.massivecraft.factions.util.RelationUtil ;
2013-04-16 10:11:59 +02:00
import com.massivecraft.mcore.cmd.req.ReqHasPerm ;
2012-05-09 03:24:07 +02:00
2013-04-10 13:12:22 +02:00
public class CmdFactionsCapeSet extends CmdFactionsCapeAbstract
2012-05-09 03:24:07 +02:00
{
2013-04-10 13:12:22 +02:00
public CmdFactionsCapeSet ( )
2012-05-09 03:24:07 +02:00
{
2013-04-16 10:11:59 +02:00
this . addAliases ( " set " ) ;
2013-04-16 10:30:21 +02:00
this . addRequiredArg ( " url " ) ;
2013-04-16 10:11:59 +02:00
this . addRequirements ( ReqHasPerm . get ( Perm . CAPE_SET . node ) ) ;
2012-05-09 03:24:07 +02:00
}
@Override
public void perform ( )
{
String newCape = this . argAsString ( 0 ) ;
if ( isUrlValid ( newCape ) )
{
capeFaction . setCape ( newCape ) ;
SpoutFeatures . updateCape ( capeFaction , null ) ;
msg ( " <h>%s <i>set the cape of <h>%s<i> to \" <h>%s<i> \" . " , RelationUtil . describeThatToMe ( fme , fme , true ) , capeFaction . describeTo ( fme ) , newCape ) ;
capeFaction . msg ( " <h>%s <i>set the cape of <h>%s<i> to \" <h>%s<i> \" . " , RelationUtil . describeThatToMe ( fme , capeFaction , true ) , capeFaction . describeTo ( capeFaction ) , newCape ) ;
}
else
{
msg ( " <i> \" <h>%s<i> \" is not a valid URL. " , newCape ) ;
}
}
public static boolean isUrlValid ( String urlString )
{
try
{
new URL ( urlString ) ;
return true ;
}
catch ( Exception e )
{
return false ;
}
}
}