[Breaking] Fix ECO NPC's. This is a work around of CB's recent changes blocking invalid uuid lookups.

NPC's converted with the previous version will need manual changes.
This commit is contained in:
KHobbits 2014-04-19 02:03:39 +01:00
parent b6d6b24796
commit 887957756e
3 changed files with 18 additions and 9 deletions

View File

@ -5,6 +5,7 @@ import com.earth2me.essentials.craftbukkit.FakeWorld;
import com.earth2me.essentials.settings.Spawns;
import com.earth2me.essentials.storage.YamlStorageWriter;
import com.earth2me.essentials.utils.StringUtil;
import com.google.common.base.Charsets;
import java.io.*;
import java.math.BigInteger;
import java.security.DigestInputStream;
@ -567,6 +568,12 @@ public class EssentialsUpgrade
}
catch (Exception ex2)
{
if (conf.getBoolean("npc", false))
{
uuid = UUID.nameUUIDFromBytes(("NPC:" + name).getBytes(Charsets.UTF_8));
break;
}
org.bukkit.OfflinePlayer player = ess.getServer().getOfflinePlayer(name);
uuid = player.getUniqueId();
}
@ -575,16 +582,9 @@ public class EssentialsUpgrade
{
countBukkit++;
break;
}
if (uuid == null && conf.getBoolean("npc", false))
{
uuid = UUID.randomUUID();
break;
}
}
}
if (uuid != null)
{
conf.forceSave();

View File

@ -16,9 +16,11 @@ import static com.earth2me.essentials.api.Economy.setMoney;
import static com.earth2me.essentials.api.Economy.substract;
import com.earth2me.essentials.utils.NumberUtil;
import com.earth2me.essentials.utils.StringUtil;
import com.google.common.base.Charsets;
import java.io.File;
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.ess3.api.IEssentials;
@ -53,11 +55,14 @@ public class Economy
{
folder.mkdirs();
}
EssentialsUserConf npcConfig = new EssentialsUserConf(name, null, new File(folder, name + ".yml"));
UUID npcUUID = UUID.nameUUIDFromBytes(("NPC:" + name).getBytes(Charsets.UTF_8));
EssentialsUserConf npcConfig = new EssentialsUserConf(name, npcUUID, new File(folder, npcUUID.toString() + ".yml"));
npcConfig.load();
npcConfig.setProperty("npc", true);
npcConfig.setProperty("lastAccountName", name);
npcConfig.setProperty("money", ess.getSettings().getStartingBalance());
npcConfig.forceSave();
ess.getUserMap().trackUUID(npcUUID, name);
}
private static void deleteNPC(String name)

View File

@ -1244,6 +1244,10 @@ public class FakeServer implements Server
{
return createOPlayer("testPlayer1");
}
if (arg0.toString().equalsIgnoreCase("f4a37409-5c40-3b2c-9cd6-57d3c5abdc76"))
{
return createOPlayer("npc1");
}
throw new UnsupportedOperationException("Not supported yet.");
}
}