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.event.LoginEvent;
|
||||
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.plugin.Listener;
|
||||
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.player.FloodgatePlayer;
|
||||
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.LanguageManager;
|
||||
import org.geysermc.floodgate.util.ReflectionUtils;
|
||||
@@ -67,6 +70,7 @@ public final class BungeeListener implements Listener {
|
||||
@Inject private ProxyFloodgateApi api;
|
||||
@Inject private LanguageManager languageManager;
|
||||
@Inject private FloodgateLogger logger;
|
||||
@Inject private SkinApplier skinApplier;
|
||||
|
||||
@Inject
|
||||
@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)
|
||||
public void onPlayerDisconnect(PlayerDisconnectEvent event) {
|
||||
api.playerRemoved(event.getPlayer().getUniqueId());
|
||||
|
||||
@@ -25,6 +25,10 @@
|
||||
|
||||
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 net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
@@ -38,6 +42,12 @@ import org.geysermc.floodgate.skin.SkinData;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public final class BungeeSkinApplier implements SkinApplier {
|
||||
private static final Field LOGIN_RESULT;
|
||||
|
||||
static {
|
||||
LOGIN_RESULT = getFieldOfType(InitialHandler.class, LoginResult.class);
|
||||
}
|
||||
|
||||
private final FloodgateLogger logger;
|
||||
|
||||
@Override
|
||||
@@ -61,6 +71,7 @@ public final class BungeeSkinApplier implements SkinApplier {
|
||||
if (loginResult == null) {
|
||||
// id and name are unused and properties will be overridden
|
||||
loginResult = new LoginResult(null, null, null);
|
||||
setValue(handler, LOGIN_RESULT, loginResult);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* TranslatableMessage is the interface for a message that can be translated.
|
||||
* Messages are generally implemented using enums.
|
||||
* TranslatableMessage is the interface for a message that can be translated. Messages are generally
|
||||
* implemented using enums.
|
||||
*/
|
||||
public interface TranslatableMessage {
|
||||
/**
|
||||
@@ -52,7 +52,7 @@ public interface TranslatableMessage {
|
||||
for (int i = 0; i < translateParts.length; i++) {
|
||||
builder.append(manager.getString(translateParts[i], locale, args));
|
||||
if (translateParts.length != i + 1) {
|
||||
builder.append(" ");
|
||||
builder.append(' ');
|
||||
}
|
||||
}
|
||||
return builder.toString();
|
||||
|
||||
@@ -111,7 +111,7 @@ public final class UserAudienceArgument extends CommandArgument<UserAudience, Us
|
||||
StringBuilder builder = new StringBuilder(input);
|
||||
while (!inputQueue.isEmpty()) {
|
||||
String string = inputQueue.remove();
|
||||
builder.append(" ").append(string);
|
||||
builder.append(' ').append(string);
|
||||
if (string.endsWith("\"")) {
|
||||
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.geysermc.floodgate.api.handshake.HandshakeHandlers;
|
||||
import org.geysermc.floodgate.api.logger.FloodgateLogger;
|
||||
import org.geysermc.floodgate.module.PaperListenerModule;
|
||||
import org.geysermc.floodgate.module.PluginMessageModule;
|
||||
import org.geysermc.floodgate.module.ServerCommonModule;
|
||||
import org.geysermc.floodgate.module.SpigotAddonModule;
|
||||
import org.geysermc.floodgate.module.SpigotCommandModule;
|
||||
import org.geysermc.floodgate.module.SpigotListenerModule;
|
||||
import org.geysermc.floodgate.module.SpigotPlatformModule;
|
||||
import org.geysermc.floodgate.util.ReflectionUtils;
|
||||
import org.geysermc.floodgate.util.SpigotHandshakeHandler;
|
||||
import org.geysermc.floodgate.util.SpigotProtocolSupportHandler;
|
||||
import org.geysermc.floodgate.util.SpigotProtocolSupportListener;
|
||||
@@ -63,11 +65,17 @@ public final class SpigotPlugin extends JavaPlugin {
|
||||
public void onEnable() {
|
||||
platform.enable(
|
||||
new SpigotCommandModule(this),
|
||||
new SpigotListenerModule(),
|
||||
new SpigotAddonModule(),
|
||||
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
|
||||
injector.getInstance(HandshakeHandlers.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
|
||||
public void register(Listener listener) {
|
||||
if (listener == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
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.register.ListenerRegister;
|
||||
|
||||
public final class SpigotListenerModule extends AbstractModule {
|
||||
public class SpigotListenerModule extends AbstractModule {
|
||||
@Override
|
||||
protected void configure() {
|
||||
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.proxy.InboundConnection;
|
||||
import com.velocitypowered.api.util.GameProfile;
|
||||
import com.velocitypowered.api.util.GameProfile.Property;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.util.AttributeKey;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@@ -141,8 +142,10 @@ public final class VelocityListener {
|
||||
FloodgatePlayer player = playerCache.getIfPresent(event.getConnection());
|
||||
if (player != null) {
|
||||
playerCache.invalidate(event.getConnection());
|
||||
event.setGameProfile(new GameProfile(
|
||||
player.getCorrectUniqueId(), player.getCorrectUsername(), new ArrayList<>()));
|
||||
// The texture properties addition is to fix the February 2 2022 Mojang authentication changes
|
||||
event.setGameProfile(new GameProfile(player.getCorrectUniqueId(),
|
||||
player.getCorrectUsername(), Collections.singletonList(
|
||||
new Property("textures", "", ""))));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user