Fix Config and permission check
Fix config "SecuredArea_Attack" read issues (caused by My bad code) and protectzone check issues
This commit is contained in:
parent
afa919be7f
commit
577542ebad
@ -3,16 +3,16 @@ package net.theprogrammersworld.herobrine.AI.cores;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
import net.theprogrammersworld.herobrine.Herobrine;
|
||||
import net.theprogrammersworld.herobrine.AI.AICore;
|
||||
import net.theprogrammersworld.herobrine.AI.Core;
|
||||
import net.theprogrammersworld.herobrine.AI.CoreResult;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.theprogrammersworld.herobrine.Herobrine;
|
||||
import net.theprogrammersworld.herobrine.AI.AICore;
|
||||
import net.theprogrammersworld.herobrine.AI.Core;
|
||||
import net.theprogrammersworld.herobrine.AI.CoreResult;
|
||||
|
||||
public class BuildStuff extends Core {
|
||||
|
||||
public BuildStuff() {
|
||||
@ -35,7 +35,8 @@ public class BuildStuff extends Core {
|
||||
return new CoreResult(false, "Cannot build stuff.");
|
||||
}
|
||||
if (loc.getBlockY() >= 60) {
|
||||
return new CoreResult(false, "Caves can only be generated in locations where the Y coordinate is less than or equal to 60.");
|
||||
return new CoreResult(false,
|
||||
"Caves can only be generated in locations where the Y coordinate is less than or equal to 60.");
|
||||
}
|
||||
final int chance = new Random().nextInt(100);
|
||||
if (chance > (100 - Herobrine.getPluginCore().getConfigDB().CaveChance)) {
|
||||
@ -55,12 +56,13 @@ public class BuildStuff extends Core {
|
||||
GenerateCave(loc);
|
||||
return new CoreResult(false, "Cave created.");
|
||||
}
|
||||
return new CoreResult(false, "Caves can only be generated in locations where the Y coordinate is less than or equal to 60.");
|
||||
return new CoreResult(false,
|
||||
"Caves can only be generated in locations where the Y coordinate is less than or equal to 60.");
|
||||
}
|
||||
|
||||
public void GenerateCave(final Location loc) {
|
||||
if (Herobrine.getPluginCore().getSupport().checkBuild(loc)) {
|
||||
final ArrayList<Location> redstoneTorchList = new ArrayList<Location>();
|
||||
final ArrayList<Location> redstoneTorchList = new ArrayList<>();
|
||||
boolean goByX = new Random().nextBoolean();
|
||||
boolean goNegative = new Random().nextBoolean();
|
||||
int baseX = loc.getBlockX();
|
||||
@ -92,9 +94,15 @@ public class BuildStuff extends Core {
|
||||
}
|
||||
baseX += finalX;
|
||||
baseZ += finalZ;
|
||||
loc.getWorld().getBlockAt(baseX, baseY, baseZ).breakNaturally((ItemStack) null);
|
||||
loc.getWorld().getBlockAt(baseX, baseY + 1, baseZ).breakNaturally((ItemStack) null);
|
||||
if (new Random().nextBoolean()) {
|
||||
if (Herobrine.getPluginCore().getSupport()
|
||||
.checkBuild(loc.getWorld().getBlockAt(baseX, baseY, baseZ).getLocation())
|
||||
&& Herobrine.getPluginCore().getSupport()
|
||||
.checkBuild(loc.getWorld().getBlockAt(baseX, baseY + 1, baseZ).getLocation())) {
|
||||
loc.getWorld().getBlockAt(baseX, baseY, baseZ).breakNaturally((ItemStack) null);
|
||||
loc.getWorld().getBlockAt(baseX, baseY + 1, baseZ).breakNaturally((ItemStack) null);
|
||||
}
|
||||
if (new Random().nextBoolean() && Herobrine.getPluginCore().getSupport()
|
||||
.checkBuild(new Location(loc.getWorld(), baseX, baseY + 1, baseZ))) {
|
||||
redstoneTorchList.add(new Location(loc.getWorld(), baseX, baseY + 1, baseZ));
|
||||
}
|
||||
}
|
||||
@ -110,7 +118,9 @@ public class BuildStuff extends Core {
|
||||
final Random randgen = new Random();
|
||||
final int chance = randgen.nextInt(100);
|
||||
if (chance > 70) {
|
||||
world.getBlockAt(x, y, z).setType(Material.REDSTONE_TORCH_ON);
|
||||
if (Herobrine.getPluginCore().getSupport().checkBuild(world.getBlockAt(x, y, z).getLocation())) {
|
||||
world.getBlockAt(x, y, z).setType(Material.REDSTONE_TORCH_ON);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -131,14 +131,9 @@ public class Support {
|
||||
|
||||
public boolean checkBuild(final Location loc) {
|
||||
if (Herobrine.getPluginCore().getConfigDB().SecuredArea_Build || !isSecuredArea(loc)) {
|
||||
if (loc.getBlock().getType().equals(Material.AIR)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean checkAttack(final Location loc) {
|
||||
|
Reference in New Issue
Block a user