How to Make An Annihilation Kit.

Dec 30, 2017
How to Make An Annihilation Kit.
  • How to Make an Annihilation Kit
    You need this API: link
    \-------------------------------------------------------------------------------------------------------------------------/


    Once you have downloaded the library 'AnnihilationAPI.zip', unzip it, to unzip it you will find 2 files. jar, these files are: 'AnniAPI ' and ' AnniKitsAPI'. These files are not plugins, they are only libraries, so you can not place them in the folder 'plugins' of your server. What you have to do is import these files as a library to your program. (In tutorial we will only use the jar file 'AnniAPI').

    Now just make a class with the name that you want to put to your Custom Kit:
    Code (Text):
    package com.hotmail.AdrianSRJose.Kits;
    public class Test
    {

    }
    Now you need to extends a class. It can be either of these two:

    1. ConfigurableKit.
    2. ClassItemKitWithEvent.

    Extending ConfigurableKit(top)

    Once extended, we add the unimplemented methods:

    Code (Text):
    package com.hotmail.AdrianSRJose.Kits;

    import java.util.List;

    import org.bukkit.configuration.ConfigurationSection;
    import org.bukkit.entity.Player;
    import org.bukkit.inventory.Inventory;
    import org.bukkit.inventory.ItemStack;

    import com.hotmail.AdrianSRJose.AnniPro.anniGame.AnniPlayer;
    import com.hotmail.AdrianSRJose.AnniPro.kits.Loadout;
    import com.hotmail.AdrianSRJose.base.ConfigurableKit;

    public class Test extends ConfigurableKit
    {

        @Override
        protected void setUp() {
        }

        @Override
        protected String getInternalName() {
            return null;
        }

        @Override
        protected ItemStack getIcon() {
            return null;
        }

        @Override
        protected int setDefaults(ConfigurationSection section) {
            return 0;
        }

        @Override
        protected List<String> getDefaultDescription() {
            return null;
        }

        @Override
        protected Loadout getFinalLoadout() {
            return null;
        }

        @Override
        protected void onPlayerRespawn(Player p, AnniPlayer ap) {
        }

        @Override
        public void cleanup(Player arg0) {
        }

        @Override
        public boolean onItemClick(Inventory arg0, AnniPlayer arg1) {
            return false;
        }

    }



    setUp() Method(top)

    It's like using a constructor.

    getInternalName() Method(top)

    Is the Kit Name. Warning: There can be no two kits with equal names
    . Example:
    Code (Text):
    @Override
    protected String getInternalName()
    {
           return "TestKit!";
    }

    getIcon() Method(top)


    It's the icon shown in the Kits menu. Example:
    Code (Text):
    @Override
    protected ItemStack getIcon()
    {
        return new ItemStack(Material.ARROW);
    }


    setDefaults(ConfigurationSection section) Method(top)

    It's used to add anything as names, to the file 'StarterKitsConfig yml'. And it serves to register configurable variables. Example:

    Code (Text):
    @Override
    protected int setDefaults(ConfigurationSection section)
    {
            ConfigurationSection c1;
            if (section.isConfigurationSection("Messages"))
                c1 = section.getConfigurationSection("Messages");
            else
                c1 = section.createSection("Messages");
            //
            this.sneakinMessage = c1.getString("SneakinMessage");
            return 1;
    }


    getDefaultDescription() Method(top)

    It's the icon Lore. Just make a list and add what you want the icon to have as lore and return this list. Example:
    Code (Text):
    @Override
    protected List<String> getDefaultDescription()
    {
            List<String> l = new ArrayList<String>();
            addToList(l, "This is A Test Kit",
                         "",
                         aqua + "Test Kit!!",
                         "",
                          aqua + "Test Lore");
            //The Method 'addToList(List<String>, String... args)' is an inherited method.
            //The Constant 'aqua' is an inherited Chat Color and is equal to ChatColor.AQUA.
            return l;
    }


    getFinalLoadout() Method(top)

    They are the items that the player will receive. Kust make a new 'Loadout'. Example:
    Code (Text):
    @Override
    protected Loadout getFinalLoadout()
    {
            return new Loadout().addWoodSword().addWoodAxe().addWoodPick().addWoodShovel().addBow().addClassSoulboundItem(new ItemStack(Material.ARROW, 10));
    }



    onPlayerRespawn(Player p, AnniPlayer ap) Method(top)

    It's called when the player respawn. You can do whatever you want. Example:
    Code (Text):
    @Override
    protected void onPlayerRespawn(Player p, AnniPlayer ap)
    {
            p.sendMessage(ChatColor.GREEN + "You has been Respawned");
    }


    cleanup(Player p) Method(top)

    It's called when the player respawn and when the pleyer chanhe his Kit. You can do whatever you want. Example:
    Code (Text):
    @Override
    public void cleanup(Player p)
    {
            p.sendMessage(ChatColor.GREEN + "You has been Change Your Kit");
    }



    onItemClick(Inventory inv, AnniPlayer ap) Method(top)

    Its called when the player clicks on the Kit menu to select this kit. It is necessary to add the items of this kit. In this way:
    Code (Text):
    @Override
    public boolean onItemClick(Inventory inv, AnniPlayer ap)
    {
            this.addLoadoutToInventory(inv); //< --- add Kit Items to new open Kit Inventory.
            ap.sendMessage(ChatColor.GREEN + "You has been selec the Kit: " + ChatColor.DARK_PURPLE + this.getInternalName()); //< --- send Message to Player.
            return true; //< --- set it like true.
    }

    You Can add an Events in This Class. All events in this class are registered. Example:
    Code (Text):
    package com.hotmail.AdrianSRJose.Kits;

    public class Test extends ConfigurableKit
    {
        private String sneakinMessage = "You Are Sneaking";
        @Override
        protected void setUp() {
        }

        @Override
        protected String getInternalName()
        {
            return "TestKit!";
        }

        @Override
        protected ItemStack getIcon()
        {
            return new ItemStack(Material.ARROW);
        }

        @Override
        protected int setDefaults(ConfigurationSection section)
        {
            ConfigurationSection c1;
            if (section.isConfigurationSection("Messages"))
                c1 = section.getConfigurationSection("Messages");
            else
                c1 = section.createSection("Messages");
            //
            this.sneakinMessage = c1.getString("SneakinMessage");
            return 1;
        }

        @Override
        protected List<String> getDefaultDescription()
        {
            List<String> l = new ArrayList<String>();
            addToList(l, "This is A Test Kit",
                         "",
                         "Test Kit!!",
                         "",
                         "Test Lore");
            //The Method 'addToList(List<String>, String... args) is an inherited method'
            //The Constant 'aqua' is an inherited Chat Color.
            return l;
        }

        @Override
        protected Loadout getFinalLoadout()
        {
            return new Loadout().addWoodSword().addWoodAxe().addWoodPick().addWoodShovel().addBow().addClassSoulboundItem(new ItemStack(Material.ARROW, 10));
        }

        @Override
        protected void onPlayerRespawn(Player p, AnniPlayer ap)
        {
            p.sendMessage(ChatColor.GREEN + "You has been Respawned");
        }

        @Override
        public void cleanup(Player p)
        {
            p.sendMessage(ChatColor.GREEN + "You has been Change Your Kit");
        }

        @Override
        public boolean onItemClick(Inventory inv, AnniPlayer ap)
        {
            this.addLoadoutToInventory(inv); //< --- add Kit Items to new open Kit Inventory.
            ap.sendMessage(ChatColor.GREEN + "You has been selec the Kit: " + ChatColor.DARK_PURPLE + this.getInternalName()); //< --- send Message to Player.
            return true; //< --- set it like true.
        }
     
        @EventHandler
        public void onSnkea(PlayerToggleSneakEvent event)
        {
            final Player p = event.getPlayer(); // < --- To get Player from event.
            final AnniPlayer ap = AnniPlayer.getPlayer(p.getUniqueId()); // < --- To get AnniPlayer from the BukkitPlayer UUID.
            if (ap != null && ap.isOnline()) // To Verify if not is null.
            {
                if (ap.hasTeam() && ap.hasKit() && !KitUtils.isOnLobby(p)) // To Verify if not is on Lobby, if has team and hast Kit.
                {
                    if (ap.getKit().equals(this)) // To Verify if the AnniPlayer kit is this.
                    {
                        if (!p.isSneaking()) //To Verify if the player no is Sneaking.
                            p.sendMessage(ChatColor.GREEN + this.sneakinMessage); // Send sneaking Message geted from 'StarterKitsConfit.yml'
                                                                                  // With the Method 'setDefaults(ConfigurationSection section)'.
                    }
                }
            }
        }
    }
     

    Extending ClassItemKitWithEvent(top)

    Once extended, we add the unimplemented methods:

    Code (Text):
    package com.hotmail.AdrianSRJose.Kits;

    import java.util.List;

    import org.bukkit.entity.Player;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.inventory.Inventory;
    import org.bukkit.inventory.ItemStack;

    import com.hotmail.AdrianSRJose.AnniPro.anniGame.AnniPlayer;
    import com.hotmail.AdrianSRJose.AnniPro.kits.Loadout;
    import com.hotmail.AdrianSRJose.base.ClassItemKitWithEvent;

    public class Test extends ClassItemKitWithEvent
    {

        @Override
        protected void onInitialize() {
        }

        @Override
        protected ItemStack specialItem() {
            return null;
        }

        @Override
        protected String defaultSpecialItemName() {
            return null;
        }

        @Override
        protected boolean isSpecialItem(ItemStack stack) {
            return false;
        }

        @Override
        protected boolean performPrimaryAction(Player player, AnniPlayer p, PlayerInteractEvent event) {
            return false;
        }

        @Override
        protected boolean performSecondaryAction(Player player, AnniPlayer p, PlayerInteractEvent event) {
            return false;
        }

        @Override
        protected long getDelayLength() {
            return 0;
        }

        @Override
        protected boolean useDefaultChecking() {
            return false;
        }

        @Override
        protected boolean useCustomMessage() {
            return false;
        }

        @Override
        protected String positiveMessage() {
            return null;
        }

        @Override
        protected String negativeMessage() {
            return null;
        }

        @Override
        protected String getInternalName() {
            return null;
        }

        @Override
        protected ItemStack getIcon() {
            return null;
        }

        @Override
        protected List<String> getDefaultDescription() {
            return null;
        }

        @Override
        protected Loadout getFinalLoadout() {
            return null;
        }

        @Override
        protected void onPlayerRespawn(Player p, AnniPlayer ap) {
        }

        @Override
        public void cleanup(Player arg0) {
        }

        @Override
        public boolean onItemClick(Inventory arg0, AnniPlayer arg1) {
            return false;
        }

    }

    onInitialize() Method(top)

    This Method is equal to the setUp() Method.

    specialItem() Method(top)

    It's the Special Item Kit. Just make a custom ItemStack and return it like a Souldboud. Souldboud Types: (Souldboud, ClassSouldboud, UndroppableSouldboud(Undroppable)):
    Code (Text):
    @Override
    protected ItemStack specialItem()
    {
            ItemStack stack = new ItemStack(Material.STICK);
            stack = KitUtils.setName(stack, getSpecialItemName() + " READY"); // < -- * Set name with the Method KitUtils.setName().
                                                                              // < -- * Set name like getSpecialItemName() + " READY".
            return KitUtils.addClassSoulbound(stack); //<-- You Can use:
                                                      //KitUtils.addClassSoulbound() or KitUtils.addClassUndropabbleSoulbound() or
                                                      //KitUtils.addSoulbound()
    }


    defaultSpecialItemName() Method(top)

    It's The Special Item Kit Name:
    Code (Text):
    @Override
    protected String defaultSpecialItemName()
    {
        return "TestItem"; // < -- Return a Custom Item Kit name.
    }


    isSpecialItem(ItemStack stack) Method(top)

    It's a boolean to verify if is the Special Item Kit:
    Code (Text):
    @Override
    protected boolean isSpecialItem(ItemStack stack)
    {
        if (!KitUtils.isClassSoulbound(stack)) // Verify if is A Class Souldbound.
                                                   // It depends on the type of souldbound you used in the Method: specialItem().
                                                   // If you use: KitUtils.addClassSoulbound() you need to use: KitUtils.isClassSoulbound().
                                                   // If you use: KitUtils.addClassUndropabbleSoulbound() you need to use: KitUtils.isClassUndropabbleSoulbound().
                                                   // If you use: KitUtils.addSoulbound() you need to use: is KitUtils.isSoulbound().
                return false;
            //
        return KitUtils.itemNameContains(stack, getSpecialItemName());
    }


    performPrimaryAction() Method(top)

    It's called when the player clicks right and has the Special Item Kit in his hand:
    Code (Text):
    @Override
    protected boolean
    performPrimaryAction(Player player, AnniPlayer p,
                PlayerInteractEvent event)
    {
            return false; // < if you return true, the action will
                          // be activated and add a delay, if you
                          // return false nothing happens.
    }


    performSecondaryAction() Method(top)

    Code (Text):
    @Override
    protected boolean
    performSecondaryAction(Player player, AnniPlayer p,
                PlayerInteractEvent event)
    {
            return false; // < if you return true, the action will
                          //be activated and add a delay, if you
                           // return false nothing happens.
    }



    getDelayLength() Method(top)

    It's the time (in Seconds * 1000) that to wait to reuse the Special Item Kit.
    Code (Text):
    @Override
    protected long getDelayLength()
    {
        return (6*1000); // Returns the time you want the player
                      // expects to reuse the Special Item Kit.
                      // (in Seconds * 1000) Example:
                      // You Want 6 seconds. You set it like: (6*1000);
    }


    useDefaultChecking() Method(top)

    Code (Text):
    @Override
    protected boolean useDefaultChecking()
    {
        return true; // Returns true if you want to
                          // Enable the Methods:
                          // performPrimaryAction and performSecondaryAction().
    }


    useCustomMessage() Method(top)

    method is the positive message if the player uses the Special Item Kit and the action is activated, or negative message if the action is not activated.
    Code (Text):
    @Override
        protected boolean useCustomMessage()  // Returns true if you want to
                                              // Use The Methods:
                                              // positiveMessage() and negativeMessage().
        {
            return false;
        }


    positiveMessage() Method(top)

    It's The Possitive Message of the useCustomMessage() Method.
    Code (Text):
    @Override
    protected String positiveMessage() // It's called when the
                                           // player use The Special Item Kit
                                           // and it's active. Requires: useCustomMessage() enabled.
    {
            return ChatColor.GREEN + "Binnn !!!!";
    }


    negativeMessage()(top)

    It's The Negative Message of the useCustomMessage() Method.
    Code (Text):
    @Override
    protected String negativeMessage() // It's called when the
                                           // player use The Special Item Kit
                                             // and it's do not active. Requires: useCustomMessage() enabled.
    {
            return ChatColor.RED + "You cannot use the Special Item Kit at this time.";
    }

    And those after these methods follow those that and explained earlier mind:

  • Loading...
  • Loading...