Skip to content

Commit

Permalink
1.5 initial
Browse files Browse the repository at this point in the history
  • Loading branch information
efekos committed Aug 16, 2023
1 parent 4ee658a commit 7e397cc
Show file tree
Hide file tree
Showing 55 changed files with 3,325 additions and 377 deletions.
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
> Note: This changelog started at Simpler 1.5. For changelog of older versions, see github releases.
# 1.5

* **Added** copyright to every class.
* **Added** proper built-in documentation (JavaDoc Coming Soon).
* **Added** `me.efekos.simpler.items.ItemContent`: Serialize an ItemStack to show it in chat **WITHOUT NMS**.
* **Added** `me.efekos.simpler.config.JSONDataManager<T>`: Store a list of the datas in '.json' format.
* **Added** `LICENSE.md`
* **Added** `package-info.java` files.
* **Added** `me.efekos.simpler.config.Storable`: Makes your class compatible for `JSONDataManager<T>`.
* **Changed** License to MIT.
* **Changed** most of the `ArrayList<...>` type to `List<...>`
* **Changed** the tutorial 'Creating A Command': Core and sub commands.
* **Changed** `CustomItem#CustomItem`: Now it is possible to create a `CustomItem` using a prepared `UUID` or a random `UUID`.
* **Changed** spigot-api to _1.20.1-R0.1-SNAPSHOT_ (was _1.19-R0.1-SNAPSHOT_ before).
* **Fixed** `NumberArgument` not using the priority given at constructor
* **Removed** `CustomItem#setUniqueItemId`
* **Removed** `Simpler#onEnable`: Useless
* **Removed** `Simpler#onDisable`: Useless
* **Moved** `me.efekos.simpler.commands.syntax.ListArgument` to `me.efekos.simpler.commands.syntax.impl.ListArgument`
* **Moved** `me.efekos.simpler.commands.syntax.StringArgument` to `me.efekos.simpler.commands.syntax.impl.StringArgument`
* **Moved** `me.efekos.simpler.commands.syntax.NumberArgument` to `me.efekos.simpler.commands.syntax.impl.NumberArgument`
* **Moved** `me.efekos.simpler.commands.syntax.PlayerArgument` to `me.efekos.simpler.commands.syntax.impl.PlayerArgument`
* **Moved** `me.efekos.simpler.commands.translation.TranslateManager` to `me.efekos.simpler.translation.TranslateManager`
30 changes: 18 additions & 12 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
ISC License
MIT License

Copyright (c) 2023 Simpler
Copyright (c) 2023 efekos

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
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 SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
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.
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 efekos

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.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![](https://jitpack.io/v/efe124/Simpler.svg)](https://jitpack.io/#efe124/Simpler)
[![License: ISC](https://img.shields.io/badge/License-ISC-yellow.svg)](https://opensource.org/licenses/MIT)
![version](https://img.shields.io/badge/version-1.4-blue)
![version](https://img.shields.io/badge/version-1.5-blue)
# Simpler

<!-- TOC -->
Expand All @@ -24,12 +24,12 @@
</repository>
</repositories>
````
* Add this dependecy
* Add this dependency
````xml
<dependency>
<groupId>com.github.efe124</groupId>
<artifactId>Simpler</artifactId>
<version>1.4</version>
<version>1.5</version>
</dependency>
````

Expand All @@ -44,9 +44,9 @@ allprojects {
}
}
````
* Add this dependecy:
* Add this dependency:
````gradle
dependencies {
implementation 'com.github.efe124:Simpler:1.4'
implementation 'com.github.efe124:Simpler:1.5'
}
````
6 changes: 4 additions & 2 deletions docs/Installation.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
> This documentation is cancelled and only will be for tutorials, due to there will be a JavaDoc for Simpler soon.
<!-- TOC -->
* [Installation](#installation)
* [Maven](#maven)
Expand All @@ -23,7 +25,7 @@ Add this dependency to your dependencies.
<dependency>
<groupId>com.github.efe124</groupId>
<artifactId>Simpler</artifactId>
<version>1.4</version>
<version>1.5</version>
</dependency>
````

Expand All @@ -42,6 +44,6 @@ allprojects {
Add this dependency
````gradle
dependencies {
implementation 'com.github.efe124:Simpler:1.4'
implementation 'com.github.efe124:Simpler:1.5'
}
````
2 changes: 2 additions & 0 deletions docs/Introduction.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
> This documentation is cancelled and only will be for tutorials, due to there will be a JavaDoc for Simpler soon.
<!-- TOC -->
* [Introduction](#introduction)
* [Features](#features)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
* [@Command](#command)
* [Creating a Base Command](#creating-a-base-command)
* [Registering a BaseCommand](#registering-a-basecommand)
* [Creating a CoreCommand](#creating-a-corecommand)
* [Creating a SubCommand](#creating-a-subcommand)
* [Registering a CoreCommand](#registering-a-corecommand)
<!-- TOC -->

# Creating a Command With Simpler

There is a class called `CommandManager` in Simpler. We use this class to register our commands to the server. But before registering a command, guess what? We have to make one! Let's talk about other classes about commands then.
There is a class called `CommandManager` in Simpler. We use this class to register our commands to the server. But before
registering a command, guess what? We have to make one! Let's talk about other classes about commands then.

## Classes for Commands

Expand All @@ -20,7 +24,9 @@ There are three main classes for registering commands. We can make other classes

## @Command

Every `BaseCommand`, `CoreCommand` and `SubCommand` has to be annotated with `Command` annotation. This annotation is used for various **final** values about the command.
Every `BaseCommand`, `CoreCommand` and `SubCommand` has to be annotated with `Command` annotation. This annotation is used
for various **final** values about the command.

`Command` annotation has these properties:

| Property | Description | Type | Default |
Expand All @@ -34,15 +40,20 @@ Every `BaseCommand`, `CoreCommand` and `SubCommand` has to be annotated with `Co
Let's start with a basic base command: `/feed`!
## Creating a Base Command

First, we will create our class `Feed` for the command. Your class name can be whatever you want. Then, extend the class with `BaseCommand`. Your class should look like this.
First, we will create our class `Feed` for the command. Your class name can be whatever you want. Then, extend the class
with `BaseCommand`. Your class should look like this.

````java
import me.efekos.simpler.commands.BaseCommand;

public class Feed extends BaseCommand {

}
````
Then, the most important part. We need to annotate our command with @`Command` annotation. Add an annotation like the one below to your class.

Then, the most important part. We need to annotate our command with @`Command` annotation. Add an annotation like the one
below to your class.


````java
import me.efekos.simpler.annotations.Command;
Expand All @@ -53,52 +64,61 @@ public class Feed extends BaseCommand {

}
````
I set `playerOnly` to true because the console must be unable to full its not existing hunger. If your command is something that console shouldn't use too, then you can set `playerOnly` to true like I did above.
I set `playerOnly` to true because the console must be unable to full its not existing hunger. If your command is something
that console shouldn't use too, then you can set `playerOnly` to true like I did above.

As you can tell from the errors your editor probably gave, we need to override some abstract methods. I use 'IntelliJ IDEA
Community Edition 2023.1.4' in this example, so I can do Ctrl+I to import the implement methods. But in case you are using
another IDE or text editor. The methods below are abstract, meaning you have to override them in your class.

As you can tell from the errors your editor probably gave, we need to override some abstract methods. I use 'IntelliJ IDEA Community Edition 2023.1.4' in this example, so I can do Ctrl+I to import the implement methods. But in case you are using another IDE or text editor. The methods below are abstract, meaning you have to import them in your class.
* `BaseCommand#getSyntax()` - Used for syntax of your command.
* `BaseCommand#onPlayerUse(Player,String[])` - Executes when a player uses your command.
* `BaseCommand#onConsoleUse(ConsoleCommandSender,String[])` - Executes when the console uses your command.

> Don't forget to override the two constructors of `BaseCommand` as well. We won't touch or use them, but it is required to be in your extended class.
> Don't forget to override the two constructors of `BaseCommand` as well. We won't touch or use them, but it is required
> to be in your extended class.
After we do all of this. Your class should look like this:

````java
import me.efekos.simpler.commands.BaseCommand;
import me.efekos.simpler.commands.syntax.Syntax;
import org.jetbrains.annotations.NotNull;

@Command(name = "feed",description = "Fulls your hunger and health!",permission = "examples.base.feed",playerOnly = true)
public class Feed extends BaseCommand{
public Feed(@NotNull String name) {
super(name);
}
@Command(name = "feed", description = "Fulls your hunger and health!", permission = "examples.base.feed", playerOnly = true)
public class Feed extends BaseCommand {
public Feed(@NotNull String name) {
super(name);
}

public Feed(@NotNull String name, @NotNull String description, @NotNull String usageMessage, @NotNull List<String> aliases) {
super(name, description, usageMessage, aliases);
}
public Feed(@NotNull String name, @NotNull String description, @NotNull String usageMessage, @NotNull List<String> aliases) {
super(name, description, usageMessage, aliases);
}

@Override
public @NotNull Syntax getSyntax() {
return null;
}
@Override
@NotNull
public Syntax getSyntax() {
return new Syntax();
}

@Override
public void onPlayerUse(Player player, String[] args) {
@Override
public void onPlayerUse(Player player, String[] args) {

}
}

@Override
public void onConsoleUse(ConsoleCommandSender sender, String[] args) {
@Override
public void onConsoleUse(ConsoleCommandSender sender, String[] args) {

}
}
}
````

This is how you create a `BaseCommand`. Rest of this section will be specific to command we are making, /feed.

Everyone knows that /feed fulls your hunger, and health too in some plugins. So I'll make that.

Since our command will be executed by a player, I need to write my code inside `BaseCommnad#onPlayerUse(Player,String[])`. It will be something like that:
Since our command will be executed by a player, I need to write my code inside `BaseCommnad#onPlayerUse(Player,String[])`.
It will be something like that:

````java
import me.efekos.simpler.commands.BaseCommand;
Expand All @@ -117,7 +137,9 @@ public class Feed extends BaseCommand{
}
````

And finally, there is `Syntax`. I will explain this more at another tutorial, but for this one: It is simply a list of arguments for your command. /feed does not require any argument. So I need to make `BaseCommand#getSyntax` return an empty `Syntax`. Like that:
And finally, there is `Syntax`. I will explain this more at another tutorial, but for this one: It is simply a list of
arguments for your command. /feed does not require any argument. So I have to make `BaseCommand#getSyntax` return an
empty `Syntax`. Like that:

````java
import me.efekos.simpler.commands.syntax.Syntax;
Expand Down Expand Up @@ -151,4 +173,79 @@ public class Example extends JavaPlugin {
CommandManager.registerBaseCommand(this,Feed.class);
}
}
````

## Creating a CoreCommand
Let's say we want to seperate the `/feed` command to two commands called `/full health` and `/full hunger`. In a case like
this, we might need a `CoreCommand` to be in action.

`CoreCommand`s are simply a tree containing `SubCommand`s inside them. So we won't do actual command stuff like we did in
`BaseCommand`s before.

First, we need a class extends `CoreCommand` like this:

```java
import me.efekos.simpler.annotations.Command;
import me.efekos.simpler.commands.CoreCommand;
import me.efekos.simpler.commands.SubCommand;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;

@Command(name = "full", description = "Commands of fulling your stuff!", permission = "examples.core.full", playerOnly = true)
public class Full extends CoreCommand {

public Full(@NotNull String name) {
super(name);
}

public Full(@NotNull String name, @NotNull String description, @NotNull String usageMessage, @NotNull List<String> aliases) {
super(name, description, usageMessage, aliases);
}

@Override
public @NotNull List<Class<? extends SubCommand>> getSubs() {
return new ArrayList<>();
}

@Override
public void renderHelpList(CommandSender sender, List<SubCommand> subInstances) {

}
}
```

At this class, we have two important methods:

* **getSubs()** _-_ This method should return every `SubCommand` that will be under this `CoreCommand` in a list. You can
use `Arrays.asList(...)` as the simplest method.
* **renderHelpList()** _-_ This method should send a help list to the `CommandSender` as message. You can use a for method
to send messages for each command, combine it with a header and footer, and you are done!

Once you made these two methods work correctly, you can move on to the next step of creating a sub command.

### Creating a SubCommand

`SubCommand` is a superclass of `BaseCommand`, so you can create a sub command just like you did for base commands. All
you need to do is override these methods too:

* **getParent()** _-_ Should return `YourCoreCommandClass.class`.

## Registering a CoreCommand

To register a `CoreCommand`, all you have to do is call `CommandManager#registerCoreCommand` like the example below.

````java
import me.efekos.simpler.commands.CommandManager;
import org.bukkit.plugin.java.JavaPlugin;
import me.efekos.examples.core.commands.Full;

public class Examples extends JavaPlugin {
@Override
public void onEnable() {
CommandManager.registerCoreCommand(this,Full.class);
}
}
````
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.efekos</groupId>
<artifactId>Simpler</artifactId>
<version>1.4</version>
<version>1.5</version>
<packaging>jar</packaging>

<name>Simpler</name>
Expand Down Expand Up @@ -81,7 +81,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19-R0.1-SNAPSHOT</version>
<version>1.20.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
Loading

0 comments on commit 7e397cc

Please sign in to comment.