forked from SteamWar/SteamWar
Remove Lunar client support
They currently have a problem with their maven repository
This commit is contained in:
@@ -57,7 +57,6 @@ dependencies {
|
||||
implementation(libs.mysql)
|
||||
|
||||
implementation(libs.msgpack)
|
||||
implementation(libs.apolloprotos)
|
||||
|
||||
implementation(libs.nbt)
|
||||
|
||||
|
||||
@@ -19,25 +19,9 @@
|
||||
|
||||
package de.steamwar.velocitycore.mods;
|
||||
|
||||
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.messages.Chatter;
|
||||
import de.steamwar.sql.Mod;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.UserPerm;
|
||||
import de.steamwar.velocitycore.VelocityCore;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class Lunar {
|
||||
// https://lunarclient.dev/apollo/introduction
|
||||
@@ -45,61 +29,7 @@ public class Lunar {
|
||||
|
||||
public static final String CHANNEL = "lunar:apollo";
|
||||
|
||||
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) {
|
||||
player.sendPluginMessage(MinecraftChannelIdentifier.from(CHANNEL), packet);
|
||||
}
|
||||
|
||||
public void handlePluginMessage(PluginMessageEvent event) {
|
||||
try {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
private void handle(Player player, PlayerHandshakeMessage packet) {
|
||||
if (!SteamwarUser.get(player.getUniqueId()).hasPerm(UserPerm.RESTRICTED_MODS)) {
|
||||
Chatter.disconnect(player).prefixless("MOD_YELLOW_SING", "Lunar");
|
||||
return;
|
||||
}
|
||||
|
||||
List<Mod> mods = new ArrayList<>();
|
||||
|
||||
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);
|
||||
Chatter.disconnect((Player) event.getSource()).prefixless("MOD_YELLOW_SING", "lunar");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user