Search in sources :

Example 1 with SettingsManager

use of carpet.settings.SettingsManager in project fabric-carpet by gnembon.

the class LocalPlayer_clientCommandMixin method inspectMessage.

@Inject(method = "chat", at = @At("HEAD"))
private void inspectMessage(String string, CallbackInfo ci) {
    if (string.startsWith("/call ")) {
        String command = string.substring(6);
        CarpetClient.sendClientCommand(command);
    }
    if (CarpetServer.minecraft_server == null && !CarpetClient.isCarpet()) {
        LocalPlayer playerSource = (LocalPlayer) (Object) this;
        CarpetServer.settingsManager.inspectClientsideCommand(playerSource.createCommandSourceStack(), string);
        CarpetServer.extensions.forEach(e -> {
            SettingsManager sm = e.customSettingsManager();
            if (sm != null)
                sm.inspectClientsideCommand(playerSource.createCommandSourceStack(), string);
        });
    }
}
Also used : SettingsManager(carpet.settings.SettingsManager) LocalPlayer(net.minecraft.client.player.LocalPlayer) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 2 with SettingsManager

use of carpet.settings.SettingsManager in project fabric-carpet by gnembon.

the class CarpetServer method onGameStarted.

public static void onGameStarted() {
    settingsManager = new SettingsManager(CarpetSettings.carpetVersion, "carpet", "Carpet Mod");
    settingsManager.parseSettingsClass(CarpetSettings.class);
    extensions.forEach(CarpetExtension::onGameStarted);
    FabricAPIHooks.initialize();
    CarpetScriptServer.parseFunctionClasses();
}
Also used : SettingsManager(carpet.settings.SettingsManager)

Example 3 with SettingsManager

use of carpet.settings.SettingsManager in project fabric-carpet by gnembon.

the class CarpetServer method registerCarpetCommands.

public static void registerCarpetCommands(CommandDispatcher<CommandSourceStack> dispatcher, Commands.CommandSelection environment) {
    if (// bootstrap dev initialization check
    settingsManager == null) {
        return;
    }
    settingsManager.registerCommand(dispatcher);
    extensions.forEach(e -> {
        SettingsManager sm = e.customSettingsManager();
        if (sm != null)
            sm.registerCommand(dispatcher);
    });
    TickCommand.register(dispatcher);
    ProfileCommand.register(dispatcher);
    CounterCommand.register(dispatcher);
    LogCommand.register(dispatcher);
    SpawnCommand.register(dispatcher);
    PlayerCommand.register(dispatcher);
    // CameraModeCommand.register(dispatcher);
    InfoCommand.register(dispatcher);
    DistanceCommand.register(dispatcher);
    PerimeterInfoCommand.register(dispatcher);
    DrawCommand.register(dispatcher);
    ScriptCommand.register(dispatcher);
    MobAICommand.register(dispatcher);
    // registering command of extensions that has registered before either server is created
    // for all other, they will have them registered when they add themselves
    extensions.forEach(e -> e.registerCommands(dispatcher));
    currentCommandDispatcher = dispatcher;
    if (environment != Commands.CommandSelection.DEDICATED)
        PerfCommand.register(dispatcher);
    if (FabricLoader.getInstance().isDevelopmentEnvironment())
        TestCommand.register(dispatcher);
// todo 1.16 - re-registerer apps if that's a reload operation.
}
Also used : SettingsManager(carpet.settings.SettingsManager)

Example 4 with SettingsManager

use of carpet.settings.SettingsManager in project fabric-carpet by gnembon.

the class CarpetServer method onServerLoaded.

public static void onServerLoaded(MinecraftServer server) {
    CarpetServer.minecraft_server = server;
    // shoudl not be needed - that bit needs refactoring, but not now.
    SpawnReporter.reset_spawn_stats(server, true);
    settingsManager.attachServer(server);
    extensions.forEach(e -> {
        SettingsManager sm = e.customSettingsManager();
        if (sm != null)
            sm.attachServer(server);
        e.onServerLoaded(server);
    });
    scriptServer = new CarpetScriptServer(server);
    MobAI.resetTrackers();
    LoggerRegistry.initLoggers();
// TickSpeed.reset();
}
Also used : CarpetScriptServer(carpet.script.CarpetScriptServer) SettingsManager(carpet.settings.SettingsManager)

Example 5 with SettingsManager

use of carpet.settings.SettingsManager in project fabric-carpet by gnembon.

the class ServerNetworkHandler method onHello.

public static void onHello(ServerPlayer playerEntity, FriendlyByteBuf packetData) {
    validCarpetPlayers.add(playerEntity);
    String clientVersion = packetData.readUtf(64);
    remoteCarpetPlayers.put(playerEntity, clientVersion);
    if (clientVersion.equals(CarpetSettings.carpetVersion))
        CarpetSettings.LOG.info("Player " + playerEntity.getName().getString() + " joined with a matching carpet client");
    else
        CarpetSettings.LOG.warn("Player " + playerEntity.getName().getString() + " joined with another carpet version: " + clientVersion);
    // .withSuperHotState()
    DataBuilder data = DataBuilder.create().withTickRate().withFrozenState().withTickPlayerActiveTimeout();
    CarpetServer.settingsManager.getRules().forEach(data::withRule);
    CarpetServer.extensions.forEach(e -> {
        SettingsManager eManager = e.customSettingsManager();
        if (eManager != null) {
            eManager.getRules().forEach(data::withRule);
        }
    });
    playerEntity.connection.send(new ClientboundCustomPayloadPacket(CarpetClient.CARPET_CHANNEL, data.build()));
}
Also used : SettingsManager(carpet.settings.SettingsManager) ClientboundCustomPayloadPacket(net.minecraft.network.protocol.game.ClientboundCustomPayloadPacket)

Aggregations

SettingsManager (carpet.settings.SettingsManager)5 CarpetScriptServer (carpet.script.CarpetScriptServer)1 LocalPlayer (net.minecraft.client.player.LocalPlayer)1 ClientboundCustomPayloadPacket (net.minecraft.network.protocol.game.ClientboundCustomPayloadPacket)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1