Skip to content

Latest commit

 

History

History
227 lines (172 loc) · 6.33 KB

File metadata and controls

227 lines (172 loc) · 6.33 KB

import { Tab, Tabs } from 'nextra-theme-docs' import { Callout } from 'nextra-theme-docs'

Server Rule Module

Overview

The server rule module contains pre-created settings servers can enable or disable, comparable to Minecraft's /gamerule command.

This module heavily integrates with our Options API.

  • Toggle or set values for pre-created server settings.
    • Ability to enable the competitive game popup.
    • Ability to forcefully disable Lunar Client mod settings and shaders.
    • Ability to override the max chat length and nametag render distance.
    • Ability to enable the quality of life features, anti-portal-trap and disable broadcasting.

Integration

Sample Code

Explore each integration by cycling through each tab, to find the best fit for your requirements and needs.

<Tabs items={['Apollo API', 'apollo-protos library', 'Manual JSON Object Construction']}>

Toggle Anti Portal Traps

public void setAntiPortalTraps(boolean value) {
    this.serverRuleModule.getOptions().set(ServerRuleModule.ANTI_PORTAL_TRAPS, value);
}

Override Nametag Render Distance

public void setOverrideNametagRenderDistance(Player viewer, boolean value) {
    Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId());

    apolloPlayerOpt.ifPresent(apolloPlayer -> {
        this.serverRuleModule.getOptions().set(apolloPlayer, ServerRuleModule.OVERRIDE_NAMETAG_RENDER_DISTANCE, value);
    });
}

Broadcast Nametag Render Distance

public void setNametagRenderDistanceExample(int value) {
    this.serverRuleModule.getOptions().set(ServerRuleModule.NAMETAG_RENDER_DISTANCE, value);
}

Toggle Anti Portal Traps

public void setAntiPortalTraps(boolean value) {
    Map<String, Value> properties = new HashMap<>();
    properties.put("anti-portal-traps", Value.newBuilder().setBoolValue(value).build());

    ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("server_rule", properties);
    ProtobufPacketUtil.broadcastPacket(settings);
}

Override Nametag Render Distance

public void setOverrideNametagRenderDistance(Player viewer, boolean value) {
    Map<String, Value> properties = new HashMap<>();
    properties.put("override-nametag-render-distance", Value.newBuilder().setBoolValue(value).build());

    ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("server_rule", properties);
    ProtobufPacketUtil.sendPacket(viewer, settings);
}

Broadcast Nametag Render Distance

public void setNametagRenderDistanceExample(int value) {
    Map<String, Value> properties = new HashMap<>();
    properties.put("nametag-render-distance", Value.newBuilder().setNumberValue(value).build());

    ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("server_rule", properties);
    ProtobufPacketUtil.broadcastPacket(settings);
}

Toggle Anti Portal Traps

public void setAntiPortalTraps(boolean value) {
    Map<String, Object> properties = new HashMap<>();
    properties.put("anti-portal-traps", value);

    JsonObject message = JsonUtil.createEnableModuleObjectWithType("server_rule", properties);
    JsonPacketUtil.broadcastPacket(message);
}

Override Nametag Render Distance

public void setOverrideNametagRenderDistance(Player viewer, boolean value) {
    Map<String, Object> properties = new HashMap<>();
    properties.put("override-nametag-render-distance", value);

    JsonObject message = JsonUtil.createEnableModuleObjectWithType("server_rule", properties);
    JsonPacketUtil.sendPacket(viewer, message);
}

Broadcast Nametag Render Distance

public void setNametagRenderDistanceExample(int value) {
    Map<String, Object> properties = new HashMap<>();
    properties.put("nametag-render-distance", value);

    JsonObject message = JsonUtil.createEnableModuleObjectWithType("server_rule", properties);
    JsonPacketUtil.broadcastPacket(message);
}

Available options

  • COMPETITIVE_GAME

    • Whether the player should see a popup prior to disconnecting.
    • Values
      • Type: Boolean
      • Default: false
  • COMPETITIVE_COMMANDS

    • A list of commands that will trigger the competitive popup.
    • Values
      • Type: List<String>
      • Default: ["/server", "/servers", "/hub"]
  • DISABLE_SHADERS

    • Prevents users from enabling shaders.
    • Values
      • Type: Boolean
      • Default: false
  • DISABLE_CHUNK_RELOADING

    • Disables chunk reloading (F3 + A) and disables shaders reload while using Iris (R).
    • Values
      • Type: Boolean
      • Default: false
  • DISABLE_BROADCASTING

    • Disables the broadcast to twitch menu added in 1.7 & 1.8 (F6).
    • Values
      • Type: Boolean
      • Default: false
  • ANTI_PORTAL_TRAPS

    • Allows players to open their chat while in a nether portal.
    • Values
      • Type: Boolean
      • Default: false
You'll need to disable the lighting mod in Lunar Client to control the players brightness levels.
  • OVERRIDE_BRIGHTNESS

    • Whether to use brightness value set in the BRIGHTNESS option.
    • Values
      • Type: Boolean
      • Default: false
  • BRIGHTNESS

    • The override brightness value.
    • Values
      • Type: Integer
      • Default: 50
      • Minimum: 1
      • Maximum: 10000
  • OVERRIDE_NAMETAG_RENDER_DISTANCE

    • Whether to use nametag render distance value set in the NAMETAG_RENDER_DISTANCE option.
    • Values
      • Type: Boolean
      • Default: false
  • NAMETAG_RENDER_DISTANCE

    • The override nametag render distance value.
    • Values
      • Type: Integer
      • Default: 64
      • Minimum: 1
      • Maximum: 96
  • OVERRIDE_MAX_CHAT_LENGTH

    • Whether to use max chat value set in the MAX_CHAT_LENGTH option.
    • Values
      • Type: Boolean
      • Default: false
  • MAX_CHAT_LENGTH

    • The override max chat length value.
    • Values
      • Type: Integer
      • Default: 256
      • Minimum: 1
      • Maximum: 256
  • CRYSTAL_OPTIMIZER

    • Whether to enable crystal optimizer.
    • Values
      • Type: Boolean
      • Default: false