Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
8c55e29
Personalising template (no actual code done)
eleanordoesntcode Apr 15, 2025
cfb03c6
handle licensing with retromc's code
eleanordoesntcode Apr 18, 2025
af3c9b0
warning on top of the README for any dev :P
eleanordoesntcode Apr 18, 2025
0ff03fb
use a repository that isn't down
eleanordoesntcode Apr 18, 2025
cdde8b0
fix package name
eleanordoesntcode Apr 18, 2025
1a6fb44
whoops, forgot that template use
eleanordoesntcode Apr 19, 2025
577653e
no, we do not greet the player.
eleanordoesntcode Apr 19, 2025
9bbd57d
start of coding for this. an IDE really helps.
eleanordoesntcode Apr 19, 2025
6849e1c
missing semicolons (i dont like java)
eleanordoesntcode Apr 19, 2025
37c5cbb
add more detailed permissions (only in documentation)
eleanordoesntcode Apr 19, 2025
036c4a5
saving progress. oh boy. that doesn't fit into a commit message.
eleanordoesntcode May 15, 2025
d8a51cd
add changelog (so that it's done for later)
eleanordoesntcode May 15, 2025
8cab8d4
removing useless imports
eleanordoesntcode May 15, 2025
7f34670
fix permission desc and add supported platforms
eleanordoesntcode May 20, 2025
7b90e5c
ok, this should be a working version (haha kidding theres probably do…
eleanordoesntcode May 23, 2025
77dc95e
version that starts (and add shading)
eleanordoesntcode May 24, 2025
f901938
version that works (apart from player join listener) + better shading
eleanordoesntcode May 24, 2025
3cc0335
(attempt to) fix listener and use proper logging
eleanordoesntcode May 27, 2025
5fd870e
add caching for UUIDs and optimize slightly CheckFileExists
eleanordoesntcode May 27, 2025
e71da09
adding colouring. should be good to go.
eleanordoesntcode May 29, 2025
d579c9e
relicense as part of RetroHaven
eleanordoesntcode May 29, 2025
dbc60ce
disable command by default
eleanordoesntcode May 29, 2025
7049a2e
better shading for guava (previous one didn't work)
eleanordoesntcode May 29, 2025
0066a5a
refactor to org.retrohaven.mc.notes and remove warning
eleanordoesntcode May 29, 2025
9e5259d
fix listener not working properly
eleanordoesntcode May 29, 2025
0bdd614
remove useless line
eleanordoesntcode May 29, 2025
f0833d1
1.0.0 release!
eleanordoesntcode May 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
branches:
- master
- main
- dev

jobs:
build:
Expand All @@ -27,15 +28,15 @@ jobs:
- name: Set up Maven
uses: stCarolas/setup-maven@v4.5
with:
maven-version: 3.9.1
maven-version: 3.9.9

- name: build application
shell: bash
run: |
mvn clean install
mvn clean package

- name: Upload artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ github.event.repository.name }}-artifact
path: target/*.jar
name: artifacts
path: target/*.jar
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ jobs:

- name: Create GitHub Release
if: ${{ !endsWith(env.PROJECT_VERSION, '-SNAPSHOT') }}
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.PROJECT_VERSION }}
body_path: changelogs/${{ env.PROJECT_VERSION }}.md
files: |
target/*.jar
env:
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 RetroMC Development Group
Copyright (c) 2025 RetroHaven Development Group

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
21 changes: 21 additions & 0 deletions LICENSE-retromc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 RetroMC Development Group

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
52 changes: 17 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,27 @@
# Poseidon-Plugin-Template
# SimpleNotes

This repository serves as a template to assist with creating plugins for Project Poseidon.
This plugin aims to provide a note/warning system implemented easily for beta 1.7.3. No other Minecraft versions are targeted and no support is provided for those other versions.

It includes examples of:
- A configuration file.
- A listener.
- A command.
This plugin currently assumes all players are paid accounts. Adding offline players support isn't planned for now.

## Steps to Use This Template
Tested with Project Poseidon. Plain Bukkit should work since this project doesn't use any of Poseidon's APIs.

1. **Clone the Repository**
- Clone this repository to your local machine.
## Commands

2. **Modify `pom.xml`**
- Update the following fields to reflect your plugin:
- `name`
- `version`
- `description`
- **Note:** Removing `-SNAPSHOT` from the version will trigger the `release.yml` GitHub Action to create a GitHub release.
The plugin uses one command, /note (with aliases /notes, /warn, /warns, /warning and /warnings).

3. **Refactor Package Structure**
- Refactor the package `org.retromc.templateplugin` to a unique package name for your plugin to avoid conflicts.
This command is disabled by default to make you look through the config (it's located in plugins/SimpleNotes/config.yml!).

4. **Update `plugin.yml`**
- Update the `plugin.yml` file to match the refactored package name and plugin metadata.
### Subcommands

5. **Modify the Code**
- Customize the code as required for your plugin.
- **Important:**
- Remove the player greeting example in the listener.
- Remove the test command.
- /note help: list the subcommands you have access to
- /note list: list your own notes/warnings (permission: simplenotes.see.self.notes/warns)
- /note list [player]: list another player's notes/warnings (permission: simplenotes.see.others.notes/warns)
- /note add [player] [content]: add a note to a player (permission: simplenotes.addnotes)
- /warn add [player] [content]: add a warn to a player (permission: simplenotes.addnotes)
- This is the only case where the alias matter. You can use any of the warn* aliases for this.
- /note remove [player] [id]: remove a note from a player (permission: simplenotes.removenotes)

## GitHub Actions
## Compiling

This repository includes a pre-configured GitHub Action:

1. **`build-and-test.yml`**:
- Runs tests on every push to ensure code quality.
- Uploads an artifact for each commit, allowing others to download the plugin for testing.

2. **`release.yml`**:
- Automatically creates a GitHub release if the `-SNAPSHOT` suffix is removed from the version in `pom.xml`.

With this template, you can kickstart your plugin development for Project Poseidon quickly and efficiently.
Clone the repository and run `mvn clean package`. The resulting jar should be in the `target` folder.
3 changes: 3 additions & 0 deletions changelogs/1.0.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
First release.

Adds /note add, /warn add, /note remove, /note list and /note help.
68 changes: 58 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>Poseidon-Plugin-Template</artifactId>
<version>1.0.0-SNAPSHOT</version>
<description>A template for creating plugins for the Poseidon server software.</description>
<groupId>org.retrohaven.mc.notes</groupId>
<artifactId>SimpleNotes</artifactId>
<version>1.0.0</version>
<description>A note system for moderators and admins, with the objective to be light on the system and on the codebase.</description>

<properties>
<maven.compiler.source>8</maven.compiler.source>
Expand Down Expand Up @@ -57,18 +57,66 @@
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<artifactSet>
<includes>
<include>com.opencsv:opencsv</include>
<include>org.json:json</include>
<include>com.google.guava:*</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>com.google.common</pattern>
<shadedPattern>org.retrohaven.shaded.com.google.common</shadedPattern>
</relocation>
</relocations>
<filters>
<filter>
<artifact>com.google.guava:guava</artifact>
<includes>
<include>com/google/common/**</include>
</includes>
</filter>
</filters>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>


<dependencies>

<dependency>
<groupId>com.legacyminecraft.poseidon</groupId>
<artifactId>poseidon-craftbukkit</artifactId>
<version>1.1.8</version>
<version>1.1.10-250328-1731-f67a8e3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20250107</version>
</dependency>
<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>5.11</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>33.4.8-jre</version>
</dependency>

</dependencies>

</project>
</project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.retromc.templateplugin;
package org.retrohaven.mc.notes;

import org.bukkit.util.config.Configuration;
import org.jetbrains.annotations.Nullable;

import java.io.File;

Expand All @@ -10,19 +9,18 @@
* Extends the {@link Configuration} class to provide additional utility methods for
* reading and writing configuration options with defaults.
*/
public class TemplateConfig extends Configuration {
private final int configVersion = 1;
public class NoteConfig extends Configuration {
private final int configVersion = 0;


private TemplatePlugin plugin;
private NotePlugin plugin;

/**
* Constructs a new TemplateConfig instance.
* Constructs a new NoteConfig instance.
*
* @param plugin The plugin instance associated with this configuration.
* @param configFile The configuration file to be managed.
*/
public TemplateConfig(TemplatePlugin plugin, File configFile) {
public NoteConfig(NotePlugin plugin, File configFile) {
super(configFile);
this.plugin = plugin;
this.reload();
Expand All @@ -44,24 +42,20 @@ private void write() {
generateConfigOption("config-version", configVersion);

// Plugin options
generateConfigOption("settings.test-command.enabled.value", true);
generateConfigOption("settings.test-command.enabled.info", "Whether the test command is enabled."); // Informational comment
generateConfigOption("settings.plugin.enabled.value", false);
generateConfigOption("settings.plugin.enabled.info", "Whether the command is enabled.");

generateConfigOption("settings.test-command.response.value", "This is the response sent to players when they execute the test command.");
generateConfigOption("settings.test-command.response.info", "The response sent to players when they execute the test command."); // Informational comment
generateConfigOption("settings.warns.showonlogin.value", true);
generateConfigOption("settings.warns.showonlogin.info", "Whether one's warns should be shown on login. Requires the player to have simplenotes.see.self.warns.");

generateConfigOption("settings.welcome-message.value", "Welcome to the server, %player%!");
generateConfigOption("settings.welcome-message.info", "The message sent to players when join the server."); // Informational comment
generateConfigOption("settings.notes.showonlogin.value", false);
generateConfigOption("settings.notes.showonlogin.info", "Whether one's notes should be shown on login. Requires the player to have simplenotes.see.self.notes.");
}

private void convertToNewConfig() {
// Convert old configuration keys to new keys

// Convert from old config version 0 to new config version 1
if(this.getString("config-version") == null || Integer.valueOf(this.getString("config-version")) < 1) {
convertToNewAddress("settings.test-command-response.value", "settings.test-command.response.value", true);
convertToNewAddress("settings.test-command.enabled", "settings.test-command.enabled.value", true);
}
// Currently unused
;
}

/**
Expand Down
28 changes: 28 additions & 0 deletions src/main/java/org/retrohaven/mc/notes/NoteListener.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.retrohaven.mc.notes;

import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerListener;
import org.retrohaven.mc.notes.commands.NoteCommand;

public class NoteListener extends PlayerListener {
private NotePlugin plugin;
private NoteConfig config;

// Constructor to link the plugin instance
public NoteListener(NotePlugin plugin) {
this.plugin = plugin;
this.config = plugin.getConfig();
}

@Override
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
if ((!player.hasPermission("simplenotes.see.self.warns") && !player.isOp() && !config.getConfigBoolean("settings.warns.showonlogin.value"))
&& (!player.hasPermission("simplenotes.see.self.notes") && !player.isOp() && !config.getConfigBoolean("settings.notes.showonlogin.value"))) {
return;
}
NoteCommand commands = new NoteCommand(plugin);
boolean b = commands.NoteList(player, new String[] {""}, true);
}
}
59 changes: 59 additions & 0 deletions src/main/java/org/retrohaven/mc/notes/NotePlugin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package org.retrohaven.mc.notes;

import org.bukkit.Bukkit;
import org.bukkit.event.Event;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;
import org.retrohaven.mc.notes.commands.NoteCommand;

import java.io.*;
import java.util.logging.Level;
import java.util.logging.Logger;

public class NotePlugin extends JavaPlugin {
private JavaPlugin plugin;
private Logger log;
private String pluginName;
private PluginDescriptionFile pdf;

private NoteConfig configuration;

@Override
public void onEnable() {
plugin = this;
log = this.getServer().getLogger();
pdf = this.getDescription();
pluginName = pdf.getName();
log.info("[" + pluginName + "] is loading, version: " + pdf.getVersion());

// Load configuration
configuration = new NoteConfig(this, new File(getDataFolder(), "config.yml")); // Load the configuration file from the plugin's data folder

// Register the command and the aliases
getCommand("note").setExecutor(new NoteCommand(this));

// Register the listeners
if (configuration.getConfigBoolean("settings.warns.showonlogin.value") || configuration.getConfigBoolean("settings.notes.showonlogin.value")) {
NoteListener listener = new NoteListener(this);
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_JOIN, listener, Event.Priority.Monitor, this);
}

log.info("[" + pluginName + "] Plugin loaded!");
}

@Override
public void onDisable() {
// Save configuration
//config.save(); // Save the configuration file to disk. This should only be necessary if the configuration cam be modified during runtime.

log.info("[" + pluginName + "] Plugin unloaded!");
}

public void logger(Level level, String message) {
Bukkit.getLogger().log(level, "[" + plugin.getDescription().getName() + "] " + message);
}

public NoteConfig getConfig() {
return configuration;
}
}
Loading