Patched discord nullpointer

This commit is contained in:
TheTelly1
2024-02-20 08:12:55 -06:00
parent f6dc9e3629
commit c9ffde93ab
11 changed files with 282 additions and 52 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/.idea/

0
build.sh Executable file → Normal file
View File

0
gradlew vendored Executable file → Normal file
View File

59
obf.sh Normal file
View File

@@ -0,0 +1,59 @@
#!/bin/bash
# Run Gradle build
./gradlew build
# Check if the build was successful
if [ $? -eq 0 ]; then
echo "Gradle build successful."
# Obfuscate with Grunt
cd ./obf/
java -jar grunt-1.5.7.jar
cd ..
echo "Obfuscation complete."
# SFTP upload
SFTP_HOST="192.168.1.199"
SFTP_USER="trouper"
SFTP_PASSWORD="Trouper12()1"
SFTP_REMOTE_DIR="/home/trouper/docker/data/plugins/"
# Specify the local file to upload
LOCAL_FILE="./build/libs/Sentinel-0.2.5.jar"
# Create a temporary file with a unique name
TEMP_FILE=$(mktemp)
# Write the SFTP commands to the temporary file
echo "put $LOCAL_FILE $SFTP_REMOTE_DIR" > "$TEMP_FILE"
echo "bye" >> "$TEMP_FILE"
# Use sftp non-interactively with the specified commands
sftp -oStrictHostKeyChecking=no -oBatchMode=no -b "$TEMP_FILE" "$SFTP_USER@$SFTP_HOST" <<EOF
$SFTP_PASSWORD
EOF
# Remove the temporary file
rm -f "$TEMP_FILE"
echo "File uploaded via SFTP."
# SSH commands to reload the plugin on the host
SSH_HOST="trouper@$SFTP_HOST"
SSH_PASSWORD="Trouper12()1"
SSH_COMMANDS=(
"docker exec docker_mc_1 mc-send-to-console pm reload Sentinel"
"docker exec docker_mc_1 mc-send-to-console tellraw @a '\"'[Server] Reload Complete, Upload Successful.'\"'"
)
for cmd in "${SSH_COMMANDS[@]}"; do
sshpass -p "$SSH_PASSWORD" ssh -oStrictHostKeyChecking=no -oBatchMode=no "$SSH_HOST" "$cmd"
done
echo "Plugin reloaded."
else
echo "Gradle build failed."
fi

181
obf/config.json Normal file
View File

@@ -0,0 +1,181 @@
{
"Settings": {
"Input": "/run/media/trouper/1TB drive/IJ/IdeaProjects/Sentinel/build/libs/Sentinel-0.2.5.jar",
"Output": "/run/media/trouper/1TB drive/IJ/IdeaProjects/Sentinel/obf/out/Sentinel-0.2.5-beta.jar",
"Libraries": [
"/run/media/trouper/1TB drive/IJ/IdeaProjects/Sentinel/build/libraries/gson-2.10.1.jar",
"/run/media/trouper/1TB drive/IJ/IdeaProjects/Sentinel/build/libraries/adventure-api-4.15.0.jar",
"/run/media/trouper/1TB drive/IJ/IdeaProjects/Sentinel/build/libraries/adventure-key-4.15.0.jar",
"/run/media/trouper/1TB drive/IJ/IdeaProjects/Sentinel/build/libraries/adventure-text-logger-slf4j-4.15.0.jar",
"/run/media/trouper/1TB drive/IJ/IdeaProjects/Sentinel/build/libraries/adventure-text-minimessage-4.15.0.jar",
"/run/media/trouper/1TB drive/IJ/IdeaProjects/Sentinel/build/libraries/adventure-text-serializer-gson-4.15.0.jar",
"/run/media/trouper/1TB drive/IJ/IdeaProjects/Sentinel/build/libraries/adventure-text-serializer-json-4.15.0.jar",
"/run/media/trouper/1TB drive/IJ/IdeaProjects/Sentinel/build/libraries/adventure-text-serializer-legacy-4.15.0.jar",
"/run/media/trouper/1TB drive/IJ/IdeaProjects/Sentinel/build/libraries/adventure-text-serializer-plain-4.15.0.jar",
"/run/media/trouper/1TB drive/IJ/IdeaProjects/Sentinel/build/libraries/annotations-24.1.0.jar",
"/run/media/trouper/1TB drive/IJ/IdeaProjects/Sentinel/build/libraries/bungeecord-chat-1.20-R0.1.jar",
"/run/media/trouper/1TB drive/IJ/IdeaProjects/Sentinel/build/libraries/checker-qual-3.33.0.jar",
"/run/media/trouper/1TB drive/IJ/IdeaProjects/Sentinel/build/libraries/error_prone_annotations-2.18.0.jar",
"/run/media/trouper/1TB drive/IJ/IdeaProjects/Sentinel/build/libraries/examination-api-1.3.0.jar",
"/run/media/trouper/1TB drive/IJ/IdeaProjects/Sentinel/build/libraries/examination-string-1.3.0.jar",
"/run/media/trouper/1TB drive/IJ/IdeaProjects/Sentinel/build/libraries/failureaccess-1.0.1.jar",
"/run/media/trouper/1TB drive/IJ/IdeaProjects/Sentinel/build/libraries/fastutil-8.5.6.jar",
"/run/media/trouper/1TB drive/IJ/IdeaProjects/Sentinel/build/libraries/gson-2.10.1.jar",
"/run/media/trouper/1TB drive/IJ/IdeaProjects/Sentinel/build/libraries/guava-32.1.2-jre.jar",
"/run/media/trouper/1TB drive/IJ/IdeaProjects/Sentinel/build/libraries/j2objc-annotations-2.8.jar",
"/run/media/trouper/1TB drive/IJ/IdeaProjects/Sentinel/build/libraries/javax.inject-1.jar",
"/run/media/trouper/1TB drive/IJ/IdeaProjects/Sentinel/build/libraries/joml-1.10.5.jar",
"/run/media/trouper/1TB drive/IJ/IdeaProjects/Sentinel/build/libraries/json-simple-1.1.1.jar",
"/run/media/trouper/1TB drive/IJ/IdeaProjects/Sentinel/build/libraries/jsr305-3.0.2.jar",
"/run/media/trouper/1TB drive/IJ/IdeaProjects/Sentinel/build/libraries/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar",
"/run/media/trouper/1TB drive/IJ/IdeaProjects/Sentinel/build/libraries/org.eclipse.sisu.inject-0.9.0.M2.jar",
"/run/media/trouper/1TB drive/IJ/IdeaProjects/Sentinel/build/libraries/PDK-1.3.4.jar",
"/run/media/trouper/1TB drive/IJ/IdeaProjects/Sentinel/build/libraries/plexus-interpolation-1.26.jar",
"/run/media/trouper/1TB drive/IJ/IdeaProjects/Sentinel/build/libraries/plexus-utils-3.5.1.jar",
"/run/media/trouper/1TB drive/IJ/IdeaProjects/Sentinel/build/libraries/snakeyaml-2.2.jar",
"/run/media/trouper/1TB drive/IJ/IdeaProjects/Sentinel/build/libraries/spigot-api-1.20.2-R0.1-SNAPSHOT.jar"
],
"Exclusions": [
"com/google/gson/",
"io/github/itzispyder/"
],
"GenerateRemap": true,
"RemapOutput": "mappings.json",
"ParallelProcessing": false,
"CustomDictionary": [],
"DictionaryStartIndex": 0,
"CorruptOutput": true,
"FileRemovePrefix": [],
"FileRemoveSuffix": []
},
"AntiDebug": {
"Enabled": true,
"SourceDebug": true,
"LineDebug": true,
"RenameSourceDebug": true,
"SourceNames": [
"protected-by-sentinel.java"
]
},
"Shrinking": {
"Enabled": false,
"RemoveInnerClass": true,
"RemoveUnusedLabel": true,
"RemoveNOP": false,
"Exclusions": []
},
"KotlinOptimizer": {
"Enabled": false,
"RemoveMetadata": true,
"RemoveIntrinsics": true,
"IntrinsicsRemoval": [
"checkExpressionValueIsNotNull",
"checkNotNullExpressionValue",
"checkReturnedValueIsNotNull",
"checkFieldIsNotNull",
"checkParameterIsNotNull",
"checkNotNullParameter"
],
"IntrinsicsExclusions": [],
"MetadataExclusions": []
},
"StringEncrypt": {
"Enabled": true,
"Intensity": 4,
"Exclusions": [
"io/github/thetrouper/sentinel/data/config/",
"io/github/thetrouper/sentinel/data/cmdblocks/"
]
},
"NumberEncrypt": {
"Enabled": true,
"FloatingPoint": true,
"Intensity": 2,
"Exclusions": [
"io/github/thetrouper/sentinel/data/config/",
"io/github/thetrouper/sentinel/data/cmdblocks/"
]
},
"ScrambleTransformer": {
"Enabled": true,
"Intensity": 1,
"RandomName": true,
"RedirectGetStatic": true,
"RedirectSetStatic": true,
"RedirectGetValue": true,
"RedirectSetField": true,
"GenerateOuterClass": false,
"ExcludedClasses": [],
"ExcludedFieldName": [],
"NativeDownCalls": true,
"NativeUpCalls": false
},
"NativeCandidate": {
"Enabled": false,
"NativeAnnotation": "Lnet/spartanb312/example/Native;",
"UpCallLimit": 0,
"Exclusions": []
},
"LocalVariableRename": {
"Enabled": false,
"Dictionary": "Alphabet",
"ThisReference": false
},
"MethodRename": {
"Enabled": true,
"Dictionary": "Alphabet",
"HeavyOverloads": false,
"RandomKeywordPrefix": false,
"Prefix": "",
"Exclusion": [
"io/github/thetrouper/sentinel/data/config/",
"io/github/thetrouper/sentinel/data/cmdblocks/"
],
"ExcludedName": []
},
"FieldRename": {
"Enabled": true,
"Dictionary": "Alphabet",
"RandomKeywordPrefix": false,
"Prefix": "",
"Exclusion": [
"io/github/thetrouper/sentinel/data/config/",
"io/github/thetrouper/sentinel/data/cmdblocks/"
],
"ExcludedName": []
},
"ClassRename": {
"Enabled": true,
"Dictionary": "Alphabet",
"Parent": "sentinel/",
"Prefix": "",
"CorruptedName": false,
"CorruptedNameExclusions": [],
"ManifestReplace": [
"Main-Class"
],
"PluginMainReplace": false,
"BungeeMainReplace": false,
"Exclusion": [
"io/github/thetrouper/sentinel/Sentinel",
"io/github/thetrouper/sentinel/data/config/",
"io/github/thetrouper/sentinel/data/cmdblocks/"
],
"MixinSupport": false,
"MixinDictionary": "Alphabet",
"MixinPackage": "net/spartanb312/client/mixins/",
"TargetMixinPackage": "net/spartanb312/obf/mixins/",
"MixinFile": "mixins.example.json",
"RefmapFile": "mixins.example.refmap.json"
},
"ShuffleMembers": {
"Enabled": false,
"Methods": true,
"Fields": true,
"Annotations": false
},
"Watermark": {
"Enabled": false,
"Watermark Message": "COPYRIGHT_C_SENTINEL_2024"
}
}

BIN
obf/grunt-1.5.7.jar Normal file

Binary file not shown.

View File

@@ -82,7 +82,7 @@ public final class Sentinel extends JavaPlugin {
log.info("Pre-load finished!\n]====---- Requesting Authentication ----====[ \n- License Key: %s\n- Server ID: %s".formatted(license,serverID)); log.info("Pre-load finished!\n]====---- Requesting Authentication ----====[ \n- License Key: %s\n- Server ID: %s".formatted(license,serverID));
String authStatus = "ERROR"; String authStatus = "ERROR";
String authstatus = "ERROR"; String authstatus = "ERROR";
/*try { try {
authStatus = Authenticator.authorize(license, serverID); authStatus = Authenticator.authorize(license, serverID);
authstatus = Auth.authorize(license, serverID); authstatus = Auth.authorize(license, serverID);
IP = Authenticator.getPublicIPAddress(); IP = Authenticator.getPublicIPAddress();
@@ -91,9 +91,7 @@ public final class Sentinel extends JavaPlugin {
e.printStackTrace(); e.printStackTrace();
log.info("WTFFFF ARE YOU DOING MAN??????"); log.info("WTFFFF ARE YOU DOING MAN??????");
manager.disablePlugin(this); manager.disablePlugin(this);
}*/ }
authStatus = "AUTHORIZED";
switch (authStatus) { switch (authStatus) {
case "AUTHORIZED" -> { case "AUTHORIZED" -> {
log.info("\n]======----- Auth Success! -----======["); log.info("\n]======----- Auth Success! -----======[");

View File

@@ -1,6 +1,7 @@
package io.github.thetrouper.sentinel.server; package io.github.thetrouper.sentinel.server;
import io.github.itzispyder.pdk.utils.SchedulerUtils;
import io.github.itzispyder.pdk.utils.discord.DiscordEmbed; import io.github.itzispyder.pdk.utils.discord.DiscordEmbed;
import io.github.itzispyder.pdk.utils.discord.DiscordWebhook; import io.github.itzispyder.pdk.utils.discord.DiscordWebhook;
import io.github.thetrouper.sentinel.Sentinel; import io.github.thetrouper.sentinel.Sentinel;
@@ -18,6 +19,7 @@ import org.bukkit.event.Cancellable;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.util.List; import java.util.List;
import java.util.concurrent.CompletableFuture;
public class Action { public class Action {
@@ -170,6 +172,9 @@ public class Action {
actions += Emojis.rightSort + " **Logged:** " + Emojis.success; actions += Emojis.rightSort + " **Logged:** " + Emojis.success;
try { try {
String finalDescription = description;
String finalActions = actions;
CompletableFuture.runAsync(()->{
ServerUtils.sendDebugMessage("Executing webhook..."); ServerUtils.sendDebugMessage("Executing webhook...");
DiscordWebhook.create() DiscordWebhook.create()
.username("Sentinel Anti-Nuke | Logs") .username("Sentinel Anti-Nuke | Logs")
@@ -177,11 +182,12 @@ public class Action {
.addEmbed(DiscordEmbed.create() .addEmbed(DiscordEmbed.create()
.author(new DiscordEmbed.Author(actionTop,"https://builtbybit.com/resources/sentinel-anti-nuke.30130/",null)) .author(new DiscordEmbed.Author(actionTop,"https://builtbybit.com/resources/sentinel-anti-nuke.30130/",null))
.title(actionTitle) .title(actionTitle)
.desc(description) .desc(finalDescription)
.addField(new DiscordEmbed.Field("Actions:", actions,false)) .addField(new DiscordEmbed.Field("Actions:", finalActions,false))
.thumbnail("https://crafatar.com/avatars/" + player.getUniqueId() + "?size=64&&overlay") .thumbnail("https://crafatar.com/avatars/" + (player == null ? "049460f7-21cb-42f5-8059-d42752bf406f" : player.getUniqueId()) + "?size=64&&overlay")
.color(action.getEmbedColor()) .color(action.getEmbedColor())
.build()).send(Sentinel.mainConfig.plugin.webhook); .build()).send(Sentinel.mainConfig.plugin.webhook);
});
} catch (Exception e) { } catch (Exception e) {
ServerUtils.sendDebugMessage(Text.prefix("Epic webhook failure!!!")); ServerUtils.sendDebugMessage(Text.prefix("Epic webhook failure!!!"));
Sentinel.log.info(e.toString()); Sentinel.log.info(e.toString());

View File

@@ -18,6 +18,7 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.concurrent.CompletableFuture;
import static io.github.thetrouper.sentinel.server.functions.AntiSpam.heatMap; import static io.github.thetrouper.sentinel.server.functions.AntiSpam.heatMap;
import static io.github.thetrouper.sentinel.server.functions.AntiSpam.lastMessageMap; import static io.github.thetrouper.sentinel.server.functions.AntiSpam.lastMessageMap;
@@ -200,6 +201,11 @@ public class FilterAction {
} }
try { try {
String finalHistoryTitle = historyTitle;
String finalHistoryValue = historyValue;
String finalCurrentTitle = currentTitle;
String finalCurrentValue = currentValue;
CompletableFuture.runAsync(()->{
ServerUtils.sendDebugMessage("Executing webhook..."); ServerUtils.sendDebugMessage("Executing webhook...");
DiscordWebhook.create() DiscordWebhook.create()
.username("Sentinel Anti-Nuke | Logs") .username("Sentinel Anti-Nuke | Logs")
@@ -208,13 +214,13 @@ public class FilterAction {
.author(new DiscordEmbed.Author(supertitle,"https://builtbybit.com/resources/sentinel-anti-nuke.30130/",null)) .author(new DiscordEmbed.Author(supertitle,"https://builtbybit.com/resources/sentinel-anti-nuke.30130/",null))
.title(title) .title(title)
.desc(String.valueOf(description)) .desc(String.valueOf(description))
.addField(new DiscordEmbed.Field(historyTitle,historyValue,true)) .addField(new DiscordEmbed.Field(finalHistoryTitle, finalHistoryValue,true))
.addField(new DiscordEmbed.Field(currentTitle,currentValue,true)) .addField(new DiscordEmbed.Field(finalCurrentTitle, finalCurrentValue,true))
.addField(new DiscordEmbed.Field("Executed: ", executed.replaceAll("%player%",offender.getName()),false)) .addField(new DiscordEmbed.Field("Executed: ", executed.replaceAll("%player%",offender.getName()),false))
.thumbnail("https://crafatar.com/avatars/" + offender.getUniqueId() + "?size=64&&overlay") .thumbnail("https://crafatar.com/avatars/" + offender.getUniqueId() + "?size=64&&overlay")
.color(type.getColor()) .color(type.getColor())
.build()).send(Sentinel.mainConfig.plugin.webhook); .build()).send(Sentinel.mainConfig.plugin.webhook);
});
} catch (Exception ex) { } catch (Exception ex) {
ServerUtils.sendDebugMessage("Filter Actions: Epic webhook failure!!!"); ServerUtils.sendDebugMessage("Filter Actions: Epic webhook failure!!!");
Sentinel.log.info(ex.toString()); Sentinel.log.info(ex.toString());

View File

@@ -24,7 +24,6 @@ public class CMDBlockWhitelist {
Location wll = WhitelistedBlock.fromSerialized(wl.loc()); Location wll = WhitelistedBlock.fromSerialized(wl.loc());
if (wll.distance(wbl) < 0.5) { if (wll.distance(wbl) < 0.5) {
Sentinel.whitelist.whitelistedCMDBlocks.remove(wb); Sentinel.whitelist.whitelistedCMDBlocks.remove(wb);
break;
} }
} }

View File

@@ -1,20 +0,0 @@
package io.github.thetrouper.sentinel.server.util;
import java.io.File;
public final class FileValidationUtils {
public static boolean validate(File file) {
try {
if (!file.getParentFile().exists())
if (!file.getParentFile().mkdirs())
return false;
if (!file.exists())
return file.createNewFile();
return true;
}
catch (Exception ex) {
return false;
}
}
}