mirror of
https://github.com/LordBoos/boosCooldowns.git
synced 2024-11-01 08:20:32 +01:00
Added: Prices for commands
Added SoftDepend: Vault
This commit is contained in:
parent
3f16d593d0
commit
2ad9adfcc1
@ -32,6 +32,8 @@ public class boosConfigManager {
|
||||
conf.setProperty("commands.cooldown./home", 30);
|
||||
conf.setProperty("commands.warmup./give", 60);
|
||||
conf.setProperty("commands.warmup./home", 20);
|
||||
conf.setProperty("commands.price./spawn", 10);
|
||||
conf.setProperty("commands.price./home", 20);
|
||||
conf.setProperty("commands.options.cancel_warmup_on_damage", false);
|
||||
conf.setProperty("commands.options.cancel_warmup_on_move", false);
|
||||
conf.setProperty("commands.options.clear_on_restart", false);
|
||||
@ -50,6 +52,8 @@ public class boosConfigManager {
|
||||
"&6Wait&e &seconds& &unit&&6 before command&e &command& &6has warmed up.&f");
|
||||
conf.setProperty("commands.options.message_warmup_alreadystarted",
|
||||
"&6Warm-Up process for&e &command& &6has already started.&f");
|
||||
conf.setProperty("commands.options.paid_error", "&6An error has occured:&e %s");
|
||||
conf.setProperty("commands.options.paid_for_command_message", "&6Price of&e &command& &6was&e %s &6and you now have&e %s");
|
||||
conf.save();
|
||||
}
|
||||
}
|
||||
@ -75,6 +79,13 @@ public class boosConfigManager {
|
||||
warmUp = conf.getInt("commands.warmup." + pre, warmUp);
|
||||
return warmUp;
|
||||
}
|
||||
|
||||
public static int getPrice(Player player, String pre) {
|
||||
int price = 0;
|
||||
pre = pre.toLowerCase();
|
||||
price = conf.getInt("commands.price." + pre, price);
|
||||
return price;
|
||||
}
|
||||
|
||||
static String getCoolDownMessage() {
|
||||
return conf
|
||||
@ -131,4 +142,12 @@ public class boosConfigManager {
|
||||
return conf.getBoolean("commands.options.cancel_warmup_on_move", false);
|
||||
}
|
||||
|
||||
public static String getPaidForCommandMessage() {
|
||||
return conf.getString("commands.options.paid_for_command_message", "Price of &command& was %s and you now have %s");
|
||||
}
|
||||
|
||||
public static String getPaidErrorMessage() {
|
||||
return conf.getString("commands.options.paid_error", "An error has occured: %s");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,10 +1,15 @@
|
||||
package cz.boosik.boosCooldown;
|
||||
|
||||
import net.milkbowl.vault.Vault;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.config.Configuration;
|
||||
|
||||
@ -23,6 +28,26 @@ public class boosCoolDown extends JavaPlugin {
|
||||
public static Configuration conf;
|
||||
public static Configuration confusers;
|
||||
public static boolean permissions = false;
|
||||
private static Vault vault = null;
|
||||
public static Vault getVault() {
|
||||
return vault;
|
||||
}
|
||||
|
||||
private static boolean usingVault;
|
||||
private static boolean usingEconomy;
|
||||
private static Economy economy = null;
|
||||
|
||||
public static Economy getEconomy() {
|
||||
return economy;
|
||||
}
|
||||
|
||||
public boolean isUsingVault() {
|
||||
return usingVault;
|
||||
}
|
||||
|
||||
public static boolean isUsingEconomy() {
|
||||
return usingEconomy;
|
||||
}
|
||||
|
||||
@SuppressWarnings("static-access")
|
||||
public void onEnable() {
|
||||
@ -50,10 +75,23 @@ public class boosCoolDown extends JavaPlugin {
|
||||
pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener,
|
||||
Event.Priority.Normal, this);
|
||||
}
|
||||
if (boosConfigManager.getClearOnRestart() == true) {
|
||||
if (boosConfigManager.getClearOnRestart()) {
|
||||
boosCoolDownManager.clear();
|
||||
} else {
|
||||
}
|
||||
Plugin x = this.getServer().getPluginManager().getPlugin("Vault");
|
||||
if(x != null & x instanceof Vault) {
|
||||
vault = (Vault) x;
|
||||
log.info("[" + pdfFile.getName() + "]" + " found [Vault] searching for economy plugin.");
|
||||
usingVault = true;
|
||||
if(setupEconomy()){
|
||||
log.info("[" + pdfFile.getName() + "]" + " found [" + economy.getName() +"] plugin, enabling prices support.");
|
||||
} else {
|
||||
log.info("[" + pdfFile.getName() + "]" + " economy plugin not found, disabling prices support.");
|
||||
}
|
||||
} else {
|
||||
log.info("[" + pdfFile.getName() + "]" + " [Vault] not found disabling economy support.");
|
||||
usingVault = false;
|
||||
}
|
||||
confusers = boosCoolDownManager.confusers;
|
||||
|
||||
}
|
||||
@ -80,4 +118,15 @@ public class boosCoolDown extends JavaPlugin {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean setupEconomy(){
|
||||
if(usingVault){
|
||||
RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
|
||||
if (economyProvider != null) {
|
||||
economy = economyProvider.getProvider();
|
||||
}
|
||||
usingEconomy = true;
|
||||
return (economy != null);
|
||||
} usingEconomy = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -93,6 +93,18 @@ public class boosCoolDownPlayerListener extends PlayerListener {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (boosConfigManager.getPrice(player, pre) > 0) {
|
||||
if (boosCoolDown.isUsingEconomy()) {
|
||||
if (boosCoolDown.getEconomy().getBalance(player.getName()) >= boosConfigManager
|
||||
.getPrice(player, pre)) {
|
||||
boosPriceManager.payForCommand(player, pre, message);
|
||||
} else {
|
||||
boosPriceManager.payForCommand(player, pre, message);
|
||||
event.setCancelled(true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
name: boosCooldown
|
||||
main: cz.boosik.boosCooldown.boosCoolDown
|
||||
version: 1.5.3
|
||||
version: 1.6.0
|
||||
author: boosik
|
||||
description: >
|
||||
Shortcuts
|
||||
|
Loading…
Reference in New Issue
Block a user