pull/6/head
jakub 10 months ago
parent e84cd87d07
commit ec07253263
  1. 9
      src/main/java/xyz/soukup/ecoCraftCore/EcoCraftCore.java
  2. 37
      src/main/java/xyz/soukup/ecoCraftCore/commands/ShopCommand.java

@ -6,10 +6,12 @@ import com.j256.ormlite.support.ConnectionSource;
import com.j256.ormlite.table.TableUtils;
import io.papermc.paper.plugin.lifecycle.event.LifecycleEventManager;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.eclipse.sisu.bean.LifecycleManager;
import org.jetbrains.annotations.NotNull;
import xyz.soukup.ecoCraftCore.commands.RulerCommand;
import xyz.soukup.ecoCraftCore.commands.ShopCommand;
import xyz.soukup.ecoCraftCore.commands.TransactionCommand;
import xyz.soukup.ecoCraftCore.events.RulerMarking;
import xyz.soukup.ecoCraftCore.objects.Shop;
@ -71,6 +73,13 @@ public final class EcoCraftCore extends JavaPlugin {
@NotNull LifecycleEventManager<@NotNull Plugin> lm = this.getLifecycleManager();
lm.registerEventHandler(LifecycleEvents.COMMANDS, event -> event.registrar().register(TransactionCommand.createCommand().build()));
lm.registerEventHandler(LifecycleEvents.COMMANDS, event -> event.registrar().register(ShopCommand.createCommand().build()));
lm.registerEventHandler(LifecycleEvents.COMMANDS, event -> event.registrar().register(RulerCommand.createCommand().build()));
}
private void registerEvents(){
PluginManager pm = this.getServer().getPluginManager();
pm.registerEvents(new RulerMarking(), this);
}
}

@ -1,4 +1,41 @@
package xyz.soukup.ecoCraftCore.commands;
import com.mojang.brigadier.arguments.*;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.context.CommandContext;
import io.papermc.paper.command.brigadier.CommandSourceStack;
import io.papermc.paper.command.brigadier.Commands;
import org.eclipse.sisu.inject.TypeArguments;
public class ShopCommand {
public static LiteralArgumentBuilder<CommandSourceStack> createCommand() {
return Commands.literal("shop")
.then(Commands.argument("amount", IntegerArgumentType.integer(1))
.then(Commands.literal("buy")
.then(Commands.argument("buy_price", FloatArgumentType.floatArg(0.1F))
.executes(ShopCommand::createBuyShop)
.then(Commands.literal("sell")
.then(Commands.argument("sell_price", FloatArgumentType.floatArg(0.1F))
.executes(ShopCommand::createBuyAndSellShop)))))
.then(Commands.literal("sell")
.then(Commands.argument("sell_price", FloatArgumentType.floatArg(0.1F))
.executes(ShopCommand::createSellShop)
.then(Commands.literal("buy")
.then(Commands.argument("buy_price", FloatArgumentType.floatArg(0.1F))
.executes(ShopCommand::createBuyAndSellShop))))));
}
private static int createBuyShop(CommandContext<CommandSourceStack> ctx){
ctx.getSource().getSender().sendPlainMessage("buy");
return 1;
}
private static int createSellShop(CommandContext<CommandSourceStack> ctx){
ctx.getSource().getSender().sendPlainMessage("sell");
return 1;
}
private static int createBuyAndSellShop(CommandContext<CommandSourceStack> ctx){
ctx.getSource().getSender().sendPlainMessage("buy and sell");
return 1;
}
}

Loading…
Cancel
Save