SteamWar/SpigotCore
Archiviert
13
0

Merge branch 'Vanilla-WE' of SteamWar/SpigotCore into master

Dieser Commit ist enthalten in:
Lixfel 2019-12-24 12:52:44 +01:00 committet von Gitea
Commit ea1bee9474
2 geänderte Dateien mit 21 neuen und 29 gelöschten Zeilen

Datei anzeigen

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

Datei anzeigen

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