mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-02 22:16:22 +00:00
implement more carbonplayer methods
This commit is contained in:
1 parent
820ac8bf12
commit
fec648de4b
1 file changed
+34
-7
@@ -1,6 +1,10 @@
|
||||
package net.draycia.carbon.fabric.users;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.api.util.InventorySlot;
|
||||
import net.draycia.carbon.common.users.CarbonPlayerCommon;
|
||||
import net.draycia.carbon.common.users.WrappedCarbonPlayer;
|
||||
import net.draycia.carbon.fabric.CarbonChatFabric;
|
||||
@@ -8,6 +12,7 @@ import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.audience.ForwardingAudience;
|
||||
import net.kyori.adventure.platform.fabric.FabricServerAudiences;
|
||||
import net.kyori.adventure.platform.fabric.PlayerLocales;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
@@ -29,12 +34,13 @@ public class CarbonPlayerFabric extends WrappedCarbonPlayer implements Forwardin
|
||||
|
||||
@Override
|
||||
public @NotNull Audience audience() {
|
||||
final ServerPlayer player = this.player();
|
||||
final ServerPlayer player = this.player().get();
|
||||
return FabricServerAudiences.of(player.server).audience(player);
|
||||
}
|
||||
|
||||
private ServerPlayer player() {
|
||||
return this.carbonChatFabric.minecraftServer().getPlayerList().getPlayer(this.carbonPlayerCommon.uuid());
|
||||
private Optional<ServerPlayer> player() {
|
||||
return Optional.ofNullable(this.carbonChatFabric.minecraftServer().getPlayerList()
|
||||
.getPlayer(this.carbonPlayerCommon.uuid()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -43,22 +49,43 @@ public class CarbonPlayerFabric extends WrappedCarbonPlayer implements Forwardin
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean awareOf(CarbonPlayer other) {
|
||||
return false;
|
||||
public boolean awareOf(final CarbonPlayer other) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Locale locale() {
|
||||
return PlayerLocales.locale(player());
|
||||
return PlayerLocales.locale(player().get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean online() {
|
||||
return this.carbonChatFabric.minecraftServer().getPlayerList().getPlayer(player().getUUID()) != null;
|
||||
return this.player().isPresent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarbonPlayerCommon carbonPlayerCommon() {
|
||||
return this.carbonPlayerCommon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String primaryGroup() {
|
||||
return "default"; // TODO: implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> groups() {
|
||||
return List.of("default"); // TODO: implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Component createItemHoverComponent(final InventorySlot slot) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(final String permission) {
|
||||
return this.player().map(value -> Permissions.check(value, permission)).orElse(false);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user