001package net.tnemc.item.example.command;
002/*
003 * The New Economy
004 * Copyright (C) 2025 Daniel "creatorfromhell" Vidmar
005 *
006 * This program is free software: you can redistribute it and/or modify
007 * it under the terms of the GNU Affero General Public License as published by
008 * the Free Software Foundation, either version 3 of the License, or
009 * (at your option) any later version.
010 *
011 * This program is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014 * GNU Affero General Public License for more details.
015 *
016 * You should have received a copy of the GNU Affero General Public License
017 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
018 */
019
020import net.tnemc.item.example.Example;
021import org.bukkit.Bukkit;
022import org.bukkit.ChatColor;
023import org.bukkit.command.Command;
024import org.bukkit.command.CommandExecutor;
025import org.bukkit.command.CommandSender;
026import org.bukkit.entity.Player;
027
028import java.util.Collection;
029import java.util.Collections;
030
031/**
032 * TNILGiveCommand
033 *
034 * @author creatorfromhell
035 * @since 1.0.0.0
036 */
037public class TNILGiveCommand implements CommandExecutor {
038
039  @Override
040  public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
041    if(args.length != 2) {
042
043      sender.sendMessage(ChatColor.RED + "Usage: /tnilgive <player> <amount>");
044      return true;
045    }
046
047    final Player target = Bukkit.getPlayerExact(args[0]);
048    if(target == null) {
049
050      sender.sendMessage(ChatColor.RED + "Player not found.");
051      return true;
052    }
053
054    final int amount;
055    try {
056
057      amount = Integer.parseInt(args[1]);
058    } catch(final NumberFormatException e) {
059
060      sender.sendMessage(ChatColor.RED + "Invalid number.");
061      return true;
062    }
063
064
065
066    Example.instance().getPlatform().calculations().giveItems(Collections.singletonList(Example.instance().getItem().amount(10)), target.getInventory());
067    Example.instance().getPlatform().calculations().giveItems(Collections.singletonList(Example.instance().getItem().amount(10)), target.getEnderChest());
068
069    Example.instance().getPlatform().calculations().giveItems(Collections.singletonList(Example.instance().getNexoItem().amount(10)), target.getInventory());
070    Example.instance().getPlatform().calculations().giveItems(Collections.singletonList(Example.instance().getNexoItem().amount(10)), target.getEnderChest());
071
072    sender.sendMessage(ChatColor.GREEN + "Gave " + amount + " TNIL tokens to " + target.getName() + ".");
073    return true;
074  }
075}