Help with JOBS plugin

Discussion in 'Bukkit Help' started by ratedam, Feb 8, 2014.

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

    ratedam

    Evening,

    I'm currently building a server and i'd like to know that if with this plugin http://dev.bukkit.org/bukkit-plugins/jobs/ we could be able to do the following:

    On the mining job you wouldn't be able to mine diamond ore unless you were level 5.

    Is there any way to do it?

    Thank you :)
     
  2. Offline

    Adriani6

    It's possible actually.
    I might look into it once I finish the other plugin I'm working on at the moment.
     
  3. Offline

    ratedam

  4. Offline

    Adriani6

    Import that jar into the IDE.

    Then look at the following code (Taken from the source of the plugin):

    Code:java
    1. public static void action(JobsPlayer jPlayer, ActionInfo info, double multiplier) {
    2. List<JobProgression> progression = jPlayer.getJobProgression();
    3. int numjobs = progression.size();
    4. // no job
    5. if (numjobs == 0) {
    6. Job jobNone = Jobs.getNoneJob();
    7. if (jobNone != null) {
    8. Double income = jobNone.getIncome(info, 1, numjobs);
    9. if (income != null)
    10. Jobs.getEconomy().pay(jPlayer, income*multiplier);
    11. }
    12. } else {
    13. for (JobProgression prog : progression) {
    14. int level = prog.getLevel();
    15. Double income = prog.getJob().getIncome(info, level, numjobs);
    16. if (income != null) {
    17. Double exp = prog.getJob().getExperience(info, level, numjobs);
    18. if (ConfigManager.getJobsConfiguration().addXpPlayer()) {
    19. Player player = getServer().getPlayer(jPlayer.getName());
    20. if (player != null) {
    21. /*
    22. * Minecraft experience is calculated in whole numbers only.
    23. * Calculate the fraction of an experience point and perform a dice roll.
    24. * That way jobs that give fractions of experience points will slowly give
    25. * experience in the aggregate
    26. */
    27. int expInt = exp.intValue();
    28. double remainder = exp.doubleValue() - expInt;
    29. if (Math.abs(remainder) > Math.random()) {
    30. if (exp.doubleValue() < 0) {
    31. expInt--;
    32. } else {
    33. expInt++;
    34. }
    35. }
    36. player.giveExp(expInt);
    37. }
    38. }
    39. // give income
    40. Jobs.getEconomy().pay(jPlayer, income*multiplier);
    41. int oldLevel = prog.getLevel();
    42. if (prog.addExperience(exp*multiplier))
    43. Jobs.getPlayerManager().performLevelUp(jPlayer, prog.getJob(), oldLevel);
    44. }


    This should give a basic idea how to.
     
  5. Offline

    ratedam

Thread Status:
Not open for further replies.

Share This Page