FactionsUUID Api

Discussion in 'Spigot Plugin Development' started by William029, May 29, 2017.

  1. I am using the factions
    Code (Text):
    package me.bukkit.William;

    import org.bukkit.ChatColor;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.BlockPlaceEvent;

    import com.massivecraft.factions.FPlayer;
    import com.massivecraft.factions.cmd.FCommand;
    import com.massivecraft.factions.struct.Permission;
    import com.massivecraft.factions.zcore.util.TL;
    import com.massivecraft.factions.zcore.util.TextUtil;

    public class ChatColor extends FCommand {

        public ChatColor() {
            this.aliases.add("titlecolor");

            this.requiredArgs.add("player name");
            this.optionalArgs.put("title", "");

            this.permission = Permission.TITLE.node;
            this.disableOnLock = true;

            senderMustBePlayer = true;
            senderMustBeMember = false;
            senderMustBeModerator = true;
            senderMustBeAdmin = false;
        }

        @Override
        public void perform() {
            FPlayer you = this.argAsBestFPlayerMatch(0);
            if (you == null) {
                return;
            }

            args.remove(0);
            String title = TextUtil.implode(args, " ");

            if (!canIAdministerYou(fme, you)) {
                return;
            }

           
           

            you.setTitle(replaceSymbols(title));

            // Inform
            myFaction.msg(TL.COMMAND_TITLE_CHANGED, fme.describeTo(myFaction, true), you.describeTo(myFaction, true));
        }

        @Override
        public TL getUsageTranslation() {
            return TL.COMMAND_TITLE_DESCRIPTION;
        }
        public static String replaceSymbols(String input)
          {
            if ((input == null) || (input.length() == 0)) {
              return input;
            }
            return
           
              ChatColor.translateAlternateColorCodes('&', input).replace("<3", "?").replace("[x]", "?").replace("[/]", "?").replace("[*]", "?").replace("[p]", "?").replace("[+]", "?").replace("[++]", "?");
          }

    }
    UUID api to add some plugins, but how would I register a command its completely diffrent
     
  2. It is very easy you only have to register it on the class FcmdRoot
    And also add it to the aliases
     
  3. on a separate plugin?
     
  4. no, the same plugin
    upload_2017-5-31_15-43-19.png


    upload_2017-5-31_15-43-30.png

    This is just an exmpl of some commands I added
     
  5. Listen to the Command pre process event and see if it is your command.
     
    • Agree Agree x 1
  6. Good idea thanks!
     
  7. That's a bad idea when there's an API for it.
    Get FRootCmd and call #addSubCommand to it.
    The source is public on GitHub if you'd like to poke there to find classes you need to extend and such.
    https://github.com/Techcable/Factio...a/com/massivecraft/factions/cmd/FCmdRoot.java
    You simply extend FCommand and then call the method.
     
  8. Extending FCommand won't work since you have to return a TL toString in your
    public TL getUsageTranslation() {


    So this basically means that if you want to add a new TL message you should modify TL class.
    I haven't really tried but I think that would be an issue, the best Idea is do what @Futurize said