Binding spell to book

Discussion in 'Plugin Development' started by klofno1, Jul 19, 2013.

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

    klofno1

    Could someone explain to me how to write a code which allows players to bind one of my magic spells to a book with the command /Venificus bind "spellname". All the spells have to be bindable to the book but you can only bind one at the time. If you left click you cast the spell.

    Source code of 1 spell :

    Code:java
    1. private List<String> cantDoCommand7 = new ArrayList<>();
    2. @EventHandler
    3. public void onInteract7(final AsyncPlayerChatEvent event){
    4.  
    5. if(event.getPlayer().getItemInHand().getType()==Material.BOOK){
    6. Player player = event.getPlayer();
    7. final String name = player.getName();
    8. final String message = event.getMessage();
    9. if (message.trim().equalsIgnoreCase("Augue")){
    10. if (cantDoCommand7.contains(name)){
    11. event.setCancelled(true);
    12. return;
    13. }
    14. if(player.hasPermission("Venificus.Augue") || player.getPlayer().isOp()){
    15. player.launchProjectile(Fireball.class);
    16. cantDoCommand7.add(name);
    17. new BukkitRunnable(){
    18. @Override
    19. public void run(){
    20. cantDoCommand7.remove(name);
    21. }
    22. }.runTaskLater(plugin, 0);
    23. }
    24. }
    25. }
    26. }
     
  2. Offline

    turqmelon

    If you want to allow players to have a multiple spells assigned to multiple books at once, I'd modify the book's display name to the spell name. You could add some lore to the book then too, to explain what the spell does. :)

    klofno1
     
  3. Offline

    klofno1

    Thank you for the idea, but do you know how to add a /bind option to my spellbook (just 1)
     
  4. Offline

    xTrollxDudex

    klofno1
    You would modify the book's lore or something and when a player does something you would check if the book has that lore or something.
    /bind would be like adding a lore and stuff. I have no idea what "just for 1" means.
     
  5. Offline

    klofno1


    Thanks, but how do I do that. I know what I have to do, but how I must do it, I have no clue. Just one means, just one spell at the time. If you'd like to bind another spell, type /bind 'spellname' again.
     
Thread Status:
Not open for further replies.

Share This Page