I need help to my plugin

Discussion in 'Plugin Development' started by marcusstein, May 18, 2014.

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

    marcusstein

    Hey guys. I need help to this: When someone hits a player with their sword they will lvl up 2lvls and
    when you are mining with a pickaxe named: Iron Golem Pickaxe and the pick have some enchants, you have 50% to get iron ingot when you are mining iron ore. THIS IS ADVANCED, BUT PLEASE HELP
     
  2. Offline

    Glumpz

    marcusstein Please give some code for us to work with.
    Player.setLevel(Player.getLevel() + 2); for the first one. As for the second one just tap into the BlockBreakEvent.
     
  3. Offline

    marcusstein

    Glumpz here is my code:
    Code:java
    1. package me.marcusstein;
    2.  
    3. import org.bukkit.entity.Egg;
    4. import org.bukkit.entity.Player;
    5. import org.bukkit.entity.Snowball;
    6. import org.bukkit.event.EventHandler;
    7. import org.bukkit.event.Listener;
    8. import org.bukkit.event.entity.EntityDamageByEntityEvent;
    9. import org.bukkit.event.player.PlayerExpChangeEvent;
    10.  
    11. public class PlayerListener implements Listener{
    12.  
    13. public PlayerListener(EventHandle plugin) {
    14. plugin.getServer().getPluginManager().registerEvents(this, plugin);
    15. }
    16.  
    17. @EventHandler
    18. public void onChange(PlayerExpChangeEvent e) {
    19.  
    20. Player player = e.getPlayer();
    21.  
    22. if (player.hasPermission("SuperEvents.ThrowEXP")) {
    23. player.launchProjectile(Snowball.class);
    24. }
    25.  
    26. if (player.hasPermission("SuperEvents.ThrowEXP")) {
    27. player.launchProjectile(Egg.class);
    28. }
    29.  
    30. }
    31.  
    32. public int levelsToGain = 2;
    33. public int maxLevel = 100;
    34.  
    35. @EventHandler
    36. public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
    37.  
    38. Player attacker;
    39.  
    40. if(event.getDamager() instanceof Player) {
    41.  
    42. attacker = (Player) event.getDamager();
    43.  
    44. incrementExp(attacker);
    45. }
    46. }
    47.  
    48. public void incrementExp(Player attacker) {
    49.  
    50. if(attacker.getLevel() + levelsToGain <= maxLevel) {
    51.  
    52. attacker.setLevel(attacker.getLevel() + levelsToGain);
    53. }
    54. }
    55. }
     
  4. Offline

    marcusstein

    please help
     
  5. Offline

    NervousBrain

    just change this:
    Code:
     @EventHandler
    public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
     
    Player attacker;
     
    if(event.getDamager() instanceof Player) {
     
    attacker = (Player) event.getDamager();
     
    attacker.setLevel(attacker.getLevel() + 2)
    }
    }
     
  6. Offline

    marcusstein

    @NervausBrain how can I do the IronGolem pick thing?
     
  7. Offline

    NervousBrain

    marcusstein
    Listen on BlockBreakEvent => Check if the block, the player has broken was iron ore => Check if the tool, the player is holding was a pickaxe and named "iron pick (or whatever)" => create a random chance of an iron ingot drop
     
  8. Offline

    marcusstein

    NervousBrain Thx
     
  9. Offline

    NervousBrain

  10. Offline

    marcusstein

    NervousBrain how can I check the block the player mined was iron ore and the pick
     
  11. Offline

    NervousBrain

  12. Offline

    marcusstein

    NervousBrain
    Im not trying to be annoying but PLEASE give me a code Im new to this :(, THX SO MUCH FOR HELP
     
  13. Offline

    NervousBrain

    marcusstein
    I will not code the plugin for you. If you are not capable of coding a bukkit plugin, then you shoul propably learn basic java first.
     
Thread Status:
Not open for further replies.

Share This Page