diff --git a/src/main/java/com/iridium/iridiumskyblock/managers/IslandManager.java b/src/main/java/com/iridium/iridiumskyblock/managers/IslandManager.java index 290712e61..63a8bba46 100644 --- a/src/main/java/com/iridium/iridiumskyblock/managers/IslandManager.java +++ b/src/main/java/com/iridium/iridiumskyblock/managers/IslandManager.java @@ -436,6 +436,8 @@ public TeamMission getTeamMission(Island island, String missionName) { if (teamMission.isPresent()) { return teamMission.get(); } else { + //TODO need to consider reworking this, it could generate some lag + IridiumSkyblock.getInstance().getDatabaseManager().getTeamMissionTableManager().save(newTeamMission); IridiumSkyblock.getInstance().getDatabaseManager().getTeamMissionTableManager().addEntry(newTeamMission); return newTeamMission; } @@ -549,7 +551,7 @@ public boolean teleport(Player player, Location location, Island team) { @Override public void handleBlockBreakOutsideTerritory(BlockBreakEvent blockEvent) { - if(isInSkyblockWorld(blockEvent.getBlock().getWorld())){ + if (isInSkyblockWorld(blockEvent.getBlock().getWorld())) { blockEvent.getPlayer().sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().cannotBreakBlocks .replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix) )); @@ -559,7 +561,7 @@ public void handleBlockBreakOutsideTerritory(BlockBreakEvent blockEvent) { @Override public void handleBlockPlaceOutsideTerritory(BlockPlaceEvent blockEvent) { - if(isInSkyblockWorld(blockEvent.getBlock().getWorld())){ + if (isInSkyblockWorld(blockEvent.getBlock().getWorld())) { blockEvent.getPlayer().sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().cannotPlaceBlocks .replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix) )); diff --git a/src/main/java/com/iridium/iridiumskyblock/managers/tablemanagers/TableManager.java b/src/main/java/com/iridium/iridiumskyblock/managers/tablemanagers/TableManager.java index e4ef83b47..2eed5d557 100644 --- a/src/main/java/com/iridium/iridiumskyblock/managers/tablemanagers/TableManager.java +++ b/src/main/java/com/iridium/iridiumskyblock/managers/tablemanagers/TableManager.java @@ -1,6 +1,5 @@ package com.iridium.iridiumskyblock.managers.tablemanagers; -import com.iridium.iridiumskyblock.IridiumSkyblock; import com.iridium.iridiumskyblock.SortedList; import com.iridium.iridiumteams.database.DatabaseObject; import com.j256.ormlite.dao.Dao; @@ -36,12 +35,8 @@ public void save() { List entryList = new ArrayList<>(entries); for (T t : entryList) { if (!t.isChanged()) continue; - try { - dao.createOrUpdate(t); - t.setChanged(false); - } catch (Exception exception) { - IridiumSkyblock.getInstance().getLogger().warning("Failed to save " + t.getClass().getSimpleName() + " to database: " + exception.getMessage()); - } + dao.createOrUpdate(t); + t.setChanged(false); } dao.commit(getDatabaseConnection()); } catch (SQLException throwables) { @@ -49,6 +44,17 @@ public void save() { } } + public void save(T t) { + try { + if (!t.isChanged()) return; + dao.createOrUpdate(t); + dao.commit(getDatabaseConnection()); + t.setChanged(false); + } catch (SQLException throwables) { + throwables.printStackTrace(); + } + } + public void addEntry(T t) { entries.add(t); }