Removed unnecessary conditional check

This commit is contained in:
David Berdik 2019-12-27 18:47:07 -05:00
parent 6eefa9cc52
commit 2ab95750d7

View File

@ -72,144 +72,128 @@ public class HerobrineAI extends JavaPlugin implements Listener {
PluginDescriptionFile pdf = this.getDescription(); PluginDescriptionFile pdf = this.getDescription();
versionStr = pdf.getVersion(); versionStr = pdf.getVersion();
isInitDone = true;
HerobrineAI.pluginCore = this;
this.configdb = new ConfigDB(log);
boolean errorCheck = true; this.NPCman = new NPCCore(this);
try { getServer().getPluginManager().registerEvents(new EntityListener(this), this);
Class.forName("net.minecraft.server.v1_15_R1.EntityTypes"); getServer().getPluginManager().registerEvents(new BlockListener(), this);
} catch (ClassNotFoundException e) { getServer().getPluginManager().registerEvents(new InventoryListener(), this);
errorCheck = false; getServer().getPluginManager().registerEvents(new PlayerListener(this), this);
isInitDone = false; getServer().getPluginManager().registerEvents(new WorldListener(), this);
// Initialize PathManager
this.pathMng = new PathManager();
// Initialize AICore
this.aicore = new AICore();
// Initialize EntityManager
this.entMng = new EntityManager();
// Config loading
configdb.Startup();
configdb.Reload();
// Spawn Herobrine
Location nowloc = new Location((World) Bukkit.getServer().getWorlds().get(0), (float) 0, (float) -20,
(float) 0);
nowloc.setYaw((float) 1);
nowloc.setPitch((float) 1);
HerobrineSpawn(nowloc);
HerobrineNPC.setItemInHand(configdb.ItemInHand.getItemStack());
// Graveyard World
if (this.configdb.UseGraveyardWorld == true && Bukkit.getServer().getWorld("world_herobrineai_graveyard") == null) {
log.info("[HerobrineAI] Creating Graveyard world...");
WorldCreator wc = new WorldCreator("world_herobrineai_graveyard");
wc.generateStructures(false);
org.bukkit.WorldType type = org.bukkit.WorldType.FLAT;
wc.type(type);
wc.createWorld();
GraveyardWorld.Create();
} }
if (errorCheck) { log.info("[HerobrineAI] Plugin loaded! Version: ");
isInitDone = true;
HerobrineAI.pluginCore = this;
this.configdb = new ConfigDB(log);
this.NPCman = new NPCCore(this); // Init Block Types
getServer().getPluginManager().registerEvents(new EntityListener(this), this); AllowedBlocks.add(Material.AIR);
getServer().getPluginManager().registerEvents(new BlockListener(), this); AllowedBlocks.add(Material.SNOW);
getServer().getPluginManager().registerEvents(new InventoryListener(), this); AllowedBlocks.add(Material.RAIL);
getServer().getPluginManager().registerEvents(new PlayerListener(this), this); AllowedBlocks.add(Material.ACTIVATOR_RAIL);
getServer().getPluginManager().registerEvents(new WorldListener(), this); AllowedBlocks.add(Material.DETECTOR_RAIL);
AllowedBlocks.add(Material.POWERED_RAIL);
AllowedBlocks.add(Material.DEAD_BUSH);
AllowedBlocks.add(Material.DANDELION);
AllowedBlocks.add(Material.POPPY);
AllowedBlocks.add(Material.ACACIA_PRESSURE_PLATE);
AllowedBlocks.add(Material.BIRCH_PRESSURE_PLATE);
AllowedBlocks.add(Material.DARK_OAK_PRESSURE_PLATE);
AllowedBlocks.add(Material.HEAVY_WEIGHTED_PRESSURE_PLATE);
AllowedBlocks.add(Material.JUNGLE_PRESSURE_PLATE);
AllowedBlocks.add(Material.LIGHT_WEIGHTED_PRESSURE_PLATE);
AllowedBlocks.add(Material.OAK_PRESSURE_PLATE);
AllowedBlocks.add(Material.SPRUCE_PRESSURE_PLATE);
AllowedBlocks.add(Material.STONE_PRESSURE_PLATE);
AllowedBlocks.add(Material.VINE);
AllowedBlocks.add(Material.TORCH);
AllowedBlocks.add(Material.REDSTONE);
AllowedBlocks.add(Material.REDSTONE_TORCH);
AllowedBlocks.add(Material.LEVER);
AllowedBlocks.add(Material.STONE_BUTTON);
AllowedBlocks.add(Material.LADDER);
// Initialize PathManager pathUpdateINT = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
public void run() {
this.pathMng = new PathManager(); if (Utils.getRandomGen().nextInt(4) == 2 && HerobrineAI.getPluginCore().getAICore().getCoreTypeNow()
.equals(CoreType.RANDOM_POSITION)) {
// Initialize AICore pathMng.setPath(new Path(Utils.getRandomGen().nextInt(15) - 7f, Utils.getRandomGen().nextInt(15) - 7f, HerobrineAI.getPluginCore()));
}
this.aicore = new AICore();
// Initialize EntityManager
this.entMng = new EntityManager();
// Config loading
configdb.Startup();
configdb.Reload();
// Spawn Herobrine
Location nowloc = new Location((World) Bukkit.getServer().getWorlds().get(0), (float) 0, (float) -20,
(float) 0);
nowloc.setYaw((float) 1);
nowloc.setPitch((float) 1);
HerobrineSpawn(nowloc);
HerobrineNPC.setItemInHand(configdb.ItemInHand.getItemStack());
// Graveyard World
if (this.configdb.UseGraveyardWorld == true && Bukkit.getServer().getWorld("world_herobrineai_graveyard") == null) {
log.info("[HerobrineAI] Creating Graveyard world...");
WorldCreator wc = new WorldCreator("world_herobrineai_graveyard");
wc.generateStructures(false);
org.bukkit.WorldType type = org.bukkit.WorldType.FLAT;
wc.type(type);
wc.createWorld();
GraveyardWorld.Create();
} }
log.info("[HerobrineAI] Plugin loaded! Version: "); }, 1 * 200L, 1 * 200L);
// Init Block Types Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
public void run() {
pathMng.update();
}
}, 1 * 5L, 1 * 5L);
AllowedBlocks.add(Material.AIR); // Command Executors
AllowedBlocks.add(Material.SNOW); this.getCommand("hb").setExecutor((CommandExecutor) new CmdExecutor(this));
AllowedBlocks.add(Material.RAIL); this.getCommand("hb-ai").setExecutor((CommandExecutor) new CmdExecutor(this));
AllowedBlocks.add(Material.ACTIVATOR_RAIL);
AllowedBlocks.add(Material.DETECTOR_RAIL);
AllowedBlocks.add(Material.POWERED_RAIL);
AllowedBlocks.add(Material.DEAD_BUSH);
AllowedBlocks.add(Material.DANDELION);
AllowedBlocks.add(Material.POPPY);
AllowedBlocks.add(Material.ACACIA_PRESSURE_PLATE);
AllowedBlocks.add(Material.BIRCH_PRESSURE_PLATE);
AllowedBlocks.add(Material.DARK_OAK_PRESSURE_PLATE);
AllowedBlocks.add(Material.HEAVY_WEIGHTED_PRESSURE_PLATE);
AllowedBlocks.add(Material.JUNGLE_PRESSURE_PLATE);
AllowedBlocks.add(Material.LIGHT_WEIGHTED_PRESSURE_PLATE);
AllowedBlocks.add(Material.OAK_PRESSURE_PLATE);
AllowedBlocks.add(Material.SPRUCE_PRESSURE_PLATE);
AllowedBlocks.add(Material.STONE_PRESSURE_PLATE);
AllowedBlocks.add(Material.VINE);
AllowedBlocks.add(Material.TORCH);
AllowedBlocks.add(Material.REDSTONE);
AllowedBlocks.add(Material.REDSTONE_TORCH);
AllowedBlocks.add(Material.LEVER);
AllowedBlocks.add(Material.STONE_BUTTON);
AllowedBlocks.add(Material.LADDER);
pathUpdateINT = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() { // Support initialize
public void run() { this.support = new Support();
if (Utils.getRandomGen().nextInt(4) == 2 && HerobrineAI.getPluginCore().getAICore().getCoreTypeNow()
.equals(CoreType.RANDOM_POSITION)) {
pathMng.setPath(new Path(Utils.getRandomGen().nextInt(15) - 7f, Utils.getRandomGen().nextInt(15) - 7f, HerobrineAI.getPluginCore()));
}
}
}, 1 * 200L, 1 * 200L);
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() { Class<?>[] argst = new Class[3];
public void run() { argst[0] = Class.class;
pathMng.update(); argst[1] = String.class;
} argst[2] = int.class;
}, 1 * 5L, 1 * 5L);
// Command Executors if (!isNPCDisabled) {
this.getCommand("hb").setExecutor((CommandExecutor) new CmdExecutor(this)); try {
this.getCommand("hb-ai").setExecutor((CommandExecutor) new CmdExecutor(this)); addCustomEntity("mzombie", CustomZombie::new, EnumCreatureType.MONSTER);
addCustomEntity("mskeleton", CustomSkeleton::new, EnumCreatureType.MONSTER);
// Support initialize } catch (Exception e) {
this.support = new Support(); e.printStackTrace();
this.setEnabled(false);
Class<?>[] argst = new Class[3];
argst[0] = Class.class;
argst[1] = String.class;
argst[2] = int.class;
if (!isNPCDisabled) {
try {
addCustomEntity("mzombie", CustomZombie::new, EnumCreatureType.MONSTER);
addCustomEntity("mskeleton", CustomSkeleton::new, EnumCreatureType.MONSTER);
} catch (Exception e) {
e.printStackTrace();
this.setEnabled(false);
}
} else {
log.warning("[HerobrineAI] Custom NPCs have been disabled. (Incompatibility error!)");
} }
} else { } else {
log.warning("[HerobrineAI] ******************ERROR******************"); log.warning("[HerobrineAI] Custom NPCs have been disabled. (Incompatibility error!)");
log.warning("[HerobrineAI] This version is only compatible with bukkit version " + bukkit_ver_string);
log.warning("[HerobrineAI] *****************************************");
this.setEnabled(false);
} }
} }