PlotSquared/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitOfflinePlayer.java

74 lines
2.8 KiB
Java
Raw Normal View History

/*
* _____ _ _ _____ _
* | __ \| | | | / ____| | |
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
* | |
* |_|
* PlotSquared plot management system for Minecraft
* Copyright (C) 2020 IntellectualSites
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2020-08-15 14:59:29 +02:00
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
2020-04-11 02:19:18 +02:00
package com.plotsquared.bukkit.player;
2015-02-21 13:52:50 +01:00
import com.plotsquared.core.permissions.NullPermissionProfile;
import com.plotsquared.core.permissions.PermissionHandler;
import com.plotsquared.core.permissions.PermissionProfile;
2020-04-15 21:26:54 +02:00
import com.plotsquared.core.player.OfflinePlotPlayer;
2015-02-21 13:52:50 +01:00
import org.bukkit.OfflinePlayer;
import javax.annotation.Nonnegative;
2020-07-14 18:49:40 +02:00
import javax.annotation.Nonnull;
2020-07-22 12:35:48 +02:00
import javax.annotation.Nullable;
2015-02-21 13:52:50 +01:00
2016-03-23 02:41:37 +01:00
import java.util.UUID;
2015-07-27 19:50:04 +02:00
2015-09-13 06:04:31 +02:00
public class BukkitOfflinePlayer implements OfflinePlotPlayer {
2016-03-23 18:09:13 +01:00
2015-02-23 02:32:27 +01:00
public final OfflinePlayer player;
private final PermissionProfile permissionProfile;
2016-03-23 18:09:13 +01:00
2015-02-21 13:52:50 +01:00
/**
2016-06-01 22:50:35 +02:00
* Please do not use this method. Instead use BukkitUtil.getPlayer(Player),
* as it caches player objects.
2015-02-21 13:52:50 +01:00
*/
public BukkitOfflinePlayer(@Nonnull final OfflinePlayer player, @Nonnull final
PermissionHandler permissionHandler) {
2015-02-21 13:52:50 +01:00
this.player = player;
this.permissionProfile = permissionHandler.getPermissionProfile(this)
.orElse(NullPermissionProfile.INSTANCE);
2015-02-21 13:52:50 +01:00
}
2016-03-23 18:09:13 +01:00
2020-07-14 18:49:40 +02:00
@Nonnull @Override public UUID getUUID() {
2016-03-23 02:41:37 +01:00
return this.player.getUniqueId();
2015-02-21 13:52:50 +01:00
}
2016-03-23 18:09:13 +01:00
@Override @Nonnegative public long getLastPlayed() {
return this.player.getLastSeen();
2015-02-21 13:52:50 +01:00
}
2016-03-23 18:09:13 +01:00
2018-08-10 17:01:10 +02:00
@Override public String getName() {
2016-03-23 02:41:37 +01:00
return this.player.getName();
2015-02-21 13:52:50 +01:00
}
2020-07-22 12:35:48 +02:00
@Override public boolean hasPermission(@Nullable final String world,
@Nonnull final String permission) {
return this.permissionProfile.hasPermission(world, permission);
}
2015-02-21 13:52:50 +01:00
}