Could someone fix this for me?

Discussion in 'Plugin Development' started by civ77, Jan 8, 2012.

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

    civ77

    I've been getting loads of null pointers and whenever I fix one another appears. If anyone would be willing to figure out what's causing these problems and/or fix it for me I would really appreciate that.
    Show Spoiler

    Code:
    //ExpBank - by Hayden
    //Created with Kickstarter
    
    package me.hayden.expbank;
    
    
    import org.bukkit.Bukkit;
    import org.bukkit.Location;
    import org.bukkit.plugin.java.JavaPlugin;
    
    import java.io.File;
    import java.util.logging.Logger;
    import java.util.HashMap;
    import org.bukkit.plugin.PluginDescriptionFile;
    import me.hayden.expbank.commands.CommandExecutor_Deposit_xp;
    import me.hayden.expbank.commands.CommandExecutor_Withdraw_xp;
    
    public class ExpBank extends JavaPlugin{
    	public Logger log;
    	private PluginDescriptionFile description;
    
    	private String prefix;
    	public double config_bankxcoord = 0;
    	public double config_bankycoord = 64;
    	public double config_bankzcoord = 0;
    	public String config_bankworld = "world";
    	public  Location BankLoc;
    	public HashMap<String,Integer> ExpBankAccs = new HashMap<String,Integer>();
    	@Override
    	public void onEnable(){
    		log = Logger.getLogger("Minecraft");
    		description = getDescription();
    		prefix = "["+description.getName()+"] ";
    		File savefile = new File("plugins/ExpBank/save.dat");
            boolean exists = savefile.exists();
            if(exists){
            	try {
    				ExpBankAccs = (HashMap<String,Integer>)SLAPI.load("plugins/ExpBank/save.dat");
    			} catch (Exception e) {
    				log.severe("!!!failed to load ExpBank accounts!!!");
    				e.printStackTrace();
    			}
            }
    		log.info("loading "+description.getFullName());
    
    
    		Location BankLoc = new Location(Bukkit.getWorld(config_bankworld),config_bankxcoord,config_bankycoord,config_bankzcoord) ;
    
    		getCommand("deposit_xp").setExecutor(new CommandExecutor_Deposit_xp(this));
    		getCommand("withdraw_xp").setExecutor(new CommandExecutor_Withdraw_xp(this));
    
    
    	}
    	@Override
    	public void onDisable(){
    		log.info("disabled "+description.getFullName());
    		try {
    			SLAPI.save(ExpBankAccs,"plugins/ExpBank/save.dat");
    		} catch (Exception e) {
    			log.severe("!!!failed to save ExpBank accounts!!!");
    			e.printStackTrace();
    		}
    
    	}
    
    }
    Code:
    package me.hayden.expbank;
    
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.ObjectInputStream;
    import java.io.ObjectOutputStream;
    
    /** SLAPI = Saving/Loading API
     * API for Saving and Loading Objects.
     * @author Tomsik68
     */
    public class SLAPI
    {
    	public static void save(Object obj,String path) throws Exception
    	{
    		ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(path));
    		oos.writeObject(obj);
    		oos.flush();
    		oos.close();
    	}
    	public static Object load(String path) throws Exception
    	{
    		ObjectInputStream ois = new ObjectInputStream(new FileInputStream(path));
    		Object result = ois.readObject();
    		ois.close();
    		return result;
    	}
    }
    Code:
    /*
     * ExpBank - by Hayden
     *
     *
     * powered by Kickstarter
     */
    
    package me.hayden.expbank.commands;
    
    
    import org.bukkit.Bukkit;
    import org.bukkit.command.Command;
    import org.bukkit.entity.*;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import me.hayden.expbank.ExpBank;
    
    
    public class CommandExecutor_Deposit_xp implements CommandExecutor {
    	private ExpBank plugin;
    
    	public CommandExecutor_Deposit_xp(ExpBank plugin){
    		this.plugin = plugin;
    	}
    
    	@Override
    	public boolean onCommand(CommandSender sender, Command command,String label, String[] args) {
    		if (command.getName().equalsIgnoreCase("deposit_xp")) {
    			int xp = 0;
    			int storedXp = 0;
    			Player client = (Player) sender;
    	double x1=1337, x2=1337, y1=1337, y2=1337, z1=1337, z2=1337;
    	x2 =plugin.config_bankxcoord;
    	y2 =plugin.config_bankycoord;
    	z2 =plugin.config_bankzcoord;
    	x1 = client.getLocation().getX();
    	y1 = client.getLocation().getY();
    	z1 = client.getLocation().getZ();
    	double distance = Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2) + Math.pow(z1 - z2, 2));
    			if (!(sender instanceof Player)) {
    				sender.sendMessage("This command is only applicable to players.");
    				return true;
    			}
    if(sender instanceof Player){
    	if(plugin.ExpBankAccs.get(client.getPlayerListName()).equals(null)){
    		plugin.ExpBankAccs.put(client.getPlayerListName(), 0);
    	}
    	if(client.getLocation() == null){
    		plugin.log.info("DEBUG:Client location was null!");
    		return true;
    	}
    	if(client.getWorld()==Bukkit.getWorld(plugin.config_bankworld)){
    	if(distance<= 3){
    	xp = client.getTotalExperience();
    	client.setTotalExperience(0);
    		storedXp = plugin.ExpBankAccs.get(client.getPlayerListName());
    		plugin.ExpBankAccs.put(client.getPlayerListName(),storedXp + xp);
    	}
    	else{
    		sender.sendMessage("Please go to the bank.");
    	}
    	}
    	else{
    		sender.sendMessage("Please go to the bank.");
    	}
    }
    	}
    return false;}
    
    }
    Code:
    /*
     * ExpBank - by Hayden
     *
     *
     * powered by Kickstarter
     */
    
    package me.hayden.expbank.commands;
    
    
    import org.bukkit.Bukkit;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    
    import me.hayden.expbank.ExpBank;
    
    
    public class CommandExecutor_Withdraw_xp implements CommandExecutor {
    	private ExpBank plugin;
    
    	public CommandExecutor_Withdraw_xp(ExpBank plugin){
    		this.plugin = plugin;
    	}
    
    	@Override
    	public boolean onCommand(CommandSender sender, Command command,String label, String[] args) {
    		if (command.getName().equalsIgnoreCase("withdraw_xp")) {
    			if (command.getName().equalsIgnoreCase("deposit_xp")) {
    				int xp = 0;
    				int storedXp = 0;
    				Player client = (Player) sender;
    		double x1=1337, x2=1337, y1=1337, y2=1337, z1=1337, z2=1337;
    		x2 =plugin.config_bankxcoord;
    		y2 =plugin.config_bankycoord;
    		z2 =plugin.config_bankzcoord;
    		x1 = client.getLocation().getX();
    		y1 = client.getLocation().getY();
    		z1 = client.getLocation().getZ();
    		double distance = Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2) + Math.pow(z1 - z2, 2));
    				if (!(sender instanceof Player)) {
    					sender.sendMessage("This command is only applicable to players.");
    					return true;
    				}
    	if(sender instanceof Player){
    		if(plugin.ExpBankAccs.get(client.getPlayerListName()).equals(null)){
    			plugin.ExpBankAccs.put(client.getPlayerListName(), 0);
    		}
    		if(client.getLocation() == null){
    			plugin.log.info("DEBUG:Client location was null!");
    			return true;
    		}
    		if(client.getWorld()==Bukkit.getWorld(plugin.config_bankworld)){
    		if(distance<= 3){
    		xp = client.getTotalExperience();
    			storedXp = plugin.ExpBankAccs.get(client.getPlayerListName());
    		client.setTotalExperience(xp + storedXp);
    			plugin.ExpBankAccs.put(client.getPlayerListName(),0);
    		}
    		else{
    			sender.sendMessage("Please go to the bank.");
    		}
    		}
    		else{
    			sender.sendMessage("Please go to the bank.");
    		}
    	}
    		}
    	return false;}
    		return false;
    	}
    }
    

    Stack Trace:
    Show Spoiler

    Code:
    2012-01-08 21:03:32 [INFO] Starting minecraft server version 1.0.1
    2012-01-08 21:03:32 [WARNING] **** NOT ENOUGH RAM!
    2012-01-08 21:03:32 [WARNING] To start the server with more ram, launch it as "java -Xmx1024M -Xms1024M -jar minecraft_server.jar"
    2012-01-08 21:03:32 [INFO] Loading properties
    2012-01-08 21:03:32 [INFO] Starting Minecraft server on *:25565
    2012-01-08 21:03:33 [INFO] This server is running Craftbukkit version git-Bukkit-1.0.1-R1-b1597jnks (MC: 1.0.1) (Implementing API version 1.0.1-R1)
    2012-01-08 21:03:33 [INFO] [Register] Preferred method [null] not found, using first found.
    2012-01-08 21:03:33 [INFO] [Register] version 1.5 is enabled.
    2012-01-08 21:03:33 [INFO] Preparing level "world"
    2012-01-08 21:03:33 [INFO] Default game type: 0
    2012-01-08 21:03:33 [INFO] Preparing start region for level 0 (Seed: -6079654219287449295)
    2012-01-08 21:03:34 [INFO] Preparing start region for level 1 (Seed: -6079654219287449295)
    2012-01-08 21:03:34 [INFO] Preparing spawn area: 20%
    2012-01-08 21:03:34 [INFO] Preparing start region for level 2 (Seed: -6079654219287449295)
    2012-01-08 21:03:35 [INFO] Preparing spawn area: 85%
    2012-01-08 21:03:35 [INFO] loading ExpBank v0.1
    2012-01-08 21:03:35 [INFO] Server permissions file permissions.yml is empty, ignoring it
    2012-01-08 21:03:35 [INFO] Done (0.224s)! For help, type "help" or "?"
    2012-01-08 21:03:41 [INFO] civ77 [/127.0.0.1:49388] logged in with entity id 191 at ([world] -0.53125, 63.0, -0.625)
    2012-01-08 21:03:52 [SEVERE] null
    org.bukkit.command.CommandException: Unhandled exception executing command 'deposit_xp' in plugin ExpBank v0.1
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:42)
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:165)
        at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:378)
        at net.minecraft.server.NetServerHandler.handleCommand(NetServerHandler.java:757)
        at net.minecraft.server.NetServerHandler.chat(NetServerHandler.java:722)
        at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:715)
        at net.minecraft.server.Packet3Chat.a(Packet3Chat.java:33)
        at net.minecraft.server.NetworkManager.b(NetworkManager.java:226)
        at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:93)
        at net.minecraft.server.NetworkListenThread.a(SourceFile:108)
        at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:527)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:425)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:457)
    Caused by: java.lang.NullPointerException
        at me.hayden.expbank.commands.CommandExecutor_Deposit_xp.onCommand(CommandExecutor_Deposit_xp.java:45)
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:40)
        ... 12 more
    2012-01-08 21:03:55 [INFO] Connection reset
    2012-01-08 21:03:55 [INFO] civ77 lost connection: disconnect.quitting
    
     
  2. Would really help to see the stacktrace...
     
  3. Offline

    civ77

    I added it.
     
  4. at me.hayden.expbank.commands.CommandExecutor_Deposit_xp.onCommand(CommandExecutor_Deposit_xp.java:45)
    We need to see that class... ;)
     
  5. Offline

    civ77

    It's in the third code of the first spoiler.
     
    V10lator likes this.
  6. Sorry, I missed that. :(

    Try:
    • Check if SLAPI.load("plugins/ExpBank/save.dat") returns null (ExpBank.java:38)
    • if(!plugin.ExpBankAccs.containsKey(client.getPlayerListName()){ (CommandExecutor_Deposit_xp.java:45)
    Also, why do you use the ListName? It can change! You should just use the name (client.getName()).
     
  7. Offline

    Zimp

    The following doesn't look right, you should be using '==' to compare it to null.

    Also, this should probably be at the top of the function:

     
  8. Offline

    civ77

    1.How?
    2.I didn't know list name could change TY
    1.Changed.
    2.okay changed that.
     
  9. Code:java
    1. if(exists){
    2. try {
    3. ExpBankAccs = (HashMap<String,Integer>)SLAPI.load("plugins/ExpBank/save.dat");
    4. if(ExpBankAccs == null)
    5. {
    6. // !!! ERROR !!!
    7. }
    8. } catch (Exception e)

    NP, but that wasn't 2., 2. was:
    ;)
     
  10. Offline

    civ77

    now the command isn't being recognized...
     
  11. ? Could you be a bit more specific? (But the error is gone? That's a step in the right direction)
     
  12. Offline

    civ77

    yes exactly that. i suspect the error is still there and I am having a problem exporting the jar, let me just try this again.

    Okay, now the command is recognized when used from the console and it replies just as it should, but when I use it as a player (typing /deposit_xp) I say "/depositxp" in the chat, with no errors showing in the console.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 23, 2016
  13. So it doesn't reply anything? Please show me the updated class.
     
  14. Offline

    civ77

    Show Spoiler

    Code:
    //ExpBank - by Hayden
    //Created with Kickstarter
     
    
    package me.hayden.expbank;
    
    
    import org.bukkit.Bukkit;
    import org.bukkit.Location;
    import org.bukkit.plugin.java.JavaPlugin;
    
    import java.io.File;
    import java.util.logging.Logger;
    import java.util.HashMap;
    import org.bukkit.plugin.PluginDescriptionFile;
    import me.hayden.expbank.commands.CommandExecutor_Deposit_xp;
    import me.hayden.expbank.commands.CommandExecutor_Withdraw_xp;
    
    public class ExpBank extends JavaPlugin{
        public Logger log;
        private PluginDescriptionFile description;
    
        private String prefix;
        public double config_bankxcoord = 0;
        public double config_bankycoord = 64;
        public double config_bankzcoord = 0;
        public String config_bankworld = "world";
        public  Location BankLoc;
        public HashMap<String,Integer> ExpBankAccs = new HashMap<String,Integer>();
        @Override
        public void onEnable(){
            log = Logger.getLogger("Minecraft");
            description = getDescription();
            prefix = "["+description.getName()+"] ";
            File savefile = new File("plugins/ExpBank/save.dat");
            boolean exists = savefile.exists();
            if(exists){
                try {
                    ExpBankAccs = (HashMap<String,Integer>)SLAPI.load("plugins/ExpBank/save.dat");
                } catch (Exception e) {
                    log.severe("!!!failed to load ExpBank accounts!!!");
                    e.printStackTrace();
                }
                
            }
            log.info("loading "+description.getFullName());
    
    
            Location BankLoc = new Location(Bukkit.getWorld(config_bankworld),config_bankxcoord,config_bankycoord,config_bankzcoord) ;
            
    
            
            getCommand("deposit_xp").setExecutor(new CommandExecutor_Deposit_xp(this));
            getCommand("withdraw_xp").setExecutor(new CommandExecutor_Withdraw_xp(this));
    
            
    
        }
        
        @Override
        public void onDisable(){
            log.info("disabled "+description.getFullName());
            try {
                SLAPI.save(ExpBankAccs,"plugins/ExpBank/save.dat");
            } catch (Exception e) {
                log.severe("!!!failed to save ExpBank accounts!!!");
                e.printStackTrace();
            }
    
        }
    
        
    }
    
    Code:
    /*
     * ExpBank - by Hayden
     * 
     *
     * powered by Kickstarter
     */
    
    package me.hayden.expbank.commands;
    
    
    import org.bukkit.Bukkit;
    import org.bukkit.command.Command;
    import org.bukkit.entity.*;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import me.hayden.expbank.ExpBank;
    
    
    public class CommandExecutor_Deposit_xp implements CommandExecutor {
        private ExpBank plugin;
    
        public CommandExecutor_Deposit_xp(ExpBank plugin){
            this.plugin = plugin;
        }
    
        @Override
        public boolean onCommand(CommandSender sender, Command command,String label, String[] args) {
            if (command.getName().equalsIgnoreCase("deposit_xp")) {
                            if (!(sender instanceof Player)) {
                    sender.sendMessage("This command is only applicable to players.");
                    return true;
                }
                int xp = 0;
                int storedXp = 0;
                Player client = (Player) sender;
        double x1=1337, x2=1337, y1=1337, y2=1337, z1=1337, z2=1337;
        x2 =plugin.config_bankxcoord;
        y2 =plugin.config_bankycoord;
        z2 =plugin.config_bankzcoord;
        x1 = client.getLocation().getX();
        y1 = client.getLocation().getY();
        z1 = client.getLocation().getZ();
        double distance = Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2) + Math.pow(z1 - z2, 2));
    
    if(sender instanceof Player){
        if(plugin.ExpBankAccs.get(client.getName()) == (null)){
            plugin.ExpBankAccs.put(client.getName(), 0);
        }
        if(client.getLocation() == null){
            plugin.log.info("DEBUG:Client location was null!");
            return true;
        }
            
        if(client.getWorld()==Bukkit.getWorld(plugin.config_bankworld)){
        if(distance<= 3){
        xp = client.getTotalExperience();
        client.setTotalExperience(0);
            storedXp = plugin.ExpBankAccs.get(client.getName());
            plugin.ExpBankAccs.put(client.getName(),storedXp + xp);
        }
        else{
            sender.sendMessage("Please go to the bank.");
        }
        }
        else{
            sender.sendMessage("Please go to the bank.");
        }
    }        
        }
        
    return false;}
    
    }
     
  15. try this:
    Code:java
    1. /*
    2.  * ExpBank - by Hayden
    3.  *
    4.  *
    5.  * powered by Kickstarter
    6.  */
    7.  
    8. package me.hayden.expbank.commands;
    9.  
    10.  
    11. import org.bukkit.Bukkit;
    12. import org.bukkit.command.Command;
    13. import org.bukkit.entity.*;
    14. import org.bukkit.command.CommandExecutor;
    15. import org.bukkit.command.CommandSender;
    16. import me.hayden.expbank.ExpBank;
    17.  
    18.  
    19. public class CommandExecutor_Deposit_xp implements CommandExecutor {
    20. private ExpBank plugin;
    21.  
    22. public CommandExecutor_Deposit_xp(ExpBank plugin){
    23. this.plugin = plugin;
    24. }
    25.  
    26. @Override
    27. public boolean onCommand(CommandSender sender, Command command,String label, String[] args) {
    28. if (command.getName().equalsIgnoreCase("deposit_xp")) {
    29. if (!(sender instanceof Player)) {
    30. sender.sendMessage("This command is only applicable to players.");
    31. return true;
    32. }
    33. int xp = 0;
    34. int storedXp = 0;
    35. Player client = (Player) sender;
    36. double x1=1337, x2=1337, y1=1337, y2=1337, z1=1337, z2=1337;
    37. x2 =plugin.config_bankxcoord;
    38. y2 =plugin.config_bankycoord;
    39. z2 =plugin.config_bankzcoord;
    40. x1 = client.getLocation().getX();
    41. y1 = client.getLocation().getY();
    42. z1 = client.getLocation().getZ();
    43. double distance = Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2) + Math.pow(z1 - z2, 2));
    44. plugin.log.info("DEBUG: Starting command...");
    45. if(plugin.ExpBankAccs.get(client.getName()) == (null)){
    46. plugin.ExpBankAccs.put(client.getName(), 0);
    47. plugin.log.info("DEBUG: New Bank account created...");
    48. }
    49. f(client.getLocation() == null){
    50. plugin.log.info("DEBUG:Client location was null!");
    51. return true;
    52. }
    53. if(client.getWorld()==Bukkit.getWorld(plugin.config_bankworld)){
    54. plugin.log.info("DEBUG: User in bank world...");
    55. if(distance<= 3){
    56. plugin.log.info("DEBUG: Updating experience...");
    57. xp = client.getTotalExperience();
    58. client.setTotalExperience(0);
    59. storedXp = plugin.ExpBankAccs.get(client.getName());
    60. plugin.ExpBankAccs.put(client.getName(),storedXp + xp);
    61. sender.sendMessage("Your experience was updated!");
    62. }
    63. else{
    64. sender.sendMessage("Please go to the bank.");
    65. plugin.log.info("DEBUG: User to far away...");
    66. }
    67. }
    68. else{
    69. sender.sendMessage("Please go to the bank.");
    70. plugin.log.info("DEBUG: User not in bank world...");
    71. }
    72. }
    73. }

    and have a look at the DEBUG: lines in your server log!
     
    civ77 likes this.
  16. Offline

    civ77

    I'm now getting a strange problem, my DEBUG is just as you'd expect but the players experience is never actually changing.
    New code:
    Code:java
    1. /*
    2.   * ExpBank - by Hayden
    3.   *
    4.   *
    5.   * powered by Kickstarter
    6.   */
    7.  
    8. package me.hayden.expbank.commands;
    9.  
    10.  
    11. import org.bukkit.Bukkit;
    12. import org.bukkit.command.Command;
    13. import org.bukkit.entity.*;
    14. import org.bukkit.command.CommandExecutor;
    15. import org.bukkit.command.CommandSender;
    16. import me.hayden.expbank.ExpBank;
    17.  
    18.  
    19. public class CommandExecutor_Deposit_xp implements CommandExecutor {
    20. private ExpBank plugin;
    21.  
    22. public CommandExecutor_Deposit_xp(ExpBank plugin){
    23. this.plugin = plugin;
    24. }
    25.  
    26. @Override
    27. public boolean onCommand(CommandSender sender, Command command,String label, String[] args) {
    28. if (command.getName().equalsIgnoreCase("deposit_xp")) {
    29. if (!(sender instanceof Player)) {
    30. sender.sendMessage("This command is only applicable to players.");
    31. return true;
    32. }
    33. int xp = 0;
    34. int storedXp = 0;
    35. Player client = (Player) sender;
    36. double x1=1337, x2=1337, y1=1337, y2=1337, z1=1337, z2=1337;
    37. x2 =plugin.config_bankxcoord;
    38. y2 =plugin.config_bankycoord;
    39. z2 =plugin.config_bankzcoord;
    40. x1 = client.getLocation().getX();
    41. y1 = client.getLocation().getY();
    42. z1 = client.getLocation().getZ();
    43. double distance = Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2) + Math.pow(z1 - z2, 2));
    44. plugin.log.info("DEBUG: Starting command...");
    45. if(plugin.ExpBankAccs.get(client.getName()) == (null)){
    46. plugin.ExpBankAccs.put(client.getName(), 0);
    47. plugin.log.info("DEBUG: New Bank account created...");
    48. }
    49. if(client.getLocation() == null){
    50. plugin.log.info("DEBUG:Client location was null!");
    51. return true;
    52. }
    53. if(client.getWorld()==Bukkit.getWorld(plugin.config_bankworld)){
    54. plugin.log.info("DEBUG: User in bank world...");
    55. if(distance<= 3){
    56. plugin.log.info("DEBUG: Updating experience...");
    57. xp = client.getTotalExperience();
    58. plugin.log.info("DEBUG: User has " + xp + "Xp");
    59. client.setTotalExperience(0);
    60. storedXp = plugin.ExpBankAccs.get(client.getName());
    61. plugin.log.info("DEBUG: User has " + storedXp + "Stored Xp");
    62. plugin.ExpBankAccs.put(client.getName(),storedXp + xp);
    63. plugin.log.info("DEBUG: User now has " + plugin.ExpBankAccs.get(client.getName()) + "Stored Xp");
    64. sender.sendMessage("Your experience was updated!");
    65. }
    66. else{
    67. sender.sendMessage("Please go to the bank.");
    68. plugin.log.info("DEBUG: User to far away...");
    69. }
    70. }
    71. else{
    72. sender.sendMessage("Please go to the bank.");
    73. plugin.log.info("DEBUG: User not in bank world...");
    74. }
    75. }
    76. return false;
    77. }
    78. }


    Edit: and although the command is being recognized when the player uses it "/depositxp" still appears in the chat.
     
  17. The only line which changes the players XP is this:
    client.setTotalExperience(0);
    I think you want:
    client.setTotalExperience(xp);

    and set return false to return true.
     
  18. Offline

    civ77

    turns out setTotalExperience() is bugged and doesn't work.
     
Thread Status:
Not open for further replies.

Share This Page