001package net.tnemc.plugincore.paper.impl; 002 003/* 004 * The New Plugin Core 005 * Copyright (C) 2022 - 2024 Daniel "creatorfromhell" Vidmar 006 * 007 * This program is free software: you can redistribute it and/or modify 008 * it under the terms of the GNU Affero General Public License as published by 009 * the Free Software Foundation, either version 3 of the License, or 010 * (at your option) any later version. 011 * 012 * This program is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 015 * GNU Affero General Public License for more details. 016 * 017 * You should have received a copy of the GNU Affero General Public License 018 * along with this program. If not, see <http://www.gnu.org/licenses/>. 019 */ 020 021import net.tnemc.menu.paper.PaperInventory; 022import net.tnemc.plugincore.core.compatibility.InventoryProvider; 023import org.bukkit.Bukkit; 024import org.bukkit.OfflinePlayer; 025import org.bukkit.inventory.Inventory; 026import org.bukkit.plugin.java.JavaPlugin; 027 028import java.util.UUID; 029 030/** 031 * BukkitInventoryProvider 032 * 033 * @author creatorfromhell 034 * @since 0.1.2.0 035 */ 036public class PaperInventoryProvider extends PaperInventory implements InventoryProvider<Inventory> { 037 038 public PaperInventoryProvider(final UUID id, final JavaPlugin plugin) { 039 040 super(id, plugin); 041 } 042 043 /** 044 * Used to get an inventory object. 045 * 046 * @param ender True if the ender chest object should be returned, otherwise false. 047 * 048 * @return The inventory object. 049 */ 050 @Override 051 public Inventory getInventory(final boolean ender) { 052 053 final OfflinePlayer player = Bukkit.getOfflinePlayer(player()); 054 if(player.getPlayer() == null) return null; 055 056 if(ender) { 057 return player.getPlayer().getEnderChest(); 058 } 059 return player.getPlayer().getInventory(); 060 } 061}