Assassin's Creed 'Lifts'

Discussion in 'Plugin Development' started by wigax, Nov 23, 2014.

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

    wigax

    I am trying to recreate lifts from Assassin's Creed and already have this code:
    Code:java
    1. package me.Dom.Cool;
    Code:java
    1.  
    2.  
    3. [FONT=arial black]import java.util.logging.Logger;[/FONT]
    4.  
    5. [FONT=arial black]import org.bukkit.plugin.PluginDescriptionFile;[/FONT]
    6. [FONT=arial black]import org.bukkit.plugin.java.JavaPlugin;[/FONT]
    7.  
    8. [FONT=arial black]public class main extends JavaPlugin{[/FONT]
    9. [FONT=arial black] public final Logger logger = Logger.getLogger("Minecraft");[/FONT]
    10. [FONT=arial black] public static main plugin;[/FONT]
    11.  
    12. [FONT=arial black] @Override[/FONT]
    13. [FONT=arial black] public void onDisable() {[/FONT]
    14. [FONT=arial black] PluginDescriptionFile pdfFile = this.getDescription();[/FONT]
    15. [FONT=arial black] this.logger.info(pdfFile.getName() + " Has Been Disabled");[/FONT]
    16. [FONT=arial black] }[/FONT]
    17.  
    18. [FONT=arial black] @Override[/FONT]
    19. [FONT=arial black] public void onEnable() {[/FONT]
    20. [FONT=arial black] new PlayerListener(this);[/FONT]
    21. [FONT=arial black] PluginDescriptionFile pdfFile = this.getDescription();[/FONT]
    22. [FONT=arial black] this.logger.info(pdfFile.getName() + " Version " + pdfFile.getVersion() + " Has Been Enabled");[/FONT]
    23.  
    24. [FONT=arial black] }[/FONT]
    25.  
    26. [FONT=arial black]}[/FONT]
    27. [FONT=arial black][/FONT]

    And the PlayerListener
    Code:java
    1. package me.Dom.Cool;
    Code:java
    1.  
    2.  
    3. [FONT=arial black]import org.bukkit.Material;[/FONT]
    4. [FONT=arial black]import org.bukkit.entity.Player;[/FONT]
    5. [FONT=arial black]import org.bukkit.event.EventHandler;[/FONT]
    6. [FONT=arial black]import org.bukkit.event.Listener;[/FONT]
    7. [FONT=arial black]import org.bukkit.event.block.Action;[/FONT]
    8. [FONT=arial black]import org.bukkit.event.player.PlayerInteractEvent;[/FONT]
    9. [FONT=arial black]import org.bukkit.util.Vector;[/FONT]
    10.  
    11. [FONT=arial black]public class PlayerListener implements Listener{[/FONT]
    12.  
    13. [FONT=arial black] public PlayerListener(main plugin) {[/FONT]
    14. [FONT=arial black] plugin.getServer().getPluginManager().registerEvents(this, plugin);[/FONT]
    15. [FONT=arial black] }[/FONT]
    16.  
    17. [FONT=arial black] @EventHandler[/FONT]
    18. [FONT=arial black] public void playerInteract(PlayerInteractEvent e){[/FONT]
    19. [FONT=arial black] if(e.getAction().equals(Action.RIGHT_CLICK_BLOCK)){[/FONT]
    20. [FONT=arial black] if(e.getClickedBlock().getType().equals(Material.TRIPWIRE_HOOK)){[/FONT]
    21. [FONT=arial black] Player player = e.getPlayer();[/FONT]
    22. [FONT=arial black] player.setVelocity(new Vector(0,1.3,0));[/FONT]
    23. [FONT=arial black] }[/FONT]
    24. [FONT=arial black] }[/FONT]
    25.  
    26. [FONT=arial black] if(e.getAction().equals(Action.RIGHT_CLICK_BLOCK)){[/FONT]
    27. [FONT=arial black] if(e.getClickedBlock().getType().equals(Material.STONE_BUTTON)){[/FONT]
    28. [FONT=arial black] Player player = e.getPlayer();[/FONT]
    29. [FONT=arial black] player.setVelocity(new Vector(0,1,0));[/FONT]
    30. [FONT=arial black] }[/FONT]
    31. [FONT=arial black] }[/FONT]
    32.  
    33. [FONT=arial black] }[/FONT]
    34.  
    35. [FONT=arial black]}[/FONT]
    36. [FONT=arial black][/FONT]


    Just learning Java and was wondering if I could:
    A - find the first piece of string above tripwire hook (could be 4 blocks, could be 10) then use this to adjust the velocity to match the jump height.
    B - in the sky spawn a almost broken falling anvil just to the right of where the tripwire hook is pointing.

    If you need more detail please comment.
    Hope you can help,
    wigax Edit: Not sure why code font is messed up.
     
  2. Offline

    Skionz

    wigax You probably should learn Java before the Bukkit API and if you disregard this suggestion, at least stop watching youtube videos on Bukkit programming. A and B are both possible.
     
    mine-care likes this.
  3. Offline

    mine-care

    As Skionz said, please get the basic knowledge of java before starting bukkit plugin development.
    just to point some mistakes/issues that blinded me when i looked your code:
    public final Logger logger = Logger.getLogger("Minecraft"); not a good idea. Use getServer().getLogger(); instead

    You dont need to use plugin description file to print enable or disable metssages since bukkit does it by its own

    new PlayerListener(this); You are not registering event listener this way...

    if(e.getClickedBlock().getType().equals(Material.TRIPWIRE_HOOK))...
    This will produce a error if clicked item is null. (no null check)
     
    Skionz likes this.
  4. Offline

    wigax

    Okay will try and learn basic Java. Thanks for the tip ;)

    Just for now would you mind giving a basic explanation of how to use relative co-ords and block placing?
     
Thread Status:
Not open for further replies.

Share This Page