Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

discord webhook #4

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .idea/.gitignore

This file was deleted.

17 changes: 0 additions & 17 deletions .idea/artifacts/RomanAC_jar.xml

This file was deleted.

13 changes: 0 additions & 13 deletions .idea/compiler.xml

This file was deleted.

7 changes: 0 additions & 7 deletions .idea/discord.xml

This file was deleted.

7 changes: 0 additions & 7 deletions .idea/encodings.xml

This file was deleted.

40 changes: 0 additions & 40 deletions .idea/jarRepositories.xml

This file was deleted.

14 changes: 0 additions & 14 deletions .idea/misc.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

124 changes: 0 additions & 124 deletions .idea/uiDesigner.xml

This file was deleted.

9 changes: 9 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
</build>

<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
Expand All @@ -70,6 +74,11 @@
</repositories>

<dependencies>
<dependency>
<groupId>com.github.micartey</groupId>
<artifactId>webhookly</artifactId>
<version>master-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/it/creeper/roman/Roman.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public final class Roman extends JavaPlugin {
public Mathemathics math;
public Data data;
public Map<Player, Boolean> hittedPlayers = new HashMap<>();
public static Long minToTick(long min) {
public static long minToTick(long min) {
return min * 60 * 20;
}
public void onEnable() {
Expand Down Expand Up @@ -105,4 +105,5 @@ public Ban getBanManager() {
public Mathemathics getMath() {
return math;
}

}
27 changes: 21 additions & 6 deletions src/main/java/it/creeper/roman/notify/CheatNotify.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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("Nessuna annotazione MyAnnotation trovata sulla classe chiamante.");
System.out.println("// FAIL //");
}
} catch (ClassNotFoundException e) {
} catch (ClassNotFoundException | IOException e) {
e.printStackTrace();
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ""