Double exp help

Discussion in 'Plugin Development' started by Vidsify, May 28, 2014.

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

    Vidsify

  2. Vidsify Were you not the one who created the plugin? So... don't you have the source code?
     
  3. Offline

    Vidsify

    DJSkepter yeah I am but I haven't actually started as I can't remember how to do it
     
  4. Vidsify
    Code:
    @EventHandler
    public void doubleExperience(PlayerExpChangeEvent e) {
        e.setAmount(e.getAmount() * 2);
    }
     
  5. Offline

    Vidsify

    Ok so who would I do it for set permissions? Like for double one perm, triple another etc?
     
  6. Vidsify
    Code:
    if(e.getPlayer().hasPermission("'Doubleurexp.multiplier.2") {
        //code
    } else if(e.getPlayer().hasPermission("'Doubleurexp.multiplier.3") {
        //code
    }
     
  7. Offline

    Vidsify

    Ok is the //code what you put before?
     
  8. Offline

    zakarls

    Vidsify
    The code is what DJSkepter put before except with the second one you would have to change the 2 in it to a 3
    This
    Code:
    e.setAmount(e.getAmount() * 2);
    to
    Code:
    e.setAmount(e.getAmount() * 3);
    That number is what you are multiplying the xp amount by
     
  9. Offline

    MordorKing78

    Just get the EXP of the player and use * 2 (2x) or * 3 (3x)
     
  10. Offline

    Vidsify

    Ok cool thanks
     
  11. Offline

    Vidsify

    Code:java
    1. package me.Vidsify.DurEXP;
    2.  
    3. import java.util.logging.Logger;
    4.  
    5. import org.bukkit.event.EventHandler;
    6. import org.bukkit.event.player.PlayerExpChangeEvent;
    7. import org.bukkit.plugin.PluginDescriptionFile;
    8. import org.bukkit.plugin.java.JavaPlugin;
    9.  
    10. public class DurEXP extends JavaPlugin {
    11.  
    12. public class Main extends JavaPlugin {
    13. public final Logger logger = Logger.getLogger("Minecraft");
    14. public DurEXP plugin;
    15.  
    16. @Override
    17. public void onDisable() {
    18. PluginDescriptionFile pdfFile = this.getDescription();
    19. this.logger.info(pdfFile.getName() + " Has been Disabled!");
    20. }
    21.  
    22. @Override
    23. public void onEnable() {
    24. PluginDescriptionFile pdfFile = this.getDescription();
    25. this.logger.info(pdfFile.getName() + " Version " + pdfFile.getVersion() + " Has been Enabled!");
    26. }
    27.  
    28. @EventHandler
    29. public void doubleExperience(PlayerExpChangeEvent e){
    30. if(e.getPlayer().hasPermission("'DoubleurEXP.multiplier.2 ")){
    31. e.setAmount(e.getAmount() * 2);
    32. }else if(e.getPlayer().hasPermission("'Doubleurexp.multiplier.3")){
    33. e.setAmount(e.getAmount() * 3);
    34.  
    35. }
    36.  
    37.  
    38.  
    39.  
    40.  
    41.  
    42.  
    43.  
    44.  
    45.  
    46.  
    47.  
    48.  
    49.  
    50.  
    51.  
    52. }
    53.  
    54.  
    55.  
    56.  
    57.  
    58.  
    59.  
    60.  
    61.  
    62.  
    63.  
    64.  
    65.  
    66. }
    67. }
    68.  

    MordorKing78 zakarls DJSkepter Is this how you would do it?

    Code:java
    1. @EventHandler
    2. public void doubleExperience1(PlayerExpChangeEvent e){
    3. if(e.getPlayer().hasPermission("'DoubleurEXP.multiplier.3 ")){
    4. e.setAmount(e.getAmount() * 3);
    5. }else if(e.getPlayer().hasPermission("")){
    6. e.setAmount(e.getAmount() * 1);}
    7.  
    8. }
    9.  
    10. @EventHandler
    11. public boolean doubleExperience2(PlayerExpChangeEvent e){
    12. if(e.getPlayer().hasPermission("'DoubleurEXP.multiplier.4 ")){
    13. e.setAmount(e.getAmount() * 4);
    14. }else {
    15. return false;
    16. }
    17. return false;

    @MordorKing78 @zakarls @DJSkepter Or would that alternatively work?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
  12. Vidsify I'd go with the first one.
     
  13. Offline

    Vidsify

Thread Status:
Not open for further replies.

Share This Page