9
0
mirror of https://github.com/WiIIiam278/HuskSync.git synced 2026-01-06 15:41:56 +00:00

Refactor; consolidate Logger and ResourceReader, simplify certain method arguments

This commit is contained in:
William
2023-01-05 19:06:04 +00:00
parent 33588c2345
commit f6663f0c09
25 changed files with 259 additions and 474 deletions

View File

@@ -48,7 +48,7 @@ public class BukkitMapHandler {
}
// Get the map data
plugin.getLoggingAdapter().debug("Rendering map view onto canvas for locked map");
plugin.debug("Rendering map view onto canvas for locked map");
final LockedMapCanvas canvas = new LockedMapCanvas(mapView);
for (MapRenderer renderer : mapView.getRenderers()) {
renderer.render(mapView, canvas, Bukkit.getServer()
@@ -58,7 +58,7 @@ public class BukkitMapHandler {
}
// Save the extracted rendered map data
plugin.getLoggingAdapter().debug("Saving pixel canvas data for locked map");
plugin.debug("Saving pixel canvas data for locked map");
if (!mapMeta.getPersistentDataContainer().has(MAP_DATA_KEY, PersistentDataType.BYTE_ARRAY)) {
mapMeta.getPersistentDataContainer().set(MAP_DATA_KEY, PersistentDataType.BYTE_ARRAY,
canvas.extractMapData().toBytes());
@@ -89,7 +89,7 @@ public class BukkitMapHandler {
final byte[] serializedData = itemStack.getItemMeta().getPersistentDataContainer()
.get(MAP_DATA_KEY, PersistentDataType.BYTE_ARRAY);
final MapData mapData = MapData.fromByteArray(Objects.requireNonNull(serializedData));
plugin.getLoggingAdapter().debug("Setting deserialized map data for an item stack");
plugin.debug("Setting deserialized map data for an item stack");
// Create a new map view renderer with the map data color at each pixel
final MapView view = Bukkit.createMap(Bukkit.getWorlds().get(0));
@@ -101,7 +101,7 @@ public class BukkitMapHandler {
view.setUnlimitedTracking(false);
mapMeta.setMapView(view);
itemStack.setItemMeta(mapMeta);
plugin.getLoggingAdapter().debug("Successfully applied renderer to map item stack");
plugin.debug("Successfully applied renderer to map item stack");
} catch (IOException | NullPointerException e) {
plugin.getLogger().log(Level.WARNING, "Failed to deserialize map data for a player", e);
}

View File

@@ -52,7 +52,7 @@ public class BukkitSerializer {
// Return encoded data, using the encoder from SnakeYaml to get a ByteArray conversion
return Base64Coder.encodeLines(byteOutputStream.toByteArray());
} catch (IOException e) {
BukkitHuskSync.getInstance().getLoggingAdapter().log(Level.SEVERE, "Failed to serialize item stack data", e);
BukkitHuskSync.getInstance().log(Level.SEVERE, "Failed to serialize item stack data", e);
throw new DataSerializationException("Failed to serialize item stack data", e);
}
});
@@ -108,7 +108,7 @@ public class BukkitSerializer {
return inventoryContents;
}
} catch (IOException | ClassNotFoundException e) {
BukkitHuskSync.getInstance().getLoggingAdapter().log(Level.SEVERE, "Failed to deserialize item stack data", e);
BukkitHuskSync.getInstance().log(Level.SEVERE, "Failed to deserialize item stack data", e);
throw new DataSerializationException("Failed to deserialize item stack data", e);
}
});
@@ -165,7 +165,7 @@ public class BukkitSerializer {
// Return encoded data, using the encoder from SnakeYaml to get a ByteArray conversion
return Base64Coder.encodeLines(byteOutputStream.toByteArray());
} catch (IOException e) {
BukkitHuskSync.getInstance().getLoggingAdapter().log(Level.SEVERE, "Failed to serialize potion effect data", e);
BukkitHuskSync.getInstance().log(Level.SEVERE, "Failed to serialize potion effect data", e);
throw new DataSerializationException("Failed to serialize potion effect data", e);
}
});
@@ -201,7 +201,7 @@ public class BukkitSerializer {
return potionEffects;
}
} catch (IOException | ClassNotFoundException e) {
BukkitHuskSync.getInstance().getLoggingAdapter().log(Level.SEVERE, "Failed to deserialize potion effect data", e);
BukkitHuskSync.getInstance().log(Level.SEVERE, "Failed to deserialize potion effect data", e);
throw new DataSerializationException("Failed to deserialize potion effects", e);
}
});