Merge remote-tracking branch 'origin/BauweltMemberConfig' into BauweltMemberConfig
Dieser Commit ist enthalten in:
Commit
e880c796e3
@ -19,6 +19,7 @@
|
||||
|
||||
package de.steamwar.inventory;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
@ -269,7 +270,7 @@ class SWItem_14 {
|
||||
ItemStack head = new ItemStack(Material.PLAYER_HEAD, 1);
|
||||
SkullMeta headmeta = (SkullMeta) head.getItemMeta();
|
||||
assert headmeta != null;
|
||||
headmeta.setOwner(player);
|
||||
headmeta.setOwningPlayer(Bukkit.getOfflinePlayer(player));
|
||||
headmeta.setDisplayName(player);
|
||||
head.setItemMeta(headmeta);
|
||||
return head;
|
||||
|
33
SpigotCore_15/src/de/steamwar/authlib/AuthlibInjector_15.java
Normale Datei
33
SpigotCore_15/src/de/steamwar/authlib/AuthlibInjector_15.java
Normale Datei
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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();
|
||||
}
|
||||
}
|
47
SpigotCore_Main/src/de/steamwar/authlib/AuthlibInjector.java
Normale Datei
47
SpigotCore_Main/src/de/steamwar/authlib/AuthlibInjector.java
Normale Datei
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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 com.mojang.authlib.yggdrasil.YggdrasilGameProfileRepository;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.core.VersionedCallable;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class 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();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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 com.mojang.authlib.Agent;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.GameProfileRepository;
|
||||
import com.mojang.authlib.ProfileLookupCallback;
|
||||
import com.mojang.authlib.yggdrasil.YggdrasilGameProfileRepository;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SteamwarGameProfileRepository implements GameProfileRepository {
|
||||
|
||||
private final YggdrasilGameProfileRepository fallback;
|
||||
|
||||
public SteamwarGameProfileRepository(YggdrasilGameProfileRepository repository) {
|
||||
fallback = repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void findProfilesByNames(String[] strings, Agent agent, ProfileLookupCallback profileLookupCallback) {
|
||||
if(agent == Agent.SCROLLS) {
|
||||
fallback.findProfilesByNames(strings, agent, profileLookupCallback);
|
||||
} else {
|
||||
List<String> unknownNames = new ArrayList<>();
|
||||
for (String name:strings) {
|
||||
SteamwarUser user = SteamwarUser.get(name);
|
||||
if(user == null) {
|
||||
unknownNames.add(name);
|
||||
continue;
|
||||
}
|
||||
|
||||
profileLookupCallback.onProfileLookupSucceeded(new GameProfile(user.getUUID(), user.getUserName()));
|
||||
}
|
||||
if(!unknownNames.isEmpty()) {
|
||||
fallback.findProfilesByNames(unknownNames.toArray(new String[0]), agent, profileLookupCallback);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.steamwar.core;
|
||||
|
||||
import de.steamwar.authlib.AuthlibInjector;
|
||||
import de.steamwar.comms.BungeeReceiver;
|
||||
import de.steamwar.core.events.ChattingEvent;
|
||||
import de.steamwar.core.events.ChunkListener;
|
||||
@ -64,6 +65,7 @@ public class Core extends JavaPlugin{
|
||||
ErrorLogger.init();
|
||||
getServer().getMessenger().registerIncomingPluginChannel(this, "sw:bridge", new BungeeReceiver());
|
||||
getServer().getMessenger().registerOutgoingPluginChannel(this, "sw:bridge");
|
||||
AuthlibInjector.inject();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren