mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-02 06:28:54 +00:00
misc cleanup
This commit is contained in:
1 parent
1403955028
commit
6add891319
16 files changed
+99
-181
No files matched your search
@@ -31,6 +31,4 @@ dependencies {
|
||||
// Provided by Minecraft
|
||||
compileOnlyApi(libs.gson)
|
||||
compileOnlyApi(libs.log4jApi)
|
||||
|
||||
api(libs.messenger)
|
||||
}
|
||||
@@ -27,10 +27,8 @@ import net.draycia.carbon.api.users.UserManager;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.moonshine.message.IMessageRenderer;
|
||||
import ninja.egg82.messenger.services.PacketService;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
|
||||
/**
|
||||
@@ -59,14 +57,6 @@ public interface CarbonChat {
|
||||
*/
|
||||
Logger logger();
|
||||
|
||||
/**
|
||||
* The plugin's cross-server messaging service.
|
||||
*
|
||||
* @return the plugin's cross-server messaging service
|
||||
* @since 2.1.0
|
||||
*/
|
||||
@Nullable PacketService packetService();
|
||||
|
||||
/**
|
||||
* The plugin's data storage directory.<br>
|
||||
* This is where configs and misc files will be stored.
|
||||
|
||||
@@ -41,6 +41,7 @@ dependencies {
|
||||
api(libs.mariadb)
|
||||
|
||||
// Messaging
|
||||
api(libs.messenger)
|
||||
api(libs.messengerNats)
|
||||
api(libs.messengerRabbitmq)
|
||||
api(libs.messengerRedis)
|
||||
|
||||
@@ -186,7 +186,6 @@ public abstract class CarbonChatInternal<C extends CarbonPlayer> implements Carb
|
||||
return (IMessageRenderer<T, String, Component, Component>) this.renderer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable PacketService packetService() {
|
||||
return this.messagingManager.get().packetService();
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ import net.draycia.carbon.api.event.CarbonEventHandler;
|
||||
import net.draycia.carbon.api.event.events.CarbonChatEvent;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.api.util.KeyedRenderer;
|
||||
import net.draycia.carbon.common.CarbonChatInternal;
|
||||
import net.draycia.carbon.common.DataDirectory;
|
||||
import net.draycia.carbon.common.command.Commander;
|
||||
import net.draycia.carbon.common.command.PlayerCommander;
|
||||
@@ -99,7 +100,7 @@ public class CarbonChannelRegistry implements ChannelRegistry, DefaultedRegistry
|
||||
private @MonotonicNonNull Key defaultKey;
|
||||
//private @MonotonicNonNull ChatChannel basicChannel;
|
||||
private final CarbonMessages carbonMessages;
|
||||
private final CarbonChat carbonChat;
|
||||
private final CarbonChatInternal<?> carbonChat;
|
||||
|
||||
private final BiMap<Key, ChatChannel> channelMap = Maps.synchronizedBiMap(HashBiMap.create());
|
||||
|
||||
@@ -120,7 +121,7 @@ public class CarbonChannelRegistry implements ChannelRegistry, DefaultedRegistry
|
||||
this.configFactory = configFactory;
|
||||
this.carbonMessages = carbonMessages;
|
||||
//this.basicChannel = basicChannel;
|
||||
this.carbonChat = carbonChat;
|
||||
this.carbonChat = (CarbonChatInternal<?>) carbonChat;
|
||||
|
||||
events.subscribe(CarbonReloadEvent.class, event -> this.reloadRegisteredConfigChannels());
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.function.Function;
|
||||
@@ -44,8 +45,8 @@ import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
public abstract class CachingUserManager implements UserManagerInternal<CarbonPlayerCommon> {
|
||||
|
||||
protected final Logger logger;
|
||||
protected final ExecutorService executor;
|
||||
protected final ProfileResolver profileResolver;
|
||||
private final ExecutorService executor;
|
||||
private final MembersInjector<CarbonPlayerCommon> playerInjector;
|
||||
private final Provider<MessagingManager> messagingManager;
|
||||
private final PacketFactory packetFactory;
|
||||
@@ -54,14 +55,13 @@ public abstract class CachingUserManager implements UserManagerInternal<CarbonPl
|
||||
|
||||
protected CachingUserManager(
|
||||
final Logger logger,
|
||||
final ExecutorService executorService,
|
||||
final ProfileResolver profileResolver,
|
||||
final MembersInjector<CarbonPlayerCommon> playerInjector,
|
||||
final Provider<MessagingManager> messagingManager,
|
||||
final PacketFactory packetFactory
|
||||
) {
|
||||
this.logger = logger;
|
||||
this.executor = executorService;
|
||||
this.executor = Executors.newSingleThreadExecutor(ConcurrentUtil.carbonThreadFactory(logger, this.getClass().getSimpleName()));
|
||||
this.profileResolver = profileResolver;
|
||||
this.playerInjector = playerInjector;
|
||||
this.messagingManager = messagingManager;
|
||||
@@ -72,6 +72,12 @@ public abstract class CachingUserManager implements UserManagerInternal<CarbonPl
|
||||
|
||||
protected abstract CarbonPlayerCommon loadOrCreate(UUID uuid);
|
||||
|
||||
protected abstract void saveSync(CarbonPlayerCommon player);
|
||||
|
||||
private CompletableFuture<Void> save(final CarbonPlayerCommon player) {
|
||||
return CompletableFuture.runAsync(() -> this.saveSync(player), this.executor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveCompleteMessageReceived(final UUID playerId) {
|
||||
this.cacheLock.lock();
|
||||
@@ -96,8 +102,6 @@ public abstract class CachingUserManager implements UserManagerInternal<CarbonPl
|
||||
});
|
||||
}
|
||||
|
||||
protected abstract CompletableFuture<Void> save(CarbonPlayerCommon player);
|
||||
|
||||
@Override
|
||||
public CompletableFuture<CarbonPlayerCommon> user(final UUID uuid) {
|
||||
this.cacheLock.lock();
|
||||
|
||||
@@ -37,15 +37,13 @@ public abstract class PlatformUserManager<C extends WrappedCarbonPlayer> impleme
|
||||
public CompletableFuture<C> user(final UUID uuid) {
|
||||
return this.backingManager.user(uuid).thenApply(common -> {
|
||||
final C wrapped = this.wrap(common);
|
||||
this.updateTransientLoadedStatus(wrapped);
|
||||
common.markTransientLoaded(!wrapped.online());
|
||||
return wrapped;
|
||||
});
|
||||
}
|
||||
|
||||
protected abstract C wrap(final CarbonPlayerCommon common);
|
||||
|
||||
protected abstract void updateTransientLoadedStatus(C wrapped);
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
this.backingManager.shutdown();
|
||||
|
||||
@@ -28,6 +28,7 @@ import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.api.util.InventorySlot;
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextReplacementConfig;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
@@ -43,7 +44,15 @@ import org.jetbrains.annotations.NotNull;
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public abstract class WrappedCarbonPlayer implements CarbonPlayer {
|
||||
|
||||
public abstract CarbonPlayerCommon carbonPlayerCommon();
|
||||
protected final CarbonPlayerCommon carbonPlayerCommon;
|
||||
|
||||
protected WrappedCarbonPlayer(final CarbonPlayerCommon carbonPlayerCommon) {
|
||||
this.carbonPlayerCommon = carbonPlayerCommon;
|
||||
}
|
||||
|
||||
public CarbonPlayerCommon carbonPlayerCommon() {
|
||||
return this.carbonPlayerCommon;
|
||||
}
|
||||
|
||||
public @Nullable User user() {
|
||||
return LuckPermsProvider.get().getUserManager().getUser(this.uuid());
|
||||
@@ -60,22 +69,22 @@ public abstract class WrappedCarbonPlayer implements CarbonPlayer {
|
||||
|
||||
@Override
|
||||
public boolean ignoring(final UUID player) {
|
||||
return this.carbonPlayerCommon().ignoring(player);
|
||||
return this.carbonPlayerCommon.ignoring(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean ignoring(final CarbonPlayer player) {
|
||||
return this.carbonPlayerCommon().ignoring(player);
|
||||
return this.carbonPlayerCommon.ignoring(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ignoring(final UUID player, final boolean nowIgnoring) {
|
||||
this.carbonPlayerCommon().ignoring(player, nowIgnoring);
|
||||
this.carbonPlayerCommon.ignoring(player, nowIgnoring);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ignoring(final CarbonPlayer player, final boolean nowIgnoring) {
|
||||
this.carbonPlayerCommon().ignoring(player, nowIgnoring);
|
||||
this.carbonPlayerCommon.ignoring(player, nowIgnoring);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -120,37 +129,37 @@ public abstract class WrappedCarbonPlayer implements CarbonPlayer {
|
||||
|
||||
@Override
|
||||
public String username() {
|
||||
return this.carbonPlayerCommon().username();
|
||||
return this.carbonPlayerCommon.username();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomDisplayName() {
|
||||
return this.carbonPlayerCommon().hasCustomDisplayName();
|
||||
return this.carbonPlayerCommon.hasCustomDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Component displayName() {
|
||||
return this.carbonPlayerCommon().displayName();
|
||||
return this.carbonPlayerCommon.displayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayName(final @Nullable Component displayName) {
|
||||
this.carbonPlayerCommon().displayName(displayName);
|
||||
this.carbonPlayerCommon.displayName(displayName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID uuid() {
|
||||
return this.carbonPlayerCommon().uuid();
|
||||
return this.carbonPlayerCommon.uuid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Component createItemHoverComponent(final InventorySlot slot) {
|
||||
return this.carbonPlayerCommon().createItemHoverComponent(slot);
|
||||
return this.carbonPlayerCommon.createItemHoverComponent(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Locale locale() {
|
||||
return this.carbonPlayerCommon().locale();
|
||||
return this.carbonPlayerCommon.locale();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -183,82 +192,113 @@ public abstract class WrappedCarbonPlayer implements CarbonPlayer {
|
||||
|
||||
@Override
|
||||
public @Nullable ChatChannel selectedChannel() {
|
||||
return this.carbonPlayerCommon().selectedChannel();
|
||||
return this.carbonPlayerCommon.selectedChannel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectedChannel(final @Nullable ChatChannel chatChannel) {
|
||||
this.carbonPlayerCommon().selectedChannel(chatChannel);
|
||||
this.carbonPlayerCommon.selectedChannel(chatChannel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean muted() {
|
||||
return this.carbonPlayerCommon().muted();
|
||||
return this.carbonPlayerCommon.muted();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void muted(final boolean muted) {
|
||||
this.carbonPlayerCommon().muted(muted);
|
||||
this.carbonPlayerCommon.muted(muted);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deafened() {
|
||||
return this.carbonPlayerCommon().deafened();
|
||||
return this.carbonPlayerCommon.deafened();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deafened(final boolean deafened) {
|
||||
this.carbonPlayerCommon().deafened(deafened);
|
||||
this.carbonPlayerCommon.deafened(deafened);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean spying() {
|
||||
return this.carbonPlayerCommon().spying();
|
||||
return this.carbonPlayerCommon.spying();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spying(final boolean spying) {
|
||||
this.carbonPlayerCommon().spying(spying);
|
||||
this.carbonPlayerCommon.spying(spying);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessageAsPlayer(final String message) {
|
||||
this.carbonPlayerCommon().sendMessageAsPlayer(message);
|
||||
this.carbonPlayerCommon.sendMessageAsPlayer(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean online() {
|
||||
return this.carbonPlayerCommon().online();
|
||||
return this.carbonPlayerCommon.online();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable UUID whisperReplyTarget() {
|
||||
return this.carbonPlayerCommon().whisperReplyTarget();
|
||||
return this.carbonPlayerCommon.whisperReplyTarget();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whisperReplyTarget(final @Nullable UUID uuid) {
|
||||
this.carbonPlayerCommon().whisperReplyTarget(uuid);
|
||||
this.carbonPlayerCommon.whisperReplyTarget(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable UUID lastWhisperTarget() {
|
||||
return this.carbonPlayerCommon().lastWhisperTarget();
|
||||
return this.carbonPlayerCommon.lastWhisperTarget();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lastWhisperTarget(final @Nullable UUID uuid) {
|
||||
this.carbonPlayerCommon().lastWhisperTarget(uuid);
|
||||
this.carbonPlayerCommon.lastWhisperTarget(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Identity identity() {
|
||||
return this.carbonPlayerCommon().identity();
|
||||
return this.carbonPlayerCommon.identity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean vanished() {
|
||||
return this.carbonPlayerCommon().vanished();
|
||||
return this.carbonPlayerCommon.vanished();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Key> leftChannels() {
|
||||
return this.carbonPlayerCommon.leftChannels();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void joinChannel(final ChatChannel channel) {
|
||||
this.carbonPlayerCommon.joinChannel(channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void leaveChannel(final ChatChannel channel) {
|
||||
this.carbonPlayerCommon.leaveChannel(channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final @Nullable Object other) {
|
||||
if (other == null || this.getClass() != other.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final WrappedCarbonPlayer that = (WrappedCarbonPlayer) other;
|
||||
|
||||
return this.carbonPlayerCommon.equals(that.carbonPlayerCommon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.carbonPlayerCommon.hashCode();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,14 +22,11 @@ package net.draycia.carbon.common.users.db;
|
||||
import com.google.inject.MembersInjector;
|
||||
import com.google.inject.Provider;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executors;
|
||||
import net.draycia.carbon.common.messaging.MessagingManager;
|
||||
import net.draycia.carbon.common.messaging.packets.PacketFactory;
|
||||
import net.draycia.carbon.common.users.CachingUserManager;
|
||||
import net.draycia.carbon.common.users.CarbonPlayerCommon;
|
||||
import net.draycia.carbon.common.users.ProfileResolver;
|
||||
import net.draycia.carbon.common.util.ConcurrentUtil;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
@@ -55,7 +52,6 @@ public abstract class DatabaseUserManager extends CachingUserManager {
|
||||
) {
|
||||
super(
|
||||
logger,
|
||||
Executors.newSingleThreadExecutor(ConcurrentUtil.carbonThreadFactory(logger, "DatabaseUserManager")),
|
||||
profileResolver,
|
||||
playerInjector,
|
||||
messagingManager,
|
||||
@@ -66,8 +62,8 @@ public abstract class DatabaseUserManager extends CachingUserManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final CompletableFuture<Void> save(final CarbonPlayerCommon player) {
|
||||
return CompletableFuture.runAsync(() -> this.jdbi.withHandle(handle -> {
|
||||
public final void saveSync(final CarbonPlayerCommon player) {
|
||||
this.jdbi.withHandle(handle -> {
|
||||
this.bindPlayerArguments(handle.createUpdate(this.locator.query("save-player")), player)
|
||||
.execute();
|
||||
|
||||
@@ -91,7 +87,7 @@ public abstract class DatabaseUserManager extends CachingUserManager {
|
||||
}
|
||||
// TODO: save ignoredplayers
|
||||
return null;
|
||||
}), this.executor);
|
||||
});
|
||||
}
|
||||
|
||||
abstract protected Update bindPlayerArguments(final Update update, final CarbonPlayerCommon player);
|
||||
|
||||
@@ -29,8 +29,6 @@ import java.io.Reader;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executors;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.common.DataDirectory;
|
||||
@@ -42,7 +40,6 @@ import net.draycia.carbon.common.users.CachingUserManager;
|
||||
import net.draycia.carbon.common.users.CarbonPlayerCommon;
|
||||
import net.draycia.carbon.common.users.PersistentUserProperty;
|
||||
import net.draycia.carbon.common.users.ProfileResolver;
|
||||
import net.draycia.carbon.common.util.ConcurrentUtil;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
@@ -68,7 +65,6 @@ public class JSONUserManager extends CachingUserManager {
|
||||
) throws IOException {
|
||||
super(
|
||||
logger,
|
||||
Executors.newSingleThreadExecutor(ConcurrentUtil.carbonThreadFactory(logger, "JSONUserManager")),
|
||||
profileResolver,
|
||||
playerInjector,
|
||||
messagingManager,
|
||||
@@ -123,22 +119,20 @@ public class JSONUserManager extends CachingUserManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> save(final CarbonPlayerCommon player) {
|
||||
return CompletableFuture.runAsync(() -> {
|
||||
final Path userFile = this.userFile(player.uuid());
|
||||
public void saveSync(final CarbonPlayerCommon player) {
|
||||
final Path userFile = this.userFile(player.uuid());
|
||||
|
||||
try {
|
||||
final String json = this.serializer.toJson(player);
|
||||
try {
|
||||
final String json = this.serializer.toJson(player);
|
||||
|
||||
if (json == null || json.isBlank()) {
|
||||
throw new IllegalStateException("No data to save - toJson returned null or blank.");
|
||||
}
|
||||
|
||||
Files.writeString(userFile, json);
|
||||
} catch (final IOException exception) {
|
||||
throw new RuntimeException("Exception while saving data for player [%s]".formatted(player.username()), exception);
|
||||
if (json == null || json.isBlank()) {
|
||||
throw new IllegalStateException("No data to save - toJson returned null or blank.");
|
||||
}
|
||||
}, this.executor);
|
||||
|
||||
Files.writeString(userFile, json);
|
||||
} catch (final IOException exception) {
|
||||
throw new RuntimeException("Exception while saving data for player [%s]".formatted(player.username()), exception);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -53,9 +53,4 @@ public final class FabricUserManager extends PlatformUserManager<CarbonPlayerFab
|
||||
return new CarbonPlayerFabric(common, this.serverHolder, this.carbonChat);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateTransientLoadedStatus(final CarbonPlayerFabric wrapped) {
|
||||
wrapped.carbonPlayerCommon().markTransientLoaded(wrapped.player().isEmpty());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,7 +25,6 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.api.util.InventorySlot;
|
||||
import net.draycia.carbon.common.users.CarbonPlayerCommon;
|
||||
@@ -36,7 +35,6 @@ import net.draycia.carbon.fabric.MinecraftServerHolder;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.audience.ForwardingAudience;
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
@@ -48,12 +46,11 @@ import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public class CarbonPlayerFabric extends WrappedCarbonPlayer implements ForwardingAudience.Single {
|
||||
|
||||
private final CarbonPlayerCommon carbonPlayerCommon;
|
||||
private final MinecraftServerHolder serverHolder;
|
||||
private final Provider<CarbonChatFabric> carbonChatFabric;
|
||||
|
||||
public CarbonPlayerFabric(final CarbonPlayerCommon carbonPlayerCommon, final MinecraftServerHolder serverHolder, final Provider<CarbonChatFabric> carbonChatFabric) {
|
||||
this.carbonPlayerCommon = carbonPlayerCommon;
|
||||
super(carbonPlayerCommon);
|
||||
this.serverHolder = serverHolder;
|
||||
this.carbonChatFabric = carbonChatFabric;
|
||||
}
|
||||
@@ -75,21 +72,6 @@ public class CarbonPlayerFabric extends WrappedCarbonPlayer implements Forwardin
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Key> leftChannels() {
|
||||
return this.carbonPlayerCommon.leftChannels();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void joinChannel(final ChatChannel channel) {
|
||||
this.carbonPlayerCommon.joinChannel(channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void leaveChannel(final ChatChannel channel) {
|
||||
this.carbonPlayerCommon.leaveChannel(channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Locale locale() {
|
||||
return this.player()
|
||||
@@ -102,11 +84,6 @@ public class CarbonPlayerFabric extends WrappedCarbonPlayer implements Forwardin
|
||||
return this.player().isPresent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarbonPlayerCommon carbonPlayerCommon() {
|
||||
return this.carbonPlayerCommon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double distanceSquaredFrom(final CarbonPlayer other) {
|
||||
if (this.player().isEmpty()) {
|
||||
|
||||
@@ -49,9 +49,4 @@ public final class PaperUserManager extends PlatformUserManager<CarbonPlayerPape
|
||||
return this.playerFactory.wrap(common);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateTransientLoadedStatus(final CarbonPlayerPaper wrapped) {
|
||||
wrapped.carbonPlayerCommon().markTransientLoaded(wrapped.bukkitPlayer() == null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,11 +22,9 @@ package net.draycia.carbon.paper.users;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import com.google.inject.assistedinject.AssistedInject;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.api.util.InventorySlot;
|
||||
import net.draycia.carbon.common.config.ConfigFactory;
|
||||
@@ -35,7 +33,6 @@ import net.draycia.carbon.common.users.WrappedCarbonPlayer;
|
||||
import net.draycia.carbon.common.util.EmptyAudienceWithPointers;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.audience.ForwardingAudience;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -51,14 +48,12 @@ import org.jetbrains.annotations.NotNull;
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public final class CarbonPlayerPaper extends WrappedCarbonPlayer implements ForwardingAudience.Single {
|
||||
|
||||
private final CarbonPlayerCommon carbonPlayerCommon;
|
||||
|
||||
@AssistedInject
|
||||
private CarbonPlayerPaper(
|
||||
final @Assisted CarbonPlayerCommon carbonPlayerCommon,
|
||||
final ConfigFactory config
|
||||
) {
|
||||
this.carbonPlayerCommon = carbonPlayerCommon;
|
||||
super(carbonPlayerCommon);
|
||||
|
||||
if (config.primaryConfig().useCarbonNicknames()) {
|
||||
this.player().ifPresent(this.applyDisplayNameToBukkit(carbonPlayerCommon.displayName()));
|
||||
@@ -69,11 +64,6 @@ public final class CarbonPlayerPaper extends WrappedCarbonPlayer implements Forw
|
||||
return Optional.ofNullable(Bukkit.getPlayer(this.carbonPlayerCommon.uuid()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarbonPlayerCommon carbonPlayerCommon() {
|
||||
return this.carbonPlayerCommon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Audience audience() {
|
||||
return this.player().map(player -> (Audience) player).orElseGet(() -> EmptyAudienceWithPointers.forCarbonPlayer(this));
|
||||
@@ -188,21 +178,6 @@ public final class CarbonPlayerPaper extends WrappedCarbonPlayer implements Forw
|
||||
return this.hasVanishMeta();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Key> leftChannels() {
|
||||
return this.carbonPlayerCommon.leftChannels();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void joinChannel(final ChatChannel channel) {
|
||||
this.carbonPlayerCommon.joinChannel(channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void leaveChannel(final ChatChannel channel) {
|
||||
this.carbonPlayerCommon.leaveChannel(channel);
|
||||
}
|
||||
|
||||
// Supported by PremiumVanish, SuperVanish, VanishNoPacket
|
||||
private boolean hasVanishMeta() {
|
||||
return this.player().stream()
|
||||
@@ -216,22 +191,6 @@ public final class CarbonPlayerPaper extends WrappedCarbonPlayer implements Forw
|
||||
return Bukkit.getPlayer(this.uuid());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final @Nullable Object other) {
|
||||
if (other == null || this.getClass() != other.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final CarbonPlayerPaper that = (CarbonPlayerPaper) other;
|
||||
|
||||
return this.carbonPlayerCommon.equals(that.carbonPlayerCommon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.carbonPlayerCommon.hashCode();
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
CarbonPlayerPaper wrap(CarbonPlayerCommon common);
|
||||
}
|
||||
|
||||
@@ -47,9 +47,4 @@ public class VelocityUserManager extends PlatformUserManager<CarbonPlayerVelocit
|
||||
return new CarbonPlayerVelocity(this.proxyServer, common);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateTransientLoadedStatus(final CarbonPlayerVelocity wrapped) {
|
||||
wrapped.carbonPlayerCommon().markTransientLoaded(wrapped.player().isEmpty());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,10 +21,8 @@ package net.draycia.carbon.velocity.users;
|
||||
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.api.util.InventorySlot;
|
||||
import net.draycia.carbon.common.users.CarbonPlayerCommon;
|
||||
@@ -32,7 +30,6 @@ import net.draycia.carbon.common.users.WrappedCarbonPlayer;
|
||||
import net.draycia.carbon.common.util.EmptyAudienceWithPointers;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.audience.ForwardingAudience;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
@@ -43,11 +40,10 @@ import org.jetbrains.annotations.NotNull;
|
||||
public final class CarbonPlayerVelocity extends WrappedCarbonPlayer implements ForwardingAudience.Single {
|
||||
|
||||
private final ProxyServer server;
|
||||
private final CarbonPlayerCommon carbonPlayerCommon;
|
||||
|
||||
public CarbonPlayerVelocity(final ProxyServer server, final CarbonPlayerCommon carbonPlayerCommon) {
|
||||
super(carbonPlayerCommon);
|
||||
this.server = server;
|
||||
this.carbonPlayerCommon = carbonPlayerCommon;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -61,30 +57,10 @@ public final class CarbonPlayerVelocity extends WrappedCarbonPlayer implements F
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Key> leftChannels() {
|
||||
return this.carbonPlayerCommon.leftChannels();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void joinChannel(final ChatChannel channel) {
|
||||
this.carbonPlayerCommon.joinChannel(channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void leaveChannel(final ChatChannel channel) {
|
||||
this.carbonPlayerCommon.leaveChannel(channel);
|
||||
}
|
||||
|
||||
public Optional<Player> player() {
|
||||
return this.server.getPlayer(this.uuid());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarbonPlayerCommon carbonPlayerCommon() {
|
||||
return this.carbonPlayerCommon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Locale locale() {
|
||||
return this.player().map(value -> value.getPlayerSettings().getLocale()).orElse(null);
|
||||
|
||||
Reference in new issue
Block a user