Skip to content

Commit

Permalink
Finish proto examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsNature committed Sep 16, 2024
1 parent 2dc65ae commit 75ea8f6
Show file tree
Hide file tree
Showing 48 changed files with 192 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import org.bukkit.event.player.PlayerRegisterChannelEvent;
import org.bukkit.plugin.messaging.Messenger;

// DONE
public class ApolloPlayerJsonListener implements Listener {

private static final List<String> APOLLO_MODULES = Arrays.asList("limb", "beam", "border", "chat", "colored_fire", "combat", "cooldown",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import org.bukkit.entity.Player;
import org.bukkit.plugin.messaging.PluginMessageListener;

// DONE
public class ApolloPacketReceiveProtoListener implements PluginMessageListener {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
*/
package com.lunarclient.apollo.example.listeners.proto;

import com.google.common.collect.HashBasedTable;
import com.google.common.collect.Table;
import com.google.protobuf.ListValue;
import com.google.protobuf.Value;
import com.lunarclient.apollo.example.ApolloExamplePlugin;
import com.lunarclient.apollo.example.utilities.ProtobufPacketUtil;
import java.util.Arrays;
Expand All @@ -38,14 +42,42 @@
import org.bukkit.event.player.PlayerRegisterChannelEvent;
import org.bukkit.plugin.messaging.Messenger;

// DONE
public class ApolloPlayerProtoListener implements Listener {

private static final List<String> APOLLO_MODULES = Arrays.asList("limb", "beam", "border", "chat", "colored_fire", "combat", "cooldown",
"entity", "glow", "hologram", "mod_setting", "nametag", "nick_hider", "notification", "packet_enrichment", "rich_presence",
"server_rule", "staff_mod", "stopwatch", "team", "title", "tnt_countdown", "transfer", "vignette", "waypoint"
);

// Module Id -> Option key -> Value
private static final Table<String, String, Value> PROPERTIES = HashBasedTable.create();

static {
// Module Options that the client needs to notified about, these properties are sent with the enable module packet
// While using the Apollo plugin this would be equivalent to modifying the config.yml
PROPERTIES.put("combat", "disable-miss-penalty", Value.newBuilder().setBoolValue(false).build());
PROPERTIES.put("server_rule", "competitive-game", Value.newBuilder().setBoolValue(false).build());
PROPERTIES.put("server_rule", "competitive-commands", Value.newBuilder().setListValue(
ListValue.newBuilder().addAllValues(Arrays.asList(
Value.newBuilder().setStringValue("/server").build(),
Value.newBuilder().setStringValue("/servers").build(),
Value.newBuilder().setStringValue("/hub").build()))
.build()
).build());
PROPERTIES.put("server_rule", "disable-shaders", Value.newBuilder().setBoolValue(false).build());
PROPERTIES.put("server_rule", "disable-chunk-reloading", Value.newBuilder().setBoolValue(false).build());
PROPERTIES.put("server_rule", "disable-broadcasting", Value.newBuilder().setBoolValue(false).build());
PROPERTIES.put("server_rule", "anti-portal-traps", Value.newBuilder().setBoolValue(true).build());
PROPERTIES.put("server_rule", "override-brightness", Value.newBuilder().setBoolValue(false).build());
PROPERTIES.put("server_rule", "brightness", Value.newBuilder().setNumberValue(50).build());
PROPERTIES.put("server_rule", "override-nametag-render-distance", Value.newBuilder().setBoolValue(false).build());
PROPERTIES.put("server_rule", "nametag-render-distance", Value.newBuilder().setNumberValue(64).build());
PROPERTIES.put("server_rule", "override-max-chat-length", Value.newBuilder().setBoolValue(false).build());
PROPERTIES.put("server_rule", "max-chat-length", Value.newBuilder().setNumberValue(256).build());
PROPERTIES.put("tnt_countdown", "tnt-ticks", Value.newBuilder().setNumberValue(80).build());
PROPERTIES.put("waypoint", "server-handles-waypoints", Value.newBuilder().setBoolValue(false).build());
}

private static final String APOLLO_CHANNEL = "lunar:apollo"; // Used for detecting whether the player supports Apollo

private final ApolloExamplePlugin plugin;
Expand Down Expand Up @@ -87,7 +119,7 @@ private boolean isPlayerRunningApollo(Player player) {
}

private void onApolloRegister(Player player) {
ProtobufPacketUtil.enableModules(player, APOLLO_MODULES);
ProtobufPacketUtil.enableModules(player, APOLLO_MODULES, PROPERTIES);

this.playersRunningApollo.add(player.getUniqueId());
player.sendMessage("You are using LunarClient!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.bukkit.entity.Player;
import org.bukkit.plugin.messaging.PluginMessageListener;

// DONE
public class ApolloRoundtripProtoListener implements PluginMessageListener {

@Getter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.bukkit.Location;
import org.bukkit.entity.Player;

// DONE
public class BeamJsonExample extends BeamExample {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import java.awt.Color;
import org.bukkit.entity.Player;

// DONE
public class BorderJsonExample extends BorderExample {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;

// DONE
public class ChatJsonExample extends ChatExample {

private int countdown = 5;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import java.util.UUID;
import org.bukkit.entity.Player;

// DONE
public class ColoredFireJsonExample extends ColoredFireExample {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import java.time.Duration;
import org.bukkit.entity.Player;

// DONE
public class CooldownJsonExample extends CooldownExample {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.bukkit.entity.Player;
import org.bukkit.entity.Sheep;

// DONE
public class EntityJsonExample extends EntityExample {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import java.util.UUID;
import org.bukkit.entity.Player;

// DONE
public class GlowJsonExample extends GlowExample {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.bukkit.Location;
import org.bukkit.entity.Player;

// DONE
public class HologramJsonExample extends HologramExample {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import com.lunarclient.apollo.example.utilities.JsonUtil;
import org.bukkit.entity.Player;

// DONE
public class LimbJsonExample extends LimbExample {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import com.lunarclient.apollo.example.modules.impl.ModSettingsExample;
import org.bukkit.entity.Player;

// TODO
public class ModSettingsJsonExample extends ModSettingsExample {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import net.kyori.adventure.text.format.TextDecoration;
import org.bukkit.entity.Player;

// DONE
public class NametagJsonExample extends NametagExample {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import com.lunarclient.apollo.example.utilities.JsonPacketUtil;
import org.bukkit.entity.Player;

// DONE
public class NickHiderJsonExample extends NickHiderExample {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.entity.Player;

// DONE
public class NotificationJsonExample extends NotificationExample {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import com.lunarclient.apollo.example.utilities.JsonPacketUtil;
import org.bukkit.entity.Player;

// DONE
public class RichPresenceJsonExample extends RichPresenceExample {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import java.util.stream.Stream;
import org.bukkit.entity.Player;

// DONE
public class StaffModJsonExample extends StaffModExample {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import com.lunarclient.apollo.example.utilities.JsonPacketUtil;
import org.bukkit.entity.Player;

// DONE
public class StopwatchJsonExample extends StopwatchExample {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import com.lunarclient.apollo.example.utilities.JsonPacketUtil;
import org.bukkit.entity.Player;

// DONE
public class VignetteJsonExample extends VignetteExample {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.bukkit.Location;
import org.bukkit.entity.Player;

// DONE
public class WaypointJsonExample extends WaypointExample {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.bukkit.Location;
import org.bukkit.entity.Player;

// DONE
public class BeamProtoExample extends BeamExample {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import java.awt.Color;
import org.bukkit.entity.Player;

// DONE
public class BorderProtoExample extends BorderExample {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;

// DONE
public class ChatProtoExample extends ChatExample {

private int countdown = 5;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import java.util.UUID;
import org.bukkit.entity.Player;

// DONE
public class ColoredFireProtoExample extends ColoredFireExample {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,22 @@
*/
package com.lunarclient.apollo.example.modules.impl.proto;

import com.google.protobuf.Value;
import com.lunarclient.apollo.configurable.v1.ConfigurableSettings;
import com.lunarclient.apollo.example.modules.impl.CombatExample;
import com.lunarclient.apollo.example.utilities.ProtobufPacketUtil;
import java.util.HashMap;
import java.util.Map;

public class CombatProtoExample extends CombatExample {

// TODO
@Override
public void setDisableMissPenalty(boolean value) {
Map<String, Value> properties = new HashMap<>();
properties.put("disable-miss-penalty", Value.newBuilder().setBoolValue(value).build());

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

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import java.time.Duration;
import org.bukkit.entity.Player;

// DONE
public class CooldownProtoExample extends CooldownExample {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.bukkit.entity.Player;
import org.bukkit.entity.Sheep;

// DONE
public class EntityProtoExample extends EntityExample {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import java.util.UUID;
import org.bukkit.entity.Player;

// DONE
public class GlowProtoExample extends GlowExample {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import org.bukkit.Location;
import org.bukkit.entity.Player;

// DONE
public class HologramProtoExample extends HologramExample {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import java.util.EnumSet;
import org.bukkit.entity.Player;

// DONE
public class LimbProtoExample extends LimbExample {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,42 @@
*/
package com.lunarclient.apollo.example.modules.impl.proto;

import com.google.protobuf.NullValue;
import com.google.protobuf.Value;
import com.lunarclient.apollo.configurable.v1.ConfigurableSettings;
import com.lunarclient.apollo.example.modules.impl.ModSettingsExample;
import com.lunarclient.apollo.example.utilities.ProtobufPacketUtil;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.entity.Player;

// TODO
public class ModSettingsProtoExample extends ModSettingsExample {

@Override
public void disableLightningModExample(Player viewer) {
Map<String, Value> properties = new HashMap<>();
properties.put("lighting.enabled", Value.newBuilder().setBoolValue(false).build());

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

@Override
public void rollbackLightningModEnabledState(Player viewer) {
Map<String, Value> properties = new HashMap<>();
properties.put("lighting.enabled", Value.newBuilder().setNullValue(NullValue.NULL_VALUE).build());

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

@Override
public void broadcastDisableLightningModExample() {
Map<String, Value> properties = new HashMap<>();
properties.put("lighting.enabled", Value.newBuilder().setBoolValue(false).build());

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

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import net.kyori.adventure.text.format.TextDecoration;
import org.bukkit.entity.Player;

// DONE
public class NametagProtoExample extends NametagExample {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import com.lunarclient.apollo.nickhider.v1.ResetNickHiderMessage;
import org.bukkit.entity.Player;

// DONE
public class NickHiderProtoExample extends NickHiderExample {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.entity.Player;

// DONE
public class NotificationProtoExample extends NotificationExample {

@Override
Expand Down
Loading

0 comments on commit 75ea8f6

Please sign in to comment.