Fixed loading configuration problens(Based on version for 1.7.10 from
jakub)
This commit is contained in:
parent
f8746f5f11
commit
0d9105a580
@ -5,164 +5,679 @@ import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.jakub1221.herobrineai.misc.CustomID;
|
||||
|
||||
public class ConfigDB {
|
||||
public class ConfigDB
|
||||
{
|
||||
private Logger log;
|
||||
public YamlConfiguration config;
|
||||
public YamlConfiguration npc;
|
||||
public int ShowRate = 2;
|
||||
public boolean HitPlayer = true;
|
||||
public boolean SendMessages = true;
|
||||
public boolean Lighting = true;
|
||||
public boolean DestroyTorches = true;
|
||||
public int DestroyTorchesRadius = 5;
|
||||
public int ShowInterval = 144000;
|
||||
public boolean TotemExplodes = true;
|
||||
public boolean OnlyWalkingMode = false;
|
||||
public boolean BuildStuff = true;
|
||||
public boolean PlaceSigns = true;
|
||||
public boolean UseTotem = true;
|
||||
public boolean WriteBooks = true;
|
||||
public boolean Killable = false;
|
||||
public boolean UsePotionEffects = true;
|
||||
public int CaveChance = 40;
|
||||
public int BookChance = 5;
|
||||
public int SignChance = 5;
|
||||
public String DeathMessage = "You cannot kill me!";
|
||||
public List<String> useWorlds = new ArrayList<String>();
|
||||
public List<String> useMessages = new ArrayList<String>();
|
||||
public List<String> useSignMessages = new ArrayList<String>();
|
||||
public List<String> useBookMessages = new ArrayList<String>();
|
||||
public boolean BuildPyramids = true;
|
||||
public boolean UseGraveyardWorld = true;
|
||||
public boolean BuryPlayers = true;
|
||||
public boolean SpawnWolves = true;
|
||||
public boolean SpawnBats = true;
|
||||
public boolean UseWalkingMode = true;
|
||||
public int WalkingModeXRadius = 1000;
|
||||
public int WalkingModeZRadius = 1000;
|
||||
public int WalkingModeFromXRadius = 0;
|
||||
public int WalkingModeFromZRadius = 0;
|
||||
public boolean BuildTemples = true;
|
||||
public boolean UseArtifactBow = true;
|
||||
public boolean UseArtifactSword = true;
|
||||
public boolean UseArtifactApple = true;
|
||||
public boolean AttackCreative = true;
|
||||
public boolean AttackOP = true;
|
||||
public boolean SecuredArea_Build = true;
|
||||
public boolean SecuredArea_Attack = true;
|
||||
public boolean SecuredArea_Haunt = true;
|
||||
public boolean SecuredArea_Signs = true;
|
||||
public boolean SecuredArea_Books = true;
|
||||
public int HerobrineHP = 150;
|
||||
public int BuildInterval = 72000;
|
||||
public boolean UseHeads = true;
|
||||
public boolean UseCustomItems = false;
|
||||
public boolean UseAncientSword = true;
|
||||
public boolean UseNPC_Guardian = true;
|
||||
public boolean UseNPC_Warrior = true;
|
||||
public boolean UseNPC_Demon = true;
|
||||
public CustomID ItemInHand = null;
|
||||
public List<String> UseCustomItemsList = new ArrayList<String>();
|
||||
public boolean Explosions = true;
|
||||
public boolean Burn = true;
|
||||
public boolean Curse = true;
|
||||
public int maxBooks = 1;
|
||||
public int maxSigns = 1;
|
||||
public int maxHeads = 1;
|
||||
public boolean UseIgnorePermission = true;
|
||||
public String HerobrineName = "Herobrine";
|
||||
public boolean UseSound = true;
|
||||
private boolean isStartupDone = false;
|
||||
|
||||
public YamlConfiguration config = new YamlConfiguration();
|
||||
public YamlConfiguration npc = new YamlConfiguration();
|
||||
public ConfigDB(Logger l)
|
||||
{
|
||||
this.log = l;
|
||||
}
|
||||
|
||||
public int showRate = 2;
|
||||
public boolean hitPlayer = true;
|
||||
public boolean sendMessages = true;
|
||||
public boolean lighting = true;
|
||||
public boolean destroyTorches = true;
|
||||
public int destroyTorchesRadius = 5;
|
||||
public int showInterval = 144000;
|
||||
public boolean totemExplodes = true;
|
||||
public boolean buildStuff = true;
|
||||
public boolean placeSigns = true;
|
||||
public boolean useTotem = true;
|
||||
public boolean writeBooks = true;
|
||||
public boolean killable= false;
|
||||
public boolean usePotionEffects = true;
|
||||
public int caveChance = 40;
|
||||
public int bookChance = 5;
|
||||
public int signChance = 5;
|
||||
public String deathMessage = "You cannot kill me!";
|
||||
public List<String> useWorlds = new ArrayList<String>();
|
||||
public List<String> useMessages = new ArrayList<String>();
|
||||
public List<String> useSignMessages = new ArrayList<String>();
|
||||
public List<String> useBookMessages = new ArrayList<String>();
|
||||
public boolean buildPyramids = true;
|
||||
public boolean useGraveyardWorld = true;
|
||||
public boolean buryPlayers = true;
|
||||
public boolean spawnWolves = true;
|
||||
public boolean spawnBats = true;
|
||||
public boolean attackCreative = true;
|
||||
public boolean attackOP = true;
|
||||
public boolean securedAreaBuild = true;
|
||||
public boolean securedAreaAttack = true;
|
||||
public boolean securedAreaHaunt = true;
|
||||
public boolean securedAreaSigns = true;
|
||||
public boolean securedAreaBooks = true;
|
||||
public int herobrineHP = 150;
|
||||
public int buildInterval = 72000;
|
||||
public boolean useHeads = true;
|
||||
public boolean useNPCGuardian = true;
|
||||
public boolean useNPCWarrior = true;
|
||||
public boolean useNPCDemon = true;
|
||||
public CustomID itemInHand = null;
|
||||
public boolean explosions = true;
|
||||
public boolean burn = true;
|
||||
public boolean curse = true;
|
||||
public int maxBooks = 1;
|
||||
public int maxSigns = 1;
|
||||
public int maxHeads = 1;
|
||||
public boolean useIgnorePermission = true;
|
||||
public boolean useSound = true;
|
||||
public File configF = new File("plugins/Herobrine/config.yml");
|
||||
public File npcF = new File("plugins/Herobrine/npc.yml");
|
||||
public File configF = new File("plugins"+File.separator+"HerobrineAI"+File.separator+"config.yml");
|
||||
public File npcF = new File("plugins"+File.separator+"HerobrineAI"+File.separator+"npc.yml");
|
||||
|
||||
public void reload() {
|
||||
try {
|
||||
config.load(configF);
|
||||
npc.load(npcF);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
showInterval = config.getInt("config.ShowInterval", showInterval);
|
||||
showRate = config.getInt("config.ShowRate", showRate);
|
||||
hitPlayer = config.getBoolean("config.HitPlayer", hitPlayer);
|
||||
sendMessages = config.getBoolean("config.SendMessages", sendMessages);
|
||||
lighting = config.getBoolean("config.Lighting", lighting);
|
||||
destroyTorches = config.getBoolean("config.DestroyTorches", destroyTorches);
|
||||
destroyTorchesRadius = config.getInt("config.DestroyTorchesRadius", destroyTorchesRadius);
|
||||
useWorlds = config.getStringList("config.Worlds");
|
||||
totemExplodes = config.getBoolean("config.TotemExplodes", totemExplodes);
|
||||
buildStuff = config.getBoolean("config.BuildStuff", buildStuff);
|
||||
placeSigns = config.getBoolean("config.PlaceSigns", placeSigns);
|
||||
useTotem = config.getBoolean("config.UseTotem", useTotem);
|
||||
writeBooks = config.getBoolean("config.WriteBooks", writeBooks);
|
||||
killable = config.getBoolean("config.Killable", killable);
|
||||
usePotionEffects = config.getBoolean("config.UsePotionEffects", usePotionEffects);
|
||||
caveChance = config.getInt("config.CaveChance", caveChance);
|
||||
bookChance = config.getInt("config.BookChance", bookChance);
|
||||
signChance = config.getInt("config.SignChance", signChance);
|
||||
deathMessage = config.getString("config.DeathMessage", deathMessage);
|
||||
useMessages = config.getStringList("config.Messages");
|
||||
useSignMessages = config.getStringList("config.SignMessages");
|
||||
useBookMessages = config.getStringList("config.BookMessages");
|
||||
buildPyramids = config.getBoolean("config.BuildPyramids", buildPyramids);
|
||||
useGraveyardWorld = config.getBoolean("config.UseGraveyardWorld", useGraveyardWorld);
|
||||
buryPlayers = config.getBoolean("config.BuryPlayers", buryPlayers);
|
||||
spawnWolves = config.getBoolean("config.SpawnWolves", spawnWolves);
|
||||
spawnBats = config.getBoolean("config.SpawnBats", spawnBats);
|
||||
buildInterval = config.getInt("config.BuildInterval", buildInterval);
|
||||
herobrineHP = config.getInt("config.HerobrineHP", herobrineHP);
|
||||
attackCreative = config.getBoolean("config.AttackCreative", attackCreative);
|
||||
attackOP = config.getBoolean("config.AttackOP", attackOP);
|
||||
securedAreaBuild = config.getBoolean("config.SecuredArea.Build", securedAreaBuild);
|
||||
securedAreaAttack = config.getBoolean("config.SecuredArea.Attack", securedAreaAttack);
|
||||
securedAreaHaunt = config.getBoolean("config.SecuredArea.Haunt", securedAreaHaunt);
|
||||
securedAreaSigns = config.getBoolean("config.SecuredArea.Signs", securedAreaSigns);
|
||||
securedAreaBooks = config.getBoolean("config.SecuredArea.Books", securedAreaBooks);
|
||||
useHeads = config.getBoolean("config.UseHeads", useHeads);
|
||||
useNPCGuardian = config.getBoolean("config.UseNPC.Guardian", useNPCGuardian);
|
||||
useNPCWarrior = config.getBoolean("config.UseNPC.Warrior", useNPCWarrior);
|
||||
useNPCDemon = config.getBoolean("config.UseNPC.Demon", useNPCDemon);
|
||||
itemInHand = new CustomID(config.getString("config.ItemInHand"));
|
||||
explosions = config.getBoolean("config.Explosions", explosions);
|
||||
burn = config.getBoolean("config.Burn", burn);
|
||||
curse = config.getBoolean("config.Curse", curse);
|
||||
maxBooks = config.getInt("config.Limit.Books", maxBooks);
|
||||
maxSigns = config.getInt("config.Limit.Signs", maxSigns);
|
||||
maxHeads = config.getInt("config.Limit.Heads", maxHeads);
|
||||
useIgnorePermission = config.getBoolean("config.UseIgnorePermission", useIgnorePermission);
|
||||
useSound = config.getBoolean("config.UseHauntSound", useSound);
|
||||
HerobrineAI.HerobrineMaxHP = herobrineHP;
|
||||
HerobrineAI.getPluginCore().getAICore().stopMAIN();
|
||||
HerobrineAI.getPluginCore().getAICore().startMAIN();
|
||||
HerobrineAI.getPluginCore().getAICore().stopBD();
|
||||
HerobrineAI.getPluginCore().getAICore().tartBD();
|
||||
HerobrineAI.getPluginCore().getAICore().stopRC();
|
||||
HerobrineAI.getPluginCore().getAICore().startRC();
|
||||
HerobrineAI.availableWorld = false;
|
||||
HerobrineAI.getPluginCore().getAICore().getResetLimits().updateFromConfig();
|
||||
if (HerobrineAI.herobrineNPC != null) {
|
||||
HerobrineAI.herobrineNPC.setItemInHand(itemInHand.getItemStack());
|
||||
}
|
||||
}
|
||||
public void Startup()
|
||||
{
|
||||
new File("plugins"+File.separator+"HerobrineAI").mkdirs();
|
||||
if (!this.configF.exists()) {
|
||||
try
|
||||
{
|
||||
this.configF.createNewFile();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
this.config = new YamlConfiguration();
|
||||
if (!this.npcF.exists()) {
|
||||
try
|
||||
{
|
||||
this.npcF.createNewFile();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
this.npc = new YamlConfiguration();
|
||||
try
|
||||
{
|
||||
this.config.load(this.configF);
|
||||
this.npc.load(this.npcF);
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (InvalidConfigurationException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (!this.npc.contains("npc.Guardian"))
|
||||
{
|
||||
this.npc.set("npc.Guardian.SpawnCount", Integer.valueOf(1));
|
||||
this.npc.set("npc.Guardian.HP", Integer.valueOf(40));
|
||||
this.npc.set("npc.Guardian.Speed", Double.valueOf(0.3D));
|
||||
this.npc.set("npc.Guardian.Drops.283.Chance", Integer.valueOf(40));
|
||||
this.npc.set("npc.Guardian.Drops.283.Count", Integer.valueOf(1));
|
||||
this.npc.set("npc.Guardian.Drops.286.Chance", Integer.valueOf(30));
|
||||
this.npc.set("npc.Guardian.Drops.286.Count", Integer.valueOf(1));
|
||||
this.npc.set("npc.Warrior.SpawnChance", Integer.valueOf(4));
|
||||
this.npc.set("npc.Warrior.HP", Integer.valueOf(40));
|
||||
this.npc.set("npc.Warrior.Speed", Double.valueOf(0.3D));
|
||||
this.npc.set("npc.Warrior.Drops.307.Chance", Integer.valueOf(25));
|
||||
this.npc.set("npc.Warrior.Drops.307.Count", Integer.valueOf(1));
|
||||
this.npc.set("npc.Warrior.Drops.306.Chance", Integer.valueOf(20));
|
||||
this.npc.set("npc.Warrior.Drops.306.Count", Integer.valueOf(1));
|
||||
this.npc.set("npc.Demon.SpawnChance", Integer.valueOf(4));
|
||||
this.npc.set("npc.Demon.HP", Integer.valueOf(40));
|
||||
this.npc.set("npc.Demon.Speed", Double.valueOf(0.3D));
|
||||
this.npc.set("npc.Demon.Drops.322.Chance", Integer.valueOf(40));
|
||||
this.npc.set("npc.Demon.Drops.322.Count", Integer.valueOf(1));
|
||||
this.npc.set("npc.Demon.Drops.397.Chance", Integer.valueOf(20));
|
||||
this.npc.set("npc.Demon.Drops.397.Count", Integer.valueOf(1));
|
||||
try
|
||||
{
|
||||
this.npc.save(this.npcF);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (!this.config.contains("config.ShowRate"))
|
||||
{
|
||||
this.useWorlds.add("world");
|
||||
this.useMessages.add("Even Notch can´t save you now!");
|
||||
this.useMessages.add("Fear me!");
|
||||
this.useMessages.add("Welcome to my world!");
|
||||
this.useMessages.add("I am your death!");
|
||||
this.useMessages.add("Grave awaits you!");
|
||||
this.useSignMessages.add("I´m watching.");
|
||||
this.useSignMessages.add("Death...");
|
||||
this.useSignMessages.add("Eyes in dark...");
|
||||
this.useBookMessages.add("White eyes in dark...");
|
||||
this.useBookMessages.add("... was last what I saw ...");
|
||||
this.useBookMessages.add("... before i was dead.");
|
||||
this.UseCustomItemsList.add("ItemExample");
|
||||
|
||||
public void addAllWorlds() {
|
||||
final ArrayList<String> allWorlds = new ArrayList<String>();
|
||||
final List<World> worlds_ = Bukkit.getWorlds();
|
||||
for (int i = 0; i <= (worlds_.size() - 1); ++i) {
|
||||
if (!worlds_.get(i).getName().equalsIgnoreCase("world_herobrine_graveyard")) {
|
||||
allWorlds.add(worlds_.get(i).getName());
|
||||
}
|
||||
}
|
||||
try {
|
||||
config.load(configF);
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e2) {
|
||||
e2.printStackTrace();
|
||||
} catch (InvalidConfigurationException e3) {
|
||||
e3.printStackTrace();
|
||||
}
|
||||
config.set("config.Worlds", allWorlds);
|
||||
try {
|
||||
config.save(configF);
|
||||
} catch (IOException e2) {
|
||||
e2.printStackTrace();
|
||||
}
|
||||
reload();
|
||||
}
|
||||
this.log.info("[HerobrineAI] Creating new Config ...");
|
||||
this.config.set("config.ShowInterval", Integer.valueOf(144000));
|
||||
this.config.set("config.ShowRate", Integer.valueOf(2));
|
||||
this.config.set("config.HitPlayer", Boolean.valueOf(true));
|
||||
this.config.set("config.SendMessages", Boolean.valueOf(true));
|
||||
this.config.set("config.Lighting", Boolean.valueOf(false));
|
||||
this.config.set("config.DestroyTorches", Boolean.valueOf(true));
|
||||
this.config.set("config.DestroyTorchesRadius", Integer.valueOf(5));
|
||||
this.config.set("config.Worlds", this.useWorlds);
|
||||
this.config.set("config.TotemExplodes", Boolean.valueOf(true));
|
||||
this.config.set("config.OnlyWalkingMode", Boolean.valueOf(false));
|
||||
this.config.set("config.BuildStuff", Boolean.valueOf(true));
|
||||
this.config.set("config.PlaceSigns", Boolean.valueOf(true));
|
||||
this.config.set("config.UseTotem", Boolean.valueOf(true));
|
||||
this.config.set("config.WriteBooks", Boolean.valueOf(true));
|
||||
this.config.set("config.Killable", Boolean.valueOf(false));
|
||||
this.config.set("config.UsePotionEffects", Boolean.valueOf(true));
|
||||
this.config.set("config.CaveChance", Integer.valueOf(40));
|
||||
this.config.set("config.BookChance", Integer.valueOf(5));
|
||||
this.config.set("config.SignChance", Integer.valueOf(5));
|
||||
this.config.set("config.DeathMessage", "You cannot kill me!");
|
||||
this.config.set("config.Messages", this.useMessages);
|
||||
this.config.set("config.SignMessages", this.useSignMessages);
|
||||
this.config.set("config.BookMessages", this.useBookMessages);
|
||||
this.config.set("config.Drops.264.count", Integer.valueOf(1));
|
||||
this.config.set("config.Drops.264.chance", Integer.valueOf(20));
|
||||
this.config.set("config.BuildPyramids", Boolean.valueOf(true));
|
||||
this.config.set("config.UseGraveyardWorld", Boolean.valueOf(true));
|
||||
this.config.set("config.BuryPlayers", Boolean.valueOf(true));
|
||||
this.config.set("config.SpawnWolves", Boolean.valueOf(true));
|
||||
this.config.set("config.SpawnBats", Boolean.valueOf(true));
|
||||
this.config.set("config.UseWalkingMode", Boolean.valueOf(true));
|
||||
this.config.set("config.WalkingModeRadius.X", Integer.valueOf(1000));
|
||||
this.config.set("config.WalkingModeRadius.Z", Integer.valueOf(1000));
|
||||
this.config.set("config.WalkingModeRadius.FromX", Integer.valueOf(0));
|
||||
this.config.set("config.WalkingModeRadius.FromZ", Integer.valueOf(0));
|
||||
this.config.set("config.BuildInterval", Integer.valueOf(72000));
|
||||
this.config.set("config.BuildTemples", Boolean.valueOf(true));
|
||||
this.config.set("config.UseArtifacts.Bow", Boolean.valueOf(true));
|
||||
this.config.set("config.UseArtifacts.Sword", Boolean.valueOf(true));
|
||||
this.config.set("config.UseArtifacts.Apple", Boolean.valueOf(true));
|
||||
this.config.set("config.HerobrineHP", Integer.valueOf(300));
|
||||
this.config.set("config.AttackCreative", Boolean.valueOf(true));
|
||||
this.config.set("config.AttackOP", Boolean.valueOf(true));
|
||||
this.config.set("config.SecuredArea.Build", Boolean.valueOf(true));
|
||||
this.config.set("config.SecuredArea.Attack", Boolean.valueOf(true));
|
||||
this.config.set("config.SecuredArea.Haunt", Boolean.valueOf(true));
|
||||
this.config.set("config.SecuredArea.Signs", Boolean.valueOf(true));
|
||||
this.config.set("config.SecuredArea.Books", Boolean.valueOf(true));
|
||||
this.config.set("config.UseHeads", Boolean.valueOf(true));
|
||||
this.config.set("config.UseCustomItems", Boolean.valueOf(false));
|
||||
this.config.set("config.CustomItemsList", this.UseCustomItemsList);
|
||||
this.config.set("config.UseAncientSword", Boolean.valueOf(true));
|
||||
this.config.set("config.UseNPC.Guardian", Boolean.valueOf(true));
|
||||
this.config.set("config.UseNPC.Warrior", Boolean.valueOf(true));
|
||||
this.config.set("config.UseNPC.Demon", Boolean.valueOf(true));
|
||||
this.config.set("config.ItemInHand", "0");
|
||||
this.config.set("config.Explosions", Boolean.valueOf(true));
|
||||
this.config.set("config.Burn", Boolean.valueOf(true));
|
||||
this.config.set("config.Curse", Boolean.valueOf(true));
|
||||
this.config.set("config.Limit.Books", Integer.valueOf(1));
|
||||
this.config.set("config.Limit.Signs", Integer.valueOf(1));
|
||||
this.config.set("config.Limit.Heads", Integer.valueOf(1));
|
||||
this.config.set("config.UseIgnorePermission", Boolean.valueOf(false));
|
||||
this.config.set("config.Name", "Herobrine");
|
||||
this.config.set("config.UseHauntSound", Boolean.valueOf(true));
|
||||
this.config.set("config.HerobrineUUID", "f84c6a79-0a4e-45e0-879b-cd49ebd4c4e2");
|
||||
try
|
||||
{
|
||||
this.config.save(this.configF);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean hasUpdated = false;
|
||||
if (!this.config.contains("config.Worlds"))
|
||||
{
|
||||
hasUpdated = true;
|
||||
this.log.info("[HerobrineAI] Updating old config...");
|
||||
this.config.set("config.Worlds", this.useWorlds);
|
||||
}
|
||||
if (!this.config.contains("config.TotemExplodes"))
|
||||
{
|
||||
if (!hasUpdated) {
|
||||
this.log.info("[HerobrineAI] Updating old config...");
|
||||
}
|
||||
hasUpdated = true;
|
||||
this.config.set("config.TotemExplodes", Boolean.valueOf(true));
|
||||
}
|
||||
if (!this.config.contains("config.OnlyWalkingMode"))
|
||||
{
|
||||
if (!hasUpdated)
|
||||
{
|
||||
hasUpdated = true;
|
||||
this.log.info("[HerobrineAI] Updating old config...");
|
||||
}
|
||||
this.config.set("config.OnlyWalkingMode", Boolean.valueOf(false));
|
||||
}
|
||||
if (!this.config.contains("config.BuildStuff"))
|
||||
{
|
||||
if (!hasUpdated) {
|
||||
this.log.info("[HerobrineAI] Updating old config...");
|
||||
}
|
||||
hasUpdated = true;
|
||||
|
||||
this.useMessages.add("Even Notch can´t save you now!");
|
||||
this.useMessages.add("Fear me!");
|
||||
this.useMessages.add("Welcome to my world!");
|
||||
this.useMessages.add("I am your death!");
|
||||
this.useMessages.add("Grave awaits you!");
|
||||
this.useSignMessages.add("I´m watching.");
|
||||
this.useSignMessages.add("Death...");
|
||||
this.useSignMessages.add("Eyes in dark...");
|
||||
this.useBookMessages.add("White eyes in dark...");
|
||||
this.useBookMessages.add("... was last what I saw ...");
|
||||
this.useBookMessages.add("... before i was dead.");
|
||||
|
||||
this.config.set("config.BuildStuff", Boolean.valueOf(true));
|
||||
this.config.set("config.PlaceSigns", Boolean.valueOf(true));
|
||||
this.config.set("config.UseTotem", Boolean.valueOf(true));
|
||||
this.config.set("config.WriteBooks", Boolean.valueOf(true));
|
||||
this.config.set("config.Killable", Boolean.valueOf(false));
|
||||
this.config.set("config.Messages", this.useMessages);
|
||||
this.config.set("config.SignMessages", this.useSignMessages);
|
||||
this.config.set("config.BookMessages", this.useBookMessages);
|
||||
this.config.set("config.Drops.264.count", Integer.valueOf(1));
|
||||
this.config.set("config.Drops.264.chance", Integer.valueOf(20));
|
||||
}
|
||||
if (!this.config.contains("config.UsePotionEffects"))
|
||||
{
|
||||
if (!hasUpdated) {
|
||||
this.log.info("[HerobrineAI] Updating old config...");
|
||||
}
|
||||
hasUpdated = true;
|
||||
this.config.set("config.UsePotionEffects", Boolean.valueOf(true));
|
||||
this.config.set("config.CaveChance", Integer.valueOf(40));
|
||||
this.config.set("config.BookChance", Integer.valueOf(5));
|
||||
this.config.set("config.SignChance", Integer.valueOf(5));
|
||||
}
|
||||
if (!this.config.contains("config.DeathMessage"))
|
||||
{
|
||||
if (!hasUpdated) {
|
||||
this.log.info("[HerobrineAI] Updating old config...");
|
||||
}
|
||||
hasUpdated = true;
|
||||
this.config.set("config.DeathMessage", "You cannot kill me!");
|
||||
}
|
||||
if (!this.config.contains("config.BuildPyramids"))
|
||||
{
|
||||
if (!hasUpdated) {
|
||||
this.log.info("[HerobrineAI] Updating old config...");
|
||||
}
|
||||
hasUpdated = true;
|
||||
this.config.set("config.BuildPyramids", Boolean.valueOf(true));
|
||||
}
|
||||
if (!this.config.contains("config.UseGraveyardWorld"))
|
||||
{
|
||||
if (!hasUpdated) {
|
||||
this.log.info("[HerobrineAI] Updating old config...");
|
||||
}
|
||||
hasUpdated = true;
|
||||
this.config.set("config.UseGraveyardWorld", Boolean.valueOf(true));
|
||||
this.config.set("config.BuryPlayers", Boolean.valueOf(true));
|
||||
this.config.set("config.SpawnWolves", Boolean.valueOf(true));
|
||||
this.config.set("config.SpawnBats", Boolean.valueOf(true));
|
||||
if (this.config.contains("config.UsePoitonEffects")) {
|
||||
this.config.set("config.UsePoitonEffects", null);
|
||||
}
|
||||
}
|
||||
if (!this.config.contains("config.DeathMessage"))
|
||||
{
|
||||
if (!hasUpdated) {
|
||||
this.log.info("[HerobrineAI] Updating old config...");
|
||||
}
|
||||
hasUpdated = true;
|
||||
this.config.set("config.DeathMessage", "You cannot kill me!");
|
||||
}
|
||||
if (!this.config.contains("config.UseWalkingMode"))
|
||||
{
|
||||
if (!hasUpdated) {
|
||||
this.log.info("[HerobrineAI] Updating old config...");
|
||||
}
|
||||
hasUpdated = true;
|
||||
this.config.set("config.UseWalkingMode", Boolean.valueOf(true));
|
||||
this.config.set("config.WalkingModeRadius.X", Integer.valueOf(1000));
|
||||
this.config.set("config.WalkingModeRadius.Z", Integer.valueOf(1000));
|
||||
}
|
||||
if (!this.config.contains("config.BuildTemples"))
|
||||
{
|
||||
if (!hasUpdated) {
|
||||
this.log.info("[HerobrineAI] Updating old config...");
|
||||
}
|
||||
hasUpdated = true;
|
||||
this.config.set("config.BuildInterval", Integer.valueOf(45000));
|
||||
this.config.set("config.BuildTemples", Boolean.valueOf(true));
|
||||
this.config.set("config.UseArtifacts.Bow", Boolean.valueOf(true));
|
||||
this.config.set("config.UseArtifacts.Sword", Boolean.valueOf(true));
|
||||
this.config.set("config.UseArtifacts.Apple", Boolean.valueOf(true));
|
||||
this.config.set("config.HerobrineHP", Integer.valueOf(200));
|
||||
this.config.set("config.AttackCreative", Boolean.valueOf(true));
|
||||
this.config.set("config.AttackOP", Boolean.valueOf(true));
|
||||
this.config.set("config.SecuredArea.Build", Boolean.valueOf(true));
|
||||
this.config.set("config.SecuredArea.Attack", Boolean.valueOf(true));
|
||||
this.config.set("config.SecuredArea.Haunt", Boolean.valueOf(true));
|
||||
this.config.set("config.SecuredArea.Signs", Boolean.valueOf(true));
|
||||
this.config.set("config.SecuredArea.Books", Boolean.valueOf(true));
|
||||
}
|
||||
if (!this.config.contains("config.UseHeads"))
|
||||
{
|
||||
if (!hasUpdated) {
|
||||
this.log.info("[HerobrineAI] Updating old config...");
|
||||
}
|
||||
hasUpdated = true;
|
||||
this.config.set("config.UseHeads", Boolean.valueOf(true));
|
||||
}
|
||||
if (!this.config.contains("config.UseCustomItems"))
|
||||
{
|
||||
if (!hasUpdated) {
|
||||
this.log.info("[HerobrineAI] Updating old config...");
|
||||
}
|
||||
hasUpdated = true;
|
||||
this.UseCustomItemsList.add("ItemExample");
|
||||
this.config.set("config.UseCustomItems", Boolean.valueOf(false));
|
||||
this.config.set("config.CustomItemsList", this.UseCustomItemsList);
|
||||
}
|
||||
if (!this.config.contains("config.UseAncientSword"))
|
||||
{
|
||||
if (!hasUpdated) {
|
||||
this.log.info("[HerobrineAI] Updating old config...");
|
||||
}
|
||||
hasUpdated = true;
|
||||
|
||||
this.config.set("config.UseAncientSword", Boolean.valueOf(true));
|
||||
this.config.set("config.UseNPC.Guardian", Boolean.valueOf(true));
|
||||
this.config.set("config.UseNPC.Warrior", Boolean.valueOf(true));
|
||||
this.config.set("config.ItemInHand", "0");
|
||||
this.config.set("config.WalkingModeRadius.FromX", Integer.valueOf(0));
|
||||
this.config.set("config.WalkingModeRadius.FromZ", Integer.valueOf(0));
|
||||
}
|
||||
if (!this.config.contains("config.Explosions"))
|
||||
{
|
||||
if (!hasUpdated) {
|
||||
this.log.info("[HerobrineAI] Updating old config...");
|
||||
}
|
||||
hasUpdated = true;
|
||||
|
||||
this.config.set("config.Explosions", Boolean.valueOf(true));
|
||||
}
|
||||
if (!this.config.contains("config.UseNPC.Demon"))
|
||||
{
|
||||
if (!hasUpdated) {
|
||||
this.log.info("[HerobrineAI] Updating old config...");
|
||||
}
|
||||
hasUpdated = true;
|
||||
|
||||
this.config.set("config.UseNPC.Demon", Boolean.valueOf(true));
|
||||
this.config.set("config.Burn", Boolean.valueOf(true));
|
||||
this.config.set("config.Curse", Boolean.valueOf(true));
|
||||
}
|
||||
if (!this.npc.contains("npc.Warrior.Speed"))
|
||||
{
|
||||
if (!hasUpdated) {
|
||||
this.log.info("[HerobrineAI] Updating old config...");
|
||||
}
|
||||
hasUpdated = true;
|
||||
|
||||
this.npc.set("npc.Warrior.Speed", Double.valueOf(0.3D));
|
||||
this.npc.set("npc.Guardian.Speed", Double.valueOf(0.3D));
|
||||
this.npc.set("npc.Demon.Speed", Double.valueOf(0.3D));
|
||||
}
|
||||
if (!this.config.contains("config.Limit.Books"))
|
||||
{
|
||||
if (!hasUpdated) {
|
||||
this.log.info("[HerobrineAI] Updating old config...");
|
||||
}
|
||||
hasUpdated = true;
|
||||
|
||||
this.config.set("config.Limit.Books", Integer.valueOf(1));
|
||||
this.config.set("config.Limit.Signs", Integer.valueOf(1));
|
||||
this.config.set("config.Limit.Heads", Integer.valueOf(1));
|
||||
}
|
||||
if (!this.config.contains("config.UseIgnorePermission"))
|
||||
{
|
||||
if (!hasUpdated) {
|
||||
this.log.info("[HerobrineAI] Updating old config...");
|
||||
}
|
||||
hasUpdated = true;
|
||||
|
||||
this.config.set("config.UseIgnorePermission", Boolean.valueOf(false));
|
||||
}
|
||||
if (!this.config.contains("config.Name"))
|
||||
{
|
||||
if (!hasUpdated) {
|
||||
this.log.info("[HerobrineAI] Updating old config...");
|
||||
}
|
||||
hasUpdated = true;
|
||||
|
||||
this.config.set("config.Name", "Herobrine");
|
||||
}
|
||||
if (!this.config.contains("config.UseHauntSound"))
|
||||
{
|
||||
if (!hasUpdated) {
|
||||
this.log.info("[HerobrineAI] Updating old config...");
|
||||
}
|
||||
hasUpdated = true;
|
||||
|
||||
this.config.set("config.UseHauntSound", Boolean.valueOf(true));
|
||||
}
|
||||
if (!this.config.contains("config.HerobrineUUID"))
|
||||
{
|
||||
if (!hasUpdated) {
|
||||
this.log.info("[HerobrineAI] Updating old config...");
|
||||
}
|
||||
hasUpdated = true;
|
||||
|
||||
this.config.set("config.HerobrineUUID", "f84c6a79-0a4e-45e0-879b-cd49ebd4c4e2");
|
||||
}
|
||||
if (hasUpdated)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.config.save(this.configF);
|
||||
this.npc.save(this.npcF);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
this.log.info("[HerobrineAI] Config was updated to v" + HerobrineAI.getPluginCore() + "!");
|
||||
}
|
||||
Reload();
|
||||
}
|
||||
}
|
||||
|
||||
public void Reload()
|
||||
{
|
||||
try
|
||||
{
|
||||
this.config.load(this.configF);
|
||||
this.npc.load(this.npcF);
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (InvalidConfigurationException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
this.ShowInterval = this.config.getInt("config.ShowInterval");
|
||||
this.ShowRate = this.config.getInt("config.ShowRate");
|
||||
this.HitPlayer = this.config.getBoolean("config.HitPlayer");
|
||||
this.SendMessages = this.config.getBoolean("config.SendMessages");
|
||||
this.Lighting = this.config.getBoolean("config.Lighting");
|
||||
this.DestroyTorches = this.config.getBoolean("config.DestroyTorches");
|
||||
this.DestroyTorchesRadius = this.config.getInt("config.DestroyTorchesRadius");
|
||||
this.useWorlds = this.config.getStringList("config.Worlds");
|
||||
this.TotemExplodes = this.config.getBoolean("config.TotemExplodes");
|
||||
this.OnlyWalkingMode = this.config.getBoolean("config.OnlyWalkingMode");
|
||||
this.BuildStuff = this.config.getBoolean("config.BuildStuff");
|
||||
this.PlaceSigns = this.config.getBoolean("config.PlaceSigns");
|
||||
this.UseTotem = this.config.getBoolean("config.UseTotem");
|
||||
this.WriteBooks = this.config.getBoolean("config.WriteBooks");
|
||||
this.Killable = this.config.getBoolean("config.Killable");
|
||||
this.UsePotionEffects = this.config.getBoolean("config.UsePotionEffects");
|
||||
this.CaveChance = this.config.getInt("config.CaveChance");
|
||||
this.BookChance = this.config.getInt("config.BookChance");
|
||||
this.SignChance = this.config.getInt("config.SignChance");
|
||||
this.DeathMessage = this.config.getString("config.DeathMessage");
|
||||
this.useMessages = this.config.getStringList("config.Messages");
|
||||
this.useSignMessages = this.config.getStringList("config.SignMessages");
|
||||
this.useBookMessages = this.config.getStringList("config.BookMessages");
|
||||
this.BuildPyramids = this.config.getBoolean("config.BuildPyramids");
|
||||
this.UseGraveyardWorld = this.config.getBoolean("config.UseGraveyardWorld");
|
||||
this.BuryPlayers = this.config.getBoolean("config.BuryPlayers");
|
||||
this.SpawnWolves = this.config.getBoolean("config.SpawnWolves");
|
||||
this.SpawnBats = this.config.getBoolean("config.SpawnBats");
|
||||
this.UseWalkingMode = this.config.getBoolean("config.UseWalkingMode");
|
||||
this.WalkingModeXRadius = this.config.getInt("config.WalkingModeRadius.X");
|
||||
this.WalkingModeZRadius = this.config.getInt("config.WalkingModeRadius.Z");
|
||||
this.WalkingModeFromXRadius = this.config.getInt("config.WalkingModeRadius.FromX");
|
||||
this.WalkingModeFromZRadius = this.config.getInt("config.WalkingModeRadius.FromZ");
|
||||
this.BuildInterval = this.config.getInt("config.BuildInterval");
|
||||
this.BuildTemples = this.config.getBoolean("config.BuildTemples");
|
||||
this.UseArtifactBow = this.config.getBoolean("config.UseArtifacts.Bow");
|
||||
this.UseArtifactSword = this.config.getBoolean("config.UseArtifacts.Sword");
|
||||
this.UseArtifactApple = this.config.getBoolean("config.UseArtifacts.Apple");
|
||||
this.HerobrineHP = this.config.getInt("config.HerobrineHP");
|
||||
this.AttackCreative = this.config.getBoolean("config.AttackCreative");
|
||||
this.AttackOP = this.config.getBoolean("config.AttackOP");
|
||||
this.SecuredArea_Build = this.config.getBoolean("config.SecuredArea.Build");
|
||||
this.SecuredArea_Attack = this.config.getBoolean("config.SecuredArea.Attack");
|
||||
this.SecuredArea_Haunt = this.config.getBoolean("config.SecuredArea.Haunt");
|
||||
this.SecuredArea_Signs = this.config.getBoolean("config.SecuredArea.Signs");
|
||||
this.SecuredArea_Books = this.config.getBoolean("config.SecuredArea.Books");
|
||||
this.UseHeads = this.config.getBoolean("config.UseHeads");
|
||||
this.UseCustomItems = this.config.getBoolean("config.UseCustomItems");
|
||||
this.UseCustomItemsList = this.config.getStringList("config.CustomItemsList");
|
||||
this.UseAncientSword = this.config.getBoolean("config.UseAncientSword");
|
||||
this.UseNPC_Guardian = this.config.getBoolean("config.UseNPC.Guardian");
|
||||
this.UseNPC_Warrior = this.config.getBoolean("config.UseNPC.Warrior");
|
||||
this.UseNPC_Demon = this.config.getBoolean("config.UseNPC.Demon");
|
||||
this.ItemInHand = new CustomID(this.config.getString("config.ItemInHand"));
|
||||
this.Explosions = this.config.getBoolean("config.Explosions");
|
||||
this.Burn = this.config.getBoolean("config.Burn");
|
||||
this.Curse = this.config.getBoolean("config.Curse");
|
||||
this.maxBooks = this.config.getInt("config.Limit.Books");
|
||||
this.maxSigns = this.config.getInt("config.Limit.Signs");
|
||||
this.maxHeads = this.config.getInt("config.Limit.Heads");
|
||||
this.UseIgnorePermission = this.config.getBoolean("config.UseIgnorePermission");
|
||||
this.HerobrineName = this.config.getString("config.Name");
|
||||
this.UseSound = this.config.getBoolean("config.UseHauntSound");
|
||||
HerobrineAI.HerobrineMaxHP = this.HerobrineHP;
|
||||
HerobrineAI.getPluginCore().getAICore().stopMAIN();
|
||||
HerobrineAI.getPluginCore().getAICore().startMAIN();
|
||||
HerobrineAI.getPluginCore().getAICore().stopBD();
|
||||
HerobrineAI.getPluginCore().getAICore().stopRC();
|
||||
HerobrineAI.getPluginCore().getAICore().startRC();
|
||||
HerobrineAI.availableWorld = false;
|
||||
HerobrineAI.getPluginCore().getAICore().getResetLimits().updateFromConfig();
|
||||
if (HerobrineAI.herobrineNPC != null) {
|
||||
HerobrineAI.herobrineNPC.setItemInHand(this.ItemInHand.getItemStack());
|
||||
}
|
||||
if (this.isStartupDone)
|
||||
{
|
||||
HerobrineAI.getPluginCore().removeHerobrine();
|
||||
HerobrineAI.getPluginCore().spawnHerobrine(new Location((World)Bukkit.getWorlds().get(0), 0.0D, -20.0D, 0.0D));
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(HerobrineAI.getPluginCore(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
for (int i = 0; i <= ConfigDB.this.useWorlds.size() - 1; i++) {
|
||||
if (Bukkit.getServer().getWorlds().contains(Bukkit.getServer().getWorld((String)ConfigDB.this.useWorlds.get(i)))) {
|
||||
HerobrineAI.availableWorld = true;
|
||||
}
|
||||
}
|
||||
if (!HerobrineAI.availableWorld)
|
||||
{
|
||||
ConfigDB.this.log.warning("**********************************************************");
|
||||
ConfigDB.this.log.warning("[HerobrineAI] There are no available worlds for Herobrine!");
|
||||
ConfigDB.this.log.warning("**********************************************************");
|
||||
}
|
||||
else
|
||||
{
|
||||
ConfigDB.this.log.info("**********************************************************");
|
||||
ConfigDB.this.log.info("[HerobrineAI] No problems detected.");
|
||||
ConfigDB.this.log.info("**********************************************************");
|
||||
}
|
||||
}
|
||||
}, 1L);
|
||||
}
|
||||
this.isStartupDone = true;
|
||||
}
|
||||
|
||||
public void addAllWorlds()
|
||||
{
|
||||
ArrayList<String> allWorlds = new ArrayList<String>();
|
||||
List<World> worlds_ = Bukkit.getWorlds();
|
||||
for (int i = 0; i <= worlds_.size() - 1; i++) {
|
||||
if (!((World)worlds_.get(i)).getName().equalsIgnoreCase("world_herobrineai_graveyard")) {
|
||||
allWorlds.add(((World)worlds_.get(i)).getName());
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
this.config.load(this.configF);
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (InvalidConfigurationException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
this.config.set("config.Worlds", allWorlds);
|
||||
try
|
||||
{
|
||||
this.config.save(this.configF);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
Reload();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user