From 63c4c6e73e6d57f9708328bbc403b39e79593877 Mon Sep 17 00:00:00 2001 From: Gilberto JR Date: Wed, 6 Apr 2022 13:33:48 -0300 Subject: [PATCH] insert pom build and simple refactor --- pom.xml | 63 ++++++++++- src/main/java/com/pay2ply/spigot/Pay2Ply.java | 102 +++++++++--------- .../spigot/command/Pay2PlyCommand.java | 36 +++---- 3 files changed, 128 insertions(+), 73 deletions(-) diff --git a/pom.xml b/pom.xml index 2620280..579531b 100644 --- a/pom.xml +++ b/pom.xml @@ -1,13 +1,70 @@ - 4.0.0 com.pay2ply.spigot - Pay2Ply [SPIGOT] + Pay2Ply 1.0-SNAPSHOT + + + bukkit + bukkit repo + https://repo.mikeprimm.com/ + + + jitpack + io + https://jitpack.io/ + + + + + + org.bukkit + bukkit + 1.8.8-R0.1-SNAPSHOT + provided + + + com.github.GilbertoKPL + pay2ply-sdk + 0.0.2 + + + + + pay2ply-spigot + install + + + org.apache.maven.plugins + maven-compiler-plugin + 3.10.0 + + 1.8 + 1.8 + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.4 + + + + package + + shade + + + + + + + 8 8 diff --git a/src/main/java/com/pay2ply/spigot/Pay2Ply.java b/src/main/java/com/pay2ply/spigot/Pay2Ply.java index ffc8b91..e502d4e 100644 --- a/src/main/java/com/pay2ply/spigot/Pay2Ply.java +++ b/src/main/java/com/pay2ply/spigot/Pay2Ply.java @@ -4,75 +4,73 @@ import com.pay2ply.sdk.dispense.Dispense; import com.pay2ply.spigot.command.Pay2PlyCommand; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitRunnable; public class Pay2Ply extends JavaPlugin { - private static Pay2Ply instance; + private static Pay2Ply instance; + private final SDK sdk = new SDK(); - public Pay2Ply() { - Pay2Ply.instance = this; - } + public Pay2Ply() { + Pay2Ply.instance = this; + } - public static Pay2Ply getInstance() { - return Pay2Ply.instance; - } + public static Pay2Ply getInstance() { + return Pay2Ply.instance; + } - private final SDK sdk = new SDK(); + public SDK getSdk() { + return sdk; + } - public SDK getSdk() { - return sdk; - } + @Override + public void onEnable() { + this.saveDefaultConfig(); - @Override - public void onEnable() { - this.saveDefaultConfig(); + this.sdk.setToken(this.getConfig().getString("settings.token")); - this.sdk.setToken(this.getConfig().getString("settings.token")); + getCommand("pay2ply").setExecutor(new Pay2PlyCommand()); - getCommand("pay2ply").setExecutor(new Pay2PlyCommand()); - - new BukkitRunnable() { - @Override - public void run() { - Dispense[] dispenses = null; - - try { - dispenses = sdk.getDispenses(); - } catch (Exception exception) { - Bukkit.getLogger().warning(String.format("[%s] %s", getDescription().getName(), exception.getMessage())); - } - - if (dispenses == null) { - return; - } - - for (Dispense dispense : dispenses) { - new BukkitRunnable() { + new BukkitRunnable() { @Override public void run() { - Player player = getServer().getPlayerExact(dispense.getUsername()); + Dispense[] dispenses = null; - if (player == null) { - return; - } + try { + dispenses = sdk.getDispenses(); + } catch (Exception exception) { + Bukkit.getLogger().warning(String.format("[%s] %s", getDescription().getName(), exception.getMessage())); + } - try { - sdk.update(dispense.getUsername(), dispense.getId()); - getServer().dispatchCommand(getServer().getConsoleSender(), dispense.getCommand()); + if (dispenses == null) { + return; + } - if (getConfig().getBoolean("settings.messages")) { - Bukkit.getLogger().info(String.format("[%s] O produto de %s foi ativo.", getDescription().getName(), dispense.getUsername())); + for (Dispense dispense : dispenses) { + new BukkitRunnable() { + @Override + public void run() { + Player player = getServer().getPlayerExact(dispense.getUsername()); + + if (player == null) { + return; + } + + try { + sdk.update(dispense.getUsername(), dispense.getId()); + getServer().dispatchCommand(getServer().getConsoleSender(), dispense.getCommand()); + + if (getConfig().getBoolean("settings.messages")) { + Bukkit.getLogger().info(String.format("[%s] O produto de %s foi ativo.", getDescription().getName(), dispense.getUsername())); + } + } catch (Exception exception) { + Bukkit.getLogger().warning(String.format("[%s] %s", getDescription().getName(), exception.getMessage())); + } + } + }.runTask(getInstance()); } - } catch (Exception exception) { - Bukkit.getLogger().warning(String.format("[%s] %s", getDescription().getName(), exception.getMessage())); - } } - }.runTask(getInstance()); - } - } - }.runTaskTimerAsynchronously(this, 60 * 20, 20 * 20); - } + }.runTaskTimerAsynchronously(this, 60 * 20, 20 * 20); + } } diff --git a/src/main/java/com/pay2ply/spigot/command/Pay2PlyCommand.java b/src/main/java/com/pay2ply/spigot/command/Pay2PlyCommand.java index b09f565..70163f2 100644 --- a/src/main/java/com/pay2ply/spigot/command/Pay2PlyCommand.java +++ b/src/main/java/com/pay2ply/spigot/command/Pay2PlyCommand.java @@ -7,27 +7,27 @@ import org.bukkit.command.CommandSender; public class Pay2PlyCommand implements CommandExecutor { - @Override - public boolean onCommand(CommandSender commandSender, Command command, String label, String[] args) { - if (!commandSender.hasPermission("pay2ply.command")) { - commandSender.sendMessage(String.format("%sVocê não possui permissão para executar este comando.", ChatColor.RED)); - return true; - } + @Override + public boolean onCommand(CommandSender commandSender, Command command, String label, String[] args) { + if (!commandSender.hasPermission("pay2ply.command")) { + commandSender.sendMessage(String.format("%sVocê não possui permissão para executar este comando.", ChatColor.RED)); + return true; + } - if (args.length > 0) { - String token = args[0].trim().toLowerCase(); + if (args.length > 0) { + String token = args[0].trim().toLowerCase(); - Pay2Ply.getInstance().getSdk().setToken(token); - Pay2Ply.getInstance().getConfig().set("settings.token", token); - Pay2Ply.getInstance().saveConfig(); + Pay2Ply.getInstance().getSdk().setToken(token); + Pay2Ply.getInstance().getConfig().set("settings.token", token); + Pay2Ply.getInstance().saveConfig(); - commandSender.sendMessage(String.format("%sSe o token do servidor estiver correto, a loja será vinculada em alguns instantes.", ChatColor.GREEN)); + commandSender.sendMessage(String.format("%sSe o token do servidor estiver correto, a loja será vinculada em alguns instantes.", ChatColor.GREEN)); - return true; - } else { - commandSender.sendMessage(String.format("%s/%s .", ChatColor.RED, "pay2ply")); - } + return true; + } else { + commandSender.sendMessage(String.format("%s/%s .", ChatColor.RED, "pay2ply")); + } - return false; - } + return false; + } }