Skip to content

Commit

Permalink
Another update
Browse files Browse the repository at this point in the history
Added:
+ Update checker (Can be disabled in the config)
+ An option to overwrite saves (Disabled by default)
If you are using MySQL and the database detects that a recording is already saved, (If you kick players instead of banning and they rejoin and instantly hack again) an error will be printed in console. With this disabled a random number between 1 - 100 will be added to the end of the file name so you can save different recordings of a player hacking.

Fixed:
Attempted to make the plugin compatible with PlugMan or other reloading plugins. This is probably the most I will do to attempt to support these types of plugins. I still recommend rebooting the server when you install/edit my plugin.
  • Loading branch information
JustinDevB committed Nov 24, 2021
1 parent 96221a9 commit c397292
Show file tree
Hide file tree
Showing 36 changed files with 77 additions and 32 deletions.
2 changes: 1 addition & 1 deletion dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>me.justindevb</groupId>
<artifactId>VulcanReplay</artifactId>
<name>VulcanReplay</name>
<version>1.3</version>
<version>1.4</version>
<url>http://maven.apache.org</url>
<build>
<defaultGoal>clean package install</defaultGoal>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>me.justindevb</groupId>
<artifactId>VulcanReplay</artifactId>
<version>1.3</version>
<version>1.4</version>
<packaging>jar</packaging>

<name>VulcanReplay</name>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package me.justindevb.VulcanReplay;
package me.justindevb.VulcanReplay.Listeners;

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
Expand All @@ -8,6 +8,9 @@
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;

import me.justindevb.VulcanReplay.PlayerCache;
import me.justindevb.VulcanReplay.VulcanReplay;

public class PlayerListener implements Listener {

private VulcanReplay vulcanReplay;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package me.justindevb.VulcanReplay;
package me.justindevb.VulcanReplay.Listeners;

import java.awt.Color;
import java.io.IOException;
Expand All @@ -9,11 +9,11 @@
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.TimeUnit;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
Expand All @@ -25,6 +25,9 @@
import me.frep.vulcan.api.event.VulcanFlagEvent;
import me.frep.vulcan.api.event.VulcanPunishEvent;
import me.jumper251.replay.api.ReplayAPI;
import me.justindevb.VulcanReplay.Util.DiscordWebhook;
import me.justindevb.VulcanReplay.PlayerCache;
import me.justindevb.VulcanReplay.VulcanReplay;

public class VulcanListener implements Listener {

Expand All @@ -40,6 +43,7 @@ public class VulcanListener implements Listener {
private String SERVER_NAME = "";
private double PLAYER_RANGE = 0D;
private long delay = 2;
private boolean OVERWRITE = false;

final ReplayAPI replay = ReplayAPI.getInstance();

Expand Down Expand Up @@ -110,8 +114,7 @@ public void run() {
replay.stopReplay(replayName, true);
vulcanReplay.log("Saving recording of attempted hack...", false);
vulcanReplay.log("Saved as: " + replayName, false);
sendDiscordWebhook(replayName, p,
getOnlineTime(loginTime, System.currentTimeMillis()));
sendDiscordWebhook(replayName, p, getOnlineTime(loginTime, System.currentTimeMillis()));
punishList.remove(p.getName());

if (alertList.contains(p.getName()))
Expand Down Expand Up @@ -196,9 +199,27 @@ private String getTimeStamp() {

String[] part = time.split("T");

return part[0];
if (this.OVERWRITE)
return part[0];

return part[0] + "." + getRandomSalt();

}

/**
* Random number between 1 and 100
* @return
*/
private int getRandomSalt() {
Random rand = new Random();
int n = 100 - 1 + 1;
int val = rand.nextInt() % n;
return Math.abs(val);
}

/**
* Initialize our config values
*/
private void initConfigFields() {
FileConfiguration config = vulcanReplay.getConfig();
this.WEBHOOK_URL = config.getString("Discord.Webhook");
Expand All @@ -210,6 +231,7 @@ private void initConfigFields() {

this.disabledRecordings = config.getStringList("General.Disabled-Recordings");
this.delay = config.getLong("General.Recording-Length");
this.OVERWRITE = config.getBoolean("General.Overwrite");
}

private long getOnlineTime(long loginTime, long currentTime) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package me.justindevb.VulcanReplay;
package me.justindevb.VulcanReplay.Util;

import javax.net.ssl.HttpsURLConnection;
import java.awt.Color;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package me.justindevb.VulcanReplpay.util;
package me.justindevb.VulcanReplay.Util;

import java.io.IOException;
import java.io.InputStream;
Expand Down
24 changes: 22 additions & 2 deletions src/main/java/me/justindevb/VulcanReplay/VulcanReplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;

import me.justindevb.VulcanReplpay.util.UpdateChecker;
import me.justindevb.VulcanReplay.Listeners.PlayerListener;
import me.justindevb.VulcanReplay.Listeners.VulcanListener;
import me.justindevb.VulcanReplay.Util.UpdateChecker;

public class VulcanReplay extends JavaPlugin {

Expand All @@ -31,6 +34,8 @@ public void onEnable() {
initBstats();

checkForUpdate();

handleReload();

}

Expand Down Expand Up @@ -110,11 +115,12 @@ private void initConfig() {
list.add("strafe");
config.addDefault("Genral.Disabled-Recordings", list);
config.addDefault("General.Recording-Length", 2);
config.addDefault("General.Overwrite", false);

String path = "Discord.";
config.addDefault(path + "Enabled", true);
config.addDefault(path + "Webhook", "Enter webhook here");
config.addDefault(path + "Avatar", "Enter link to a discord avatar");
config.addDefault(path + "Avatar", "https://i.imgur.com/JPG1Kwk.png");
config.addDefault(path + "Username", "VulcanReplay");
config.addDefault(path + "Server-Name", "Server");
config.options().copyDefaults(true);
Expand Down Expand Up @@ -186,4 +192,18 @@ private void checkForUpdate() {
});
}

/**
* Attempt to handle if the plugin was reloaded with /reload or PlugMan
*/
private void handleReload() {
Bukkit.getScheduler().runTask(this, () -> {
if (!Bukkit.getOnlinePlayers().isEmpty()) {
for (Player p : Bukkit.getOnlinePlayers()) {
PlayerCache cachedPlayer = new PlayerCache(p, this);
putCachedPlayer(p.getUniqueId(), cachedPlayer);
}
}
});
}

}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified target/classes/me/justindevb/VulcanReplay/VulcanReplay.class
Binary file not shown.
2 changes: 1 addition & 1 deletion target/classes/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: VulcanReplay
main: me.justindevb.VulcanReplay.VulcanReplay
version: 1.3
version: 1.4
author: JustinDevB
depend: [AdvancedReplay, Vulcan]
api-version: 1.13
4 changes: 2 additions & 2 deletions target/maven-archiver/pom.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Generated by Maven
#Wed Nov 24 10:02:13 CST 2021
#Wed Nov 24 13:33:52 CST 2021
groupId=me.justindevb
artifactId=VulcanReplay
version=1.3
version=1.4
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
me\justindevb\VulcanReplay\Util\DiscordWebhook$1.class
me\justindevb\VulcanReplay\VulcanReplay.class
me\justindevb\VulcanReplay\VulcanListener.class
me\justindevb\VulcanReplay\DiscordWebhook$EmbedObject$Image.class
me\justindevb\VulcanReplay\DiscordWebhook$JSONObject.class
me\justindevb\VulcanReplay\DiscordWebhook.class
me\justindevb\VulcanReplay\DiscordWebhook$EmbedObject$Author.class
me\justindevb\VulcanReplay\DiscordWebhook$EmbedObject.class
me\justindevb\VulcanReplay\VulcanListener$1.class
me\justindevb\VulcanReplay\PlayerListener.class
me\justindevb\VulcanReplay\DiscordWebhook$EmbedObject$Footer.class
me\justindevb\VulcanReplpay\util\UpdateChecker.class
me\justindevb\VulcanReplay\DiscordWebhook$EmbedObject$Field.class
me\justindevb\VulcanReplay\Util\DiscordWebhook$EmbedObject$Author.class
me\justindevb\VulcanReplay\Listeners\PlayerListener.class
me\justindevb\VulcanReplay\Util\DiscordWebhook$EmbedObject$Thumbnail.class
me\justindevb\VulcanReplay\Listeners\VulcanListener.class
me\justindevb\VulcanReplay\Util\UpdateChecker.class
me\justindevb\VulcanReplay\Util\DiscordWebhook$EmbedObject$Field.class
me\justindevb\VulcanReplay\Util\DiscordWebhook$EmbedObject.class
me\justindevb\VulcanReplay\Util\DiscordWebhook$EmbedObject$Image.class
me\justindevb\VulcanReplay\PlayerCache.class
me\justindevb\VulcanReplay\DiscordWebhook$1.class
me\justindevb\VulcanReplay\DiscordWebhook$EmbedObject$Thumbnail.class
me\justindevb\VulcanReplay\Listeners\VulcanListener$1.class
me\justindevb\VulcanReplay\Util\DiscordWebhook$JSONObject.class
me\justindevb\VulcanReplay\Util\DiscordWebhook$EmbedObject$Footer.class
me\justindevb\VulcanReplay\Util\DiscordWebhook.class
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
C:\Users\Justin\eclipse-workspace\VulcanReplay\src\main\java\me\justindevb\VulcanReplpay\util\UpdateChecker.java
C:\Users\Justin\eclipse-workspace\VulcanReplay\src\main\java\me\justindevb\VulcanReplay\Util\DiscordWebhook.java
C:\Users\Justin\eclipse-workspace\VulcanReplay\src\main\java\me\justindevb\VulcanReplay\Util\UpdateChecker.java
C:\Users\Justin\eclipse-workspace\VulcanReplay\src\main\java\me\justindevb\VulcanReplay\PlayerCache.java
C:\Users\Justin\eclipse-workspace\VulcanReplay\src\main\java\me\justindevb\VulcanReplay\PlayerListener.java
C:\Users\Justin\eclipse-workspace\VulcanReplay\src\main\java\me\justindevb\VulcanReplay\VulcanListener.java
C:\Users\Justin\eclipse-workspace\VulcanReplay\src\main\java\me\justindevb\VulcanReplay\Listeners\PlayerListener.java
C:\Users\Justin\eclipse-workspace\VulcanReplay\src\main\java\me\justindevb\VulcanReplay\Listeners\VulcanListener.java
C:\Users\Justin\eclipse-workspace\VulcanReplay\src\main\java\me\justindevb\VulcanReplay\VulcanReplay.java
C:\Users\Justin\eclipse-workspace\VulcanReplay\src\main\java\me\justindevb\VulcanReplay\DiscordWebhook.java
Binary file removed target/original-VulcanReplay-1.3.jar
Binary file not shown.
Binary file added target/original-VulcanReplay-1.4.jar
Binary file not shown.

0 comments on commit c397292

Please sign in to comment.