Browse Source

Reworking schematic paste management (removing old version support)

RedstoneFuture 10 months ago
parent
commit
87cd93eeb0

+ 0 - 58
1_13/pom.xml

@@ -1,58 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ This file is part of MissileWars (https://github.com/Butzlabben/missilewars).
-  ~ Copyright (c) 2018-2021 Daniel Nägele.
-  ~
-  ~ MissileWars is free software: you can redistribute it and/or modify
-  ~ it under the terms of the GNU General Public License as published by
-  ~ the Free Software Foundation, either version 3 of the License, or
-  ~ (at your option) any later version.
-  ~
-  ~ MissileWars is distributed in the hope that it will be useful,
-  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
-  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  ~ GNU General Public License for more details.
-  ~
-  ~ You should have received a copy of the GNU General Public License
-  ~ along with MissileWars.  If not, see <https://www.gnu.org/licenses/>.
-  -->
-
-<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xmlns="http://maven.apache.org/POM/4.0.0"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <parent>
-        <artifactId>missilewars</artifactId>
-        <groupId>de.butzlabben</groupId>
-        <version>1.0</version>
-    </parent>
-
-    <modelVersion>4.0.0</modelVersion>
-
-    <artifactId>1_13</artifactId>
-
-    <dependencies>
-        <!-- WorldEdit (Bukkit) API -->
-        <dependency>
-            <groupId>com.sk89q.worldedit</groupId>
-            <artifactId>worldedit-bukkit</artifactId>
-            <version>7.0.0-SNAPSHOT</version>
-            <scope>provided</scope>
-
-            <exclusions>
-                <exclusion>
-                    <groupId>org.bstats</groupId>
-                    <artifactId>bstats-bukkit</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-
-        <!-- WorldEdit (Core) API -->
-        <dependency>
-            <groupId>com.sk89q.worldedit</groupId>
-            <artifactId>worldedit-core</artifactId>
-            <version>7.0.0-SNAPSHOT</version>
-            <scope>provided</scope>
-        </dependency>
-    </dependencies>
-
-</project>

+ 0 - 51
1_13/src/main/java/de/butzlabben/missilewars/missile/paste/r1_13/we/BlockFilterExtent.java

@@ -1,51 +0,0 @@
-/*
- * This file is part of MissileWars (https://github.com/Butzlabben/missilewars).
- * Copyright (c) 2018-2021 Daniel Nägele.
- *
- * MissileWars is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * MissileWars is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with MissileWars.  If not, see <https://www.gnu.org/licenses/>.
- */
-
-package de.butzlabben.missilewars.missile.paste.r1_13.we;
-
-import com.sk89q.worldedit.extent.AbstractDelegateExtent;
-import com.sk89q.worldedit.extent.Extent;
-import com.sk89q.worldedit.math.BlockVector3;
-import com.sk89q.worldedit.world.block.BaseBlock;
-import com.sk89q.worldedit.world.block.BlockTypes;
-import org.bukkit.Material;
-
-public class BlockFilterExtent extends AbstractDelegateExtent {
-
-    private Material material;
-
-    protected BlockFilterExtent(Extent extent) {
-        super(extent);
-    }
-
-    public BlockFilterExtent(Extent extent, Material material) {
-        this(extent);
-        this.material = material;
-    }
-
-    @Override
-    public BaseBlock getFullBlock(BlockVector3 position) {
-        BaseBlock block = super.getFullBlock(position);
-        if (block.getBlockType().toString().contains("stained_glass_pane")) {
-            block = BlockTypes.get(material.toString().toLowerCase() + "_pane").getDefaultState().toBaseBlock();
-        } else if (block.getBlockType().toString().contains("stained_glass")) {
-            block = BlockTypes.get(material.toString().toLowerCase()).getDefaultState().toBaseBlock();
-        }
-        return block;
-    }
-}

+ 0 - 118
1_13/src/main/java/de/butzlabben/missilewars/missile/paste/r1_13/we/R1_13Paster.java

@@ -1,118 +0,0 @@
-/*
- * This file is part of MissileWars (https://github.com/Butzlabben/missilewars).
- * Copyright (c) 2018-2021 Daniel Nägele.
- *
- * MissileWars is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * MissileWars is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with MissileWars.  If not, see <https://www.gnu.org/licenses/>.
- */
-
-package de.butzlabben.missilewars.missile.paste.r1_13.we;
-
-import com.sk89q.worldedit.EditSession;
-import com.sk89q.worldedit.WorldEdit;
-import com.sk89q.worldedit.bukkit.BukkitWorld;
-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.ClipboardReader;
-import com.sk89q.worldedit.extent.transform.BlockTransformExtent;
-import com.sk89q.worldedit.function.mask.ExistingBlockMask;
-import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
-import com.sk89q.worldedit.function.operation.Operation;
-import com.sk89q.worldedit.function.operation.Operations;
-import com.sk89q.worldedit.math.BlockVector3;
-import com.sk89q.worldedit.math.transform.AffineTransform;
-import com.sk89q.worldedit.regions.CuboidRegion;
-import com.sk89q.worldedit.session.ClipboardHolder;
-import com.sk89q.worldedit.world.World;
-import java.io.File;
-import java.io.FileInputStream;
-import java.util.HashSet;
-import java.util.Set;
-import org.bukkit.Material;
-import org.bukkit.block.Block;
-import org.bukkit.plugin.java.JavaPlugin;
-import org.bukkit.scheduler.BukkitRunnable;
-import org.bukkit.util.Vector;
-
-/**
- * @author Butzlabben
- * @since 23.09.2018
- */
-public class R1_13Paster {
-
-    public void pasteMissile(File schematic, org.bukkit.util.Vector pos, int rotation, org.bukkit.World world,
-                             Material glassBlockReplace, int radius, Material replaceType, JavaPlugin plugin, int replaceTicks) {
-        try {
-            World weWorld = new BukkitWorld(world);
-            ClipboardFormat format = ClipboardFormats.findByFile(schematic);
-
-            try (ClipboardReader reader = format.getReader(new FileInputStream(schematic));
-                 EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(weWorld, -1)) {
-                ClipboardHolder clipboardHolder = new ClipboardHolder(reader.read());
-                Clipboard clipboard = clipboardHolder.getClipboard();
-                AffineTransform transform = new AffineTransform();
-                transform = transform.rotateY(rotation);
-
-                BlockTransformExtent extent = new BlockTransformExtent(clipboard, transform);
-                ForwardExtentCopy copy = new ForwardExtentCopy(new BlockFilterExtent(extent, glassBlockReplace), clipboard.getRegion(), clipboard.getOrigin(), editSession, BlockVector3.at(pos.getX(), pos.getY(), pos.getZ()));
-                copy.setTransform(transform);
-                copy.setSourceMask(new ExistingBlockMask(clipboard));
-
-                Operations.complete(copy);
-            }
-
-            // Replace given blocks
-            Set<Block> replace = new HashSet<>();
-            BlockVector3 min = BlockVector3.at(pos.getX() - radius, pos.getY() - radius, pos.getZ() - radius);
-            BlockVector3 max = BlockVector3.at(pos.getX() + radius, pos.getY() + radius, pos.getZ() + radius);
-            for (BlockVector3 v : new CuboidRegion(min, max)) {
-                Block b = world.getBlockAt(v.getBlockX(), v.getBlockY(), v.getBlockZ());
-                if (b.getType() == replaceType) {
-                    replace.add(b);
-                }
-            }
-            new BukkitRunnable() {
-                @Override
-                public void run() {
-                    replace.forEach(b -> b.setType(Material.AIR));
-                }
-            }.runTaskLater(plugin, replaceTicks);
-
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    public void pasteSchematic(File schematic, Vector pos, org.bukkit.World world) {
-        try {
-            World weWorld = new BukkitWorld(world);
-
-            ClipboardFormat format = ClipboardFormats.findByFile(schematic);
-            try (ClipboardReader reader = format.getReader(new FileInputStream(schematic));
-                 EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(weWorld, -1)) {
-                ClipboardHolder clipboard = new ClipboardHolder(reader.read());
-
-                Operation operation = clipboard
-                        .createPaste(editSession)
-                        .to(BlockVector3.at(pos.getX(), pos.getY(), pos.getZ()))
-                        .ignoreAirBlocks(true)
-                        .build();
-                Operations.complete(operation);
-
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-}

BIN
1_13_FAWE/lib/FastAsyncWorldEdit.jar


+ 0 - 44
1_13_FAWE/pom.xml

@@ -1,44 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ This file is part of MissileWars (https://github.com/Butzlabben/missilewars).
-  ~ Copyright (c) 2018-2021 Daniel Nägele.
-  ~
-  ~ MissileWars is free software: you can redistribute it and/or modify
-  ~ it under the terms of the GNU General Public License as published by
-  ~ the Free Software Foundation, either version 3 of the License, or
-  ~ (at your option) any later version.
-  ~
-  ~ MissileWars is distributed in the hope that it will be useful,
-  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
-  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  ~ GNU General Public License for more details.
-  ~
-  ~ You should have received a copy of the GNU General Public License
-  ~ along with MissileWars.  If not, see <https://www.gnu.org/licenses/>.
-  -->
-
-<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xmlns="http://maven.apache.org/POM/4.0.0"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <parent>
-        <artifactId>missilewars</artifactId>
-        <groupId>de.butzlabben</groupId>
-        <version>1.0</version>
-    </parent>
-
-    <modelVersion>4.0.0</modelVersion>
-
-    <artifactId>1_13_FAWE</artifactId>
-
-    <dependencies>
-        <!-- FAWE API -->
-        <dependency>
-            <groupId>com.sk98q.worldedit</groupId>
-            <artifactId>FastAsnycWorldEdit</artifactId>
-            <version>1.0</version>
-            <scope>system</scope>
-            <systemPath>${pom.basedir}/lib/FastAsyncWorldEdit.jar</systemPath>
-        </dependency>
-    </dependencies>
-
-</project>

+ 0 - 97
1_13_FAWE/src/main/java/de/butzlabben/missilewars/missile/paste/r1_13/fawe/R1_13Paster.java

@@ -1,97 +0,0 @@
-/*
- * This file is part of MissileWars (https://github.com/Butzlabben/missilewars).
- * Copyright (c) 2018-2021 Daniel Nägele.
- *
- * MissileWars is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * MissileWars is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with MissileWars.  If not, see <https://www.gnu.org/licenses/>.
- */
-
-package de.butzlabben.missilewars.missile.paste.r1_13.fawe;
-
-import com.sk89q.worldedit.EditSession;
-import com.sk89q.worldedit.Vector;
-import com.sk89q.worldedit.WorldEdit;
-import com.sk89q.worldedit.bukkit.BukkitWorld;
-import com.sk89q.worldedit.extent.clipboard.Clipboard;
-import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
-import com.sk89q.worldedit.function.mask.ExistingBlockMask;
-import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
-import com.sk89q.worldedit.function.operation.Operations;
-import com.sk89q.worldedit.math.transform.AffineTransform;
-import com.sk89q.worldedit.regions.CuboidRegion;
-import com.sk89q.worldedit.world.World;
-import java.io.File;
-import java.util.HashSet;
-import java.util.Set;
-import org.bukkit.Material;
-import org.bukkit.block.Block;
-import org.bukkit.plugin.java.JavaPlugin;
-import org.bukkit.scheduler.BukkitRunnable;
-
-public class R1_13Paster {
-
-    public void pasteMissile(File schematic, org.bukkit.util.Vector pos, int rotation, org.bukkit.World world,
-                             Material glassBlockReplace, int radius, Material replaceType, JavaPlugin plugin, int replaceTicks) {
-        try {
-            World weWorld = new BukkitWorld(world);
-
-            EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(weWorld, -1);
-            Clipboard clipboard = ClipboardFormat.findByFile(schematic).load(schematic).getClipboard();
-
-            AffineTransform transform = new AffineTransform();
-            transform = transform.rotateY(rotation);
-
-            Vector origin = new Vector(clipboard.getOrigin().getX(), clipboard.getOrigin().getY(), clipboard.getOrigin().getZ());
-//            BlockTransformExtent extent = new BlockTransformExtent(clipboard, transform, ((BukkitWorld) weWorld).getWorldData().getBlockRegistry());
-            ForwardExtentCopy copy = new ForwardExtentCopy(clipboard, clipboard.getRegion(), origin, editSession, new Vector(pos.getX(), pos.getY(), pos.getZ()));
-            copy.setTransform(transform);
-            copy.setSourceMask(new ExistingBlockMask(clipboard));
-
-            Operations.complete(copy);
-
-
-            // Replace given blocks
-            Set<Block> replace = new HashSet<>();
-            Vector min = new Vector(pos.getX() - radius, pos.getY() - radius, pos.getZ() - radius);
-            Vector max = new Vector(pos.getX() + radius, pos.getY() + radius, pos.getZ() + radius);
-            for (Vector v : new CuboidRegion(min, max)) {
-                Block b = world.getBlockAt(v.getBlockX(), v.getBlockY(), v.getBlockZ());
-                if (b.getType() == replaceType) {
-                    replace.add(b);
-                }
-            }
-            new BukkitRunnable() {
-                @Override
-                public void run() {
-                    replace.forEach(b -> b.setType(Material.AIR));
-                }
-            }.runTaskLater(plugin, replaceTicks);
-
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    public void pasteSchematic(File schematic, org.bukkit.util.Vector pos, org.bukkit.World world) {
-        try {
-            World weWorld = new BukkitWorld(world);
-
-            EditSession editSession = ClipboardFormat.findByFile(schematic).load(schematic)
-                    .paste(weWorld, new Vector(pos.getX(), pos.getY(), pos.getZ()), false, false, null);
-            editSession.flushQueue();
-
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-}

+ 1 - 1
FAWE_Paster/pom.xml

@@ -28,7 +28,7 @@
 
     <modelVersion>4.0.0</modelVersion>
 
-    <artifactId>1_16_FAWE</artifactId>
+    <artifactId>FAWE_Paster</artifactId>
 
     <dependencies>
         <!-- FAWE API -->

+ 36 - 26
1_16_FAWE/src/main/java/de/butzlabben/missilewars/missile/paste/r1_16/fawe/R1_16Paster.java → FAWE_Paster/src/main/java/de/butzlabben/missilewars/missile/paste/v1_20/fawe/FAWE_Paster.java

@@ -16,38 +16,38 @@
  * along with MissileWars.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-package de.butzlabben.missilewars.missile.paste.r1_16.fawe;
+package de.butzlabben.missilewars.missile.paste.v1_20.fawe;
 
 import com.sk89q.worldedit.WorldEdit;
-import com.sk89q.worldedit.bukkit.BukkitAdapter;
 import com.sk89q.worldedit.bukkit.BukkitWorld;
-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.ClipboardReader;
 import com.sk89q.worldedit.function.operation.Operation;
 import com.sk89q.worldedit.function.operation.Operations;
 import com.sk89q.worldedit.math.BlockVector3;
 import com.sk89q.worldedit.math.transform.AffineTransform;
-import com.sk89q.worldedit.regions.CuboidRegion;
 import com.sk89q.worldedit.session.ClipboardHolder;
 import com.sk89q.worldedit.world.World;
 import org.bukkit.Material;
+import org.bukkit.block.Block;
 import org.bukkit.plugin.java.JavaPlugin;
 import org.bukkit.scheduler.BukkitRunnable;
 import org.bukkit.util.Vector;
 
 import java.io.File;
-import java.util.Set;
+import java.io.FileInputStream;
 import java.util.logging.Level;
 
 /**
  * @author Daniel Nägele
  */
-public class R1_16Paster {
+public class FAWE_Paster {
 
     public void pasteMissile(File schematic, Vector locationVec, int rotation, org.bukkit.World world,
                              Material glassBlockReplace, int replaceRadius, Material replaceMaterial, int replaceTicks, JavaPlugin plugin) {
         
-        pasteSchematic(schematic, locationVec, world, rotation, plugin);
+        pasteSchematic(schematic, locationVec, rotation, world, plugin);
         
         // Remove "Replacer-Block" after a short time to update the pasted schematic structure via (normal) WorldEdit:
         new BukkitRunnable() {
@@ -62,19 +62,20 @@ public class R1_16Paster {
      * This method executes the paste command via FAWE.
      * 
      * @param schematic (File) the target WorldEdit schematic file
-     * @param locationVec (Vector) 
+     * @param locationVec (Vector) the abstract block location
      * @param world (World) the target world for the WorldEdit action
      * @param rotation (int) the target schematic rotation
      * @param plugin (JavaPlugin) the basis plugin
      */
-    public void pasteSchematic(File schematic, Vector locationVec, org.bukkit.World world, int rotation, JavaPlugin plugin) {
+    public void pasteSchematic(File schematic, Vector locationVec, int rotation, org.bukkit.World world, JavaPlugin plugin) {
         World weWorld = new BukkitWorld(world);
-        BlockVector3 blockVec = fromBukkitVector(locationVec);
-
-        try (Clipboard clipboard = ClipboardFormats.findByFile(schematic).load(schematic); 
+        BlockVector3 blockVec = getBlockVector(locationVec);
+        ClipboardFormat clipboardFormat = ClipboardFormats.findByFile(schematic);
+        
+        try (ClipboardReader clipboardReader = clipboardFormat.getReader(new FileInputStream(schematic));
              var session = WorldEdit.getInstance().newEditSession(weWorld)) {
             
-            ClipboardHolder clipboardHolder = new ClipboardHolder(clipboard);
+            ClipboardHolder clipboardHolder = new ClipboardHolder(clipboardReader.read());
             clipboardHolder.setTransform(new AffineTransform().rotateY(rotation));
             
             Operation pasteBuilder = clipboardHolder
@@ -94,23 +95,32 @@ public class R1_16Paster {
      * This method removes the temporary "Replacer-Block", so that the (asynchronously) 
      * paste structure via FAWE gets an update.
      * 
-     * @param locationVec (Vector) 
+     * @param locationVec (Vector) the abstract block location
      * @param world (World) the target world for the WorldEdit action
-     * @param radius (int) the configured update-radius
+     * @param replaceRadius (int) the configured "Replace radius" (= half diagonals)
      * @param replaceMaterial (Material) the target material for the replacement
      */
-    private void removeTempBlock(Vector locationVec, org.bukkit.World world, int radius, Material replaceMaterial) {
-        World weWorld = new BukkitWorld(world);
-        BlockVector3 blockVec = fromBukkitVector(locationVec);
-        
-        var radiusVec = BlockVector3.at(radius, radius, radius);
-        
-        weWorld.replaceBlocks(new CuboidRegion(blockVec.subtract(radiusVec), blockVec.add(radiusVec)), 
-                Set.of(BukkitAdapter.adapt(replaceMaterial.createBlockData()).toBaseBlock()), 
-                BukkitAdapter.adapt(Material.AIR.createBlockData()));
+    public void removeTempBlock(Vector locationVec, org.bukkit.World world, int replaceRadius, Material replaceMaterial) {
+        int startX = locationVec.getBlockX() - replaceRadius;
+        int endX = locationVec.getBlockX() + replaceRadius;
+        int startY = locationVec.getBlockY() - replaceRadius;
+        int endY = locationVec.getBlockY() + replaceRadius;
+        int startZ = locationVec.getBlockZ() - replaceRadius;
+        int endZ = locationVec.getBlockZ() + replaceRadius;
+    
+        for (int x = startX; x <= endX; x++) {
+            for (int y = startY; y <= endY; y++) {
+                for (int z = startZ; z <= endZ; z++) {
+                    Block block = world.getBlockAt(x, y, z);
+                    if (block.getType() == replaceMaterial) {
+                        block.setType(Material.AIR);
+                    }
+                }
+            }
+        }
     }
     
-    private BlockVector3 fromBukkitVector(org.bukkit.util.Vector pos) {
-        return BlockVector3.at(pos.getX(), pos.getY(), pos.getZ());
+    public static BlockVector3 getBlockVector(org.bukkit.util.Vector locationVec) {
+        return BlockVector3.at(locationVec.getX(), locationVec.getY(), locationVec.getZ());
     }
 }

+ 1 - 13
missilewars-plugin/pom.xml

@@ -50,19 +50,7 @@
     <dependencies>
         <dependency>
             <groupId>de.butzlabben</groupId>
-            <artifactId>1_13</artifactId>
-            <version>1.0</version>
-            <scope>compile</scope>
-        </dependency>
-        <dependency>
-            <groupId>de.butzlabben</groupId>
-            <artifactId>1_13_FAWE</artifactId>
-            <version>1.0</version>
-            <scope>compile</scope>
-        </dependency>
-        <dependency>
-            <groupId>de.butzlabben</groupId>
-            <artifactId>1_16_FAWE</artifactId>
+            <artifactId>FAWE_Paster</artifactId>
             <version>1.0</version>
             <scope>compile</scope>
         </dependency>

+ 4 - 4
missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/schematics/paste/R1_16FawePasteProvider.java → missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/schematics/paste/FawePasteProvider.java

@@ -21,7 +21,7 @@ package de.butzlabben.missilewars.game.schematics.paste;
 import de.butzlabben.missilewars.MissileWars;
 import de.butzlabben.missilewars.configuration.Config;
 import de.butzlabben.missilewars.game.Team;
-import de.butzlabben.missilewars.missile.paste.r1_16.fawe.R1_16Paster;
+import de.butzlabben.missilewars.missile.paste.v1_20.fawe.FAWE_Paster;
 import de.butzlabben.missilewars.util.version.ColorConverter;
 import org.bukkit.World;
 import org.bukkit.util.Vector;
@@ -32,9 +32,9 @@ import java.io.File;
  * @author Butzlabben
  * @since 23.09.2018
  */
-public class R1_16FawePasteProvider implements Paster {
+public class FawePasteProvider implements Paster {
 
-    R1_16Paster paster = new R1_16Paster();
+    FAWE_Paster paster = new FAWE_Paster();
 
     @Override
     public void pasteMissile(File schematic, Vector position, int rotation, World world, Team team) {
@@ -44,6 +44,6 @@ public class R1_16FawePasteProvider implements Paster {
 
     @Override
     public void pasteSchematic(File schematic, Vector position, int rotation, World world) {
-        paster.pasteSchematic(schematic, position, world, rotation, MissileWars.getInstance());
+        paster.pasteSchematic(schematic, position, rotation, world, MissileWars.getInstance());
     }
 }

+ 7 - 13
missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/schematics/paste/PasteProvider.java

@@ -21,7 +21,7 @@ package de.butzlabben.missilewars.game.schematics.paste;
 
 import de.butzlabben.missilewars.Logger;
 import de.butzlabben.missilewars.MissileWars;
-import de.butzlabben.missilewars.util.version.VersionUtil;
+import lombok.Getter;
 
 /**
  * @author Butzlabben
@@ -29,27 +29,21 @@ import de.butzlabben.missilewars.util.version.VersionUtil;
  */
 public class PasteProvider {
 
+    @Getter
     private static final Paster paster;
 
     static {
         if (MissileWars.getInstance().foundFAWE()) {
-            if (VersionUtil.getVersion() < 16) {
-                paster = new R1_13FawePasteProvider();
-                Logger.DEBUG.log("Chose 1.13 FAWE paster");
-            } else {
-                paster = new R1_16FawePasteProvider();
-                Logger.DEBUG.log("Chose 1.16 FAWE paster");
-            }
+            paster = new FawePasteProvider();
+            Logger.DEBUG.log("Chose FAWE paster.");
         } else {
-            paster = new R1_13WEPasteProvider();
-            Logger.DEBUG.log("Chose 1.13 WE paster");
+            // FAWE Paster works also for (normal) WorldEdit
+            paster = new FawePasteProvider();
+            Logger.DEBUG.log("Chose FAWE paster.");
         }
     }
 
     private PasteProvider() {
     }
 
-    public static Paster getPaster() {
-        return paster;
-    }
 }

+ 0 - 49
missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/schematics/paste/R1_13FawePasteProvider.java

@@ -1,49 +0,0 @@
-/*
- * This file is part of MissileWars (https://github.com/Butzlabben/missilewars).
- * Copyright (c) 2018-2021 Daniel Nägele.
- *
- * MissileWars is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * MissileWars is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with MissileWars.  If not, see <https://www.gnu.org/licenses/>.
- */
-
-package de.butzlabben.missilewars.game.schematics.paste;
-
-import de.butzlabben.missilewars.MissileWars;
-import de.butzlabben.missilewars.configuration.Config;
-import de.butzlabben.missilewars.game.Team;
-import de.butzlabben.missilewars.missile.paste.r1_13.fawe.R1_13Paster;
-import de.butzlabben.missilewars.util.version.ColorConverter;
-import org.bukkit.World;
-import org.bukkit.util.Vector;
-
-import java.io.File;
-
-/**
- * @author Butzlabben
- * @since 23.09.2018
- */
-public class R1_13FawePasteProvider implements Paster {
-
-    R1_13Paster paster = new R1_13Paster();
-
-    @Override
-    public void pasteMissile(File schematic, Vector position, int rotation, World world, Team team) {
-        paster.pasteMissile(schematic, position, rotation, world, ColorConverter.getGlassFromColorCode(team.getColorCode()),
-                Config.getReplaceRadius(), Config.getStartReplace(), MissileWars.getInstance(), Config.getReplaceTicks());
-    }
-
-    @Override
-    public void pasteSchematic(File schematic, Vector position, int rotation, World world) {
-        paster.pasteSchematic(schematic, position, world);
-    }
-}

+ 0 - 49
missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/schematics/paste/R1_13WEPasteProvider.java

@@ -1,49 +0,0 @@
-/*
- * This file is part of MissileWars (https://github.com/Butzlabben/missilewars).
- * Copyright (c) 2018-2021 Daniel Nägele.
- *
- * MissileWars is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * MissileWars is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with MissileWars.  If not, see <https://www.gnu.org/licenses/>.
- */
-
-package de.butzlabben.missilewars.game.schematics.paste;
-
-import de.butzlabben.missilewars.MissileWars;
-import de.butzlabben.missilewars.configuration.Config;
-import de.butzlabben.missilewars.game.Team;
-import de.butzlabben.missilewars.missile.paste.r1_13.we.R1_13Paster;
-import de.butzlabben.missilewars.util.version.ColorConverter;
-import org.bukkit.World;
-import org.bukkit.util.Vector;
-
-import java.io.File;
-
-/**
- * @author Butzlabben
- * @since 23.09.2018
- */
-public class R1_13WEPasteProvider implements Paster {
-
-    R1_13Paster paster = new R1_13Paster();
-
-    @Override
-    public void pasteMissile(File schematic, Vector position, int rotation, World world, Team team) {
-        paster.pasteMissile(schematic, position, rotation, world, ColorConverter.getGlassFromColorCode(team.getColorCode()),
-                Config.getReplaceRadius(), Config.getStartReplace(), MissileWars.getInstance(), Config.getReplaceTicks());
-    }
-
-    @Override
-    public void pasteSchematic(File schematic, Vector position, int rotation, World world) {
-        paster.pasteSchematic(schematic, position, world);
-    }
-}

+ 1 - 3
pom.xml

@@ -33,9 +33,7 @@
     <version>1.0</version>
 
     <modules>
-        <module>1_13</module>
-        <module>1_13_FAWE</module>
-        <module>1_16_FAWE</module>
+        <module>FAWE_Paster</module>
         <module>missilewars-plugin</module>
     </modules>