mirror of
https://github.com/barkeser2002/CatServer.git
synced 2026-09-25 02:20:01 +03:00
239 lines
12 KiB
Diff
239 lines
12 KiB
Diff
--- ../src-base/minecraft/net/minecraft/server/management/PreYggdrasilConverter.java
|
|
+++ ../src-work/minecraft/net/minecraft/server/management/PreYggdrasilConverter.java
|
|
@@ -10,7 +10,6 @@
|
|
import com.mojang.authlib.ProfileLookupCallback;
|
|
import com.mojang.authlib.yggdrasil.ProfileNotFoundException;
|
|
import java.io.File;
|
|
-import java.io.FileNotFoundException;
|
|
import java.io.IOException;
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.text.ParseException;
|
|
@@ -22,6 +21,8 @@
|
|
import java.util.UUID;
|
|
import javax.annotation.Nullable;
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
+import net.minecraft.nbt.CompressedStreamTools;
|
|
+import net.minecraft.nbt.NBTTagCompound;
|
|
import net.minecraft.server.MinecraftServer;
|
|
import net.minecraft.server.dedicated.DedicatedServer;
|
|
import net.minecraft.server.dedicated.PropertyManager;
|
|
@@ -49,7 +50,7 @@
|
|
}
|
|
}), String.class);
|
|
|
|
- if (server.isServerInOnlineMode())
|
|
+ if (server.isServerInOnlineMode() || org.spigotmc.SpigotConfig.bungee) // Spigot: bungee = online mode, for now.
|
|
{
|
|
server.getGameProfileRepository().findProfilesByNames(astring, Agent.MINECRAFT, callback);
|
|
}
|
|
@@ -135,9 +136,10 @@
|
|
{
|
|
userlistbans.readSavedFile();
|
|
}
|
|
- catch (FileNotFoundException filenotfoundexception)
|
|
+ // CraftBukkit start - FileNotFoundException -> IOException, don't print stacktrace
|
|
+ catch (IOException filenotfoundexception)
|
|
{
|
|
- LOGGER.warn("Could not load existing file {}", userlistbans.getSaveFile().getName(), filenotfoundexception);
|
|
+ LOGGER.warn("Could not load existing file {}", userlistbans.getSaveFile().getName());
|
|
}
|
|
}
|
|
|
|
@@ -155,7 +157,7 @@
|
|
if (astring == null)
|
|
{
|
|
PreYggdrasilConverter.LOGGER.warn("Could not convert user banlist entry for {}", (Object)p_onProfileLookupSucceeded_1_.getName());
|
|
- throw new PreYggdrasilConverter.ConversionError("Profile not in the conversionlist");
|
|
+ throw new ConversionError("Profile not in the conversionlist");
|
|
}
|
|
else
|
|
{
|
|
@@ -172,7 +174,7 @@
|
|
|
|
if (!(p_onProfileLookupFailed_2_ instanceof ProfileNotFoundException))
|
|
{
|
|
- throw new PreYggdrasilConverter.ConversionError("Could not request user " + p_onProfileLookupFailed_1_.getName() + " from backend systems", p_onProfileLookupFailed_2_);
|
|
+ throw new ConversionError("Could not request user " + p_onProfileLookupFailed_1_.getName() + " from backend systems", p_onProfileLookupFailed_2_);
|
|
}
|
|
}
|
|
};
|
|
@@ -186,7 +188,7 @@
|
|
LOGGER.warn("Could not read old user banlist to convert it!", (Throwable)ioexception);
|
|
return false;
|
|
}
|
|
- catch (PreYggdrasilConverter.ConversionError preyggdrasilconverter$conversionerror)
|
|
+ catch (ConversionError preyggdrasilconverter$conversionerror)
|
|
{
|
|
LOGGER.error("Conversion failed, please try again later", (Throwable)preyggdrasilconverter$conversionerror);
|
|
return false;
|
|
@@ -211,9 +213,10 @@
|
|
{
|
|
userlistipbans.readSavedFile();
|
|
}
|
|
- catch (FileNotFoundException filenotfoundexception)
|
|
+ // CraftBukkit start - FileNotFoundException -> IOException, don't print stacktrace
|
|
+ catch (IOException filenotfoundexception)
|
|
{
|
|
- LOGGER.warn("Could not load existing file {}", userlistipbans.getSaveFile().getName(), filenotfoundexception);
|
|
+ LOGGER.warn("Could not load existing file {}", userlistipbans.getSaveFile().getName());
|
|
}
|
|
}
|
|
|
|
@@ -261,9 +264,10 @@
|
|
{
|
|
userlistops.readSavedFile();
|
|
}
|
|
- catch (FileNotFoundException filenotfoundexception)
|
|
+ // CraftBukkit start - FileNotFoundException -> IOException, don't print stacktrace
|
|
+ catch (IOException filenotfoundexception)
|
|
{
|
|
- LOGGER.warn("Could not load existing file {}", userlistops.getSaveFile().getName(), filenotfoundexception);
|
|
+ LOGGER.warn("Could not load existing file {}", userlistops.getSaveFile().getName());
|
|
}
|
|
}
|
|
|
|
@@ -283,7 +287,7 @@
|
|
|
|
if (!(p_onProfileLookupFailed_2_ instanceof ProfileNotFoundException))
|
|
{
|
|
- throw new PreYggdrasilConverter.ConversionError("Could not request user " + p_onProfileLookupFailed_1_.getName() + " from backend systems", p_onProfileLookupFailed_2_);
|
|
+ throw new ConversionError("Could not request user " + p_onProfileLookupFailed_1_.getName() + " from backend systems", p_onProfileLookupFailed_2_);
|
|
}
|
|
}
|
|
};
|
|
@@ -297,7 +301,7 @@
|
|
LOGGER.warn("Could not read old oplist to convert it!", (Throwable)ioexception);
|
|
return false;
|
|
}
|
|
- catch (PreYggdrasilConverter.ConversionError preyggdrasilconverter$conversionerror)
|
|
+ catch (ConversionError preyggdrasilconverter$conversionerror)
|
|
{
|
|
LOGGER.error("Conversion failed, please try again later", (Throwable)preyggdrasilconverter$conversionerror);
|
|
return false;
|
|
@@ -322,9 +326,10 @@
|
|
{
|
|
userlistwhitelist.readSavedFile();
|
|
}
|
|
- catch (FileNotFoundException filenotfoundexception)
|
|
+ // CraftBukkit start - FileNotFoundException -> IOException, don't print stacktrace
|
|
+ catch (IOException filenotfoundexception)
|
|
{
|
|
- LOGGER.warn("Could not load existing file {}", userlistwhitelist.getSaveFile().getName(), filenotfoundexception);
|
|
+ LOGGER.warn("Could not load existing file {}", userlistwhitelist.getSaveFile().getName());
|
|
}
|
|
}
|
|
|
|
@@ -344,7 +349,7 @@
|
|
|
|
if (!(p_onProfileLookupFailed_2_ instanceof ProfileNotFoundException))
|
|
{
|
|
- throw new PreYggdrasilConverter.ConversionError("Could not request user " + p_onProfileLookupFailed_1_.getName() + " from backend systems", p_onProfileLookupFailed_2_);
|
|
+ throw new ConversionError("Could not request user " + p_onProfileLookupFailed_1_.getName() + " from backend systems", p_onProfileLookupFailed_2_);
|
|
}
|
|
}
|
|
};
|
|
@@ -358,7 +363,7 @@
|
|
LOGGER.warn("Could not read old whitelist to convert it!", (Throwable)ioexception);
|
|
return false;
|
|
}
|
|
- catch (PreYggdrasilConverter.ConversionError preyggdrasilconverter$conversionerror)
|
|
+ catch (ConversionError preyggdrasilconverter$conversionerror)
|
|
{
|
|
LOGGER.error("Conversion failed, please try again later", (Throwable)preyggdrasilconverter$conversionerror);
|
|
return false;
|
|
@@ -409,7 +414,7 @@
|
|
|
|
if (uuid == null)
|
|
{
|
|
- throw new PreYggdrasilConverter.ConversionError("Missing UUID for user profile " + p_onProfileLookupSucceeded_1_.getName());
|
|
+ throw new ConversionError("Missing UUID for user profile " + p_onProfileLookupSucceeded_1_.getName());
|
|
}
|
|
else
|
|
{
|
|
@@ -427,18 +432,41 @@
|
|
}
|
|
else
|
|
{
|
|
- throw new PreYggdrasilConverter.ConversionError("Could not request user " + p_onProfileLookupFailed_1_.getName() + " from backend systems", p_onProfileLookupFailed_2_);
|
|
+ throw new ConversionError("Could not request user " + p_onProfileLookupFailed_1_.getName() + " from backend systems", p_onProfileLookupFailed_2_);
|
|
}
|
|
}
|
|
private void renamePlayerFile(File p_152743_1_, String p_152743_2_, String p_152743_3_)
|
|
{
|
|
File file5 = new File(file1, p_152743_2_ + ".dat");
|
|
File file6 = new File(p_152743_1_, p_152743_3_ + ".dat");
|
|
+ // CraftBukkit start - Use old file name to seed lastKnownName
|
|
+ NBTTagCompound root = null;
|
|
+
|
|
+ try {
|
|
+ root = CompressedStreamTools.readCompressed(new java.io.FileInputStream(file1));
|
|
+ } catch (Exception exception) {
|
|
+ exception.printStackTrace();
|
|
+ }
|
|
+
|
|
+ if (root != null) {
|
|
+ if (!root.hasKey("bukkit")) {
|
|
+ root.setTag("bukkit", new NBTTagCompound());
|
|
+ }
|
|
+ NBTTagCompound data = root.getCompoundTag("bukkit");
|
|
+ data.setString("lastKnownName", p_152743_2_);
|
|
+
|
|
+ try {
|
|
+ CompressedStreamTools.writeCompressed(root, new java.io.FileOutputStream(file2));
|
|
+ } catch (Exception exception) {
|
|
+ exception.printStackTrace();
|
|
+ }
|
|
+ }
|
|
+ // CraftBukkit end
|
|
PreYggdrasilConverter.mkdir(p_152743_1_);
|
|
|
|
if (!file5.renameTo(file6))
|
|
{
|
|
- throw new PreYggdrasilConverter.ConversionError("Could not convert file for " + p_152743_2_);
|
|
+ throw new ConversionError("Could not convert file for " + p_152743_2_);
|
|
}
|
|
}
|
|
private String getFileNameForProfile(GameProfile p_152744_1_)
|
|
@@ -456,7 +484,7 @@
|
|
|
|
if (s2 == null)
|
|
{
|
|
- throw new PreYggdrasilConverter.ConversionError("Could not find the filename for " + p_152744_1_.getName() + " anymore");
|
|
+ throw new ConversionError("Could not find the filename for " + p_152744_1_.getName() + " anymore");
|
|
}
|
|
else
|
|
{
|
|
@@ -467,7 +495,7 @@
|
|
lookupNames(server, Lists.newArrayList(astring), profilelookupcallback);
|
|
return true;
|
|
}
|
|
- catch (PreYggdrasilConverter.ConversionError preyggdrasilconverter$conversionerror)
|
|
+ catch (ConversionError preyggdrasilconverter$conversionerror)
|
|
{
|
|
LOGGER.error("Conversion failed, please try again later", (Throwable)preyggdrasilconverter$conversionerror);
|
|
return false;
|
|
@@ -486,12 +514,12 @@
|
|
{
|
|
if (!dir.isDirectory())
|
|
{
|
|
- throw new PreYggdrasilConverter.ConversionError("Can't create directory " + dir.getName() + " in world save directory.");
|
|
+ throw new ConversionError("Can't create directory " + dir.getName() + " in world save directory.");
|
|
}
|
|
}
|
|
else if (!dir.mkdirs())
|
|
{
|
|
- throw new PreYggdrasilConverter.ConversionError("Can't create directory " + dir.getName() + " in world save directory.");
|
|
+ throw new ConversionError("Can't create directory " + dir.getName() + " in world save directory.");
|
|
}
|
|
}
|
|
|
|
@@ -589,7 +617,7 @@
|
|
private static File getPlayersDirectory(PropertyManager properties)
|
|
{
|
|
String s = properties.getStringProperty("level-name", "world");
|
|
- File file1 = new File(s);
|
|
+ File file1 = new File(MinecraftServer.getServerInst().server.getWorldContainer(), s); // CraftBukkit - Respect container setting
|
|
return new File(file1, "players");
|
|
}
|
|
|