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 028/** 029 * TNILCountCommand 030 * 031 * @author creatorfromhell 032 * @since 1.0.0.0 033 */ 034public class TNILCountCommand implements CommandExecutor { 035 036 037 @Override 038 public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) { 039 if(!(sender instanceof Player) && args.length == 0) { 040 sender.sendMessage("Console must specify a player."); 041 return true; 042 } 043 044 final Player target; 045 if(args.length >= 1) { 046 047 target = Bukkit.getPlayerExact(args[0]); 048 if(target == null) { 049 050 sender.sendMessage("Player not found."); 051 return true; 052 } 053 } else { 054 target = (Player) sender; 055 } 056 057 final int normalAmount = Example.instance().getPlatform().calculations().count(Example.instance().getItem(), target.getInventory()); 058 final int normalAmountEnder = Example.instance().getPlatform().calculations().count(Example.instance().getItem(), target.getEnderChest()); 059 final int nexoItem = Example.instance().getPlatform().calculations().count(Example.instance().getNexoItem(), target.getInventory()); 060 final int nexoItemEnder = Example.instance().getPlatform().calculations().count(Example.instance().getNexoItem(), target.getEnderChest()); 061 062 063 final int totalNormal = normalAmount + normalAmountEnder; 064 final int totalNexo = nexoItem + nexoItemEnder; 065 066 sender.sendMessage(ChatColor.GOLD + "== TNIL Token Report =="); 067 sender.sendMessage(ChatColor.YELLOW + "Target: " + ChatColor.AQUA + target.getName()); 068 sender.sendMessage(ChatColor.YELLOW + "Normal Item: " + ChatColor.GREEN + totalNormal + ChatColor.GRAY + 069 " (" + normalAmount + " inv, " + normalAmountEnder + " ender)"); 070 sender.sendMessage(ChatColor.YELLOW + "Nexo Item: " + ChatColor.GREEN + totalNexo + ChatColor.GRAY + 071 " (" + nexoItem + " inv, " + nexoItemEnder + " ender)"); 072 return true; 073 } 074}