From d8ea53336585c330164aa2f42413d0199be94152 Mon Sep 17 00:00:00 2001 From: KamikazeVerde ! <136932172+KamikazeVerde@users.noreply.github.com> Date: Fri, 15 Nov 2024 21:39:11 +0100 Subject: [PATCH 1/2] Update CheatNotify.java --- src/main/java/it/creeper/roman/notify/CheatNotify.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/it/creeper/roman/notify/CheatNotify.java b/src/main/java/it/creeper/roman/notify/CheatNotify.java index dcd24cf..1ca6d95 100644 --- a/src/main/java/it/creeper/roman/notify/CheatNotify.java +++ b/src/main/java/it/creeper/roman/notify/CheatNotify.java @@ -76,7 +76,7 @@ public void fail(Player player, String... debug) { ALERT_MESSAGE = plugin.getConfig().getString("messages.alert-message"); } } else { - System.out.println("Nessuna annotazione MyAnnotation trovata sulla classe chiamante."); + System.out.println("// FAIL //"); } } catch (ClassNotFoundException e) { e.printStackTrace(); From ac4aa16b1d3673975db922ed516d3d6f05a0f104 Mon Sep 17 00:00:00 2001 From: vincyxiroff Date: Wed, 27 Nov 2024 20:10:17 +0100 Subject: [PATCH 2/2] discord webhook --- .idea/.gitignore | 3 - .idea/artifacts/RomanAC_jar.xml | 17 --- .idea/compiler.xml | 13 -- .idea/discord.xml | 7 - .idea/encodings.xml | 7 - .idea/jarRepositories.xml | 40 ------ .idea/misc.xml | 14 -- .idea/modules.xml | 8 -- .idea/uiDesigner.xml | 124 ------------------ pom.xml | 9 ++ src/main/java/it/creeper/roman/Roman.java | 3 +- .../it/creeper/roman/notify/CheatNotify.java | 25 +++- src/main/resources/config.yml | 8 ++ 13 files changed, 39 insertions(+), 239 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/artifacts/RomanAC_jar.xml delete mode 100644 .idea/compiler.xml delete mode 100644 .idea/discord.xml delete mode 100644 .idea/encodings.xml delete mode 100644 .idea/jarRepositories.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/uiDesigner.xml diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 26d3352..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml diff --git a/.idea/artifacts/RomanAC_jar.xml b/.idea/artifacts/RomanAC_jar.xml deleted file mode 100644 index 7e851c4..0000000 --- a/.idea/artifacts/RomanAC_jar.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - $PROJECT_DIR$/out/artifacts/RomanAC_jar - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index e40703e..0000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/discord.xml b/.idea/discord.xml deleted file mode 100644 index d8e9561..0000000 --- a/.idea/discord.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml deleted file mode 100644 index aa00ffa..0000000 --- a/.idea/encodings.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml deleted file mode 100644 index 88cedb2..0000000 --- a/.idea/jarRepositories.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index ae9c995..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index ff1a178..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml deleted file mode 100644 index 2b63946..0000000 --- a/.idea/uiDesigner.xml +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/pom.xml b/pom.xml index 0edf83c..a95fdfb 100644 --- a/pom.xml +++ b/pom.xml @@ -51,6 +51,10 @@ + + jitpack.io + https://jitpack.io + spigotmc-repo https://hub.spigotmc.org/nexus/content/repositories/snapshots/ @@ -70,6 +74,11 @@ + + com.github.micartey + webhookly + master-SNAPSHOT + org.spigotmc spigot-api diff --git a/src/main/java/it/creeper/roman/Roman.java b/src/main/java/it/creeper/roman/Roman.java index f0e8b89..553f62d 100644 --- a/src/main/java/it/creeper/roman/Roman.java +++ b/src/main/java/it/creeper/roman/Roman.java @@ -25,7 +25,7 @@ public final class Roman extends JavaPlugin { public Mathemathics math; public Data data; public Map hittedPlayers = new HashMap<>(); - public static Long minToTick(long min) { + public static long minToTick(long min) { return min * 60 * 20; } public void onEnable() { @@ -105,4 +105,5 @@ public Ban getBanManager() { public Mathemathics getMath() { return math; } + } diff --git a/src/main/java/it/creeper/roman/notify/CheatNotify.java b/src/main/java/it/creeper/roman/notify/CheatNotify.java index 1ca6d95..9aaa426 100644 --- a/src/main/java/it/creeper/roman/notify/CheatNotify.java +++ b/src/main/java/it/creeper/roman/notify/CheatNotify.java @@ -3,12 +3,12 @@ import it.creeper.roman.Roman; import it.creeper.roman.check.CheckInfo; import me.clip.placeholderapi.PlaceholderAPI; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.OfflinePlayer; -import org.bukkit.Server; +import me.micartey.webhookly.DiscordWebhook; +import me.micartey.webhookly.embeds.EmbedObject; +import org.bukkit.*; import org.bukkit.entity.Player; +import java.awt.Color; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.IOException; @@ -74,11 +74,26 @@ public void fail(Player player, String... debug) { //Bukkit.broadcast(ChatColor.translateAlternateColorCodes('&', ALERT_PREFIX + " "+"&6"+ cheater.getName() + " &r&7potrebbe star utilizzando &2&l"+check+" &r&7VL: " + vl.get(cheater)), "roman.notify"); Bukkit.broadcast(ChatColor.translateAlternateColorCodes('&', ALERT_PREFIX + " " + ALERT_MESSAGE + " &7" + Arrays.toString(debug)), "roman.notify"); ALERT_MESSAGE = plugin.getConfig().getString("messages.alert-message"); + + // webhook discord + + DiscordWebhook webhook = new DiscordWebhook(plugin.getConfig().getString("discord.webhook-url")); + webhook.setAvatarUrl(plugin.getConfig().getString("discord.webhook-avatar")); + webhook.setUsername(plugin.getConfig().getString("discord.webhook-username")); + + EmbedObject embed = new EmbedObject() + .setTitle(plugin.getConfig().getString("discord.embed-title")) + .setColor(new Color(255, 0 ,0)) + .setDescription(ALERT_MESSAGE); + + webhook.getEmbeds().add(embed); + webhook.execute(); + } } else { System.out.println("// FAIL //"); } - } catch (ClassNotFoundException e) { + } catch (ClassNotFoundException | IOException e) { e.printStackTrace(); } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index c39d5e0..68e8865 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -33,3 +33,11 @@ checks: punishment: "kick" test-1: false test-2: false + + +discord: + webhook-url: "" + webhook-avatar: "" + webhook-username: "" + # now we do the embed + embed-title: ""