Merge pull request #124 from creatorfromhell/master

Implement Reserve Support.

Former-commit-id: 4159b2cab5844f10b828b51038c3166f1832e307 [formerly d4348049f7791eb73a566b7691254dbfcad6aed9]
Former-commit-id: 85ea794c4c5f63264f8095f0c0121e29eac3d3b3
This commit is contained in:
Ghost_chu authored and GitHub committed 2019-06-18 18:11:52 +08:00
commit 7ebbf25690
4 files changed
+263 -103

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!");
+90 -90
View File
@@ -1,91 +1,91 @@
name: ${name}
main: ${package}.${name}
version: ${project.version}
authors: [BukkitCommonsStudio,Netherfoam, Timtower, KaiNoMood, Ghost_chu, Mgazul, TiaraRinne]
description: Economy Shops plugin
#softdepend: [Herochat, Vault, Essentials, OpenInv] OLD Remove Herochat support.
#Now we only need Vault.
softdepend: [Vault]
api-version: 1.13
commands:
qs:
description: QuickShop command
usage: /qs
aliases: [shop,qsshop,qshop,quickshop,chestshop,cshop]
permissions:
quickshop.create.sell:
description: Allows a player to sell from a shop
default: op
quickshop.create.buy:
description: Allows a player to buy from a shop
default: op
quickshop.create.double:
description: Allows a player to create a double shop
default: op
quickshop.create.changeprice:
description: Allow a player to change their shop's price
default: op
quickshop.use:
description: Allows a player to buy/sell using other players shops
default: true
quickshop.unlimited:
description: Allows a Staff Member to use /qs unlimited and make a shop infinite
default: op
quickshop.bypass.<itemID>:
description: Allows a player to sell <itemID>, even if its blacklisted
default: op
quickshop.other.destroy:
description: Allows a Staff Member to destroy other players shops if they are locked in the config
default: op
quickshop.other.open:
description: Allows a Staff Member to open someone elses shop if they are locked in the config
default: op
quickshop.other.price:
description: Allows a Staff Member to change the price of someone elses shop
default: op
quickshop.setowner:
description: Allows a Staff Member to change the owner of any shop
default: op
quickshop.staff:
description: Allow a shop owner to add staff to the shop
default: op
quickshio.areashop.bypass:
description: If you enable a special zone only and the player has this permission, the special zone will only ignore your limit.
default: op
quickshop.find:
description: Allows a player to locate the nearest shop that has a specific item type. Works in a 3 chunk radius.
default: true
quickshop.refill:
description: Allows a Staff Member to refill the shop theyre looking at with the given number of items.
default: op
quickshop.empty:
description: Allows a Staff Member to empty the shop theyre looking at of all items.
default: op
quickshop.debug:
description: Switch to or from developer mode
default: op
quickshop.export:
description: Allows exporting the database to mysql or sqlite
default: op
quickshop.alerts:
description: Alert the player when someone tries to cheat with the display item
default: op
quickshop.about:
description: Show QuickShop about message
default: true
quickshop.info:
description: Show QuickShop Statistics.
default: op
quickshop.fetchmessage:
description: Use command /qs fetchmessage to manual fetch shop message from database. Will not effect auto fetch if you have it on...
default: true
quickshop.paste:
description: Command to upload server information to Pastebin. !WARNING, This will upload your data and it may leak your server configuration and other sensitive information.
default: op
quickshop.preview:
description: Permission for preview item to use a GUI
name: ${name}
main: ${package}.${name}
version: ${project.version}
authors: [BukkitCommonsStudio,Netherfoam, Timtower, KaiNoMood, Ghost_chu, Mgazul, TiaraRinne]
description: Economy Shops plugin
#softdepend: [Herochat, Vault, Essentials, OpenInv] OLD Remove Herochat support.
#Now we only need Vault.
softdepend: [Vault, Reserve]
api-version: 1.13
commands:
qs:
description: QuickShop command
usage: /qs
aliases: [shop,qsshop,qshop,quickshop,chestshop,cshop]
permissions:
quickshop.create.sell:
description: Allows a player to sell from a shop
default: op
quickshop.create.buy:
description: Allows a player to buy from a shop
default: op
quickshop.create.double:
description: Allows a player to create a double shop
default: op
quickshop.create.changeprice:
description: Allow a player to change their shop's price
default: op
quickshop.use:
description: Allows a player to buy/sell using other players shops
default: true
quickshop.unlimited:
description: Allows a Staff Member to use /qs unlimited and make a shop infinite
default: op
quickshop.bypass.<itemID>:
description: Allows a player to sell <itemID>, even if its blacklisted
default: op
quickshop.other.destroy:
description: Allows a Staff Member to destroy other players shops if they are locked in the config
default: op
quickshop.other.open:
description: Allows a Staff Member to open someone elses shop if they are locked in the config
default: op
quickshop.other.price:
description: Allows a Staff Member to change the price of someone elses shop
default: op
quickshop.setowner:
description: Allows a Staff Member to change the owner of any shop
default: op
quickshop.staff:
description: Allow a shop owner to add staff to the shop
default: op
quickshio.areashop.bypass:
description: If you enable a special zone only and the player has this permission, the special zone will only ignore your limit.
default: op
quickshop.find:
description: Allows a player to locate the nearest shop that has a specific item type. Works in a 3 chunk radius.
default: true
quickshop.refill:
description: Allows a Staff Member to refill the shop theyre looking at with the given number of items.
default: op
quickshop.empty:
description: Allows a Staff Member to empty the shop theyre looking at of all items.
default: op
quickshop.debug:
description: Switch to or from developer mode
default: op
quickshop.export:
description: Allows exporting the database to mysql or sqlite
default: op
quickshop.alerts:
description: Alert the player when someone tries to cheat with the display item
default: op
quickshop.about:
description: Show QuickShop about message
default: true
quickshop.info:
description: Show QuickShop Statistics.
default: op
quickshop.fetchmessage:
description: Use command /qs fetchmessage to manual fetch shop message from database. Will not effect auto fetch if you have it on...
default: true
quickshop.paste:
description: Command to upload server information to Pastebin. !WARNING, This will upload your data and it may leak your server configuration and other sensitive information.
default: op
quickshop.preview:
description: Permission for preview item to use a GUI
default: true