forked from Upstream/CommandPanels
Merge pull request #206 from TheLonelyWolf1/master
Added CoinsAPI Support
This commit is contained in:
commit
0e3bd95b2d
@ -61,6 +61,9 @@ purchase:
|
||||
tokens:
|
||||
success: '&aSuccessfully Bought For %cp-args% Tokens.'
|
||||
failure: '&cInsufficient Tokens!'
|
||||
coins:
|
||||
success: '&aSuccessfully Bought For %cp-args% Coins.'
|
||||
failure: '&cInsufficient Coins!'
|
||||
item:
|
||||
success: '&aSuccessfully Sold %cp-args%.'
|
||||
failure: '&cInsufficient Items!'
|
||||
|
@ -1,10 +1,10 @@
|
||||
version: 3.17.5.0
|
||||
version: 3.17.6.0
|
||||
main: me.rockyhawk.commandpanels.CommandPanels
|
||||
name: CommandPanels
|
||||
author: RockyHawk
|
||||
api-version: '1.13'
|
||||
description: Fully Custom GUIs. Make your Server Professional.
|
||||
softdepend: [PlaceholderAPI, Vault, HeadDatabase, TokenManager, VotingPlugin, MMOItems, CustomItems, ChestSort]
|
||||
softdepend: [PlaceholderAPI, Vault, HeadDatabase, TokenManager, VotingPlugin, MMOItems, CustomItems, ChestSort, CoinsAPINB]
|
||||
commands:
|
||||
commandpanel:
|
||||
description: Open a command panel.
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.rockyhawk.commandpanels.classresources.placeholders;
|
||||
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import de.NeonnBukkit.CoinsAPI.API.CoinsAPI;
|
||||
import me.realized.tokenmanager.api.TokenManager;
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.api.Panel;
|
||||
@ -351,6 +352,11 @@ public class Placeholders {
|
||||
return Long.toString(api.getTokens(p).orElse(0));
|
||||
}
|
||||
}
|
||||
if (plugin.getServer().getPluginManager().isPluginEnabled("CoinsAPINB")) {
|
||||
if(identifier.equals("coins-balance")) {
|
||||
return String.valueOf(CoinsAPI.getCoins(p.getUniqueId().toString()));
|
||||
}
|
||||
}
|
||||
if (plugin.getServer().getPluginManager().isPluginEnabled("VotingPlugin")) {
|
||||
if(identifier.equals("votingplugin-points")) {
|
||||
return String.valueOf(UserManager.getInstance().getVotingPluginUser(p).getPoints());
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.rockyhawk.commandpanels.commandtags;
|
||||
|
||||
import de.NeonnBukkit.CoinsAPI.API.CoinsAPI;
|
||||
import me.realized.tokenmanager.api.TokenManager;
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.api.Panel;
|
||||
@ -189,6 +190,30 @@ public class CommandTags {
|
||||
return PaywallOutput.Blocked;
|
||||
}
|
||||
}
|
||||
case "coinpaywall=": {
|
||||
//if player uses coinpaywall= [price]
|
||||
try {
|
||||
if (plugin.getServer().getPluginManager().isPluginEnabled("CoinsAPINB")) {
|
||||
int balance = CoinsAPI.getCoins(p.getUniqueId().toString());
|
||||
if (balance >= Double.parseDouble(command.split("\\s")[1])) {
|
||||
CoinsAPI.removeCoins(p.getUniqueId().toString(), (int) Long.parseLong(command.split("\\s")[1]));
|
||||
//if the message is empty don't send
|
||||
plugin.tex.sendString(p,Objects.requireNonNull(plugin.config.getString("purchase.coins.success")).replaceAll("%cp-args%", command.split("\\s")[1]));
|
||||
return PaywallOutput.Passed;
|
||||
} else {
|
||||
plugin.tex.sendString(p,plugin.config.getString("purchase.coins.failure"));
|
||||
return PaywallOutput.Blocked;
|
||||
}
|
||||
} else {
|
||||
plugin.tex.sendString(p, tag + ChatColor.RED + "Needs CoinAPI to work!");
|
||||
return PaywallOutput.Blocked;
|
||||
}
|
||||
} catch (Exception buyc) {
|
||||
plugin.debug(buyc,p);
|
||||
plugin.tex.sendString(p, tag + plugin.config.getString("config.format.error") + " " + "commands: " + command);
|
||||
return PaywallOutput.Blocked;
|
||||
}
|
||||
}
|
||||
case "item-paywall=": {
|
||||
//if player uses item-paywall= [Material] [Amount] [Id]
|
||||
//player can use item-paywall= [custom-item]
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.rockyhawk.commandpanels.commandtags.tags.economy;
|
||||
|
||||
import de.NeonnBukkit.CoinsAPI.API.CoinsAPI;
|
||||
import me.realized.tokenmanager.api.TokenManager;
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.commandtags.CommandTagEvent;
|
||||
@ -69,5 +70,29 @@ public class BuyCommandTags implements Listener {
|
||||
plugin.tex.sendMessage(e.p, plugin.config.getString("config.format.error") + " " + "commands: " + e.name);
|
||||
}
|
||||
}
|
||||
if(e.name.equalsIgnoreCase("coinbuycommand=")){
|
||||
e.commandTagUsed();
|
||||
//if player uses coinbuycommand [price] [command]
|
||||
try {
|
||||
if (plugin.getServer().getPluginManager().isPluginEnabled("CoinsAPINB")) {
|
||||
int balance = CoinsAPI.getCoins(e.p.getUniqueId().toString());
|
||||
if (balance >= Double.parseDouble(e.args[0])) {
|
||||
CoinsAPI.removeCoins(e.p.getUniqueId().toString(), (int) Long.parseLong(e.args[0]));
|
||||
//execute command under here
|
||||
String price = e.args[0];
|
||||
String command = String.join(" ",Arrays.copyOfRange(e.raw, 1, e.raw.length));
|
||||
plugin.commandTags.runCommand(e.panel,e.pos,e.p,command);
|
||||
plugin.tex.sendMessage(e.p, Objects.requireNonNull(plugin.config.getString("purchase.coins.success")).replaceAll("%cp-args%", price));
|
||||
} else {
|
||||
plugin.tex.sendMessage(e.p, plugin.config.getString("purchase.coins.failure"));
|
||||
}
|
||||
} else {
|
||||
plugin.tex.sendMessage(e.p, ChatColor.RED + "Buying Requires Vault and an Economy to work!");
|
||||
}
|
||||
} catch (Exception buyc) {
|
||||
plugin.debug(buyc,e.p);
|
||||
plugin.tex.sendMessage(e.p, plugin.config.getString("config.format.error") + " " + "commands: " + e.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.rockyhawk.commandpanels.commandtags.tags.economy;
|
||||
|
||||
import de.NeonnBukkit.CoinsAPI.API.CoinsAPI;
|
||||
import me.realized.tokenmanager.api.TokenManager;
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.commandtags.CommandTagEvent;
|
||||
@ -66,6 +67,27 @@ public class BuyItemTags implements Listener {
|
||||
plugin.tex.sendMessage(e.p, plugin.config.getString("config.format.error") + " " + "commands: " + e.name);
|
||||
}
|
||||
}
|
||||
if(e.name.equalsIgnoreCase("coinbuy=")) {
|
||||
e.commandTagUsed();
|
||||
//if player uses coinbuy= it will be eg. coinbuy= <price> <item> <amount of item> <ID>
|
||||
try {
|
||||
if (plugin.getServer().getPluginManager().isPluginEnabled("CoinsAPINB")) {
|
||||
int balance = CoinsAPI.getCoins(e.p.getUniqueId().toString());
|
||||
if (balance >= Double.parseDouble(e.args[0])) {
|
||||
CoinsAPI.removeCoins(e.p.getUniqueId().toString(), (int) Long.parseLong(e.args[0]));
|
||||
plugin.tex.sendMessage(e.p, Objects.requireNonNull(plugin.config.getString("purchase.coins.success")).replaceAll("%cp-args%", e.args[0]));
|
||||
giveItem(e.p,e.args);
|
||||
} else {
|
||||
plugin.tex.sendMessage(e.p, plugin.config.getString("purchase.coins.failure"));
|
||||
}
|
||||
} else {
|
||||
plugin.tex.sendMessage(e.p, ChatColor.RED + "Buying Requires CoinsAPINB to work!");
|
||||
}
|
||||
} catch (Exception buy) {
|
||||
plugin.debug(buy, e.p);
|
||||
plugin.tex.sendMessage(e.p, plugin.config.getString("config.format.error") + " " + "commands: " + e.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.rockyhawk.commandpanels.commandtags.tags.economy;
|
||||
|
||||
import de.NeonnBukkit.CoinsAPI.API.CoinsAPI;
|
||||
import me.realized.tokenmanager.api.TokenManager;
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.commandtags.CommandTagEvent;
|
||||
@ -69,6 +70,26 @@ public class SellItemTags implements Listener {
|
||||
plugin.tex.sendMessage(e.p, plugin.config.getString("config.format.error") + " " + "commands: " + e.name);
|
||||
}
|
||||
}
|
||||
if(e.name.equalsIgnoreCase("coinsell=")) {
|
||||
e.commandTagUsed();
|
||||
//if player uses coinsell= it will be eg. coinsell= <cashback> <item> <amount of item> [enchanted:KNOCKBACK:1] [potion:JUMP]
|
||||
try {
|
||||
if (plugin.getServer().getPluginManager().isPluginEnabled("CoinsAPINB")) {
|
||||
boolean sold = removeItem(e.p, e.args);
|
||||
if (!sold) {
|
||||
plugin.tex.sendMessage(e.p, plugin.config.getString("purchase.item.failure"));
|
||||
} else {
|
||||
CoinsAPI.addCoins(e.p.getUniqueId().toString(), (int) Long.parseLong(e.args[0]));
|
||||
plugin.tex.sendMessage(e.p, plugin.config.getString("purchase.item.success").replaceAll("%cp-args%", e.args[1]));
|
||||
}
|
||||
} else {
|
||||
plugin.tex.sendMessage(e.p, ChatColor.RED + "Selling Requires CoinsAPINB to work!");
|
||||
}
|
||||
} catch (Exception sell) {
|
||||
plugin.debug(sell,e.p);
|
||||
plugin.tex.sendMessage(e.p, plugin.config.getString("config.format.error") + " " + "commands: " + e.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//returns false if player does not have item
|
||||
|
Loading…
Reference in New Issue
Block a user