✉️
Solyze's Message System
A super simple system for easily creating messages and putting them in in a file, whilst also being able to add replacement values without struggle. Please remember
: Give constructive feedback, not negative feedback. There are probably a million things to improve, and I am aware of that.
💻
Usage
It's really easy. You could probably figure it out yourself by just having a look at the example plugin. But I will be explaining anyways.
- Copy the classes in the source code to your own project. (Obviously change the Main class of your project to follow the same process as in the MainClass.java class)
- Follow the code in the ExampleCommand.java class and you will understand it. Indented code
ExampleCommand.java
package io.github.solyze.solyzemessagesystem;
import io.github.solyze.solyzemessagesystem.message.Message;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import java.util.Arrays;
/**
* @author Solyze
*
* You are free to use this in any of your
* projects, credit would be appreciated though,
* just leave the javadoc in each class please.
*/
public class ExampleCommand implements CommandExecutor {
// We get an instance of the Main class.
MainClass plugin;
/**
* A constructor to set the string that
* must be typed to execute the command.
*
* You can make commands in your own way, this
* is just how I like to do it. Looks clean.
*/
public ExampleCommand() {
/*
We set ("activate") the instance,
making sure it is not null.
*/
plugin = MainClass.getInstance();
/*
We set the string that must be typed
for the command to be executed.
Making the command /example.
*/
plugin.getCommand("example").setExecutor(this);
}
/**
* Reminder: The format for the message
* replacements can be changed in
* @see Message
*
* By default, it will be {%count%}.
*/
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
/*
We send a test STRING message to the sender.
The process:
- We create a new Message passing in a path, and a String.
- We add 2 replacements, which will be:
- {0}: very cool
- {1}: don't you agree
- We send it to the CommandSender. (You can alternatively send it to a Player)
NOTE: You can also call getString() to get the String without sending it.
*/
new Message("testMessage", "&fThis is a &b{0} &ftest &b{1}&f?")
.withReplacement("very cool")
.withReplacement("don't you agree")
.send(sender); // You can alternatively use .send(CommandSender, long) to add a delay.
/*
We send a test STRINGLIST message to the sender.
The process:
- We create a new Message passing in a path, and a StringList.
- We add 3 replacements, which will be:
- {0}: amazing
- {1}: duper
- {2}: are you with me
- We send it to the CommandSender. (You can alternatively send it to a Player)
NOTE: You can also call getList() to get the StringList without sending it.
*/
new Message("testList", "&fThis is an &b{0}&f, super &b{1}", "&fcool list &b{2}&f?")
.withReplacement("amazing")
.withReplacement("duper")
.withReplacement("are you with me")
.send(sender); // You can alternatively use .send(CommandSender, long) to add a delay.
return false;
}
}
testMessage: '&fThis is a &b{0} &ftest &b{1}&f?'
testList:
- '&fThis is an &b{0}&f, super &b{1}'
- '&fcool list &b{2}&f?'
🤖
Contribute
Contact me on Discord (@Solyze#3343) if you want to contribute to the system. You can also send me suggestions there if you want to, I'd appreciate it! Please remember
: I do not accept friend requests before you've sent a message, so make sure to send a message before friend adding me so I realize what's going on (I get a lot of random friend requests out of nowhere, which kind of sketches me out).
Contributors (Currently empty):
Name | Contribution |
---|---|
Insert name here | Insert contribution here |
📜
TO-DO
Feature | Status |
---|---|
Send messages with a delay | |