How do I import other plugins into my plugin?

Discussion in 'Plugin Development' started by mixxcraft, May 5, 2014.

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

    mixxcraft

    Hey, I am trying to figure out how too import another plugin into my eclipse source code. Right now I am trying too import Vault Economy and Vault Permissions:

    Code:java
    1. package me.sina797.mixxcraft;
    2.  
    3. import java.util.HashSet;
    4. import java.util.Set;
    5.  
    6. import net.milkbowl.vault.economy.Economy;
    7. import net.milkbowl.vault.permission.Permission;
    8. import org.bukkit.entity.Player;
    9. import org.bukkit.event.Listener;
    10. import org.bukkit.plugin.PluginManager;
    11. import org.bukkit.plugin.RegisteredServiceProvider;
    12. import org.bukkit.plugin.java.JavaPlugin;
    13.  
    14. /**
    15. *
    16. * @author sina797
    17. *
    18. */
    19.  
    20. public class MixxCoinsVotingMoneyPlugin extends JavaPlugin implements Listener {
    21.  
    22.  
    23. public static MixxCoinsVotingMoneyPlugin plugin;
    24. public Permission permission = null;
    25. public Economy economy = null;
    26.  
    27. public Double backupCash = 0.0;
    28. public Set<String> voteGroups = new HashSet<>();
    29.  
    30. public static MixxCoinsVotingMoneyPlugin get() {
    31. return plugin;
    32. }
    33.  
    34. @Override
    35. public void onEnable() {
    36. plugin = this;
    37.  
    38. this.log("Starting up...");
    39.  
    40. PluginManager pm = getServer().getPluginManager();
    41. pm.registerEvents(new MixxCoinsMoneyListener(), this);
    42.  
    43. if (pm.getPlugin("Vault") == null) {
    44. this.log("Error: Vault not found!");
    45. pm.disablePlugin(this);
    46. return;
    47. }
    48.  
    49. if (pm.getPlugin("Votifier") == null) {
    50. this.log("Error: Votifier not found!");
    51. pm.disablePlugin(this);
    52. return;
    53. }
    54.  
    55. this.setupPermissions();
    56. this.setupEconomy();
    57.  
    58. this.saveDefaultConfig();
    59.  
    60. backupCash = getConfig().getDouble("backupcash");
    61. voteGroups = getConfig().getConfigurationSection("groups").getKeys(false);
    62. }
    63.  
    64. @Override
    65. public void onDisable() {
    66. this.log("Plugin stopping...");
    67. }
    68.  
    69. /**
    70.   * Return if a player has a group from the config (PEX COMPATABLE)
    71.   *
    72.   * @param player
    73.   * @return
    74.   */
    75. public String getPlayerVoteGroup(Player player) {
    76. for (String groupName : permission.getPlayerGroups(player)) {
    77. for (String keysString : voteGroups) {
    78. if (keysString.toLowerCase().equalsIgnoreCase(groupName.toLowerCase())) {
    79. return keysString;
    80. }
    81. }
    82. }
    83.  
    84. return "Default";
    85. }
    86.  
    87. /**
    88.   * See if the group is in the config and return its cash (PEX COMPATABLE)
    89.   *
    90.   * @param voteGroup
    91.   * @return
    92.   */
    93. public double getVoteMoney(String voteGroup) {
    94. for (String keysString : voteGroups) {
    95. if (keysString.toLowerCase().equalsIgnoreCase(voteGroup.toLowerCase())) {
    96. return plugin.getConfig().getDouble("groups." + keysString + ".money");
    97. }
    98. }
    99.  
    100. return backupCash;
    101. }
    102.  
    103. private boolean setupPermissions() {
    104. RegisteredServiceProvider permissionProvider = getServer().getServicesManager().getRegistration(Permission.class);
    105. if (permissionProvider != null) {
    106. permission = (Permission) permissionProvider.getProvider();
    107. }
    108. return permission != null;
    109. }
    110.  
    111. private boolean setupEconomy() {
    112. RegisteredServiceProvider economyProvider = getServer().getServicesManager().getRegistration(Economy.class);
    113. if (economyProvider != null) {
    114. economy = (Economy) economyProvider.getProvider();
    115. }
    116.  
    117. return economy != null;
    118. }
    119.  
    120. public void log(String msg) {
    121. this.getLogger().info(msg);
    122. }
    123. }
    124.  

    I can't seem to figure out why it still isn't working, I am trying everything I can as I am trying to import Votifier from GitHub and import Vault for GitHub.
     
  2. Just say it's a library, just as you would do with bukkit
     
Thread Status:
Not open for further replies.

Share This Page