/* * This file is part of LanternServer, licensed under the MIT License (MIT). * * Copyright (c) LanternPowered <https://www.lanternpowered.org> * Copyright (c) SpongePowered <https://www.spongepowered.org> * Copyright (c) contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the Software), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package org.lanternpowered.server.entity.living.player; import org.lanternpowered.server.data.property.AbstractPropertyHolder; import org.lanternpowered.server.entity.AbstractArmorEquipable; import org.lanternpowered.server.permission.AbstractSubjectBase; import org.lanternpowered.server.profile.LanternGameProfile; import org.spongepowered.api.command.CommandSource; import org.spongepowered.api.data.DataContainer; import org.spongepowered.api.data.DataHolder; import org.spongepowered.api.data.DataTransactionResult; import org.spongepowered.api.data.DataView; import org.spongepowered.api.data.key.Key; import org.spongepowered.api.data.manipulator.DataManipulator; import org.spongepowered.api.data.merge.MergeFunction; import org.spongepowered.api.data.persistence.InvalidDataException; import org.spongepowered.api.data.value.BaseValue; import org.spongepowered.api.data.value.immutable.ImmutableValue; import org.spongepowered.api.entity.living.player.Player; import org.spongepowered.api.entity.living.player.User; import org.spongepowered.api.event.cause.Cause; import org.spongepowered.api.item.inventory.Carrier; import org.spongepowered.api.item.inventory.ItemStack; import org.spongepowered.api.item.inventory.equipment.EquipmentType; import org.spongepowered.api.item.inventory.type.CarriedInventory; import org.spongepowered.api.profile.GameProfile; import org.spongepowered.api.service.permission.PermissionService; import org.spongepowered.api.util.Tristate; import org.spongepowered.api.util.annotation.NonnullByDefault; import java.lang.ref.WeakReference; import java.util.Collection; import java.util.Optional; import java.util.Set; import java.util.UUID; import javax.annotation.Nullable; @NonnullByDefault public class LanternUser extends AbstractSubjectBase implements AbstractPropertyHolder, AbstractArmorEquipable, User { private final LanternGameProfile gameProfile; @Nullable private WeakReference<Player> player; public LanternUser(LanternGameProfile gameProfile) { this.gameProfile = gameProfile; this.initSubject(); } @Override public boolean validateRawData(DataView dataView) { // TODO Auto-generated method stub return false; } @Override public void setRawData(DataView dataView) throws InvalidDataException { // TODO Auto-generated method stub } @Override public int getContentVersion() { return 0; } @Override public DataContainer toContainer() { // TODO Auto-generated method stub return null; } @Override public <T extends DataManipulator<?, ?>> Optional<T> get(Class<T> containerClass) { // TODO Auto-generated method stub return null; } @Override public <T extends DataManipulator<?, ?>> Optional<T> getOrCreate(Class<T> containerClass) { // TODO Auto-generated method stub return null; } @Override public boolean supports(Class<? extends DataManipulator<?, ?>> holderClass) { // TODO Auto-generated method stub return false; } @Override public <E> DataTransactionResult offer(Key<? extends BaseValue<E>> key, E value) { // TODO Auto-generated method stub return null; } @Override public <E> DataTransactionResult offer(Key<? extends BaseValue<E>> key, E value, Cause cause) { return null; } @Override public DataTransactionResult offer(DataManipulator<?, ?> valueContainer, MergeFunction function) { // TODO Auto-generated method stub return null; } @Override public DataTransactionResult offer(DataManipulator<?, ?> valueContainer, MergeFunction function, Cause cause) { return null; } @Override public DataTransactionResult remove(Class<? extends DataManipulator<?, ?>> containerClass) { // TODO Auto-generated method stub return null; } @Override public DataTransactionResult remove(Key<?> key) { // TODO Auto-generated method stub return null; } @Override public DataTransactionResult undo(DataTransactionResult result) { // TODO Auto-generated method stub return null; } @Override public DataTransactionResult copyFrom(DataHolder that, MergeFunction function) { // TODO Auto-generated method stub return null; } @Override public Collection<DataManipulator<?, ?>> getContainers() { // TODO Auto-generated method stub return null; } @Override public <E> Optional<E> get(Key<? extends BaseValue<E>> key) { // TODO Auto-generated method stub return null; } @Override public <E, V extends BaseValue<E>> Optional<V> getValue(Key<V> key) { // TODO Auto-generated method stub return null; } @Override public boolean supports(Key<?> key) { // TODO Auto-generated method stub return false; } @Override public DataHolder copy() { // TODO Auto-generated method stub return null; } @Override public Set<Key<?>> getKeys() { // TODO Auto-generated method stub return null; } @Override public Set<ImmutableValue<?>> getValues() { // TODO Auto-generated method stub return null; } @Override public UUID getUniqueId() { return this.gameProfile.getUniqueId(); } @Override public boolean canEquip(EquipmentType type) { // TODO Auto-generated method stub return false; } @Override public boolean canEquip(EquipmentType type, ItemStack equipment) { // TODO Auto-generated method stub return false; } @Override public Optional<ItemStack> getEquipped(EquipmentType type) { // TODO Auto-generated method stub return null; } @Override public boolean equip(EquipmentType type, ItemStack equipment) { // TODO Auto-generated method stub return false; } @Override public CarriedInventory<? extends Carrier> getInventory() { // TODO Auto-generated method stub return null; } @Override public String getIdentifier() { return this.gameProfile.getUniqueId().toString(); } @Override public Optional<CommandSource> getCommandSource() { return (Optional) this.getPlayer(); } @Override public String getSubjectCollectionIdentifier() { return PermissionService.SUBJECTS_USER; } @Override public Tristate getPermissionDefault(String permission) { return Tristate.FALSE; } @Override public GameProfile getProfile() { return this.gameProfile; } @Override public String getName() { return this.gameProfile.getName().get(); } @Override public boolean isOnline() { return this.getPlayer().isPresent(); } @Override public Optional<Player> getPlayer() { return this.player == null ? Optional.empty() : Optional.ofNullable(this.player.get()); } /** * Sets the {@link Player} that is attached to this user. * * @param player the player */ public void setPlayer(Player player) { this.player = new WeakReference<>(player); } }