Making custom enchantment signs

Discussion in 'Plugin Development' started by Redrield, Sep 22, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    Redrield

    Hello, I've been asked by an owner of one of my favourite servers, to make a custom sign plugin for a custom enchantment plugin he bought from Spigot. I know how to make normal enchant signs, but I've haven't a clue on how to do this The plugin he wants me to work on is <Edit by Moderator: Redacted not allowed paid resource url>
     
    Last edited by a moderator: Dec 5, 2016
  2. Offline

    teej107

    @Redrield The page shows code on how to enchant with it.
     
  3. Offline

    DoggyCode™

    Ask owner to send you the plugin and then add it to your jars.

    And here's the methods:


    Code:
    MainEnchants.applyEnchant(ItemStack, int, EnchantPlus);
    
    
    ItemStack item =new ItemStack(Material.DIAMOND_BOOTS);
    MainEnchants.applyEnchant(item, 1, EnchantTypes.FLIGHT);
    
    So whenever your guy clicks on the sign get the item in his hand and enchant it using the method(s) above.
     
    lubbs31 likes this.
  4. Offline

    Redrield

    I have that but when I actually try to use it ingame it doesn't apply the enchantments
     
  5. Offline

    SuperSniper

    @Redrield Make sure that the plugin is enabled on the server, and the server has the plugin "EnchantPlus" enabled on it also.
     
  6. Offline

    Redrield

    Both of them are on the server and enabled, but it just doesn't apply the enchants
     
  7. Offline

    teej107

  8. Offline

    Redrield

    Code:
    package me.Redrield;
    
    import java.util.ArrayList;
    import java.util.List;
    
    import org.bukkit.Bukkit;
    import org.bukkit.Material;
    import org.bukkit.block.Block;
    import org.bukkit.block.Sign;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.meta.ItemMeta;
    import org.bukkit.plugin.java.JavaPlugin;
    
    import com.gmail.revision9000.VEnchants.Enchants.EnchantTypes;
    import com.gmail.revision9000.VEnchants.Utils.MainEnchants;
    
    public class SignEnch extends JavaPlugin implements Listener{
       
       
        @Override
        public void onEnable()
        {
            Bukkit.getServer().getPluginManager().registerEvents(this, this);
            getLogger().info("Plugin Enabled");
        }
       
        @Override
        public void onDisable()
        {
            getLogger().info("Plugin Disabled");
        }
       
        @EventHandler
        public void onSignClick(PlayerInteractEvent e)
        {
            Player p = (Player) e.getPlayer();
            Block b = e.getClickedBlock();
            if(e.getAction() != Action.RIGHT_CLICK_BLOCK) return;
            {
                if(b.getState() instanceof Sign)
                {
                    Sign s = (Sign) e.getClickedBlock().getState();
                    if(s.getLine(0).equalsIgnoreCase("[BDMCEnchant]") && s.getLine(1).equalsIgnoreCase("Flight"))
                    {
                        ItemStack i = new ItemStack(p.getItemInHand());
                        ItemStack iWant = new ItemStack(Material.DIAMOND_BOOTS);
                        if(i == iWant)
                        {
                            MainEnchants.applyEnchant(i, 1, EnchantTypes.FLIGHT);
                        }
                   
                    }
                }
            }
        }
    }
    
     
  9. Offline

    teej107

    @Redrield Use Object#equals() to compare objects instead.
     
  10. Offline

    Redrield

    @teej107 Alright so I changed i == iWant to i.equals(iWant) and it still doesn't work
     
    Last edited: Sep 25, 2015
Thread Status:
Not open for further replies.

Share This Page