How can i add money using VAULT

Discussion in 'Plugin Development' started by Chintzi, Nov 15, 2014.

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

    Chintzi

    Hey so i have looked at some posts about it but i really don't understand it and i was wondering if someone could help me understand it more. I have been developing for about 1 month now and i am getting to know it quiet a bit but i haven't worked with economy at all and i would really like to add it to my plugin SkieCraft because i know i could do a lot more things knowing i can add money

    Heres my code: (Sorry if its messy btw :p)

    Code:java
    1. package net.wrightnz.minecraft.skiecraft.commands;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.Color;
    6. import org.bukkit.FireworkEffect;
    7. import org.bukkit.FireworkEffect.Type;
    8. import org.bukkit.Material;
    9. import org.bukkit.command.Command;
    10. import org.bukkit.command.CommandSender;
    11. import org.bukkit.enchantments.Enchantment;
    12. import org.bukkit.entity.Firework;
    13. import org.bukkit.entity.Player;
    14. import org.bukkit.inventory.ItemStack;
    15. import org.bukkit.inventory.meta.FireworkMeta;
    16. import org.bukkit.inventory.meta.ItemMeta;
    17.  
    18. public class CakeCommand extends SkieCraftCommand {
    19.  
    20. static final String commandName = "cake";
    21.  
    22. public CakeCommand(CommandSender sender, Command cmd, String[] args) {
    23. super(sender, cmd, commandName, args);
    24. }
    25.  
    26. @Override
    27. public void runCommand() {
    28. if (args.length == 1 && args[0].equalsIgnoreCase("all")) {
    29. if (sender instanceof Player) {
    30. Player player = (Player) sender;
    31. for (Player players : Bukkit.getOnlinePlayers()) {
    32.  
    33. //Cake Item
    34. ItemStack cake = new ItemStack(Material.CAKE, 1);
    35. ItemMeta cakeMeta = cake.getItemMeta();
    36. cakeMeta.setDisplayName(
    37. ChatColor.DARK_BLUE + "T" + ChatColor.BLUE + "h" + ChatColor.DARK_GREEN + "e "
    38. + ChatColor.GREEN + "M" + ChatColor.DARK_AQUA + "a" + ChatColor.AQUA + "j" + ChatColor.DARK_RED + "e" + ChatColor.RED + "s" + ChatColor.DARK_PURPLE + "t" + ChatColor.LIGHT_PURPLE + "i" + ChatColor.GOLD + "c "
    39. + ChatColor.YELLOW + "C" + ChatColor.BLUE + "a" + ChatColor.DARK_BLUE + "k" + ChatColor.DARK_GREEN + "e" + ChatColor.GREEN + "! " + ChatColor.LIGHT_PURPLE + "❤");
    40. cake.setItemMeta(cakeMeta);
    41.  
    42. //Enchantments
    43. cake.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 5);
    44. cake.addUnsafeEnchantment(Enchantment.ARROW_FIRE, 1);
    45. cake.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1);
    46. cake.addUnsafeEnchantment(Enchantment.ARROW_KNOCKBACK, 2);
    47. cake.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 5);
    48. cake.addUnsafeEnchantment(Enchantment.DAMAGE_ARTHROPODS, 5);
    49. cake.addUnsafeEnchantment(Enchantment.DAMAGE_UNDEAD, 5);
    50. cake.addUnsafeEnchantment(Enchantment.DIG_SPEED, 5);
    51. cake.addUnsafeEnchantment(Enchantment.DURABILITY, 3);
    52. cake.addUnsafeEnchantment(Enchantment.FIRE_ASPECT, 2);
    53. cake.addUnsafeEnchantment(Enchantment.KNOCKBACK, 2);
    54. cake.addUnsafeEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 3);
    55. cake.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 3);
    56. cake.addUnsafeEnchantment(Enchantment.LUCK, 3);
    57. cake.addUnsafeEnchantment(Enchantment.LURE, 3);
    58.  
    59. //Giving the player item 'CAKE'
    60. players.getInventory().addItem(cake);
    61. sender.sendMessage(ChatColor.BLUE + "Party> "
    62. + ChatColor.GRAY + "We all love cake don't you? If your feeling sad eat some "
    63. + ChatColor.AQUA + "Cake"
    64. + ChatColor.GRAY + "!");
    65.  
    66. Firework firework = (Firework) players.getWorld().spawn(players.getLocation(), Firework.class);
    67. FireworkMeta fireworkMeta = firework.getFireworkMeta();
    68. FireworkEffect effect = FireworkEffect.builder()
    69. .flicker(true)
    70. .withColor(Color.AQUA)
    71. .withFade(Color.NAVY)
    72. .with(Type.BALL_LARGE)
    73. .trail(true)
    74. .build();
    75.  
    76. fireworkMeta.addEffect(effect);
    77. fireworkMeta.setPower(0);
    78.  
    79. firework.setFireworkMeta(fireworkMeta);
    80. }
    81. }
    82. } else if (args.length == 1 && args[0].equalsIgnoreCase("me")) {
    83. Player player = (Player) sender;
    84.  
    85. //Cake Item
    86. ItemStack cake = new ItemStack(Material.CAKE, 1);
    87. ItemMeta cakeMeta = cake.getItemMeta();
    88. cakeMeta.setDisplayName(
    89. ChatColor.DARK_BLUE + "T" + ChatColor.BLUE + "h" + ChatColor.DARK_GREEN + "e "
    90. + ChatColor.GREEN + "M" + ChatColor.DARK_AQUA + "a" + ChatColor.AQUA + "j" + ChatColor.DARK_RED + "e" + ChatColor.RED + "s" + ChatColor.DARK_PURPLE + "t" + ChatColor.LIGHT_PURPLE + "i" + ChatColor.GOLD + "c "
    91. + ChatColor.YELLOW + "C" + ChatColor.BLUE + "a" + ChatColor.DARK_BLUE + "k" + ChatColor.DARK_GREEN + "e" + ChatColor.GREEN + "! " + ChatColor.LIGHT_PURPLE + "❤");
    92. cake.setItemMeta(cakeMeta);
    93.  
    94. //Enchantments
    95. cake.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 5);
    96. cake.addUnsafeEnchantment(Enchantment.ARROW_FIRE, 1);
    97. cake.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1);
    98. cake.addUnsafeEnchantment(Enchantment.ARROW_KNOCKBACK, 2);
    99. cake.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 5);
    100. cake.addUnsafeEnchantment(Enchantment.DAMAGE_ARTHROPODS, 5);
    101. cake.addUnsafeEnchantment(Enchantment.DAMAGE_UNDEAD, 5);
    102. cake.addUnsafeEnchantment(Enchantment.DIG_SPEED, 5);
    103. cake.addUnsafeEnchantment(Enchantment.DURABILITY, 3);
    104. cake.addUnsafeEnchantment(Enchantment.FIRE_ASPECT, 2);
    105. cake.addUnsafeEnchantment(Enchantment.KNOCKBACK, 2);
    106. cake.addUnsafeEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 3);
    107. cake.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 3);
    108. cake.addUnsafeEnchantment(Enchantment.LUCK, 3);
    109. cake.addUnsafeEnchantment(Enchantment.LURE, 3);
    110.  
    111. //Giving the player item 'CAKE'
    112. player.getInventory().addItem(cake);
    113. sender.sendMessage(ChatColor.BLUE + "Party> "
    114. + ChatColor.GRAY + "We all love cake don't you? If your feeling sad eat some "
    115. + ChatColor.AQUA + "Cake"
    116. + ChatColor.GRAY + "!");
    117.  
    118. Firework firework = (Firework) player.getWorld().spawn(player.getLocation(), Firework.class);
    119. FireworkMeta fireworkMeta = firework.getFireworkMeta();
    120. FireworkEffect effect = FireworkEffect.builder()
    121. .flicker(true)
    122. .withColor(Color.AQUA)
    123. .withFade(Color.NAVY)
    124. .with(Type.BALL_LARGE)
    125. .trail(true)
    126. .build();
    127.  
    128. fireworkMeta.addEffect(effect);
    129. fireworkMeta.setPower(0);
    130.  
    131. firework.setFireworkMeta(fireworkMeta);
    132. } else {
    133. sender.sendMessage(ChatColor.BLUE + "Party> "
    134. + ChatColor.AQUA + "/cake "
    135. + ChatColor.GRAY + "me, all");
    136. sender.sendMessage(ChatColor.BLUE + "Usage> " + ChatColor.AQUA + "<me:all>");
    137. }
    138. }
    139. }
     
  2. Offline

    JordyPwner

    Chintzi

    Code:java
    1. EconomyResponse er = Main.economy.depositPlayer(player.getName(), <amount>);
    2. if(er.transactionSuccess()){
    3. //do stuff
     
  3. Offline

    Chintzi

    w0w you answered fast :D thanks but it wont work D:
     
  4. Offline

    JordyPwner

    Tell me why it wont work?
     
  5. Offline

    Chintzi

    When i put in the code below it says:

    Illegal Start or expression and that it cant find variable 'economy'

    Code:java
    1. } else if (args.length == 1 && args[0].equalsIgnoreCase("me")) {
    2. Player player = (Player) sender;
    3. EconomyResponse er = Main.economy.withdrawPlayer(player.getName(), <amount>);
    4. if(er.transactionSuccess()){
     
  6. Offline

    JordyPwner

    Since i used this in a different class u can try:
    Code:java
    1. EconomyResponse er = economy.depositPlayer(player.getName(), <amount>);
    2. if(er.transactionSuccess()){
    3. //do stuff


    or
    Code:java
    1. EconomyResponse er = Economy.depositPlayer(player.getName(), <amount>);
    2. if(er.transactionSuccess()){
    3. //do stuff
     
  7. Offline

    Chintzi

    Still wont work D:
     
  8. Offline

    JordyPwner

    Code?
     
  9. Offline

    Chintzi

    K so this is the code i have now and everything is fine its just the

    Code:java
    1. package net.wrightnz.minecraft.skiecraft.commands;
    2.  
    3. import net.milkbowl.vault.economy.EconomyResponse;
    4. import org.bukkit.Bukkit;
    5. import org.bukkit.ChatColor;
    6. import org.bukkit.Color;
    7. import org.bukkit.FireworkEffect;
    8. import org.bukkit.FireworkEffect.Type;
    9. import org.bukkit.Material;
    10. import org.bukkit.command.Command;
    11. import org.bukkit.command.CommandSender;
    12. import org.bukkit.enchantments.Enchantment;
    13. import org.bukkit.entity.Firework;
    14. import org.bukkit.entity.Player;
    15. import org.bukkit.inventory.ItemStack;
    16. import org.bukkit.inventory.meta.FireworkMeta;
    17. import org.bukkit.inventory.meta.ItemMeta;
    18.  
    19. public class CakeCommand extends SkieCraftCommand {
    20.  
    21. static final String commandName = "cake";
    22.  
    23. public CakeCommand(CommandSender sender, Command cmd, String[] args) {
    24. super(sender, cmd, commandName, args);
    25. }
    26.  
    27. @Override
    28. public void runCommand() {
    29. if (args.length == 1 && args[0].equalsIgnoreCase("all")) {
    30. if (sender instanceof Player) {
    31. Player player = (Player) sender;
    32. for (Player players : Bukkit.getOnlinePlayers()) {
    33.  
    34. //Cake Item
    35. ItemStack cake = new ItemStack(Material.CAKE, 1);
    36. ItemMeta cakeMeta = cake.getItemMeta();
    37. cakeMeta.setDisplayName(
    38. ChatColor.DARK_BLUE + "T" + ChatColor.BLUE + "h" + ChatColor.DARK_GREEN + "e "
    39. + ChatColor.GREEN + "M" + ChatColor.DARK_AQUA + "a" + ChatColor.AQUA + "j" + ChatColor.DARK_RED + "e" + ChatColor.RED + "s" + ChatColor.DARK_PURPLE + "t" + ChatColor.LIGHT_PURPLE + "i" + ChatColor.GOLD + "c "
    40. + ChatColor.YELLOW + "C" + ChatColor.BLUE + "a" + ChatColor.DARK_BLUE + "k" + ChatColor.DARK_GREEN + "e" + ChatColor.GREEN + "! " + ChatColor.LIGHT_PURPLE + "❤");
    41. cake.setItemMeta(cakeMeta);
    42.  
    43. //Enchantments
    44. cake.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 5);
    45. cake.addUnsafeEnchantment(Enchantment.ARROW_FIRE, 1);
    46. cake.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1);
    47. cake.addUnsafeEnchantment(Enchantment.ARROW_KNOCKBACK, 2);
    48. cake.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 5);
    49. cake.addUnsafeEnchantment(Enchantment.DAMAGE_ARTHROPODS, 5);
    50. cake.addUnsafeEnchantment(Enchantment.DAMAGE_UNDEAD, 5);
    51. cake.addUnsafeEnchantment(Enchantment.DIG_SPEED, 5);
    52. cake.addUnsafeEnchantment(Enchantment.DURABILITY, 3);
    53. cake.addUnsafeEnchantment(Enchantment.FIRE_ASPECT, 2);
    54. cake.addUnsafeEnchantment(Enchantment.KNOCKBACK, 2);
    55. cake.addUnsafeEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 3);
    56. cake.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 3);
    57. cake.addUnsafeEnchantment(Enchantment.LUCK, 3);
    58. cake.addUnsafeEnchantment(Enchantment.LURE, 3);
    59.  
    60. //Giving the player item 'CAKE'
    61. players.getInventory().addItem(cake);
    62. sender.sendMessage(ChatColor.BLUE + "Party> "
    63. + ChatColor.GRAY + "We all love cake don't you? If your feeling sad eat some "
    64. + ChatColor.AQUA + "Cake"
    65. + ChatColor.GRAY + "!");
    66.  
    67. Firework firework = (Firework) players.getWorld().spawn(players.getLocation(), Firework.class);
    68. FireworkMeta fireworkMeta = firework.getFireworkMeta();
    69. FireworkEffect effect = FireworkEffect.builder()
    70. .flicker(true)
    71. .withColor(Color.AQUA)
    72. .withFade(Color.NAVY)
    73. .with(Type.BALL_LARGE)
    74. .trail(true)
    75. .build();
    76.  
    77. fireworkMeta.addEffect(effect);
    78. fireworkMeta.setPower(0);
    79.  
    80. firework.setFireworkMeta(fireworkMeta);
    81. }
    82. }
    83. } else if (args.length == 1 && args[0].equalsIgnoreCase("me")) {
    84. Player player = (Player) sender;
    85. EconomyResponse er = economy.depositPlayer(player.getName(), <amount>);
    86. if (er.transactionSuccess()) {
    87.  
    88. //Cake Item
    89. ItemStack cake = new ItemStack(Material.CAKE, 1);
    90. ItemMeta cakeMeta = cake.getItemMeta();
    91. cakeMeta.setDisplayName(
    92. ChatColor.DARK_BLUE + "T" + ChatColor.BLUE + "h" + ChatColor.DARK_GREEN + "e "
    93. + ChatColor.GREEN + "M" + ChatColor.DARK_AQUA + "a" + ChatColor.AQUA + "j" + ChatColor.DARK_RED + "e" + ChatColor.RED + "s" + ChatColor.DARK_PURPLE + "t" + ChatColor.LIGHT_PURPLE + "i" + ChatColor.GOLD + "c "
    94. + ChatColor.YELLOW + "C" + ChatColor.BLUE + "a" + ChatColor.DARK_BLUE + "k" + ChatColor.DARK_GREEN + "e" + ChatColor.GREEN + "! " + ChatColor.LIGHT_PURPLE + "❤");
    95. cake.setItemMeta(cakeMeta);
    96.  
    97. //Enchantments
    98. cake.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 5);
    99. cake.addUnsafeEnchantment(Enchantment.ARROW_FIRE, 1);
    100. cake.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1);
    101. cake.addUnsafeEnchantment(Enchantment.ARROW_KNOCKBACK, 2);
    102. cake.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 5);
    103. cake.addUnsafeEnchantment(Enchantment.DAMAGE_ARTHROPODS, 5);
    104. cake.addUnsafeEnchantment(Enchantment.DAMAGE_UNDEAD, 5);
    105. cake.addUnsafeEnchantment(Enchantment.DIG_SPEED, 5);
    106. cake.addUnsafeEnchantment(Enchantment.DURABILITY, 3);
    107. cake.addUnsafeEnchantment(Enchantment.FIRE_ASPECT, 2);
    108. cake.addUnsafeEnchantment(Enchantment.KNOCKBACK, 2);
    109. cake.addUnsafeEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 3);
    110. cake.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 3);
    111. cake.addUnsafeEnchantment(Enchantment.LUCK, 3);
    112. cake.addUnsafeEnchantment(Enchantment.LURE, 3);
    113.  
    114. //Giving the player item 'CAKE'
    115. player.getInventory().addItem(cake);
    116. sender.sendMessage(ChatColor.BLUE + "Party> "
    117. + ChatColor.GRAY + "We all love cake don't you? If your feeling sad eat some "
    118. + ChatColor.AQUA + "Cake"
    119. + ChatColor.GRAY + "!");
    120.  
    121. Firework firework = (Firework) player.getWorld().spawn(player.getLocation(), Firework.class);
    122. FireworkMeta fireworkMeta = firework.getFireworkMeta();
    123. FireworkEffect effect = FireworkEffect.builder()
    124. .flicker(true)
    125. .withColor(Color.AQUA)
    126. .withFade(Color.NAVY)
    127. .with(Type.BALL_LARGE)
    128. .trail(true)
    129. .build();
    130.  
    131. fireworkMeta.addEffect(effect);
    132. fireworkMeta.setPower(0);
    133.  
    134. firework.setFireworkMeta(fireworkMeta);
    135. } else {
    136. sender.sendMessage(ChatColor.BLUE + "Party> "
    137. + ChatColor.AQUA + "/cake "
    138. + ChatColor.GRAY + "me, all");
    139. sender.sendMessage(ChatColor.BLUE + "Usage> " + ChatColor.AQUA + "<me:all>");
    140. }
    141. }
    142. }
    143. }


    Code:java
    1. EconomyResponse er = Economy.depositPlayer(player.getName(), <amount>);

    that it doesn't like
     
  10. Offline

    JordyPwner

    replace <amount> with a int like: 5
    That will add 5 to the balance of the player
    Also i hope you know basic java :p replace player with ur own variable to get the player
     
  11. Offline

    Chintzi

    Wait it says it cant find variable 'economy' now D:
     
  12. Offline

    JordyPwner

    Do you have vault in ur buildpath?
    Also add this in ur main:
    Code:java
    1. public static Economy economy = null;
    2. private boolean setupEconomy()
    3. {
    4. RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
    5. if (economyProvider != null) {
    6. economy = economyProvider.getProvider();
    7. }
    8.  
    9. return (economy != null);
    10. }
     
  13. Offline

    Chintzi

    Whats a build path? do you mean Library?
     
  14. Offline

    JordyPwner

    Yea where you add your bukkit development ect.
     
  15. Offline

    Chintzi

    What u mean so u mean the Libraries directory where you add Bukkit, Vault & all the other dependencies
     
  16. Offline

    JordyPwner

    Yes
     
  17. Offline

    Chintzi

    Oh then yeah xD

    Wait when you said "Add this to your main" what do you mean by main?

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

    JordyPwner

    Also did u put this in ur main? Ur main class (where it extends JavaPlugin)

    Code:java
    1. public static Economy economy = null;
    2. private boolean setupEconomy()
    3. {
    4. RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
    5. if (economyProvider != null) {
    6. economy = economyProvider.getProvider();
    7. }
    8.  
    9. return (economy != null);
    10. }
     
  19. Offline

    Chintzi

    I put it here is this the right spot above onEnable()
    Code:java
    1. package net.wrightnz.minecraft.skiecraft;
    2.  
    3. import java.io.File;
    4. import java.util.logging.Level;
    5. import java.io.IOException;
    6. import net.milkbowl.vault.economy.Economy;
    7. import org.bukkit.command.Command;
    8. import org.bukkit.command.CommandSender;
    9. import org.bukkit.configuration.file.FileConfiguration;
    10. import org.bukkit.plugin.PluginDescriptionFile;
    11. import org.bukkit.plugin.PluginManager;
    12. import org.bukkit.plugin.java.JavaPlugin;
    13. import net.wrightnz.minecraft.skiecraft.commands.SkieCraftCommand;
    14. import net.wrightnz.minecraft.skiecraft.commands.WoodToGoldCommand;
    15. import net.wrightnz.minecraft.skiecraft.commands.BlockPlaceParticleCommand;
    16. import net.wrightnz.minecraft.skiecraft.commands.MainSkiecraftCommand;
    17. import net.wrightnz.minecraft.skiecraft.commands.TrailCommand;
    18. import net.wrightnz.minecraft.skiecraft.commands.AdminGUICommand;
    19. import net.wrightnz.minecraft.skiecraft.commands.BlockBreakParticleCommand;
    20. import net.wrightnz.minecraft.skiecraft.commands.HandCommand;
    21. import net.wrightnz.minecraft.skiecraft.commands.BBCCommand;
    22. import net.wrightnz.minecraft.skiecraft.commands.BombMeCommand;
    23. import net.wrightnz.minecraft.skiecraft.commands.CakeCommand;
    24. import net.wrightnz.minecraft.skiecraft.commands.ClearChatCommand;
    25. import net.wrightnz.minecraft.skiecraft.commands.CmdListCommand;
    26. import net.wrightnz.minecraft.skiecraft.commands.DeopAllCommand;
    27. import net.wrightnz.minecraft.skiecraft.commands.DiceCommand;
    28. import net.wrightnz.minecraft.skiecraft.commands.DieCommand;
    29. import net.wrightnz.minecraft.skiecraft.commands.ExpShowerCommand;
    30. import net.wrightnz.minecraft.skiecraft.commands.ExplodingEggsCommand;
    31. import net.wrightnz.minecraft.skiecraft.commands.FakeCommand;
    32. import net.wrightnz.minecraft.skiecraft.commands.FireworkCommand;
    33. import net.wrightnz.minecraft.skiecraft.commands.GadgetCommand;
    34. import net.wrightnz.minecraft.skiecraft.commands.HatCommand;
    35. import net.wrightnz.minecraft.skiecraft.commands.HeartsCommand;
    36. import net.wrightnz.minecraft.skiecraft.commands.InvisCommand;
    37. import net.wrightnz.minecraft.skiecraft.commands.MajesticCommand;
    38. import net.wrightnz.minecraft.skiecraft.commands.MusicCommand;
    39. import net.wrightnz.minecraft.skiecraft.commands.PlaySoundAllCommand;
    40. import net.wrightnz.minecraft.skiecraft.commands.PresentCommand;
    41. import net.wrightnz.minecraft.skiecraft.commands.SCMobCommand;
    42. import net.wrightnz.minecraft.skiecraft.commands.ShootCommand;
    43. import net.wrightnz.minecraft.skiecraft.commands.ZapCommand;
    44. import net.wrightnz.minecraft.skiecraft.listeners.BlockListener;
    45. import net.wrightnz.minecraft.skiecraft.listeners.DisguiseListener;
    46. import net.wrightnz.minecraft.skiecraft.listeners.EntityListener;
    47. import net.wrightnz.minecraft.skiecraft.commands.JokeCommand;
    48. import net.wrightnz.minecraft.skiecraft.commands.MelonShowerCommand;
    49. import net.wrightnz.minecraft.skiecraft.commands.MilkCommand;
    50. import net.wrightnz.minecraft.skiecraft.commands.OpAllCommand;
    51. import net.wrightnz.minecraft.skiecraft.commands.PickUpCommand;
    52. import net.wrightnz.minecraft.skiecraft.commands.PigInvasionCommand;
    53. import net.wrightnz.minecraft.skiecraft.commands.PortableCommand;
    54. import net.wrightnz.minecraft.skiecraft.commands.SmiteAllCommand;
    55. import net.wrightnz.minecraft.skiecraft.commands.SpectateCommand;
    56. import net.wrightnz.minecraft.skiecraft.commands.TNTCannonCommand;
    57. import net.wrightnz.minecraft.skiecraft.commands.WardrobeCommand;
    58. import net.wrightnz.minecraft.skiecraft.listeners.GUIListener;
    59. import net.wrightnz.minecraft.skiecraft.listeners.InventoryListener;
    60. import net.wrightnz.minecraft.skiecraft.listeners.OnPlayer;
    61. import net.wrightnz.minecraft.skiecraft.listeners.PlayerListener;
    62. import org.bukkit.ChatColor;
    63. import org.bukkit.plugin.RegisteredServiceProvider;
    64.  
    65. public class SkieCraft extends JavaPlugin {
    66.  
    67. public static String Version = "";
    68. public static String Name = "";
    69. public static String Boarder = "";
    70. public static String Website = "";
    71.  
    72. public SkieCraft() {
    73. super();
    74. PluginDescriptionFile description = this.getDescription();
    75. Version = description.getVersion();
    76. Name = description.getName();
    77. Boarder = getBoarder();
    78. Website = description.getWebsite();
    79. }
    80. public static Economy economy = null;
    81.  
    82. private boolean setupEconomy() {
    83. RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
    84. if (economyProvider != null) {
    85. economy = economyProvider.getProvider();
    86. }
    87.  
    88. return (economy != null);
    89. }
    90.  
    91. @Override
    92. public void onEnable() {
    93. getConfig().addDefault("apply-message", "Apply at example.com!");
    94. getConfig().addDefault("server-name", "SkieCraft");
    95. getConfig().options().copyDefaults(true);
    96. saveConfig();
    97. try {
    98. saveConfig();
    99. setupConfig(getConfig());
    100. } catch (IOException e) {
    101. e.printStackTrace();
    102. }
    103.  
    104. final PluginManager pm = this.getServer().getPluginManager();
    105. pm.registerEvents(new BlockListener(), this);
    106. pm.registerEvents(new GUIListener(), this);
    107. pm.registerEvents(new InventoryListener(), this);
    108. pm.registerEvents(new OnPlayer(), this);
    109. pm.registerEvents(new PlayerListener(), this);
    110. pm.registerEvents(new EntityListener(), this);
    111. pm.registerEvents(new DisguiseListener(), this);
    112. }
     
  20. Offline

    JordyPwner

  21. Offline

    Chintzi

    kk then what?
     
  22. Offline

    JordyPwner

    Then put this somewhere when you want to add a amount of money:

    Code:java
    1. EconomyResponse er = economy.depositPlayer(player.getName(), amount);
    2. if(er.transactionSuccess()){
    3. //do stuff
    4.  
     
  23. Offline

    Chintzi

    Still saying economy is an unknown variable D:

    Are you sure its called economy or if theres something else called vault or economyvault or something?

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

    JordyPwner

    Tried with Case Sensitive? Like Economy and economy?
     
  25. Offline

    Chintzi

    Yeah didn't work D: hmm are sure i don't have to make a variable for it?
     
  26. Offline

    JordyPwner

    i didnt so u guess you dont have to do that to. Maybe try: this.Economy or this.economy
     
  27. Offline

    Chintzi

    Hey i just tried something just gonna test it out
     
  28. Offline

    Chintzi

    Dint work, i did this btw D;

    Code:java
    1. CommandSender sender;
    2. Command cmd;
    3. String commandLabel;
    4. String[] args;
    5. Economy economy;
    6.  
    7. public SkieCraftCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    8. this.sender = sender;
    9. this.cmd = cmd;
    10. this.commandLabel = commandLabel;
    11. this.args = args;
    12. this.economy = economy;
     
  29. Chintzi Yeah that wont work. Look at my post before.
     
Thread Status:
Not open for further replies.

Share This Page