Skip to content

Commit

Permalink
1.20.1 + Sign Change Checker + Discord Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ExceptedPrism3 committed Jun 16, 2023
1 parent d4366ab commit 734501b
Show file tree
Hide file tree
Showing 19 changed files with 273 additions and 29 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ Additions
[+] Plugin Prefix
[+] 1.7 server versions enums
[+] 1.19.2 / 1.19.3 Support
[+] 1.20.1 Support
[+] Sign Change Checker

Fixes
[!] Plugin not starting up correctly
Expand All @@ -197,6 +199,8 @@ Fixes
[!] LiteBans table not auto deleting on Velocity instance
[!] Toggle Commands are no longer case sensitive
[!] Chest Interaction errors when run on 1.8.8 servers & being run with other plugins
[!] Discord not working properly due to a mistake by me xD
[!] Corrected the exact location of sign placement

Changes
[*] Remade permissions which will log OP and NOT OP players until they're permitted with the exempt permission
Expand Down
4 changes: 2 additions & 2 deletions Logger-BungeeCord/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>

<artifactId>Logger-Bungeecord</artifactId>
<version>1.8.0.8</version>
<version>1.8.0.9</version>
<packaging>jar</packaging>

<name>Logger-BungeeCord</name>
Expand All @@ -19,7 +19,7 @@
<parent>
<artifactId>Logger</artifactId>
<groupId>me.prism3</groupId>
<version>1.8.0.8</version>
<version>1.8.0.9</version>
</parent>

<build>
Expand Down
8 changes: 4 additions & 4 deletions Logger-Shaded/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>Logger</artifactId>
<groupId>me.prism3</groupId>
<version>1.8.0.8</version>
<version>1.8.0.9</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -58,17 +58,17 @@
<dependency>
<groupId>me.prism3</groupId>
<artifactId>Logger-Spigot</artifactId>
<version>1.8.0.8</version>
<version>1.8.0.9</version>
</dependency>
<dependency>
<groupId>me.prism3</groupId>
<artifactId>Logger-Bungeecord</artifactId>
<version>1.8.0.8</version>
<version>1.8.0.9</version>
</dependency>
<dependency>
<groupId>me.prism3</groupId>
<artifactId>Logger-Velocity</artifactId>
<version>1.8.0.8</version>
<version>1.8.0.9</version>
</dependency>
</dependencies>
</project>
6 changes: 3 additions & 3 deletions Logger-Spigot/dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
<parent>
<artifactId>Logger</artifactId>
<groupId>me.prism3</groupId>
<version>1.8.0.2</version>
<version>1.8.0.9</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>Logger-Spigot</artifactId>
<name>Logger-Spigot</name>
<version>1.8.0.4</version>
<version>1.8.0.9</version>
<description>Log all Activities from Players or Server Side!</description>
<build>
<resources>
Expand Down Expand Up @@ -162,7 +162,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19.3-R0.1-SNAPSHOT</version>
<version>1.20-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
4 changes: 2 additions & 2 deletions Logger-Spigot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>

<artifactId>Logger-Spigot</artifactId>
<version>1.8.0.8</version>
<version>1.8.0.9</version>
<packaging>jar</packaging>

<name>Logger-Spigot</name>
Expand All @@ -19,7 +19,7 @@
<parent>
<artifactId>Logger</artifactId>
<groupId>me.prism3</groupId>
<version>1.8.0.8</version>
<version>1.8.0.9</version>
</parent>

<build>
Expand Down
5 changes: 3 additions & 2 deletions Logger-Spigot/src/main/java/me/prism3/logger/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ private void eventsInitializer() {
this.getServer().getPluginManager().registerEvents(new OnPlayerChat(), this);
this.getServer().getPluginManager().registerEvents(new OnCommand(), this);
this.getServer().getPluginManager().registerEvents(new Console(), this);
this.getServer().getPluginManager().registerEvents(new OnSign(), this);
this.getServer().getPluginManager().registerEvents(new OnSignPlacing(), this);
this.getServer().getPluginManager().registerEvents(new OnPlayerJoin(), this);
this.getServer().getPluginManager().registerEvents(new OnPlayerLeave(), this);
this.getServer().getPluginManager().registerEvents(new OnPlayerKick(), this);
Expand All @@ -162,6 +162,7 @@ private void eventsInitializer() {
this.getServer().getPluginManager().registerEvents(new PlayerInventory(), this);
this.getServer().getPluginManager().registerEvents(new OnCommandBlock(), this);
this.getServer().getPluginManager().registerEvents(new OnEntityDeath(), this);
this.getServer().getPluginManager().registerEvents(new OnSignChange(), this);

this.getServer().getPluginManager().registerEvents(new OnFurnace(), this);
this.getServer().getPluginManager().registerEvents(new OnCraft(), this);
Expand Down Expand Up @@ -300,4 +301,4 @@ private boolean langChecker() {
public DiscordFile getDiscordFile() { return this.discordFile; }

public Messages getMessages() { return this.messages; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class ExternalData {
"player_kick", "player_level", "Bucket_fill", "bucket_empty", "anvil", "item_drop", "enchanting",
"book_editing", "item_pickup", "furnace", "game_mode", "crafting", "registration", "server_start",
"server_stop", "console_commands", "ram", "tps", "portal_creation", "rcon", "primed_tnt", "command_block",
"chest_interaction", "entity_death").collect(Collectors.toCollection(ArrayList::new));
"chest_interaction", "entity_death", "sign_change").collect(Collectors.toCollection(ArrayList::new));

public void createTable() {

Expand Down Expand Up @@ -136,6 +136,10 @@ public void createTable() {
+ "(id BIGINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, server_name VARCHAR(30), date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP(), world VARCHAR(100)," +
"player_uuid VARCHAR(80), player_name VARCHAR(100), mob VARCHAR(50), x INT, y INT, z INT, is_staff TINYINT)");

stsm.executeUpdate("CREATE TABLE IF NOT EXISTS sign_change "
+ "(id BIGINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, server_name VARCHAR(30), date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP(), world VARCHAR(100)," +
"player_uuid VARCHAR(80), player_name VARCHAR(100), x INT, y INT, z INT, new_text VARCHAR(100), is_staff TINYINT)");

// Server Side Part
stsm.executeUpdate("CREATE TABLE IF NOT EXISTS server_start "
+ "(id BIGINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, server_name VARCHAR(30), date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP())");
Expand Down Expand Up @@ -954,6 +958,27 @@ public static void entityDeath(String serverName, Player player, String mob, int
} catch (SQLException e) { e.printStackTrace(); }
}

public static void signChange(String serverName, Player player, int x, int y, int z, String text, boolean staff) {

try (Connection connection = plugin.getExternal().getHikari().getConnection();
final PreparedStatement signChange = connection.prepareStatement("INSERT INTO sign_change" +
" (server_name, world, player_uuid, player_name, x, y, z, new_text, is_staff) VALUES(?,?,?,?,?,?,?,?,?)")) {

signChange.setString(1, serverName);
signChange.setString(2, player.getWorld().getName());
signChange.setString(3, player.getUniqueId().toString());
signChange.setString(4, player.getName());
signChange.setInt(5, x);
signChange.setInt(6, y);
signChange.setInt(7, z);
signChange.setString(8, text);
signChange.setBoolean(9, staff);

signChange.executeUpdate();

} catch (SQLException e) { e.printStackTrace(); }
}

public void emptyTable() {

if (externalDataDel <= 0) return;
Expand Down Expand Up @@ -1029,6 +1054,8 @@ public void emptyTable() {

stsm.executeUpdate("DELETE FROM command_block WHERE date < NOW() - INTERVAL " + externalDataDel + " DAY");

stsm.executeUpdate("DELETE FROM sign_change WHERE date < NOW() - INTERVAL " + externalDataDel + " DAY");

// Extras Side Part
if (EssentialsUtil.getEssentialsAPI() != null) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void createTable() {
playerDeath, playerTeleport, blockPlace, blockBreak, tps, ram, playerKick, portalCreation, playerLevel,
bucketFill, bucketEmpty, anvil, serverStart, serverStop, itemDrop, enchant, bookEditing, afk,
wrongPassword, itemPickup, furnace, rCon, gameMode, craft, vault, registration, primedTNT, chestInteraction, liteBans,
advancedBan, commandBlock, woodStripping, entityDeath;
advancedBan, commandBlock, woodStripping, entityDeath, signChange;

try {

Expand Down Expand Up @@ -134,6 +134,10 @@ public void createTable() {
"(server_name TEXT(30), date TIMESTAMP DEFAULT CURRENT_TIMESTAMP, world TEXT(50), player_uuid INTEGER, " +
"player_name TEXT(40), mob TEXT(50), x INTEGER, y INTEGER, z INTEGER, is_staff INTEGER)");

signChange = plugin.getSqLite().getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS sign_change" +
"(server_name TEXT(30), date TIMESTAMP DEFAULT CURRENT_TIMESTAMP, world TEXT(50), player_uuid INTEGER, " +
"player_name TEXT(40), x INTEGER, y INTEGER, z INTEGER, new_text TEXT(50), is_staff INTEGER)");

// Server Side Part
serverStart = plugin.getSqLite().getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS server_start" +
"(server_name TEXT(30), date TIMESTAMP DEFAULT CURRENT_TIMESTAMP PRIMARY KEY)");
Expand Down Expand Up @@ -273,6 +277,8 @@ public void createTable() {
chestInteraction.close();
entityDeath.executeUpdate();
entityDeath.close();
signChange.executeUpdate();
signChange.close();

serverStart.executeUpdate();
serverStart.close();
Expand Down Expand Up @@ -986,6 +992,26 @@ public static void insertEntityDeath(String serverName, Player player, String mo
} catch (SQLException e) { e.printStackTrace(); }
}

public static void insertSignChange(String serverName, Player player, int x, int y, int z, String text, boolean isStaff) {
try {
final PreparedStatement entityDeathStatement = plugin.getSqLite().getConnection().prepareStatement("INSERT INTO sign_change (server_name, date, world, player_uuid, player_name, x, y, z, new_text, is_staff) VALUES (?,?,?,?,?,?,?,?,?,?)");
entityDeathStatement.setString(1, serverName);
entityDeathStatement.setString(2, dateTimeFormatter.format(ZonedDateTime.now()));
entityDeathStatement.setString(3, player.getWorld().getName());
entityDeathStatement.setString(4, player.getUniqueId().toString());
entityDeathStatement.setString(5, player.getName());
entityDeathStatement.setInt(6, x);
entityDeathStatement.setInt(7, y);
entityDeathStatement.setInt(8, z);
entityDeathStatement.setString(9, text);
entityDeathStatement.setBoolean(10, isStaff);

entityDeathStatement.executeUpdate();
entityDeathStatement.close();

} catch (SQLException e) { e.printStackTrace(); }
}

public void emptyTable() {

if (sqliteDataDel <= 0) return;
Expand Down Expand Up @@ -1043,6 +1069,9 @@ public void emptyTable() {

final PreparedStatement entityDeath = plugin.getSqLite().getConnection().prepareStatement("DELETE FROM entity_death WHERE date <= datetime('now','-" + sqliteDataDel + " day')");

final PreparedStatement signChange = plugin.getSqLite().getConnection().prepareStatement("DELETE FROM sign_change WHERE date <= datetime('now','-" + sqliteDataDel + " day')");


// Server Side Part
final PreparedStatement serverStart = plugin.getSqLite().getConnection().prepareStatement("DELETE FROM server_start WHERE date <= datetime('now','-" + sqliteDataDel + " day')");

Expand Down Expand Up @@ -1165,6 +1194,8 @@ public void emptyTable() {
chestInteraction.close();
entityDeath.executeUpdate();
entityDeath.close();
signChange.executeUpdate();
signChange.close();

serverStart.executeUpdate();
serverStart.close();
Expand Down
19 changes: 15 additions & 4 deletions Logger-Spigot/src/main/java/me/prism3/logger/discord/Discord.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class Discord {
private TextChannel primedTNTChannel;
private TextChannel chestInteractionChannel;
private TextChannel entityDeathChannel;
private TextChannel signChangeChannel;

private TextChannel serverStartChannel;
private TextChannel serverStopChannel;
Expand Down Expand Up @@ -130,6 +131,8 @@ public void run() {

final String entityDeathChannelID = this.main.getDiscordFile().get().getString("Discord.Entity-Death.Channel-ID");

final String signChangeChannelID = this.main.getDiscordFile().get().getString("Discord.Sign-Change.Channel-ID");

// Server Side Part
final String serverStartChannelID = this.main.getDiscordFile().get().getString("Discord.Server-Side.Start.Channel-ID");

Expand Down Expand Up @@ -321,6 +324,12 @@ public void run() {

}

if (this.isValid(signChangeChannelID, "Log-Player.Sign-Change")) {

this.signChangeChannel = this.jda.getTextChannelById(signChangeChannelID);

}

// Server Side Part
if (this.isValid(serverStartChannelID, "Log-Server.Start")) {

Expand Down Expand Up @@ -420,8 +429,7 @@ private boolean isValid(String channelID, String path) {

if (channelID == null) return false;

return (!channelID.isEmpty() && this.main.getConfig().getBoolean(path) && !channelID.equals("LINK_HERE"));

return (!channelID.isEmpty() && this.main.getConfig().getBoolean(path) && (!channelID.equals("CHANNEL_ID") && !channelID.equals("LINK_HERE")));
}

public void staffChat(Player player, String content, boolean contentInAuthorLine) {
Expand Down Expand Up @@ -685,6 +693,11 @@ public void entityDeath(Player player, String content, boolean contentInAuthorLi
this.discordUtil(player, content, contentInAuthorLine, this.entityDeathChannel);
}

public void signChange(Player player, String content, boolean contentInAuthorLine) {

this.discordUtil(player, content, contentInAuthorLine, this.signChangeChannel);
}

private void discordUtil(Player player, String content, boolean contentInAuthorLine, TextChannel channel) {
if (channel == null) return;

Expand Down Expand Up @@ -716,6 +729,4 @@ public void disconnect() {
}
}
}

public JDA getJda() { return this.jda; }
}
Loading

0 comments on commit 734501b

Please sign in to comment.