Reload Herobrine world when reload command; Added startDB to reload
method.
This commit is contained in:
parent
c9a3c31e24
commit
919d78a04d
@ -45,7 +45,7 @@ public class AICore {
|
|||||||
private ArrayList<Core> allCores = new ArrayList<Core>(Arrays.asList(new Core[] {
|
private ArrayList<Core> allCores = new ArrayList<Core>(Arrays.asList(new Core[] {
|
||||||
new Attack(), new Book(), new BuildStuff(), new BuryPlayer(), new DestroyTorches(), new Graveyard(),
|
new Attack(), new Book(), new BuildStuff(), new BuryPlayer(), new DestroyTorches(), new Graveyard(),
|
||||||
new Haunt(), new Pyramid(), new Signs(), new SoundF(), new Totem(), new Heads(),
|
new Haunt(), new Pyramid(), new Signs(), new SoundF(), new Totem(), new Heads(),
|
||||||
new RandomSound(), new RandomExplosion(), new Burn(), new Curse(),new Temple()
|
new RandomSound(), new RandomExplosion(), new Burn(), new Curse(), new Temple()
|
||||||
}));
|
}));
|
||||||
private Core.CoreType currentCore = Core.CoreType.ANY;
|
private Core.CoreType currentCore = Core.CoreType.ANY;
|
||||||
private ResetLimits resetLimits;
|
private ResetLimits resetLimits;
|
||||||
@ -155,12 +155,12 @@ public class AICore {
|
|||||||
if (AICore.PlayerTarget.isOnline() && AICore.isTarget && !AICore.PlayerTarget.isDead()) {
|
if (AICore.PlayerTarget.isOnline() && AICore.isTarget && !AICore.PlayerTarget.isDead()) {
|
||||||
final Object[] data = { AICore.PlayerTarget };
|
final Object[] data = { AICore.PlayerTarget };
|
||||||
final int chance = new Random().nextInt(100);
|
final int chance = new Random().nextInt(100);
|
||||||
if (chance <= 5) {
|
if (chance <= 10) {
|
||||||
if (HerobrineAI.getPluginCore().getConfigDB().UseGraveyardWorld) {
|
if (HerobrineAI.getPluginCore().getConfigDB().UseGraveyardWorld) {
|
||||||
AICore.log.info("[Herobrine] Teleporting " + PlayerTarget.getDisplayName() + " to Herobrine's Graveyard.");
|
AICore.log.info("[Herobrine] Teleporting " + PlayerTarget.getDisplayName() + " to Herobrine's Graveyard.");
|
||||||
getCore(Core.CoreType.GRAVEYARD).runCore(data);
|
getCore(Core.CoreType.GRAVEYARD).runCore(data);
|
||||||
}
|
}
|
||||||
} else if (chance <= 20) {
|
} else if (chance <= 25) {
|
||||||
getCore(Core.CoreType.ATTACK).runCore(data);
|
getCore(Core.CoreType.ATTACK).runCore(data);
|
||||||
} else {
|
} else {
|
||||||
getCore(Core.CoreType.HAUNT).runCore(data);
|
getCore(Core.CoreType.HAUNT).runCore(data);
|
||||||
@ -334,7 +334,7 @@ public class AICore {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
AICore.this.startMAIN();
|
AICore.this.startMAIN();
|
||||||
AICore.this.tartBD();
|
AICore.this.startBD();
|
||||||
AICore.this.startRC();
|
AICore.this.startRC();
|
||||||
}
|
}
|
||||||
}, 5L);
|
}, 5L);
|
||||||
@ -351,7 +351,7 @@ public class AICore {
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void tartBD() {
|
public void startBD() {
|
||||||
BuildINT = true;
|
BuildINT = true;
|
||||||
BD_INT = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(AICore.plugin, new Runnable() {
|
BD_INT = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(AICore.plugin, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -10,8 +10,11 @@ import java.util.logging.Logger;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.WorldCreator;
|
||||||
|
import org.bukkit.WorldType;
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.jakub1221.herobrineai.AI.extensions.GraveyardWorld;
|
||||||
import org.jakub1221.herobrineai.misc.CustomID;
|
import org.jakub1221.herobrineai.misc.CustomID;
|
||||||
|
|
||||||
public class ConfigDB
|
public class ConfigDB
|
||||||
@ -82,6 +85,7 @@ public class ConfigDB
|
|||||||
public boolean UseIgnorePermission = true;
|
public boolean UseIgnorePermission = true;
|
||||||
public String HerobrineName = "Herobrine";
|
public String HerobrineName = "Herobrine";
|
||||||
public String HerobrineWorldName = "world_herobrine_graveyard";
|
public String HerobrineWorldName = "world_herobrine_graveyard";
|
||||||
|
public String HerobrineUUID = "f84c6a79-0a4e-45e0-879b-cd49ebd4c4e2";
|
||||||
public boolean UseSound = true;
|
public boolean UseSound = true;
|
||||||
private boolean isStartupDone = false;
|
private boolean isStartupDone = false;
|
||||||
|
|
||||||
@ -249,6 +253,7 @@ public class ConfigDB
|
|||||||
this.config.set("config.UseIgnorePermission", Boolean.valueOf(false));
|
this.config.set("config.UseIgnorePermission", Boolean.valueOf(false));
|
||||||
this.config.set("config.Name", "Herobrine");
|
this.config.set("config.Name", "Herobrine");
|
||||||
this.config.set("config.HerobrineWorldName", "world_herobrine_graveyard");
|
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));
|
this.config.set("config.UseHauntSound", Boolean.valueOf(true));
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -492,6 +497,15 @@ public class ConfigDB
|
|||||||
|
|
||||||
this.config.set("config.Name", "Herobrine");
|
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 (!this.config.contains("config.UseHauntSound"))
|
||||||
{
|
{
|
||||||
if (!hasUpdated) {
|
if (!hasUpdated) {
|
||||||
@ -518,10 +532,13 @@ public class ConfigDB
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Reload()
|
public void Reload() {
|
||||||
{
|
HerobrineAI.getPluginCore().removeHerobrine();
|
||||||
try
|
World world = Bukkit.getServer().getWorld(this.HerobrineWorldName);
|
||||||
{
|
if (this.UseGraveyardWorld && world != null) {
|
||||||
|
Bukkit.getServer().unloadWorld(world, true);
|
||||||
|
}
|
||||||
|
try {
|
||||||
this.config.load(this.configF);
|
this.config.load(this.configF);
|
||||||
this.npc.load(this.npcF);
|
this.npc.load(this.npcF);
|
||||||
}
|
}
|
||||||
@ -600,11 +617,13 @@ public class ConfigDB
|
|||||||
this.UseIgnorePermission = this.config.getBoolean("config.UseIgnorePermission");
|
this.UseIgnorePermission = this.config.getBoolean("config.UseIgnorePermission");
|
||||||
this.HerobrineName = this.config.getString("config.Name");
|
this.HerobrineName = this.config.getString("config.Name");
|
||||||
this.HerobrineWorldName = this.config.getString("config.HerobrineWorldName");
|
this.HerobrineWorldName = this.config.getString("config.HerobrineWorldName");
|
||||||
|
this.HerobrineUUID = this.config.getString("config.HerobrineUUID");
|
||||||
this.UseSound = this.config.getBoolean("config.UseHauntSound");
|
this.UseSound = this.config.getBoolean("config.UseHauntSound");
|
||||||
HerobrineAI.HerobrineMaxHP = this.HerobrineHP;
|
HerobrineAI.HerobrineMaxHP = this.HerobrineHP;
|
||||||
HerobrineAI.getPluginCore().getAICore().stopMAIN();
|
HerobrineAI.getPluginCore().getAICore().stopMAIN();
|
||||||
HerobrineAI.getPluginCore().getAICore().startMAIN();
|
HerobrineAI.getPluginCore().getAICore().startMAIN();
|
||||||
HerobrineAI.getPluginCore().getAICore().stopBD();
|
HerobrineAI.getPluginCore().getAICore().stopBD();
|
||||||
|
HerobrineAI.getPluginCore().getAICore().startBD();
|
||||||
HerobrineAI.getPluginCore().getAICore().stopRC();
|
HerobrineAI.getPluginCore().getAICore().stopRC();
|
||||||
HerobrineAI.getPluginCore().getAICore().startRC();
|
HerobrineAI.getPluginCore().getAICore().startRC();
|
||||||
HerobrineAI.availableWorld = false;
|
HerobrineAI.availableWorld = false;
|
||||||
@ -612,9 +631,18 @@ public class ConfigDB
|
|||||||
if (HerobrineAI.herobrineNPC != null) {
|
if (HerobrineAI.herobrineNPC != null) {
|
||||||
HerobrineAI.herobrineNPC.setItemInHand(this.ItemInHand.getItemStack());
|
HerobrineAI.herobrineNPC.setItemInHand(this.ItemInHand.getItemStack());
|
||||||
}
|
}
|
||||||
if (this.isStartupDone)
|
if (this.isStartupDone) {
|
||||||
{
|
world = Bukkit.getServer().getWorld(this.HerobrineWorldName);
|
||||||
HerobrineAI.getPluginCore().removeHerobrine();
|
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));
|
HerobrineAI.getPluginCore().spawnHerobrine(new Location((World)Bukkit.getWorlds().get(0), 0.0D, -20.0D, 0.0D));
|
||||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(HerobrineAI.getPluginCore(), new Runnable()
|
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(HerobrineAI.getPluginCore(), new Runnable()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user