forked from SteamWar/SteamWar
Additional Pluginmessage classifications, Lunar refactoring
This commit is contained in:
@@ -62,6 +62,5 @@ dependencies {
|
||||
|
||||
implementation(libs.msgpack)
|
||||
|
||||
implementation(libs.apolloapi)
|
||||
implementation(libs.apollocommon)
|
||||
implementation(libs.apolloprotos)
|
||||
}
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
package de.steamwar.velocitycore.listeners;
|
||||
|
||||
import com.lunarclient.apollo.ApolloManager;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.connection.PluginMessageEvent;
|
||||
import com.velocitypowered.api.event.player.PlayerChannelRegisterEvent;
|
||||
@@ -32,12 +31,12 @@ import com.velocitypowered.api.proxy.messages.ChannelMessageSource;
|
||||
import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier;
|
||||
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import de.steamwar.messages.Chatter;
|
||||
import de.steamwar.network.packets.NetworkPacket;
|
||||
import de.steamwar.velocitycore.VelocityCore;
|
||||
import de.steamwar.velocitycore.commands.TeamCommand;
|
||||
import de.steamwar.velocitycore.mods.*;
|
||||
import de.steamwar.velocitycore.network.ServerMetaInfo;
|
||||
import de.steamwar.messages.Chatter;
|
||||
import de.steamwar.network.packets.NetworkPacket;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@@ -115,15 +114,15 @@ public class PluginMessage extends BasicListener {
|
||||
"labymod3:main", "labymod:neo", "labymod:voicechat", "labymod:germanminer",
|
||||
"feather:client/frag",
|
||||
Alpine.HANDSHAKE, Alpine.PLAY,
|
||||
"lunarclient:pm", "transfer:channel", "apollo:json", //https://lunarclient.dev/apollo/developers/modules/transfer (Lunarclient channels)
|
||||
|
||||
"sw:hotkeys",
|
||||
"floodgate:form", "floodgate:w", "floodgate:packet", "floodgate:transfer",
|
||||
"floodgate:form", "floodgate:w", "floodgate:packet", "floodgate:transfer", "erosion:msg",
|
||||
|
||||
"Replay|Restrict", "replaymod:restrict",
|
||||
"WDL|CONTROL", "wdl:control",
|
||||
"tpshud:handshake", "tpshud:tps", //https://github.com/mooziii/tpshud-fabric/tree/main
|
||||
"methane_server:statepacket", //https://modrinth.com/mod/methane
|
||||
"servux:structures", "servux:entity_data", "servux:hud_metadata", "servux:debug_service", //https://modrinth.com/mod/servux
|
||||
"architectury:spawn_entity_packet", //https://modrinth.com/mod/architectury-api
|
||||
"jei:channel", "jei:cheat_permission", //https://modrinth.com/mod/jei
|
||||
"owo:local_packet", "owo:sync_screen_handler_properties", //https://modrinth.com/mod/owo-lib
|
||||
@@ -185,13 +184,16 @@ public class PluginMessage extends BasicListener {
|
||||
"walkietalkie:buttonpressedresponse", //https://github.com/Flaton1/walkie-talkie-mod (Simple voice chat walkietalkie addon)
|
||||
"whereisit:s2c_founditem", "whereisit:found_item_s2c", //https://modrinth.com/mod/where-is-it (needs server side component to work)
|
||||
"wildfire_gender:hurt", "wildfire_gender:sync", //https://github.com/WildfireRomeo/WildfireFemaleGenderMod (Female player model)
|
||||
"lunarclient:pm", "transfer:channel", //https://lunarclient.dev/apollo/developers/modules/transfer (Lunarclient channels)
|
||||
"cancelblockupdate:channel", //https://github.com/Phoupraw/CancelBlockUpdate/ (Server side block update suppression)
|
||||
"replayvoicechat:entity_sound", "replayvoicechat:locational_sound", "replayvoicechat:static_sound", //https://github.com/henkelmax/replay-voice-chat (Record simple voice chat with replay mod)
|
||||
"adventure:registered_arg_mappings",
|
||||
"better-suggestions:entity_scores_response", "better-suggestions:entity_tags_response", //https://github.com/shurik204/better-suggestions (Better command tab completion)
|
||||
"farmingforblockheads:chicken_nest_effect", "farmingforblockheads:market_categories", //https://github.com/TwelveIterationMods/FarmingForBlockheads (Improved farming with new blocks)
|
||||
|
||||
//https://modrinth.com/mod/servux
|
||||
"servux:structures", "servux:entity_data", "servux:hud_metadata", "servux:debug_service",
|
||||
"servux:tweaks",
|
||||
|
||||
//https://github.com/ZsoltMolnarrr/SpellEngine (Magic library)
|
||||
"spell_engine:config_sync", "spell_engine:particle_effects", "spell_engine:spell_animation",
|
||||
"spell_engine:spell_cooldown", "spell_engine:spell_registry_sync",
|
||||
@@ -335,7 +337,7 @@ public class PluginMessage extends BasicListener {
|
||||
))
|
||||
channelRegisterHandlers.put(channel, player -> {});
|
||||
|
||||
channelRegisterHandlers.put(ApolloManager.PLUGIN_MESSAGE_CHANNEL, lunar::sendRestrictions);
|
||||
channelRegisterHandlers.put(Lunar.CHANNEL, lunar::sendRestrictions);
|
||||
channelRegisterHandlers.put(Feather.CHANNEL, new Feather()::sendRestrictions);
|
||||
channelRegisterHandlers.put("openboatutils:settings", player -> send(player, "openboatutils:settings", new byte[] { 0, 0 })); //https://github.com/o7Moon/OpenBoatUtils/wiki/Packets (Reset packet)
|
||||
channelRegisterHandlers.put("itemswapper:disable", player -> send(player, "itemswapper:disable", new byte[]{ 0 })); //https://github.com/tr7zw/ItemSwapper/blob/main/src/main/java/dev/tr7zw/itemswapper/packets/DisableModPayload.java
|
||||
@@ -413,7 +415,8 @@ public class PluginMessage extends BasicListener {
|
||||
"fwaystones:request_player_waystone_update",
|
||||
"openboatutils:settings", //https://github.com/o7Moon/OpenBoatUtils
|
||||
"block-event-separator:handshake", //https://github.com/SpaceWalkerRS/block-event-separator (Separating block events)
|
||||
"oth3r-sit:settings_v1.1" //https://github.com/Oth3r/Sit (Sitting mod)
|
||||
"oth3r-sit:settings_v1.1", //https://github.com/Oth3r/Sit (Sitting mod)
|
||||
"carryon:key_pressed" //https://github.com/Tschipp/CarryOn/blob/1.21/Common/src/main/java/tschipp/carryon/networking/serverbound/ServerboundCarryKeyPressedPacket.java
|
||||
))
|
||||
register(channel, false, directional(UNKNOWN, DROP));
|
||||
|
||||
@@ -431,8 +434,7 @@ public class PluginMessage extends BasicListener {
|
||||
register("WDL|INIT", true, directional(UNKNOWN, wdl::handlePluginMessage));
|
||||
register("wdl:init", true, directional(UNKNOWN, wdl::handlePluginMessage));
|
||||
|
||||
register("apollo:json", true, UNKNOWN);
|
||||
register(ApolloManager.PLUGIN_MESSAGE_CHANNEL, true, async(lunar::handlePluginMessage));
|
||||
register(Lunar.CHANNEL, true, async(lunar::handlePluginMessage));
|
||||
register(Alpine.HANDSHAKE, false, directional(UNKNOWN, new Alpine()::handleHandshakeMessage));
|
||||
register("LMC", true, directional(UNKNOWN, async(labyMod::handlePluginMessage)));
|
||||
register("labymod3:main", true, directional(UNKNOWN, async(labyMod::handlePluginMessage)));
|
||||
|
||||
@@ -19,112 +19,79 @@
|
||||
|
||||
package de.steamwar.velocitycore.mods;
|
||||
|
||||
import com.lunarclient.apollo.ApolloManager;
|
||||
import com.lunarclient.apollo.libs.protobuf.Any;
|
||||
import com.lunarclient.apollo.libs.protobuf.InvalidProtocolBufferException;
|
||||
import com.lunarclient.apollo.libs.protobuf.Message;
|
||||
import com.lunarclient.apollo.mods.impl.*;
|
||||
import com.lunarclient.apollo.module.ApolloModuleManager;
|
||||
import com.lunarclient.apollo.module.ApolloModuleManagerImpl;
|
||||
import com.lunarclient.apollo.module.modsetting.ModSettingModule;
|
||||
import com.lunarclient.apollo.network.NetworkOptions;
|
||||
import com.lunarclient.apollo.option.Options;
|
||||
import com.lunarclient.apollo.player.AbstractApolloPlayer;
|
||||
import com.google.protobuf.Any;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import com.google.protobuf.Value;
|
||||
import com.lunarclient.apollo.configurable.v1.ConfigurableSettings;
|
||||
import com.lunarclient.apollo.configurable.v1.OverrideConfigurableSettingsMessage;
|
||||
import com.lunarclient.apollo.player.v1.ModMessage;
|
||||
import com.lunarclient.apollo.player.v1.PlayerHandshakeMessage;
|
||||
import com.velocitypowered.api.event.connection.PluginMessageEvent;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||
import de.steamwar.velocitycore.VelocityCore;
|
||||
import de.steamwar.sql.Mod;
|
||||
import lombok.AllArgsConstructor;
|
||||
import de.steamwar.velocitycore.VelocityCore;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class Lunar {
|
||||
// https://lunarclient.dev/apollo/introduction
|
||||
// https://github.com/LunarClient/Apollo
|
||||
|
||||
private final ApolloModuleManager manager = new ApolloModuleManagerImpl().addModule(ModSettingModule.class);
|
||||
public static final String CHANNEL = "lunar:apollo";
|
||||
|
||||
public Lunar() { //TODO seems defunct
|
||||
Options modSettings = manager.getModule(ModSettingModule.class).getOptions();
|
||||
modSettings.set(ModReplaymod.ENABLED, false); // TODO check if restrictions working
|
||||
modSettings.set(ModFreelook.ENABLED, false);
|
||||
modSettings.set(ModHypixelMod.ENABLED, false);
|
||||
modSettings.set(ModMinimap.ENABLED, false);
|
||||
modSettings.set(ModNametag.ENABLED, false);
|
||||
modSettings.set(ModTeamView.ENABLED, false);
|
||||
modSettings.set(ModTntCountdown.ENABLED, false);
|
||||
modSettings.set(ModToggleSneak.TOGGLE_SNEAK_CONTAINER, false);
|
||||
private final byte[] packet;
|
||||
|
||||
public Lunar() {
|
||||
ConfigurableSettings.Builder builder = ConfigurableSettings.newBuilder()
|
||||
.setApolloModule("mod_setting")
|
||||
.setEnable(true);
|
||||
|
||||
for(String property : List.of(
|
||||
"freelook.enabled", "hypixel-mod.enabled", "minimap.enabled", "nametag.enabled", "replaymod.enabled",
|
||||
"team-view.enabled", "tnt-countdown.enabled", "toggle-sneak.toggle-sneak-container"
|
||||
))
|
||||
builder.putProperties(property, Value.newBuilder().setBoolValue(false).build());
|
||||
|
||||
packet = Any.pack(OverrideConfigurableSettingsMessage.newBuilder().addConfigurableSettings(builder).build()).toByteArray();
|
||||
}
|
||||
|
||||
public void sendRestrictions(Player player) {
|
||||
NetworkOptions.sendOptions(manager.getModules(), true, new SWApolloPlayer(player));
|
||||
player.sendPluginMessage(MinecraftChannelIdentifier.from(CHANNEL), packet);
|
||||
}
|
||||
|
||||
public void handlePluginMessage(PluginMessageEvent event) {
|
||||
Player player = (Player) event.getSource();
|
||||
Any packet;
|
||||
|
||||
try {
|
||||
packet = Any.parseFrom(event.getData());
|
||||
Any packet = Any.parseFrom(event.getData());
|
||||
if(packet.is(PlayerHandshakeMessage.class))
|
||||
handle((Player) event.getSource(), packet.unpack(PlayerHandshakeMessage.class));
|
||||
} catch (InvalidProtocolBufferException e) {
|
||||
throw new SecurityException(e);
|
||||
}
|
||||
}
|
||||
|
||||
handle(PlayerHandshakeMessage.class, packet, handshake -> {
|
||||
List<Mod> mods = new ArrayList<>();
|
||||
private void handle(Player player, PlayerHandshakeMessage packet) {
|
||||
List<Mod> mods = new ArrayList<>();
|
||||
|
||||
for(ModMessage mod : handshake.getInstalledModsList()) {
|
||||
switch(mod.getType()) {
|
||||
case TYPE_FABRIC_INTERNAL, TYPE_FORGE_INTERNAL:
|
||||
// Controlled with ModSettings
|
||||
break;
|
||||
case TYPE_FABRIC_EXTERNAL:
|
||||
mods.add(Mod.getOrCreate(mod.getName(), Mod.Platform.FABRIC));
|
||||
break;
|
||||
case TYPE_FORGE_EXTERNAL:
|
||||
mods.add(Mod.getOrCreate(mod.getName(), Mod.Platform.FORGE));
|
||||
break;
|
||||
default:
|
||||
VelocityCore.getLogger().log(Level.INFO, () -> player.getUsername() + " uses Lunar mod with unknown type " + mod);
|
||||
break;
|
||||
}
|
||||
for(ModMessage mod : packet.getInstalledModsList()) {
|
||||
switch(mod.getType()) {
|
||||
case TYPE_FABRIC_INTERNAL, TYPE_FORGE_INTERNAL:
|
||||
// Controlled with ModSettings
|
||||
break;
|
||||
case TYPE_FABRIC_EXTERNAL:
|
||||
mods.add(Mod.getOrCreate(mod.getName(), Mod.Platform.FABRIC));
|
||||
break;
|
||||
case TYPE_FORGE_EXTERNAL:
|
||||
mods.add(Mod.getOrCreate(mod.getName(), Mod.Platform.FORGE));
|
||||
break;
|
||||
default:
|
||||
VelocityCore.getLogger().log(Level.INFO, () -> player.getUsername() + " uses Lunar mod with unknown type " + mod);
|
||||
break;
|
||||
}
|
||||
|
||||
ModUtils.handleMods(player, mods);
|
||||
});
|
||||
}
|
||||
|
||||
private <T extends Message> void handle(Class<T> type, Any packet, Consumer<T> handler) {
|
||||
try {
|
||||
handler.accept(packet.unpack(type));
|
||||
} catch (InvalidProtocolBufferException ignored) { /*ignored*/ }
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
private static class SWApolloPlayer extends AbstractApolloPlayer {
|
||||
|
||||
private final Player player;
|
||||
|
||||
@Override
|
||||
public void sendPacket(Message message) {
|
||||
sendPacket(Any.pack(message).toByteArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPacket(byte[] bytes) {
|
||||
player.sendPluginMessage(MinecraftChannelIdentifier.from(ApolloManager.PLUGIN_MESSAGE_CHANNEL), bytes);
|
||||
}
|
||||
|
||||
@Override public UUID getUniqueId() { return player.getUniqueId(); }
|
||||
@Override public String getName() { return player.getUsername(); }
|
||||
@Override public boolean hasPermission(String s) { return player.hasPermission(s); }
|
||||
@Override public Object getPlayer() { return player; }
|
||||
ModUtils.handleMods(player, mods);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-4
@@ -107,8 +107,6 @@ dependencyResolutionManagement {
|
||||
library("netty", "io.netty:netty-all:4.1.68.Final")
|
||||
library("junit", "junit:junit:4.13.2")
|
||||
library("hamcrest", "org.hamcrest:hamcrest:2.2")
|
||||
library("jda", "net.dv8tion:JDA:5.2.0")
|
||||
library("msgpack", "org.msgpack:msgpack-core:0.9.8")
|
||||
library("classindex", "org.atteo.classindex:classindex:3.13")
|
||||
|
||||
library("spigotapi", "org.spigotmc:spigot-api:1.20-R0.1-SNAPSHOT")
|
||||
@@ -140,8 +138,9 @@ dependencyResolutionManagement {
|
||||
|
||||
library("velocity", "de.steamwar:velocity:RELEASE")
|
||||
library("velocityapi", "com.velocitypowered:velocity-api:3.3.0-SNAPSHOT")
|
||||
library("apolloapi", "com.lunarclient:apollo-api:1.1.0")
|
||||
library("apollocommon", "com.lunarclient:apollo-common:1.1.0")
|
||||
library("jda", "net.dv8tion:JDA:5.2.0")
|
||||
library("msgpack", "org.msgpack:msgpack-core:0.9.8")
|
||||
library("apolloprotos", "com.lunarclient:apollo-protos:1.0-SNAPSHOT")
|
||||
|
||||
library("logback", "ch.qos.logback:logback-classic:1.5.6")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user