Skip to content

Commit

Permalink
New notification + new command
Browse files Browse the repository at this point in the history
Added push for PlayerDeath and the ability to push custom messages by using the command /spe message

close #2
  • Loading branch information
Kim committed Jun 16, 2024
1 parent 4e5eba3 commit 318837e
Show file tree
Hide file tree
Showing 7 changed files with 279 additions and 121 deletions.
58 changes: 38 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@
# SimplePushEvents Plugin

## Description
This Spigot plugin, for use with the latest Minecraft version, automatically sends notifications to a push service (ntfy.sh), when players join, leave, execute specific commands or the server starts/shuts down.
It helps server you and your players to stay informed about server activities in real-time.
This Spigot plugin, for use with the latest Minecraft version, automatically sends notifications to a push service (ntfy.sh), when players join, leave, execute specific commands, do certain things or the server starts/shuts down.
This helps server owners and players stay informed about server activities in real-time.


## Ideas
If you have ideas for more events, open an issue.


## Java Version
Compatible with Minecraft 1.20.6 and requires Java 21.


## Features
- Sends push notifications when a player joins or leaves the server.
- Notifies when the server starts up or shuts down.
- Configurable message content and status for each event.
- Sends push notifications when
- a player joins or leaves the server.
- a player unlocks an advancement.
- a player creates a portal.
- a player dies (including the death message).
- executes `/spe [message content]` for custom notifications (with custom permissions).
- Change the message format or disable/enable them entirely.
- Easy integration with the ntfy.sh push service.
- Quick setup with minimal configuration required.
- Checks and notifies for specific player commands:
- `op`
- `deop`
- `ban`
- `banip`
- `pardon`
- `pardonip`
- `whitelist`
- `/op`
- `/deop`
- `/ban`
- `/banip`
- `/pardon`
- `/pardonip`
- `/whitelist`


## Setup
Expand All @@ -45,13 +51,12 @@ To set up the SimplePushEvents plugin, follow these steps:


## Plugin Configuration

Before deploying the plugin, ensure you configure the following parameters in the `options.yml` file:

```yaml
donottouch:
configexists: true
pushchannel: 1dea3f4db2bb
pushchannel: 7fc647dd98
messages:
general:
title: 'Minecraft Server:'
Expand All @@ -61,11 +66,31 @@ messages:
poweroff:
status: true
content: The server is shutting down!
chatcommand:
status: true
content: '[%PLAYER%] wrote: %MESSAGE%'
permission: spe.usechatcommand
player:
advancement:
status: true
content: 'The player %PLAYER% unlocked the advancement: %NAME%'
join:
status: true
content: The player %PLAYER% joined!
leave:
status: true
content: The player %PLAYER% left!
count:
status: true
content: 'Players online right now: %ONLINE%/%MAX%'
death:
status: true
content: 'The Player %PLAYER% died: %MESSAGE%'
portalcreation:
status: true
content: The Player %PLAYER% created a portal at %LOCATION%
command:
disableall: false
op:
status: true
content: The player %PLAYER% executed /op for %TARGET% !
Expand All @@ -87,13 +112,6 @@ messages:
whitelist:
status: true
content: 'The player %PLAYER% used a whitelist command: %CONTENT%'
join:
status: true
content: The player %PLAYER% joined!
leave:
status: true
content: The player %PLAYER% left!

```
Expand Down
10 changes: 8 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.liebki</groupId>
<artifactId>simplepushevents</artifactId>
<version>0.0.4</version>
<version>0.0.5</version>
<name>simplepushevents</name>


<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
</properties>


<!-- Example packaging -->
<packaging>jar</packaging>

Expand Down Expand Up @@ -35,7 +41,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<version>3.6.0</version>
<executions>
<execution>
<phase>package</phase>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
*
* Copyright liebki: https://github.com/liebki | https://kmliebl.de
* You may use this class when stating where it is from and from whom.
*
*/

package de.liebki;

import java.io.File;
Expand All @@ -7,43 +14,52 @@
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.Plugin;

public class Config<T> {
/**
* Custom class to create and use config files more easy in a plugin
*/
public class KonfigurationsManager {

private File file;
private FileConfiguration fileConfig;

public Config(String path, String fileName, Runnable callback, Plugin plugin) {
public KonfigurationsManager(String path, String fileName, Runnable callback, Plugin plugin) {
if (!fileName.contains(".yml")) {
fileName = fileName + ".yml";
}

file = new File(path, fileName);
fileConfig = YamlConfiguration.loadConfiguration(file);

if (!file.exists()) {
fileConfig.options().copyDefaults(true);
callback.run();

try {
fileConfig.save(file);
} catch (IOException exception) {
exception.printStackTrace();
}

}
}

public Config(String path, String fileName, Plugin plugin) {
public KonfigurationsManager(String path, String fileName, Plugin plugin) {
if (!fileName.contains(".yml")) {
fileName = fileName + ".yml";
}

file = new File(path, fileName);
fileConfig = YamlConfiguration.loadConfiguration(file);

if (!file.exists()) {

fileConfig.options().copyDefaults(true);
try {
fileConfig.save(file);
} catch (IOException exception) {
exception.printStackTrace();
}

}
}

Expand All @@ -54,6 +70,7 @@ public FileConfiguration getConfig() {
public void saveConfig() {
try {
fileConfig.save(file);

} catch (IOException exception) {
exception.printStackTrace();
}
Expand All @@ -63,6 +80,7 @@ public Boolean check(String path) {
if (fileConfig.get(path) == null) {
return false;
}

return true;
}

Expand All @@ -71,7 +89,7 @@ public void set(String path, Object wert) {
saveConfig();
}

public T get(String path) {
public <T> T get(String path) {
if (fileConfig.getString(path) == null) {
return null;
}
Expand Down
Loading

0 comments on commit 318837e

Please sign in to comment.