Compare commits
10 Commits
3e955489ea
...
1.1.42
| Author | SHA1 | Date | |
|---|---|---|---|
| 6b463cf5b3 | |||
| 0f834e5810 | |||
| dc680883ac | |||
| fb4baac9d4 | |||
| ace02fa9e8 | |||
| fe402f7dde | |||
| 628bfc397e | |||
| bbbbf9cada | |||
| 16d0fde833 | |||
| 02fc5f03a1 |
+3
-1
@@ -1,4 +1,4 @@
|
||||
.gradle
|
||||
/.gradle
|
||||
**/build/
|
||||
!src/**/build/
|
||||
|
||||
@@ -16,3 +16,5 @@ gradle-app.setting
|
||||
.project
|
||||
# JDT-specific (Eclipse Java Development Tools)
|
||||
.classpath
|
||||
|
||||
/bin
|
||||
generated
+1
-1
@@ -1 +1 @@
|
||||
mc-srv2-notifyonstart
|
||||
notifyonstart
|
||||
generated
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel target="17" />
|
||||
<bytecodeTargetLevel target="18" />
|
||||
</component>
|
||||
</project>
|
||||
generated
+1
@@ -5,6 +5,7 @@
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleJvm" value="17" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
|
||||
generated
+5
@@ -26,5 +26,10 @@
|
||||
<option name="name" value="maven" />
|
||||
<option name="url" value="https://oss.sonatype.org/content/repositories/snapshots" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="maven3" />
|
||||
<option name="name" value="maven3" />
|
||||
<option name="url" value="https://repo.opencollab.dev/main/" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
||||
generated
+1
-1
@@ -6,5 +6,5 @@
|
||||
</list>
|
||||
</component>
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="17" project-jdk-type="JavaSDK" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_18" default="true" project-jdk-name="17" project-jdk-type="JavaSDK" />
|
||||
</project>
|
||||
generated
+8
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/modules/notifyonstart.main.iml" filepath="$PROJECT_DIR$/.idea/modules/notifyonstart.main.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
generated
+13
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="minecraft" name="Minecraft">
|
||||
<configuration>
|
||||
<autoDetectTypes>
|
||||
<platformType>SPIGOT</platformType>
|
||||
</autoDetectTypes>
|
||||
<projectReimportVersion>1</projectReimportVersion>
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
</module>
|
||||
generated
+191
@@ -0,0 +1,191 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AutoImportSettings">
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="ce97b9f5-6785-4670-b350-12f90ab9ea27" name="Changes" comment="dunno if it works (2)" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="ExternalProjectsData">
|
||||
<projectState path="$PROJECT_DIR$">
|
||||
<ProjectState />
|
||||
</projectState>
|
||||
</component>
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="GitLabMergeRequestFiltersHistory">{
|
||||
"lastFilter": {
|
||||
"state": "OPENED",
|
||||
"assignee": {
|
||||
"type": "org.jetbrains.plugins.gitlab.mergerequest.ui.filters.GitLabMergeRequestsFiltersValue.MergeRequestsMemberFilterValue.MergeRequestsAssigneeFilterValue",
|
||||
"username": "mangorifo",
|
||||
"fullname": "rrryfoo"
|
||||
}
|
||||
}
|
||||
}</component>
|
||||
<component name="GitLabMergeRequestsSettings">{
|
||||
"selectedUrlAndAccountId": {
|
||||
"first": "https://git.sob.moe/sobrooms/notify-on-start",
|
||||
"second": "bb8a3a4e-cb6a-4b4f-aca5-fb589330d6a4"
|
||||
}
|
||||
}</component>
|
||||
<component name="MarkdownSettingsMigration">
|
||||
<option name="stateVersion" value="1" />
|
||||
</component>
|
||||
<component name="ProjectColorInfo">{
|
||||
"customColor": "",
|
||||
"associatedIndex": 8
|
||||
}</component>
|
||||
<component name="ProjectId" id="2VtRIra79d9tkHTc8fsXlFQRFWj" />
|
||||
<component name="ProjectViewState">
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"Downloaded.Files.Path.Enabled": "false",
|
||||
"Gradle.notify-on-start [build].executor": "Run",
|
||||
"Repository.Attach.Annotations": "false",
|
||||
"Repository.Attach.JavaDocs": "false",
|
||||
"Repository.Attach.Sources": "false",
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"RunOnceActivity.git.unshallow": "true",
|
||||
"git-widget-placeholder": "main",
|
||||
"last_opened_file_path": "G:/java/notify-on-start",
|
||||
"project.structure.last.edited": "Libraries",
|
||||
"project.structure.proportion": "0.0",
|
||||
"project.structure.side.proportion": "0.2",
|
||||
"settings.editor.selected.configurable": "reference.settingsdialog.project.gradle"
|
||||
}
|
||||
}]]></component>
|
||||
<component name="RunManager" selected="Gradle.notify-on-start [build]">
|
||||
<configuration name="notify-on-start [build]" type="GradleRunConfiguration" factoryName="Gradle" nameIsGenerated="true">
|
||||
<ExternalSystemSettings>
|
||||
<option name="executionName" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="externalSystemIdString" value="GRADLE" />
|
||||
<option name="scriptParameters" value="" />
|
||||
<option name="taskDescriptions">
|
||||
<list />
|
||||
</option>
|
||||
<option name="taskNames">
|
||||
<list>
|
||||
<option value="build" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="vmOptions" />
|
||||
</ExternalSystemSettings>
|
||||
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
|
||||
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
|
||||
<DebugAllEnabled>false</DebugAllEnabled>
|
||||
<RunAsTest>false</RunAsTest>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="notify-on-start [dependencies]" type="GradleRunConfiguration" factoryName="Gradle" temporary="true">
|
||||
<ExternalSystemSettings>
|
||||
<option name="executionName" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="externalSystemIdString" value="GRADLE" />
|
||||
<option name="scriptParameters" />
|
||||
<option name="taskDescriptions">
|
||||
<list />
|
||||
</option>
|
||||
<option name="taskNames">
|
||||
<list>
|
||||
<option value="dependencies" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="vmOptions" />
|
||||
</ExternalSystemSettings>
|
||||
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
|
||||
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
|
||||
<DebugAllEnabled>false</DebugAllEnabled>
|
||||
<RunAsTest>false</RunAsTest>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration default="true" type="JetRunConfigurationType">
|
||||
<module name="mc-srv2-notifyonstart" />
|
||||
<method v="2">
|
||||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
<configuration default="true" type="KotlinStandaloneScriptRunConfigurationType">
|
||||
<module name="mc-srv2-notifyonstart" />
|
||||
<option name="filePath" />
|
||||
<method v="2">
|
||||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
<recent_temporary>
|
||||
<list>
|
||||
<item itemvalue="Gradle.notify-on-start [dependencies]" />
|
||||
</list>
|
||||
</recent_temporary>
|
||||
</component>
|
||||
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
||||
<component name="TaskManager">
|
||||
<task active="true" id="Default" summary="Default task">
|
||||
<changelist id="ce97b9f5-6785-4670-b350-12f90ab9ea27" name="Changes" comment="" />
|
||||
<created>1695653315409</created>
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1695653315409</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="hmmm">
|
||||
<option name="closed" value="true" />
|
||||
<created>1695655158506</created>
|
||||
<option name="number" value="00001" />
|
||||
<option name="presentableId" value="LOCAL-00001" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1695655158506</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00002" summary="fix stuff and add more functionality (definitely) (hi again)">
|
||||
<option name="closed" value="true" />
|
||||
<created>1695656657760</created>
|
||||
<option name="number" value="00002" />
|
||||
<option name="presentableId" value="LOCAL-00002" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1695656657760</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00003" summary="wrong version number">
|
||||
<option name="closed" value="true" />
|
||||
<created>1695657371321</created>
|
||||
<option name="number" value="00003" />
|
||||
<option name="presentableId" value="LOCAL-00003" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1695657371321</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00004" summary="dunno if it works">
|
||||
<option name="closed" value="true" />
|
||||
<created>1699756821626</created>
|
||||
<option name="number" value="00004" />
|
||||
<option name="presentableId" value="LOCAL-00004" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1699756821626</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00005" summary="dunno if it works (2)">
|
||||
<option name="closed" value="true" />
|
||||
<created>1699768015200</created>
|
||||
<option name="number" value="00005" />
|
||||
<option name="presentableId" value="LOCAL-00005" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1699768015200</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="6" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="hmmm" />
|
||||
<MESSAGE value="fix stuff and add more functionality (definitely) (hi again)" />
|
||||
<MESSAGE value="wrong version number" />
|
||||
<MESSAGE value="dunno if it works" />
|
||||
<MESSAGE value="dunno if it works (2)" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="dunno if it works (2)" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -4,8 +4,10 @@ this project is made to just send messages to Discord webhooks when events trigg
|
||||
|
||||
this was just made to remember whatever goofy things we did in a minecraft server, in discord
|
||||
|
||||
or, you know, notify us when the server starts (notifies when you use the /stop command)
|
||||
or, you know, notify us when the server starts and ends (and other things...)
|
||||
|
||||
*(maki, 4/20/25)*
|
||||
this is a personal project, there are DEFINITELY better alternatives; this plugin is mostly server-exclusive
|
||||
# Prerequisites
|
||||
Before using this plugin, you must:
|
||||
* Get Spigot
|
||||
|
||||
+3
-1
@@ -3,16 +3,18 @@ plugins {
|
||||
}
|
||||
|
||||
group 'cf.sobrooms'
|
||||
version '1.1'
|
||||
version '1.1.4'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
|
||||
maven { url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }
|
||||
maven { url "https://repo.opencollab.dev/main/" }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly 'org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT'
|
||||
compileOnly 'org.geysermc.geyser:api:2.2.0-SNAPSHOT'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
|
||||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
|
||||
}
|
||||
|
||||
+1
-2
@@ -1,2 +1 @@
|
||||
rootProject.name = 'mc-srv2-notifyonstart'
|
||||
|
||||
rootProject.name = 'notifyonstart'
|
||||
@@ -15,27 +15,45 @@ import cf.sobrooms.events.weather.ThunderChange;
|
||||
import cf.sobrooms.events.weather.WeatherChange;
|
||||
import cf.sobrooms.events.world.WorldInit;
|
||||
import cf.sobrooms.events.world.WorldLoad;
|
||||
import cf.sobrooms.events.world.WorldSave;
|
||||
import cf.sobrooms.events.world.WorldUnload;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParser;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
public class Main extends JavaPlugin {
|
||||
public static File isLoggingConfig;
|
||||
public static File webhookConfig;
|
||||
private static boolean webhooksAreValidUrls;
|
||||
|
||||
public static boolean hdc;
|
||||
public static File greetConfig;
|
||||
public static void main(String... args) {
|
||||
System.out.printf("Initializing using server address: %s...%n", ServerUtils.address);
|
||||
}
|
||||
@Override
|
||||
public void onDisable() {
|
||||
if (Main.webhooksAreValidUrls) {
|
||||
DiscordWebhook notify = new DiscordWebhook(Main.getNotifyWebhook());
|
||||
DiscordWebhook.EmbedObject embedObject = new DiscordWebhook.EmbedObject().setTitle("The server has been disabled.").setDescription(String.format("The server at %s:%d is now shutting down.", Utils.getServerHostPublicIP(), Bukkit.getServer().getPort()))
|
||||
.addField("Date occurred (as a local timestamp)", new Date().toString(), false)
|
||||
.setColor(Color.DARK_GRAY);
|
||||
notify.addEmbed(embedObject);
|
||||
try {
|
||||
notify.execute();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onEnable() {
|
||||
String loggingDir = "./NoS";
|
||||
File directory = new File(loggingDir);
|
||||
@@ -46,17 +64,23 @@ public class Main extends JavaPlugin {
|
||||
System.out.println("Failed to create config directory: " + loggingDir);
|
||||
}
|
||||
}
|
||||
isLoggingConfig = new File("./NoS/willLogCommands.bool");
|
||||
isLoggingConfig = new File("./NoS/willLogEvents");
|
||||
greetConfig = new File("./NoS/greetText.txt");
|
||||
webhookConfig = new File("./NoS/config_webhook.json");
|
||||
try {
|
||||
if (isLoggingConfig.createNewFile()) {
|
||||
System.out.println("Config created: " + isLoggingConfig.getName());
|
||||
System.out.println("Configuration file created: " + isLoggingConfig.getName());
|
||||
//FileWriter notifyWebhookConfigWriter = new FileWriter(notifyWebhookConfig);
|
||||
//FileWriter pubMessageWebhookConfigWriter = new FileWriter(pubMessageWebhookConfig);
|
||||
//notifyWebhookConfigWriter.write("{\"url_notify\": \"default-ns\"}");
|
||||
FileWriter linkConfigWriter = new FileWriter(webhookConfig);
|
||||
linkConfigWriter.write("{\"url_publicmsg\": \"default-ns\", \"url_notify\": \"default-ns\"}");
|
||||
FileWriter greetConfigWriter = new FileWriter(greetConfig);
|
||||
greetConfigWriter.write("Welcome to $servername, $playername!");
|
||||
linkConfigWriter.write("""
|
||||
{"servername": "Nilou-PNK", "url_publicmsg": "default-ns", "url_notify": "default-ns", "entryMessage": "Welcome to @servername, @playername!"}
|
||||
""");
|
||||
linkConfigWriter.close();
|
||||
greetConfigWriter.close();
|
||||
//notifyWebhookConfigWriter.close();
|
||||
} else {
|
||||
System.out.println("Tried to create config even while it already exists, skipping step...");
|
||||
@@ -64,8 +88,8 @@ public class Main extends JavaPlugin {
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
// post
|
||||
Bukkit.getConsoleSender().sendMessage("Note: This Spigot/Bukkit plugin is highly verbose, so it will log a lot of events...");
|
||||
// such cap
|
||||
//Bukkit.getConsoleSender().sendMessage("Note: This Spigot/Bukkit plugin is highly verbose, so it will log a lot of events...");
|
||||
// register commands
|
||||
try {
|
||||
Objects.requireNonNull(this.getCommand("info")).setExecutor(new InfoCommand());
|
||||
@@ -76,7 +100,7 @@ public class Main extends JavaPlugin {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
webhooksAreValidUrls = validateWebhook_Ntfy();
|
||||
webhooksAreValidUrls = validateWebhook_Pub();
|
||||
hdc = validateWebhook_Pub();
|
||||
// register events
|
||||
if (getLoggingConfig().equals("true") && webhooksAreValidUrls)
|
||||
registerEvents();
|
||||
@@ -93,6 +117,10 @@ public class Main extends JavaPlugin {
|
||||
|
||||
public static boolean validateWebhook_Pub() {
|
||||
try {
|
||||
if (getPublicMessageWebhook().equals("default-ns") || !getPublicMessageWebhook().contains("https://")) {
|
||||
System.out.println("There was no webhook set for the public messages function. The send-message command cannot be used until you do.");
|
||||
return true;
|
||||
}
|
||||
URL url = new URL(getPublicMessageWebhook());
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
@@ -100,11 +128,12 @@ public class Main extends JavaPlugin {
|
||||
if (responseCode == HttpURLConnection.HTTP_OK) {
|
||||
return true;
|
||||
} else {
|
||||
System.out.println("Invalid webhook URL provided. Please create a new one.");
|
||||
System.out.println("Invalid webhook URL provided for your public messages. Please provide the correct webhook and check for any typos.");
|
||||
return false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Invalid webhook URL provided. Please create a new one.. (Caught exception)");
|
||||
System.out.println("Invalid webhook URL provide for your public messages. Please provide the correct webhook and check for any typos. (Caught exception)");
|
||||
System.out.printf("Exception: %s%n", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -117,11 +146,12 @@ public class Main extends JavaPlugin {
|
||||
if (responseCode == HttpURLConnection.HTTP_OK) {
|
||||
return true;
|
||||
} else {
|
||||
System.out.println("Invalid webhook URL provided. Please create a new one.");
|
||||
System.out.println("Invalid webhook URL provided for the event logs. Please provide the correct webhook and check for any typos.");
|
||||
return false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Invalid webhook URL provided. Please create a new one.. (Caught exception)");
|
||||
System.out.println("Invalid webhook URL provided for the event logs. Please provide the correct webhook and check for any typos. (Caught exception)");
|
||||
System.out.println("Exception: %s".formatted(e));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -131,34 +161,58 @@ public class Main extends JavaPlugin {
|
||||
JsonParser jsonReader = new JsonParser();
|
||||
JsonElement MsgParse = jsonReader.parse(brfmsg.readLine());
|
||||
String lineMsg = MsgParse.getAsJsonObject().get("url_publicmsg").getAsString();
|
||||
// validate url being url
|
||||
// but this won't validate the url being an actual webhook
|
||||
// i can try but lazy :sob:
|
||||
if (lineMsg.equals("default-ns")) {
|
||||
System.out.printf("Please set the public message webhook URL in %s and restart the server", webhookConfig.getAbsolutePath());
|
||||
webhooksAreValidUrls = false;
|
||||
return lineMsg;
|
||||
} else if (lineMsg.startsWith("https://") || lineMsg.startsWith("http://")) {
|
||||
|
||||
brfmsg.close();
|
||||
if (lineMsg.startsWith("https://") || lineMsg.startsWith("http://")) {
|
||||
webhooksAreValidUrls = true;
|
||||
return lineMsg;
|
||||
} else {
|
||||
System.out.printf("Please set the public message webhook URL in %s and restart the server", webhookConfig.getAbsolutePath());
|
||||
webhooksAreValidUrls = false;
|
||||
return lineMsg;
|
||||
}
|
||||
|
||||
return "default-ns";
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
public static String getServerName() {
|
||||
try {
|
||||
BufferedReader brfmsg = new BufferedReader(new FileReader(webhookConfig));
|
||||
JsonParser jsonReader = new JsonParser();
|
||||
JsonElement MsgParse = jsonReader.parse(brfmsg.readLine());
|
||||
String serverName = MsgParse.getAsJsonObject().get("servername").getAsString();
|
||||
|
||||
brfmsg.close();
|
||||
|
||||
return serverName;
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
public static String getGreetMessage(Player player) {
|
||||
try {
|
||||
BufferedReader brfmsg = new BufferedReader(new FileReader(webhookConfig));
|
||||
JsonParser jsonReader = new JsonParser();
|
||||
JsonElement MsgParse = jsonReader.parse(brfmsg.readLine());
|
||||
String entryMessage = MsgParse.getAsJsonObject().get("entryMessage").getAsString();
|
||||
String serverName = getServerName();
|
||||
String playername = player.getName();
|
||||
brfmsg.close();
|
||||
String finalOut = "";
|
||||
finalOut = entryMessage.replaceAll("@servername", serverName).replaceAll("@playername", playername);
|
||||
|
||||
return finalOut;
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getNotifyWebhook() {
|
||||
try {
|
||||
BufferedReader brfntfy = new BufferedReader(new FileReader(webhookConfig));
|
||||
JsonParser jsonReader = new JsonParser();
|
||||
JsonElement NtfyParse = jsonReader.parse(brfntfy.readLine());
|
||||
String lineNtfy = NtfyParse.getAsJsonObject().get("url_notify").getAsString();
|
||||
// validate url being url
|
||||
// but this won't validate the url being an actual webhook
|
||||
// i can try but lazy :sob:
|
||||
|
||||
brfntfy.close();
|
||||
if (lineNtfy.equals("default-ns")) {
|
||||
System.out.printf("Please set the webhook URL in %s and restart the server", webhookConfig.getAbsolutePath());
|
||||
webhooksAreValidUrls = false;
|
||||
@@ -177,16 +231,15 @@ public class Main extends JavaPlugin {
|
||||
}
|
||||
public static String getLoggingConfig() {
|
||||
try {
|
||||
File file = new File("./NoS/willLogCommands.bool");
|
||||
File file = new File("./NoS/willLogEvents");
|
||||
BufferedReader reader = new BufferedReader(new FileReader(file));
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
if (line.equals("true") || line.equals("false"))
|
||||
return line;
|
||||
else
|
||||
return "Content is not a boolean";
|
||||
return "";
|
||||
}
|
||||
reader.close();
|
||||
} catch (IOException e) {
|
||||
System.out.println("An error occurred while reading the configuration file.");
|
||||
e.printStackTrace();
|
||||
@@ -207,7 +260,6 @@ public class Main extends JavaPlugin {
|
||||
WeatherChange weatherChange = new WeatherChange();
|
||||
WorldInit worldInit = new WorldInit();
|
||||
WorldLoad worldLoad = new WorldLoad();
|
||||
WorldSave worldSave = new WorldSave();
|
||||
WorldUnload worldUnload = new WorldUnload();
|
||||
VehicleEnter vehicleEnter = new VehicleEnter();
|
||||
VehicleExit vehicleExit = new VehicleExit();
|
||||
@@ -222,7 +274,6 @@ public class Main extends JavaPlugin {
|
||||
getServer().getPluginManager().registerEvents(weatherChange, this);
|
||||
getServer().getPluginManager().registerEvents(worldInit, this);
|
||||
getServer().getPluginManager().registerEvents(worldLoad, this);
|
||||
getServer().getPluginManager().registerEvents(worldSave, this);
|
||||
getServer().getPluginManager().registerEvents(worldUnload, this);
|
||||
getServer().getPluginManager().registerEvents(vehicleEnter, this);
|
||||
getServer().getPluginManager().registerEvents(vehicleExit, this);
|
||||
|
||||
@@ -19,7 +19,7 @@ public class ServerUtils {
|
||||
Socket s = new Socket();
|
||||
s.connect(new InetSocketAddress(serverAddress, Integer.parseInt(serverPort.toString())), 15);
|
||||
s.close();
|
||||
System.out.println("Server is online. Sending message to webhook_notify... (Pinged " + serverAddress + ":" + server.getPort() + ")");
|
||||
System.out.println("Server is online. Test notifying by sending a message to your webhook... (Pinged " + serverAddress + ":" + server.getPort() + ")");
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
System.out.println("Server is inactive. Pinging fallback address...");
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package cf.sobrooms.commands;
|
||||
|
||||
|
||||
import cf.sobrooms.Main;
|
||||
import cf.sobrooms.Utils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@@ -10,7 +11,6 @@ import org.bukkit.command.CommandSender;
|
||||
|
||||
public class InfoCommand implements CommandExecutor {
|
||||
|
||||
// This method is called, when somebody uses our command
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
sender.sendMessage((ChatColor.YELLOW + """
|
||||
@@ -18,15 +18,13 @@ public class InfoCommand implements CommandExecutor {
|
||||
|
||||
""" + ChatColor.WHITE +
|
||||
"""
|
||||
Server name/type: %s
|
||||
Server name: %s
|
||||
Server IP: %s
|
||||
Server Port: %s
|
||||
Server Version: %s
|
||||
Active Players:""" + ChatColor.GOLD +
|
||||
" %s\n" + ChatColor.WHITE + "Plugin made by sobrooms (rrryfoo, AnonCYTO)\n" + ChatColor.MAGIC + ":sob: all day" + ChatColor.WHITE)
|
||||
.formatted(Bukkit.getServer().getName(), Utils.getServerHostPublicIP(), Bukkit.getServer().getPort(), Bukkit.getServer().getVersion(), Utils.getActivePlayers()));
|
||||
|
||||
// If the player (or console) uses our command correct, we can return true
|
||||
" %s\n" + ChatColor.WHITE + "Plugin made by sobrooms (rrryfoo/maki + AnonCYTO)\n" + ChatColor.MAGIC + ":sob: all day" + ChatColor.WHITE)
|
||||
.formatted(Main.getServerName(), Utils.getServerHostPublicIP(), Bukkit.getServer().getPort(), Bukkit.getServer().getVersion(), Utils.getActivePlayers()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.geysermc.geyser.api.GeyserApi;
|
||||
|
||||
public class PingCommand implements CommandExecutor {
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
@@ -20,14 +21,19 @@ public class PingCommand implements CommandExecutor {
|
||||
sender.sendMessage("You must be a player to use this command.");
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage("Attempting to get server ping...");
|
||||
if (ping_host.equals("404svh")) {
|
||||
sender.sendMessage("Failed to fetch ping.");
|
||||
sender.sendMessage("Failed to fetch server ping.");
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.ITALIC + "Server ping: %sms".formatted(ping_host));
|
||||
sender.sendMessage(ChatColor.ITALIC + "Player ping: %sms".formatted(player.getPing()));
|
||||
if (GeyserApi.api().isBedrockPlayer(player.getUniqueId()))
|
||||
sender.sendMessage(ChatColor.RED + "" + ChatColor.ITALIC + "This command will not work on bedrock clients.");
|
||||
else
|
||||
sender.sendMessage(ChatColor.ITALIC + "Player ping: %sms".formatted(player.getPing()));
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage("Failed to obtain server ping. (%s)".formatted(e.toString()));
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package cf.sobrooms.commands;
|
||||
|
||||
import cf.sobrooms.DiscordWebhook;
|
||||
import cf.sobrooms.Main;
|
||||
import cf.sobrooms.ServerUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@@ -13,29 +14,35 @@ import java.util.Date;
|
||||
public class SendMessageCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (args.length == 0) {
|
||||
sender.sendMessage("Please input a message to send...");
|
||||
return false;
|
||||
} else {
|
||||
sender.sendMessage("Sending public message to discord server...");
|
||||
DiscordWebhook discordWebhook = new DiscordWebhook(ServerUtils.webhook_messages);
|
||||
discordWebhook.setUsername("Public Messages");
|
||||
String message = String.join(" ", args);
|
||||
DiscordWebhook.EmbedObject embedObject = new DiscordWebhook.EmbedObject()
|
||||
.setTitle("New public message")
|
||||
.setDescription(message)
|
||||
.setAuthor(sender.getName(), "", "")
|
||||
.setFooter(new Date().toString(), "")
|
||||
.setColor(Color.darkGray);
|
||||
discordWebhook.addEmbed(embedObject);
|
||||
try {
|
||||
discordWebhook.execute();
|
||||
sender.sendMessage("Sent public message.");
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
sender.sendMessage("An error occurred while sending your message...");
|
||||
throw new RuntimeException(e);
|
||||
if (Main.hdc) {
|
||||
if (args.length == 0) {
|
||||
sender.sendMessage("Please input a message to send...");
|
||||
return false;
|
||||
} else {
|
||||
sender.sendMessage("Sending a public message to the discord server...");
|
||||
DiscordWebhook discordWebhook = new DiscordWebhook(ServerUtils.webhook_messages);
|
||||
discordWebhook.setUsername("Public Messages");
|
||||
String message = String.join(" ", args);
|
||||
DiscordWebhook.EmbedObject embedObject = new DiscordWebhook.EmbedObject()
|
||||
.setTitle("New public message")
|
||||
.setDescription(message)
|
||||
.setAuthor(sender.getName(), "", "")
|
||||
.setFooter(new Date().toString(), "")
|
||||
.setColor(Color.darkGray);
|
||||
discordWebhook.addEmbed(embedObject);
|
||||
try {
|
||||
discordWebhook.execute();
|
||||
sender.sendMessage("Sent public message.");
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
sender.sendMessage("An error occurred while sending your message...");
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage("There is no discord server that was set for this command.");
|
||||
sender.sendMessage("Please ask the server owner to add a webhook to the configuration. (the entry is called \"url_publicmsg\")");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package cf.sobrooms.commands;
|
||||
|
||||
import cf.sobrooms.Main;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -12,17 +13,24 @@ import java.io.IOException;
|
||||
public class SetLoggingModeCommand implements CommandExecutor {
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (args[0].isBlank()) {
|
||||
sender.sendMessage("Please provide a boolean and make sure you only provided one argument. (true/false)");
|
||||
sender.sendMessage("Please only provide true or false in the command arguments.");
|
||||
return false;
|
||||
} else {
|
||||
if (args[0].equals("true") || args[0].equals("false")) {
|
||||
try {
|
||||
|
||||
FileWriter writer = new FileWriter(Main.isLoggingConfig);
|
||||
writer.write(args[0]);
|
||||
writer.close();
|
||||
System.out.println("Wrote to config, closing writer...");
|
||||
sender.sendMessage(ChatColor.RED + "" + ChatColor.ITALIC + "Changes will only apply once the server has restarted.");
|
||||
sender.sendMessage(ChatColor.RED + "" + ChatColor.ITALIC + "Please restart the server manually.");
|
||||
String status = "";
|
||||
if (args[0].equals("true"))
|
||||
status = "enabled";
|
||||
else if (args[0].equals("false"))
|
||||
status = "disabled";
|
||||
Bukkit.broadcastMessage(ChatColor.ITALIC + "%s %s server logging.".formatted(sender.getName(), status));
|
||||
Bukkit.broadcastMessage(ChatColor.ITALIC + "Changes will only apply once the server has restarted.");
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
@@ -27,10 +27,10 @@ public class EnchantItem implements Listener {
|
||||
.addField("Amount", String.valueOf(event.getItem().getAmount()), true)
|
||||
.setColor(Color.BLUE);
|
||||
notify.addEmbed(embedObject);
|
||||
try {
|
||||
/*try {
|
||||
notify.execute();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,10 +24,10 @@ public class PrepareItemEnchant implements Listener {
|
||||
.addField("Item to be enchanted", event.getItem().toString(), true)
|
||||
.setColor(Color.BLUE);
|
||||
notify.addEmbed(embedObject);
|
||||
try {
|
||||
/*try {
|
||||
notify.execute();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,10 +15,10 @@ import java.util.Date;
|
||||
public class PlayerBedEnter implements Listener {
|
||||
@EventHandler
|
||||
public void onPlayerBedEnter(PlayerBedEnterEvent event) {
|
||||
Bukkit.getConsoleSender().sendMessage("Triggered PlayerBedEnter event.");
|
||||
Bukkit.getConsoleSender().sendMessage("Player entered a bed.");
|
||||
Player player = event.getPlayer();
|
||||
DiscordWebhook notify = new DiscordWebhook(ServerUtils.webhook_notify);
|
||||
DiscordWebhook.EmbedObject embedObject = new DiscordWebhook.EmbedObject().setTitle("Player slep").setDescription("Player is sleping")
|
||||
DiscordWebhook.EmbedObject embedObject = new DiscordWebhook.EmbedObject().setTitle(player.getName() + " is now sleeping...")
|
||||
.addField("Time", new Date().toString(), false)
|
||||
.addField("Player name", player.getName(), true)
|
||||
.setColor(Color.BLUE);
|
||||
|
||||
@@ -15,10 +15,10 @@ import java.util.Date;
|
||||
public class PlayerBedLeave implements Listener {
|
||||
@EventHandler
|
||||
public void onPlayerBedLeave(PlayerBedLeaveEvent event) {
|
||||
Bukkit.getConsoleSender().sendMessage("Triggered PlayerBedLeave event.");
|
||||
Bukkit.getConsoleSender().sendMessage("Player left a bed");
|
||||
Player player = event.getPlayer();
|
||||
DiscordWebhook notify = new DiscordWebhook(ServerUtils.webhook_notify);
|
||||
DiscordWebhook.EmbedObject embedObject = new DiscordWebhook.EmbedObject().setTitle("Player no longe slep...").setDescription("Player is no slep")
|
||||
DiscordWebhook.EmbedObject embedObject = new DiscordWebhook.EmbedObject().setTitle(player.getName() + " is no longer sleeping.")
|
||||
.addField("Time", new Date().toString(), false)
|
||||
.addField("Player name", player.getName(), true)
|
||||
.setColor(Color.BLUE);
|
||||
|
||||
@@ -18,10 +18,10 @@ public class PlayerChat implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
||||
Bukkit.getConsoleSender().sendMessage("Triggered chat event.");
|
||||
Bukkit.getConsoleSender().sendMessage("A message was sent by " + event.getPlayer().getName());
|
||||
Player player = event.getPlayer();
|
||||
DiscordWebhook notify = new DiscordWebhook(ServerUtils.webhook_notify);
|
||||
DiscordWebhook.EmbedObject embedObject = new DiscordWebhook.EmbedObject().setTitle("A message was sent").setDescription(String.format("A message sent by %s was sent.", player.getName()))
|
||||
DiscordWebhook.EmbedObject embedObject = new DiscordWebhook.EmbedObject().setTitle("A message was sent by " + event.getPlayer().getName())
|
||||
.addField("Date of message", new Date().toString(), false)
|
||||
.addField("Message content", event.getMessage(), true)
|
||||
.setColor(Color.BLUE);
|
||||
|
||||
@@ -16,7 +16,7 @@ import java.util.Date;
|
||||
public class PlayerCommandPreprocess implements Listener {
|
||||
@EventHandler
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
Bukkit.getConsoleSender().sendMessage("PlayerCommandPreprocess event triggered");
|
||||
Bukkit.getConsoleSender().sendMessage("%s used a command".formatted(event.getPlayer().getName()));
|
||||
Player player = event.getPlayer();
|
||||
String[] command = event.getMessage().split(" "); // get the command name
|
||||
DiscordWebhook notify = new DiscordWebhook(ServerUtils.webhook_notify);
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package cf.sobrooms.events.player;
|
||||
|
||||
import cf.sobrooms.DiscordWebhook;
|
||||
import cf.sobrooms.Main;
|
||||
import cf.sobrooms.ServerUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -15,15 +17,16 @@ import java.util.Date;
|
||||
public class PlayerJoin implements Listener {
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Bukkit.getConsoleSender().sendMessage("Triggered PlayerJoinEvent.");
|
||||
Bukkit.getConsoleSender().sendMessage("A player has joined the server.");
|
||||
Player player = event.getPlayer();
|
||||
DiscordWebhook notify = new DiscordWebhook(ServerUtils.webhook_notify);
|
||||
DiscordWebhook.EmbedObject embedObject = new DiscordWebhook.EmbedObject().setTitle("Player join").setDescription("A player has joined the game.")
|
||||
DiscordWebhook.EmbedObject embedObject = new DiscordWebhook.EmbedObject().setTitle("A player has joined the server.")
|
||||
.addField("Date of join", new Date().toString(), false)
|
||||
.addField("Player name", player.getName(), true)
|
||||
.setColor(Color.BLUE);
|
||||
notify.addEmbed(embedObject);
|
||||
try {
|
||||
Bukkit.broadcastMessage(Main.getGreetMessage(player));
|
||||
notify.execute();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
||||
@@ -14,10 +14,10 @@ import java.util.Date;
|
||||
public class PlayerQuit implements Listener {
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
Bukkit.getConsoleSender().sendMessage("PlayerQuit event triggered");
|
||||
Bukkit.getConsoleSender().sendMessage("A player has left the server.");
|
||||
Player player = event.getPlayer();
|
||||
DiscordWebhook.EmbedObject embedObject = new DiscordWebhook.EmbedObject().setTitle("A player has left the server").setDescription(String.format("A player left the server..", player.getName()))
|
||||
.addField("Date of quit", new Date().toString(), false)
|
||||
DiscordWebhook.EmbedObject embedObject = new DiscordWebhook.EmbedObject().setTitle("A player has left the server.")
|
||||
.addField("Date of exit", new Date().toString(), false)
|
||||
.addField("Player name", event.getPlayer().getName(), true)
|
||||
.setColor(Color.BLUE);
|
||||
DiscordWebhook notify = new DiscordWebhook(ServerUtils.webhook_notify);
|
||||
|
||||
@@ -14,9 +14,9 @@ import java.util.Date;
|
||||
public class VehicleEnter implements Listener {
|
||||
@EventHandler
|
||||
public void onVehicleEnter(VehicleEnterEvent event) {
|
||||
Bukkit.getConsoleSender().sendMessage("Triggered VehicleEnter event.");
|
||||
Bukkit.getConsoleSender().sendMessage("%s rode a vehicle.".formatted(event.getEntered().getName()));
|
||||
DiscordWebhook notify = new DiscordWebhook(ServerUtils.webhook_notify);
|
||||
DiscordWebhook.EmbedObject embedObject = new DiscordWebhook.EmbedObject().setTitle("Vehicle Enter").setDescription("cars update? :scream:")
|
||||
DiscordWebhook.EmbedObject embedObject = new DiscordWebhook.EmbedObject().setTitle("Vehicle Enter").setDescription("On a ridable animal")
|
||||
.addField("Time", new Date().toString(), false)
|
||||
.addField("Triggered by", event.getEntered().getName(), true)
|
||||
.addField("Vehicle name", event.getVehicle().getName(), true)
|
||||
|
||||
@@ -14,9 +14,9 @@ import java.util.Date;
|
||||
public class VehicleExit implements Listener {
|
||||
@EventHandler
|
||||
public void onVehicleExit(VehicleExitEvent event) {
|
||||
Bukkit.getConsoleSender().sendMessage("Triggered VehicleExit event.");
|
||||
Bukkit.getConsoleSender().sendMessage("%s left a vehicle.".formatted(event.getExited().getName()));
|
||||
DiscordWebhook notify = new DiscordWebhook(ServerUtils.webhook_notify);
|
||||
DiscordWebhook.EmbedObject embedObject = new DiscordWebhook.EmbedObject().setTitle("Vehicle Exit").setDescription("cars update? :scream:")
|
||||
DiscordWebhook.EmbedObject embedObject = new DiscordWebhook.EmbedObject().setTitle("Vehicle Exit").setDescription("Off a ridable animal")
|
||||
.addField("Time", new Date().toString(), false)
|
||||
.addField("Triggered by", event.getExited().getName(), true)
|
||||
.addField("Vehicle name", event.getVehicle().getName(), true)
|
||||
|
||||
@@ -3,7 +3,6 @@ package cf.sobrooms.events.weather;
|
||||
import cf.sobrooms.DiscordWebhook;
|
||||
import cf.sobrooms.ServerUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.weather.LightningStrikeEvent;
|
||||
@@ -23,10 +22,10 @@ public class LightningStrike implements Listener {
|
||||
.addField("Cause of strike", event.getCause().name(), true)
|
||||
.setColor(Color.BLUE);
|
||||
notify.addEmbed(embedObject);
|
||||
try {
|
||||
/*try {
|
||||
notify.execute();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package cf.sobrooms.events.weather;
|
||||
import cf.sobrooms.DiscordWebhook;
|
||||
import cf.sobrooms.ServerUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.weather.ThunderChangeEvent;
|
||||
@@ -22,10 +21,10 @@ public class ThunderChange implements Listener {
|
||||
.addField("Occurred in world", event.getWorld().getName(), true)
|
||||
.setColor(Color.BLUE);
|
||||
notify.addEmbed(embedObject);
|
||||
try {
|
||||
/*try {
|
||||
notify.execute();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,10 +21,10 @@ public class WeatherChange implements Listener {
|
||||
.addField("Occurred in world", event.getWorld().getName(), true)
|
||||
.setColor(Color.BLUE);
|
||||
notify.addEmbed(embedObject);
|
||||
try {
|
||||
/*try {
|
||||
notify.execute();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
package cf.sobrooms.events.world;
|
||||
|
||||
import cf.sobrooms.DiscordWebhook;
|
||||
import cf.sobrooms.ServerUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.world.WorldSaveEvent;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
public class WorldSave implements Listener {
|
||||
@EventHandler
|
||||
public void onWorldSave(WorldSaveEvent event) {
|
||||
Bukkit.getConsoleSender().sendMessage("Triggered WorldSave event.");
|
||||
DiscordWebhook notify = new DiscordWebhook(ServerUtils.webhook_notify);
|
||||
DiscordWebhook.EmbedObject embedObject = new DiscordWebhook.EmbedObject().setTitle("WorldSave").setDescription("World in the server was saved")
|
||||
.addField("Time", new Date().toString(), false)
|
||||
.addField("World name", event.getWorld().getName(), true)
|
||||
.setColor(Color.BLUE);
|
||||
notify.addEmbed(embedObject);
|
||||
try {
|
||||
notify.execute();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,24 @@
|
||||
main: cf.sobrooms.Main
|
||||
version: 1.0.0
|
||||
version: 1.1.4
|
||||
name: notifyOnStart
|
||||
description: Sends webhook_notify to sobrooms when the server starts successfully
|
||||
api-version: 1.19
|
||||
authors: [rrryfoo, sobrooms]
|
||||
commands:
|
||||
info:
|
||||
description: Shows info about this server.
|
||||
description: Shows information about the Minecraft server.
|
||||
usage: /info
|
||||
aliases: [i]
|
||||
send-message:
|
||||
description: Sends a message to the server's main discord server.
|
||||
description: Sends a message to the Discord server. (If any was set)
|
||||
usage: /send-message <message content>
|
||||
aliases: [sms]
|
||||
set-logging:
|
||||
description: Toggles event logging in the server, may greatly increase performance and reduce lag.
|
||||
description: Enables or disables event logging in the server, performance and events can occur faster with this off. (Depending on server speed)
|
||||
usage: /set-logging <true|false>
|
||||
permission: op
|
||||
aliases: [sl]
|
||||
ping-server:
|
||||
description: Pings the server. Will not work on Bedrock clients. (ex. through geyser)
|
||||
description: Gets the server ping.
|
||||
usage: /ping-server
|
||||
aliases: [ping]
|
||||
|
||||
Reference in New Issue
Block a user