Making BauSystem fully 1.15 compatible
Dieser Commit ist enthalten in:
Ursprung
94a138b9ec
Commit
3e6495eb1a
@ -33,6 +33,12 @@
|
||||
<version>1.12</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>steamwar</groupId>
|
||||
<artifactId>WorldEdit</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>steamwar</groupId>
|
||||
<artifactId>BauSystem_API</artifactId>
|
||||
@ -42,7 +48,7 @@
|
||||
<dependency>
|
||||
<groupId>steamwar</groupId>
|
||||
<artifactId>FAWE</artifactId>
|
||||
<version>1.0</version>
|
||||
<version>1.12</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
17
BauSystem_12/src/de/steamwar/bausystem/world/RegionListener_12.java
Normale Datei
17
BauSystem_12/src/de/steamwar/bausystem/world/RegionListener_12.java
Normale Datei
@ -0,0 +1,17 @@
|
||||
package de.steamwar.bausystem.world;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
class RegionListener_12 {
|
||||
private RegionListener_12(){}
|
||||
|
||||
static boolean isWorldEditCommand(String command) {
|
||||
if (command.startsWith("/")) {
|
||||
command = command.replaceFirst("/", "");
|
||||
}
|
||||
command = command.toLowerCase();
|
||||
return ((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit")).getWorldEdit().getPlatformManager()
|
||||
.getCommandManager().getDispatcher().get(command) != null;
|
||||
}
|
||||
}
|
@ -1,15 +1,36 @@
|
||||
package de.steamwar.bausystem.world;
|
||||
|
||||
import com.boydti.fawe.FaweAPI;
|
||||
import com.boydti.fawe.object.schematic.Schematic;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
public class Region_12 {
|
||||
private Region_12(){}
|
||||
|
||||
static void paste(Schematic schem, Vector v, AffineTransform aT){
|
||||
static void paste(File file, int x, int y, int z, boolean rotate){
|
||||
Schematic schem;
|
||||
try {
|
||||
schem = FaweAPI.load(file);
|
||||
}catch(IOException e){
|
||||
throw new SecurityException("Bausystem schematic not found", e);
|
||||
}
|
||||
Vector dimensions = Objects.requireNonNull(schem.getClipboard()).getDimensions();
|
||||
Vector v = new Vector(x, y, z);
|
||||
Vector offset = new Vector(schem.getClipboard().getRegion().getMinimumPoint()).subtract(schem.getClipboard().getOrigin());
|
||||
AffineTransform aT = new AffineTransform();
|
||||
if(rotate){
|
||||
aT = aT.rotateY(180);
|
||||
v = v.add(dimensions.getX()/2 + dimensions.getX()%2, 0, dimensions.getZ()/2 + dimensions.getZ()%2).subtract(offset.multiply(-1, 1, -1)).subtract(1, 0, 1);
|
||||
}else{
|
||||
v = v.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()/2 - dimensions.getZ()%2).subtract(offset);
|
||||
}
|
||||
schem.paste(new BukkitWorld(Bukkit.getWorlds().get(0)), v, false, true, aT).flushQueue();
|
||||
}
|
||||
}
|
||||
|
@ -40,8 +40,8 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>steamwar</groupId>
|
||||
<artifactId>FAWE</artifactId>
|
||||
<version>1.14</version>
|
||||
<artifactId>WorldEdit</artifactId>
|
||||
<version>1.15</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
15
BauSystem_15/src/de/steamwar/bausystem/world/RegionListener_15.java
Normale Datei
15
BauSystem_15/src/de/steamwar/bausystem/world/RegionListener_15.java
Normale Datei
@ -0,0 +1,15 @@
|
||||
package de.steamwar.bausystem.world;
|
||||
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
|
||||
class RegionListener_15 {
|
||||
private RegionListener_15(){}
|
||||
|
||||
static boolean isWorldEditCommand(String command) {
|
||||
if (command.startsWith("/")) {
|
||||
command = command.replaceFirst("/", "");
|
||||
}
|
||||
command = command.toLowerCase();
|
||||
return WorldEdit.getInstance().getPlatformManager().getPlatformCommandManager().getCommandManager().containsCommand(command);
|
||||
}
|
||||
}
|
@ -1,16 +1,47 @@
|
||||
package de.steamwar.bausystem.world;
|
||||
|
||||
import com.boydti.fawe.object.schematic.Schematic;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
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.ClipboardFormats;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
public class Region_15 {
|
||||
private Region_15(){}
|
||||
|
||||
static void paste(Schematic schem, Vector v, AffineTransform aT){
|
||||
schem.paste(new BukkitWorld(Bukkit.getWorlds().get(0)), BlockVector3.at(v.getX(), v.getY(), v.getZ()), false, true, aT).flushQueue();
|
||||
static void paste(File file, int x, int y, int z, boolean rotate){
|
||||
Clipboard clipboard;
|
||||
try {
|
||||
clipboard = Objects.requireNonNull(ClipboardFormats.findByFile(file)).getReader(new FileInputStream(file)).read();
|
||||
} catch (NullPointerException | IOException e) {
|
||||
throw new SecurityException("Bausystem schematic not found", e);
|
||||
}
|
||||
|
||||
BlockVector3 dimensions = clipboard.getDimensions();
|
||||
BlockVector3 v = BlockVector3.at(x, y, z);
|
||||
BlockVector3 offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
|
||||
AffineTransform aT = new AffineTransform();
|
||||
if(rotate){
|
||||
aT = aT.rotateY(180);
|
||||
v = v.add(dimensions.getX()/2 + dimensions.getX()%2, 0, dimensions.getZ()/2 + dimensions.getZ()%2).subtract(offset.multiply(-1, 1, -1)).subtract(1, 0, 1);
|
||||
}else{
|
||||
v = v.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()/2 - dimensions.getZ()%2).subtract(offset);
|
||||
}
|
||||
|
||||
EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1);
|
||||
ClipboardHolder ch = new ClipboardHolder(clipboard);
|
||||
ch.setTransform(aT);
|
||||
Operations.completeBlindly(ch.createPaste(e).to(v).build());
|
||||
e.flushSession();
|
||||
}
|
||||
}
|
||||
|
@ -67,11 +67,5 @@
|
||||
<version>1.14</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>steamwar</groupId>
|
||||
<artifactId>FAWE</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -1,9 +1,5 @@
|
||||
package de.steamwar.bausystem.world;
|
||||
|
||||
import com.boydti.fawe.FaweAPI;
|
||||
import com.boydti.fawe.object.schematic.Schematic;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
@ -13,6 +9,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ArenaSection extends Region {
|
||||
|
||||
@ -21,7 +18,7 @@ public class ArenaSection extends Region {
|
||||
|
||||
private ArenaSection(ConfigurationSection config) {
|
||||
super(config);
|
||||
testblock = new Region(config.getConfigurationSection("testblock"));
|
||||
testblock = new Region(Objects.requireNonNull(config.getConfigurationSection("testblock")));
|
||||
protectSchematic = config.getString("protection");
|
||||
}
|
||||
|
||||
@ -44,23 +41,6 @@ public class ArenaSection extends Region {
|
||||
|
||||
public void protect(){
|
||||
File file = new File(BauSystem.SECTION_PATH + protectSchematic);
|
||||
Schematic schem;
|
||||
try {
|
||||
schem = FaweAPI.load(file);
|
||||
}catch(IOException e){
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
Vector dimensions = schem.getClipboard().getDimensions();
|
||||
Vector v = new Vector(minX + sizeX/2, testblock.minY-1, minZ + sizeZ/2);
|
||||
Vector offset = new Vector(schem.getClipboard().getRegion().getMinimumPoint()).subtract(schem.getClipboard().getOrigin());
|
||||
AffineTransform aT = new AffineTransform();
|
||||
if(rotate){
|
||||
aT = aT.rotateY(180);
|
||||
v = v.add(dimensions.getX()/2 + dimensions.getX()%2, 0, dimensions.getZ()/2 + dimensions.getZ()%2).subtract(offset.multiply(-1, 1, -1)).subtract(1, 0, 1);
|
||||
}else{
|
||||
v = v.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()/2 - dimensions.getZ()%2).subtract(offset);
|
||||
}
|
||||
Region.paste(schem, v, aT);
|
||||
paste(file, minX + sizeX/2, testblock.minY-1, minZ + sizeZ/2, rotate);
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,11 @@
|
||||
package de.steamwar.bausystem.world;
|
||||
|
||||
import com.boydti.fawe.FaweAPI;
|
||||
import com.boydti.fawe.object.schematic.Schematic;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.core.Core;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Region {
|
||||
final int sizeX;
|
||||
@ -45,32 +40,16 @@ public class Region {
|
||||
|
||||
public void reset(){
|
||||
File file = new File(BauSystem.SECTION_PATH + schematic);
|
||||
Schematic schem;
|
||||
try {
|
||||
schem = FaweAPI.load(file);
|
||||
}catch(IOException e){
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
Vector dimensions = schem.getClipboard().getDimensions();
|
||||
Vector v = new Vector(minX + sizeX/2, minY, minZ + sizeZ/2);
|
||||
Vector offset = new Vector(schem.getClipboard().getRegion().getMinimumPoint()).subtract(schem.getClipboard().getOrigin());
|
||||
AffineTransform aT = new AffineTransform();
|
||||
if(rotate){
|
||||
aT = aT.rotateY(180);
|
||||
v = v.add(dimensions.getX()/2 + dimensions.getX()%2, 0, dimensions.getZ()/2 + dimensions.getZ()%2).subtract(offset.multiply(-1, 1, -1)).subtract(1, 0, 1);
|
||||
}else{
|
||||
v = v.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()/2 - dimensions.getZ()%2).subtract(offset);
|
||||
}
|
||||
paste(schem, v, aT);
|
||||
paste(file, minX + sizeX/2, minY, minZ + sizeZ/2, rotate);
|
||||
}
|
||||
|
||||
static void paste(Schematic schem, Vector v, AffineTransform aT){
|
||||
static void paste(File file, int x, int y, int z, boolean rotate){
|
||||
switch(Core.getVersion()){
|
||||
case 15:
|
||||
Region_15.paste(schem, v, aT);
|
||||
Region_15.paste(file, x, y, z, rotate);
|
||||
break;
|
||||
default:
|
||||
Region_12.paste(schem, v, aT);
|
||||
Region_12.paste(file, x, y, z, rotate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,17 @@
|
||||
package de.steamwar.bausystem.world;
|
||||
|
||||
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import org.bukkit.Bukkit;
|
||||
import de.steamwar.core.Core;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.*;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
public class RegionListener implements Listener {
|
||||
@ -49,12 +50,12 @@ public class RegionListener implements Listener {
|
||||
}
|
||||
|
||||
private boolean isWorldEditCommand(String command) {
|
||||
if (command.startsWith("/")) {
|
||||
command = command.replaceFirst("/", "");
|
||||
switch(Core.getVersion()){
|
||||
case 15:
|
||||
return RegionListener_15.isWorldEditCommand(command);
|
||||
default:
|
||||
return RegionListener_12.isWorldEditCommand(command);
|
||||
}
|
||||
command = command.toLowerCase();
|
||||
return ((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit")).getWorldEdit().getPlatformManager()
|
||||
.getCommandManager().getDispatcher().get(command) != null;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
6
pom.xml
6
pom.xml
@ -48,12 +48,6 @@
|
||||
<version>2.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>steamwar</groupId>
|
||||
<artifactId>WorldEdit</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>steamwar</groupId>
|
||||
<artifactId>F3NPerm</artifactId>
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren