Skip to content

Commit

Permalink
Updated LoggerUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
Bletch1971 committed Nov 19, 2021
1 parent 29bbbb1 commit 246fe43
Show file tree
Hide file tree
Showing 16 changed files with 125 additions and 846 deletions.
10 changes: 5 additions & 5 deletions src/main/src/main/java/bletch/tektopiathief/TektopiaThief.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,24 @@ public void postInitialize(FMLPostInitializationEvent e) {
@Mod.EventHandler
public void onServerStarting(final FMLServerStartingEvent e) {

LoggerUtils.info("Starting command registrations...");
LoggerUtils.instance.info("Starting command registrations...");

LoggerUtils.info("Registering thief commands");
LoggerUtils.instance.info("Registering thief commands");
ThiefCommands commands = new ThiefCommands();
e.registerServerCommand(commands);
commands.registerNodes();

LoggerUtils.info("Finished command registrations");
LoggerUtils.instance.info("Finished command registrations");

World world = e.getServer().getEntityWorld();

LoggerUtils.info("Starting ScheduleManager setup...");
LoggerUtils.instance.info("Starting ScheduleManager setup...");

// create the schedule manager
scheduleManager = new ScheduleManager(world);
scheduleManager.addScheduler(new ThiefScheduler());

LoggerUtils.info("Finished ScheduleManager setup");
LoggerUtils.instance.info("Finished ScheduleManager setup");
}

@EventBusSubscriber
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ public void execute(MinecraftServer server, ICommandSender sender, String[] args
Village village = villageManager != null && entityPlayer != null ? villageManager.getVillageAt(entityPlayer.getPosition()) : null;
if (village == null) {
notifyCommandListener(sender, this, this.prefix + COMMAND_NAME + ".novillage");
LoggerUtils.info(TextUtils.translate(this.prefix + COMMAND_NAME + ".novillage"), true);
LoggerUtils.instance.info(TextUtils.translate(this.prefix + COMMAND_NAME + ".novillage"), true);
return;
}

List<EntityThief> entityList = world.getEntitiesWithinAABB(EntityThief.class, village.getAABB().grow(Village.VILLAGE_SIZE));
if (entityList.size() == 0) {
notifyCommandListener(sender, this, this.prefix + COMMAND_NAME + ".noexists");
LoggerUtils.info(TextUtils.translate(this.prefix + COMMAND_NAME + ".noexists"), true);
LoggerUtils.instance.info(TextUtils.translate(this.prefix + COMMAND_NAME + ".noexists"), true);
return;
}

Expand All @@ -55,7 +55,7 @@ public void execute(MinecraftServer server, ICommandSender sender, String[] args
entity.setDead();

notifyCommandListener(sender, this, this.prefix + COMMAND_NAME + ".success");
LoggerUtils.info(TextUtils.translate(this.prefix + COMMAND_NAME + ".success"), true);
LoggerUtils.instance.info(TextUtils.translate(this.prefix + COMMAND_NAME + ".success"), true);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,48 +58,48 @@ public void execute(MinecraftServer server, ICommandSender sender, String[] args

if (world == null || world.isRaining()) {
notifyCommandListener(sender, this, this.prefix + COMMAND_NAME + ".badconditions");
LoggerUtils.info(TextUtils.translate(this.prefix + COMMAND_NAME + ".badconditions"), true);
LoggerUtils.instance.info(TextUtils.translate(this.prefix + COMMAND_NAME + ".badconditions"), true);
return;
}

if (world.getDifficulty() == EnumDifficulty.PEACEFUL && !ModConfig.thief.thiefSpawnsWhenPeaceful) {
notifyCommandListener(sender, this, this.prefix + COMMAND_NAME + ".peaceful");
LoggerUtils.info(TextUtils.translate(this.prefix + COMMAND_NAME + ".peaceful"), true);
LoggerUtils.instance.info(TextUtils.translate(this.prefix + COMMAND_NAME + ".peaceful"), true);
return;
}

VillageManager villageManager = world != null ? VillageManager.get(world) : null;
Village village = villageManager != null && entityPlayer != null ? villageManager.getVillageAt(entityPlayer.getPosition()) : null;
if (village == null) {
notifyCommandListener(sender, this, this.prefix + COMMAND_NAME + ".novillage");
LoggerUtils.info(TextUtils.translate(this.prefix + COMMAND_NAME + ".novillage"), true);
LoggerUtils.instance.info(TextUtils.translate(this.prefix + COMMAND_NAME + ".novillage"), true);
return;
}

BlockPos spawnPosition = spawnNearMe ? entityPlayer.getPosition() : TektopiaUtils.getVillageSpawnPoint(world, village);

if (spawnPosition == null) {
notifyCommandListener(sender, this, this.prefix + COMMAND_NAME + ".noposition");
LoggerUtils.info(TextUtils.translate(this.prefix + COMMAND_NAME + ".noposition"), true);
LoggerUtils.instance.info(TextUtils.translate(this.prefix + COMMAND_NAME + ".noposition"), true);
return;
}

List<EntityThief> entityList = world.getEntitiesWithinAABB(EntityThief.class, village.getAABB().grow(Village.VILLAGE_SIZE));
if (entityList.size() > 0) {
notifyCommandListener(sender, this, this.prefix + COMMAND_NAME + ".exists");
LoggerUtils.info(TextUtils.translate(this.prefix + COMMAND_NAME + ".exists"), true);
LoggerUtils.instance.info(TextUtils.translate(this.prefix + COMMAND_NAME + ".exists"), true);
return;
}

// attempt to spawn the thief
if (!TektopiaUtils.trySpawnPersistenceEntity(world, spawnPosition, (World w) -> new EntityThief(w, level))) {
notifyCommandListener(sender, this, this.prefix + COMMAND_NAME + ".failed");
LoggerUtils.info(TextUtils.translate(this.prefix + COMMAND_NAME + ".failed"), true);
LoggerUtils.instance.info(TextUtils.translate(this.prefix + COMMAND_NAME + ".failed"), true);
return;
}

notifyCommandListener(sender, this, this.prefix + COMMAND_NAME + ".success", TektopiaUtils.formatBlockPos(spawnPosition));
LoggerUtils.info(TextUtils.translate(this.prefix + COMMAND_NAME + ".success", TektopiaUtils.formatBlockPos(spawnPosition)), true);
LoggerUtils.instance.info(TextUtils.translate(this.prefix + COMMAND_NAME + ".success", TektopiaUtils.formatBlockPos(spawnPosition)), true);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,24 @@ public File getMinecraftDirectory() {
public void registerCraftStudioAnimations() {
super.registerCraftStudioAnimations();

LoggerUtils.info("Starting registerCraftStudioAnimations...");
LoggerUtils.instance.info("Starting registerCraftStudioAnimations...");

this.registry.register(EnumResourceType.ANIM, EnumRenderType.ENTITY, ModEntities.ANIMATION_VILLAGER_WALK);
this.registry.register(EnumResourceType.ANIM, EnumRenderType.ENTITY, ModEntities.ANIMATION_VILLAGER_RUN);
this.registry.register(EnumResourceType.ANIM, EnumRenderType.ENTITY, ModEntities.ANIMATION_VILLAGER_CREEP);

LoggerUtils.info("Finished registerCraftStudioAnimations...");
LoggerUtils.instance.info("Finished registerCraftStudioAnimations...");
}

@Override
public void registerCraftStudioModels() {
super.registerCraftStudioModels();

LoggerUtils.info("Starting registerCraftStudioModels...");
LoggerUtils.instance.info("Starting registerCraftStudioModels...");

registry.register(EnumResourceType.MODEL, EnumRenderType.ENTITY, EntityThief.ANIMATION_MODEL_NAME);

LoggerUtils.info("Finished registerCraftStudioModels...");
LoggerUtils.instance.info("Finished registerCraftStudioModels...");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,8 @@ public void registerCraftStudioModels() {
}

public void resetDebug() {
LoggerUtils.Initialise(ModDetails.MOD_NAME, getMinecraftDirectory() + ModDetails.FILE_DEBUGLOG);

if (ModConfig.debug.enableDebug) {
LoggerUtils.resetDebug();
}
LoggerUtils.instance.Initialise(ModDetails.MOD_NAME, getMinecraftDirectory() + ModDetails.FILE_DEBUGLOG);
LoggerUtils.instance.resetDebug();
}

}
Loading

0 comments on commit 246fe43

Please sign in to comment.