mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-02 14:38:49 +00:00
Implement velocity module (#151)
Co-authored-by: jmp <[email protected]>
This commit is contained in:
1 parent
eb7ec4353f
commit
e402ef2e70
26 files changed
+702
-28
No files matched your search
@@ -2,6 +2,7 @@ package net.draycia.carbon.sponge;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Injector;
|
||||
import java.util.Set;
|
||||
import net.draycia.carbon.sponge.listeners.SpongeChatListener;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
@@ -17,9 +18,12 @@ import org.spongepowered.plugin.jvm.Plugin;
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public final class CarbonChatSpongeEntry {
|
||||
|
||||
private static final Set<Class<?>> LISTENER_CLASSES = Set.of(
|
||||
SpongeChatListener.class
|
||||
);
|
||||
private static final int BSTATS_PLUGIN_ID = 11279;
|
||||
|
||||
private @MonotonicNonNull CarbonChatSponge carbon;
|
||||
private final @MonotonicNonNull CarbonChatSponge carbon;
|
||||
private final Game game;
|
||||
private final Injector injector;
|
||||
|
||||
@@ -38,9 +42,10 @@ public final class CarbonChatSpongeEntry {
|
||||
this.injector = injector.createChildInjector(injector.getInstance(CarbonChatSpongeModule.class));
|
||||
this.carbon = this.injector.getInstance(CarbonChatSponge.class);
|
||||
|
||||
for (final Class<?> clazz : LISTENER_CLASSES) {
|
||||
this.game.eventManager().registerListeners(this.pluginContainer, this.injector.getInstance(clazz));
|
||||
}
|
||||
//metricsFactory.make(BSTATS_PLUGIN_ID);
|
||||
this.game.eventManager().registerListeners(this.pluginContainer,
|
||||
this.injector.getInstance(SpongeChatListener.class));
|
||||
|
||||
this.carbon.initialize();
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import net.draycia.carbon.api.CarbonServer;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.api.users.UserManager;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.audience.ForwardingAudience;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
@@ -17,7 +18,7 @@ import org.spongepowered.api.entity.living.player.Player;
|
||||
|
||||
@Singleton
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public final class CarbonServerSponge implements CarbonServer {
|
||||
public final class CarbonServerSponge implements CarbonServer, ForwardingAudience.Single {
|
||||
|
||||
private final Game game;
|
||||
private final UserManager userManager;
|
||||
@@ -28,6 +29,11 @@ public final class CarbonServerSponge implements CarbonServer {
|
||||
this.game = game;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Audience audience() {
|
||||
return this.console();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Audience console() {
|
||||
return Sponge.systemSubject();
|
||||
|
||||
@@ -26,7 +26,11 @@ public final class SpongeChatListener {
|
||||
private final BasicChatChannel basicChat;
|
||||
|
||||
@Inject
|
||||
private SpongeChatListener(final Game game, final CarbonChatSponge carbonChat, final BasicChatChannel basicChat) {
|
||||
private SpongeChatListener(
|
||||
final Game game,
|
||||
final CarbonChatSponge carbonChat,
|
||||
final BasicChatChannel basicChat
|
||||
) {
|
||||
this.game = game;
|
||||
this.carbonChat = carbonChat;
|
||||
this.basicChat = basicChat;
|
||||
@@ -62,7 +66,7 @@ public final class SpongeChatListener {
|
||||
}
|
||||
|
||||
// console too!
|
||||
recipients.add(this.game.systemSubject());
|
||||
recipients.add(this.carbonChat.server());
|
||||
|
||||
final var renderers = new ArrayList<KeyedRenderer>();
|
||||
renderers.add(keyedRenderer(key("carbon", "default"), channel));
|
||||
|
||||
@@ -25,10 +25,9 @@ public final class CarbonPlayerSponge extends CarbonPlayerCommon {
|
||||
|
||||
public CarbonPlayerSponge(
|
||||
final @NonNull String username,
|
||||
final @NonNull Component displayName,
|
||||
final @NonNull UUID uuid
|
||||
) {
|
||||
super(username, displayName, uuid, Identity.identity(uuid));
|
||||
super(username, uuid, Identity.identity(uuid));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,8 +12,6 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.spongepowered.api.Sponge;
|
||||
import org.spongepowered.api.entity.living.player.server.ServerPlayer;
|
||||
|
||||
import static net.kyori.adventure.text.Component.text;
|
||||
|
||||
/**
|
||||
* This class should not be used.
|
||||
* No data is persisted or saved.
|
||||
@@ -39,7 +37,7 @@ public final class MemoryUserManagerSponge implements UserManager {
|
||||
final ServerPlayer player = serverPlayer.get();
|
||||
|
||||
return this.users.computeIfAbsent(player.uniqueId(), key ->
|
||||
new CarbonPlayerSponge(player.name(), text(player.name()), player.uniqueId()));
|
||||
new CarbonPlayerSponge(player.name(), player.uniqueId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user