mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-14 12:11:25 +01:00
[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:
parent
b6d6b24796
commit
887957756e
@ -5,6 +5,7 @@ import com.earth2me.essentials.craftbukkit.FakeWorld;
|
|||||||
import com.earth2me.essentials.settings.Spawns;
|
import com.earth2me.essentials.settings.Spawns;
|
||||||
import com.earth2me.essentials.storage.YamlStorageWriter;
|
import com.earth2me.essentials.storage.YamlStorageWriter;
|
||||||
import com.earth2me.essentials.utils.StringUtil;
|
import com.earth2me.essentials.utils.StringUtil;
|
||||||
|
import com.google.common.base.Charsets;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.security.DigestInputStream;
|
import java.security.DigestInputStream;
|
||||||
@ -567,6 +568,12 @@ public class EssentialsUpgrade
|
|||||||
}
|
}
|
||||||
catch (Exception ex2)
|
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);
|
org.bukkit.OfflinePlayer player = ess.getServer().getOfflinePlayer(name);
|
||||||
uuid = player.getUniqueId();
|
uuid = player.getUniqueId();
|
||||||
}
|
}
|
||||||
@ -576,14 +583,7 @@ public class EssentialsUpgrade
|
|||||||
countBukkit++;
|
countBukkit++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uuid == null && conf.getBoolean("npc", false))
|
|
||||||
{
|
|
||||||
uuid = UUID.randomUUID();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (uuid != null)
|
if (uuid != null)
|
||||||
{
|
{
|
||||||
|
@ -16,9 +16,11 @@ import static com.earth2me.essentials.api.Economy.setMoney;
|
|||||||
import static com.earth2me.essentials.api.Economy.substract;
|
import static com.earth2me.essentials.api.Economy.substract;
|
||||||
import com.earth2me.essentials.utils.NumberUtil;
|
import com.earth2me.essentials.utils.NumberUtil;
|
||||||
import com.earth2me.essentials.utils.StringUtil;
|
import com.earth2me.essentials.utils.StringUtil;
|
||||||
|
import com.google.common.base.Charsets;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.MathContext;
|
import java.math.MathContext;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import net.ess3.api.IEssentials;
|
import net.ess3.api.IEssentials;
|
||||||
@ -53,11 +55,14 @@ public class Economy
|
|||||||
{
|
{
|
||||||
folder.mkdirs();
|
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.load();
|
||||||
npcConfig.setProperty("npc", true);
|
npcConfig.setProperty("npc", true);
|
||||||
|
npcConfig.setProperty("lastAccountName", name);
|
||||||
npcConfig.setProperty("money", ess.getSettings().getStartingBalance());
|
npcConfig.setProperty("money", ess.getSettings().getStartingBalance());
|
||||||
npcConfig.forceSave();
|
npcConfig.forceSave();
|
||||||
|
ess.getUserMap().trackUUID(npcUUID, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void deleteNPC(String name)
|
private static void deleteNPC(String name)
|
||||||
|
@ -1244,6 +1244,10 @@ public class FakeServer implements Server
|
|||||||
{
|
{
|
||||||
return createOPlayer("testPlayer1");
|
return createOPlayer("testPlayer1");
|
||||||
}
|
}
|
||||||
|
if (arg0.toString().equalsIgnoreCase("f4a37409-5c40-3b2c-9cd6-57d3c5abdc76"))
|
||||||
|
{
|
||||||
|
return createOPlayer("npc1");
|
||||||
|
}
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
throw new UnsupportedOperationException("Not supported yet.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user