mirror of
https://github.com/GeyserMC/Floodgate.git
synced 2025-12-19 14:59:20 +00:00
Merge remote-tracking branch 'origin/master' into dev/2.1.1
# Conflicts: # spigot/pom.xml
This commit is contained in:
@@ -36,6 +36,7 @@ import java.util.UUID;
|
|||||||
import net.md_5.bungee.api.connection.PendingConnection;
|
import net.md_5.bungee.api.connection.PendingConnection;
|
||||||
import net.md_5.bungee.api.event.LoginEvent;
|
import net.md_5.bungee.api.event.LoginEvent;
|
||||||
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
||||||
|
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||||
import net.md_5.bungee.api.event.PreLoginEvent;
|
import net.md_5.bungee.api.event.PreLoginEvent;
|
||||||
import net.md_5.bungee.api.plugin.Listener;
|
import net.md_5.bungee.api.plugin.Listener;
|
||||||
import net.md_5.bungee.connection.InitialHandler;
|
import net.md_5.bungee.connection.InitialHandler;
|
||||||
@@ -46,6 +47,8 @@ import org.geysermc.floodgate.api.ProxyFloodgateApi;
|
|||||||
import org.geysermc.floodgate.api.logger.FloodgateLogger;
|
import org.geysermc.floodgate.api.logger.FloodgateLogger;
|
||||||
import org.geysermc.floodgate.api.player.FloodgatePlayer;
|
import org.geysermc.floodgate.api.player.FloodgatePlayer;
|
||||||
import org.geysermc.floodgate.player.FloodgatePlayerImpl;
|
import org.geysermc.floodgate.player.FloodgatePlayerImpl;
|
||||||
|
import org.geysermc.floodgate.skin.SkinApplier;
|
||||||
|
import org.geysermc.floodgate.skin.SkinData;
|
||||||
import org.geysermc.floodgate.util.BungeeCommandUtil;
|
import org.geysermc.floodgate.util.BungeeCommandUtil;
|
||||||
import org.geysermc.floodgate.util.LanguageManager;
|
import org.geysermc.floodgate.util.LanguageManager;
|
||||||
import org.geysermc.floodgate.util.ReflectionUtils;
|
import org.geysermc.floodgate.util.ReflectionUtils;
|
||||||
@@ -67,6 +70,7 @@ public final class BungeeListener implements Listener {
|
|||||||
@Inject private ProxyFloodgateApi api;
|
@Inject private ProxyFloodgateApi api;
|
||||||
@Inject private LanguageManager languageManager;
|
@Inject private LanguageManager languageManager;
|
||||||
@Inject private FloodgateLogger logger;
|
@Inject private FloodgateLogger logger;
|
||||||
|
@Inject private SkinApplier skinApplier;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Named("playerAttribute")
|
@Named("playerAttribute")
|
||||||
@@ -121,6 +125,15 @@ public final class BungeeListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
|
public void onPostLogin(PostLoginEvent event) {
|
||||||
|
// To fix the February 2 2022 Mojang authentication changes
|
||||||
|
FloodgatePlayer player = api.getPlayer(event.getPlayer().getUniqueId());
|
||||||
|
if (player != null) {
|
||||||
|
skinApplier.applySkin(player, new SkinData("", ""));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onPlayerDisconnect(PlayerDisconnectEvent event) {
|
public void onPlayerDisconnect(PlayerDisconnectEvent event) {
|
||||||
api.playerRemoved(event.getPlayer().getUniqueId());
|
api.playerRemoved(event.getPlayer().getUniqueId());
|
||||||
|
|||||||
@@ -25,6 +25,10 @@
|
|||||||
|
|
||||||
package org.geysermc.floodgate.pluginmessage;
|
package org.geysermc.floodgate.pluginmessage;
|
||||||
|
|
||||||
|
import static org.geysermc.floodgate.util.ReflectionUtils.getFieldOfType;
|
||||||
|
import static org.geysermc.floodgate.util.ReflectionUtils.setValue;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
@@ -38,6 +42,12 @@ import org.geysermc.floodgate.skin.SkinData;
|
|||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public final class BungeeSkinApplier implements SkinApplier {
|
public final class BungeeSkinApplier implements SkinApplier {
|
||||||
|
private static final Field LOGIN_RESULT;
|
||||||
|
|
||||||
|
static {
|
||||||
|
LOGIN_RESULT = getFieldOfType(InitialHandler.class, LoginResult.class);
|
||||||
|
}
|
||||||
|
|
||||||
private final FloodgateLogger logger;
|
private final FloodgateLogger logger;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -61,6 +71,7 @@ public final class BungeeSkinApplier implements SkinApplier {
|
|||||||
if (loginResult == null) {
|
if (loginResult == null) {
|
||||||
// id and name are unused and properties will be overridden
|
// id and name are unused and properties will be overridden
|
||||||
loginResult = new LoginResult(null, null, null);
|
loginResult = new LoginResult(null, null, null);
|
||||||
|
setValue(handler, LOGIN_RESULT, loginResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
Property property = new Property("textures", skinData.getValue(), skinData.getSignature());
|
Property property = new Property("textures", skinData.getValue(), skinData.getSignature());
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ package org.geysermc.floodgate.platform.command;
|
|||||||
import org.geysermc.floodgate.util.LanguageManager;
|
import org.geysermc.floodgate.util.LanguageManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TranslatableMessage is the interface for a message that can be translated.
|
* TranslatableMessage is the interface for a message that can be translated. Messages are generally
|
||||||
* Messages are generally implemented using enums.
|
* implemented using enums.
|
||||||
*/
|
*/
|
||||||
public interface TranslatableMessage {
|
public interface TranslatableMessage {
|
||||||
/**
|
/**
|
||||||
@@ -52,7 +52,7 @@ public interface TranslatableMessage {
|
|||||||
for (int i = 0; i < translateParts.length; i++) {
|
for (int i = 0; i < translateParts.length; i++) {
|
||||||
builder.append(manager.getString(translateParts[i], locale, args));
|
builder.append(manager.getString(translateParts[i], locale, args));
|
||||||
if (translateParts.length != i + 1) {
|
if (translateParts.length != i + 1) {
|
||||||
builder.append(" ");
|
builder.append(' ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ public final class UserAudienceArgument extends CommandArgument<UserAudience, Us
|
|||||||
StringBuilder builder = new StringBuilder(input);
|
StringBuilder builder = new StringBuilder(input);
|
||||||
while (!inputQueue.isEmpty()) {
|
while (!inputQueue.isEmpty()) {
|
||||||
String string = inputQueue.remove();
|
String string = inputQueue.remove();
|
||||||
builder.append(" ").append(string);
|
builder.append(' ').append(string);
|
||||||
if (string.endsWith("\"")) {
|
if (string.endsWith("\"")) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
0
spigot/pom.xml
Normal file
0
spigot/pom.xml
Normal file
@@ -30,12 +30,14 @@ import com.google.inject.Injector;
|
|||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.geysermc.floodgate.api.handshake.HandshakeHandlers;
|
import org.geysermc.floodgate.api.handshake.HandshakeHandlers;
|
||||||
import org.geysermc.floodgate.api.logger.FloodgateLogger;
|
import org.geysermc.floodgate.api.logger.FloodgateLogger;
|
||||||
|
import org.geysermc.floodgate.module.PaperListenerModule;
|
||||||
import org.geysermc.floodgate.module.PluginMessageModule;
|
import org.geysermc.floodgate.module.PluginMessageModule;
|
||||||
import org.geysermc.floodgate.module.ServerCommonModule;
|
import org.geysermc.floodgate.module.ServerCommonModule;
|
||||||
import org.geysermc.floodgate.module.SpigotAddonModule;
|
import org.geysermc.floodgate.module.SpigotAddonModule;
|
||||||
import org.geysermc.floodgate.module.SpigotCommandModule;
|
import org.geysermc.floodgate.module.SpigotCommandModule;
|
||||||
import org.geysermc.floodgate.module.SpigotListenerModule;
|
import org.geysermc.floodgate.module.SpigotListenerModule;
|
||||||
import org.geysermc.floodgate.module.SpigotPlatformModule;
|
import org.geysermc.floodgate.module.SpigotPlatformModule;
|
||||||
|
import org.geysermc.floodgate.util.ReflectionUtils;
|
||||||
import org.geysermc.floodgate.util.SpigotHandshakeHandler;
|
import org.geysermc.floodgate.util.SpigotHandshakeHandler;
|
||||||
import org.geysermc.floodgate.util.SpigotProtocolSupportHandler;
|
import org.geysermc.floodgate.util.SpigotProtocolSupportHandler;
|
||||||
import org.geysermc.floodgate.util.SpigotProtocolSupportListener;
|
import org.geysermc.floodgate.util.SpigotProtocolSupportListener;
|
||||||
@@ -63,11 +65,17 @@ public final class SpigotPlugin extends JavaPlugin {
|
|||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
platform.enable(
|
platform.enable(
|
||||||
new SpigotCommandModule(this),
|
new SpigotCommandModule(this),
|
||||||
new SpigotListenerModule(),
|
|
||||||
new SpigotAddonModule(),
|
new SpigotAddonModule(),
|
||||||
new PluginMessageModule()
|
new PluginMessageModule()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (ReflectionUtils.getClassSilently(
|
||||||
|
"com.destroystokyo.paper.event.profile.PreFillProfileEvent") != null) {
|
||||||
|
platform.enable(new PaperListenerModule());
|
||||||
|
} else {
|
||||||
|
platform.enable(new SpigotListenerModule());
|
||||||
|
}
|
||||||
|
|
||||||
//todo add proper support for disabling things on shutdown and enabling this on enable
|
//todo add proper support for disabling things on shutdown and enabling this on enable
|
||||||
injector.getInstance(HandshakeHandlers.class)
|
injector.getInstance(HandshakeHandlers.class)
|
||||||
.addHandshakeHandler(injector.getInstance(SpigotHandshakeHandler.class));
|
.addHandshakeHandler(injector.getInstance(SpigotHandshakeHandler.class));
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019-2022 GeyserMC. http://geysermc.org
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @author GeyserMC
|
||||||
|
* @link https://github.com/GeyserMC/Floodgate
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.geysermc.floodgate.listener;
|
||||||
|
|
||||||
|
import com.destroystokyo.paper.event.profile.PreFillProfileEvent;
|
||||||
|
import com.destroystokyo.paper.profile.ProfileProperty;
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.geysermc.floodgate.api.SimpleFloodgateApi;
|
||||||
|
|
||||||
|
public final class PaperProfileListener implements Listener {
|
||||||
|
@Inject private SimpleFloodgateApi api;
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onFill(PreFillProfileEvent event) {
|
||||||
|
UUID id = event.getPlayerProfile().getId();
|
||||||
|
if (!this.api.isFloodgatePlayer(id) ||
|
||||||
|
event.getPlayerProfile().getProperties().stream().anyMatch(
|
||||||
|
prop -> "textures".equals(prop.getName()))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<ProfileProperty> properties = new HashSet<>(event.getPlayerProfile().getProperties());
|
||||||
|
properties.add(new ProfileProperty("textures", "", ""));
|
||||||
|
event.setProperties(properties);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -38,6 +38,10 @@ public final class SpigotListenerRegistration implements ListenerRegistration<Li
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void register(Listener listener) {
|
public void register(Listener listener) {
|
||||||
|
if (listener == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(listener, plugin);
|
Bukkit.getServer().getPluginManager().registerEvents(listener, plugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019-2022 GeyserMC. http://geysermc.org
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @author GeyserMC
|
||||||
|
* @link https://github.com/GeyserMC/Floodgate
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.geysermc.floodgate.module;
|
||||||
|
|
||||||
|
import com.google.inject.Singleton;
|
||||||
|
import com.google.inject.TypeLiteral;
|
||||||
|
import com.google.inject.multibindings.ProvidesIntoSet;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.geysermc.floodgate.listener.PaperProfileListener;
|
||||||
|
import org.geysermc.floodgate.register.ListenerRegister;
|
||||||
|
|
||||||
|
public class PaperListenerModule extends SpigotListenerModule {
|
||||||
|
@Override
|
||||||
|
protected void configure() {
|
||||||
|
bind(new TypeLiteral<ListenerRegister<Listener>>() {}).asEagerSingleton();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
@ProvidesIntoSet
|
||||||
|
public Listener paperProfileListener() {
|
||||||
|
return new PaperProfileListener();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -33,7 +33,7 @@ import org.bukkit.event.Listener;
|
|||||||
import org.geysermc.floodgate.listener.SpigotListener;
|
import org.geysermc.floodgate.listener.SpigotListener;
|
||||||
import org.geysermc.floodgate.register.ListenerRegister;
|
import org.geysermc.floodgate.register.ListenerRegister;
|
||||||
|
|
||||||
public final class SpigotListenerModule extends AbstractModule {
|
public class SpigotListenerModule extends AbstractModule {
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
bind(new TypeLiteral<ListenerRegister<Listener>>() {}).asEagerSingleton();
|
bind(new TypeLiteral<ListenerRegister<Listener>>() {}).asEagerSingleton();
|
||||||
|
|||||||
@@ -44,10 +44,11 @@ import com.velocitypowered.api.event.connection.PreLoginEvent;
|
|||||||
import com.velocitypowered.api.event.player.GameProfileRequestEvent;
|
import com.velocitypowered.api.event.player.GameProfileRequestEvent;
|
||||||
import com.velocitypowered.api.proxy.InboundConnection;
|
import com.velocitypowered.api.proxy.InboundConnection;
|
||||||
import com.velocitypowered.api.util.GameProfile;
|
import com.velocitypowered.api.util.GameProfile;
|
||||||
|
import com.velocitypowered.api.util.GameProfile.Property;
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import io.netty.util.AttributeKey;
|
import io.netty.util.AttributeKey;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.Collections;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
@@ -141,8 +142,10 @@ public final class VelocityListener {
|
|||||||
FloodgatePlayer player = playerCache.getIfPresent(event.getConnection());
|
FloodgatePlayer player = playerCache.getIfPresent(event.getConnection());
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
playerCache.invalidate(event.getConnection());
|
playerCache.invalidate(event.getConnection());
|
||||||
event.setGameProfile(new GameProfile(
|
// The texture properties addition is to fix the February 2 2022 Mojang authentication changes
|
||||||
player.getCorrectUniqueId(), player.getCorrectUsername(), new ArrayList<>()));
|
event.setGameProfile(new GameProfile(player.getCorrectUniqueId(),
|
||||||
|
player.getCorrectUsername(), Collections.singletonList(
|
||||||
|
new Property("textures", "", ""))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user