Change Schematic version dependant calls
Dieser Commit ist enthalten in:
Ursprung
2c0c75e6ea
Commit
68155e228a
@ -64,17 +64,17 @@ class Schematic_14 {
|
|||||||
private static final ClipboardFormat SCHEMATIC = BuiltInClipboardFormat.MCEDIT_SCHEMATIC;
|
private static final ClipboardFormat SCHEMATIC = BuiltInClipboardFormat.MCEDIT_SCHEMATIC;
|
||||||
private static final ClipboardFormat SCHEM = BuiltInClipboardFormat.SPONGE_SCHEMATIC;
|
private static final ClipboardFormat SCHEM = BuiltInClipboardFormat.SPONGE_SCHEMATIC;
|
||||||
|
|
||||||
static byte[] getPlayerClipboard(Player player, boolean schemFormat) throws IOException, NoClipboardException {
|
static byte[] getPlayerClipboard(Player player, boolean schemFormat) {
|
||||||
ClipboardHolder clipboardHolder;
|
ClipboardHolder clipboardHolder;
|
||||||
try {
|
try {
|
||||||
clipboardHolder = getWorldEditPlugin().getSession(player).getClipboard();
|
clipboardHolder = getWorldEditPlugin().getSession(player).getClipboard();
|
||||||
} catch (EmptyClipboardException e) {
|
} catch (EmptyClipboardException e) {
|
||||||
throw new NoClipboardException();
|
throw new RuntimeException(e.getMessage(), new NoClipboardException());
|
||||||
}
|
}
|
||||||
|
|
||||||
Clipboard clipboard = clipboardHolder.getClipboard();
|
Clipboard clipboard = clipboardHolder.getClipboard();
|
||||||
if(clipboard == null)
|
if(clipboard == null)
|
||||||
throw new NoClipboardException();
|
throw new RuntimeException("Clipboard was null", new NoClipboardException());
|
||||||
|
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
try{
|
try{
|
||||||
@ -86,16 +86,23 @@ class Schematic_14 {
|
|||||||
SCHEMATIC.getWriter(outputStream).write(clipboard);
|
SCHEMATIC.getWriter(outputStream).write(clipboard);
|
||||||
}
|
}
|
||||||
}catch(NullPointerException e){
|
}catch(NullPointerException e){
|
||||||
throw new IOException(e);
|
throw new RuntimeException(e.getMessage(), new IOException(e));
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
return outputStream.toByteArray();
|
return outputStream.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setPlayerClipboard(Player player, InputStream is, boolean schemFormat) throws IOException, NoClipboardException {
|
static void setPlayerClipboard(Player player, InputStream is, boolean schemFormat) {
|
||||||
Clipboard clipboard = getClipboard(is, schemFormat);
|
Clipboard clipboard = null;
|
||||||
|
try {
|
||||||
|
clipboard = getClipboard(is, schemFormat);
|
||||||
|
} catch (IOException | NoClipboardException e) {
|
||||||
|
throw new RuntimeException(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
if (clipboard == null)
|
if (clipboard == null)
|
||||||
throw new NoClipboardException();
|
throw new RuntimeException("clipboard was null", new NoClipboardException());
|
||||||
|
|
||||||
Actor actor = getWorldEditPlugin().wrapCommandSender(player);
|
Actor actor = getWorldEditPlugin().wrapCommandSender(player);
|
||||||
getWorldEditPlugin().getWorldEdit().getSessionManager().get(actor).setClipboard(new ClipboardHolder(clipboard));
|
getWorldEditPlugin().getWorldEdit().getSessionManager().get(actor).setClipboard(new ClipboardHolder(clipboard));
|
||||||
|
@ -52,26 +52,35 @@ import java.util.zip.GZIPInputStream;
|
|||||||
class Schematic_8 {
|
class Schematic_8 {
|
||||||
private Schematic_8(){}
|
private Schematic_8(){}
|
||||||
|
|
||||||
static byte[] getPlayerClipboard(Player player) throws IOException, NoClipboardException {
|
static byte[] getPlayerClipboard(Player player) {
|
||||||
ClipboardHolder clipboardHolder;
|
ClipboardHolder clipboardHolder;
|
||||||
try {
|
try {
|
||||||
clipboardHolder = getWorldEditPlugin().getSession(player).getClipboard();
|
clipboardHolder = getWorldEditPlugin().getSession(player).getClipboard();
|
||||||
} catch (EmptyClipboardException e) {
|
} catch (EmptyClipboardException e) {
|
||||||
throw new NoClipboardException();
|
throw new RuntimeException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
Clipboard clipboard = clipboardHolder.getClipboard();
|
Clipboard clipboard = clipboardHolder.getClipboard();
|
||||||
if(clipboard == null)
|
if(clipboard == null)
|
||||||
throw new NoClipboardException();
|
throw new RuntimeException("clipboard was null", new NoClipboardException());
|
||||||
|
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
ClipboardFormat.SCHEMATIC.getWriter(outputStream).write(clipboard, clipboardHolder.getWorldData());
|
try {
|
||||||
|
ClipboardFormat.SCHEMATIC.getWriter(outputStream).write(clipboard, clipboardHolder.getWorldData());
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e.getMessage(), e);
|
||||||
|
}
|
||||||
return outputStream.toByteArray();
|
return outputStream.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setPlayerClipboard(Player player, InputStream is, boolean schemFormat) throws IOException {
|
static void setPlayerClipboard(Player player, InputStream is, boolean schemFormat) {
|
||||||
WorldData world = new BukkitWorld(player.getWorld()).getWorldData();
|
WorldData world = new BukkitWorld(player.getWorld()).getWorldData();
|
||||||
Clipboard clipboard = getClipboard(is, schemFormat);
|
Clipboard clipboard;
|
||||||
|
try {
|
||||||
|
clipboard = getClipboard(is, schemFormat);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
Actor actor = getWorldEditPlugin().wrapCommandSender(player);
|
Actor actor = getWorldEditPlugin().wrapCommandSender(player);
|
||||||
getWorldEditPlugin().getWorldEdit().getSessionManager().get(actor).setClipboard(new ClipboardHolder(clipboard, world));
|
getWorldEditPlugin().getWorldEdit().getSessionManager().get(actor).setClipboard(new ClipboardHolder(clipboard, world));
|
||||||
|
@ -205,19 +205,8 @@ public class Schematic {
|
|||||||
if(blob == null)
|
if(blob == null)
|
||||||
throw new NoClipboardException();
|
throw new NoClipboardException();
|
||||||
InputStream is = blob.getBinaryStream();
|
InputStream is = blob.getBinaryStream();
|
||||||
VersionedRunnable.call(new VersionedRunnable(() -> {
|
VersionedRunnable.call(new VersionedRunnable(() -> Schematic_8.setPlayerClipboard(player, is, schemFormat), 8),
|
||||||
try {
|
new VersionedRunnable(() -> Schematic_14.setPlayerClipboard(player, is, schemFormat), 14));
|
||||||
Schematic_8.setPlayerClipboard(player, is, schemFormat);
|
|
||||||
} catch (IOException exception) {
|
|
||||||
throw new RuntimeException(exception.getMessage(), exception);
|
|
||||||
}
|
|
||||||
}, 8), new VersionedRunnable(() -> {
|
|
||||||
try {
|
|
||||||
Schematic_14.setPlayerClipboard(player, is, schemFormat);
|
|
||||||
} catch (IOException | NoClipboardException exception) {
|
|
||||||
throw new RuntimeException(exception.getMessage(), exception);
|
|
||||||
}
|
|
||||||
}, 14));
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new IOException(e);
|
throw new IOException(e);
|
||||||
}
|
}
|
||||||
@ -236,15 +225,15 @@ public class Schematic {
|
|||||||
VersionedRunnable.call(new VersionedRunnable(() -> {
|
VersionedRunnable.call(new VersionedRunnable(() -> {
|
||||||
try {
|
try {
|
||||||
blob.setBytes(1, Schematic_8.getPlayerClipboard(player));
|
blob.setBytes(1, Schematic_8.getPlayerClipboard(player));
|
||||||
} catch (IOException | NoClipboardException | SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new RuntimeException(e.getMessage(), e);
|
throw new RuntimeException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
updateDatabase(blob, player, false);
|
updateDatabase(blob, player, false);
|
||||||
}, 8), new VersionedRunnable(() -> {
|
}, 8), new VersionedRunnable(() -> {
|
||||||
try {
|
try {
|
||||||
blob.setBytes(1, Schematic_14.getPlayerClipboard(player, newFormat));
|
blob.setBytes(1, Schematic_14.getPlayerClipboard(player, newFormat));
|
||||||
} catch (IOException | NoClipboardException | SQLException e) {
|
} catch (SQLException exception) {
|
||||||
throw new RuntimeException(e.getMessage(), e);
|
throw new RuntimeException(exception.getMessage(), exception);
|
||||||
}
|
}
|
||||||
updateDatabase(blob, player, newFormat);
|
updateDatabase(blob, player, newFormat);
|
||||||
}, 14));
|
}, 14));
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren