Add Toggles to Paywall Messages & use Tag provided by the Main Class

This commit is contained in:
TheLonelyWolf 2022-06-18 22:39:46 +02:00
parent 575c574a66
commit f4ff0631d1
2 changed files with 47 additions and 22 deletions

View File

@ -50,7 +50,7 @@ public class Commandpanelsreload implements CommandExecutor {
registerCommands(); registerCommands();
} }
plugin.tag = plugin.tex.colour(plugin.config.getString("config.format.tag") + " "); plugin.tag = plugin.tex.colour(plugin.config.getString("config.format.tag"));
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.reload"))); sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.reload")));
}else{ }else{
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms"))); sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));

View File

@ -138,7 +138,7 @@ public class CommandTags {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public PaywallOutput commandPayWall(Panel panel, Player p, String rawCommand) { //return 0 means no funds, 1 is they passed and 2 means paywall is not this command public PaywallOutput commandPayWall(Panel panel, Player p, String rawCommand) { //return 0 means no funds, 1 is they passed and 2 means paywall is not this command
String tag = plugin.config.getString("config.format.tag") + " ";
//create new instance of command but with placeholders parsed //create new instance of command but with placeholders parsed
String command = plugin.tex.placeholders(panel,PanelPosition.Top,p,rawCommand); String command = plugin.tex.placeholders(panel,PanelPosition.Top,p,rawCommand);
switch(command.split("\\s")[0]){ switch(command.split("\\s")[0]){
@ -148,19 +148,23 @@ public class CommandTags {
if (plugin.econ != null) { if (plugin.econ != null) {
if (plugin.econ.getBalance(p) >= Double.parseDouble(command.split("\\s")[1])) { if (plugin.econ.getBalance(p) >= Double.parseDouble(command.split("\\s")[1])) {
plugin.econ.withdrawPlayer(p, Double.parseDouble(command.split("\\s")[1])); plugin.econ.withdrawPlayer(p, Double.parseDouble(command.split("\\s")[1]));
plugin.tex.sendString(p,Objects.requireNonNull(plugin.config.getString("purchase.currency.success")).replaceAll("%cp-args%", command.split("\\s")[1])); if(plugin.config.getBoolean("purchase.currency.enable")){
plugin.tex.sendString(p,Objects.requireNonNull(plugin.config.getString("purchase.currency.success")).replaceAll("%cp-args%", command.split("\\s")[1]));
}
return PaywallOutput.Passed; return PaywallOutput.Passed;
} else { } else {
plugin.tex.sendString(p,plugin.config.getString("purchase.currency.failure")); if(plugin.config.getBoolean("purchase.currency.enable")){
plugin.tex.sendString(p,plugin.config.getString("purchase.currency.failure"));
}
return PaywallOutput.Blocked; return PaywallOutput.Blocked;
} }
} else { } else {
plugin.tex.sendString(p, tag + ChatColor.RED + "Paying Requires Vault and an Economy to work!"); plugin.tex.sendString(p, plugin.tag + ChatColor.RED + "Paying Requires Vault and an Economy to work!");
return PaywallOutput.Blocked; return PaywallOutput.Blocked;
} }
} catch (Exception buyc) { } catch (Exception buyc) {
plugin.debug(buyc,p); plugin.debug(buyc,p);
plugin.tex.sendString(p, tag + plugin.config.getString("config.format.error") + " " + "commands: " + command); plugin.tex.sendString(p, plugin.tag + plugin.config.getString("config.format.error") + " " + "commands: " + command);
return PaywallOutput.Blocked; return PaywallOutput.Blocked;
} }
} }
@ -174,19 +178,24 @@ public class CommandTags {
if (balance >= Double.parseDouble(command.split("\\s")[1])) { if (balance >= Double.parseDouble(command.split("\\s")[1])) {
api.removeTokens(p, Long.parseLong(command.split("\\s")[1])); api.removeTokens(p, Long.parseLong(command.split("\\s")[1]));
//if the message is empty don't send //if the message is empty don't send
if(plugin.config.getBoolean("purchase.tokens.enable")){
plugin.tex.sendString(p,plugin.config.getString("purchase.tokens.failure"));
}
plugin.tex.sendString(p,Objects.requireNonNull(plugin.config.getString("purchase.tokens.success")).replaceAll("%cp-args%", command.split("\\s")[1])); plugin.tex.sendString(p,Objects.requireNonNull(plugin.config.getString("purchase.tokens.success")).replaceAll("%cp-args%", command.split("\\s")[1]));
return PaywallOutput.Passed; return PaywallOutput.Passed;
} else { } else {
plugin.tex.sendString(p,plugin.config.getString("purchase.tokens.failure")); if(plugin.config.getBoolean("purchase.tokens.enable")){
plugin.tex.sendString(p,plugin.config.getString("purchase.tokens.failure"));
}
return PaywallOutput.Blocked; return PaywallOutput.Blocked;
} }
} else { } else {
plugin.tex.sendString(p, tag + ChatColor.RED + "Needs TokenManager to work!"); plugin.tex.sendString(p, plugin.tag + ChatColor.RED + "Needs TokenManager to work!");
return PaywallOutput.Blocked; return PaywallOutput.Blocked;
} }
} catch (Exception buyc) { } catch (Exception buyc) {
plugin.debug(buyc,p); plugin.debug(buyc,p);
plugin.tex.sendString(p, tag + plugin.config.getString("config.format.error") + " " + "commands: " + command); plugin.tex.sendString(p, plugin.tag + plugin.config.getString("config.format.error") + " " + "commands: " + command);
return PaywallOutput.Blocked; return PaywallOutput.Blocked;
} }
} }
@ -198,19 +207,23 @@ public class CommandTags {
if (balance >= Double.parseDouble(command.split("\\s")[1])) { if (balance >= Double.parseDouble(command.split("\\s")[1])) {
CoinsAPI.removeCoins(p.getUniqueId().toString(), (int) Long.parseLong(command.split("\\s")[1])); CoinsAPI.removeCoins(p.getUniqueId().toString(), (int) Long.parseLong(command.split("\\s")[1]));
//if the message is empty don't send //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])); if(plugin.config.getBoolean("purchase.coins.enable")){
plugin.tex.sendString(p,Objects.requireNonNull(plugin.config.getString("purchase.coins.success")).replaceAll("%cp-args%", command.split("\\s")[1]));
}
return PaywallOutput.Passed; return PaywallOutput.Passed;
} else { } else {
plugin.tex.sendString(p,plugin.config.getString("purchase.coins.failure")); if(plugin.config.getBoolean("purchase.coins.enable")){
plugin.tex.sendString(p,plugin.config.getString("purchase.coins.failure"));
}
return PaywallOutput.Blocked; return PaywallOutput.Blocked;
} }
} else { } else {
plugin.tex.sendString(p, tag + ChatColor.RED + "Needs CoinAPI to work!"); plugin.tex.sendString(p, plugin.tag + ChatColor.RED + "Needs CoinAPI to work!");
return PaywallOutput.Blocked; return PaywallOutput.Blocked;
} }
} catch (Exception buyc) { } catch (Exception buyc) {
plugin.debug(buyc,p); plugin.debug(buyc,p);
plugin.tex.sendString(p, tag + plugin.config.getString("config.format.error") + " " + "commands: " + command); plugin.tex.sendString(p, plugin.tag + plugin.config.getString("config.format.error") + " " + "commands: " + command);
return PaywallOutput.Blocked; return PaywallOutput.Blocked;
} }
} }
@ -301,14 +314,18 @@ public class CommandTags {
//send message and return //send message and return
if(removedItem == PaywallOutput.Blocked){ if(removedItem == PaywallOutput.Blocked){
plugin.tex.sendString(p, tag + plugin.config.getString("purchase.item.failure")); if(plugin.config.getBoolean("purchase.item.enable")){
plugin.tex.sendString(p, plugin.tag + plugin.config.getString("purchase.item.failure"));
}
}else{ }else{
plugin.tex.sendString(p,Objects.requireNonNull(plugin.config.getString("purchase.item.success")).replaceAll("%cp-args%",sellItem.getType().toString())); if(plugin.config.getBoolean("purchase.item.enable")){
plugin.tex.sendString(p,Objects.requireNonNull(plugin.config.getString("purchase.item.success")).replaceAll("%cp-args%",sellItem.getType().toString()));
}
} }
return removedItem; return removedItem;
} catch (Exception buyc) { } catch (Exception buyc) {
plugin.debug(buyc,p); plugin.debug(buyc,p);
plugin.tex.sendString(p, tag + plugin.config.getString("config.format.error") + " " + "commands: " + command); plugin.tex.sendString(p, plugin.tag + plugin.config.getString("config.format.error") + " " + "commands: " + command);
return PaywallOutput.Blocked; return PaywallOutput.Blocked;
} }
} }
@ -328,15 +345,19 @@ public class CommandTags {
removePlayerExp(p,Integer.parseInt(command.split("\\s")[1])); removePlayerExp(p,Integer.parseInt(command.split("\\s")[1]));
} }
//if the message is empty don't send //if the message is empty don't send
plugin.tex.sendString(p,Objects.requireNonNull(plugin.config.getString("purchase.xp.success")).replaceAll("%cp-args%", command.split("\\s")[1])); if(plugin.config.getBoolean("purchase.xp.enable")){
plugin.tex.sendString(p,Objects.requireNonNull(plugin.config.getString("purchase.xp.success")).replaceAll("%cp-args%", command.split("\\s")[1]));
}
return PaywallOutput.Passed; return PaywallOutput.Passed;
} else { } else {
plugin.tex.sendString(p, plugin.config.getString("purchase.xp.failure")); if(plugin.config.getBoolean("purchase.xp.enable")){
plugin.tex.sendString(p, plugin.config.getString("purchase.xp.failure"));
}
return PaywallOutput.Blocked; return PaywallOutput.Blocked;
} }
} catch (Exception buyc) { } catch (Exception buyc) {
plugin.debug(buyc,p); plugin.debug(buyc,p);
plugin.tex.sendString(p, tag + plugin.config.getString("config.format.error") + " " + "commands: " + command); plugin.tex.sendString(p, plugin.tag + plugin.config.getString("config.format.error") + " " + "commands: " + command);
return PaywallOutput.Blocked; return PaywallOutput.Blocked;
} }
} }
@ -346,15 +367,19 @@ public class CommandTags {
if (Double.parseDouble(plugin.panelData.getUserData(p.getUniqueId(),command.split("\\s")[1])) >= Double.parseDouble(command.split("\\s")[2])) { if (Double.parseDouble(plugin.panelData.getUserData(p.getUniqueId(),command.split("\\s")[1])) >= Double.parseDouble(command.split("\\s")[2])) {
plugin.panelData.doDataMath(p.getUniqueId(),command.split("\\s")[1],"-" + plugin.tex.placeholdersNoColour(panel,PanelPosition.Top,p,command.split("\\s")[2])); plugin.panelData.doDataMath(p.getUniqueId(),command.split("\\s")[1],"-" + plugin.tex.placeholdersNoColour(panel,PanelPosition.Top,p,command.split("\\s")[2]));
//if the message is empty don't send //if the message is empty don't send
plugin.tex.sendString(p,Objects.requireNonNull(plugin.config.getString("purchase.data.success")).replaceAll("%cp-args%", command.split("\\s")[2])); if(plugin.config.getBoolean("purchase.data.enable")){
plugin.tex.sendString(p,Objects.requireNonNull(plugin.config.getString("purchase.data.success")).replaceAll("%cp-args%", command.split("\\s")[2]));
}
return PaywallOutput.Passed; return PaywallOutput.Passed;
} else { } else {
plugin.tex.sendString(p, plugin.config.getString("purchase.data.failure")); if(plugin.config.getBoolean("purchase.data.enable")){
plugin.tex.sendString(p, plugin.config.getString("purchase.data.failure"));
}
return PaywallOutput.Blocked; return PaywallOutput.Blocked;
} }
} catch (Exception buyc) { } catch (Exception buyc) {
plugin.debug(buyc,p); plugin.debug(buyc,p);
plugin.tex.sendString(p, tag + plugin.config.getString("config.format.error") + " " + "commands: " + command); plugin.tex.sendString(p, plugin.tag + plugin.config.getString("config.format.error") + " " + "commands: " + command);
return PaywallOutput.Blocked; return PaywallOutput.Blocked;
} }
} }