From 042449e59192305855af269ececd29862710f979 Mon Sep 17 00:00:00 2001 From: jojo Date: Mon, 4 Jan 2021 22:26:29 +0100 Subject: [PATCH] Fix try/catch in FightTeam.pasteSchematic --- .../steamwar/fightsystem/fight/FightTeam.java | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java b/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java index 05ea9ec..61cdb04 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java @@ -279,22 +279,30 @@ public class FightTeam implements IFightTeam{ try { VersionedRunnable.call(new VersionedRunnable(() -> { - EditSession e = FightTeam_8.pasteSchematic(schem, pasteX, pasteY, pasteZ, rotate); - FightTeam_8.replaceTeamColor(e, c, cornerX, cornerY, cornerZ); + try { + EditSession e = FightTeam_8.pasteSchematic(schem, pasteX, pasteY, pasteZ, rotate); + FightTeam_8.replaceTeamColor(e, c, cornerX, cornerY, cornerZ); + } catch (Schematic.WrongVersionException | IOException | NoClipboardException ex) { + throw new SecurityException("Error pasting arena in schematic", ex); + } }, 8), new VersionedRunnable(() -> { - EditSession e = FightTeam_8.pasteSchematic(schem, pasteX, pasteY, pasteZ, rotate); - FightTeam_12.replaceTeamColor(e, c, cornerX, cornerY, cornerZ); + try { + EditSession e = FightTeam_8.pasteSchematic(schem, pasteX, pasteY, pasteZ, rotate); + FightTeam_12.replaceTeamColor(e, c, cornerX, cornerY, cornerZ); + } catch (Schematic.WrongVersionException | IOException | NoClipboardException ex) { + throw new SecurityException("Error pasting arena in schematic", ex); + } }, 12), new VersionedRunnable(() -> { - EditSession e = FightTeam_14.pasteSchematic(schem, pasteX, pasteY, pasteZ, rotate); - FightTeam_14.replaceTeamColor(e, c, cornerX, cornerY, cornerZ); + try { + EditSession e = FightTeam_14.pasteSchematic(schem, pasteX, pasteY, pasteZ, rotate); + FightTeam_14.replaceTeamColor(e, c, cornerX, cornerY, cornerZ); + } catch (Schematic.WrongVersionException | IOException | NoClipboardException ex) { + throw new SecurityException("Error pasting arena in schematic", ex); + } }, 14)); - } catch (Schematic.WrongVersionException ex) { - broadcast(FightSystem.PREFIX + "§cDie gewählte Schematic kann nicht in dieser Version geladen werden"); - HandlerList.unregisterAll(freezer); - return; - } catch (IOException | NoClipboardException ex) { + } catch (SecurityException securityException) { broadcast(FightSystem.PREFIX + "§cFehler beim Pasten der Schematic"); - throw new SecurityException("Error pasting arena in schematic", ex); + throw securityException; } Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> HandlerList.unregisterAll(freezer), 3); Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), this::teleportToSpawn,40);