SteamWar/SpigotCore
Archiviert
13
0

New version dependent, ProtocolLib -> TinyProtocol, Sub 1.12 ErrorLogger #114

Manuell gemergt
Lixfel hat 6 Commits von newVersionDependentNoProtocolLib nach master 2021-09-11 21:03:46 +02:00 zusammengeführt
4 geänderte Dateien mit 10 neuen und 55 gelöschten Zeilen
Nur Änderungen aus Commit 6f116804b7 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -1,33 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.authlib;
import net.minecraft.server.v1_15_R1.MinecraftServer;
public class AuthlibInjector_15 {
static Class getMinecraftClass() {
return MinecraftServer.class;
}
static Object getMinecraftServerInstance() {
return MinecraftServer.getServer();
}
}

Datei anzeigen

@ -19,7 +19,7 @@
package de.steamwar.core;
import de.steamwar.authlib.AuthlibInjector;
import de.steamwar.core.authlib.AuthlibInjector;
import de.steamwar.comms.BungeeReceiver;
import de.steamwar.core.events.ChattingEvent;
import de.steamwar.core.events.ChunkListener;

Datei anzeigen

@ -17,31 +17,19 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.authlib;
package de.steamwar.core.authlib;
import com.comphenix.tinyprotocol.Reflection;
import com.mojang.authlib.GameProfileRepository;
import com.mojang.authlib.yggdrasil.YggdrasilGameProfileRepository;
import de.steamwar.core.Core;
import de.steamwar.core.VersionedCallable;
import java.lang.reflect.Field;
public class AuthlibInjector {
private AuthlibInjector() {}
public static void inject() {
if (Core.getVersion() != 15) {
return;
}
try {
Class<?> minecraftServerClass = VersionedCallable.call(new VersionedCallable<>(() -> AuthlibInjector_15.getMinecraftClass(), 15));
Field repo = minecraftServerClass.getDeclaredField("gameProfileRepository");
repo.setAccessible(true);
Object instance = VersionedCallable.call(new VersionedCallable<>(() -> AuthlibInjector_15.getMinecraftServerInstance(), 15));
repo.set(instance, new SteamwarGameProfileRepository((YggdrasilGameProfileRepository) repo.get(instance)));
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
Class<?> minecraftServerClass = Reflection.getClass("{nms}.MinecraftServer");
Reflection.FieldAccessor<GameProfileRepository> gameProfile = Reflection.getField(minecraftServerClass, GameProfileRepository.class, 0);
Object minecraftServer = Reflection.getTypedMethod(minecraftServerClass, "getServer", minecraftServerClass).invoke(null);
gameProfile.set(minecraftServer, new SteamwarGameProfileRepository((YggdrasilGameProfileRepository) gameProfile.get(minecraftServer)));
}
}

Datei anzeigen

@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.authlib;
package de.steamwar.core.authlib;
import com.mojang.authlib.Agent;
import com.mojang.authlib.GameProfile;