Fix build
This commit is contained in:
1 parent
45ae2870ca
commit
752ac2fd81
11 files changed
+4
-506
No files matched your search
+3
-17
@@ -137,7 +137,7 @@ subprojects {
|
||||
}
|
||||
|
||||
project(":core") {
|
||||
java { toolchain { languageVersion.set(JavaLanguageVersion.of(8)) } }
|
||||
java { toolchain { languageVersion.set(JavaLanguageVersion.of(17)) } }
|
||||
dependencies {
|
||||
compileOnly("com.google.code.gson:gson:2.8.9")
|
||||
implementation("com.github.thijsa:socket.io-client-java:1.0.3")
|
||||
@@ -171,21 +171,8 @@ project(":bukkit") {
|
||||
}
|
||||
}
|
||||
|
||||
project(":bungee") {
|
||||
java { toolchain { languageVersion.set(JavaLanguageVersion.of(8)) } }
|
||||
dependencies {
|
||||
implementation(project(":core"))
|
||||
compileOnly("net.md-5:bungeecord-api:1.10-SNAPSHOT")
|
||||
}
|
||||
tasks.named<ProcessResources>("processResources") {
|
||||
val props = mapOf("version" to rootProject.version.toString())
|
||||
inputs.properties(props)
|
||||
filesMatching("**/*") { expand(props) }
|
||||
}
|
||||
}
|
||||
|
||||
project(":sponge") {
|
||||
java { toolchain { languageVersion.set(JavaLanguageVersion.of(8)) } }
|
||||
java { toolchain { languageVersion.set(JavaLanguageVersion.of(17)) } }
|
||||
dependencies {
|
||||
implementation(project(":core"))
|
||||
compileOnly("org.spongepowered:spongeapi:7.1.0")
|
||||
@@ -198,7 +185,7 @@ project(":sponge") {
|
||||
}
|
||||
|
||||
project(":velocity") {
|
||||
java { toolchain { languageVersion.set(JavaLanguageVersion.of(8)) } }
|
||||
java { toolchain { languageVersion.set(JavaLanguageVersion.of(17)) } }
|
||||
dependencies {
|
||||
implementation(project(":core"))
|
||||
compileOnly("com.velocitypowered:velocity-api:3.0.0")
|
||||
@@ -220,7 +207,6 @@ project(":assembly") {
|
||||
dependencies {
|
||||
implementation(project(":core"))
|
||||
implementation(project(":bukkit"))
|
||||
implementation(project(":bungee"))
|
||||
implementation(project(":sponge"))
|
||||
implementation(project(":velocity"))
|
||||
}
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
package net.craftingstore.bungee;
|
||||
|
||||
import net.craftingstore.core.PluginConfiguration;
|
||||
|
||||
public class BungeePluginConfiguration implements PluginConfiguration {
|
||||
|
||||
private CraftingStoreBungee plugin;
|
||||
|
||||
BungeePluginConfiguration(CraftingStoreBungee plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "BungeeCord";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getMainCommands() {
|
||||
return new String[]{"csb"};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return plugin.getDescription().getVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlatform() {
|
||||
return plugin.getProxy().getVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuyCommandEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTimeBetweenCommands() {
|
||||
return plugin.getConfig().getInt("time-between-commands", 200);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNotEnoughBalanceMessage() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUsingAlternativeApi() {
|
||||
return plugin.getConfig().getBoolean("use-alternative-api", false);
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package net.craftingstore.bungee;
|
||||
|
||||
import net.craftingstore.bungee.commands.CraftingStoreCommand;
|
||||
import net.craftingstore.bungee.config.Config;
|
||||
import net.craftingstore.bungee.listeners.AdminJoinListener;
|
||||
import net.craftingstore.bungee.listeners.PendingDonationJoinListener;
|
||||
import net.craftingstore.core.CraftingStore;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import net.md_5.bungee.config.Configuration;
|
||||
|
||||
public class CraftingStoreBungee extends Plugin {
|
||||
|
||||
private Config config;
|
||||
private CraftingStore craftingStore;
|
||||
private String prefix = ChatColor.GRAY + "[" + ChatColor.RED + "CraftingStore" + ChatColor.GRAY + "] " + ChatColor.WHITE;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
config = new Config(this, "config.yml");
|
||||
this.craftingStore = new CraftingStore(new CraftingStoreBungeeImpl(this));
|
||||
getProxy().getPluginManager().registerCommand(this, new CraftingStoreCommand(this));
|
||||
getProxy().getPluginManager().registerListener(this, new AdminJoinListener(this));
|
||||
getProxy().getPluginManager().registerListener(this, new PendingDonationJoinListener(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
craftingStore.setEnabled(false);
|
||||
}
|
||||
|
||||
public Configuration getConfig() {
|
||||
return config.getConfig();
|
||||
}
|
||||
|
||||
public Config getConfigWrapper() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public CraftingStore getCraftingStore() {
|
||||
return craftingStore;
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
package net.craftingstore.bungee;
|
||||
|
||||
import net.craftingstore.bungee.events.DonationReceivedEvent;
|
||||
import net.craftingstore.core.CraftingStorePlugin;
|
||||
import net.craftingstore.core.PluginConfiguration;
|
||||
import net.craftingstore.core.logging.CraftingStoreLogger;
|
||||
import net.craftingstore.core.logging.impl.JavaLogger;
|
||||
import net.craftingstore.core.models.donation.Donation;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class CraftingStoreBungeeImpl implements CraftingStorePlugin {
|
||||
|
||||
private CraftingStoreBungee bungeePlugin;
|
||||
private JavaLogger logger;
|
||||
private BungeePluginConfiguration configuration;
|
||||
|
||||
CraftingStoreBungeeImpl(CraftingStoreBungee bungeePlugin) {
|
||||
this.bungeePlugin = bungeePlugin;
|
||||
this.configuration = new BungeePluginConfiguration(bungeePlugin);
|
||||
this.logger = new JavaLogger(bungeePlugin.getLogger());
|
||||
this.logger.setDebugging(bungeePlugin.getConfig().getBoolean("debug", false));
|
||||
}
|
||||
|
||||
public boolean executeDonation(final Donation donation) {
|
||||
ProxyServer proxy = bungeePlugin.getProxy();
|
||||
if (donation.getPlayer().isRequiredOnline()) {
|
||||
ProxiedPlayer player = proxy.getPlayer(donation.getPlayer().getUsername());
|
||||
if (player == null || !player.isConnected()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
DonationReceivedEvent event = new DonationReceivedEvent(donation);
|
||||
proxy.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
proxy.getScheduler().runAsync(bungeePlugin, () -> proxy.getPluginManager().dispatchCommand(proxy.getConsole(), donation.getCommand()));
|
||||
return true;
|
||||
}
|
||||
|
||||
public CraftingStoreLogger getLogger() {
|
||||
return this.logger;
|
||||
}
|
||||
|
||||
public void registerRunnable(Runnable runnable, int delay, int interval) {
|
||||
bungeePlugin.getProxy().getScheduler().schedule(bungeePlugin, runnable, delay, interval, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
public void runAsyncTask(Runnable runnable) {
|
||||
bungeePlugin.getProxy().getScheduler().runAsync(bungeePlugin, runnable);
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return bungeePlugin.getConfig().getString("api-key");
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginConfiguration getConfiguration() {
|
||||
return this.configuration;
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
package net.craftingstore.bungee.commands;
|
||||
|
||||
import net.craftingstore.bungee.CraftingStoreBungee;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
public class CraftingStoreCommand extends Command {
|
||||
|
||||
private CraftingStoreBungee instance;
|
||||
|
||||
public CraftingStoreCommand(CraftingStoreBungee instance) {
|
||||
super("csb", instance.getCraftingStore().ADMIN_PERMISSION);
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (!sender.hasPermission(instance.getCraftingStore().ADMIN_PERMISSION)) {
|
||||
sender.sendMessage(new TextComponent(instance.getPrefix() + "You don't have the required permission!"));
|
||||
return;
|
||||
}
|
||||
if (args.length == 1 && args[0].equalsIgnoreCase("reload")) {
|
||||
instance.getCraftingStore().reload();
|
||||
sender.sendMessage(new TextComponent(instance.getPrefix() + "The plugin is reloading!"));
|
||||
return;
|
||||
}
|
||||
if (args.length == 2 && args[0].equalsIgnoreCase("key")) {
|
||||
instance.getConfig().set("api-key", args[1]);
|
||||
instance.getConfigWrapper().saveConfig();
|
||||
instance.getProxy().getScheduler().runAsync(instance, () -> {
|
||||
try {
|
||||
if (instance.getCraftingStore().reload().get()) {
|
||||
sender.sendMessage(new TextComponent(instance.getPrefix() + "The new API key has been set in the config, and the plugin has been reloaded."));
|
||||
} else {
|
||||
sender.sendMessage(new TextComponent(instance.getPrefix() + "The API key is invalid. The plugin will not work until you set a valid API key."));
|
||||
}
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
if ((args.length == 1 || args.length == 2) && args[0].equalsIgnoreCase("debug")) {
|
||||
boolean isDebugging = this.instance.getCraftingStore().getLogger().isDebugging();
|
||||
if (args.length == 1) {
|
||||
sender.sendMessage(new TextComponent(String.format(
|
||||
"%sDebug mode is currently %s.",
|
||||
this.instance.getPrefix(),
|
||||
isDebugging ? "enabled" : "disabled"
|
||||
)));
|
||||
return;
|
||||
}
|
||||
String debugValue = args[1].toLowerCase();
|
||||
if (debugValue.equalsIgnoreCase("true")) {
|
||||
isDebugging = true;
|
||||
} else if (debugValue.equalsIgnoreCase("false")) {
|
||||
isDebugging = false;
|
||||
} else {
|
||||
sender.sendMessage(new TextComponent(instance.getPrefix() + "Unknown debug value."));
|
||||
return;
|
||||
}
|
||||
this.instance.getCraftingStore().getLogger().setDebugging(isDebugging);
|
||||
instance.getConfig().set("debug", isDebugging);
|
||||
instance.getConfigWrapper().saveConfig();
|
||||
sender.sendMessage(new TextComponent(String.format(
|
||||
"%sDebug mode has been %s.",
|
||||
this.instance.getPrefix(),
|
||||
isDebugging ? "enabled" : "disabled"
|
||||
)));
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage(new TextComponent(ChatColor.GRAY + "" + ChatColor.STRIKETHROUGH + "-----------------------"));
|
||||
sender.sendMessage(new TextComponent(ChatColor.DARK_GRAY + ">" + ChatColor.GRAY + " /csb reload" + ChatColor.DARK_GRAY + " -> " + ChatColor.GRAY + "Reload the config."));
|
||||
sender.sendMessage(new TextComponent(ChatColor.DARK_GRAY + ">" + ChatColor.GRAY + " /csb key <your key>" + ChatColor.DARK_GRAY + " -> " + ChatColor.GRAY + "Update the key."));
|
||||
sender.sendMessage(new TextComponent(ChatColor.GRAY + "" + ChatColor.STRIKETHROUGH + "-----------------------"));
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package net.craftingstore.bungee.config;
|
||||
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import net.md_5.bungee.config.Configuration;
|
||||
import net.md_5.bungee.config.ConfigurationProvider;
|
||||
import net.md_5.bungee.config.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class Config {
|
||||
|
||||
private Plugin instance;
|
||||
private Configuration configuration;
|
||||
private String filename;
|
||||
|
||||
public Config(Plugin instance, String filename) {
|
||||
this.instance = instance;
|
||||
this.filename = filename;
|
||||
|
||||
instance.getDataFolder().mkdir();
|
||||
|
||||
File file = new File(instance.getDataFolder(), filename);
|
||||
if (!file.exists()) {
|
||||
InputStream is = instance.getResourceAsStream(filename);
|
||||
if (is != null) {
|
||||
instance.getLogger().info("Copying default config file.");
|
||||
try {
|
||||
Files.copy(is, file.toPath());
|
||||
} catch (IOException e) {
|
||||
instance.getLogger().log(Level.SEVERE, "An error occurred while copying the default config file " + filename + ".", e);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
file.createNewFile();
|
||||
} catch (IOException e) {
|
||||
instance.getLogger().log(Level.SEVERE, "An error occurred while creating the config file " + filename + ".", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
reload();
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
try {
|
||||
configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(instance.getDataFolder(), filename));
|
||||
} catch (IOException e) {
|
||||
instance.getLogger().log(Level.SEVERE, "An error occurred while loading the config file " + filename + ".", e);
|
||||
}
|
||||
}
|
||||
|
||||
public Configuration getConfig() {
|
||||
if (configuration == null) {
|
||||
reload();
|
||||
}
|
||||
return configuration;
|
||||
}
|
||||
|
||||
public void saveConfig() {
|
||||
try {
|
||||
ConfigurationProvider.getProvider(YamlConfiguration.class).save(configuration, new File(instance.getDataFolder(), filename));
|
||||
} catch (IOException e) {
|
||||
instance.getLogger().log(Level.SEVERE, "An error occured while saving the config file " + filename + ".", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
package net.craftingstore.bungee.events;
|
||||
|
||||
import net.craftingstore.core.models.donation.Donation;
|
||||
import net.md_5.bungee.api.plugin.Cancellable;
|
||||
import net.md_5.bungee.api.plugin.Event;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class DonationReceivedEvent extends Event implements Cancellable {
|
||||
|
||||
@Deprecated
|
||||
private String command;
|
||||
@Deprecated
|
||||
private String username;
|
||||
@Deprecated
|
||||
private UUID uuid;
|
||||
@Deprecated
|
||||
private String packageName;
|
||||
@Deprecated
|
||||
private int packagePrice;
|
||||
@Deprecated
|
||||
private int couponDiscount;
|
||||
|
||||
private Donation donation;
|
||||
|
||||
private boolean cancelled = false;
|
||||
|
||||
@Deprecated
|
||||
public DonationReceivedEvent(String command, String username, UUID uuid, String packageName, int packagePrice, int couponDiscount) {
|
||||
this.command = command;
|
||||
this.username = username;
|
||||
this.uuid = uuid;
|
||||
this.packageName = packageName;
|
||||
this.packagePrice = packagePrice;
|
||||
this.couponDiscount = couponDiscount;
|
||||
}
|
||||
|
||||
public DonationReceivedEvent(Donation donation) {
|
||||
this.command = donation.getCommand();
|
||||
this.username = donation.getPlayer().getUsername();
|
||||
this.uuid = donation.getPlayer().getUUID();
|
||||
this.packageName = donation.getPackage().getName();
|
||||
this.packagePrice = donation.getPackage().getPrice();
|
||||
this.couponDiscount = donation.getDiscount();
|
||||
this.donation = donation;
|
||||
}
|
||||
|
||||
public Donation getDonation() {
|
||||
return this.donation;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String getCommand() {
|
||||
return command;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String getPackageName() {
|
||||
return packageName;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int getPackagePrice() {
|
||||
return packagePrice;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int getCouponDiscount() {
|
||||
return couponDiscount;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package net.craftingstore.bungee.listeners;
|
||||
|
||||
import net.craftingstore.bungee.CraftingStoreBungee;
|
||||
import net.craftingstore.core.models.api.misc.CraftingStoreInformation;
|
||||
import net.craftingstore.core.models.api.misc.UpdateInformation;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
public class AdminJoinListener implements Listener {
|
||||
|
||||
private CraftingStoreBungee instance;
|
||||
|
||||
public AdminJoinListener(CraftingStoreBungee instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPostLogin(PostLoginEvent e) {
|
||||
ProxiedPlayer p = e.getPlayer();
|
||||
if (!p.hasPermission(instance.getCraftingStore().ADMIN_PERMISSION)) {
|
||||
return;
|
||||
}
|
||||
CraftingStoreInformation information = instance.getCraftingStore().getInformation();
|
||||
UpdateInformation update = null;
|
||||
if (information != null) {
|
||||
update = information.getUpdateInformation();
|
||||
|
||||
// Update notification
|
||||
if (update != null) {
|
||||
p.sendMessage(new TextComponent(instance.getPrefix() + update.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
if (!instance.getCraftingStore().isEnabled()) {
|
||||
if (update != null && update.shouldDisable()) {
|
||||
p.sendMessage(new TextComponent(instance.getPrefix() + "The CraftingStore plugin has been disabled because this is an outdated version. Please update the plugin."));
|
||||
} else {
|
||||
p.sendMessage(new TextComponent(instance.getPrefix() + "The CraftingStore plugin has not been set-up correctly. Please set your API key using /csb key <your key>."));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
package net.craftingstore.bungee.listeners;
|
||||
|
||||
import net.craftingstore.bungee.CraftingStoreBungee;
|
||||
import net.craftingstore.core.exceptions.CraftingStoreApiException;
|
||||
import net.craftingstore.core.jobs.ProcessPendingPaymentsJob;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
public class PendingDonationJoinListener implements Listener {
|
||||
|
||||
private final CraftingStoreBungee instance;
|
||||
|
||||
public PendingDonationJoinListener(CraftingStoreBungee instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPostLogin(PostLoginEvent e) {
|
||||
ProxiedPlayer p = e.getPlayer();
|
||||
String username = p.getName();
|
||||
instance.getCraftingStore().getImplementation().runAsyncTask(() -> {
|
||||
try {
|
||||
new ProcessPendingPaymentsJob(instance.getCraftingStore(), username);
|
||||
} catch (CraftingStoreApiException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
name: CraftingStore
|
||||
main: net.craftingstore.bungee.CraftingStoreBungee
|
||||
version: ${version}
|
||||
author: thijs_a
|
||||
prefix: CraftingStore
|
||||
+1
-1
@@ -12,4 +12,4 @@ file("libs")
|
||||
project(":libs:${dir.name}").projectDir = dir
|
||||
}
|
||||
|
||||
include(":core", ":bukkit", ":bungee", ":sponge", ":assembly", ":velocity")
|
||||
include(":core", ":bukkit", ":sponge", ":assembly", ":velocity")
|
||||
Reference in new issue
Block a user