-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
669 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# maven | ||
target/ | ||
dependency-reduced-pom.xml | ||
|
||
# vim | ||
.*.sw[a-p] | ||
|
||
# various other potential build files | ||
build/ | ||
bin/ | ||
dist/ | ||
manifest.mf | ||
|
||
# Mac filesystem dust | ||
.DS_Store/ | ||
|
||
# intellij | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea/ | ||
|
||
# Linux temp files | ||
*~ | ||
|
||
# Java | ||
*.jar | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,7 @@ | ||
# GodsEyeDiscordLogger | ||
# GodsEyeDiscordLogger | ||
|
||
Hello there! I made this simple plugin to log GodsEye punishments and alerts on discord | ||
|
||
I'm open for any suggestions + tips | ||
|
||
Made with ♥ By TehSteel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>me.tehsteel</groupId> | ||
<artifactId>godseyediscordlogger</artifactId> | ||
<name>GodsEyeDiscordLogger</name> | ||
<version>1.0.0</version> | ||
|
||
<properties> | ||
<java.version>1.8</java.version> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
|
||
<repositories> | ||
<!-- Spigot --> | ||
<repository> | ||
<id>spigotmc-repo</id> | ||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url> | ||
</repository> | ||
</repositories> | ||
|
||
<dependencies> | ||
<!-- Spigot --> | ||
<dependency> | ||
<groupId>org.spigotmc</groupId> | ||
<artifactId>spigot-api</artifactId> | ||
<version>1.16.4-R0.1-SNAPSHOT</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<!-- GodsEye --> | ||
<dependency> | ||
<groupId>me.nort721</groupId> | ||
<artifactId>GodsEye</artifactId> | ||
<version>Build 42</version> | ||
<systemPath>${project.basedir}/lib/GodsEye.jar</systemPath> | ||
<scope>system</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.8.1</version> | ||
<configuration> | ||
<source>${java.version}</source> | ||
<target>${java.version}</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<version>3.2.4</version> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>shade</goal> | ||
</goals> | ||
<configuration> | ||
<createDependencyReducedPom>false</createDependencyReducedPom> | ||
<minimizeJar>false</minimizeJar> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
<resources> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
<filtering>true</filtering> | ||
</resource> | ||
</resources> | ||
</build> | ||
|
||
</project> |
23 changes: 23 additions & 0 deletions
23
src/main/java/me/tehsteel/godseyediscordlogger/Constants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package me.tehsteel.godseyediscordlogger; | ||
|
||
/** | ||
* @author TehSteel | ||
* @link https://github.com/TehSteel/GodsEyeDiscordLogger | ||
*/ | ||
public final class Constants { | ||
public static class Alert { | ||
public static String Webhook = ""; | ||
public static String Title = ""; | ||
public static String Description = ""; | ||
} | ||
|
||
public static class Punish { | ||
public static String Webhook = ""; | ||
public static String Title = ""; | ||
public static String Description = ""; | ||
|
||
} | ||
|
||
private Constants() { | ||
} | ||
} |
118 changes: 118 additions & 0 deletions
118
src/main/java/me/tehsteel/godseyediscordlogger/GodsEyeDiscordLogger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
package me.tehsteel.godseyediscordlogger; | ||
|
||
import godseye.GodsEyeAlertEvent; | ||
import godseye.GodsEyePunishPlayerEvent; | ||
import me.tehsteel.godseyediscordlogger.util.DiscordWebhook; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.ChatColor; | ||
import org.bukkit.configuration.file.FileConfiguration; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
import java.io.IOException; | ||
import java.util.Arrays; | ||
|
||
/** | ||
* @author TehSteel | ||
* @link https://github.com/TehSteel/GodsEyeDiscordLogger | ||
*/ | ||
public class GodsEyeDiscordLogger extends JavaPlugin implements Listener { | ||
|
||
|
||
@Override | ||
public void onEnable() { | ||
super.onEnable(); | ||
|
||
getConfig().options().copyDefaults(); | ||
saveDefaultConfig(); | ||
|
||
Bukkit.getPluginManager().registerEvents(this, this); | ||
|
||
loadConstants(); | ||
|
||
getLogger().info(ChatColor.GREEN + "Thanks for using GodsEyeDiscordLogger :)"); | ||
|
||
} | ||
|
||
@Override | ||
public void onDisable() { | ||
super.onDisable(); | ||
|
||
getLogger().info(ChatColor.GREEN + "Thanks for using GodsEyeDiscordLogger :)"); | ||
} | ||
|
||
|
||
@EventHandler | ||
public void onPlayerAlertEvent(final GodsEyeAlertEvent event) { | ||
final String name = event.getPlayer().getName(); | ||
final DiscordWebhook webhook = new DiscordWebhook(Constants.Alert.Webhook); | ||
webhook.addEmbed(new DiscordWebhook.EmbedObject() | ||
.setTitle(Constants.Alert.Title.replace("{player}", name) | ||
.replace("{checktype}", event.getCheckType().getName())) | ||
.setDescription(Constants.Alert.Description | ||
.replace("{player}", name) | ||
.replace("{checktype}", event.getCheckType().getName()) | ||
.replace("{vl}", String.valueOf(event.getViolationCount()))) | ||
); | ||
|
||
Bukkit.getScheduler().runTaskAsynchronously(this, new Runnable() { | ||
@Override | ||
public void run() { | ||
try { | ||
webhook.execute(); | ||
} catch (final IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
}); | ||
|
||
} | ||
|
||
@EventHandler | ||
public void onPlayerPunishEvent(final GodsEyePunishPlayerEvent event) { | ||
final String name = event.getPlayer().getName(); | ||
final String checkType = event.getCheckType().getName(); | ||
final DiscordWebhook webhook = new DiscordWebhook(Constants.Punish.Webhook); | ||
webhook.addEmbed(new DiscordWebhook.EmbedObject() | ||
.setTitle(Constants.Punish.Title | ||
.replace("{player}", name) | ||
.replace("{checktype}", checkType)) | ||
.setDescription(Constants.Punish.Description | ||
.replace("{player}", name) | ||
.replace("{checktype}", checkType)) | ||
); | ||
|
||
Bukkit.getScheduler().runTaskAsynchronously(this, new Runnable() { | ||
@Override | ||
public void run() { | ||
try { | ||
webhook.execute(); | ||
} catch (final IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
|
||
private void loadConstants() { | ||
final FileConfiguration con = getConfig(); | ||
|
||
Arrays.asList(Constants.Alert.class.getFields()).forEach(field -> { | ||
try { | ||
field.set(String.class, con.getString("Alert." + field.getName())); | ||
} catch (final IllegalAccessException ignore) { | ||
} | ||
}); | ||
|
||
Arrays.asList(Constants.Punish.class.getFields()).forEach(field -> { | ||
try { | ||
field.set(String.class, con.getString("Punish." + field.getName())); | ||
} catch (final IllegalAccessException ignore) { | ||
} | ||
}); | ||
|
||
|
||
} | ||
} |
Oops, something went wrong.