Filled Simple XP account with commands

Discussion in 'Archived: Plugin Requests' started by Plumeex, Jun 21, 2013.

  1. Offline


    Hello everyone, I tested a few plugins that provide a way to store XP, but some were buggy and others didn't suit my needs.

    Plugin category: Mechanics I guess.

    Suggested name: « XP Account » (how creative~).

    What I want: A simple plugin (I can't tell if it's simple to code, but I guess it should be a small plugin) with only a few features, because my players need to store their XP before a PVP event or stuff like that. It would act like a bank account with XP.
    It would be nice to have a file with all the accounts, so I could reset or change some player's account.
    And that's all, I don't need anything else, no trading, no signs...

    For the "interface", I thought of something like this:

    Ideas for commands:
    • /xpaShow how many XP is on the account (points & levels);
    • /xpa add <amount> [levels|points] Add x levels or x points (debited from the player's XP);
    • /xpa take <amount> [levels|points] Take x levels or x points (and add it to the player's XP);
    • /xpa <name> Show how many XP is on someone else's account (points & levels).
    Ideas for permissions:
    • xpa.useShow, add and take from the account;
    • xpa.others Show other player's account.
    Something else: Before someone asks, YES, I know there are a lot of plugins that do this but please read the beginning of my post.

    Voilà. Just a last thing: if you can make a locale file ready to be translated, it'd be perfect.

    I apologize if there are spelling mistakes, you can tell me and I'll correct.
    Thank you!
  2. Essentials has XP commands maybe you should look to it.
  3. Offline


    Thanks for your reply [email protected] but Essentials XP commands only allow to create and show other's XP, not to store it.
  4. Offline


  5. Offline


    This would be a really cool plugin to see deved! I wouldn't mind taking it on if i didn't already have a project
  6. Offline


    What about using gamerule keepInventory for pvp world?
    And you could use essentials xp commands for editing other persons xp?
  7. Offline


    I'm glad you like it Aperx, and thank you though. :)

    agowa338: Essentials XP commands allow to give, set or look at a player's XP.
    What I want is storage. And I don't use multiple worlds for events. There are others games than PVP, like Spleef, Russian Roulette, Thimble, Rainbow Fighter... you can die and loose your XP.
  8. I will try to make this.
  9. Offline


  10. Offline


    Plumeex like the sound of this. Might make one too for my server.
  11. I'm having some trouble atm, but I have asked some other developers on the forum, and soon as we have a solution it won't take long until I finished it...
  12. Offline


  13. Offline


  14. Allmost done just handling some error messages atm and tomorrow I will add the permissions.
    Plumeex likes this.
  15. Offline


    Plumeex Okies, done. Download Link:

    Details of Plugin:

    Name of Plugin: XP Account

    • /xpa show - Show how much levels or points you have in the Bank
    • /xpa show-me - Show your players levels and points
    • /xpa add <amount> [levels|points] Add x levels or x points (debited from the player's XP/Levels);
    • /xpa take <amount> [levels|points] Take x levels or x points (and add it to the player's XP/Levels);
    • /xpa player <name> Show how many XP is on someone else's account in the bank (points & levels).
    • xpa.useShow, add and take from the account;
    • xpa.others Show other player's account.
    Default permissions are for OP's only.

    Let me know if you have any issues or questions.

    Ill put this up on Bukkit Plugins
  16. Offline


    [email protected] was on it... but thanks wizzinangel.

    I have a few issues with it tough:
    • When I take some XP from my account, this happens. o_o[​IMG]
    • I can add/take levels but points are very buggy, I can't add points ("don't have enough") and when I add some in the config file (and reload), sometimes I can take sometimes I don't. (you can delete the "points" feature if you cannot fix it...)
    • You wrote "xpb" instead of "xpa" in the "Usage" messages.
    • When I take/add, if I don't write "levels" or "points", I have internal error:
      2013-06-25 13:44:18 [INFO] Plumeex issued server command: /xpa take 10
      2013-06-25 13:44:18 [SEVERE] null
      org.bukkit.command.CommandException: Unhandled exception executing command 'xpa' in plugin XPAccount v1.0
          at org.bukkit.command.PluginCommand.execute(
          at org.bukkit.command.SimpleCommandMap.dispatch(
          at org.bukkit.craftbukkit.v1_5_R3.CraftServer.dispatchCommand(
          at net.minecraft.server.v1_5_R3.PlayerConnection.handleCommand(
          at net.minecraft.server.v1_5_R3.PlayerConnection.a(
          at net.minecraft.server.v1_5_R3.Packet3Chat.handle(
          at org.spigotmc.netty.NettyNetworkManager.b(
          at net.minecraft.server.v1_5_R3.PlayerConnection.d(
          at net.minecraft.server.v1_5_R3.ServerConnection.b(SourceFile:35)
          at org.spigotmc.MultiplexingServerConnection.b(
          at net.minecraft.server.v1_5_R3.MinecraftServer.r(
          at net.minecraft.server.v1_5_R3.DedicatedServer.r(
          at net.minecraft.server.v1_5_R3.MinecraftServer.q(
      Caused by: java.lang.ArrayIndexOutOfBoundsException: 2
          at org.bukkit.command.PluginCommand.execute(
          ... 15 more
    • A few other typos... could you make a locale file so I can translate it into french?
    Thanks again, and if you made something [email protected] I'll try it too. :)
  17. Offline


    Plumeex you get that error because u haven't specified levels or points at tr end of your command. I must have uploaded the wrong file. As those errors are handled and messages are returned.

    I'll check and upload again

    Forgot to mention the XP or points is between 0 and 1. Levels are the green number.
    So points are a progressive to 1 the. It increments the level.

    Infancy it's pretty useless having the points or Xp part in this plugin. Would be better just with the levels.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 2, 2016
  18. Offline


  19. Yeah I'm also having troubles with the xp points, but how did you handle the error messages?
    And how did you return messages to the player when he was missing something?

    I think wizzinangel made the plugin at the same way I did...
  20. Offline


    It's better without points, only levels. And /xpa add | /xpa take would only need a number, not "levels" or "points" behind.

    [email protected] If you finish it I'll try it and keep my favorite.
  21. Offline


    [email protected] you check args.length. Because your command is xpa your first argument in args array is args[0]. So you check to make sure that it equals either add or take. Otherwise error back to the players. And so on.

    So an example:

    2. if ("add".equalsIgnoreCase(args[0])) {
    3. // Do stuff here
    4. } else if ("take".equalsIgnoreCase(args[0])) {
    5. //do stuff here for take command
    6. } else {
    7. //send message to player saying their command was invalid.
    8. }

    You also need to check that args[1] is an integer otherwise it will cause problems in your execution.
  22. Ok, do you know if it's possible to do something on the command /xpa
  23. Offline


    What do you mean? I think you could put that code anywhere :p.

    If you post the source to github or just upload it as an attachment I can try to help with the errors/commands.
  24. this is my source:
    Show Spoiler

    1. package com.bugs3.cracmac.XPAccount;
    3. import java.util.logging.Logger;
    5. import org.bukkit.ChatColor;
    6. import org.bukkit.command.Command;
    7. import org.bukkit.command.CommandSender;
    8. import org.bukkit.entity.Player;
    9. import org.bukkit.event.Listener;
    10. import org.bukkit.plugin.PluginDescriptionFile;
    11. import;
    13. public class XPAccount extends JavaPlugin implements Listener {
    15. public Logger log;
    16. public final Logger logger = Logger.getLogger("Minecraft");
    17. public void onEnable()
    18. {
    20. log = getLogger();
    21. PluginDescriptionFile pdfFile = this.getDescription();
    22."["+pdfFile.getName()+ "] "+pdfFile.getName()+" "+ pdfFile.getVersion() + " has been Enabled");
    23. getServer().getPluginManager().registerEvents(this, this);
    24. saveConfig();
    25. }
    26. public void onDisable(){
    27. PluginDescriptionFile pdfFile = this.getDescription();
    28."["+pdfFile.getName()+ "] "+pdfFile.getName()+" "+ pdfFile.getVersion() + " has been Disabled");
    29. saveConfig();
    30. }
    33. public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args){
    34. Player player = (Player) sender;
    35. String p = player.getName();
    36. if(command.getName().equalsIgnoreCase("xpa"))
    37. {
    38. if(args[0].equalsIgnoreCase("add")){
    39. try {
    40. Integer.parseInt(args[1]);
    41. } catch(NumberFormatException e) {
    42. player.sendMessage(ChatColor.RED + "[XP Account] Please specify a valid number of levels!");
    43. return true;
    44. }
    45. if(player.hasPermission("xpa.use")){
    47. int amount = Integer.parseInt(args[1]);
    48. int plvl = player.getLevel();
    49. int pl = plvl-amount;
    50. if(pl >= 0){
    51. player.sendMessage(ChatColor.DARK_GREEN + "[XP Account] You added " + ChatColor.WHITE + args[1] + " levels" + ChatColor.DARK_GREEN + " to your XP bank");
    52. int blvl = getConfig().getInt("XPA."+p+".LVL");
    53. int nblvl = blvl+amount;
    54. getConfig().set("XPA."+p+".LVL", nblvl);
    55. player.setLevel(pl);
    56. return true;
    57. }
    58. else{
    59. player.sendMessage(ChatColor.RED + "[XP Account] You don't have enough levels to store!");
    60. return true;
    61. }
    62. }
    63. else{
    64. player.sendMessage(ChatColor.RED + "[XP Account] You don't have permission to execute this command");
    65. return true;
    66. }
    67. }
    69. else if(args[0].equalsIgnoreCase("take")){
    70. try {
    71. Integer.parseInt(args[1]);
    72. } catch(NumberFormatException e) {
    73. player.sendMessage(ChatColor.RED + "[XP Account] Please specify a valid number of levels!");
    74. return true;
    75. }
    76. if(player.hasPermission("xpa.use")){
    77. int amount = Integer.parseInt(args[1]);
    78. int blvl = getConfig().getInt("XPA."+p+".LVL");
    79. int pl = blvl-amount;
    80. int cplvl = player.getLevel();
    81. int plevel = cplvl+amount;
    82. if(pl >= 0){
    83. player.sendMessage(ChatColor.DARK_GREEN + "[XP Account] You took " + ChatColor.WHITE + args[1] + " levels" + ChatColor.DARK_GREEN + " from your XP bank");
    84. player.setLevel(plevel);
    85. getConfig().set("XPA."+p+".LVL", pl);
    86. return true;
    87. }
    88. else{
    89. player.sendMessage(ChatColor.RED + "[XP Account] You don't have enough levels on your bank to take!");
    90. return true;
    91. }
    93. }
    94. else{
    95. player.sendMessage(ChatColor.RED + "[XP Account] You don't have permission to execute this command!");
    96. return true;
    97. }
    98. }
    99. else if(args[0].equalsIgnoreCase("player")){
    100. if(player.hasPermission("xpa.others")){
    101. int blvl = getConfig().getInt("XPA."+args[1]+".LVL");
    102. player.sendMessage(ChatColor.DARK_GREEN + "[XP Account] Levels: "+ChatColor.WHITE+ blvl);
    103. return true;
    104. }
    105. else{
    106. player.sendMessage(ChatColor.RED + "[XP Account] You don't have permission to execute this command!");
    107. return true;
    108. }
    109. }
    111. else if(args[0].equalsIgnoreCase("show")){
    112. if(player.hasPermission("xpa.use")){
    113. int blvl = getConfig().getInt("XPA."+p+".LVL");
    114. player.sendMessage(ChatColor.DARK_GREEN + "[XP Account] Levels: "+ChatColor.WHITE+ blvl);
    115. return true;
    116. }
    117. else{
    118. player.sendMessage(ChatColor.RED + "[XP Account] You don't have permission to execute this command!");
    119. return true;
    120. }
    121. }
    122. else if(args[0].equalsIgnoreCase("help")){
    123. player.sendMessage(ChatColor.GREEN + "-----------------------------------------");
    124. player.sendMessage(ChatColor.DARK_GREEN + "[XP Account] Use '/xpa add [amount]' to add levels to your XP Account");
    125. player.sendMessage(ChatColor.DARK_GREEN + "[XP Account] Use '/xpa take [amount]' to take levels from your XP Account");
    126. player.sendMessage(ChatColor.DARK_GREEN + "[XP Account] Use '/xpa show' to show your XP Account");
    127. player.sendMessage(ChatColor.DARK_GREEN + "[XP Account] Use '/xpa player [player]' to show another player XP Account");
    128. player.sendMessage(ChatColor.GREEN + "-----------------------------------------");
    129. return true;
    130. }
    131. else{
    132. player.sendMessage(ChatColor.RED + "[XP Account] Use /xpa help to check the XPA commands!");
    133. }
    134. }
    135. return false;
    136. }
    137. }

    And I want to fix the errors that I get when I type /xpa or when i type /xpa [player|take|add] without the amount
  25. Offline


    I will fix the command problems you are having and post the result soon.
  26. Ok thanks
  27. Offline


    You guys are amazing. :D
  28. Offline


  29. Offline


    Plumeex [email protected] You cannot call the Plugin 'XP Account', as I had mine up on someone reported it stating i had stole their idea.

    So I now have to find a new name for it...

    WhatTheCrafterLP Interesting isn't it. You report me because I apparently "stole" your idea. Yet here you are posting a link to your plugin that was created on 22nd June when this thread was created as well.

    Maybe we should report it as it was Plumeex's original Idea....

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 2, 2016

Share This Page