Reload Herobrine world when reload command; Added startDB to reload

method.
This commit is contained in:
FabioZumbi12 2015-03-06 02:58:07 -03:00
parent c9a3c31e24
commit 919d78a04d
2 changed files with 46 additions and 18 deletions

View File

@ -155,12 +155,12 @@ public class AICore {
if (AICore.PlayerTarget.isOnline() && AICore.isTarget && !AICore.PlayerTarget.isDead()) {
final Object[] data = { AICore.PlayerTarget };
final int chance = new Random().nextInt(100);
if (chance <= 5) {
if (chance <= 10) {
if (HerobrineAI.getPluginCore().getConfigDB().UseGraveyardWorld) {
AICore.log.info("[Herobrine] Teleporting " + PlayerTarget.getDisplayName() + " to Herobrine's Graveyard.");
getCore(Core.CoreType.GRAVEYARD).runCore(data);
}
} else if (chance <= 20) {
} else if (chance <= 25) {
getCore(Core.CoreType.ATTACK).runCore(data);
} else {
getCore(Core.CoreType.HAUNT).runCore(data);
@ -334,7 +334,7 @@ public class AICore {
@Override
public void run() {
AICore.this.startMAIN();
AICore.this.tartBD();
AICore.this.startBD();
AICore.this.startRC();
}
}, 5L);
@ -351,7 +351,7 @@ public class AICore {
return item;
}
public void tartBD() {
public void startBD() {
BuildINT = true;
BD_INT = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(AICore.plugin, new Runnable() {
@Override

View File

@ -10,8 +10,11 @@ import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.WorldType;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.jakub1221.herobrineai.AI.extensions.GraveyardWorld;
import org.jakub1221.herobrineai.misc.CustomID;
public class ConfigDB
@ -82,6 +85,7 @@ public class ConfigDB
public boolean UseIgnorePermission = true;
public String HerobrineName = "Herobrine";
public String HerobrineWorldName = "world_herobrine_graveyard";
public String HerobrineUUID = "f84c6a79-0a4e-45e0-879b-cd49ebd4c4e2";
public boolean UseSound = true;
private boolean isStartupDone = false;
@ -249,6 +253,7 @@ public class ConfigDB
this.config.set("config.UseIgnorePermission", Boolean.valueOf(false));
this.config.set("config.Name", "Herobrine");
this.config.set("config.HerobrineWorldName", "world_herobrine_graveyard");
this.config.set("config.HerobrineUUID", "f84c6a79-0a4e-45e0-879b-cd49ebd4c4e2");
this.config.set("config.UseHauntSound", Boolean.valueOf(true));
try
{
@ -492,6 +497,15 @@ public class ConfigDB
this.config.set("config.Name", "Herobrine");
}
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 (!this.config.contains("config.UseHauntSound"))
{
if (!hasUpdated) {
@ -518,10 +532,13 @@ public class ConfigDB
}
}
public void Reload()
{
try
{
public void Reload() {
HerobrineAI.getPluginCore().removeHerobrine();
World world = Bukkit.getServer().getWorld(this.HerobrineWorldName);
if (this.UseGraveyardWorld && world != null) {
Bukkit.getServer().unloadWorld(world, true);
}
try {
this.config.load(this.configF);
this.npc.load(this.npcF);
}
@ -600,11 +617,13 @@ public class ConfigDB
this.UseIgnorePermission = this.config.getBoolean("config.UseIgnorePermission");
this.HerobrineName = this.config.getString("config.Name");
this.HerobrineWorldName = this.config.getString("config.HerobrineWorldName");
this.HerobrineUUID = this.config.getString("config.HerobrineUUID");
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().startBD();
HerobrineAI.getPluginCore().getAICore().stopRC();
HerobrineAI.getPluginCore().getAICore().startRC();
HerobrineAI.availableWorld = false;
@ -612,9 +631,18 @@ public class ConfigDB
if (HerobrineAI.herobrineNPC != null) {
HerobrineAI.herobrineNPC.setItemInHand(this.ItemInHand.getItemStack());
}
if (this.isStartupDone)
{
HerobrineAI.getPluginCore().removeHerobrine();
if (this.isStartupDone) {
world = Bukkit.getServer().getWorld(this.HerobrineWorldName);
if (this.UseGraveyardWorld && world == null) {
HerobrineAI.log.info("[Herobrine] Reloading Herobrine Graveyard world");
final WorldCreator wc = new WorldCreator(this.HerobrineWorldName);
wc.generateStructures(false);
final WorldType type = WorldType.FLAT;
wc.type(type);
wc.createWorld();
GraveyardWorld.create();
}
HerobrineAI.getPluginCore().spawnHerobrine(new Location((World)Bukkit.getWorlds().get(0), 0.0D, -20.0D, 0.0D));
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(HerobrineAI.getPluginCore(), new Runnable()
{