diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..85e7c1d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/.idea/ diff --git a/build.sh b/build.sh old mode 100755 new mode 100644 diff --git a/gradlew b/gradlew old mode 100755 new mode 100644 diff --git a/obf.sh b/obf.sh new file mode 100644 index 0000000..22d1435 --- /dev/null +++ b/obf.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +# Run Gradle build +./gradlew build + +# Check if the build was successful +if [ $? -eq 0 ]; then + echo "Gradle build successful." + + # Obfuscate with Grunt + cd ./obf/ + java -jar grunt-1.5.7.jar + cd .. + + echo "Obfuscation complete." + + # SFTP upload + SFTP_HOST="192.168.1.199" + SFTP_USER="trouper" + SFTP_PASSWORD="Trouper12()1" + SFTP_REMOTE_DIR="/home/trouper/docker/data/plugins/" + + # Specify the local file to upload + LOCAL_FILE="./build/libs/Sentinel-0.2.5.jar" + + # Create a temporary file with a unique name + TEMP_FILE=$(mktemp) + + # Write the SFTP commands to the temporary file + echo "put $LOCAL_FILE $SFTP_REMOTE_DIR" > "$TEMP_FILE" + echo "bye" >> "$TEMP_FILE" + + # Use sftp non-interactively with the specified commands + sftp -oStrictHostKeyChecking=no -oBatchMode=no -b "$TEMP_FILE" "$SFTP_USER@$SFTP_HOST" < { log.info("\n]======----- Auth Success! -----======["); diff --git a/src/main/java/io/github/thetrouper/sentinel/server/Action.java b/src/main/java/io/github/thetrouper/sentinel/server/Action.java index e4c4836..5822f77 100644 --- a/src/main/java/io/github/thetrouper/sentinel/server/Action.java +++ b/src/main/java/io/github/thetrouper/sentinel/server/Action.java @@ -1,6 +1,7 @@ package io.github.thetrouper.sentinel.server; +import io.github.itzispyder.pdk.utils.SchedulerUtils; import io.github.itzispyder.pdk.utils.discord.DiscordEmbed; import io.github.itzispyder.pdk.utils.discord.DiscordWebhook; import io.github.thetrouper.sentinel.Sentinel; @@ -18,6 +19,7 @@ import org.bukkit.event.Cancellable; import org.bukkit.inventory.ItemStack; import java.util.List; +import java.util.concurrent.CompletableFuture; public class Action { @@ -170,18 +172,22 @@ public class Action { actions += Emojis.rightSort + " **Logged:** " + Emojis.success; try { - ServerUtils.sendDebugMessage("Executing webhook..."); - DiscordWebhook.create() - .username("Sentinel Anti-Nuke | Logs") - .avatar("https://r2.e-z.host/d440b58a-ba90-4839-8df6-8bba298cf817/3lwit5nt.png") - .addEmbed(DiscordEmbed.create() - .author(new DiscordEmbed.Author(actionTop,"https://builtbybit.com/resources/sentinel-anti-nuke.30130/",null)) - .title(actionTitle) - .desc(description) - .addField(new DiscordEmbed.Field("Actions:", actions,false)) - .thumbnail("https://crafatar.com/avatars/" + player.getUniqueId() + "?size=64&&overlay") - .color(action.getEmbedColor()) - .build()).send(Sentinel.mainConfig.plugin.webhook); + String finalDescription = description; + String finalActions = actions; + CompletableFuture.runAsync(()->{ + ServerUtils.sendDebugMessage("Executing webhook..."); + DiscordWebhook.create() + .username("Sentinel Anti-Nuke | Logs") + .avatar("https://r2.e-z.host/d440b58a-ba90-4839-8df6-8bba298cf817/3lwit5nt.png") + .addEmbed(DiscordEmbed.create() + .author(new DiscordEmbed.Author(actionTop,"https://builtbybit.com/resources/sentinel-anti-nuke.30130/",null)) + .title(actionTitle) + .desc(finalDescription) + .addField(new DiscordEmbed.Field("Actions:", finalActions,false)) + .thumbnail("https://crafatar.com/avatars/" + (player == null ? "049460f7-21cb-42f5-8059-d42752bf406f" : player.getUniqueId()) + "?size=64&&overlay") + .color(action.getEmbedColor()) + .build()).send(Sentinel.mainConfig.plugin.webhook); + }); } catch (Exception e) { ServerUtils.sendDebugMessage(Text.prefix("Epic webhook failure!!!")); Sentinel.log.info(e.toString()); diff --git a/src/main/java/io/github/thetrouper/sentinel/server/FilterAction.java b/src/main/java/io/github/thetrouper/sentinel/server/FilterAction.java index 65b15ed..42148ff 100644 --- a/src/main/java/io/github/thetrouper/sentinel/server/FilterAction.java +++ b/src/main/java/io/github/thetrouper/sentinel/server/FilterAction.java @@ -18,6 +18,7 @@ import org.bukkit.event.player.AsyncPlayerChatEvent; import java.math.RoundingMode; import java.text.DecimalFormat; +import java.util.concurrent.CompletableFuture; import static io.github.thetrouper.sentinel.server.functions.AntiSpam.heatMap; import static io.github.thetrouper.sentinel.server.functions.AntiSpam.lastMessageMap; @@ -200,21 +201,26 @@ public class FilterAction { } try { - ServerUtils.sendDebugMessage("Executing webhook..."); - DiscordWebhook.create() - .username("Sentinel Anti-Nuke | Logs") - .avatar("https://r2.e-z.host/d440b58a-ba90-4839-8df6-8bba298cf817/3lwit5nt.png") - .addEmbed(DiscordEmbed.create() - .author(new DiscordEmbed.Author(supertitle,"https://builtbybit.com/resources/sentinel-anti-nuke.30130/",null)) - .title(title) - .desc(String.valueOf(description)) - .addField(new DiscordEmbed.Field(historyTitle,historyValue,true)) - .addField(new DiscordEmbed.Field(currentTitle,currentValue,true)) - .addField(new DiscordEmbed.Field("Executed: ", executed.replaceAll("%player%",offender.getName()),false)) - .thumbnail("https://crafatar.com/avatars/" + offender.getUniqueId() + "?size=64&&overlay") - .color(type.getColor()) - .build()).send(Sentinel.mainConfig.plugin.webhook); - + String finalHistoryTitle = historyTitle; + String finalHistoryValue = historyValue; + String finalCurrentTitle = currentTitle; + String finalCurrentValue = currentValue; + CompletableFuture.runAsync(()->{ + ServerUtils.sendDebugMessage("Executing webhook..."); + DiscordWebhook.create() + .username("Sentinel Anti-Nuke | Logs") + .avatar("https://r2.e-z.host/d440b58a-ba90-4839-8df6-8bba298cf817/3lwit5nt.png") + .addEmbed(DiscordEmbed.create() + .author(new DiscordEmbed.Author(supertitle,"https://builtbybit.com/resources/sentinel-anti-nuke.30130/",null)) + .title(title) + .desc(String.valueOf(description)) + .addField(new DiscordEmbed.Field(finalHistoryTitle, finalHistoryValue,true)) + .addField(new DiscordEmbed.Field(finalCurrentTitle, finalCurrentValue,true)) + .addField(new DiscordEmbed.Field("Executed: ", executed.replaceAll("%player%",offender.getName()),false)) + .thumbnail("https://crafatar.com/avatars/" + offender.getUniqueId() + "?size=64&&overlay") + .color(type.getColor()) + .build()).send(Sentinel.mainConfig.plugin.webhook); + }); } catch (Exception ex) { ServerUtils.sendDebugMessage("Filter Actions: Epic webhook failure!!!"); Sentinel.log.info(ex.toString()); diff --git a/src/main/java/io/github/thetrouper/sentinel/server/functions/CMDBlockWhitelist.java b/src/main/java/io/github/thetrouper/sentinel/server/functions/CMDBlockWhitelist.java index 83e3645..d8b3c67 100644 --- a/src/main/java/io/github/thetrouper/sentinel/server/functions/CMDBlockWhitelist.java +++ b/src/main/java/io/github/thetrouper/sentinel/server/functions/CMDBlockWhitelist.java @@ -24,7 +24,6 @@ public class CMDBlockWhitelist { Location wll = WhitelistedBlock.fromSerialized(wl.loc()); if (wll.distance(wbl) < 0.5) { Sentinel.whitelist.whitelistedCMDBlocks.remove(wb); - break; } } diff --git a/src/main/java/io/github/thetrouper/sentinel/server/util/FileValidationUtils.java b/src/main/java/io/github/thetrouper/sentinel/server/util/FileValidationUtils.java deleted file mode 100644 index d2a0024..0000000 --- a/src/main/java/io/github/thetrouper/sentinel/server/util/FileValidationUtils.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.github.thetrouper.sentinel.server.util; - -import java.io.File; - -public final class FileValidationUtils { - - public static boolean validate(File file) { - try { - if (!file.getParentFile().exists()) - if (!file.getParentFile().mkdirs()) - return false; - if (!file.exists()) - return file.createNewFile(); - return true; - } - catch (Exception ex) { - return false; - } - } -}