1
0
mirror of https://github.com/GeyserMC/Floodgate.git synced 2025-12-19 14:59:20 +00:00

Added metrics and fixed relocations not applying for child projects

This commit is contained in:
Tim203
2022-03-21 14:41:53 +01:00
parent 440e20f5ea
commit 465e66df72
22 changed files with 406 additions and 48 deletions

View File

@@ -42,6 +42,7 @@ import org.geysermc.floodgate.logger.JavaUtilFloodgateLogger;
import org.geysermc.floodgate.platform.command.CommandUtil;
import org.geysermc.floodgate.platform.listener.ListenerRegistration;
import org.geysermc.floodgate.platform.pluginmessage.PluginMessageUtils;
import org.geysermc.floodgate.platform.util.PlatformUtils;
import org.geysermc.floodgate.pluginmessage.PluginMessageRegistration;
import org.geysermc.floodgate.pluginmessage.SpigotPluginMessageRegistration;
import org.geysermc.floodgate.pluginmessage.SpigotPluginMessageUtils;
@@ -49,12 +50,18 @@ import org.geysermc.floodgate.pluginmessage.SpigotSkinApplier;
import org.geysermc.floodgate.skin.SkinApplier;
import org.geysermc.floodgate.util.LanguageManager;
import org.geysermc.floodgate.util.SpigotCommandUtil;
import org.geysermc.floodgate.util.SpigotPlatformUtils;
import org.geysermc.floodgate.util.SpigotVersionSpecificMethods;
@RequiredArgsConstructor
public final class SpigotPlatformModule extends AbstractModule {
private final SpigotPlugin plugin;
@Override
protected void configure() {
bind(PlatformUtils.class).to(SpigotPlatformUtils.class);
}
@Provides
@Singleton
public JavaPlugin javaPlugin() {

View File

@@ -58,6 +58,7 @@ public class ClassNames {
public static final Field HANDSHAKE_HOST;
public static final Field LOGIN_PROFILE;
public static final Field PACKET_LISTENER;
@Nullable
public static final Field PAPER_DISABLE_USERNAME_VALIDATION;
@@ -67,6 +68,10 @@ public class ClassNames {
public static final Method INIT_UUID;
public static final Method FIRE_LOGIN_EVENTS;
public static final Class<?> SPIGOT_CONFIG;
public static final Field BUNGEE;
public static final Method GET_VERSION;
static {
String version = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
SPIGOT_MAPPING_PREFIX = "net.minecraft.server." + version;
@@ -162,12 +167,24 @@ public class ClassNames {
FIRE_LOGIN_EVENTS = getMethod(LOGIN_HANDLER, "fireEvents");
checkNotNull(FIRE_LOGIN_EVENTS, "fireEvents from LoginHandler");
PAPER_DISABLE_USERNAME_VALIDATION = getField(LOGIN_LISTENER,
"iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation");
if (Constants.DEBUG_MODE) {
System.out.println("Paper disable username validation field exists? " +
(PAPER_DISABLE_USERNAME_VALIDATION != null));
}
// SpigotPlatformUtils
SPIGOT_CONFIG = ReflectionUtils.getClass("org.spigotmc.SpigotConfig");
checkNotNull(SPIGOT_CONFIG, "Spigot config");
BUNGEE = ReflectionUtils.getField(SPIGOT_CONFIG, "bungee");
checkNotNull(BUNGEE, "Bungee field");
GET_VERSION = ReflectionUtils.getMethod(MINECRAFT_SERVER, "getVersion");
checkNotNull(GET_VERSION, "Minecraft server version");
}
private static Class<?> getClassOrFallBack(String className, String fallbackName) {

View File

@@ -0,0 +1,48 @@
/*
* 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.util;
import org.bukkit.Bukkit;
import org.geysermc.floodgate.platform.util.PlatformUtils;
public class SpigotPlatformUtils extends PlatformUtils {
@Override
@SuppressWarnings("ConstantConditions")
public AuthType authType() {
if (Bukkit.getOnlineMode()) {
return AuthType.ONLINE;
}
boolean bungeeEnabled = ReflectionUtils.getCastedValue(null, ClassNames.BUNGEE);
return bungeeEnabled ? AuthType.PROXIED : AuthType.OFFLINE;
}
@Override
public String minecraftVersion() {
Object instance = ReflectionUtils.invokeStatic(ClassNames.MINECRAFT_SERVER, "getServer");
return ReflectionUtils.castedInvoke(instance, ClassNames.GET_VERSION);
}
}