Skip to content

Commit

Permalink
Merge pull request #45 from MrIvanPlays/modularization
Browse files Browse the repository at this point in the history
Split Treasury's code into modules
  • Loading branch information
lokka30 authored Dec 1, 2021
2 parents b93bbbb + b556145 commit cc0f43a
Show file tree
Hide file tree
Showing 81 changed files with 2,935 additions and 1,186 deletions.
38 changes: 38 additions & 0 deletions api-bukkit/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?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>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>treasury-api-bukkit</artifactId>

<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>
25 changes: 25 additions & 0 deletions api/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?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>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>treasury-api</artifactId>

<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,34 +17,22 @@
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;

/**
* {@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 they're implementing it for.
*
* @author lokka30
* @since v1.0.0
*/
@SuppressWarnings({"unused", "UnusedReturnValue"})
public interface EconomyProvider {

/**
* Get the "Economy Provider" - the {@link Plugin} facilitating the economy.
*
* @author lokka30
* @return the {@code Plugin} facilitating the economy
* @since v1.0.0
*/
@NotNull
Plugin 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,28 @@
package me.lokka30.treasury.api.economy.misc;

/**
* Represents a utility class for handling double values, or economy amounts.
*
* @since v1.0.0
*/
public final class AmountUtils {

/**
* 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.
* @author lokka30
* @since v1.0.0
*/
public static double ensureAtLeastZero(final double amount) {
return Math.max(amount, 0.0d);
}

private AmountUtils() {
throw new IllegalArgumentException("Initialization of utility-type class");
}
}
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.AmountUtils;
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 = AmountUtils.ensureAtLeastZero(newBalance);
this.transactionAmount = AmountUtils.ensureAtLeastZero(newBalance);
this.transactionType = transactionType;
}

Expand Down
130 changes: 130 additions & 0 deletions bukkit/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<?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>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>treasury-bukkit</artifactId>

<name>Treasury-Bukkit</name>
<description>A modern code library for plugins.</description>

<properties>
<maven.deploy.skip>true</maven.deploy.skip>
<maven.javadoc.skip>true</maven.javadoc.skip>
</properties>

<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.treasury.plugin.bukkit.shade.bstats</shadedPattern>
</relocation>
<relocation>
<pattern>com.mrivanplays.annotationconfig</pattern>
<shadedPattern>me.lokka30.treasury.plugin.shade.annotationconfig</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>papermc</id>
<url>https://papermc.io/repo/repository/maven-public/</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>
<exclusions>
<exclusion>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--
Note: just because the dependency is paper doesn't mean we always use paper specific methods
or that Treasury is a paper-only plugin
-->
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>${spigot.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-mojangapi</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>${bstats.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>

</project>
Loading

0 comments on commit cc0f43a

Please sign in to comment.