diff --git a/bukkit/dependency-reduced-pom.xml b/bukkit/dependency-reduced-pom.xml index 9f85730..08ebbe7 100644 --- a/bukkit/dependency-reduced-pom.xml +++ b/bukkit/dependency-reduced-pom.xml @@ -3,7 +3,7 @@ Donation-Store-Minecraft net.donationstore - 2.2.3 + 2.3 4.0.0 donation-store-bukkit @@ -20,14 +20,6 @@ - - - - com.fasterxml.jackson - net.donationstore.plugin.internal.jackson - - - diff --git a/bukkit/pom.xml b/bukkit/pom.xml index 13930b1..2fb5079 100644 --- a/bukkit/pom.xml +++ b/bukkit/pom.xml @@ -5,7 +5,7 @@ Donation-Store-Minecraft net.donationstore - 2.2.3 + 2.3 4.0.0 @@ -40,14 +40,6 @@ org.apache.maven.plugins maven-shade-plugin 3.2.2 - - - - com.fasterxml.jackson - net.donationstore.plugin.internal.jackson - - - package diff --git a/bukkit/src/main/java/net/donationstore/bukkit/DonationStorePlugin.java b/bukkit/src/main/java/net/donationstore/bukkit/DonationStorePlugin.java index ed05237..2e4df68 100644 --- a/bukkit/src/main/java/net/donationstore/bukkit/DonationStorePlugin.java +++ b/bukkit/src/main/java/net/donationstore/bukkit/DonationStorePlugin.java @@ -24,7 +24,7 @@ public void onEnable() { plugin = this; - Log.toConsole(String.format(Logging.enableLog(), "Bukkit", "v2.2.3")); + Log.toConsole(String.format(Logging.enableLog(), "Bukkit", "v2.3")); config = plugin.getConfig(); @@ -54,7 +54,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St if (args.length == 0) { Log.send(sender, "Webstore and Helpdesk for Game Servers"); - Log.send(sender, "Bukkit Plugin - Version 2.2.3"); + Log.send(sender, "Bukkit Plugin - Version 2.3"); Log.send(sender, "https://donationstore.net"); Log.send(sender, "Type /ds help for command information"); } else { diff --git a/bukkit/src/main/java/net/donationstore/bukkit/queue/QueueTask.java b/bukkit/src/main/java/net/donationstore/bukkit/queue/QueueTask.java index 4335c04..c20fd20 100644 --- a/bukkit/src/main/java/net/donationstore/bukkit/queue/QueueTask.java +++ b/bukkit/src/main/java/net/donationstore/bukkit/queue/QueueTask.java @@ -41,7 +41,17 @@ public void run() { player = Bukkit.getPlayer(UUID.fromString(command.uuid)); } - if(player != null) { + boolean canExecuteCommand = false; + + if (command.requireOnline) { + if (player != null) { + canExecuteCommand = true; + } + } else { + canExecuteCommand = true; + } + + if(canExecuteCommand) { Bukkit.getServer().getScheduler().runTask(plugin, new Runnable() { @Override public void run() { diff --git a/bungeecord/pom.xml b/bungeecord/pom.xml index 9f61cb8..3197b10 100644 --- a/bungeecord/pom.xml +++ b/bungeecord/pom.xml @@ -5,7 +5,7 @@ Donation-Store-Minecraft net.donationstore - 2.2.3 + 2.3 4.0.0 diff --git a/bungeecord/src/main/java/net/donationstore/bungeecord/DonationStorePlugin.java b/bungeecord/src/main/java/net/donationstore/bungeecord/DonationStorePlugin.java index 20e0ec9..0d070a7 100644 --- a/bungeecord/src/main/java/net/donationstore/bungeecord/DonationStorePlugin.java +++ b/bungeecord/src/main/java/net/donationstore/bungeecord/DonationStorePlugin.java @@ -25,7 +25,7 @@ public void onEnable() { queueTask = new QueueTask(); - Log.toConsole(String.format(Logging.enableLog(), "BungeeCord", "v2.2.3")); + Log.toConsole(String.format(Logging.enableLog(), "BungeeCord", "v2.3")); try { configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(FileConfiguration.loadResource(plugin, "config.yml")); diff --git a/bungeecord/src/main/java/net/donationstore/bungeecord/commands/DonationStoreCommand.java b/bungeecord/src/main/java/net/donationstore/bungeecord/commands/DonationStoreCommand.java index 305496e..d0ecdfa 100644 --- a/bungeecord/src/main/java/net/donationstore/bungeecord/commands/DonationStoreCommand.java +++ b/bungeecord/src/main/java/net/donationstore/bungeecord/commands/DonationStoreCommand.java @@ -33,7 +33,7 @@ public DonationStoreCommand(Configuration configuration, Plugin plugin) { public void execute(CommandSender commandSender, String[] strings) { if(strings.length < 1) { Log.send(commandSender, "Webstore and Helpdesk for Game Servers"); - Log.send(commandSender, "BungeeCord Plugin - Version 2.2.3"); + Log.send(commandSender, "BungeeCord Plugin - Version 2.3"); Log.send(commandSender, "https://donationstore.net"); Log.send(commandSender, "Type /ds help for command information"); } else { diff --git a/bungeecord/src/main/java/net/donationstore/bungeecord/queue/QueueTask.java b/bungeecord/src/main/java/net/donationstore/bungeecord/queue/QueueTask.java index 202fd38..9fe5079 100644 --- a/bungeecord/src/main/java/net/donationstore/bungeecord/queue/QueueTask.java +++ b/bungeecord/src/main/java/net/donationstore/bungeecord/queue/QueueTask.java @@ -42,7 +42,17 @@ public void run() { player = plugin.getProxy().getPlayer(UUID.fromString(command.uuid)); } - if(player != null) { + boolean canExecuteCommand = false; + + if (command.requireOnline) { + if (player != null) { + canExecuteCommand = true; + } + } else { + canExecuteCommand = true; + } + + if(canExecuteCommand) { runCommand(plugin, command.command); updateCommandExecutedRequest.getCommands().add(command.id); } diff --git a/common/dependency-reduced-pom.xml b/common/dependency-reduced-pom.xml new file mode 100644 index 0000000..0b8d19c --- /dev/null +++ b/common/dependency-reduced-pom.xml @@ -0,0 +1,70 @@ + + + + Donation-Store-Minecraft + net.donationstore + 2.3 + + 4.0.0 + common + + + + maven-shade-plugin + 3.2.2 + + + package + + shade + + + + + + + com.fasterxml.jackson + net.donationstore.plugin.internal.jackson + + + com.squareup.okhttp3 + net.donationstore.plugin.internal.okhttp3 + + + + + + + + + junit + junit + 4.13 + test + + + hamcrest-core + org.hamcrest + + + + + org.springframework + spring-test + 5.2.3.RELEASE + test + + + spring-core + org.springframework + + + + + org.mockito + mockito-all + 1.10.19 + test + + + diff --git a/common/pom.xml b/common/pom.xml index 62c9a64..d9d6bd0 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -5,7 +5,7 @@ Donation-Store-Minecraft net.donationstore - 2.2.3 + 2.3 4.0.0 @@ -50,4 +50,34 @@ test + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.2 + + + + com.fasterxml.jackson + net.donationstore.plugin.internal.jackson + + + com.squareup.okhttp3 + net.donationstore.plugin.internal.okhttp3 + + + + + + package + + shade + + + + + + \ No newline at end of file diff --git a/common/src/main/java/net/donationstore/commands/CommandManager.java b/common/src/main/java/net/donationstore/commands/CommandManager.java index 8faa348..a80df66 100644 --- a/common/src/main/java/net/donationstore/commands/CommandManager.java +++ b/common/src/main/java/net/donationstore/commands/CommandManager.java @@ -20,6 +20,11 @@ public class CommandManager { private static String UUID_IDENTIFIER = "{uuid}"; private static String USERNAME_IDENTIFIER = "{username}"; private static String TRANSACTION_ID_IDENTIFIER = "{transactionId}"; + private static String SERVER_IDENTIFIER = "{server}"; + private static String AMOUNT_IDENTIFIER = "{amount}"; + private static String PACKAGE_ID_IDENTIFIER = "{packageId}"; + private static String PACKAGE_PRICE_IDENTIFIER = "{packagePrice}"; + private static String PACKAGE_NAME_IDENTIFIER = "{packageName}"; private ArrayList logs; private ObjectMapper objectMapper; @@ -67,17 +72,37 @@ public QueueResponse getCommands() throws Exception { } } - if (command.command.contains("{username}")) { + if (command.command.contains(USERNAME_IDENTIFIER)) { command.command = command.command.replace(USERNAME_IDENTIFIER, command.username); } - if (command.command.contains("{transactionId}")) { + if (command.command.contains(TRANSACTION_ID_IDENTIFIER)) { command.command = command.command.replace(TRANSACTION_ID_IDENTIFIER, payment.meta.transactionId); } - if (command.command.contains("{uuid}")) { + if (command.command.contains(UUID_IDENTIFIER)) { command.command = command.command.replace(UUID_IDENTIFIER, command.uuid); } + + if (command.command.contains(SERVER_IDENTIFIER)) { + command.command = command.command.replace(SERVER_IDENTIFIER, command.server); + } + + if (command.command.contains(AMOUNT_IDENTIFIER)) { + command.command = command.command.replace(AMOUNT_IDENTIFIER, command.amount); + } + + if (command.command.contains(PACKAGE_ID_IDENTIFIER)) { + command.command = command.command.replace(PACKAGE_ID_IDENTIFIER, Integer.toString(command.packageResponse.id)); + } + + if (command.command.contains(PACKAGE_PRICE_IDENTIFIER)) { + command.command = command.command.replace(PACKAGE_PRICE_IDENTIFIER, command.packageResponse.price); + } + + if (command.command.contains(PACKAGE_NAME_IDENTIFIER)) { + command.command = command.command.replace(PACKAGE_NAME_IDENTIFIER, command.packageResponse.name); + } } } diff --git a/common/src/main/java/net/donationstore/models/Command.java b/common/src/main/java/net/donationstore/models/Command.java index b06ba31..a9d4a11 100644 --- a/common/src/main/java/net/donationstore/models/Command.java +++ b/common/src/main/java/net/donationstore/models/Command.java @@ -1,8 +1,24 @@ package net.donationstore.models; +import com.fasterxml.jackson.annotation.JsonProperty; +import net.donationstore.models.response.PackageResponse; + public class Command { - public String command; public int id; + + public String command; + public String uuid; + + @JsonProperty("require_online") + public boolean requireOnline; + + public String server; + + public String amount; + public String username; + + @JsonProperty("package") + public PackageResponse packageResponse; } diff --git a/common/src/main/java/net/donationstore/models/Meta.java b/common/src/main/java/net/donationstore/models/Meta.java index bb64013..5bcbaa5 100644 --- a/common/src/main/java/net/donationstore/models/Meta.java +++ b/common/src/main/java/net/donationstore/models/Meta.java @@ -3,14 +3,17 @@ import com.fasterxml.jackson.annotation.JsonProperty; public class Meta { - @JsonProperty("payment_id") public String paymentId; public String user; + public String uuid; + @JsonProperty("transaction_id") public String transactionId; - public String uuid; + public String currency; + + public String email; } diff --git a/common/src/main/java/net/donationstore/models/response/PackageResponse.java b/common/src/main/java/net/donationstore/models/response/PackageResponse.java new file mode 100644 index 0000000..79344a4 --- /dev/null +++ b/common/src/main/java/net/donationstore/models/response/PackageResponse.java @@ -0,0 +1,7 @@ +package net.donationstore.models.response; + +public class PackageResponse { + public int id; + public String price; + public String name; +} diff --git a/pom.xml b/pom.xml index 03f2a47..24d76d7 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ net.donationstore Donation-Store-Minecraft - 2.2.3 + 2.3 pom bungeecord diff --git a/sponge/dependency-reduced-pom.xml b/sponge/dependency-reduced-pom.xml index b318d1b..ef97c35 100644 --- a/sponge/dependency-reduced-pom.xml +++ b/sponge/dependency-reduced-pom.xml @@ -3,7 +3,7 @@ Donation-Store-Minecraft net.donationstore - 2.2.3 + 2.3 4.0.0 donation-store-sponge @@ -26,6 +26,10 @@ com.fasterxml.jackson net.donationstore.plugin.internal.jackson + + com.squareup.okhttp3 + net.donationstore.plugin.internal.okhttp3 + diff --git a/sponge/pom.xml b/sponge/pom.xml index 8969bc9..d933bde 100644 --- a/sponge/pom.xml +++ b/sponge/pom.xml @@ -5,7 +5,7 @@ Donation-Store-Minecraft net.donationstore - 2.2.3 + 2.3 4.0.0 @@ -43,6 +43,10 @@ com.fasterxml.jackson net.donationstore.plugin.internal.jackson + + com.squareup.okhttp3 + net.donationstore.plugin.internal.okhttp3 + diff --git a/sponge/src/main/java/net/donationstore/sponge/DonationStorePlugin.java b/sponge/src/main/java/net/donationstore/sponge/DonationStorePlugin.java index 235ba48..e93374d 100644 --- a/sponge/src/main/java/net/donationstore/sponge/DonationStorePlugin.java +++ b/sponge/src/main/java/net/donationstore/sponge/DonationStorePlugin.java @@ -21,8 +21,9 @@ import java.nio.file.Path; import java.util.ArrayList; -@Plugin(id = "donationstore", name = "Donation Store", version = "2.2.3", description = "The Sponge Plugin for Donation Store webstores") +@Plugin(id = "donationstore", name = "Donation Store", version = "2.3", description = "The Sponge Plugin for Donation Store webstores") public class DonationStorePlugin { + public static DonationStorePlugin instance; @Inject @ConfigDir(sharedRoot = false) @@ -42,8 +43,17 @@ public class DonationStorePlugin { private PluginManager pluginManager = Sponge.getPluginManager(); + public FileConfiguration getFileConfiguration() { + return fileConfiguration; + } + + public static DonationStorePlugin getInstance() { + return instance; + } + @Listener public void onGamePreInitializationEvent(GamePreInitializationEvent event) { + instance = this; fileConfiguration = new FileConfiguration(configurationDir); if (fileConfiguration.getNode("queue-delay").getInt() == 0) { @@ -56,9 +66,9 @@ public void onGamePreInitializationEvent(GamePreInitializationEvent event) { @Listener public void onServerStart(GameStartedServerEvent event) { - logger.info(String.format(Logging.enableLog(), "Sponge", "v2.2.3")); + logger.info(String.format(Logging.enableLog(), "Sponge", "v2.3")); - Sponge.getCommandManager().register(pluginContainer, new DonationStoreCommand(fileConfiguration), "ds"); + Sponge.getCommandManager().register(pluginContainer, new DonationStoreCommand(), "ds"); queueTask.run(fileConfiguration, pluginContainer); } diff --git a/sponge/src/main/java/net/donationstore/sponge/commands/DonationStoreCommand.java b/sponge/src/main/java/net/donationstore/sponge/commands/DonationStoreCommand.java index 4fcf1f5..a300aa5 100644 --- a/sponge/src/main/java/net/donationstore/sponge/commands/DonationStoreCommand.java +++ b/sponge/src/main/java/net/donationstore/sponge/commands/DonationStoreCommand.java @@ -1,6 +1,7 @@ package net.donationstore.sponge.commands; import net.donationstore.commands.CommandFactory; +import net.donationstore.sponge.DonationStorePlugin; import net.donationstore.sponge.config.FileConfiguration; import net.donationstore.sponge.logging.Log; import org.spongepowered.api.command.CommandCallable; @@ -17,13 +18,8 @@ public class DonationStoreCommand implements CommandCallable { - private CommandFactory commandFactory; - private FileConfiguration fileConfiguration; - - public DonationStoreCommand(FileConfiguration configuration) { - this.fileConfiguration = configuration; - this.commandFactory = new CommandFactory(); - } + private final CommandFactory commandFactory = new CommandFactory(); + private final FileConfiguration fileConfiguration = DonationStorePlugin.getInstance().getFileConfiguration(); @Override public CommandResult process(CommandSource source, String arguments) throws CommandException { @@ -35,7 +31,7 @@ public CommandResult process(CommandSource source, String arguments) throws Comm } if(args.length < 1) { Log.send(source, "Webstore and Helpdesk for Game Servers"); - Log.send(source, "Sponge Plugin - Version 2.2.3"); + Log.send(source, "Sponge Plugin - Version 2.3"); Log.send(source, "https://donationstore.net"); Log.send(source, "Type /ds help for command information"); } else { diff --git a/sponge/src/main/java/net/donationstore/sponge/queue/QueueTask.java b/sponge/src/main/java/net/donationstore/sponge/queue/QueueTask.java index 37ac456..bbc59c7 100644 --- a/sponge/src/main/java/net/donationstore/sponge/queue/QueueTask.java +++ b/sponge/src/main/java/net/donationstore/sponge/queue/QueueTask.java @@ -49,7 +49,17 @@ public void run(FileConfiguration configuration, PluginContainer pluginContainer player = Sponge.getServer().getPlayer(UUID.fromString(command.uuid)); } - if (player.isPresent()) { + boolean canExecuteCommand = false; + + if (command.requireOnline) { + if (player.isPresent()) { + canExecuteCommand = true; + } + } else { + canExecuteCommand = true; + } + + if (canExecuteCommand) { syncExecutor.submit(() -> Sponge.getCommandManager().process(Sponge.getServer().getConsole(), command.command)); updateCommandExecutedRequest.getCommands().add(command.id); } diff --git a/velocity/pom.xml b/velocity/pom.xml index 4bb79a5..ca6d9f8 100644 --- a/velocity/pom.xml +++ b/velocity/pom.xml @@ -5,12 +5,12 @@ Donation-Store-Minecraft net.donationstore - 2.2.3 + 2.3 4.0.0 donation-store-velocity - 2.1.3 + 2.2 diff --git a/velocity/src/main/java/net/donationstore/velocity/DonationStorePlugin.java b/velocity/src/main/java/net/donationstore/velocity/DonationStorePlugin.java index 4be4828..9fa2af8 100644 --- a/velocity/src/main/java/net/donationstore/velocity/DonationStorePlugin.java +++ b/velocity/src/main/java/net/donationstore/velocity/DonationStorePlugin.java @@ -17,7 +17,7 @@ import java.nio.file.Path; -@Plugin(id = "donationstore", name = "Donation-Store-Velocity", version = "2.1.3", authors = {"Donation Store"}) +@Plugin(id = "donationstore", name = "Donation-Store-Velocity", version = "2.2", authors = {"Donation Store"}) public class DonationStorePlugin { private ProxyServer server; @@ -33,7 +33,7 @@ public DonationStorePlugin(ProxyServer server, @DataDirectory Path dataDirectory this.dataDirectory = dataDirectory; - Log.toConsole(String.format(Logging.enableLog(), "Velocity", "v2.1.3")); + Log.toConsole(String.format(Logging.enableLog(), "Velocity", "v2.2")); } @Subscribe diff --git a/velocity/src/main/java/net/donationstore/velocity/commands/DonationStoreCommand.java b/velocity/src/main/java/net/donationstore/velocity/commands/DonationStoreCommand.java index 4e31b91..6cfb6f2 100644 --- a/velocity/src/main/java/net/donationstore/velocity/commands/DonationStoreCommand.java +++ b/velocity/src/main/java/net/donationstore/velocity/commands/DonationStoreCommand.java @@ -27,7 +27,7 @@ public DonationStoreCommand(FileConfiguration configuration) { public void execute(@NonNull CommandSource commandSender, String[] strings) { if(strings.length < 1) { Log.send(commandSender, "Webstore and Helpdesk for Game Servers"); - Log.send(commandSender, "Velocity Plugin - Version 2.1.3"); + Log.send(commandSender, "Velocity Plugin - Version 2.2"); Log.send(commandSender, "https://donationstore.net"); Log.send(commandSender, "Type /ds help for command information"); } else {