Skip to content

Commit

Permalink
Adding some better console logging of repeate tasks that have failure…
Browse files Browse the repository at this point in the history
… states, and improve handling of sponge vs wet sponge
  • Loading branch information
ProgrammerDan committed Jul 9, 2017
1 parent 163e614 commit 651968d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/main/java/isaac/bastion/BastionBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public BastionBlock(Location location, long placed, double balance, int ID, Bast
} else{
this.health = 0;
destroy();
Bastion.getPlugin().severe("Reinforcement removed during BastionBlock instantiation, removing");
Bastion.getPlugin().severe("Reinforcement removed during BastionBlock instantiation, removing at " + location.toString());
}

}
Expand Down Expand Up @@ -213,7 +213,7 @@ public void regen() {
}
} else {
destroy();
Bastion.getPlugin().severe("Reinforcement removed without removing bastion, fixed");
Bastion.getPlugin().severe("Reinforcement removed without removing bastion, fixed at " + location);
}
}
}
Expand Down Expand Up @@ -277,7 +277,7 @@ private PlayerReinforcement getReinforcement() {
return (PlayerReinforcement) reinforcement;
} else {
destroy();
Bastion.getPlugin().severe("Reinforcement removed without removing bastion, fixed");
Bastion.getPlugin().severe("Reinforcement no longer exists, but bastion not removed, fixed at " + location);
}
return null;
}
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/isaac/bastion/BastionType.java
Original file line number Diff line number Diff line change
Expand Up @@ -378,18 +378,27 @@ public static void startRegenAndErosionTasks() {
if(type.erosionTime > 0) {
new BukkitRunnable() {
public void run() {
Bastion.getPlugin().getLogger().log(Level.INFO, "Erosion task begin, found " +
Bastion.getBastionStorage().getBastionsForType(type).size() + " to erode");
for(BastionBlock bastion : Bastion.getBastionStorage().getBastionsForType(type)) {
bastion.erode(1);
}
Bastion.getPlugin().getLogger().log(Level.INFO, "Erosion task ended, after erosion " +
Bastion.getBastionStorage().getBastionsForType(type).size() + " remain");
}
}.runTaskTimerAsynchronously(Bastion.getPlugin(), type.erosionTime, type.erosionTime);
}
if(type.regenTime > 0) {
new BukkitRunnable() {
public void run() {
Bastion.getPlugin().getLogger().log(Level.INFO, "Regen task begin, found " +
Bastion.getBastionStorage().getBastionsForType(type).size() + " to regen");
for(BastionBlock bastion : Bastion.getBastionStorage().getBastionsForType(type)) {
bastion.regen();
}
Bastion.getPlugin().getLogger().log(Level.INFO, "Regen task ended, after regen " +
Bastion.getBastionStorage().getBastionsForType(type).size() + " remain");

}
}.runTaskTimerAsynchronously(Bastion.getPlugin(), type.regenTime, type.regenTime);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ public void run() {
}
}

@SuppressWarnings("deprecation")
//@SuppressWarnings("deprecation")
public BastionType blockToType(Block block, ItemStack inHand) {
MaterialData mat = new MaterialData(block.getType(), block.getData());
MaterialData mat = new MaterialData(block.getType()); //, block.getData()); -- again, we can't differentiate based on this?
String displayName = null;
List<String> lore = null;
if (inHand != null) {
Expand Down
14 changes: 9 additions & 5 deletions src/main/java/isaac/bastion/storage/BastionBlockStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ public BastionType getTypeAtLocation(Location loc) {
/**
* Loads all bastions from the database
*/
@SuppressWarnings("deprecation")
//@SuppressWarnings("deprecation")
public void loadBastions() {
int enderSearchRadius = EnderPearlManager.MAX_TELEPORT + 100;
for(World world : Bukkit.getWorlds()) {
Expand All @@ -359,16 +359,20 @@ public void loadBastions() {
long placed = result.getLong("placed");
double balance = result.getDouble("fraction");
BastionType type = BastionType.getBastionType(result.getString("bastion_type"));
boolean died = result.getBoolean("dead");
Location loc = new Location(world, x, y, z);
BastionBlock block = new BastionBlock(loc, placed, balance, id, type);
//Check if it's a ghost bastion, if so remove from the db
if(loc.getBlock().getType() != type.getMaterial().getItemType()
|| loc.getBlock().getData() != type.getMaterial().getData()) {
if(loc.getBlock().getType() != type.getMaterial().getItemType() ) { // can't set data why check with it
deleteBastion(block);
continue;
}
bastions.add(block);
bastionsForWorld.add(block);
if (died) {
dead.put(loc, block.getType().getName());
} else {
bastions.add(block);
bastionsForWorld.add(block);
}
}
} catch (SQLException e) {
log.log(Level.SEVERE, "Error loading bastions from database, shutting down", e);
Expand Down

0 comments on commit 651968d

Please sign in to comment.