mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-24 17:39:52 -05:00
Reserve support. Add vault maven repo.
Former-commit-id: cc301a1916514ad703a19d338c381d964abd315d [formerly 3abb21befa0d514000fd8a3ea6b81810cada7b04] Former-commit-id: 2691cc041de76bb8fba57f352edad2e5f4c392ad
This commit is contained in:
1 parent
964be09801
commit
345df257df
3 files changed
+173
-13
No files matched your search
@@ -0,0 +1,100 @@
|
||||
package org.maxgamer.quickshop.Economy;
|
||||
|
||||
import net.tnemc.core.Reserve;
|
||||
import net.tnemc.core.economy.EconomyAPI;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author creatorfromhell
|
||||
*/
|
||||
public class Economy_Reserve implements EconomyCore {
|
||||
|
||||
private EconomyAPI reserve = null;
|
||||
|
||||
public Economy_Reserve() {
|
||||
setup();
|
||||
}
|
||||
|
||||
private void setup() {
|
||||
if(((Reserve)Bukkit.getPluginManager().getPlugin("Reserve")).economyProvided()) {
|
||||
reserve = ((Reserve)Bukkit.getPluginManager().getPlugin("Reserve")).economy();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that this economy is valid. Returns false if it is not valid.
|
||||
*
|
||||
* @return True if this economy will work, false if it will not.
|
||||
*/
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return reserve != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats the given number... E.g. 50.5 becomes $50.5 Dollars, or 50 Dollars 5 Cents
|
||||
*
|
||||
* @param balance The given number
|
||||
*
|
||||
* @return The balance in human readable text.
|
||||
*/
|
||||
@Override
|
||||
public String format(double balance) {
|
||||
return reserve.format(new BigDecimal(balance));
|
||||
}
|
||||
|
||||
/**
|
||||
* Deposits a given amount of money from thin air to the given username.
|
||||
*
|
||||
* @param name The exact (case insensitive) username to give money to
|
||||
* @param amount The amount to give them
|
||||
*
|
||||
* @return True if success (Should be almost always)
|
||||
*/
|
||||
@Override
|
||||
public boolean deposit(UUID name, double amount) {
|
||||
return reserve.addHoldings(name, new BigDecimal(amount));
|
||||
}
|
||||
|
||||
/**
|
||||
* Withdraws a given amount of money from the given username and turns it to thin air.
|
||||
*
|
||||
* @param name The exact (case insensitive) username to take money from
|
||||
* @param amount The amount to take from them
|
||||
*
|
||||
* @return True if success, false if they didn't have enough cash
|
||||
*/
|
||||
@Override
|
||||
public boolean withdraw(UUID name, double amount) {
|
||||
return reserve.removeHoldings(name, new BigDecimal(amount));
|
||||
}
|
||||
|
||||
/**
|
||||
* Transfers the given amount of money from Player1 to Player2
|
||||
*
|
||||
* @param from The player who is paying money
|
||||
* @param to The player who is receiving money
|
||||
* @param amount The amount to transfer
|
||||
*
|
||||
* @return true if success (Payer had enough cash, receiver was able to receive the funds)
|
||||
*/
|
||||
@Override
|
||||
public boolean transfer(UUID from, UUID to, double amount) {
|
||||
return reserve.transferHoldings(from, to, new BigDecimal(amount));
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the balance of the given account name
|
||||
*
|
||||
* @param name The name of the account
|
||||
*
|
||||
* @return Their current balance.
|
||||
*/
|
||||
@Override
|
||||
public double getBalance(UUID name) {
|
||||
return reserve.getHoldings(name).doubleValue();
|
||||
}
|
||||
}
|
||||
@@ -1,35 +1,62 @@
|
||||
package org.maxgamer.quickshop;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import lombok.*;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.jetbrains.annotations.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.maxgamer.quickshop.Command.QS;
|
||||
import org.maxgamer.quickshop.Command.Tab;
|
||||
import org.maxgamer.quickshop.Database.*;
|
||||
import org.maxgamer.quickshop.Database.Database;
|
||||
import org.maxgamer.quickshop.Database.Database.ConnectionException;
|
||||
import org.maxgamer.quickshop.Database.DatabaseCore;
|
||||
import org.maxgamer.quickshop.Database.DatabaseHelper;
|
||||
import org.maxgamer.quickshop.Database.DatabaseManager;
|
||||
import org.maxgamer.quickshop.Database.MySQLCore;
|
||||
import org.maxgamer.quickshop.Database.SQLiteCore;
|
||||
import org.maxgamer.quickshop.Economy.Economy;
|
||||
import org.maxgamer.quickshop.Economy.EconomyCore;
|
||||
import org.maxgamer.quickshop.Economy.Economy_Reserve;
|
||||
import org.maxgamer.quickshop.Economy.Economy_Vault;
|
||||
import org.maxgamer.quickshop.Listeners.*;
|
||||
import org.maxgamer.quickshop.Listeners.BlockListener;
|
||||
import org.maxgamer.quickshop.Listeners.ChatListener;
|
||||
import org.maxgamer.quickshop.Listeners.ChunkListener;
|
||||
import org.maxgamer.quickshop.Listeners.CustomInventoryListener;
|
||||
import org.maxgamer.quickshop.Listeners.DisplayBugFixListener;
|
||||
import org.maxgamer.quickshop.Listeners.DisplayProtectionListener;
|
||||
import org.maxgamer.quickshop.Listeners.LockListener;
|
||||
import org.maxgamer.quickshop.Listeners.PlayerListener;
|
||||
import org.maxgamer.quickshop.Listeners.WorldListener;
|
||||
import org.maxgamer.quickshop.Shop.Shop;
|
||||
import org.maxgamer.quickshop.Shop.ShopLoader;
|
||||
import org.maxgamer.quickshop.Shop.ShopManager;
|
||||
import org.maxgamer.quickshop.Util.*;
|
||||
import org.maxgamer.quickshop.Util.Compatibility;
|
||||
import org.maxgamer.quickshop.Util.IncompatibleChecker;
|
||||
import org.maxgamer.quickshop.Util.ItemMatcher;
|
||||
import org.maxgamer.quickshop.Util.MsgUtil;
|
||||
import org.maxgamer.quickshop.Util.PermissionChecker;
|
||||
import org.maxgamer.quickshop.Util.SentryErrorReporter;
|
||||
import org.maxgamer.quickshop.Util.Timer;
|
||||
import org.maxgamer.quickshop.Util.Util;
|
||||
import org.maxgamer.quickshop.Watcher.LogWatcher;
|
||||
import org.maxgamer.quickshop.Watcher.UpdateWatcher;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
//import com.griefcraft.lwc.LWCPlugin;
|
||||
@Getter
|
||||
public class QuickShop extends JavaPlugin {
|
||||
@@ -759,6 +786,14 @@ public class QuickShop extends JavaPlugin {
|
||||
private boolean loadEcon() {
|
||||
try {
|
||||
EconomyCore core = new Economy_Vault();
|
||||
|
||||
if(Bukkit.getPluginManager().isPluginEnabled("Reserve")) {
|
||||
final EconomyCore reserveCore = new Economy_Reserve();
|
||||
if(reserveCore.isValid()) {
|
||||
core = reserveCore;
|
||||
}
|
||||
}
|
||||
|
||||
if (!core.isValid()) {
|
||||
// getLogger().severe("Economy is not valid!");
|
||||
getLogger().severe("QuickShop could not hook into an economy plugin/Not found Vault!");
|
||||
|
||||
Reference in new issue
Block a user