Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split Treasury's code into modules #45

Merged
merged 24 commits into from
Dec 1, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
1b8acb0
Not really meaningless diff just to open the PR
MrIvanPlays Nov 12, 2021
e857167
Make the split
MrIvanPlays Nov 12, 2021
ecaae20
A bit more progress
MrIvanPlays Nov 14, 2021
8abe4fe
Core module now compiles!
MrIvanPlays Nov 15, 2021
f1fe141
Try to make github actually think this file has been moved
MrIvanPlays Nov 15, 2021
a7a196b
platform independent update checker
MrIvanPlays Nov 15, 2021
fe0124c
Document the core module
MrIvanPlays Nov 15, 2021
f4c0734
APIUtils -> AmountUtils
MrIvanPlays Nov 15, 2021
ac127c9
Bukkit impl
MrIvanPlays Nov 15, 2021
1a2e85b
I think the javadoc now is good so remove todo on that
MrIvanPlays Nov 15, 2021
4fdbcae
Remove BY_CONFIG_KEY and BY_CONFIG_VERSION
MrIvanPlays Nov 15, 2021
1ea8ead
Remove unused imports
MrIvanPlays Nov 15, 2021
ff19d8a
Don't complain always for messages
MrIvanPlays Nov 16, 2021
03b8e7c
Also don't call generateMissingEntries if justGenerated is true
MrIvanPlays Nov 16, 2021
c8d08d8
More progress
MrIvanPlays Nov 17, 2021
58c3a84
deployment skip for bukkit and core module
MrIvanPlays Nov 17, 2021
7da2e8a
fix common.states
MrIvanPlays Nov 18, 2021
9c4126a
Handle colors fully platform side
MrIvanPlays Nov 18, 2021
81fcd7d
Fix completions
MrIvanPlays Nov 18, 2021
80ddb5b
Change obvious stuff
MrIvanPlays Nov 18, 2021
ff2726c
fork -> vendor
MrIvanPlays Nov 21, 2021
5c984e4
Message.of on the same line as sendMessage where feasible
MrIvanPlays Nov 22, 2021
db27b9e
Migrate messages and settings fully to AnnotationConfig
MrIvanPlays Nov 29, 2021
b556145
Apply lokka30 suggestions and also do some tab completion fixes
MrIvanPlays Nov 30, 2021
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
39 changes: 39 additions & 0 deletions api-bukkit/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>treasury-parent</artifactId>
<groupId>me.lokka30</groupId>
<version>dev-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>treasury-api-bukkit</artifactId>
<version>1.0.0-SNAPSHOT</version>

<name>Treasury-API-Bukkit</name>
<description>Additions to Treasury's API for Bukkit</description>

<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>${spigot.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.lokka30</groupId>
<artifactId>treasury-api</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package me.lokka30.treasury.api.economy;

import org.bukkit.plugin.Plugin;

public interface BukkitEconomyProvider extends EconomyProvider<Plugin> {
}
26 changes: 26 additions & 0 deletions api/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>treasury-parent</artifactId>
<groupId>me.lokka30</groupId>
<version>dev-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>treasury-api</artifactId>
<version>1.0.0-SNAPSHOT</version>

<name>Treasury-API</name>
<description>Base API for Treasury.</description>

<dependencies>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>${jetbrains.annotations.version}</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,32 @@
import me.lokka30.treasury.api.economy.currency.Currency;
import me.lokka30.treasury.api.economy.misc.EconomyAPIVersion;
import me.lokka30.treasury.api.economy.response.EconomySubscriber;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;

import java.util.Collection;
import java.util.UUID;

// TODO: This javadoc is weirdo. How should we rephrase it?
/**
* {@link Plugin Plugins} providing and managing economy data create a class
* which implements this interface to be registered via the
* {@link org.bukkit.plugin.ServicesManager ServicesManager} as a
* {@link org.bukkit.plugin.RegisteredServiceProvider RegisteredServiceProvider&lt;EconomyProvider&gt;}.
* Implementors providing and managing economy data create a class
* which implements this interface to be registered in
* the specific platform.
*
* @author lokka30
* @since v1.0.0
*/
@SuppressWarnings({"unused", "UnusedReturnValue"})
public interface EconomyProvider {
public interface EconomyProvider<T> {

/**
* Get the "Economy Provider" - the {@link Plugin} facilitating the economy.
* Get the "Economy Provider" - the "Plugin" facilitating the economy.
*
* @author lokka30
* @return the {@code Plugin} facilitating the economy
* @since v1.0.0
*/
@NotNull
Plugin getProvider();
T getProvider();

/**
* Get the version of the Treasury API the {@code EconomyProvider} is based on.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package me.lokka30.treasury.api.economy.misc;

// TODO: What shall we call this?
public class APIUtils {

/**
* @author lokka30
* @since v1.0.0
* If the specified amount is less than zero
* then zero is returned. Otherwise, the amount
* is returned. This ensures an amount is at least zero
* since negative values are not allowed in the API.
* @param amount to check for.
* @return the unmodified or modified amount.
*/
MrIvanPlays marked this conversation as resolved.
Show resolved Hide resolved
public static double ensureAtLeastZero(final double amount) {
return Math.max(amount, 0.0d);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

package me.lokka30.treasury.api.economy.transaction;

import me.lokka30.treasury.plugin.misc.Utils;
import me.lokka30.treasury.api.economy.misc.APIUtils;
import org.jetbrains.annotations.NotNull;

@SuppressWarnings("unused")
Expand All @@ -23,8 +23,8 @@ public class Transaction {
@NotNull private final TransactionType transactionType;

public Transaction(final double newBalance, final double transactionAmount, @NotNull final TransactionType transactionType) {
this.newBalance = Utils.ensureAtLeastZero(newBalance);
this.transactionAmount = Utils.ensureAtLeastZero(newBalance);
this.newBalance = APIUtils.ensureAtLeastZero(newBalance);
this.transactionAmount = APIUtils.ensureAtLeastZero(newBalance);
this.transactionType = transactionType;
}

Expand Down
116 changes: 116 additions & 0 deletions bukkit/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>treasury-parent</artifactId>
<groupId>me.lokka30</groupId>
<version>dev-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>treasury-bukkit</artifactId>
<version>1.0.0-SNAPSHOT</version>

<name>Treasury-Bukkit</name>
<description>Bukkit implementation of the treasury plugin</description>

<build>
<defaultGoal>clean package</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<relocations>
<relocation>
<pattern>org.bstats</pattern>
<shadedPattern>me.lokka30.elementaleconomy.bstats</shadedPattern>
</relocation>
<relocation>
<pattern>me.lokka30.microlib</pattern>
<shadedPattern>me.lokka30.elementaleconomy.microlib</shadedPattern>
</relocation>
</relocations>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>

<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>CodeMC</id>
<url>https://repo.codemc.org/repository/maven-public</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>me.lokka30</groupId>
<artifactId>treasury-api-bukkit</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>me.lokka30</groupId>
<artifactId>treasury-core</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>${spigot.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>${jetbrains.annotations.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>2.2.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.lokka30</groupId>
<artifactId>MicroLib</artifactId>
<version>3.1.0</version>
<scope>compile</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
* 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.
*/

package me.lokka30.treasury.plugin;
package me.lokka30.treasury.plugin.bukkit;

import me.lokka30.microlib.files.YamlConfigFile;
import me.lokka30.microlib.maths.QuickTimer;
import me.lokka30.treasury.api.economy.currency.conversion.CurrencyConverter;
import me.lokka30.treasury.api.economy.misc.EconomyAPIVersion;
import me.lokka30.treasury.plugin.command.CommandHandler;
import me.lokka30.treasury.plugin.debug.DebugHandler;
import me.lokka30.treasury.plugin.file.FileHandler;
import me.lokka30.treasury.plugin.misc.UpdateCheckerHandler;
import me.lokka30.treasury.plugin.misc.Utils;
import me.lokka30.treasury.plugin.bukkit.command.CommandHandler;
import me.lokka30.treasury.plugin.bukkit.debug.DebugHandler;
import me.lokka30.treasury.plugin.bukkit.file.FileHandler;
import me.lokka30.treasury.plugin.bukkit.misc.UpdateCheckerHandler;
import me.lokka30.treasury.plugin.bukkit.misc.Utils;
import org.bstats.bukkit.Metrics;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
* 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.
*/

package me.lokka30.treasury.plugin.command;
package me.lokka30.treasury.plugin.bukkit.command;

import me.lokka30.treasury.plugin.Treasury;
import me.lokka30.treasury.plugin.command.treasury.TreasuryCommand;
import me.lokka30.treasury.plugin.misc.Utils;
import me.lokka30.treasury.plugin.bukkit.Treasury;
import me.lokka30.treasury.plugin.bukkit.command.treasury.TreasuryCommand;
import me.lokka30.treasury.plugin.bukkit.misc.Utils;
import org.bukkit.command.PluginCommand;
import org.bukkit.command.TabExecutor;
import org.jetbrains.annotations.NotNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* 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.
*/

package me.lokka30.treasury.plugin.command;
package me.lokka30.treasury.plugin.bukkit.command;

import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
* 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.
*/

package me.lokka30.treasury.plugin.command.treasury;
package me.lokka30.treasury.plugin.bukkit.command.treasury;

import me.lokka30.microlib.messaging.MultiMessage;
import me.lokka30.treasury.plugin.Treasury;
import me.lokka30.treasury.plugin.command.treasury.subcommand.HelpSubcommand;
import me.lokka30.treasury.plugin.command.treasury.subcommand.InfoSubcommand;
import me.lokka30.treasury.plugin.command.treasury.subcommand.migrate.MigrateSubcommand;
import me.lokka30.treasury.plugin.command.treasury.subcommand.ReloadSubcommand;
import me.lokka30.treasury.plugin.bukkit.Treasury;
import me.lokka30.treasury.plugin.bukkit.command.treasury.subcommand.HelpSubcommand;
import me.lokka30.treasury.plugin.bukkit.command.treasury.subcommand.InfoSubcommand;
import me.lokka30.treasury.plugin.bukkit.command.treasury.subcommand.ReloadSubcommand;
import me.lokka30.treasury.plugin.bukkit.command.treasury.subcommand.migrate.MigrateSubcommand;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
* 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.
*/

package me.lokka30.treasury.plugin.command.treasury.subcommand;
package me.lokka30.treasury.plugin.bukkit.command.treasury.subcommand;

import me.lokka30.microlib.messaging.MultiMessage;
import me.lokka30.treasury.plugin.Treasury;
import me.lokka30.treasury.plugin.command.Subcommand;
import me.lokka30.treasury.plugin.misc.Utils;
import me.lokka30.treasury.plugin.bukkit.Treasury;
import me.lokka30.treasury.plugin.bukkit.command.Subcommand;
import me.lokka30.treasury.plugin.bukkit.misc.Utils;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
* 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.
*/

package me.lokka30.treasury.plugin.command.treasury.subcommand;
package me.lokka30.treasury.plugin.bukkit.command.treasury.subcommand;

import me.lokka30.microlib.messaging.MultiMessage;
import me.lokka30.treasury.api.economy.EconomyProvider;
import me.lokka30.treasury.plugin.Treasury;
import me.lokka30.treasury.plugin.command.Subcommand;
import me.lokka30.treasury.plugin.misc.Utils;
import me.lokka30.treasury.api.economy.BukkitEconomyProvider;
import me.lokka30.treasury.plugin.bukkit.Treasury;
import me.lokka30.treasury.plugin.bukkit.command.Subcommand;
import me.lokka30.treasury.plugin.bukkit.misc.Utils;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -48,7 +48,7 @@ public void run(@NotNull CommandSender sender, @NotNull String label, @NotNull S
return;
}

final RegisteredServiceProvider<EconomyProvider> registeredServiceProvider = main.getServer().getServicesManager().getRegistration(EconomyProvider.class);
final RegisteredServiceProvider<BukkitEconomyProvider> registeredServiceProvider = main.getServer().getServicesManager().getRegistration(BukkitEconomyProvider.class);

new MultiMessage(main.messagesCfg.getConfig().getStringList("commands.treasury.subcommands.info.treasury"), Arrays.asList(
new MultiMessage.Placeholder("prefix", main.messagesCfg.getConfig().getString("common.prefix"), true),
Expand All @@ -66,7 +66,7 @@ public void run(@NotNull CommandSender sender, @NotNull String label, @NotNull S
new MultiMessage.Placeholder("prefix", main.messagesCfg.getConfig().getString("common.prefix"), true)
));
} else {
final EconomyProvider provider = registeredServiceProvider.getProvider();
final BukkitEconomyProvider provider = registeredServiceProvider.getProvider();

new MultiMessage(main.messagesCfg.getConfig().getStringList("commands.treasury.subcommands.info.economy-provider-available"), Arrays.asList(
new MultiMessage.Placeholder("prefix", main.messagesCfg.getConfig().getString("common.prefix"), true),
Expand Down
Loading