package com.massivecraft.factions.cmd; import java.net.URL; import com.massivecraft.factions.Perm; import com.massivecraft.factions.integration.SpoutFeatures; import com.massivecraft.factions.util.RelationUtil; import com.massivecraft.mcore.cmd.req.ReqHasPerm; public class CmdFactionsCapeSet extends CmdFactionsCapeAbstract { public CmdFactionsCapeSet() { this.addAliases("set"); this.requiredArgs.add("url"); this.addRequirements(ReqHasPerm.get(Perm.CAPE_SET.node)); } @Override public void perform() { String newCape = this.argAsString(0); if (isUrlValid(newCape)) { capeFaction.setCape(newCape); SpoutFeatures.updateCape(capeFaction, null); msg("%s set the cape of %s to \"%s\".", RelationUtil.describeThatToMe(fme, fme, true), capeFaction.describeTo(fme), newCape); capeFaction.msg("%s set the cape of %s to \"%s\".", RelationUtil.describeThatToMe(fme, capeFaction, true), capeFaction.describeTo(capeFaction), newCape); } else { msg("\"%s\" is not a valid URL.", newCape); } } public static boolean isUrlValid(String urlString) { try { new URL(urlString); return true; } catch (Exception e) { return false; } } }