-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
90 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package stonks.hooks; | ||
|
||
import org.bukkit.entity.Player; | ||
|
||
public abstract class EconomyHook { | ||
|
||
public abstract void giveMoney(Player player, double amount); | ||
public abstract void takeMoney(Player player, double amount); | ||
public abstract boolean hasMoney(Player player, double amount); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package stonks.hooks; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.plugin.RegisteredServiceProvider; | ||
|
||
import net.milkbowl.vault.economy.Economy; | ||
|
||
public class VaultEconomyHook extends EconomyHook { | ||
|
||
private boolean available = false; | ||
private Economy economy; | ||
|
||
public VaultEconomyHook() { | ||
RegisteredServiceProvider<Economy> rsp = Bukkit.getServer().getServicesManager().getRegistration(Economy.class); | ||
if (rsp == null) { available = false; return; } | ||
economy = rsp.getProvider(); | ||
if (economy == null) { available = false; return; } | ||
} | ||
|
||
public boolean serviceAvailable() { return available; } | ||
|
||
@Override | ||
public void giveMoney(Player player, double amount) { | ||
economy.depositPlayer(player, amount); | ||
} | ||
|
||
@Override | ||
public void takeMoney(Player player, double amount) { | ||
economy.withdrawPlayer(player, amount); | ||
} | ||
|
||
@Override | ||
public boolean hasMoney(Player player, double amount) { | ||
return economy.has(player, amount); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters