Balance Dots Plugin Help!

Discussion in 'Plugin Development' started by DuB_B_O_S, Aug 23, 2014.

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

    DuB_B_O_S

    Hey
    whats worng with this ? when i do ./bal its show me 1234567.89 ...

    Code:java
    1. package me.staticnetwork.staticbal;
    2.  
    3. import java.text.DecimalFormat;
    4.  
    5. import org.bukkit.Bukkit;
    6. import org.bukkit.ChatColor;
    7. import org.bukkit.command.Command;
    8. import org.bukkit.command.CommandSender;
    9. import org.bukkit.entity.Player;
    10. import org.bukkit.event.Listener;
    11. import org.bukkit.plugin.java.JavaPlugin;
    12.  
    13. public class StaticBal extends JavaPlugin implements Listener{
    14. public void onEnable() {
    15. Bukkit.getServer().getLogger();
    16. }
    17.  
    18. public void onDisable() {
    19. Bukkit.getServer().getLogger().info("StaticBal Plugin Disabled!");
    20. }
    21.  
    22. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    23. if (!(sender instanceof Player)) {
    24. sender.sendMessage("console is not allowed to use balance command!");
    25. return true;
    26. }
    27. double balance = 1234567.89;
    28. DecimalFormat df = new DecimalFormat("###,###,###,###,###.##");
    29. String formattedBalance = df.format(balance);
    30. Player player = (Player) sender;
    31. if (cmd.getName().equalsIgnoreCase("bal")) {
    32. player.sendMessage(ChatColor.GREEN + "Your balance: " + formattedBalance + "!");
    33. }
    34. return true;
    35. }
    36. }


    is the Prob on the Codes or?

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

    teej107

    Is that even English?

    Your code should work.
     
    Experminator and Datdenkikniet like this.
  3. Offline

    DuB_B_O_S

    teej107

    when i do ./bal is not showing the real balance
    its show me $1,234,567.89
     
  4. Offline

    teej107

    DuB_B_O_S What do you mean? Do you have your real balance stored somewhere?
     
  5. Offline

    DuB_B_O_S

    teej107

    when i do ./essentials:bal its shows me 1500
    when i do ./bal its 1,234,567.89
     
  6. Offline

    PluginMaker

    DuB_B_O_S
    Code:java
    1. double balance = 1234567.89;
    2. DecimalFormat df = new DecimalFormat("###,###,###,###,###.##");
    3. String formattedBalance = df.format(balance);

    are you seriously asking why? look at your code.
     
  7. Offline

    DuB_B_O_S

    PluginMaker

    whats is wrong ?
    im new at plugin coding so im not good at it yet
    please tell me so i can code my plugin and learn at the same ;)
     
  8. Offline

    unon1100

    You should probably learn a bit more about Java before continuing further with Bukkit, as Bukkit requires basic Java knowledge in order to use it properly. Don't feel embarrassed, there are plenty of people who think Bukkit is easier than it really is. Please watch the following Java tutorials, once you finish those, I'd be glad to help :) http://l.unon1100.com/learnJava1
     
    Darkpicasa, AdamQpzm and DuB_B_O_S like this.
  9. Offline

    ChipDev

    Simple, why did you create that balance double?
    Coincidence that they are the same.. hmm.,.
     
    Darkpicasa and AdamQpzm like this.
  10. Offline

    DuB_B_O_S

    because i suck at coding
     
  11. Offline

    AdamQpzm

    DuB_B_O_S But do you see your mistake yet? Because you've not made that clear :)
     
  12. Offline

    Darkpicasa

    Is this your first plugin?
    Also, what's the point of doing this anyways, if you want it to show the same thing that essentials' /bal command already does?
    But if you really need Essentials economy, you should look up a tutorial on Vault.
     
  13. Offline

    DuB_B_O_S

    i quit doing this so why asking?...

    and i never had 1st plugin done lol

    EDIT by Timtower: merged posts
     
  14. Offline

    Experminator

    DuB_B_O_S If you really want to make a balance plugin, i prefer to use Vault.
    And the second point: You have already balance specified, it will always be 1234567.89. It will not change in your code.

    If you want to make a balance plugin without Vault, you can use a HashMap with the Playername/UUID and a Double.
    And store the balance in a HashMap.

    But i understand it is hard to do, if you don't anything of coding. Then use the tutorials.
     
  15. Offline

    DuB_B_O_S

    i have the Plugin done so...
     
  16. Offline

    TGRHavoc

    @DuB_B_O_S
    If you have managed to do what you originally set out to do, then please tell us how you did it (for future reference for other people) and don't forget to mark the thread as "solved".
     
Thread Status:
Not open for further replies.

Share This Page