From e638588df30f31cbdb10ebc70a47af275b0d863d Mon Sep 17 00:00:00 2001 From: David Berdik Date: Thu, 14 Jan 2016 23:34:01 -0500 Subject: [PATCH] Added two new configuration options, "BuildPyramidOnChunkPercentage" and "BuildTempleOnChunkPercentage" that will allow server administrators to control the chance of a pyramid or temple spawning when a chunk is loaded --- src/net/theprogrammersworld/herobrine/ConfigDB.java | 9 +++++++++ .../herobrine/listeners/WorldListener.java | 7 +++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/net/theprogrammersworld/herobrine/ConfigDB.java b/src/net/theprogrammersworld/herobrine/ConfigDB.java index caf5360..96c2a3d 100644 --- a/src/net/theprogrammersworld/herobrine/ConfigDB.java +++ b/src/net/theprogrammersworld/herobrine/ConfigDB.java @@ -47,6 +47,7 @@ public class ConfigDB public List useSignMessages = new ArrayList(); public List useBookMessages = new ArrayList(); public boolean BuildPyramids = true; + public int BuildPyramidOnChunkPercentage = 5; public boolean UseGraveyardWorld = true; public boolean BuryPlayers = true; public boolean SpawnWolves = true; @@ -54,6 +55,7 @@ public class ConfigDB public int WalkingModeXRadius = 1000; public int WalkingModeZRadius = 1000; public boolean BuildTemples = true; + public int BuildTempleOnChunkPercentage = 5; public boolean UseArtifactBow = true; public boolean UseArtifactSword = true; public boolean UseArtifactApple = true; @@ -87,6 +89,7 @@ public class ConfigDB public boolean UseSound = true; public boolean ShowInTabList = false; public boolean CheckForUpdates = true; + private boolean isStartupDone = false; private String pluginVersionNumber = Bukkit.getServer().getPluginManager().getPlugin("Herobrine"). getDescription().getVersion(); @@ -223,6 +226,7 @@ public class ConfigDB 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.BuildPyramidOnChunkPercentage", Integer.valueOf(5)); this.config.set("config.UseGraveyardWorld", Boolean.valueOf(true)); this.config.set("config.BuryPlayers", Boolean.valueOf(true)); this.config.set("config.SpawnWolves", Boolean.valueOf(true)); @@ -231,6 +235,7 @@ public class ConfigDB this.config.set("config.WalkingModeRadius.Z", Integer.valueOf(1000)); this.config.set("config.BuildInterval", Integer.valueOf(72000)); this.config.set("config.BuildTemples", Boolean.valueOf(true)); + this.config.set("config.BuildTempleOnChunkPercentage", Integer.valueOf(5)); 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)); @@ -548,6 +553,8 @@ public class ConfigDB this.config.set("config.UseWalkingMode", null); this.config.set("config.WalkingModeRadius.FromX", null); this.config.set("config.WalkingModeRadius.FromZ", null); + this.config.set("config.BuildPyramidOnChunkPercentage", Integer.valueOf(5)); + this.config.set("config.BuildTempleOnChunkPercentage", Integer.valueOf(5)); } if (hasUpdated) { @@ -612,6 +619,7 @@ public class ConfigDB this.useSignMessages = this.config.getStringList("config.SignMessages"); this.useBookMessages = this.config.getStringList("config.BookMessages"); this.BuildPyramids = this.config.getBoolean("config.BuildPyramids"); + this.BuildPyramidOnChunkPercentage = this.config.getInt("config.BuildPyramidOnChunkPercentage"); this.UseGraveyardWorld = this.config.getBoolean("config.UseGraveyardWorld"); this.BuryPlayers = this.config.getBoolean("config.BuryPlayers"); this.SpawnWolves = this.config.getBoolean("config.SpawnWolves"); @@ -620,6 +628,7 @@ public class ConfigDB this.WalkingModeZRadius = this.config.getInt("config.WalkingModeRadius.Z"); this.BuildInterval = this.config.getInt("config.BuildInterval"); this.BuildTemples = this.config.getBoolean("config.BuildTemples"); + this.BuildTempleOnChunkPercentage = this.config.getInt("config.BuildTempleOnChunkPercentage"); this.UseArtifactBow = this.config.getBoolean("config.UseArtifacts.Bow"); this.UseArtifactSword = this.config.getBoolean("config.UseArtifacts.Sword"); this.UseArtifactApple = this.config.getBoolean("config.UseArtifacts.Apple"); diff --git a/src/net/theprogrammersworld/herobrine/listeners/WorldListener.java b/src/net/theprogrammersworld/herobrine/listeners/WorldListener.java index b2bff4a..a1b8804 100644 --- a/src/net/theprogrammersworld/herobrine/listeners/WorldListener.java +++ b/src/net/theprogrammersworld/herobrine/listeners/WorldListener.java @@ -18,11 +18,14 @@ public class WorldListener implements Listener { final World world = event.getWorld(); if (Herobrine.getPluginCore().getConfigDB().useWorlds.contains(world.getName())) { - if (Herobrine.getPluginCore().getConfigDB().BuildPyramids && (new Random().nextInt(15) == 1)) { + int pyramidChance = Herobrine.getPluginCore().getConfigDB().BuildPyramidOnChunkPercentage; + int templeChance = Herobrine.getPluginCore().getConfigDB().BuildTempleOnChunkPercentage; + + if (Herobrine.getPluginCore().getConfigDB().BuildPyramids && (new Random().nextInt(100) + 1 <= pyramidChance)) { final Object[] data = { event.getChunk() }; Herobrine.getPluginCore().getAICore().getCore(Core.CoreType.PYRAMID).runCore(data); } - if (Herobrine.getPluginCore().getConfigDB().BuildTemples && (new Random().nextInt(20) == 1)) { + if (Herobrine.getPluginCore().getConfigDB().BuildTemples && (new Random().nextInt(100) + 1 <= templeChance)) { final Object[] data = { event.getChunk() }; Herobrine.getPluginCore().getAICore().getCore(Core.CoreType.TEMPLE).runCore(data); }