SteamWar/SpigotCore
Archiviert
13
0

Vanilla-WE #20

Zusammengeführt
Lixfel hat 2 Commits von Vanilla-WE nach master 2019-12-24 12:52:49 +01:00 zusammengeführt
2 geänderte Dateien mit 21 neuen und 29 gelöschten Zeilen

Datei anzeigen

@ -35,8 +35,8 @@
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>FAWE</artifactId>
<version>1.14</version>
<artifactId>WorldEdit</artifactId>
<version>1.15</version>
<scope>provided</scope>
</dependency>
<dependency>
@ -51,11 +51,5 @@
<version>2.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>SpigotCore_12</artifactId>
<version>2.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

Datei anzeigen

@ -4,6 +4,7 @@ import com.sk89q.worldedit.EmptyClipboardException;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
import com.sk89q.worldedit.session.ClipboardHolder;
import org.bukkit.Bukkit;
@ -16,28 +17,30 @@ import java.io.InputStream;
class Schematic_14 {
private Schematic_14(){}
private static final String SCHEM = "schem";
private static final String SCHEMATIC = "schematic";
private static final ClipboardFormat SCHEMATIC = ClipboardFormats.findByAlias("schematic");
private static final ClipboardFormat SCHEM = ClipboardFormats.findByAlias("schem");
static byte[] getPlayerClipboard(Player player, boolean schemFormat) throws IOException, NoClipboardException {
ClipboardHolder clipboardHolder;
try {
clipboardHolder = WorldEditPlugin.getInstance().getSession(player).getClipboard();
clipboardHolder = getWorldEditPlugin().getSession(player).getClipboard();
} catch (EmptyClipboardException e) {
throw new NoClipboardException();
}
@SuppressWarnings("deprecation")
Clipboard clipboard = clipboardHolder.getClipboard();
if(clipboard == null)
throw new NoClipboardException();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
try{
if(schemFormat)
ClipboardFormats.findByExtension(SCHEM).getWriter(outputStream).write(clipboard);
else
ClipboardFormats.findByExtension(SCHEMATIC).getWriter(outputStream).write(clipboard);
if(schemFormat){
assert SCHEM != null;
SCHEM.getWriter(outputStream).write(clipboard);
}else{
assert SCHEMATIC != null;
SCHEMATIC.getWriter(outputStream).write(clipboard);
}
}catch(NullPointerException e){
throw new IOException(e);
}
@ -45,15 +48,7 @@ class Schematic_14 {
}
static void setPlayerClipboard(Player player, InputStream is, boolean schemFormat) throws IOException, NoClipboardException {
Clipboard clipboard;
try {
if (schemFormat)
clipboard = ClipboardFormats.findByExtension(SCHEM).getReader(is).read();
else
clipboard = ClipboardFormats.findByExtension(SCHEMATIC).getReader(is).read();
}catch(NullPointerException e){
throw new IOException(e);
}
Clipboard clipboard = getClipboard(is, schemFormat);
if (clipboard == null)
throw new NoClipboardException();
@ -64,10 +59,13 @@ class Schematic_14 {
static Clipboard getClipboard(InputStream is, boolean schemFormat) throws IOException, NoClipboardException {
try {
if(schemFormat)
return ClipboardFormats.findByExtension(SCHEM).getReader(is).read();
else
return ClipboardFormats.findByExtension(SCHEMATIC).getReader(is).read();
if(schemFormat){
assert SCHEM != null;
return SCHEM.getReader(is).read();
}else{
assert SCHEMATIC != null;
return SCHEMATIC.getReader(is).read();
}
} catch (NullPointerException e) {
throw new NoClipboardException();
}