1
0
Fork 0
mirror of https://github.com/xHyroM/lighteco.git synced 2024-11-10 01:18:07 +01:00

feat: add currency-money addon

This commit is contained in:
Jozef Steinhübl 2023-08-27 13:59:35 +02:00
parent 9305b33f13
commit a99fb995e4
14 changed files with 123 additions and 65 deletions

View file

@ -4,6 +4,7 @@ import dev.xhyrom.lighteco.api.model.currency.Currency;
import org.checkerframework.checker.nullness.qual.NonNull;
public interface CommandManager {
// Make more transparent and freedom way to do this (more abstract)
void registerCurrencyCommand(@NonNull Currency currency);
void registerCurrencyCommand(@NonNull Currency currency, boolean main);
}

View file

@ -0,0 +1,13 @@
plugins {
id("lighteco.shadow-logic")
}
val Project.addon: String
get() = project.name.split("-").drop(1).joinToString("-")
tasks {
shadowJar {
archiveFileName.set("lighteco-${project.addon}-${project.version}.jar")
destinationDirectory.set(rootProject.layout.buildDirectory.dir("libs/addons"))
}
}

View file

@ -50,10 +50,22 @@ public class BukkitCommandManager extends AbstractCommandManager {
String permissionBase = "lighteco.currency." + currency.getIdentifier() + ".command.";
new SetCommand(this, currency, permissionBase).build().register();
new GiveCommand(this, currency, permissionBase).build().register();
new TakeCommand(this, currency, permissionBase).build().register();
// Dont expose set, give, take directly - only through main command
new CommandAPICommand(currency.getIdentifier())
.withSubcommand(new SetCommand(this, currency, permissionBase).build())
.withSubcommand(new GiveCommand(this, currency, permissionBase).build())
.withSubcommand(new TakeCommand(this, currency, permissionBase).build());
new PayCommand(this, currency, permissionBase).build().register();
new BalanceCommand(this, "balance", currency, permissionBase).build().register();
for (CommandAPICommand cmd : new BalanceCommand(
this,
"balance",
currency,
permissionBase
).multipleBuild()) {
cmd.register();
}
}
}

View file

@ -4,7 +4,4 @@ version: ${version}
main: dev.xhyrom.lighteco.bukkit.BukkitLightEcoLoader
author: ${author}
api-version: 1.20
load: STARTUP
softdepend:
- Vault
load: STARTUP

View file

@ -20,7 +20,7 @@ public abstract class AbstractLightEcoPlugin implements LightEcoPlugin {
private Config config;
public final void load() {
Config config = ConfigManager.create(Config.class, (it) -> {
this.config = ConfigManager.create(Config.class, (it) -> {
File path = new File(this.getBootstrap().getDataFolder(), "config.yml");
path.mkdir();
@ -30,8 +30,6 @@ public abstract class AbstractLightEcoPlugin implements LightEcoPlugin {
it.saveDefaults();
it.load(true);
});
this.config = config;
}
public final void enable() {

View file

@ -0,0 +1,19 @@
plugins {
id("lighteco.addon-logic")
}
repositories {
maven("https://repo.papermc.io/repository/maven-public/")
}
dependencies {
compileOnly(project(":lighteco-api"))
compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")
compileOnly("org.projectlombok:lombok:1.18.28")
annotationProcessor("org.projectlombok:lombok:1.18.28")
compileOnly("org.checkerframework:checker-qual:3.8.0")
compileOnly("org.jetbrains:annotations:20.1.0")
}

View file

@ -0,0 +1,24 @@
package dev.xhyrom.lighteco.currency.money.bukkit;
import dev.xhyrom.lighteco.api.LightEco;
import dev.xhyrom.lighteco.api.LightEcoProvider;
import dev.xhyrom.lighteco.api.manager.CommandManager;
import dev.xhyrom.lighteco.api.manager.CurrencyManager;
import dev.xhyrom.lighteco.api.model.currency.Currency;
import dev.xhyrom.lighteco.currency.money.common.MoneyCurrency;
import org.bukkit.plugin.java.JavaPlugin;
public class BukkitMCLoader extends JavaPlugin {
@Override
public void onEnable() {
LightEco provider = LightEcoProvider.get();
CurrencyManager currencyManager = provider.getCurrencyManager();
CommandManager commandManager = provider.getCommandManager();
Currency currency = new MoneyCurrency();
currencyManager.registerCurrency(currency);
commandManager.registerCurrencyCommand(currency, true);
}
}

View file

@ -0,0 +1,4 @@
package dev.xhyrom.lighteco.currency.money.bukkit.hooks;
public class Vault {
}

View file

@ -0,0 +1,32 @@
package dev.xhyrom.lighteco.currency.money.common;
import dev.xhyrom.lighteco.api.model.currency.Currency;
import java.math.BigDecimal;
public class MoneyCurrency extends Currency {
@Override
public String getIdentifier() {
return "money";
}
@Override
public Type getType() {
return Type.LOCAL;
}
@Override
public boolean isPayable() {
return true;
}
@Override
public BigDecimal getDefaultBalance() {
return BigDecimal.ZERO;
}
@Override
public int getDecimalPlaces() {
return 2;
}
}

View file

@ -0,0 +1,10 @@
name: ${name}
description: ${description}
version: ${version}
main: dev.xhyrom.lighteco.currency.money.bukkit.BukkitMCLoader
author: ${author}
api-version: 1.20
softdepend:
- Vault
- lighteco-bukkit

View file

@ -5,7 +5,7 @@ sequenceOf(
"common",
"bukkit",
"bukkittest",
"velocity"
"currency-money"
).forEach {
include("lighteco-$it")
project(":lighteco-$it").projectDir = file(it)
@ -17,4 +17,4 @@ pluginManagement {
mavenCentral()
gradlePluginPortal()
}
}
}

42
velocity/.gitignore vendored
View file

@ -1,42 +0,0 @@
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

View file

@ -1,3 +0,0 @@
plugins {
id("lighteco.platform-logic")
}

View file

@ -1,7 +0,0 @@
package dev.xhyrom;
public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}